]> Creatis software - creaMaracasVisu.git/commitdiff
*** empty log message ***
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Fri, 16 Jul 2010 17:31:18 +0000 (17:31 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Fri, 16 Jul 2010 17:31:18 +0000 (17:31 +0000)
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx

diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
new file mode 100644 (file)
index 0000000..93d63ad
--- /dev/null
@@ -0,0 +1,91 @@
+
+/**
+ *  \file 
+ *  \brief Class bbtk::ThresholdImageView . 
+ */
+
+#include "ColorLayerImageView.h"
+
+#include <vtkImageReslice.h>
+#include <vtkLookupTable.h>
+#include <vtkImageData.h>
+
+
+  //=========================================================================
+  //=========================================================================
+  //=========================================================================
+  //=========================================================================
+       ColorLayerImageView::ColorLayerImageView( )
+  {
+  }
+
+  //=========================================================================
+  ColorLayerImageView::~ColorLayerImageView()
+  {
+  }
+  //=========================================================================
+
+
+//----------------------------------------------------------------------------
+void ColorLayerImageView::ConfigLookupTable()  // virtual
+{
+       double range[2];
+       
+       GetImage()->GetScalarRange(range);
+       if (range[1]==0)
+       {
+               range[1]=255;
+       }
+       
+       int minTot = floor (range[0]);
+       int maxTot = ceil (range[1]);
+       
+
+       vtkLookupTable* thresholdTable = GetThresholdTable();
+       thresholdTable->SetNumberOfTableValues(maxTot+1);
+       thresholdTable->SetTableRange(range); 
+       thresholdTable->SetAlphaRange(0, 1);
+       thresholdTable->SetValueRange(0, 1);
+       thresholdTable->SetSaturationRange(0, 0); 
+       thresholdTable->SetRampToLinear( );
+
+       //Assign a fake color for the upper image, and set the white as transparent
+       int i,ii;
+       double iBlue=0 , iYellow=0 , iRed=0;
+       double delta=(maxTot-minTot)/3.0;
+
+       double delta0=delta*0;
+       double delta1=delta*1;
+       double delta2=delta*2;
+       double delta3=delta*3;
+
+
+       for(i = minTot; i <= maxTot; i++)
+       {
+               ii=i-minTot;
+               if ((ii>=delta0) && (ii<=delta1)) // iBlue
+               {
+                       thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);    
+                       iBlue++;
+               }
+               if ((ii>=delta1) && (ii<=delta2)) // iYellow
+               {
+                       thresholdTable->SetTableValue( i , iYellow/delta , iYellow/delta , (delta-iYellow)/delta , 1);  
+                       iYellow++;
+               }
+               if ((ii>=delta2) && (ii<=delta3)) // iRed
+               {
+                       thresholdTable->SetTableValue( i , 1 , (delta-iRed)/delta , 0 , 1);     
+                       iRed++;
+               }
+       } // for
+
+       thresholdTable->Build( );
+
+}
+
+
+
+
+// EOF
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h
new file mode 100644 (file)
index 0000000..6229bf1
--- /dev/null
@@ -0,0 +1,34 @@
+
+
+
+/**
+ *  \file 
+ *  \brief Class ThresholdImageView . 
+ */
+
+/**
+ * \class ThresholdImageView
+ * \brief 
+ */
+#ifndef __ColorLayerImageView_h__
+#define __ColorLayerImageView_h__
+
+#include "LayerImageBase.h"
+
+
+class  ColorLayerImageView : public LayerImageBase
+  {
+  public: 
+         ColorLayerImageView( );
+         ~ColorLayerImageView();
+         
+  private:
+
+         virtual void ConfigLookupTable();
+
+  protected:
+ };
+
+#endif
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
new file mode 100644 (file)
index 0000000..01244c3
--- /dev/null
@@ -0,0 +1,146 @@
+                                                                    
+
+/**
+ *  \file 
+ *  \brief ClassThresholdImageViewPanel . 
+ */
+
+
+#include "ColorLayerImageViewPanel.h"
+
+
+
+/**
+ ** Begin of the threshold panel
+ **/
+ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+{
+       _colorLayerImageView = new ColorLayerImageView();
+
+       _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") );
+       
+
+       _thresholdGo = true;
+       _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
+       _cb_ShowHide->SetValue(_thresholdGo);
+       
+       _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
+       _interpolationCheckBox->SetValue(true); 
+       _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+       
+       if (type==0)
+       {
+       }
+       
+       if (type==1)
+       {
+       }
+       
+       
+       Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage ); 
+       Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow ); 
+       Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
+       Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
+       
+       wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
+       if (type==1)
+       {
+               sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer"))  , 1, wxGROW );
+               sizer -> Add( _btn_ReadImage, 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
+       }
+       sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))  , 1, wxGROW );
+       sizer -> Add( _opacity, 1, wxGROW );
+       sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
+       sizer -> Add( _cb_ShowHide, 1, wxGROW );
+       sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
+       sizer -> Add( _interpolationCheckBox, 1, wxGROW );
+       
+       this->SetSizer( sizer );
+       this->SetAutoLayout( true );
+       this->Layout();
+}
+
+//----------------------------------------------------------------------------
+ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
+{
+}
+
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView)
+{
+       _colorLayerImageView = colorLayerImageView;
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
+{
+       printf("EED UPS.... ");
+}
+
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
+{
+       if (_thresholdGo)
+       {
+               _colorLayerImageView->onThresholdChange();
+               _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+               //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
+       }
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
+{
+       _thresholdGo = _cb_ShowHide->GetValue();
+       if (_thresholdGo)
+       {
+               _colorLayerImageView->onThreshold();
+       }
+       else
+       {       
+               _colorLayerImageView->onThresholdRemove( );
+       }
+       _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onThresholdStop()
+{
+       if (_thresholdGo)
+       {       
+               _colorLayerImageView->onThresholdRemove( );
+               _thresholdGo=false;             
+       }
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
+{
+       _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
+       _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
+{
+       int opacity = _opacity->GetValue();
+       _colorLayerImageView->onThresholdChangeOpacity(opacity);
+       _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+}
+
+
+//----------------------------------------------------------------------------
+bool ColorLayerImageViewPanel::IsVisible()
+{
+       return _thresholdGo;
+}
+
+
+
+// EOF
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h
new file mode 100644 (file)
index 0000000..bbb52c4
--- /dev/null
@@ -0,0 +1,49 @@
+
+
+/**
+ *  \file 
+ *  \brief Class ThresholdImageViewPanel . 
+ */
+
+/**
+ * \class ThresholdImageViewPanel
+ * \brief 
+ */
+#ifndef __ColorLayerImageViewPanel_h__
+#define __ColorLayerImageViewPanel_h__
+
+
+#include <wx/wx.h>
+#include <wx/button.h>
+#include "ColorLayerImageView.h"
+
+       
+       class ColorLayerImageViewPanel
+               : public wxPanel
+               {
+               public:
+                       ColorLayerImageViewPanel(wxWindow * parent, int min, int max, int type);                
+                       ~ColorLayerImageViewPanel();
+                       void onThresholdStop();
+                       void SetColorLayerImageView(ColorLayerImageView* colorLayerImageView);
+                       bool IsVisible();
+                       
+               private:
+                       
+                       bool                            _thresholdGo;
+                       ColorLayerImageView     *_colorLayerImageView;
+                       wxButton                        *_btn_ReadImage;
+                       wxSlider                        *_opacity;
+                       wxCheckBox                      *_interpolationCheckBox;        
+                       wxCheckBox                      *_cb_ShowHide;
+                       
+                       void onReadImage(wxCommandEvent& event);
+                       void onThresholdChange(wxCommandEvent& event);                  
+                       void onThresholdShow(wxCommandEvent& event);
+                       void onThresholdInterpolation(wxCommandEvent& event);
+                       void onChangeOpacity(wxScrollEvent& event);
+               };
+
+#endif
+
index 7d2dd8cab8a9c96db9dc1490c8c257d45087689f..9ed31ca73c6da2a09e1816f969a0282872aca4ae 100644 (file)
@@ -41,8 +41,8 @@ ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int
        if (type==1)
        {
                _mBarThreshold  =  new mBarRange(this,70,65);
-               _mBarThreshold->SetMin(0);
-               _mBarThreshold->SetStart(0);
+               _mBarThreshold-> SetMin(0);
+               _mBarThreshold-> SetStart(0);
                _mBarThreshold-> SetOrientation( true );
                _mBarThreshold-> setActiveStateTo(true);
                _mBarThreshold-> setVisibleLabels( true );
@@ -57,6 +57,7 @@ ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int
        
        Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdShow ); 
        Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation );
+       Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ThresholdImageViewPanel::onChangeOpacity );
        
        wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
        if (type==1)
@@ -155,7 +156,10 @@ BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
   EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
   EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_END, ThresholdImageViewPanel::onThresholdChange)
   EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_MOVED, ThresholdImageViewPanel::onThresholdChange) 
-  EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity)
+
+//EED Borrame
+//  EVT_SCROLL(ThresholdImageViewPanel::onChangeOpacity)
+
 END_EVENT_TABLE()