From b641daa81052dcd500ed7c8fbbfea7269ee16f06 Mon Sep 17 00:00:00 2001 From: Otmane Lahlou <otmane.lahlou@c-s.fr> Date: Tue, 6 Oct 2009 10:16:50 +0200 Subject: [PATCH] MRG --- .../Visualization/otbHistogramActionHandler.h | 69 ++++++++++++------- Code/Visualization/otbImageLayer.txx | 23 ++++++- .../otbStandardRenderingFunction.h | 10 +-- 3 files changed, 71 insertions(+), 31 deletions(-) diff --git a/Code/Visualization/otbHistogramActionHandler.h b/Code/Visualization/otbHistogramActionHandler.h index d04607a922..875cc199b0 100644 --- a/Code/Visualization/otbHistogramActionHandler.h +++ b/Code/Visualization/otbHistogramActionHandler.h @@ -60,12 +60,13 @@ public: typedef typename ViewType::ImageWidgetType::PointType PointType; /** Curve Widget*/ - typedef Curves2DWidget CurveWidgetType; - typedef typename CurveWidgetType::Pointer CurveWidgetPointerType; + typedef Curves2DWidget CurveWidgetType; + typedef typename CurveWidgetType::Pointer CurveWidgetPointerType; /** Rendering Function Type */ - typedef TRenderingFunction SRenderingFunctionType; - typedef typename SRenderingFunctionType::Pointer SRenderingFunctionPointerType; + typedef TRenderingFunction RenderingFunctionType; + typedef typename RenderingFunctionType::Pointer RenderingFunctionPointerType; + typedef typename RenderingFunctionType::ParametersType ParametersType; /** */ typedef VerticalAsymptoteCurve VerticalAsymptoteType; @@ -73,10 +74,9 @@ public: - /** Handle Boundaries translation - * \param widgetId The id of the resized widget - * \param x new x location - * \param y new y location + /** Handle vertical asymptotes translation + * \param widgetId The id of the handled Curve widget + * \param event kind of event ot handle : FL_DRAG , FL_PUSH, FL_RELEASE */ virtual bool HandleWidgetEvent(std::string widgetId, int event) { @@ -99,8 +99,7 @@ virtual bool HandleWidgetEvent(std::string widgetId, int event) { // Position Clicked double x = Fl::event_x(); - - //std::cout <<"I clicked in position " << x << "," << y << std::endl; + //typename SRenderingFunctionType::ParametersType param = m_RenderingFunction->GetParameters(); if ((vcl_abs(x-abcisseL)<50) || (vcl_abs(x-abcisseR)<50)) @@ -118,6 +117,16 @@ virtual bool HandleWidgetEvent(std::string widgetId, int event) } case FL_RELEASE: { + if(m_ModifyLeft || m_ModifyRight) + { + // + m_Model->Update(); + // +/* m_View->GetScrollWidget()->redraw(); */ +/* m_View->GetFullWidget()->redraw(); */ +/* m_View->GetZoomWidget()->redraw(); */ + } + m_ModifyLeft = false; m_ModifyRight = false; return true; @@ -131,9 +140,12 @@ virtual bool HandleWidgetEvent(std::string widgetId, int event) double tx = x - abcisseL; m_LeftAsymptote->SetAbcisse(m_LeftAsymptote->GetAbcisse() + tx); m_Curve->redraw(); - - //Update The Rendering Function min and max - //.... + + // Update The Rendering Function min and max + ParametersType param = m_RenderingFunction->GetParameters(); + param.SetElement(2*m_Channel, m_LeftAsymptote->GetAbcisse() + tx); + param.SetElement(2*m_Channel, m_RightAsymptote->GetAbcisse()); + m_RenderingFunction->SetParameters(param); } if(m_ModifyRight) @@ -141,11 +153,13 @@ virtual bool HandleWidgetEvent(std::string widgetId, int event) double tx = x - abcisseR; m_RightAsymptote->SetAbcisse(m_RightAsymptote->GetAbcisse() + tx); m_Curve->redraw(); - - //Update The Rendering Function min and max - //.... + + // Update The Rendering Function min and max + ParametersType param = m_RenderingFunction->GetParameters(); + param.SetElement(2*m_Channel, m_LeftAsymptote->GetAbcisse()); + param.SetElement(2*m_Channel, m_RightAsymptote->GetAbcisse()+tx); + m_RenderingFunction->SetParameters(param); } - return true; } } @@ -167,17 +181,20 @@ virtual bool HandleWidgetEvent(std::string widgetId, int event) /** Get The left asymptote*/ itkSetObjectMacro(LeftAsymptote,VerticalAsymptoteType); itkSetObjectMacro(RightAsymptote,VerticalAsymptoteType); - - + /** Set/Get the rendering Function */ - itkSetObjectMacro(RenderingFunction , SRenderingFunctionType); + itkSetObjectMacro(RenderingFunction , RenderingFunctionType); + + /** Set/Get the channel dealed with in the image*/ + itkSetMacro(Channel,unsigned int); protected: /** Constructor */ HistogramActionHandler() : m_View(), m_Model(), m_RenderingFunction() { - m_ModifyLeft = false; - m_ModifyRight = false; + m_Channel = 0; + m_ModifyLeft = false; + m_ModifyRight = false; } /** Destructor */ @@ -202,17 +219,19 @@ private: CurveWidgetPointerType m_Curve; // StandardRenderingFunction - SRenderingFunctionPointerType m_RenderingFunction; + RenderingFunctionPointerType m_RenderingFunction; // Left And Rigth Asymptote VerticalAsymptotePointerType m_LeftAsymptote; VerticalAsymptotePointerType m_RightAsymptote; + // Flags bool m_ModifyLeft ; bool m_ModifyRight; - - + //Channel we're dealing handling + unsigned int m_Channel; + }; // end class } // end namespace otb #endif diff --git a/Code/Visualization/otbImageLayer.txx b/Code/Visualization/otbImageLayer.txx index 6e55f08a53..f0c34b6dd3 100644 --- a/Code/Visualization/otbImageLayer.txx +++ b/Code/Visualization/otbImageLayer.txx @@ -103,10 +103,19 @@ ImageLayer<TImage,TOutputImage> // this->UpdateListSample(); // } // Render quicklook + + if(this->GetHasQuicklook()) { itk::TimeProbe probe; probe.Start(); + + // Impacting modified on the the rendering function + if(m_RenderingFunction->GetMTime() > m_QuicklookRenderingFilter->GetOutput()->GetUpdateMTime()) + { + m_QuicklookRenderingFilter->Modified(); + } + m_QuicklookRenderingFilter->Update(); this->SetRenderedQuicklook(m_QuicklookRenderingFilter->GetOutput()); probe.Stop(); @@ -117,7 +126,13 @@ ImageLayer<TImage,TOutputImage> { itk::TimeProbe probe; probe.Start(); -// std::cout<<"Extent: "<<this->GetExtent()<<" Largest: "<<m_Image->GetLargestPossibleRegion()<<" ExtractRegion: "<<this->GetExtractRegion()<<std::endl; + + // Impacting modified on the the rendering function + if(m_RenderingFunction->GetMTime() > m_ExtractRenderingFilter->GetOutput()->GetUpdateMTime()) + { + m_ExtractRenderingFilter->Modified(); + } + m_ExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetExtractRegion()); m_ExtractRenderingFilter->Update(); this->SetRenderedExtract(m_ExtractRenderingFilter->GetOutput()); @@ -135,6 +150,12 @@ ImageLayer<TImage,TOutputImage> { itk::TimeProbe probe; probe.Start(); + // Impacting modified on the the rendering function + if(m_RenderingFunction->GetMTime() > m_ScaledExtractRenderingFilter->GetOutput()->GetUpdateMTime()) + { + m_ScaledExtractRenderingFilter->Modified(); + } + m_ScaledExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetScaledExtractRegion()); m_ScaledExtractRenderingFilter->Update(); this->SetRenderedScaledExtract(m_ScaledExtractRenderingFilter->GetOutput()); diff --git a/Code/Visualization/otbStandardRenderingFunction.h b/Code/Visualization/otbStandardRenderingFunction.h index fa3a6273b0..c196109b38 100644 --- a/Code/Visualization/otbStandardRenderingFunction.h +++ b/Code/Visualization/otbStandardRenderingFunction.h @@ -202,8 +202,8 @@ public: if (this->GetHistogramList().IsNull()) { this->RenderHistogram(); - // itkExceptionMacro( << "To Compute min/max automatically, Histogram should be " - // <<"provided to the rendering function with SetHistogramList()" ); + // itkExceptionMacro( << "To Compute min/max automatically, Histogram should be " + // <<"provided to the rendering function with SetHistogramList()" ); } for(unsigned int comp = 0; comp < nbComps;++comp) { @@ -314,7 +314,7 @@ public: */ virtual ParametersType GetParameters() { - unsigned int nbBands = m_TransferedMaximum.size(); + unsigned int nbBands = m_Minimum.size();/*TransferedMaximum*/ ParametersType param; param.SetSize(2*nbBands); @@ -322,9 +322,9 @@ public: for(unsigned int i = 0; i< nbBands ; i++) { // Min Band - param.SetElement(2*i,m_TransferedMinimum[i]); + param.SetElement(2*i,/*TransferedMinimum*/m_Minimum[i]); // Max Band - param.SetElement(2*i+1,m_TransferedMaximum[i]); + param.SetElement(2*i+1,/*TransferedMaximum*/m_Maximum[i]); } return param; } -- GitLab