Skip to content
Snippets Groups Projects
Commit a5466b68 authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

BUG: fix bug 450. Trouble in handler order and no updated isotropiczoom for the second view

parent 3d4e7922
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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.
**/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment