]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
#3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / LayerImageBase.cxx
index 1e402d3b35785d86341c215e7f797ca9285c2487..c295169ae16fc898a8eb0fab5bb0708ab31cde3e 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "wxMPRBaseData.h"
 #include "wxVtk2DBaseView.h"
-#include "wxVTKRenderWindowInteractor.h"
+#include "creawxVTKRenderWindowInteractor.h"
 #include "vtkTextProperty.h"
 
 
@@ -97,6 +97,7 @@ LayerImageBase::LayerImageBase()
        _X                                              =       -1;
        _Y                                              =       -1;
        _Z                                              =       -1;
+       _opacity                                =       1;
        _thresholdTable                 =       NULL;
        _thresholdMapper                =       NULL;
        _scalarbarActor                 =       NULL;
@@ -235,7 +236,7 @@ void LayerImageBase::SetImage(vtkImageData* image)
                } // if imagebase
        } // if wxvtkbaseview
        _image->GetScalarRange( _range );
-       _thresholdTable = vtkLookupTable::New();
+//     _thresholdTable = vtkLookupTable::New();
 
 
 //EED 2017-01-01 Migration VTK7
@@ -243,6 +244,7 @@ void LayerImageBase::SetImage(vtkImageData* image)
        _imageChangeInformation->SetInput(_image);
 #else
        _imageChangeInformation->SetInputData(_image);
+       _imageChangeInformation->Update();
 #endif
 
 }
@@ -258,9 +260,9 @@ void LayerImageBase::SetSpcOriginalLayer(double spc[3])
 //------------------------------------------------------------------------------
 void LayerImageBase::SetNewSpacingLayer(double spc[3])
 {
-       _newSpcLayer[0]=spc[0];
-       _newSpcLayer[1]=spc[1];
-       _newSpcLayer[2]=spc[2];
+       _newSpcLayer[0] = spc[0];
+       _newSpcLayer[1] = spc[1];
+       _newSpcLayer[2] = spc[2];
        _imageChangeInformation->SetOutputSpacing( _newSpcLayer );  
 
 }
@@ -430,12 +432,10 @@ void LayerImageBase::onThreshold()
                double y=GetY();
                double z=GetZ();
 
-
                x = x*_spcBase[0];
                y = y*_spcBase[1];
                z = z*_spcBase[2];
 
-
                CleanXYZ(x,y,z);
 
                vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera();
@@ -470,6 +470,8 @@ void LayerImageBase::onThreshold()
                                } else {
                                        _scalarbarActor->SetDisplayPosition(0,0);
                                }
+                               _scalarbarActor->SetHeight(0.4);        //default  0.8
+                               _scalarbarActor->SetWidth(0.08);    //default  0.17
 
                                _thresholdActor->SetOpacity( 1 );
                                _thresholdActor->InterpolateOn(  );
@@ -528,11 +530,15 @@ void LayerImageBase::onThreshold()
                _imageReslicer->SetInterpolationModeToNearestNeighbor();
                _imageReslicer->Modified();
 
-
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               // ..
+#else
+               _imageReslicer->Update();
+#endif
                vtkImageData *img = _imageReslicer->GetOutput();
 //             img->Update();
 //             img->UpdateInformation();
-
 //             _thresholdTable->Update();
 
 //EED 2017-01-01 Migration VTK7
@@ -549,20 +555,18 @@ void LayerImageBase::onThreshold()
 #if VTK_MAJOR_VERSION <= 5
                _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
 #else
+               _thresholdMapper->Update();
                _thresholdActor->SetInputData( _thresholdMapper->GetOutput() );
 #endif
-
                
+               _thresholdActor->SetOpacity(_opacity);
                _scalarbarActor->SetLookupTable( _thresholdTable );
 //             _scalarbarActor->SetLookupTable( _thresholdMapper->GetLookupTable() );
                _scalarbarActor->SetTitle("Value");
                _scalarbarActor->SetNumberOfLabels(4);
                int fontsize = _scalarbarActor->GetLabelTextProperty()->GetFontSize();
                _scalarbarActor->GetLabelTextProperty()->SetFontSize(fontsize/2);
-
 //             _scalarbarActor->SetTextPad(4);  ??
-
-
                } // _image
 }
 
@@ -600,6 +604,8 @@ void LayerImageBase::onThresholdChangeOpacity (int opacity)
        {
                _thresholdActor->SetOpacity(opacity/100.0);
        }
+// EED 2017-12-17
+       _opacity = (double)opacity/100.0;
 }
 
 //----------------------------------------------------------------------------
@@ -610,15 +616,8 @@ void LayerImageBase::onThresholdRemove()
                wxVtkBaseView * baseView = _baseView;
                baseView->GetRenderer()->RemoveActor( _thresholdActor );
                baseView->GetRenderer()->RemoveActor( _scalarbarActor );
-
                _actorPresent = false;
-       }
-}
-
-//----------------------------------------------------------------------------
-vtkLookupTable *LayerImageBase::GetvtkLookupTable()
-{
-    return _thresholdTable;
+       }  // if _actorPresent
 }
 
 //----------------------------------------------------------------------------
@@ -637,7 +636,10 @@ void LayerImageBase::GetImageScalarRange()
        _range[1]=max;
 }
 
-
+vtkScalarsToColors* LayerImageBase::GetLookupTable()
+{
+       return _thresholdTable;
+}
 
 // EOF