]> Creatis software - creaMaracasVisu.git/commitdiff
*** empty log message ***
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Wed, 21 Jul 2010 15:56:46 +0000 (15:56 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Wed, 21 Jul 2010 15:56:46 +0000 (15:56 +0000)
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h

index 93d63ada411e9c561981bebf546c152ef172c15e..01c53b7d29a11309c7169099f666f5d598a2d184 100644 (file)
@@ -17,6 +17,8 @@
   //=========================================================================
        ColorLayerImageView::ColorLayerImageView( )
   {
+         _z2                   =       0;
+         _fix_dinamic  =       true;
   }
 
   //=========================================================================
   //=========================================================================
 
 
+//----------------------------------------------------------------------------
+void ColorLayerImageView::SetSliceFixDinamic(bool fix_dinamic)
+{
+       _fix_dinamic = fix_dinamic;
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageView::SetZ2(int z2)  
+{
+       _z2 = z2;
+}
+
+//----------------------------------------------------------------------------
+int ColorLayerImageView::GetZ() // virtual 
+{
+       int result=0;
+       if (_fix_dinamic==false)
+       {
+               result = _z2;
+       } else  {
+               result = LayerImageBase::GetZ();
+       }  
+
+       return result;
+}
+
+
 //----------------------------------------------------------------------------
 void ColorLayerImageView::ConfigLookupTable()  // virtual
 {
@@ -66,6 +95,12 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
                if ((ii>=delta0) && (ii<=delta1)) // iBlue
                {
                        thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);    
+                       if (ii==0)
+                       {
+                               thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 0);    
+                       } else {
+                               thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);    
+                       }
                        iBlue++;
                }
                if ((ii>=delta1) && (ii<=delta2)) // iYellow
index 6229bf17391255d23f9f882737c0540bd542d0f1..e1f4a533bd6fc8c884f19693ee04b1ef46701b71 100644 (file)
@@ -22,11 +22,17 @@ class  ColorLayerImageView : public LayerImageBase
   public: 
          ColorLayerImageView( );
          ~ColorLayerImageView();
-         
+         void SetSliceFixDinamic(bool fix_dinamic);
+         void SetZ2(int z2);
+         virtual int GetZ();
+
   private:
 
+         int _z2;
+         bool _fix_dinamic;
          virtual void ConfigLookupTable();
 
+
   protected:
  };
 
index 01244c3df3a96bcbee9809feb0c9aac5a9c661a7..6ea524f5efa7ea01efeb393227adbb93c8a5c9f8 100644 (file)
@@ -7,7 +7,7 @@
 
 
 #include "ColorLayerImageViewPanel.h"
