ThresholdImageView Class Reference

#include <ThresholdImageView.h>

Collaboration diagram for ThresholdImageView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ThresholdImageView ()
 ~ThresholdImageView ()
void onThreshold ()
void onThresholdChange ()
void onThresholdInterpolation (bool interpolate)
void onThresholdChangeOpacity (int opacity)
void onThresholdRemove ()
void SetImage (vtkImageData *image)
void SetwxVtkBaseView (wxVtkBaseView *baseview)
wxVtkBaseViewGetwxVtkBaseView ()
void SetBaseColor (double r, double g, double b)
void SetZ (int z)
void SetminMaxValue (int min, int max)

Private Attributes

int _Z
double _baseColorR
double _baseColorG
double _baseColorB
double _minValue
double _maxValue
bool _actorPresent
vtkImageData * _image
vtkImageReslice * _imageReslicer
vtkLookupTable * _thresholdTable
vtkImageMapToColors * _thresholdMapper
vtkImageActor * _thresholdActor
wxVtkBaseView_baseView

Detailed Description

Definition at line 26 of file ThresholdImageView.h.


Constructor & Destructor Documentation

ThresholdImageView::ThresholdImageView (  ) 

Definition at line 10 of file ThresholdImageView.cxx.

References _actorPresent, _baseColorB, _baseColorG, _baseColorR, _image, _imageReslicer, _maxValue, _minValue, _thresholdActor, _thresholdMapper, _thresholdTable, and _Z.

00011   {
00012           _actorPresent                         =       false;
00013           _Z                                            =       0;
00014           _minValue                                     =       0;
00015           _maxValue                                     =       1000;
00016           _image                                        =       NULL;
00017           _imageReslicer                        =       NULL;
00018           _thresholdTable                       =       NULL;
00019           _thresholdMapper                      =       NULL;
00020           _thresholdActor                       =       NULL;
00021           _baseColorR                           =       1;
00022           _baseColorG                           =       0;
00023           _baseColorB                           =       0;
00024   }

ThresholdImageView::~ThresholdImageView (  ) 

Definition at line 27 of file ThresholdImageView.cxx.

00028   {
00029   }


Member Function Documentation

wxVtkBaseView * ThresholdImageView::GetwxVtkBaseView (  ) 
void ThresholdImageView::onThreshold (  ) 

Definition at line 65 of file ThresholdImageView.cxx.

References _actorPresent, _baseColorB, _baseColorG, _baseColorR, _baseView, _image, _imageReslicer, _maxValue, _minValue, _thresholdActor, _thresholdMapper, _thresholdTable, _Z, and wxVtkBaseView::GetRenderer().

Referenced by onThresholdChange(), and ThresholdImageViewPanel::onThresholdShow().

