Commit 9cad5bef authored by Stéphane Albert's avatar Stéphane Albert

ENH: Implemented ImaveViewRender rendering algorithm and ::SetImageList();...

ENH: Implemented ImaveViewRender rendering algorithm and ::SetImageList(); Added ImageViewManipulator::m_ViewSettings shared with ImageViewRenderer.
parent 8ede2b16
......@@ -953,12 +953,17 @@ ImageViewWidget*
MainWindow
::CreateImageViewWidget( QGLWidget* sharedGlWidget )
{
ImageViewManipulator* manipulator =
new ImageViewManipulator( this );
ImageViewRenderer* renderer =
new ImageViewRenderer( this );
ImageViewManipulator* manipulator =
new ImageViewManipulator(
#if USE_VIEW_SETTINGS_SIDE_EFFECT
renderer->GetViewSettings(),
#endif // USE_VIEW_SETTINGS_SIDE_EFFECT
this
);
ImageViewWidget* imageView = new ImageViewWidget(
manipulator, // (will be reparented.)
renderer, // (will be reparented.)
......@@ -980,12 +985,17 @@ ImageViewWidget*
MainWindow
::CreateQuicklookViewWidget( QGLWidget* sharedGlWidget )
{
QuicklookViewManipulator* manipulator =
new QuicklookViewManipulator( this );
ImageViewRenderer* renderer =
new ImageViewRenderer( this );
QuicklookViewManipulator* manipulator =
new QuicklookViewManipulator(
#if USE_VIEW_SETTINGS_SIDE_EFFECT
renderer->GetViewSettings(),
#endif // USE_VIEW_SETTINGS_SIDE_EFFECT
this
);
ImageViewWidget* quicklookView = new ImageViewWidget(
manipulator, // (will be reparented.)
renderer, // (will be reparented.)
......@@ -1419,7 +1429,7 @@ MainWindow
// must be done before the SetImageModel (to be able to receive
// the signal with zoom level)
ConnectStatusBar( model );
ConnectPixelDescriptionWidget( model );
#if USE_OLD_IMAGE_VIEW
......@@ -1468,6 +1478,15 @@ MainWindow
#endif // USE_OLD_IMAGE_VIEW
#if USE_ICE_IMAGE_VIEW
ImageViewWidget::VectorImageModelList images;
if( vectorImageModel!=NULL )
images << vectorImageModel;
m_ImageView->SetImageList( images );
#endif // USE_ICE_IMAGE_VIEW
//
// MODEL(s).
//
......
......@@ -251,10 +251,12 @@ public:
*/
inline CountType GetCurrentLod() const;
/** */
/**
*/
inline const SpacingType& GetSpacing() const;
/** */
/**
*/
inline const PointType& GetOrigin() const;
/** Release as much memory as possible (default implementation does
......@@ -529,20 +531,20 @@ AbstractImageModel
/*****************************************************************************/
inline
const SpacingType&
const PointType&
AbstractImageModel
::GetSpacing() const
::GetOrigin() const
{
return ToImageBase()->GetSpacing();
return ToImageBase()->GetOrigin();
}
/*****************************************************************************/
inline
const PointType&
const SpacingType&
AbstractImageModel
::GetOrigin() const
::GetSpacing() const
{
return ToImageBase()->GetOrigin();
return ToImageBase()->GetSpacing();
}
/*****************************************************************************/
......
......@@ -55,7 +55,8 @@ namespace mvd
/*******************************************************************************/
AbstractImageViewManipulator
::AbstractImageViewManipulator( QObject* parent ) :
QObject( parent )
QObject( parent ),
m_NavigationContext()
{
}
......
......@@ -45,6 +45,8 @@
//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdTypes.h"
#include "Gui/mvdAbstractImageViewRenderer.h"
/*****************************************************************************/
......@@ -61,7 +63,6 @@ namespace mvd
//
// Internal classes pre-declaration.
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
......@@ -91,15 +92,45 @@ public:
/**
*/
virtual void mouseMoveEvent( QMouseEvent* event ) = 0;
virtual void mousePressEvent( QMouseEvent* event ) = 0;
virtual void mouseReleaseEvent( QMouseEvent* event ) = 0;
inline void SetViewportSize( int width, int height );
/**
*/
inline void SetOrigin( const PointType& origin );
/**
*/
inline void SetSpacing( const SpacingType& spacing );
/**
*/
inline void SetWkt( const std::string& wkt );
virtual void wheelEvent( QWheelEvent* event) = 0;
/**
*/
inline
void
SetupRenderingContext(
AbstractImageViewRenderer::RenderingContext * const ) const;
virtual void keyPressEvent( QKeyEvent * event ) = 0;
/**
*/
inline void MouseMoveEvent( QMouseEvent* event );
/**
*/
inline void MousePressEvent( QMouseEvent* event );
/**
*/
inline void MouseReleaseEvent( QMouseEvent* event );
virtual void resizeEvent( QResizeEvent* event ) = 0;
/**
*/
inline void WheelEvent( QWheelEvent* event);
/**
*/
inline void KeyPressEvent( QKeyEvent * event );
/**
*/
inline void ResizeEvent( QResizeEvent* event );
//
// Public SLOTS.
......@@ -125,9 +156,21 @@ protected:
* Default constructor (safely) initializes POD (Plain Old Data)
* structure.
*/
NavigationContext()
NavigationContext() :
m_Origin(),
m_Spacing(),
m_ViewportSize(),
m_Wkt()
{
m_Origin.Fill( 0 );
m_Spacing.Fill( 1 );
m_ViewportSize.Fill( 0 );
}
PointType m_Origin;
SpacingType m_Spacing;
SizeType m_ViewportSize;
std::string m_Wkt;
};
/** Mouse context */
......@@ -144,7 +187,50 @@ protected:
//
// Protected methods.
protected:
/**
*/
virtual void virtual_SetViewportSize( int width, int height ) = 0;
/**
*/
virtual void virtual_SetOrigin( const PointType& origin ) = 0;
/**
*/
virtual void virtual_SetSpacing( const SpacingType& spacing ) = 0;
/**
*/
virtual void virtual_SetWkt( const std::string& wkt ) = 0;
/**
*/
virtual void virtual_MouseMoveEvent( QMouseEvent* event ) = 0;
/**
*/
virtual void virtual_MousePressEvent( QMouseEvent* event ) = 0;
/**
*/
virtual void virtual_MouseReleaseEvent( QMouseEvent* event ) = 0;
/**
*/
virtual void virtual_WheelEvent( QWheelEvent* event) = 0;
/**
*/
virtual void virtual_KeyPressEvent( QKeyEvent * event ) = 0;
/**
*/
virtual void virtual_ResizeEvent( QResizeEvent* event ) = 0;
/**
*/
virtual
void
virtual_SetupRenderingContext(
AbstractImageViewRenderer::RenderingContext * const ) const = 0;
//
// Protected attributes.
protected:
......@@ -163,6 +249,10 @@ private:
// Private attributes.
private:
/**
*/
NavigationContext m_NavigationContext;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
......@@ -177,6 +267,118 @@ private slots:
namespace mvd
{
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::SetViewportSize( int width, int height )
{
m_NavigationContext.m_ViewportSize[ 0 ] = width;
m_NavigationContext.m_ViewportSize[ 1 ] = height;
virtual_SetViewportSize( width, height );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::SetOrigin( const PointType& origin )
{
m_NavigationContext.m_Origin = origin;
virtual_SetOrigin( origin );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::SetSpacing( const SpacingType& spacing )
{
m_NavigationContext.m_Spacing = spacing;
virtual_SetSpacing( spacing );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::SetWkt( const std::string& wkt )
{
m_NavigationContext.m_Wkt = wkt;
virtual_SetWkt( wkt );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::SetupRenderingContext(
AbstractImageViewRenderer::RenderingContext * const context ) const
{
assert( context!=NULL );
virtual_SetupRenderingContext( context );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::MouseMoveEvent( QMouseEvent* event )
{
virtual_MouseMoveEvent( event );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::MousePressEvent( QMouseEvent* event )
{
virtual_MousePressEvent( event );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::MouseReleaseEvent( QMouseEvent* event )
{
virtual_MouseReleaseEvent( event );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::WheelEvent( QWheelEvent* event)
{
virtual_WheelEvent( event );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::KeyPressEvent( QKeyEvent * event )
{
virtual_KeyPressEvent( event );
}
/*****************************************************************************/
inline
void
AbstractImageViewManipulator
::ResizeEvent( QResizeEvent* event )
{
virtual_ResizeEvent( event );
}
} // end namespace 'mvd'
#endif // __mvdAbstractImageViewManipulator_h
......@@ -61,7 +61,8 @@ namespace mvd
//
// Internal classes pre-declaration.
class Monteverdi2_EXPORT AbstractImageModel;
class AbstractImageModel;
class VectorImageModel;
/*****************************************************************************/
......@@ -85,6 +86,10 @@ class AbstractImageViewRenderer :
//
// Public types.
public:
/**
*/
typedef QList< VectorImageModel* > VectorImageModelList;
/**
*/
struct RenderingContext
......@@ -97,6 +102,10 @@ public:
{
}
/**
*/
virtual ~RenderingContext() {}
/**
*/
enum RenderMode
......@@ -116,15 +125,26 @@ public:
*/
virtual ~AbstractImageViewRenderer();
/**
*/
inline void SetImageList( const VectorImageModelList& images );
/**
*/
inline
AbstractImageViewRenderer::RenderingContext* NewRenderingContext() const;
/**
*/
inline void InitializeGL();
/**
*/
inline void ResizeGL( int width, int height );
/**
*/
inline void PaintGL( const RenderingContext& context );
inline void PaintGL( RenderingContext const * context );
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
......@@ -158,6 +178,15 @@ protected:
//
// Private methods.
private:
/**
*/
virtual void virtual_SetImageList( const VectorImageModelList& images ) =0;
/**
*/
virtual
AbstractImageViewRenderer::RenderingContext*
virtual_NewRenderingContext() const =0;
/**
*/
......@@ -167,7 +196,7 @@ private:
virtual void virtual_ResizeGL( int width, int height ) =0;
/**
*/
virtual void virtual_PaintGL( const RenderingContext& context ) =0;
virtual void virtual_PaintGL( RenderingContext const * context ) =0;
//
// Private attributes.
......@@ -188,6 +217,24 @@ private slots:
namespace mvd
{
/*****************************************************************************/
inline
void
AbstractImageViewRenderer
::SetImageList( const VectorImageModelList& images )
{
virtual_SetImageList( images );
}
/*****************************************************************************/
inline
AbstractImageViewRenderer::RenderingContext*
AbstractImageViewRenderer
::NewRenderingContext() const
{
return virtual_NewRenderingContext();
}
/*****************************************************************************/
inline
void
......@@ -210,7 +257,7 @@ AbstractImageViewRenderer
inline
void
AbstractImageViewRenderer
::PaintGL( const RenderingContext& context )
::PaintGL( RenderingContext const * context )
{
virtual_PaintGL( context );
}
......
......@@ -34,6 +34,7 @@
//
// Monteverdi includes (sorted by alphabetic order)
#include "Gui/mvdImageViewRenderer.h"
namespace mvd
{
......@@ -46,12 +47,27 @@ namespace mvd
*/
/*****************************************************************************/
#if USE_VIEW_SETTINGS_SIDE_EFFECT
ImageViewManipulator
::ImageViewManipulator( const otb::ViewSettings::Pointer& viewSettings,
QObject* parent ) :
AbstractImageViewManipulator( parent ),
m_ViewSettings( viewSettings )
{
}
#else // USE_VIEW_SETTINGS_SIDE_EFFECT
ImageViewManipulator
::ImageViewManipulator( QObject* parent ) :
AbstractImageViewManipulator( parent )
AbstractImageViewManipulator( parent ),
m_ViewSettings( otb::ViewSettings::New() )
{
}
#endif // USE_VIEW_SETTINGS_SIDE_EFFECT
/*****************************************************************************/
ImageViewManipulator
::~ImageViewManipulator()
......@@ -61,41 +77,118 @@ ImageViewManipulator
/******************************************************************************/
void
ImageViewManipulator
::mousePressEvent( QMouseEvent* event )
::virtual_SetViewportSize( int width, int height )
{
SizeType size;
size[ 0 ] = width;
size[ 1 ] = height;
assert( !m_ViewSettings.IsNull() );
m_ViewSettings->SetViewportSize( size );
}
/******************************************************************************/
void
ImageViewManipulator
::mouseMoveEvent( QMouseEvent * event)
::virtual_SetOrigin( const PointType& origin )
{
assert( !m_ViewSettings.IsNull() );
m_ViewSettings->SetOrigin( origin );
}
/******************************************************************************/
void
ImageViewManipulator
::mouseReleaseEvent( QMouseEvent * event)
::virtual_SetSpacing( const SpacingType& spacing )
{
assert( !m_ViewSettings.IsNull() );
m_ViewSettings->SetSpacing( spacing );
}
/******************************************************************************/
void ImageViewManipulator
::resizeEvent( QResizeEvent * event )
void
ImageViewManipulator
::virtual_SetWkt( const std::string& wkt )
{
assert( !m_ViewSettings.IsNull() );
m_ViewSettings->SetWkt( wkt );
m_ViewSettings->SetUseProjection( !wkt.empty() );
}
/******************************************************************************/
void
ImageViewManipulator
::virtual_SetupRenderingContext(
AbstractImageViewRenderer::RenderingContext * const c ) const
{
assert(
c==dynamic_cast< ImageViewRenderer::RenderingContext const * >( c )
);
ImageViewRenderer::RenderingContext * const context =
dynamic_cast< ImageViewRenderer::RenderingContext * const >( c );
context->m_RenderMode =
AbstractImageViewRenderer::RenderingContext::RENDER_MODE_FULL;
#if USE_VIEW_SETTINGS_SIDE_EFFECT
#else // USE_VIEW_SETTINGS_SIDE_EFFECT
context->m_ViewSettings->SetOrigin( m_ViewSettings->GetOrigin() );
context->m_ViewSettings->SetSpacing( m_ViewSettings->GetSpacing() );
context->m_ViewSettings->SetViewportSize( m_ViewSettings->GetViewportSize() );
context->m_ViewSettings->SetWkt( m_ViewSettings->GetWkt() );
context->m_ViewSettings->SetKeywordList( m_ViewSettings->GetKeywordList() );
context->m_ViewSettings->SetUseProjection( m_ViewSettings->GetUseProjection() );
context->m_ViewSettings->SetGeometryChanged(
m_ViewSettings->GetGeometryChanged()
);
#endif // USE_VIEW_SETTINGS_SIDE_EFFECT
}
/******************************************************************************/
void
ImageViewManipulator
::virtual_MousePressEvent( QMouseEvent* event )
{
}
/******************************************************************************/
void
ImageViewManipulator
::virtual_MouseMoveEvent( QMouseEvent* event)
{
}
/******************************************************************************/
void
ImageViewManipulator
::virtual_MouseReleaseEvent( QMouseEvent* event)
{
}
/******************************************************************************/
void
ImageViewManipulator
::virtual_ResizeEvent( QResizeEvent* event )
{
}
/******************************************************************************/
void
ImageViewManipulator
::wheelEvent( QWheelEvent * event)
::virtual_WheelEvent( QWheelEvent* event )
{
}
/******************************************************************************/
void
ImageViewManipulator
::keyPressEvent( QKeyEvent * event )
::virtual_KeyPressEvent( QKeyEvent* event )
{
}
......
......@@ -41,10 +41,12 @@
//
// OTB includes (sorted by alphabetic order)
#include "otbViewSettings.h"
//
// Monteverdi includes (sorted by alphabetic order)
#include "Gui/mvdAbstractImageViewManipulator.h"
#include "Gui/mvdImageViewRenderer.h"
/*****************************************************************************/
......@@ -85,30 +87,16 @@ class Monteverdi2_EXPORT ImageViewManipulator :
public:
/** \brief Constructor. */
#if USE_VIEW_SETTINGS_SIDE_EFFECT
ImageViewManipulator( const otb::ViewSettings::Pointer& viewSettings,
QObject* parent =NULL );
#else // USE_VIEW_SETTINGS_SIDE_EFFECT
ImageViewManipulator( QObject* parent =NULL );
#endif // USE_VIEW_SETTINGS_SIDE_EFFECT
/** \brief Destructor. */
virtual ~ImageViewManipulator();
/**
*/
virtual void mouseMoveEvent( QMouseEvent * event );
/**
*/
virtual void mousePressEvent( QMouseEvent * event );
/**
*/
virtual void mouseReleaseEvent( QMouseEvent * event );
/**
*/
virtual void wheelEvent( QWheelEvent* event);
/**
*/
virtual void resizeEvent( QResizeEvent * event );
/**
*/
virtual void keyPressEvent( QKeyEvent * event );
/*-[ PUBLIC SLOTS SECTION ]-----------------------------------------------**/
//
......@@ -127,7 +115,46 @@ signals:
//
// Protected methods.
protected:
/**
*/
virtual void virtual_SetViewportSize( int width, int height );
/**
*/
virtual void virtual_SetOrigin( const PointType& origin );
/**
*/
virtual void virtual_SetSpacing( const SpacingType& spacing );
/**
*/
virtual void virtual_SetWkt( const std::string& wkt );
/**