From fc7acb097601b8e9ff688688dda039c7344ac826 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@c-s.fr> Date: Mon, 19 Feb 2007 10:02:41 +0000 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20viewer.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Code/Visu/otbImageViewer.h | 4 +- Code/Visu/otbImageViewer.txx | 47 +++++++++++++--------- Code/Visu/otbImageViewerFullWidget.h | 54 ++++++++++++++++++++++++-- Code/Visu/otbImageViewerScrollWidget.h | 2 +- Code/Visu/otbImageViewerZoomWidget.h | 54 +++++++++++++++++++++++--- 5 files changed, 132 insertions(+), 29 deletions(-) diff --git a/Code/Visu/otbImageViewer.h b/Code/Visu/otbImageViewer.h index 0b4b1798a6..e7a2cadb17 100644 --- a/Code/Visu/otbImageViewer.h +++ b/Code/Visu/otbImageViewer.h @@ -90,6 +90,8 @@ class ITK_EXPORT ImageViewer itkGetMacro(GreenChannelIndex,unsigned int); itkSetMacro(BlueChannelIndex,unsigned int); itkGetMacro(BlueChannelIndex,unsigned int); + itkSetMacro(Label,char *); + itkGetMacro(Label,const char *); /** Set the input image */ @@ -152,7 +154,7 @@ protected: unsigned int m_RedChannelIndex; unsigned int m_GreenChannelIndex; unsigned int m_BlueChannelIndex; - + const char * m_Label; }; diff --git a/Code/Visu/otbImageViewer.txx b/Code/Visu/otbImageViewer.txx index b2791dbe1e..025fa8cbb2 100644 --- a/Code/Visu/otbImageViewer.txx +++ b/Code/Visu/otbImageViewer.txx @@ -54,6 +54,7 @@ namespace otb m_ScrollWindow=NULL; m_PixLocWindow=NULL; m_PixLocOutput=NULL; + m_Label="OTB Image viewer"; } /// Destructor template <class TPixel> @@ -171,6 +172,7 @@ namespace otb { itkExceptionMacro(<<"No input image !"); } + std::stringstream oss; // Get the image dimension typename ImageType::SizeType size = m_InputImage->GetLargestPossibleRegion().GetSize(); m_ImageGeometry = static_cast<double>(size[0])/static_cast<double>(size[1]); @@ -182,14 +184,17 @@ namespace otb int hfull = (size[1]<m_FullMaxInitialSize ? size[1] : m_FullMaxInitialSize); // Create full windows - m_FullWindow = new Fl_Window(0,0,wfull,hfull,"Full Resolution Window"); + oss.str(""); + oss<<m_Label<<" - Full Window"; + m_FullWindow = new Fl_Window(0,0,wfull,hfull,""); + m_FullWindow->copy_label(oss.str().c_str()); m_FullWidget = FullWidgetType::New(); m_FullWindow->resizable(m_FullWidget); m_FullWidget->SetParent(this); m_FullWindow->size_range(0,0,size[0],size[1]); m_FullWindow->end(); m_FullWidget->SetInput(m_InputImage); - m_FullWidget->Init(0,0,wfull,hfull,"Full Resolution Window"); + m_FullWidget->Init(0,0,wfull,hfull,""); m_FullWidget->box( FL_EMBOSSED_BOX ); m_FullWidget->SetFormOverlayVisible(true); @@ -222,14 +227,17 @@ namespace otb m_Shrink->Update(); // Create the scroll windows - m_ScrollWindow = new Fl_Window(wfull+15,0,wscroll,hscroll,"Scroll Window"); + oss.str(""); + oss<<m_Label<<" - Scroll Window"; + m_ScrollWindow = new Fl_Window(wfull+15,0,wscroll,hscroll,""); + m_ScrollWindow->copy_label(oss.str().c_str()); m_ScrollWidget = ScrollWidgetType::New(); m_ScrollWindow->resizable(m_ScrollWidget); m_ScrollWindow->size_range(wscroll,hscroll,size[0],size[1],0,0,1); m_ScrollWindow->end(); m_ScrollWidget->SetInput(m_Shrink->GetOutput()); m_ScrollWidget->SetParent(this); - m_ScrollWidget->Init(0,0,wscroll,hscroll,"Scroll window"); + m_ScrollWidget->Init(0,0,wscroll,hscroll,oss.str().c_str()); m_ScrollWidget->box( FL_EMBOSSED_BOX ); m_ScrollWidget->SetFormOverlayVisible(true); @@ -261,7 +269,8 @@ namespace otb } } // Create the zoom window - m_ZoomWindow = new Fl_Window(wfull+15,hscroll+45,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,"Zoom Window"); + std::string zoomLabel="Zoom Window"; + m_ZoomWindow = new Fl_Window(wfull+15,hscroll+110,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,zoomLabel.c_str()); m_ZoomWidget = ZoomWidgetType::New(); m_ZoomWidget->SetParent(this); m_ZoomWindow->resizable(m_ZoomWidget); @@ -269,7 +278,7 @@ namespace otb m_ZoomWindow->end(); m_ZoomWidget->SetZoomFactor(4.0); m_ZoomWidget->SetInput(m_InputImage); - m_ZoomWidget->Init(0,0,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,"Zoom Window"); + m_ZoomWidget->Init(0,0,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,zoomLabel.c_str()); m_ZoomWidget->box( FL_EMBOSSED_BOX ); m_ZoomWidget->SetFormOverlayVisible(true); @@ -321,15 +330,16 @@ namespace otb m_ScrollWidget->SetMaxComponentValues(m_MaxComponentValue); } - m_PixLocWindow= new Fl_Window(0,hfull+15,250,30,"Pixel location & values"); - m_PixLocOutput = new Fl_Output(0,0,250,30,"Pixel location & values"); + m_PixLocWindow= new Fl_Window(wfull+15,hscroll+50,wscroll,20,"Pixel location & values"); + m_PixLocOutput = new Fl_Output(0,0,wscroll,20,"Pixel location & values"); m_PixLocWindow->resizable(m_PixLocOutput); + m_PixLocOutput->textsize(10); m_PixLocOutput->box(FL_EMBOSSED_BOX ); m_PixLocWindow->end(); + m_Built=true; // Built done - m_Built=true; - otbMsgDebugMacro(<<"Leaving build method"); + // otbMsgDebugMacro(<<"Leaving build method"); } /// Set the left image template <class TPixel> @@ -345,25 +355,25 @@ namespace otb ImageViewer<TPixel> ::Show(void) { - otbMsgDebugMacro(<<"Entering show method."); + // otbMsgDebugMacro(<<"Entering show method."); Fl::check(); if(m_UseScroll) { - otbMsgDebugMacro(<<"Showing scroll widget."); + // otbMsgDebugMacro(<<"Showing scroll widget."); m_ScrollWindow->show(); m_ScrollWidget->Show(); } - otbMsgDebugMacro(<<"Showing full widget."); + // otbMsgDebugMacro(<<"Showing full widget."); m_FullWindow->show(); m_FullWidget->Show(); - otbMsgDebugMacro(<<"Showing zoom widget."); + // otbMsgDebugMacro(<<"Showing zoom widget."); m_ZoomWindow->show(); m_ZoomWidget->Show(); - otbMsgDebugMacro(<<"Between show and check"); + // otbMsgDebugMacro(<<"Between show and check"); m_PixLocWindow->show(); m_PixLocOutput->show(); Fl::check(); - otbMsgDebugMacro(<<"Leaving Show method."); + // otbMsgDebugMacro(<<"Leaving Show method."); } /// Hide the app template <class TPixel> @@ -380,8 +390,9 @@ namespace otb Fl::check(); UpdateScrollWidget(); UpdateFullWidget(); - UpdateZoomWidget(); + UpdateZoomWidget(); Fl::check(); + } template <class TPixel> @@ -401,7 +412,7 @@ namespace otb { std::stringstream oss; oss<<"Zoom Window (X"<<m_ZoomWidget->GetOpenGlIsotropicZoom()<<")"; - m_ZoomWindow->label(oss.str().c_str()); + m_ZoomWindow->copy_label(oss.str().c_str()); m_ZoomWindow->redraw(); m_ZoomWidget->redraw(); } diff --git a/Code/Visu/otbImageViewerFullWidget.h b/Code/Visu/otbImageViewerFullWidget.h index d88dee6f86..ebc544b15a 100644 --- a/Code/Visu/otbImageViewerFullWidget.h +++ b/Code/Visu/otbImageViewerFullWidget.h @@ -46,6 +46,7 @@ class ITK_EXPORT ImageViewerFullWidget typedef TPixel PixelType; typedef typename Superclass::IndexType IndexType; typedef typename Superclass::SizeType SizeType; + typedef typename Superclass::ImageType ImageType; typedef ImageViewer<PixelType> ParentType; typedef typename ParentType::Pointer ParentPointerType; @@ -86,15 +87,60 @@ class ITK_EXPORT ImageViewerFullWidget { m_MousePos[0]=Fl::event_x(); m_MousePos[1]=Fl::event_y(); - std::stringstream oss; IndexType newIndex = this->WindowToImageCoordinates(m_MousePos); - oss<<"Location: "<<newIndex<<", Values: "<<this->GetInput()->GetPixel(newIndex); - m_Parent->PrintPixLocVal(oss.str()); - m_MouseMoveCount=0; + if(this->GetInput()->GetBufferedRegion().IsInside(newIndex)) + { + std::stringstream oss; + typename ImageType::PixelType newPixel = this->GetInput()->GetPixel(newIndex); + oss<<" Location: "<<newIndex<<", Values: "<<newPixel; + m_Parent->PrintPixLocVal(oss.str()); + m_MouseMoveCount=0; + } } m_MouseMoveCount++; return 1; } + case FL_FOCUS: + { + return 1; + } + case FL_UNFOCUS: + { + return 1; + } + case FL_KEYDOWN: + { + IndexType newIndex = this->GetViewedRegion().GetIndex(); + SizeType newSize = this->GetViewedRegion().GetSize(); + newIndex[0]=newIndex[0]+newSize[0]/2; + newIndex[1] = newIndex[1] + newSize[1]/2; + switch(Fl::event_key()) + { + case FL_Down: + { + newIndex[1] = newIndex[1]+newSize[1]/8; + break; + } + case FL_Up: + { + newIndex[1] = newIndex[1]-newSize[1]/8; + break; + } + case FL_Left: + { + newIndex[0] = newIndex[0]-newSize[0]/8; + break; + } + case FL_Right: + { + newIndex[0] = newIndex[0]+newSize[0]/8; + break; + } + } + m_Parent->ChangeFullViewedRegion(newIndex); + m_Parent->ChangeZoomViewedRegion(newIndex); + return 1; + } } return 0; } diff --git a/Code/Visu/otbImageViewerScrollWidget.h b/Code/Visu/otbImageViewerScrollWidget.h index 06cdad1c5d..c259d4fd3e 100644 --- a/Code/Visu/otbImageViewerScrollWidget.h +++ b/Code/Visu/otbImageViewerScrollWidget.h @@ -100,7 +100,7 @@ class ITK_EXPORT ImageViewerScrollWidget 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); + oss<<" Location: "<<realIndex<<", Values: "<<this->GetInput()->GetPixel(newIndex); m_Parent->PrintPixLocVal(oss.str()); m_MouseMoveCount=0; } diff --git a/Code/Visu/otbImageViewerZoomWidget.h b/Code/Visu/otbImageViewerZoomWidget.h index ca3e425304..05272783e7 100644 --- a/Code/Visu/otbImageViewerZoomWidget.h +++ b/Code/Visu/otbImageViewerZoomWidget.h @@ -82,10 +82,13 @@ class ITK_EXPORT ImageViewerZoomWidget m_MousePos[0]=Fl::event_x(); m_MousePos[1]=Fl::event_y(); IndexType newIndex = this->WindowToImageCoordinates(m_MousePos); - std::stringstream oss; - oss<<"Location: "<<newIndex<<", Values: "<<this->GetInput()->GetPixel(newIndex); - m_Parent->PrintPixLocVal(oss.str()); - m_MouseMoveCount=0; + if(this->GetInput()->GetBufferedRegion().IsInside(newIndex)) + { + std::stringstream oss; + oss<<" Location: "<<newIndex<<", Values: "<<this->GetInput()->GetPixel(newIndex); + m_Parent->PrintPixLocVal(oss.str()); + m_MouseMoveCount=0; + } } m_MouseMoveCount++; return 1; @@ -112,7 +115,48 @@ class ITK_EXPORT ImageViewerZoomWidget m_Parent->UpdateZoomWidget(); return 1; } - } +case FL_FOCUS: + { + return 1; + } + case FL_UNFOCUS: + { + return 1; + } + case FL_KEYDOWN: + { + IndexType newIndex = this->GetViewedRegion().GetIndex(); + SizeType newSize = this->GetViewedRegion().GetSize(); + newIndex[0]=newIndex[0]+newSize[0]/2; + newIndex[1] = newIndex[1] + newSize[1]/2; + switch(Fl::event_key()) + { + case FL_Down: + { + newIndex[1] = newIndex[1]+newSize[1]/8; + break; + } + case FL_Up: + { + newIndex[1] = newIndex[1]-newSize[1]/8; + break; + } + case FL_Left: + { + newIndex[0] = newIndex[0]-newSize[0]/8; + break; + } + case FL_Right: + { + newIndex[0] = newIndex[0]+newSize[0]/8; + break; + } + } + m_Parent->ChangeZoomViewedRegion(newIndex); + return 1; + } + + } return 0; } -- GitLab