Commit 434393cc authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

Synchronize rfc-51-mvd_modules with branch develop

Conflicts:
	CMakeLists.txt
parents 25cfbc70 52fbf20c
......@@ -32,7 +32,7 @@
#include <QPixmap>
#include <QSplashScreen>
#define USE_SPLASH_SCREEN 0
#define USE_SPLASH_SCREEN ( ( !defined( _DEBUG ) && 0 ) || 0 )
//
// System includes (sorted by alphabetic order)
......@@ -72,7 +72,7 @@ main( int argc, char* argv[] )
//
// 0. Splash-screen.
#if !defined( _DEBUG ) && USE_SPLASH_SCREEN
#if USE_SPLASH_SCREEN
QPixmap pixmap(QLatin1String( ":/images/application_splash" ));
QSplashScreen splash(pixmap);
splash.show();
......@@ -155,21 +155,12 @@ main( int argc, char* argv[] )
//
// 3. Show window.
#if defined( _DEBUG )
// Usefull when developping/debugging to avoid overlapping other windows.
mainWindow.show();
#else // _DEBUG
#if USE_SPLASH_SCREEN
splash.finish( &mainWindow );
#endif // USE_SPLASH_SCREEN
// TODO: Correctly manage main-window state via application settings.
mainWindow.showMaximized();
#endif // _DEBUG
//
// 4. Check OpenGL capabilities
if( !mainWindow.CheckGLCapabilities() )
......
......@@ -790,8 +790,7 @@ MainWindow
< HistogramWidget, HistogramController, QDockWidget >
( "HISTOGRAM",
tr( "Histogram" ),
Qt::RightDockWidgetArea,
false
Qt::RightDockWidgetArea
);
tabifyDockWidget( m_QuicklookViewDock, m_HistogramDock );
......@@ -830,7 +829,8 @@ MainWindow
< ColorDynamicsWidget, ColorDynamicsController, QDockWidget >
( "COLOR_DYNAMICS",
tr( "Color dynamics" ),
Qt::RightDockWidgetArea
Qt::RightDockWidgetArea,
I18nMainWindow::DOCK_LAYOUT_SCROLLABLE
);
// Tabify dock-widgets.
......@@ -1184,19 +1184,19 @@ MainWindow
stackedLayerModel->SetCurrent( imageModel );
bool hasReference = stackedLayerModel->HasReference();
if( !hasReference && srt!=SRT_UNKNOWN )
stackedLayerModel->SetReference( imageModel );
if( gcs==0 )
{
if( unk==0 )
{
if( srt!=SRT_UNKNOWN )
stackedLayerModel->SetReference( imageModel );
else if( hasReference && srt==SRT_UNKNOWN )
UserZoomExtent();
}
}
else if( unk==0 && srt==SRT_UNKNOWN )
stackedLayerModel->SetReference( StackedLayerModel::NIL_INDEX );
//
// Set zoom-level which forces image-views refresh.
if( !hasReference )
UserZoomExtent();
//
// Re-activate rendering of image-views.
m_ImageView->SetBypassRenderingEnabled( bypassImageView );
......@@ -1553,7 +1553,7 @@ MainWindow
( "APPLICATIONS_BROWSER",
tr( "OTB-Applications browser" ),
Qt::RightDockWidgetArea,
true
I18nMainWindow::DOCK_LAYOUT_FLOATING
);
tabifyDockWidget( m_HistogramDock, m_OtbApplicationsBrowserDock );
......
......@@ -247,7 +247,7 @@ StackedLayerModel
//
// Remember new current index.
SizeType current =
index>=m_Current
index>m_Current
? m_Current
: ( m_Current>0
? m_Current - 1
......@@ -281,9 +281,11 @@ StackedLayerModel
// Update reference pointer.
if( emitReferenceChanged )
SetReference(
index>=m_Reference
index>m_Reference
? m_Reference
: m_Reference - 1,
: ( m_Reference > 0
? m_Reference - 1
: StackedLayerModel::NIL_INDEX ),
true
);
......
......@@ -187,6 +187,10 @@ public:
*/
virtual void ResizeEvent( QResizeEvent* event ) =0;
/**
*/
virtual void ResetViewport() =0;
//
// Public SLOTS.
public slots:
......
......@@ -221,6 +221,9 @@ public:
/**
*/
inline bool IsGLSLEnabled() const;
/**
*/
virtual bool IsEffectsEnabled() const = 0;
/**
*/
inline bool ZoomToRegion( const PointType & origin,
......
......@@ -87,6 +87,14 @@ class Monteverdi_EXPORT I18nMainWindow
//
// Public types.
public:
enum DockLayout
{
DOCK_LAYOUT_NONE = 0,
DOCK_LAYOUT_FLOATING = 1,
DOCK_LAYOUT_SCROLLABLE = 2,
};
typedef QFlags< DockLayout > DockLayoutFlags;
//
// Public methods.
......@@ -225,7 +233,7 @@ protected:
const QString& dockName,
const QString& dockTitle,
Qt::DockWidgetArea dockArea,
bool isFloating =false );
DockLayoutFlags flags = DOCK_LAYOUT_NONE );
/**
*/
......@@ -235,7 +243,7 @@ protected:
AddDockWidget( const QString& dockName,
const QString& dockTitle,
Qt::DockWidgetArea dockArea,
bool isFloating =false );
DockLayoutFlags flags = DOCK_LAYOUT_NONE );
/**
*/
......@@ -245,7 +253,7 @@ protected:
AddDockWidget( const QString& dockName,
const QString& dockTitle,
Qt::DockWidgetArea dockArea,
bool isFloating =false );
DockLayoutFlags flags = DOCK_LAYOUT_NONE );
/**
*/
const AbstractModelController *
......@@ -431,20 +439,20 @@ template< typename TWidget, typename TDockWidget >
inline
TDockWidget*
I18nMainWindow
::AddDockWidget( const QString& dockName,
const QString& dockTitle,
::AddDockWidget( const QString & dockName,
const QString & dockTitle,
Qt::DockWidgetArea dockArea,
bool isFloating )
DockLayoutFlags flags )
{
TWidget* widget = new TWidget( this );
TWidget * widget = new TWidget( this );
TDockWidget* dockWidget =
TDockWidget * dockWidget =
AddWidgetToDock(
widget,
dockName,
dockTitle,
dockArea,
isFloating
flags
);
return dockWidget;
......@@ -455,20 +463,34 @@ template< typename TWidget, typename TController, typename TDockWidget >
inline
TDockWidget*
I18nMainWindow
::AddDockWidget( const QString& dockName,
const QString& dockTitle,
::AddDockWidget( const QString & dockName,
const QString & dockTitle,
Qt::DockWidgetArea dockArea,
bool isFloating )
DockLayoutFlags flags )
{
TWidget* widget = new TWidget( this );
TWidget * widget = new TWidget( this );
QWidget * pannel = widget;
if( flags.testFlag( DOCK_LAYOUT_SCROLLABLE ) )
{
QScrollArea * scrollArea = new QScrollArea( this );
scrollArea->setWidgetResizable( true );
TDockWidget* dockWidget =
scrollArea->setWidget( widget );
pannel = scrollArea;
}
TDockWidget * dockWidget =
AddWidgetToDock(
widget,
pannel,
dockName,
dockTitle,
dockArea,
isFloating
flags
);
new TController(
......
......@@ -166,6 +166,8 @@ public:
virtual const PointType& Transform( PointType&, const QPoint& ) const;
virtual void ResetViewport();
//
// Events.
......
......@@ -194,6 +194,8 @@ public:
const PointType & vcenter,
const SpacingType & vspacing ) const;
virtual bool IsEffectsEnabled() const;
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
// public slots
......@@ -210,6 +212,7 @@ signals:
void ClearProjectionRequired();
void SetProjectionRequired();
void UpdateProjectionRequired();
void ResetViewport();
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
......
......@@ -420,6 +420,9 @@ private slots:
/**
*/
void OnRefreshViewRequested();
/**
*/
void OnResetViewport();
};
}// end namespace 'mvd'
......
......@@ -128,7 +128,7 @@ I18nMainWindow
const QString& dockName,
const QString& dockTitle,
Qt::DockWidgetArea dockArea,
bool isFloating )
DockLayoutFlags flags )
{
// New dock.
QDockWidget* dockWidget = new QDockWidget( dockTitle, this );
......@@ -138,7 +138,7 @@ I18nMainWindow
dockWidget->setWidget( widget );
// Features.
dockWidget->setFloating( isFloating );
dockWidget->setFloating( flags.testFlag( DOCK_LAYOUT_FLOATING ) );
dockWidget->setFeatures(
QDockWidget::DockWidgetMovable |
QDockWidget::DockWidgetFloatable |
......
......@@ -365,6 +365,30 @@ ImageViewManipulator
return viewport;
}
/******************************************************************************/
void
ImageViewManipulator
::ResetViewport()
{
assert( !m_ViewSettings.IsNull() );
otb::ViewSettings::SizeType size( m_ViewSettings->GetViewportSize() );
m_ViewSettings->Reset();
m_ViewSettings->SetViewportSize( size );
m_NativeSpacing.Fill( 1.0 );
m_ZoomFactor = 1.0;
emit RoiChanged(
GetOrigin(),
GetViewportSize(),
GetSpacing(),
m_ViewSettings->GetViewportCenter()
);
}
/******************************************************************************/
void
ImageViewManipulator
......
......@@ -357,7 +357,6 @@ ImageViewRenderer
assert( !m_GlView.IsNull() );
// qDebug() << this << "::PaintGL(" << c << ")";
// qDebug() << "{";
// qDebug() << m_GlView.GetPointer();
......@@ -411,8 +410,6 @@ ImageViewRenderer
// qDebug() << m_GlView.GetPointer() << "::AfterRendering()";
#endif // USE_REMOTE_DESKTOP_DISABLED_RENDERING
// qDebug() << "}\n";
}
/*****************************************************************************/
......@@ -829,8 +826,15 @@ ImageViewRenderer
if( stackedLayerModel==NULL || stackedLayerModel->IsEmpty() )
{
m_GlView->ClearActors();
//
// MANTIS-1244: image-view not reset when layer-stack is cleared.
// {
emit ResetViewport();
// }
}
else
{
{
......@@ -841,7 +845,8 @@ ImageViewRenderer
++it )
if( !stackedLayerModel->Contains( *it ) )
{
// qDebug() << QString( "Removing image-actor '%1'..." ).arg( it->c_str() );
// qDebug()
// << QString( "Removing image-actor '%1'..." ).arg( it->c_str() );
m_GlView->RemoveActor( *it );
}
......@@ -1093,6 +1098,14 @@ ImageViewRenderer
m_GlView->SaveScreenshot( QFile::encodeName( filename ).constData() );
}
/*****************************************************************************/
bool
ImageViewRenderer
::IsEffectsEnabled() const
{
return m_EffectsEnabled;
}
/*****************************************************************************/
/* SLOTS */
/*****************************************************************************/
......@@ -1109,6 +1122,9 @@ ImageViewRenderer
assert( !m_GlView.IsNull() );
if( !m_EffectsEnabled )
return;
for( PixelInfo::Vector::const_iterator it( pixels.begin() );
it != pixels.end();
++ it )
......@@ -1174,6 +1190,11 @@ ImageViewRenderer
p_screen[ 1 ] =
m_GlView->GetSettings()->GetViewportSize()[ 1 ] - screen.y();
// qDebug()
// << "otb::StandardShader::SetCenter("
// << p_screen[ 0 ] << "," << p_screen[ 1 ]
// << ")";
shader->SetCenter( p_screen );
if( shader->GetShaderType()==otb::SHADER_ALPHA_SLIDER )
......
......@@ -632,6 +632,14 @@ ImageViewWidget
this,
SLOT( OnUpdateProjectionRequired() )
);
QObject::connect(
m_Renderer,
SIGNAL( ResetViewport() ),
// to:
this,
SLOT( OnResetViewport() )
);
}
/*******************************************************************************/
......@@ -727,19 +735,94 @@ ImageViewWidget
{
assert( event!=NULL );
// qDebug() << this << "::mouseMove(" << event << ")";
// Superclass default behaviour.
QGLWidget::mouseMoveEvent( event );
// Delegate behaviour.
m_Manipulator->MouseMoveEvent( event );
//
// Get layer-stack.
StackedLayerModel * stackedLayerModel = GetLayerStack();
// assert( stackedLayerModel!=NULL );
if( stackedLayerModel==NULL )
return;
assert( stackedLayerModel!=NULL );
//
// Update view depending on shader status special behaviour.
//
bool isAnyEffectActive = false;
if( m_Renderer->IsEffectsEnabled() )
{
for( StackedLayerModel::ConstIterator it( stackedLayerModel->Begin() );
it!=stackedLayerModel->End();
++ it )
{
assert( it->second!=NULL );
if( it->second->inherits( AbstractImageModel::staticMetaObject.className() ) )
{
VectorImageModel * imageModel = qobject_cast< VectorImageModel * >( it->second );
assert( imageModel!=NULL );
if( imageModel->GetSettings().GetEffect()!=EFFECT_NONE &&
imageModel->GetSettings().GetEffect()!=EFFECT_NORMAL )
{
#if USE_XP_REGION_OPTIM
PointType origin;
PointType extent;
m_Renderer->GetLayerExtent( it->first, origin, extent );
if( ( origin[ 0 ]<=ptView[ 0 ] && ptView[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=ptView[ 1 ] && ptView[ 1 ]<=extent[ 1 ] ) ||
( origin[ 0 ]<=m_Position[ 0 ] && m_Position[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=m_Position[ 1 ] && m_Position[ 1 ]<=extent[ 1 ] ) )
{
qDebug() << FromStdString( it->first );
// qDebug()
// << "x:" << origin[ 0 ] << ptView[ 0 ] << m_Position[ 0 ] << extent[ 0 ];
// qDebug()
// << "y:" << origin[ 1 ] << ptView[ 1 ] << m_Position[ 1 ] << extent[ 1 ];
// qDebug()
// << "x:" << ptView[ 0 ] << m_Position[ 0 ];
// qDebug()
// << "y:" << ptView[ 1 ] << m_Position[ 1 ];
#endif // USE_XP_REGION_OPTIM
// qDebug() << "updateGL(" << in[ 0 ] << "," << in[ 1 ] << ")";
isAnyEffectActive = true;
break;
}
#if USE_XP_REGION_OPTIM
}
#endif // USE_XP_REGION_OPTIM
}
}
#if USE_XP_REGION_OPTIM
m_Position = ptView;
#endif // USE_XP_REGION_OPTION
}
// Delegate behaviour.
if( isAnyEffectActive )
{
bool bypass = m_Renderer->SetBypassRenderingEnabled( true );
m_Manipulator->MouseMoveEvent( event );
m_Renderer->SetBypassRenderingEnabled( bypass );
}
else
m_Manipulator->MouseMoveEvent( event );
//
// Pixel-picking special behaviour.
......@@ -786,60 +869,27 @@ ImageViewWidget
DefaultImageType::PixelType()
);
}
//
// Update view depending on shader status special behaviour.
//
{
for( StackedLayerModel::ConstIterator it( stackedLayerModel->Begin() );
it!=stackedLayerModel->End();
++ it )
else if( isAnyEffectActive )
{
assert( it->second!=NULL );
if( it->second->inherits( AbstractImageModel::staticMetaObject.className() ) )
{
VectorImageModel * imageModel = qobject_cast< VectorImageModel * >( it->second );
assert( imageModel!=NULL );
if( imageModel->GetSettings().GetEffect()!=EFFECT_NONE &&
imageModel->GetSettings().GetEffect()!=EFFECT_NORMAL )
{
#if USE_XP_REGION_OPTIM
PointType origin;
PointType extent;
m_Renderer->GetLayerExtent( it->first, origin, extent );
if( ( origin[ 0 ]<=in[ 0 ] && in[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=in[ 1 ] && in[ 1 ]<=extent[ 1 ] ) |
( origin[ 0 ]<=m_Position[ 0 ] && m_Position[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=m_Position[ 1 ] && m_Position[ 1 ]<=extent[ 1 ] ) )
{
qDebug() << FromStdString( it->first );
// Transform coordinates from widget space to viewport space.
assert( m_Manipulator!=NULL );
qDebug()
<< "o:" << origin[ 0 ] << "," << origin[ 1 ] << ";"
<< "e:" << extent[ 0 ] << "," << extent[ 1 ];
#endif // USE_XP_REGION_OPTIM
PointType ptView;
// qDebug() << "updateGL(" << in[ 0 ] << "," << in[ 1 ] << ")";
m_Manipulator->Transform( ptView, event->pos() );
updateGL();
//
// Pick pixel of point in viewport space and return point in image
// space.
assert( m_Renderer!=NULL );
break;
const PixelInfo::Vector & pixels = stackedLayerModel->PixelInfos();
}
#if USE_XP_REGION_OPTIM
}
#endif // USE_XP_REGION_OPTIM
}
m_Renderer->UpdatePixelInfo( event->pos(), ptView, pixels );
}