diff --git a/Code/Visu/otbFullResolutionImageWidget.h b/Code/Visu/otbFullResolutionImageWidget.h index 02f2106fc6d1a5d0d0db852308377b6966cf8f25..e58f79fa9aa3cc9edf6ccd981bfb117f807029b8 100644 --- a/Code/Visu/otbFullResolutionImageWidget.h +++ b/Code/Visu/otbFullResolutionImageWidget.h @@ -62,7 +62,7 @@ class FullResolutionImageWidget * Set upper left corner position in image. * \param index the upper left corner index. */ - void SetUpperLeftCorner(IndexType index); + virtual void SetUpperLeftCorner(IndexType index); itkGetMacro(UpperLeftCorner,IndexType); protected: diff --git a/Code/Visu/otbImageViewerBase.txx b/Code/Visu/otbImageViewerBase.txx index 16fa22b4c7c7fe7fdcf1142f8a1f3d39f78b3a61..18213d24361fc9c55711ed8768ff4cf831948c27 100644 --- a/Code/Visu/otbImageViewerBase.txx +++ b/Code/Visu/otbImageViewerBase.txx @@ -851,31 +851,35 @@ template <class TPixel, class TLabel> ImageViewerBase<TPixel,TLabel> ::ChangeZoomViewedRegion(IndexType clickedIndex) { + m_Updating = true; //comment: std::cout<<"ChangeZoomViewedRegion: "<<m_Label<<" Updating flag on"<<std::endl; - RegionType region = m_ZoomWidget->GetViewedRegion(); - IndexType newIndex; - newIndex[0]=clickedIndex[0]-region.GetSize()[0]/2; - newIndex[1]=clickedIndex[1]-region.GetSize()[1]/2; - - region.SetIndex(newIndex); - RegionType newRegion = ComputeConstrainedRegion(region,m_FullWidget->GetViewedRegion()); - m_ZoomWidget->SetZoomUpperLeftCorner(newRegion.GetIndex()); - - typename ViewerListType::Iterator linkedIt = m_LinkedViewerList->Begin(); - typename OffsetListType::iterator offIt = m_LinkedViewerOffsetList.begin(); - - while(linkedIt!=m_LinkedViewerList->End()&&offIt!=m_LinkedViewerOffsetList.end()) + if(m_ShowZoomWidget) { - if(!linkedIt.Get()->GetUpdating()) + RegionType region = m_ZoomWidget->GetViewedRegion(); + IndexType newIndex; + newIndex[0]=clickedIndex[0]-region.GetSize()[0]/2; + newIndex[1]=clickedIndex[1]-region.GetSize()[1]/2; + + region.SetIndex(newIndex); + RegionType newRegion = ComputeConstrainedRegion(region,m_FullWidget->GetViewedRegion()); + m_ZoomWidget->SetZoomUpperLeftCorner(newRegion.GetIndex()); + + typename ViewerListType::Iterator linkedIt = m_LinkedViewerList->Begin(); + typename OffsetListType::iterator offIt = m_LinkedViewerOffsetList.begin(); + + while(linkedIt!=m_LinkedViewerList->End()&&offIt!=m_LinkedViewerOffsetList.end()) { - IndexType linkedIndex; - linkedIndex[0] = clickedIndex[0]+(*offIt)[0]; - linkedIndex[1] = clickedIndex[1]+(*offIt)[1]; - linkedIt.Get()->ChangeZoomViewedRegion(linkedIndex); + if(!linkedIt.Get()->GetUpdating()) + { + IndexType linkedIndex; + linkedIndex[0] = clickedIndex[0]+(*offIt)[0]; + linkedIndex[1] = clickedIndex[1]+(*offIt)[1]; + linkedIt.Get()->ChangeZoomViewedRegion(linkedIndex); + } + ++offIt; + ++linkedIt; } - ++offIt; - ++linkedIt; } //comment: std::cout<<"ChangeZoomViewedRegion: "<<m_Label<<" Updating flag off"<<std::endl; m_Updating = false; diff --git a/Code/Visu/otbImageViewerFullResolutionEventsInterface.h b/Code/Visu/otbImageViewerFullResolutionEventsInterface.h index f36f1854333a42c0658c3d93c5f130c4e675440b..f2feb9eb8b293afc2b28c82279d45ecb3151185c 100644 --- a/Code/Visu/otbImageViewerFullResolutionEventsInterface.h +++ b/Code/Visu/otbImageViewerFullResolutionEventsInterface.h @@ -38,13 +38,16 @@ class ImageViewerFullResolutionEventsInterface itkTypeMacro(ImageViewerFullResolutionEventsInterface,Superclass); typedef itk::ImageRegion<2> RegionType; + typedef RegionType::IndexType IndexType; itkSetMacro(ForwardEvents,bool); itkGetMacro(ForwardEvents,bool); /** Users actions */ - virtual void RegionSelected(const RegionType & region) = 0; - + virtual void RegionSelected(const RegionType & region){}; + virtual void ViewedRegionChanged(){}; + virtual void PixelClicked(const IndexType& index){}; + protected: /** Constructor */ ImageViewerFullResolutionEventsInterface() diff --git a/Code/Visu/otbImageViewerFullWidget.h b/Code/Visu/otbImageViewerFullWidget.h index 750306b2d8cfe83932018d35d1249984eec6d631..e3a6546063d590d9f3a729f4d9fe279770a5eba7 100644 --- a/Code/Visu/otbImageViewerFullWidget.h +++ b/Code/Visu/otbImageViewerFullWidget.h @@ -82,7 +82,17 @@ class ITK_EXPORT ImageViewerFullWidget itkGetMacro(Parent,ParentPointerType); itkGetObjectMacro(EventsInterface,EventsInterfaceType); itkSetObjectMacro(EventsInterface,EventsInterfaceType); - /** Handle method */ + + virtual void SetUpperLeftCorner(IndexType index) + { + Superclass::SetUpperLeftCorner(index); + if(m_EventsInterface.IsNotNull()) + { + m_EventsInterface->ViewedRegionChanged(); + } + } + + /** Handle method */ /** Default mode handling, without ROI selection */ @@ -99,8 +109,16 @@ class ITK_EXPORT ImageViewerFullWidget clickedIndex[0]=x; clickedIndex[1]=y; clickedIndex=this->WindowToImageCoordinates(clickedIndex); - m_Parent->ChangeZoomViewedRegion(clickedIndex); - m_Parent->Update(); + + if(m_EventsInterface.IsNotNull()) + { + m_EventsInterface->PixelClicked(clickedIndex); + } + if(m_EventsInterface.IsNotNull() && m_EventsInterface->GetForwardEvents()) + { + m_Parent->ChangeZoomViewedRegion(clickedIndex); + m_Parent->Update(); + } return 1; } case FL_KEYDOWN: diff --git a/Examples/Projections/OrthoRectificationExample.cxx b/Examples/Projections/OrthoRectificationExample.cxx index 06239c29b68b19c8098d99356696615fae33777e..bdf9c7289b42de301b95cae35f4f36bef6a5a92a 100644 --- a/Examples/Projections/OrthoRectificationExample.cxx +++ b/Examples/Projections/OrthoRectificationExample.cxx @@ -81,10 +81,8 @@ int main( int argc, char* argv[] ) - - typedef otb::Image<unsigned char, 2> CharImageType; - typedef otb::Image<unsigned int, 2> ImageType; - typedef otb::VectorImage<unsigned int, 2> VectorImageType; + typedef otb::Image<int, 2> ImageType; + typedef otb::VectorImage<int, 2> VectorImageType; typedef otb::ImageFileReader<VectorImageType> ReaderType; typedef otb::StreamingImageFileWriter<VectorImageType> WriterType;