diff --git a/Code/Visualization/Viewer/Model/otbViewerModel.cxx b/Code/Visualization/Viewer/Model/otbViewerModel.cxx index bec4025633aa5660a4ab27497bc2124ae5384136..ee4209400fd28333dacebf4c8c068f4d7d1cf97a 100644 --- a/Code/Visualization/Viewer/Model/otbViewerModel.cxx +++ b/Code/Visualization/Viewer/Model/otbViewerModel.cxx @@ -555,13 +555,59 @@ ViewerModel VisuModelPointerType leftRenderModel = m_ObjectTrackedList.at(leftChoice-1).pRendering; //Get the views related to the choosen images - VisuViewPointerType pRightVisuView = m_ObjectTrackedList.at(rightChoice-1).pVisuView; ; + VisuViewPointerType pRightVisuView = m_ObjectTrackedList.at(rightChoice-1).pVisuView; VisuViewPointerType pLeftVisuView = m_ObjectTrackedList.at(leftChoice-1).pVisuView; //Pixel View PixelDescriptionModelPointerType rightPixelModel = m_ObjectTrackedList.at(rightChoice-1).pPixelModel; PixelDescriptionModelPointerType leftPixelModel = m_ObjectTrackedList.at(leftChoice-1).pPixelModel; +/* + pLeftVisuView->GetScrollWidget()->SetIdentifier("Scroll_l"); + pLeftVisuView->GetFullWidget()->SetIdentifier("Full_l"); + pLeftVisuView->GetZoomWidget()->SetIdentifier("Zoom_l"); + + pRightVisuView->GetScrollWidget()->SetIdentifier("Scroll_r"); + pRightVisuView->GetFullWidget()->SetIdentifier("Full_r"); + pRightVisuView->GetZoomWidget()->SetIdentifier("Zoom_r"); + + + leftController->RemoveActionHandler(3); + rightController->RemoveActionHandler(3); + + // Add the change scaled handler + ChangeScaleHandlerType::Pointer rightChangeScaleHandler =ChangeScaleHandlerType::New(); + rightChangeScaleHandler->SetModel(rightRenderModel ); + rightChangeScaleHandler->SetView(pLeftVisuView); + rightChangeScaleHandler->SetView2(pRightVisuView); + + ChangeScaleHandlerType::Pointer leftChangeScaleHandler =ChangeScaleHandlerType::New(); + leftChangeScaleHandler->SetModel(leftRenderModel ); + leftChangeScaleHandler->SetView(pRightVisuView); + leftChangeScaleHandler->SetView2(pLeftVisuView); + + rightController->AddActionHandler( leftChangeScaleHandler); + leftController->AddActionHandler(rightChangeScaleHandler); + + // Add the change scaled handler + ChangeScaleHandlerType::Pointer rChangeScaleHandler =ChangeScaleHandlerType::New(); + rChangeScaleHandler->SetModel(leftRenderModel ); + rChangeScaleHandler->SetView(pLeftVisuView); + + ChangeScaleHandlerType::Pointer lChangeScaleHandler =ChangeScaleHandlerType::New(); + lChangeScaleHandler->SetModel(rightRenderModel ); + lChangeScaleHandler->SetView(pRightVisuView); + + rightController->AddActionHandler( lChangeScaleHandler); + leftController->AddActionHandler(rChangeScaleHandler); + +*/ + + + + + + // Add the resizing handler ResizingHandlerType::Pointer rightResizingHandler = ResizingHandlerType::New(); rightResizingHandler->SetModel(rightRenderModel); @@ -602,17 +648,22 @@ ViewerModel rightController->AddActionHandler( leftChangeHandler); leftController->AddActionHandler(rightChangeHandler); + // Add the change scaled handler ChangeScaleHandlerType::Pointer rightChangeScaleHandler =ChangeScaleHandlerType::New(); rightChangeScaleHandler->SetModel(rightRenderModel ); rightChangeScaleHandler->SetView(pLeftVisuView); + rightChangeScaleHandler->SetViewToUpdate(pRightVisuView); ChangeScaleHandlerType::Pointer leftChangeScaleHandler =ChangeScaleHandlerType::New(); leftChangeScaleHandler->SetModel(leftRenderModel ); leftChangeScaleHandler->SetView(pRightVisuView); + leftChangeScaleHandler->SetViewToUpdate(pLeftVisuView); - rightController->AddActionHandler( leftChangeScaleHandler); - leftController->AddActionHandler(rightChangeScaleHandler); + // This handler has to be set before the classical zoom handler of + // the ImageView to avoid confusion + rightController->InsertActionHandler(0, leftChangeScaleHandler); + leftController->InsertActionHandler(0, rightChangeScaleHandler); //Pixel Description Handling-- PixelDescriptionActionHandlerType::Pointer rightPixelActionHandler = PixelDescriptionActionHandlerType::New(); @@ -625,8 +676,8 @@ ViewerModel leftPixelActionHandler->SetModel(leftPixelModel); leftPixelActionHandler->SetOffset(offset); - rightController->AddActionHandler(leftPixelActionHandler ); - leftController->AddActionHandler(rightPixelActionHandler); + //rightController->AddActionHandler(leftPixelActionHandler ); + //leftController->AddActionHandler(rightPixelActionHandler); } diff --git a/Code/Visualization/otbChangeScaleActionHandler.h b/Code/Visualization/otbChangeScaleActionHandler.h index 7030e50dca4d4b2379be4b0209742bf70803eac9..99ad7bc91878937106ce35a420cb4210cca2151c 100644 --- a/Code/Visualization/otbChangeScaleActionHandler.h +++ b/Code/Visualization/otbChangeScaleActionHandler.h @@ -25,12 +25,17 @@ namespace otb /** \class ChangeScaleActionHandler * \brief Implements basic Scroll, Full and Zoom widgets resizing. * +* The m_ViewToUpdate attribut is use in the case of the view and the +* model doesn't belong to the same ImageView (typically, Link function +* in otbView). If a m_ViewToUpdate is set, the IsotropicZoom of its +* ZoomWidget will be update too (at the same time of the one of m_View). +* * \sa ImageWidgetController * \sa ImageWidgetActionHandler * \ingroup Visualization */ -template <class TModel, class TView> +template <class TModel, class TView, class TViewToUpdate=TView> class ChangeScaleActionHandler : public ImageWidgetActionHandler { @@ -55,6 +60,9 @@ public: /** View typedefs */ typedef TView ViewType; typedef typename ViewType::Pointer ViewPointerType; + + typedef TViewToUpdate ViewToUpdateType; + typedef typename ViewToUpdateType::Pointer ViewToUpdatePointerType; /** Handle widget event * \param widgetId The id of the moved widget @@ -78,6 +86,13 @@ public: if (newScale >= 1.0) { m_View->GetZoomWidget()->SetIsotropicZoom(newScale); + + // If set, update the IsotropicZoom of the second view + if(m_ViewToUpdate.IsNotNull()) + { + m_ViewToUpdate->GetZoomWidget()->SetIsotropicZoom(newScale); + } + RegionType region = m_Model->GetScaledExtractRegion(); typename RegionType::IndexType index = region.GetIndex(); @@ -102,6 +117,9 @@ public: itkSetObjectMacro(View, ViewType); itkGetObjectMacro(View, ViewType); + itkSetObjectMacro(ViewToUpdate, ViewToUpdateType); + itkGetObjectMacro(ViewToUpdate, ViewToUpdateType); + /** Set/Get the pointer to the model */ itkSetObjectMacro(Model, ModelType); itkGetObjectMacro(Model, ModelType); @@ -113,7 +131,9 @@ public: protected: /** Constructor */ ChangeScaleActionHandler() : m_View(), m_Model(), m_ScaleRatio(1.25) - {} + { + m_ViewToUpdate = NULL; + } /** Destructor */ virtual ~ChangeScaleActionHandler(){} @@ -129,6 +149,7 @@ private: // Pointer to the view ViewPointerType m_View; + ViewToUpdatePointerType m_ViewToUpdate; // Pointer to the model ModelPointerType m_Model; diff --git a/Code/Visualization/otbImageWidgetController.cxx b/Code/Visualization/otbImageWidgetController.cxx index aa08c786780c66ef181fee12307fbcf6fbb54afc..f949bd8505c765bb794f8ff4e0293478d1ac5802 100644 --- a/Code/Visualization/otbImageWidgetController.cxx +++ b/Code/Visualization/otbImageWidgetController.cxx @@ -35,6 +35,12 @@ void ImageWidgetController::AddActionHandler(ActionHandlerType * handler) m_ActionHandlersList->PushBack(handler); } +void ImageWidgetController::InsertActionHandler(const unsigned int id, ActionHandlerType * handler) +{ + // Insert the handler to the specified index in the list + m_ActionHandlersList->Insert(m_ActionHandlersList->Begin()+id, handler); +} + void ImageWidgetController::RemoveActionHandler(unsigned int index) { // Remove the given handler diff --git a/Code/Visualization/otbImageWidgetController.h b/Code/Visualization/otbImageWidgetController.h index 568432f42c92c06f2fbaa38f698c9121f2f7d98b..0088f8c91f29a18d18bf89916c8a118297731405 100644 --- a/Code/Visualization/otbImageWidgetController.h +++ b/Code/Visualization/otbImageWidgetController.h @@ -60,6 +60,12 @@ public: **/ virtual void AddActionHandler(ActionHandlerType * handler); + /** Insert an action handler to a specified index + * \param handler The action handler. + **/ + virtual void InsertActionHandler(const unsigned int id, ActionHandlerType * handler); + + /** Remove an action handler if it exists * \param index The index of the action handler. **/