diff --git a/Code/Application/mvdMainWindow.cxx b/Code/Application/mvdMainWindow.cxx index 12fb53a6ca8d8af667819c703ce0b0856d218a4c..639080b58b9d50961c315b2bb02aaf27aea40e2b 100644 --- a/Code/Application/mvdMainWindow.cxx +++ b/Code/Application/mvdMainWindow.cxx @@ -44,6 +44,9 @@ #include "mvdGLImageWidget.h" #include "mvdVectorImageModel.h" +#include "mvdImageModelRenderer.h" +#include "mvdImageViewManipulator.h" +#include "mvdQuicklookViewManipulator.h" namespace mvd { /* @@ -79,9 +82,19 @@ MainWindow setObjectName( "mvd::MainWindow" ); setWindowTitle( PROJECT_NAME ); - // Set the GLImageWidget as the centralWidget in MainWindow. - setCentralWidget( new GLImageWidget( this ) ); + // instanciate the manipulator and the renderer relative to this widget + ImageViewManipulator * imageViewManipulator = new ImageViewManipulator(); + ImageModelRenderer * imageModelRenderer = new ImageModelRenderer(); + // set the GLImageWidget as the centralWidget in MainWindow. + setCentralWidget( new GLImageWidget( imageViewManipulator, + imageModelRenderer, + this ) ); + + // grab the keyboard notifications in this widget + centralWidget()->grabKeyboard(); + + // add the needed docks InitializeDockWidgets(); // Connect Quit action of main menu to QApplication's quit() slot. @@ -92,8 +105,8 @@ MainWindow // Connect the setLargestPossibleregion QObject::connect( - this, SIGNAL( LargestPossibleRegionChanged(const ImageRegionType&) ), - centralWidget(), SLOT( OnLargestPossibleRegionChanged(const ImageRegionType&)) ); + centralWidget(), SIGNAL( ModelImageRegionChanged(const ImageRegionType&) ), + imageViewManipulator, SLOT( OnModelImageRegionChanged(const ImageRegionType&)) ); // Connect Appllication and MainWindow when selected model is about // to change. @@ -120,6 +133,28 @@ void MainWindow ::InitializeDockWidgets() { + // instanciate the manipulator and the renderer relative to this widget + QuicklookViewManipulator * qlViewManipulator = new QuicklookViewManipulator(); + ImageModelRenderer * qlModelRenderer = new ImageModelRenderer(); + + // + // EXPERIMENTAL QUICKLOOK Widget. + GLImageWidget * qlWidget = new GLImageWidget( qlViewManipulator, qlModelRenderer, this ); + qlWidget->setMinimumSize(100,100); // TODO : temporary + + AddWidgetToDock( + qlWidget, + QUICKLOOK_DOCK, + tr( "Quicklook" ), + Qt::LeftDockWidgetArea + ); + + // Connect the setLargestPossibleregion + QObject::connect( + qlWidget, SIGNAL( ModelImageRegionChanged(const ImageRegionType&) ), + qlViewManipulator, SLOT( OnModelImageRegionChanged(const ImageRegionType&)) ); + + // // COLOR SETUP. ColorSetupWidget* colorSetupWgt = new ColorSetupWidget( this ); @@ -312,6 +347,16 @@ MainWindow centralWidget(), SLOT( updateGL() ) ); + + // TODO : where to do this + QObject::disconnect( + vectorImageModel->GetQuicklookModel(), + SIGNAL( SettingsUpdated() ), + // to: + qobject_cast<GLImageWidget *>(GetQuicklookDock()->widget()), + SLOT( updateGL() ) + ); + } /*****************************************************************************/ @@ -356,16 +401,29 @@ MainWindow SLOT( updateGL() ) ); - // - // REFRESH DISPLAY. - - // set the largest possible region of the image - // TODO: rename signal name when handling DataSets collections - // TODO: move signal into mvdApplication and link it to DockWidget - // and ImageView. - emit LargestPossibleRegionChanged( - vectorImageModel->GetNativeLargestRegion() + + // TODO : where to do this + QObject::connect( + vectorImageModel->GetQuicklookModel(), + SIGNAL( SettingsUpdated() ), + // to: + qobject_cast<GLImageWidget *>(GetQuicklookDock()->widget()), + SLOT( updateGL() ) ); + + // Connect newly selected model to UI controller. + QObject::connect( + colorSetupWidget, + SIGNAL( CurrentIndexChanged( RgbaChannel, int ) ), + // to: + vectorImageModel->GetQuicklookModel(), + SLOT( OnCurrentIndexChanged( RgbaChannel, int ) ) + ); + + + // + qobject_cast<GLImageWidget *>(centralWidget())->SetImageModel(vectorImageModel); + qobject_cast<GLImageWidget *>(GetQuicklookDock()->widget())->SetImageModel(vectorImageModel->GetQuicklookModel()); } /*****************************************************************************/ diff --git a/Code/Application/mvdMainWindow.h b/Code/Application/mvdMainWindow.h index 90cb7e987646debc152acd00e58f1b4e246c6ab8..7446c7ee902aafb2931865751fa85710d8ecda9e 100644 --- a/Code/Application/mvdMainWindow.h +++ b/Code/Application/mvdMainWindow.h @@ -106,7 +106,6 @@ public: // // SIGNALS. signals: - void LargestPossibleRegionChanged(const ImageRegionType& largestRegion); /*-[ PROTECTED SECTION ]---------------------------------------------------*/ @@ -148,6 +147,9 @@ private: /** */ inline QDockWidget* GetColorDynamicsDock(); + /** */ + inline const QDockWidget* GetQuicklookDock() const; + /** * \brief Assign model to the controller which is child of given * dock-widget. @@ -214,6 +216,7 @@ private slots: // Some constants. #define VIDEO_COLOR_DYNAMICS_DOCK "videoColorDynamicsDock" #define VIDEO_COLOR_SETUP_DOCK "videoColorSetupDock" +#define QUICKLOOK_DOCK "quicklookDock" namespace mvd { @@ -254,6 +257,15 @@ MainWindow return findChild< QDockWidget* >( VIDEO_COLOR_DYNAMICS_DOCK ); } +/*****************************************************************************/ +inline +const QDockWidget* +MainWindow +::GetQuicklookDock() const +{ + return findChild< QDockWidget* >( QUICKLOOK_DOCK ); +} + /*****************************************************************************/ inline void diff --git a/Code/Common/mvdGLImageWidget.cxx b/Code/Common/mvdGLImageWidget.cxx index 07df9c284cbb794590f8e450e35d5d1d231fd68a..8f1d107f9a54a2467ac9d3ff96f1100d23dd53fc 100644 --- a/Code/Common/mvdGLImageWidget.cxx +++ b/Code/Common/mvdGLImageWidget.cxx @@ -22,7 +22,7 @@ // // Qt includes (sorted by alphabetic order) //// Must be included before system/custom includes. -#include <QKeyEvent> +//#include <QKeyEvent> // // System includes (sorted by alphabetic order) @@ -38,8 +38,6 @@ #include "mvdAbstractImageModel.h" #include "mvdApplication.h" #include "mvdDatasetModel.h" -#include "mvdImageModelRenderer.h" -#include "mvdImageViewManipulator.h" namespace mvd { @@ -53,42 +51,49 @@ namespace mvd /*******************************************************************************/ GLImageWidget -::GLImageWidget( QWidget* parent, +::GLImageWidget( AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer, + QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags flags ) : QGLWidget( parent, shareWidget, flags ), m_ImageViewManipulator( NULL ), - m_ImageModelRenderer( NULL ) + m_ImageModelRenderer( NULL ), + m_ImageModel( NULL ) { - Initialize(); + Initialize(manipulator, renderer); } /*******************************************************************************/ GLImageWidget -::GLImageWidget( QGLContext* context, +::GLImageWidget( AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer, + QGLContext* context, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags flags ) : QGLWidget( context, parent, shareWidget, flags ), m_ImageViewManipulator( NULL ), - m_ImageModelRenderer( NULL ) + m_ImageModelRenderer( NULL ), + m_ImageModel( NULL ) { - Initialize(); + Initialize(manipulator, renderer); } /*******************************************************************************/ GLImageWidget -::GLImageWidget( const QGLFormat& format, - QWidget* parent, - const QGLWidget* shareWidget, - Qt::WindowFlags flags ) : +::GLImageWidget( AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer, + const QGLFormat& format, + QWidget* parent, + const QGLWidget* shareWidget, + Qt::WindowFlags flags ) : QGLWidget( format, parent, shareWidget, flags ), m_ImageViewManipulator( NULL ), - m_ImageModelRenderer( NULL ) -/*, m_ImageToScreenTransform(AffineTransformType::New()), - m_ScreenToImageTransform(AffineTransformType::New()) */ + m_ImageModelRenderer( NULL ), + m_ImageModel( NULL ) { - Initialize(); + Initialize(manipulator, renderer); } /*******************************************************************************/ @@ -102,12 +107,14 @@ GLImageWidget /*******************************************************************************/ void GLImageWidget -::Initialize() +::Initialize(AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer) { - m_ImageViewManipulator = new ImageViewManipulator( this ); - m_ImageModelRenderer = new ImageModelRenderer( this ); + m_ImageViewManipulator = manipulator; + m_ImageViewManipulator->setParent(this); - this->grabKeyboard(); + m_ImageModelRenderer = renderer; + m_ImageModelRenderer->setParent(this); connect(this, SIGNAL(movingMouse()), m_ImageModelRenderer, SLOT(onMovingEvent())); connect(this, SIGNAL(releasingMouse()), m_ImageModelRenderer, SLOT(onReleasedMouse())); @@ -209,16 +216,9 @@ GLImageWidget if( Application::ConstInstance()->GetModel()==NULL ) return; - // Access dataset-model. - // TODO: Design better way to access model from GLImageWidget. - const DatasetModel* datasetModel = - qobject_cast< const DatasetModel* >( - Application::ConstInstance()->GetModel() - ); - // Setup rendering context with image-model and redering information. - ImageModelRenderer::RenderingContext context( - datasetModel->GetSelectedImageModel(), + AbstractModelRenderer::RenderingContext context( + m_ImageModel, region, isotropicZoom, width(), height(), m_ImageViewManipulator->HasZoomChanged() ); @@ -282,7 +282,7 @@ GLImageWidget m_ImageViewManipulator->wheelEvent(event); // repaint the buffer - this->update(); + //this->update(); } /*******************************************************************************/ @@ -308,13 +308,6 @@ GLImageWidget this->update(); } -/*******************************************************************************/ -void GLImageWidget::OnLargestPossibleRegionChanged(const ImageRegionType& largestRegion) -{ - m_ImageViewManipulator->SetImageLargestRegion(largestRegion); - this->update(); -} - /*******************************************************************************/ /* SLOTS */ /*******************************************************************************/ diff --git a/Code/Common/mvdGLImageWidget.h b/Code/Common/mvdGLImageWidget.h index 4edb252e262a327bdc42da82cdd11fa3e4d1c8da..871e070e5059b64771d2d6e7279243a45e3494a5 100644 --- a/Code/Common/mvdGLImageWidget.h +++ b/Code/Common/mvdGLImageWidget.h @@ -40,6 +40,8 @@ // // Monteverdi includes (sorted by alphabetic order) #include "mvdTypes.h" +#include "mvdAbstractModelRenderer.h" +#include "mvdAbstractViewManipulator.h" // // External classes pre-declaration. @@ -66,18 +68,24 @@ class Monteverdi2_EXPORT GLImageWidget : // Public methods. public: /** Constructor */ - GLImageWidget( QWidget* parent =NULL, + GLImageWidget( AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer, + QWidget* parent =NULL, const QGLWidget* shareWidget =NULL, Qt::WindowFlags f =0 ); /** Constructor */ - GLImageWidget( QGLContext* context, + GLImageWidget( AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer, + QGLContext* context, QWidget* parent =NULL, const QGLWidget* shareWidget =NULL, Qt::WindowFlags f =0 ); /** Constructor */ - GLImageWidget( const QGLFormat& format, + GLImageWidget( AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer, + const QGLFormat& format, QWidget* parent =NULL, const QGLWidget *shareWidget =NULL, Qt::WindowFlags f =0 ); @@ -105,16 +113,19 @@ public: return 1.0; } + /** Set image model */ + inline void SetImageModel(AbstractImageModel* model); + // // Public SLOTS. public slots: - void OnLargestPossibleRegionChanged(const ImageRegionType& largestRegion); // // SIGNALS. signals: void movingMouse(); void releasingMouse(); + void ModelImageRegionChanged(const ImageRegionType & ); // // Protected methods. @@ -140,7 +151,8 @@ protected: // Private methods. private: /** Construction code (factorizes constructors initializations). */ - void Initialize(); + void Initialize(AbstractViewManipulator * manipulator, + AbstractModelRenderer * renderer); // // Private attributes. @@ -150,12 +162,48 @@ private: //AffineTransformType::Pointer m_ScreenToImageTransform; /** Event handler pointer */ - ImageViewManipulator* m_ImageViewManipulator; + AbstractViewManipulator* m_ImageViewManipulator; /** Model Renderer pointer */ - ImageModelRenderer* m_ImageModelRenderer; + AbstractModelRenderer* m_ImageModelRenderer; + + AbstractImageModel* m_ImageModel; }; +}// end namespace 'mvd' + +/*****************************************************************************/ +/* INLINE SECTION */ + +// +// ITK includes (sorted by alphabetic order) + +// +// OTB includes (sorted by alphabetic order) + +// +// Monteverdi includes (sorted by alphabetic order) +#include "mvdHistogramModel.h" + +namespace mvd +{ +void +GLImageWidget::SetImageModel(AbstractImageModel* model) +{ + m_ImageModel = model; + + // + // REFRESH DISPLAY. + + // set the largest possible region of the image + // TODO: rename signal name when handling DataSets collections + // TODO: move signal into mvdApplication and link it to DockWidget + // and ImageView. + emit ModelImageRegionChanged( + model->GetNativeLargestRegion() + ); +} + } -#endif +#endif // __mvdGLImageWidget_h