diff --git a/Code/Visu/otbImageViewer.txx b/Code/Visu/otbImageViewer.txx index 1b01a7d46063df5ef48fae7eb738e915578c1f44..71a25b641cffc4791c26ba9db388a671bc0e8344 100644 --- a/Code/Visu/otbImageViewer.txx +++ b/Code/Visu/otbImageViewer.txx @@ -63,16 +63,42 @@ namespace otb ImageViewer<TPixel> ::~ImageViewer() { + + Hide(); + if (m_FullWindow!=NULL) - delete m_FullWindow; + { + m_FullWindow->remove(m_FullWidget); + delete m_FullWindow; + m_FullWindow = NULL; + } + m_ZoomWidget = NULL; if(m_ZoomWindow!=NULL) - delete m_ZoomWindow; + { + m_ZoomWindow->remove(m_ZoomWidget); + delete m_ZoomWindow; + m_ZoomWindow = NULL; + } + if(m_ScrollWindow!=NULL) - delete m_ScrollWindow; + { + m_ScrollWindow->remove(m_ScrollWidget); + delete m_ScrollWindow; + m_ScrollWindow = NULL; + } + if(m_PixLocWindow!=NULL) + { + m_PixLocWindow->remove(m_PixLocOutput); delete m_PixLocWindow; + m_PixLocWindow = NULL; + } if(m_PixLocOutput!=NULL) + { delete m_PixLocOutput; + m_PixLocOutput = NULL; + } + } /// Compute the normalization factor @@ -414,6 +440,7 @@ namespace otb m_PixLocWindow->hide(); m_PixLocOutput->hide(); Fl::check(); + } /// Update the display diff --git a/Code/Visu/otbImageViewerFullWidget.h b/Code/Visu/otbImageViewerFullWidget.h index 0a3a4a398f474cf82476c2e631f073c81a46bb8c..0ad96d5710fa7113f9b949bc2f576a3337c6f6ff 100644 --- a/Code/Visu/otbImageViewerFullWidget.h +++ b/Code/Visu/otbImageViewerFullWidget.h @@ -55,10 +55,10 @@ class ITK_EXPORT ImageViewerFullWidget typedef typename Superclass::ImageType ImageType; typedef ImageViewer<PixelType> ParentType; - typedef typename ParentType::Pointer ParentPointerType; + typedef ParentType* ParentPointerType; - itkSetObjectMacro(Parent,ParentType); - itkGetObjectMacro(Parent,ParentType); + itkSetMacro(Parent,ParentPointerType); + itkGetMacro(Parent,ParentPointerType); /** Handle method */ virtual int handle(int event) { @@ -72,7 +72,7 @@ class ITK_EXPORT ImageViewerFullWidget clickedIndex[0]=x; clickedIndex[1]=y; clickedIndex=this->WindowToImageCoordinates(clickedIndex); - GetParent()->ChangeZoomViewedRegion(clickedIndex); + m_Parent->ChangeZoomViewedRegion(clickedIndex); return 1; } case FL_ENTER: @@ -83,7 +83,7 @@ class ITK_EXPORT ImageViewerFullWidget case FL_LEAVE: { m_MouseIn = false; - GetParent()->PrintPixLocVal(""); + m_Parent->PrintPixLocVal(""); return 1; } case FL_MOVE: @@ -99,7 +99,7 @@ class ITK_EXPORT ImageViewerFullWidget std::stringstream oss; typename ImageType::PixelType newPixel = this->GetInput()->GetPixel(newIndex); oss<<" Location: "<<newIndex<<", Values: "<<newPixel; - GetParent()->PrintPixLocVal(oss.str()); + m_Parent->PrintPixLocVal(oss.str()); m_MouseMoveCount=0; } } @@ -143,14 +143,14 @@ class ITK_EXPORT ImageViewerFullWidget break; } } - GetParent()->ChangeFullViewedRegion(newIndex); - GetParent()->ChangeZoomViewedRegion(newIndex); + m_Parent->ChangeFullViewedRegion(newIndex); + m_Parent->ChangeZoomViewedRegion(newIndex); return 1; } case FL_HIDE: { - GetParent()->Hide(); - return 1; + m_Parent->Hide(); + return 0; } } return 0; @@ -159,8 +159,8 @@ class ITK_EXPORT ImageViewerFullWidget virtual void resize(int x,int y, int w, int h) { Superclass::resize(x,y,w,h); - if(GetParent()->GetBuilt()) - GetParent()->UpdateScrollWidget(); + if(m_Parent->GetBuilt()) + m_Parent->UpdateScrollWidget(); } protected: @@ -177,7 +177,10 @@ class ITK_EXPORT ImageViewerFullWidget /** * Destructor. */ - ~ImageViewerFullWidget(){}; + ~ImageViewerFullWidget() + { + m_Parent = NULL; + } private: ParentPointerType m_Parent; diff --git a/Code/Visu/otbImageViewerScrollWidget.h b/Code/Visu/otbImageViewerScrollWidget.h index ec50deed4cc6407995557e8d1f68bddd204f25fd..058597e31671f07a81dd7e9c663243f5aca453ae 100644 --- a/Code/Visu/otbImageViewerScrollWidget.h +++ b/Code/Visu/otbImageViewerScrollWidget.h @@ -58,13 +58,13 @@ class ITK_EXPORT ImageViewerScrollWidget typedef typename Superclass::SizeType SizeType; typedef ImageViewer<PixelType> ParentType; - typedef typename ParentType::Pointer ParentPointerType; + typedef ParentType* ParentPointerType; typedef otb::ImageWidgetBoxForm BoxType; typedef BoxType::ColorType ColorType; - itkSetObjectMacro(Parent,ParentType); - itkGetObjectMacro(Parent,ParentType); + itkSetMacro(Parent,ParentPointerType); + itkGetMacro(Parent,ParentPointerType); /** Handle method */ virtual int handle(int event) { @@ -78,10 +78,10 @@ class ITK_EXPORT ImageViewerScrollWidget clickedIndex[0]=x; clickedIndex[1]=y; clickedIndex=this->WindowToImageCoordinates(clickedIndex); - clickedIndex[0]=clickedIndex[0]*GetParent()->GetShrinkFactor(); - clickedIndex[1]=clickedIndex[1]*GetParent()->GetShrinkFactor(); - GetParent()->ChangeFullViewedRegion(clickedIndex); - GetParent()->ChangeZoomViewedRegion(clickedIndex); + clickedIndex[0]=clickedIndex[0]*m_Parent->GetShrinkFactor(); + clickedIndex[1]=clickedIndex[1]*m_Parent->GetShrinkFactor(); + m_Parent->ChangeFullViewedRegion(clickedIndex); + m_Parent->ChangeZoomViewedRegion(clickedIndex); return 1; } case FL_ENTER: @@ -92,7 +92,7 @@ class ITK_EXPORT ImageViewerScrollWidget case FL_LEAVE: { m_MouseIn = false; - GetParent()->PrintPixLocVal(""); + m_Parent->PrintPixLocVal(""); return 1; } case FL_MOVE: @@ -104,11 +104,11 @@ class ITK_EXPORT ImageViewerScrollWidget m_MousePos[1]=Fl::event_y(); IndexType newIndex = this->WindowToImageCoordinates(m_MousePos); IndexType realIndex; - realIndex[0]=newIndex[0]*GetParent()->GetShrinkFactor(); - realIndex[1]=newIndex[1]*GetParent()->GetShrinkFactor(); + realIndex[0]=newIndex[0]*m_Parent->GetShrinkFactor(); + realIndex[1]=newIndex[1]*m_Parent->GetShrinkFactor(); std::stringstream oss; oss<<" Location: "<<realIndex<<", Values: "<<this->GetInput()->GetPixel(newIndex); - GetParent()->PrintPixLocVal(oss.str()); + m_Parent->PrintPixLocVal(oss.str()); m_MouseMoveCount=0; } m_MouseMoveCount++; @@ -116,8 +116,8 @@ class ITK_EXPORT ImageViewerScrollWidget } case FL_HIDE: { - GetParent()->Hide(); - return 1; + m_Parent->Hide(); + return 0; } } return 0; @@ -136,7 +136,10 @@ class ITK_EXPORT ImageViewerScrollWidget /** * Destructor. */ - ~ImageViewerScrollWidget(){}; + ~ImageViewerScrollWidget() + { + m_Parent = NULL; + } private: ParentPointerType m_Parent; diff --git a/Code/Visu/otbImageViewerZoomWidget.h b/Code/Visu/otbImageViewerZoomWidget.h index 4eb10493da0b967b63193592fd510c8f44c75f5b..3d6b77b380a97ba5c7536b952564130aa09770f4 100644 --- a/Code/Visu/otbImageViewerZoomWidget.h +++ b/Code/Visu/otbImageViewerZoomWidget.h @@ -57,10 +57,10 @@ class ITK_EXPORT ImageViewerZoomWidget typedef typename Superclass::SizeType SizeType; typedef ImageViewer<PixelType> ParentType; - typedef typename ParentType::Pointer ParentPointerType; + typedef ParentType* ParentPointerType; - itkSetObjectMacro(Parent,ParentType); - itkGetObjectMacro(Parent,ParentType); + itkSetMacro(Parent,ParentPointerType); + itkGetMacro(Parent,ParentPointerType); /** Handle method */ virtual int handle(int event) { @@ -75,8 +75,8 @@ class ITK_EXPORT ImageViewerZoomWidget case FL_LEAVE: { m_MouseIn = false; - GetParent()->UpdateZoomWidget(); - GetParent()->PrintPixLocVal(""); + m_Parent->UpdateZoomWidget(); + m_Parent->PrintPixLocVal(""); // otbMsgDebugMacro(<<"Mouse out"); return 1; } @@ -92,7 +92,7 @@ class ITK_EXPORT ImageViewerZoomWidget { std::stringstream oss; oss<<" Location: "<<newIndex<<", Values: "<<this->GetInput()->GetPixel(newIndex); - GetParent()->PrintPixLocVal(oss.str()); + m_Parent->PrintPixLocVal(oss.str()); m_MouseMoveCount=0; } } @@ -117,8 +117,8 @@ class ITK_EXPORT ImageViewerZoomWidget this->SetZoomFactor(1.0); } } - GetParent()->UpdateFullWidget(); - GetParent()->UpdateZoomWidget(); + m_Parent->UpdateFullWidget(); + m_Parent->UpdateZoomWidget(); return 1; } case FL_FOCUS: @@ -158,7 +158,7 @@ case FL_FOCUS: break; } } - GetParent()->ChangeZoomViewedRegion(newIndex); + m_Parent->ChangeZoomViewedRegion(newIndex); return 1; } @@ -170,8 +170,8 @@ case FL_FOCUS: virtual void resize(int x,int y, int w, int h) { Superclass::resize(x,y,w,h); - if(GetParent()->GetBuilt()) - GetParent()->UpdateFullWidget(); + if(m_Parent->GetBuilt()) + m_Parent->UpdateFullWidget(); } @@ -191,7 +191,10 @@ case FL_FOCUS: /** * Destructor. */ - ~ImageViewerZoomWidget(){}; + ~ImageViewerZoomWidget() + { + m_Parent = NULL; + } private: ParentPointerType m_Parent;