00066 {
00067         int     z = _Z;
00068         double range[2];
00069         
00070         vtkImageData *img = _image;
00071         img->GetScalarRange(range);
00072         if (range[1]==0)
00073         {
00074                 range[1]=255;
00075         }
00076         
00077         int minTot = floor (range[0]);
00078         int maxTot = ceil (range[1]);
00079         
00080         int minVal = floor (_minValue);
00081         int maxVal = floor (_maxValue);
00082         
00083         if (!_actorPresent)
00084         {
00085                 if (_imageReslicer==NULL)
00086                 {
00087                         _imageReslicer = vtkImageReslice::New();
00088                         _imageReslicer->SetInput( img );
00089                         _imageReslicer->SetInformationInput(img);                       
00090                         _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
00091                         _imageReslicer->SetOutputDimensionality(2);
00092                         _imageReslicer->SetInterpolationModeToLinear();
00093                 }
00094                 
00095                 _imageReslicer->SetResliceAxesOrigin(0,0,z);
00096                 
00097                 img = _imageReslicer->GetOutput();
00098                 img->Update();
00099                 img->UpdateInformation();
00100                 
00101                 wxVtkBaseView *baseView = _baseView;
00102                 
00103                 if (_thresholdTable==NULL)
00104                 {
00105                         //Lookup Table
00106                         _thresholdTable = vtkLookupTable::New();
00107                         _thresholdTable->SetNumberOfTableValues(maxTot+1);
00108                         _thresholdTable->SetTableRange(range); 
00109                         _thresholdTable->SetAlphaRange(0, 1);
00110                         _thresholdTable->SetValueRange(0, 1);
00111                         _thresholdTable->SetSaturationRange(0, 0); 
00112                         _thresholdTable->SetRampToLinear( );
00113                 }
00114                 
00115                 //Assign a fake color for the upper image, and set the white as transparent
00116                 int i;
00117                 for(i = minTot; i <= maxTot; i++)
00118                 {
00119                         if( i >= minVal && i <= maxVal )
00120                         {
00121                                 _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
00122                         }
00123                         else if( i >= minTot && i < minVal )
00124                         {
00125                                 _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00126                         }
00127                         else if( i > maxVal && i < maxTot )
00128                         {
00129                                 _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00130                         }
00131                         else
00132                         {
00133                                 _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00134                         }
00135                 }
00136                 _thresholdTable->Build( );
00137                 
00138                 if (_thresholdMapper==NULL)
00139                 {
00140                         _thresholdMapper = vtkImageMapToColors::New( );
00141                 }
00142                 
00143                 _thresholdMapper->SetLookupTable( _thresholdTable );
00144                 _thresholdMapper->SetInput( img );
00145                 
00146                 if (_thresholdActor==NULL)
00147                 {
00148                         _thresholdActor = vtkImageActor::New( );
00149                         _thresholdActor->SetOpacity( 0.6 );
00150                         _thresholdActor->InterpolateOn(  );
00151                         _thresholdActor->SetPosition( 0,0, 900-1 );
00152                 }
00153                 
00154                 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
00155                 
00156                 baseView->GetRenderer()->AddActor( _thresholdActor );
00157                 _actorPresent = true;
00158         }
00159         else
00160         {
00161                 _imageReslicer->SetResliceAxesOrigin(0,0,z);
00162                 img = _imageReslicer->GetOutput();
00163                 img->Update();
00164                 img->UpdateInformation();
00165                 
00166                 //Assign a fake color for the upper image, and set the white as transparent
00167                 int i;
00168                 for(i = minTot; i <= maxTot; i++)
00169                 {
00170                         if( i >= minVal && i <= maxVal )
00171                         {
00172                                 _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
00173                         }
00174                         else if( i >= minTot && i < minVal )
00175                         {
00176                                 _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00177                         }
00178                         else if( i > maxVal && i < maxTot )
00179                         {
00180                                 _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00181                         }
00182                         else
00183                         {
00184                                 _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00185                         }
00186                 }
00187                 _thresholdTable->Build( );
00188                 _thresholdMapper->SetLookupTable( _thresholdTable );
00189                 _thresholdMapper->SetInput( img );
00190                 _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
00191         }
00192 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ThresholdImageView::onThresholdChange (  ) 

Definition at line 196 of file ThresholdImageView.cxx.

References _actorPresent, and onThreshold().

Referenced by ThresholdImageViewPanel::onThresholdChange().

00197 {
00198         if (_actorPresent)
00199         {
00200                 onThreshold();
00201         }
00202 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ThresholdImageView::onThresholdChangeOpacity ( int  opacity  ) 

Definition at line 221 of file ThresholdImageView.cxx.

References _actorPresent, and _thresholdActor.

Referenced by ThresholdImageViewPanel::onChangeOpacity().

00222 {
00223         if (_actorPresent)
00224         {
00225                 _thresholdActor->SetOpacity(opacity*0.1);
00226         }
00227 }

Here is the caller graph for this function:

void ThresholdImageView::onThresholdInterpolation ( bool  interpolate  ) 

Definition at line 205 of file ThresholdImageView.cxx.

References _thresholdActor.

Referenced by ThresholdImageViewPanel::onThresholdInterpolation().

00206 {
00207         if (_thresholdActor!=NULL)
00208         {
00209                 if (interpolate)
00210                 {
00211                         _thresholdActor->InterpolateOn( );
00212                 }
00213                 else
00214                 {
00215                         _thresholdActor->InterpolateOff( );
00216                 }               
00217         }
00218 }

Here is the caller graph for this function:

void ThresholdImageView::onThresholdRemove (  ) 

Definition at line 230 of file ThresholdImageView.cxx.

References _actorPresent, _baseView, _thresholdActor, and wxVtkBaseView::GetRenderer().

Referenced by ThresholdImageViewPanel::onThresholdShow(), and ThresholdImageViewPanel::onThresholdStop().

00231 {
00232         if (_actorPresent)
00233         {
00234                 wxVtkBaseView * baseView = _baseView;
00235                 baseView->GetRenderer()->RemoveActor( _thresholdActor );
00236                 _actorPresent = false;
00237         }       
00238 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ThresholdImageView::SetBaseColor ( double  r,
double  g,
double  b 
)

Definition at line 242 of file ThresholdImageView.cxx.

References _baseColorB, _baseColorG, and _baseColorR.

00243 {
00244         _baseColorR = r;
00245         _baseColorG = g;
00246         _baseColorB = b;
00247 }

void ThresholdImageView::SetImage ( vtkImageData *  image  ) 

Definition at line 34 of file ThresholdImageView.cxx.

References _image.

00035 {
00036         _image = image;
00037 }

void ThresholdImageView::SetminMaxValue ( int  min,
int  max 
)

Definition at line 58 of file ThresholdImageView.cxx.

References _maxValue, and _minValue.

Referenced by ThresholdImageViewPanel::onThresholdChange().

00059 {
00060         _minValue = min;
00061         _maxValue = max;
00062 }

Here is the caller graph for this function:

void ThresholdImageView::SetwxVtkBaseView ( wxVtkBaseView baseview  ) 

Definition at line 40 of file ThresholdImageView.cxx.

References _baseView.

00041 {
00042         _baseView = baseview;
00043 }

void ThresholdImageView::SetZ ( int  z  ) 

Definition at line 52 of file ThresholdImageView.cxx.

References _Z.

00053 {
00054         _Z = z;
00055 }


Member Data Documentation

Definition at line 49 of file ThresholdImageView.h.

Referenced by onThreshold(), SetBaseColor(), and ThresholdImageView().

Definition at line 48 of file ThresholdImageView.h.

Referenced by onThreshold(), SetBaseColor(), and ThresholdImageView().

Definition at line 47 of file ThresholdImageView.h.

Referenced by onThreshold(), SetBaseColor(), and ThresholdImageView().

vtkImageData* ThresholdImageView::_image [private]

Definition at line 53 of file ThresholdImageView.h.

Referenced by onThreshold(), SetImage(), and ThresholdImageView().

vtkImageReslice* ThresholdImageView::_imageReslicer [private]

Definition at line 54 of file ThresholdImageView.h.

Referenced by onThreshold(), and ThresholdImageView().

Definition at line 51 of file ThresholdImageView.h.

Referenced by onThreshold(), SetminMaxValue(), and ThresholdImageView().

Definition at line 50 of file ThresholdImageView.h.

Referenced by onThreshold(), SetminMaxValue(), and ThresholdImageView().

vtkImageActor* ThresholdImageView::_thresholdActor [private]
vtkImageMapToColors* ThresholdImageView::_thresholdMapper [private]

Definition at line 56 of file ThresholdImageView.h.

Referenced by onThreshold(), and ThresholdImageView().

vtkLookupTable* ThresholdImageView::_thresholdTable [private]

Definition at line 55 of file ThresholdImageView.h.

Referenced by onThreshold(), and ThresholdImageView().

int ThresholdImageView::_Z [private]

Definition at line 46 of file ThresholdImageView.h.

Referenced by onThreshold(), SetZ(), and ThresholdImageView().


The documentation for this class was generated from the following files:

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1