#include <ColorLayerImageView.h>
Public Member Functions | |
ColorLayerImageView () | |
~ColorLayerImageView () | |
void | SetSliceFixDinamic (bool fix_dinamic) |
void | SetZ2 (int z2) |
virtual int | GetZ () |
void | SetZ (int z) |
void | SetImage (vtkImageData *image) |
void | SetwxVtkBaseView (wxVtkBaseView *baseview) |
void | onThreshold () |
void | onThresholdChange () |
void | onThresholdInterpolation (bool interpolate) |
void | onThresholdChangeOpacity (int opacity) |
void | onThresholdRemove () |
wxVtkBaseView * | GetwxVtkBaseView () |
void | Refresh () |
Protected Member Functions | |
vtkLookupTable * | GetThresholdTable () |
vtkImageData * | GetImage () |
Private Member Functions | |
virtual void | ConfigLookupTable () |
Private Attributes | |
int | _z2 |
bool | _fix_dinamic |
Definition at line 20 of file ColorLayerImageView.h.
ColorLayerImageView::ColorLayerImageView | ( | ) |
Definition at line 18 of file ColorLayerImageView.cxx.
References _fix_dinamic, and _z2.
00019 { 00020 _z2 = 0; 00021 _fix_dinamic = true; 00022 }
ColorLayerImageView::~ColorLayerImageView | ( | ) |
Definition at line 25 of file ColorLayerImageView.cxx.
void ColorLayerImageView::ConfigLookupTable | ( | ) | [private, virtual] |
Implements LayerImageBase.
Definition at line 59 of file ColorLayerImageView.cxx.
References LayerImageBase::GetImage(), and LayerImageBase::GetThresholdTable().
00060 { 00061 double range[2]; 00062 00063 GetImage()->GetScalarRange(range); 00064 if (range[1]==0) 00065 { 00066 range[1]=255; 00067 } 00068 00069 int minTot = floor (range[0]); 00070 int maxTot = ceil (range[1]); 00071 00072 00073 vtkLookupTable* thresholdTable = GetThresholdTable(); 00074 thresholdTable->SetNumberOfTableValues(maxTot+1); 00075 thresholdTable->SetTableRange(range); 00076 thresholdTable->SetAlphaRange(0, 1); 00077 thresholdTable->SetValueRange(0, 1); 00078 thresholdTable->SetSaturationRange(0, 0); 00079 thresholdTable->SetRampToLinear( ); 00080 00081 //Assign a fake color for the upper image, and set the white as transparent 00082 int i,ii; 00083 double iBlue=0 , iYellow=0 , iRed=0; 00084 double delta=(maxTot-minTot)/3.0; 00085 00086 double delta0=delta*0; 00087 double delta1=delta*1; 00088 double delta2=delta*2; 00089 double delta3=delta*3; 00090 00091 00092 for(i = minTot; i <= maxTot; i++) 00093 { 00094 ii=i-minTot; 00095 if ((ii>=delta0) && (ii<=delta1)) // iBlue 00096 { 00097 thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1); 00098 if (ii==0) 00099 { 00100 thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 0); 00101 } else { 00102 thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1); 00103 } 00104 iBlue++; 00105 } 00106 if ((ii>=delta1) && (ii<=delta2)) // iYellow 00107 { 00108 thresholdTable->SetTableValue( i , iYellow/delta , iYellow/delta , (delta-iYellow)/delta , 1); 00109 iYellow++; 00110 } 00111 if ((ii>=delta2) && (ii<=delta3)) // iRed 00112 { 00113 thresholdTable->SetTableValue( i , 1 , (delta-iRed)/delta , 0 , 1); 00114 iRed++; 00115 } 00116 } // for 00117 00118 thresholdTable->Build( ); 00119 00120 }
vtkImageData * LayerImageBase::GetImage | ( | ) | [protected, inherited] |
Definition at line 40 of file LayerImageBase.cxx.
References LayerImageBase::_image.
Referenced by ThresholdImageView::ConfigLookupTable(), ConfigLookupTable(), and LayerImageBase::onThreshold().
00041 { 00042 return _image; 00043 }
vtkLookupTable * LayerImageBase::GetThresholdTable | ( | ) | [protected, inherited] |
Definition at line 82 of file LayerImageBase.cxx.
References LayerImageBase::_thresholdTable.
Referenced by ThresholdImageView::ConfigLookupTable(), and ConfigLookupTable().
00083 { 00084 return _thresholdTable; 00085 }
wxVtkBaseView * LayerImageBase::GetwxVtkBaseView | ( | ) | [inherited] |
Definition at line 66 of file LayerImageBase.cxx.
References LayerImageBase::_baseView.
Referenced by ThresholdImageViewPanel::onChangeOpacity(), ThresholdImageViewPanel::onThresholdChange(), ThresholdImageViewPanel::onThresholdInterpolation(), and ThresholdImageViewPanel::onThresholdShow().
00067 { 00068 return _baseView; 00069 }
int ColorLayerImageView::GetZ | ( | ) | [virtual] |
Reimplemented from LayerImageBase.
Definition at line 44 of file ColorLayerImageView.cxx.
References _fix_dinamic, and _z2.
00045 { 00046 int result=0; 00047 if (_fix_dinamic==false) 00048 { 00049 result = _z2; 00050 } else { 00051 result = LayerImageBase::GetZ(); 00052 } 00053 00054 return result; 00055 }
void LayerImageBase::onThreshold | ( | ) | [inherited] |
Definition at line 107 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, LayerImageBase::_baseView, LayerImageBase::_image, LayerImageBase::_imageReslicer, LayerImageBase::_thresholdActor, LayerImageBase::_thresholdMapper, LayerImageBase::_thresholdTable, LayerImageBase::CleanZ(), LayerImageBase::ConfigLookupTable(), LayerImageBase::GetActorPresent(), LayerImageBase::GetImage(), wxVtkBaseView::GetRenderer(), and LayerImageBase::GetZ().
Referenced by ColorLayerImageViewPanel::onReadImage(), ColorLayerImageViewPanel::onSliceFixDinamic(), ColorLayerImageViewPanel::onSliceImage(), LayerImageBase::onThresholdChange(), ThresholdImageViewPanel::onThresholdShow(), and ColorLayerImageViewPanel::onThresholdShow().
00108 { 00109 00110 if ((_image!=NULL) && (_baseView!=NULL)) 00111 { 00112 int z=CleanZ( GetZ() ); 00113 00114 if (!GetActorPresent()) 00115 { 00116 if (_thresholdTable==NULL) 00117 { 00118 //Lookup Table 00119 _thresholdTable = vtkLookupTable::New(); 00120 } // _thresholdTable 00121 00122 if (_thresholdMapper==NULL) 00123 { 00124 _thresholdMapper = vtkImageMapToColors::New( ); 00125 } 00126 00127 if (_thresholdActor==NULL) 00128 { 00129 _thresholdActor = vtkImageActor::New( ); 00130 _thresholdActor->SetOpacity( 0.6 ); 00131 _thresholdActor->InterpolateOn( ); 00132 _thresholdActor->SetPosition( 0,0, 900-1 ); 00133 } // _thresholdActor 00134 _baseView->GetRenderer()->AddActor( _thresholdActor ); 00135 _actorPresent = true; 00136 } // !GetActorPresent() 00137 00138 ConfigLookupTable(); // virtual method 00139 _imageReslicer->SetInput( GetImage() ); 00140 _imageReslicer->SetInformationInput( GetImage() ); 00141 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); 00142 _imageReslicer->SetOutputDimensionality(2); 00143 _imageReslicer->SetInterpolationModeToLinear(); 00144 _imageReslicer->SetResliceAxesOrigin(0,0,z); 00145 00146 vtkImageData *img = _imageReslicer->GetOutput(); 00147 img->Update(); 00148 img->UpdateInformation(); 00149 00150 _thresholdMapper->SetInput( img ); 00151 _thresholdMapper->SetLookupTable( _thresholdTable ); 00152 _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); 00153 } // _image 00154 }
void LayerImageBase::onThresholdChange | ( | ) | [inherited] |
Definition at line 159 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, and LayerImageBase::onThreshold().
Referenced by ThresholdImageViewPanel::onThresholdChange(), and ColorLayerImageViewPanel::onThresholdChange().
00160 { 00161 if (_actorPresent) 00162 { 00163 onThreshold(); 00164 } 00165 }
void LayerImageBase::onThresholdChangeOpacity | ( | int | opacity | ) | [inherited] |
Definition at line 184 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, and LayerImageBase::_thresholdActor.
Referenced by ThresholdImageViewPanel::onChangeOpacity(), and ColorLayerImageViewPanel::onChangeOpacity().
00185 { 00186 if (_actorPresent) 00187 { 00188 _thresholdActor->SetOpacity(opacity*0.1); 00189 } 00190 }
void LayerImageBase::onThresholdInterpolation | ( | bool | interpolate | ) | [inherited] |
Definition at line 168 of file LayerImageBase.cxx.
References LayerImageBase::_thresholdActor.
Referenced by ThresholdImageViewPanel::onThresholdInterpolation(), and ColorLayerImageViewPanel::onThresholdInterpolation().
00169 { 00170 if (_thresholdActor!=NULL) 00171 { 00172 if (interpolate) 00173 { 00174 _thresholdActor->InterpolateOn( ); 00175 } 00176 else 00177 { 00178 _thresholdActor->InterpolateOff( ); 00179 } 00180 } 00181 }
void LayerImageBase::onThresholdRemove | ( | ) | [inherited] |
Definition at line 193 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, LayerImageBase::_baseView, LayerImageBase::_thresholdActor, and wxVtkBaseView::GetRenderer().
Referenced by ThresholdImageViewPanel::onThresholdShow(), ColorLayerImageViewPanel::onThresholdShow(), ThresholdImageViewPanel::onThresholdStop(), and ColorLayerImageViewPanel::onThresholdStop().
00194 { 00195 if (_actorPresent) 00196 { 00197 wxVtkBaseView * baseView = _baseView; 00198 baseView->GetRenderer()->RemoveActor( _thresholdActor ); 00199 _actorPresent = false; 00200 } 00201 }
void LayerImageBase::Refresh | ( | ) | [inherited] |
Definition at line 72 of file LayerImageBase.cxx.
References LayerImageBase::_baseView, and wxVtkBaseView::Refresh().
Referenced by ColorLayerImageViewPanel::onChangeOpacity(), ColorLayerImageViewPanel::onReadImage(), ColorLayerImageViewPanel::onSliceFixDinamic(), ColorLayerImageViewPanel::onSliceImage(), ColorLayerImageViewPanel::onThresholdChange(), ColorLayerImageViewPanel::onThresholdInterpolation(), and ColorLayerImageViewPanel::onThresholdShow().
void LayerImageBase::SetImage | ( | vtkImageData * | image | ) | [inherited] |
Definition at line 54 of file LayerImageBase.cxx.
References LayerImageBase::_image.
Referenced by ColorLayerImageViewPanel::onReadImage().
00055 { 00056 _image = image; 00057 }
void ColorLayerImageView::SetSliceFixDinamic | ( | bool | fix_dinamic | ) |
Definition at line 32 of file ColorLayerImageView.cxx.
References _fix_dinamic.
Referenced by ColorLayerImageViewPanel::onSliceFixDinamic().
00033 { 00034 _fix_dinamic = fix_dinamic; 00035 }
void LayerImageBase::SetwxVtkBaseView | ( | wxVtkBaseView * | baseview | ) | [inherited] |
Definition at line 60 of file LayerImageBase.cxx.
References LayerImageBase::_baseView.
00061 { 00062 _baseView = baseview; 00063 }
void LayerImageBase::SetZ | ( | int | z | ) | [inherited] |
Definition at line 28 of file LayerImageBase.cxx.
References LayerImageBase::_Z.
00029 { 00030 _Z = z; 00031 }
void ColorLayerImageView::SetZ2 | ( | int | z2 | ) |
Definition at line 38 of file ColorLayerImageView.cxx.
References _z2.
Referenced by ColorLayerImageViewPanel::onSliceFixDinamic(), and ColorLayerImageViewPanel::onSliceImage().
00039 { 00040 _z2 = z2; 00041 }
bool ColorLayerImageView::_fix_dinamic [private] |
Definition at line 32 of file ColorLayerImageView.h.
Referenced by ColorLayerImageView(), GetZ(), and SetSliceFixDinamic().
int ColorLayerImageView::_z2 [private] |
Definition at line 31 of file ColorLayerImageView.h.
Referenced by ColorLayerImageView(), GetZ(), and SetZ2().