]> Creatis software - creaMaracasVisu.git/commitdiff
no message
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Wed, 22 Jul 2009 14:46:11 +0000 (14:46 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Wed, 22 Jul 2009 14:46:11 +0000 (14:46 +0000)
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h

index 7989c0d7422d0fe69f2a45334b6788d662c9ce71..4e32b1e7990c9b767e5038a829c55c2148441699 100644 (file)
@@ -315,7 +315,11 @@ void ContourExtractData::ResetImageResult(int z)
                int ext[6];
                imagedataValueResult->GetExtent(ext);
 
-               int i,size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); 
+               int size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); 
+               memset(pValue,0,size*2);
+               memset(pMask,0,size*2);
+       /*      
+               int i; 
                for(i=0; i<size; i++)
                {
                        *pMask  = 0;
@@ -323,6 +327,8 @@ void ContourExtractData::ResetImageResult(int z)
                        pMask++;
                        pValue++;
                }// for
+       */ 
+               
        } // if
 }
 
@@ -360,7 +366,9 @@ void ContourExtractData::CalculateImageResult()
 
                imagedataValueResult->Modified();
                imagedataMaskResult->Modified();
-       }
+               imagedataValueResult->Update();
+               imagedataMaskResult->Update();
+       } // if
 
 }
 
@@ -439,6 +447,7 @@ vtkImageData *ContourExtractData::GetVtkImageMaskResult()
 // ------------------------------------------------------------------------
 void ContourExtractData::InitVtkImagesResult()
 {
+       printf("EED ContourExtractData::InitVtkImagesResult\n");
          int ext[6];
          int newDim[3];
          double spc[3];
@@ -472,6 +481,7 @@ void ContourExtractData::InitVtkImagesResult()
          imagedataMaskResult->SetSpacing(spc);
          imagedataMaskResult->SetDimensions( newDim );
          imagedataMaskResult->AllocateScalars();
+       printf("EED ContourExtractData::InitVtkImagesResult %p %p\n", imagedataValueResult, imagedataMaskResult);
 }
 
 
index d857d50730b31fa70fd0da572a048350f142a3db..658f5d4319b521f4fe3205e71a1726642d81d3c8 100644 (file)
@@ -44,6 +44,7 @@
                                                                double *vol_minValue, double *vol_maxValue,
                                                                double *vol_average, double *vol_standardeviation);
          
+         void ResetImageResult(int z);
          
          
   private:
@@ -67,7 +68,6 @@
                                                                int y, 
                                                                manualContourModel *manualcontourmodel );
        double GetDataValue(int x, int y, int z);
-       void ResetImageResult(int z);
        void PutVtkImageDataResultValue( int x, int y,int z, double value );
        void InitVtkImagesResult();
 
index 426bf801a48364a716277e59605357682718de16..693b7d8510c8f1d2bc5f6c251e70a951ce550e39 100644 (file)
   //=========================================================================
        ThresholdImageView::ThresholdImageView( )
   {
-         _actorPresent                         = false;
+         _actorPresent                         =       false;
+         _Z                                            =       0;
+         _minValue                                     =       0;
+         _maxValue                                     =       1000;
+         _image                                        =       NULL;
+         _imageReslicer                        =       NULL;
+         _thresholdTable                       =       NULL;
+         _thresholdMapper                      =       NULL;
+         _thresholdActor                       =       NULL;
+         _baseColorR                           =       1;
+         _baseColorG                           =       0;
+         _baseColorB                           =       0;
   }
 
   //=========================================================================
@@ -25,6 +36,7 @@
 //----------------------------------------------------------------------------
 void ThresholdImageView::SetImage(vtkImageData* image)
 {
+       printf("ThresholdImageView::SetImage %p\n", image);
        _image = image;
 }
 
@@ -34,6 +46,12 @@ void ThresholdImageView::SetwxVtkBaseView(wxVtkBaseView *baseview)
        _baseView = baseview;
 }
 
+//----------------------------------------------------------------------------
+wxVtkBaseView *ThresholdImageView::GetwxVtkBaseView()
+{
+       return _baseView;
+}
+
 //----------------------------------------------------------------------------
 void ThresholdImageView::SetZ(int z)
 {
@@ -41,10 +59,10 @@ void ThresholdImageView::SetZ(int z)
 }
 
 //----------------------------------------------------------------------------
-void ThresholdImageView::SetminMax(int min, int max)
+void ThresholdImageView::SetminMaxValue(int min, int max)
 {
-       _min = min;
-       _max = max;
+       _minValue = min;
+       _maxValue = max;
 }
 
 //----------------------------------------------------------------------------
@@ -55,14 +73,19 @@ void ThresholdImageView::onThreshold()
        
        vtkImageData *img = _image;
        img->GetScalarRange(range);
