]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx
no message
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ThresholdImageView.cxx
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