]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
2339 creaMaracasVisu Feature New Normal ColorLayer in perpendicular planes
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageViewPanel.cxx
index a70c96d31228c8594944029ac66a51714d7088bc..963a51c222ec7ab2c888be502b3a19bc616cfc33 100644 (file)
@@ -95,7 +95,9 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
        _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
 
-       _colorLayerImageView            = new ColorLayerImageView();
+//EED01        _colorLayerImageView            = new ColorLayerImageView();
+       _colorLayerImageViewManager     = new ColorLayerImageViewManager();
+
        _btn_ReadImage                  = new wxButton(this, wxID_ANY, _T("Read Image") );
        _thresholdGo                    = true;
        _cb_ShowHide                    = new wxCheckBox(this, wxID_ANY, _T("Show/Hide Layer") );
@@ -104,8 +106,12 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        _cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Fixed/Dynamic Slice") );
        _cb_SliceFixDinamic->SetValue(true);
 
-       _sl_SliceImage = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-       _sl_SliceImage->Enable(false);
+       _sl_SliceImageX = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+       _sl_SliceImageY = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+       _sl_SliceImageZ = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+       _sl_SliceImageX->Enable(false);
+       _sl_SliceImageY->Enable(false);
+       _sl_SliceImageZ->Enable(false);
 
        _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image Interpolation") );
        _interpolationCheckBox->SetValue(true);
@@ -125,11 +131,25 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
        Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
        Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic );
-       Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_THUMBTRACK       , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEUP           , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEDOWN         , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEUP           , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEDOWN         , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
+       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
+       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
+       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
 
 
        wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
@@ -148,7 +168,9 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
 
        sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
        sizer -> Add( new wxStaticText(this,-1,_T("Slice "))  , 1, wxGROW );
-       sizer -> Add( _sl_SliceImage, 1, wxGROW );
+       sizer -> Add( _sl_SliceImageX, 1, wxGROW );
+       sizer -> Add( _sl_SliceImageY, 1, wxGROW );
+       sizer -> Add( _sl_SliceImageZ, 1, wxGROW );
        sizer -> Add( _cb_SliceFixDinamic, 1, wxGROW );
 
        this->SetSizer( sizer );
@@ -166,16 +188,23 @@ ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
 }
 
 
-//----------------------------------------------------------------------------
-void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView)
-{
-       _colorLayerImageView = colorLayerImageView;
-}
+//EED01  
+//EED01  //----------------------------------------------------------------------------
+//EED01  void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView)
+//EED01  {
+//EED01        _colorLayerImageView = colorLayerImageView;
+//EED01  }
+//EED01  
+//EED01  //----------------------------------------------------------------------------
+//EED01  ColorLayerImageView* ColorLayerImageViewPanel::GetColorLayerImageView()
+//EED01  {
+//EED01        return _colorLayerImageView;
+//EED01  }
 
-//----------------------------------------------------------------------------
-ColorLayerImageView* ColorLayerImageViewPanel::GetColorLayerImageView()
+
+ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager()
 {
-       return _colorLayerImageView;
+   return _colorLayerImageViewManager;
 }
 
 
@@ -212,7 +241,7 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 {
     if (img!=NULL)
     {
-        _colorLayerImageView->SetImage( img );
+        _colorLayerImageViewManager->SetImage( img );
 
         double spc[3];
         img->GetSpacing(spc);
@@ -223,7 +252,9 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
         dim[0] = ext[1]-ext[0];
         dim[1] = ext[3]-ext[2];
         dim[2] = ext[5]-ext[4];
-        _sl_SliceImage->SetRange( 0 , dim[2] );
+        _sl_SliceImageX->SetRange( 0 , dim[0] );
+        _sl_SliceImageY->SetRange( 0 , dim[1] );
+        _sl_SliceImageZ->SetRange( 0 , dim[2] );
 
         if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) ||
              (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2])
@@ -273,16 +304,24 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
             img->SetSpacing(spc);
         } // spc !_spcBase   dim!__dimBase
 
-        if (_colorLayerImageView!=NULL)
-        {
-            _colorLayerImageView->onThreshold();
-            _colorLayerImageView->Refresh();
-        }
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
+//EED01            _colorLayerImageView->onThreshold();
+               _colorLayerImageViewManager->onThreshold();
+               RefreshView();
+//EED01        }
 
 
     }
 }
 