+       if (range[1]==0)
+       {
+               range[1]=255;
+       }
+       
        
        int minTot = floor (range[0]);
        int maxTot = ceil (range[1]);
        
-//EED  _pannew->onThresholdInstantChange(minMax);
        
-       int minVal = floor (_min);
-       int maxVal = floor (_max);
+       int minVal = floor (_minValue);
+       int maxVal = floor (_maxValue);
+       
        
        if (!_actorPresent)
        {
@@ -70,7 +93,7 @@ void ThresholdImageView::onThreshold()
                {
                        _imageReslicer = vtkImageReslice::New();
                        _imageReslicer->SetInput( img );
-                       _imageReslicer->SetInformationInput(img);
+                       _imageReslicer->SetInformationInput(img);                       
                        _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
                        _imageReslicer->SetOutputDimensionality(2);
                        _imageReslicer->SetInterpolationModeToLinear();
@@ -102,7 +125,7 @@ void ThresholdImageView::onThreshold()
                {
                        if( i >= minVal && i <= maxVal )
                        {
-                               _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+                               _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
                        }
                        else if( i >= minTot && i < minVal )
                        {
@@ -154,7 +177,7 @@ void ThresholdImageView::onThreshold()
                {
                        if( i >= minVal && i <= maxVal )
                        {
-                               _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+                               _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
                        }
                        else if( i >= minTot && i < minVal )
                        {
@@ -175,15 +198,6 @@ void ThresholdImageView::onThreshold()
                _thresholdMapper->SetInput( img );
                _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
        }
-       /*
-        vtkImageViewer2* viewer = vtkImageViewer2::New();       
-        viewer->SetInput( upperImageActor->GetInput() ); 
-        viewer->SetColorLevel((range[1]-range[0])/2);
-        viewer->SetColorWindow(range[1]);
-        viewer->GetRenderer()->AddActor( upperImageActor );
-        viewer->Render();
-        */
-//EED  _theViewPanel->RefreshInterface();
 }
 
 
@@ -240,6 +254,13 @@ void ThresholdImageView::onThresholdRemove()
 }
 
 
+//----------------------------------------------------------------------------
+void ThresholdImageView::SetBaseColor(double r, double g, double b)
+{
+       _baseColorR = r;
+       _baseColorG = g;
+       _baseColorB = b;
+}
 
 
 // EOF
index 56dd8a6e7e0c94800ffe7812ca5c9781fda6a4db..5ca77b56deb4ed2b1950dbf10786fd431b46e625 100644 (file)
@@ -36,14 +36,19 @@ class  ThresholdImageView
          
          void SetImage(vtkImageData* image);
          void SetwxVtkBaseView(wxVtkBaseView *baseview);
+         wxVtkBaseView *GetwxVtkBaseView();
+         void SetBaseColor(double r, double g, double b);
          
          void SetZ(int z);
-         void SetminMax(int min, int max);
+         void SetminMaxValue(int min, int max);
          
   private:
          int                                   _Z;
-         double                                _min;
-         double                                _max;
+         double                                _baseColorR;
+         double                                _baseColorG;
+         double                                _baseColorB;
+         double                                _minValue;
+         double                                _maxValue;
          bool                                  _actorPresent;
          vtkImageData                  *_image;
          vtkImageReslice               *_imageReslicer;
index 4ad0d443b5905cf79e675603ef5782e573186fec..7d2dd8cab8a9c96db9dc1490c8c257d45087689f 100644 (file)
 /**
  ** Begin of the threshold panel
  **/
-ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent)
+ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int type)
 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
 {
        _thresholdImageView = new ThresholdImageView();
 
-       wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
+//     wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
+       
+       _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);
-       _thresholdGo = false;
        
-       double range[2];
+//     double range[2];
 //     interfMainPanel::getInstance()->getImageRange(range);
        
-       int min = (int)floor (range[0]);
-       int max = (int)ceil (range[1]);
+//     int min = (int)floor (range[0]);
+//     int max = (int)ceil (range[1]);
+
+       if (type==0)
+       {
+       }
+       
+       if (type==1)
+       {
+               _mBarThreshold  =  new mBarRange(this,70,65);
+               _mBarThreshold->SetMin(0);
+               _mBarThreshold->SetStart(0);
+               _mBarThreshold-> SetOrientation( true );
+               _mBarThreshold-> setActiveStateTo(true);
+               _mBarThreshold-> setVisibleLabels( true );
+               _mBarThreshold-> setDeviceEndMargin(10);
+               _mBarThreshold-> setRepresentedValues( min , max );
+               _mBarThreshold-> setDeviceBlitStart(10,10); 
+               _mBarThreshold-> setIfWithActualDrawed( false );
+               _mBarThreshold-> SetStart( min );
+               _mBarThreshold-> SetEnd( max );  
+       }
        
-       _mBarThreshold  =  new mBarRange(this,70,65);
-       _mBarThreshold->SetMin(0);
-       _mBarThreshold->SetStart(0);
-       _mBarThreshold-> SetOrientation( true );
-       _mBarThreshold-> setActiveStateTo(true);
-       _mBarThreshold-> setVisibleLabels( true );
-       _mBarThreshold-> setDeviceEndMargin(10);
-       _mBarThreshold-> setRepresentedValues( min , max );
-       _mBarThreshold-> setDeviceBlitStart(10,10); 
-       _mBarThreshold-> setIfWithActualDrawed( false );
-       _mBarThreshold-> SetStart( min );
-       _mBarThreshold-> SetEnd( max );  
        
-       Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdGo ); 
+       Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdShow ); 
        Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation );
        
        wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