-
+#include "OpenImageDialog.h"
 
 
 /**
@@ -24,7 +24,13 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        _thresholdGo = true;
        _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
        _cb_ShowHide->SetValue(_thresholdGo);
-       
+
+       _cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Slice Fix/Dinamic") );
+       _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);
+
        _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);
@@ -42,7 +48,14 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        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 );
-       
+       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 );
+
+
        wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
        if (type==1)
        {
@@ -56,7 +69,12 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        sizer -> Add( _cb_ShowHide, 1, wxGROW );
        sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
        sizer -> Add( _interpolationCheckBox, 1, wxGROW );
-       
+
+       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( _cb_SliceFixDinamic, 1, wxGROW );
+
        this->SetSizer( sizer );
        this->SetAutoLayout( true );
        this->Layout();
@@ -77,7 +95,19 @@ void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* color
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
 {
-       printf("EED UPS.... ");
+// EED ???
+//      creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB"); 
+//      w.ShowModal(); 
+
+       creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
+       _colorLayerImageView->SetImage( diag.getImageData() );
+
+       int ext[6];
+       diag.getImageData()->GetWholeExtent(ext);
+       _sl_SliceImage->SetRange( 0 , ext[5]-ext[4] );
+
+       _colorLayerImageView->onThreshold();
+       _colorLayerImageView->GetwxVtkBaseView()->Refresh();
 }
 
 
@@ -125,6 +155,28 @@ void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
 
 }
 
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
+{
+       bool fixdin = _cb_SliceFixDinamic->GetValue();
+       _colorLayerImageView->SetSliceFixDinamic( fixdin );
+       if (fixdin==false)
+       {
+               _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
+       }
+       _sl_SliceImage->Enable(!fixdin);
+       _colorLayerImageView->onThreshold();
+       _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
+{
+       _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
+       _colorLayerImageView->onThreshold();
+       _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+}
+
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
 {
index bbb52c483c226c69c5292936ffd9040d32f3194c..3927cc9fb5fbc782e7b538a73612b753ad0b95ab 100644 (file)
                        wxSlider                        *_opacity;
                        wxCheckBox                      *_interpolationCheckBox;        
                        wxCheckBox                      *_cb_ShowHide;
-                       
+                       wxCheckBox                      *_cb_SliceFixDinamic;
+                       wxSlider                        *_sl_SliceImage;
                        void onReadImage(wxCommandEvent& event);
                        void onThresholdChange(wxCommandEvent& event);                  
                        void onThresholdShow(wxCommandEvent& event);
                        void onThresholdInterpolation(wxCommandEvent& event);
                        void onChangeOpacity(wxScrollEvent& event);
+                       void onSliceFixDinamic(wxCommandEvent& event);
+                       void onSliceImage(wxScrollEvent& event);
                };
 
 #endif
index a4946f0ccbc07659f62e56a62ad2cda49801cb6c..c079604b5debfe8a5eecf4536ee736a64003267f 100644 (file)
@@ -30,7 +30,7 @@ void LayerImageBase::SetZ(int z)
 }
 
 //----------------------------------------------------------------------------
-int LayerImageBase::GetZ()
+int LayerImageBase::GetZ()  // virtual
 {
        return _Z;
 }
@@ -75,54 +75,73 @@ vtkLookupTable* LayerImageBase::GetThresholdTable()
        return _thresholdTable;
 }
 
+//----------------------------------------------------------------------------
+int LayerImageBase::CleanZ(int z)
+{ 
+       int ext[6];
+       _image->GetWholeExtent(ext);
+
+       if (z<0)
+       {
+               z=0;
+       }
+
+       if ( z > (ext[5]-ext[4]) )
+       {
+               z=ext[5]-ext[4];
+       }
 
+       return z;
+}
 
 //----------------------------------------------------------------------------
 void LayerImageBase::onThreshold()
 {
-       int     z = GetZ();
-       
-       if (!GetActorPresent())
-       {                               
-               if (_thresholdTable==NULL)
-               {
-                       //Lookup Table
-                       _thresholdTable = vtkLookupTable::New();
-               } // _thresholdTable
-               
-               if (_thresholdMapper==NULL)
-               {
-                       _thresholdMapper = vtkImageMapToColors::New( );
-               }
-               
-               if (_thresholdActor==NULL)
-               {
-                       _thresholdActor = vtkImageActor::New( );
-                       _thresholdActor->SetOpacity( 0.6 );
-                       _thresholdActor->InterpolateOn(  );
-                       _thresholdActor->SetPosition( 0,0, 900-1 );
-               } // _thresholdActor
-               
-               
-               _baseView->GetRenderer()->AddActor( _thresholdActor );
-               _actorPresent = true;           
-       }  // !GetActorPresent()
-
-       ConfigLookupTable();  // virtual method
-       _imageReslicer->SetInput( GetImage() );
-       _imageReslicer->SetInformationInput( GetImage() );                      
-       _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
-       _imageReslicer->SetOutputDimensionality(2);
-       _imageReslicer->SetInterpolationModeToLinear();
-       _imageReslicer->SetResliceAxesOrigin(0,0,z);
-
-       vtkImageData *img = _imageReslicer->GetOutput();
-       img->Update();
-       img->UpdateInformation();
-
-       _thresholdMapper->SetInput( img );
-       _thresholdMapper->SetLookupTable( _thresholdTable );
-       _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+
+       if (_image!=NULL)
+       {
+               int z=CleanZ( GetZ() );
+
+               if (!GetActorPresent())
+               {                               
+                       if (_thresholdTable==NULL)
+                       {
+                               //Lookup Table
+                               _thresholdTable = vtkLookupTable::New();
+                       } // _thresholdTable
+                       
+                       if (_thresholdMapper==NULL)
+                       {
+                               _thresholdMapper = vtkImageMapToColors::New( );
+                       }
+                       
+                       if (_thresholdActor==NULL)
+                       {
+                               _thresholdActor = vtkImageActor::New( );
+                               _thresholdActor->SetOpacity( 0.6 );
+                               _thresholdActor->InterpolateOn(  );
+                               _thresholdActor->SetPosition( 0,0, 900-1 );
+                       } // _thresholdActor                    
+                       _baseView->GetRenderer()->AddActor( _thresholdActor );
+                       _actorPresent = true;           
+               }  // !GetActorPresent()
+
+               ConfigLookupTable();  // virtual method
+               _imageReslicer->SetInput( GetImage() );
+               _imageReslicer->SetInformationInput( GetImage() );                      
+               _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
+               _imageReslicer->SetOutputDimensionality(2);
+               _imageReslicer->SetInterpolationModeToLinear();
+               _imageReslicer->SetResliceAxesOrigin(0,0,z);
+
+               vtkImageData *img = _imageReslicer->GetOutput();
+               img->Update();
+               img->UpdateInformation();
+
+               _thresholdMapper->SetInput( img );
+               _thresholdMapper->SetLookupTable( _thresholdTable );
+               _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+               } // _image
 }
 
 
index 0af0e62db2a69f471f452bd4dd0c3c82d82c00d2..a96a2b3b19f491a6f499862fbcdca48159a27440 100644 (file)
@@ -48,10 +48,12 @@ class LayerImageBase
                wxVtkBaseView           *_baseView;
 
                virtual void ConfigLookupTable() = 0;
-               int GetZ();
                bool GetActorPresent();
+               int CleanZ(int z);
+
 
   protected:
+               virtual int GetZ();
                vtkLookupTable* GetThresholdTable();
                vtkImageData* GetImage();
  };