+
+void ColorLayerImageViewPanel::RefreshView()
+{
+//EED01        _colorLayerImageView->Refresh();
+       _colorLayerImageViewManager->Refresh();
+}
+
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::SetFittingMode(int fitting_mode)
 {
@@ -318,93 +357,111 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
 {
-       if (_colorLayerImageView!=NULL)
-       {
-        if (_thresholdGo)
-        {
-            _colorLayerImageView->onThresholdChange();
-            _colorLayerImageView->Refresh();
-            //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
-        } // _threshold
-       }//_colorLayerImageView
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
+               if (_thresholdGo)
+               {
+//EED01                 _colorLayerImageView->onThresholdChange();
+                _colorLayerImageViewManager->onThresholdChange();
+                RefreshView();
+               //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
+          } // _thresholdGo
+//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
 {
-       if (_colorLayerImageView!=NULL)
-       {
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
         _thresholdGo = _cb_ShowHide->GetValue();
         if (_thresholdGo)
         {
-            _colorLayerImageView->onThreshold();
+//EED01            _colorLayerImageView->onThreshold();
+                   _colorLayerImageViewManager->onThreshold();
         }else{
-            _colorLayerImageView->onThresholdRemove( );
+//EED01            _colorLayerImageView->onThresholdRemove( );
+                   _colorLayerImageViewManager->onThresholdRemove( );
         }
-        _colorLayerImageView->Refresh();
-       }//_colorLayerImageView
+            RefreshView();
+//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdStop()
 {
-       if (_colorLayerImageView!=NULL)
-       {
-        if (_thresholdGo)
-        {
-            _colorLayerImageView->onThresholdRemove( );
-            _thresholdGo=false;
-        }
-       }//_colorLayerImageView
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
+               if (_thresholdGo)
+               {
+//EED01                    _colorLayerImageView->onThresholdRemove( );
+                   _colorLayerImageViewManager->onThresholdRemove( );
+                   _thresholdGo=false;
+               }
+//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
 {
-       if (_colorLayerImageView!=NULL)
-       {
-        _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
-        _colorLayerImageView->Refresh();
-       }//_colorLayerImageView
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
+//EED01                _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
+               _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue());
+               RefreshView();
+//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
 {
-       if (_colorLayerImageView!=NULL)
-       {
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
         bool fixdin = _cb_SliceFixDinamic->GetValue();
-        _colorLayerImageView->SetSliceFixDynamic( fixdin );
+//EED01        _colorLayerImageView->SetSliceFixDynamic( fixdin );
+        _colorLayerImageViewManager->SetSliceFixDynamic( fixdin );
         if (fixdin==false)
         {
-            _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
+//EED01            _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
+            _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() );
+            _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() );
+            _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() );
         }
-        _sl_SliceImage->Enable(!fixdin);
-        _colorLayerImageView->onThreshold();
-        _colorLayerImageView->Refresh();
-       }//_colorLayerImageView
+        _sl_SliceImageX->Enable(!fixdin);
+        _sl_SliceImageY->Enable(!fixdin);
+        _sl_SliceImageZ->Enable(!fixdin);
+//EED01        _colorLayerImageView->onThreshold();
+        _colorLayerImageViewManager->onThreshold();
+       RefreshView();
+//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
 {
-       if (_colorLayerImageView!=NULL)
-       {
-        _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
-        _colorLayerImageView->onThreshold();
-        _colorLayerImageView->Refresh();
-       }//_colorLayerImageView
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
+//EED01        _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
+//EED01        _colorLayerImageView->onThreshold();
+//EED01        RefreshView();
+         _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() );
+         _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() );
+         _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() );
+         _colorLayerImageViewManager->onThreshold();
+       RefreshView();
+//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
 {
-       if (_colorLayerImageView!=NULL)
-       {
+//EED01        if (_colorLayerImageView!=NULL)
+//EED01        {
         int opacity = _opacity->GetValue();
-        _colorLayerImageView->onThresholdChangeOpacity(opacity);
-        _colorLayerImageView->Refresh();
-       }//_colorLayerImageView
+//EED01        _colorLayerImageView->onThresholdChangeOpacity(opacity);
+        _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
+       RefreshView();
+//EED01        }//_colorLayerImageView
 }