-       sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold"))  , 1, wxGROW );
-       sizer -> Add( _mBarThreshold, 1, wxGROW );
-       sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
+       if (type==1)
+       {
+               sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold"))  , 1, wxGROW );
+               sizer -> Add( _mBarThreshold, 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( thresholdGoBtn, 1, wxGROW );
+       sizer -> Add( _cb_ShowHide, 1, wxGROW );
        sizer -> Add( new wxStaticText(this,-1,_T(" "))  , 1, wxGROW );
        sizer -> Add( _interpolationCheckBox, 1, wxGROW );
        
@@ -63,7 +78,8 @@ ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent)
 }
 
 //----------------------------------------------------------------------------
-ThresholdImageViewPanel::~ThresholdImageViewPanel(){
+ThresholdImageViewPanel::~ThresholdImageViewPanel()
+{
 }
 
 
@@ -79,25 +95,26 @@ void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event)
 {
        if (_thresholdGo)
        {
+               _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() );
                _thresholdImageView->onThresholdChange();
-               
+               _thresholdImageView->GetwxVtkBaseView()->Refresh();
                //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
        }
 }
 
 //----------------------------------------------------------------------------
-void ThresholdImageViewPanel::onThresholdGo(wxCommandEvent& event)
+void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event)
 {
-       if (!_thresholdGo)
+       _thresholdGo = _cb_ShowHide->GetValue();
+       if (_thresholdGo)
        {
                _thresholdImageView->onThreshold();
-               _thresholdGo=true;
        }
        else
        {       
                _thresholdImageView->onThresholdRemove( );
-               _thresholdGo=false;             
        }
+       _thresholdImageView->GetwxVtkBaseView()->Refresh();
 }
 
 //----------------------------------------------------------------------------
@@ -110,17 +127,12 @@ void ThresholdImageViewPanel::onThresholdStop()
        }
 }
 
-//----------------------------------------------------------------------------
-void ThresholdImageViewPanel::onThresholdInstantChange(double range[])
-{
-       range[0] = _mBarThreshold->GetStart();
-       range[1] = _mBarThreshold->GetEnd();
-}
-
 //----------------------------------------------------------------------------
 void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
 {
        _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
+       _thresholdImageView->GetwxVtkBaseView()->Refresh();
+
 }
 
 //----------------------------------------------------------------------------
@@ -128,9 +140,16 @@ void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event)
 {
        int opacity = _opacity->GetValue();
        _thresholdImageView->onThresholdChangeOpacity(opacity);
+       _thresholdImageView->GetwxVtkBaseView()->Refresh();
 }
 
 
+//----------------------------------------------------------------------------
+bool ThresholdImageViewPanel::IsVisible()
+{
+       return _thresholdGo;
+}
+
 
 BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
   EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)
index 54d9985a84da32e579496b40e847a88f2eb85f64..a5380c2c068c1d2ad7712d2da2a93416aeb2cdaf 100644 (file)
                : public wxPanel
                {
                public:
-                       ThresholdImageViewPanel(wxWindow * parent);             
+                       ThresholdImageViewPanel(wxWindow * parent, int min, int max, int type);         
                        ~ThresholdImageViewPanel();
                        void onThresholdStop();
-                       void onThresholdInstantChange(double range[]);
                        void SetThresholdImageView(ThresholdImageView* thresholdImageView);
+                       bool IsVisible();
                        
                private:
                        
                        mBarRange                       *_mBarThreshold;
                        wxSlider                        *_opacity;
                        wxCheckBox                      *_interpolationCheckBox;        
+                       wxCheckBox                      *_cb_ShowHide;
                        
                        void onThresholdChange(wxCommandEvent& event);                  
-                       void onThresholdGo(wxCommandEvent& event);
+                       void onThresholdShow(wxCommandEvent& event);
                        void onThresholdInterpolation(wxCommandEvent& event);
                        void onChangeOpacity(wxScrollEvent& event);
-                       
                        DECLARE_EVENT_TABLE()
                };