1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
23 #include "vvLandmarks.h"
26 #include "vvMeshActor.h"
28 #include <vtkSmartPointer.h>
29 #include <vtkImageViewer2.h>
30 #include <vtkImageReslice.h>
35 class vtkPolyDataMapper2D;
37 class vtkClipPolyData;
39 class vvBlendImageActor;
41 class vtkCornerAnnotation;
43 class vtkPolyDataMapper2D;
44 class vtkPolyDataMapper;
50 class vtkAssignAttribute;
51 class vtkScalarBarActor;
53 class vtkImageReslice;
55 class vvSlicer: public vtkImageViewer2
58 static vvSlicer *New();
59 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
60 void PrintSelf(ostream& os, vtkIndent indent);
62 void SetImage(vvImage::Pointer inputImages);
63 vvImage::Pointer GetImage() {
67 void SetOverlay(vvImage::Pointer inputOverlay);
68 vvImage::Pointer GetOverlay() {
71 vtkImageMapToWindowLevelColors* GetOverlayMapper();
72 vvBlendImageActor* GetOverlayActor() ;
73 vtkImageMapToWindowLevelColors* GetFusionMapper() ;
74 vtkImageActor* GetFusionActor() ;
75 vtkActor* GetVFActor() ;
76 vtkCornerAnnotation* GetAnnotation();
78 void SetFusion(vvImage::Pointer inputFusion);
79 vvImage::Pointer GetFusion() {
83 /**Set an actor's visibility ("overlay, fusion, vf, contour...")
84 Overlay index is the index of the overlay by type, eg. if there are
85 5 contours and we want to activate the 3rd one, pass 2 **/
86 void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
87 void RemoveActor(const std::string& actor_type, int overlay_index);
89 void SetVF(vvImage::Pointer vf);
94 void SetLandmarks(vvLandmarks* landmarks);
95 void SetTSlice(int t);
96 void SetSliceOrientation(int orientation);
97 void AdjustResliceToSliceOrientation(vtkImageReslice *reslice);
99 ///Reimplemented from vtkImageViewer2 to add polydata support
100 void SetSlice(int s);
102 return (unsigned int)mImage->GetVTKImages().size() - 1;
105 void SetOpacity(double s);
106 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
107 void SetDisplayMode(bool i);
108 void FlipHorizontalView();
109 void FlipVerticalView();
110 static double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component=0);
112 ///Sets the camera to fit the image in the window
115 void SetVFSubSampling(int sub);
116 int GetVFSubSampling() {
119 void SetVFScale(int scale);
120 void SetVFWidth(int width);
124 void SetVFLog(int log);
129 void SetFileName(std::string filename) {
130 mFileName = filename;
132 std::string GetFileName() {
136 double* GetCursorPosition() {
140 void SetCurrentPosition(double x, double y, double z, int t);
141 double* GetCurrentPosition() {
145 void UpdateCursorPosition();
146 void SetCursorVisibility(bool s);
148 bool GetCursorVisibility();
149 void SetCursorColor(int r,int g, int b);
151 void SetCornerAnnotationVisibility(bool s);
152 bool GetCornerAnnotationVisibility();
154 void GetExtremasAroundMousePointer(double & min, double & max);
156 void UpdateLandmarks();
157 void ForceUpdateDisplayExtent();
159 int* GetDisplayExtent();
160 /**Add a polydata to be displayed as a contour over the image
161 ** the contour can be propagated to a time sequence using a motion field */
162 void AddContour(vvMesh::Pointer contours,bool propagate);
163 ///Toggle temporal superposition of contours
164 void ToggleContourSuperposition();
166 virtual void SetColorWindow(double s);
167 virtual void SetColorLevel(double s);
170 * When it is enabled, beware of a call to GetExtent.
171 * we must have setted mReducedExtent otherwhise random values
172 * are returned by GetExtent
174 void EnableReducedExtent(bool b);
175 void SetReducedExtent(int * ext);
177 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
178 int GetOrientation();
181 double* GetVFColor() {
184 void SetVFColor(double r, double g, double b);
190 std::string mFileName;
191 vvImage::Pointer mImage;
192 vvImage::Pointer mOverlay;
193 vvImage::Pointer mFusion;
194 vvImage::Pointer mVF;
196 vvLandmarks* mLandmarks;
198 vtkSmartPointer<vtkImageReslice> mImageReslice;
199 vtkSmartPointer<vtkImageReslice> mOverlayReslice;
200 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
201 vtkSmartPointer<vvBlendImageActor> mOverlayActor;
202 vtkSmartPointer<vtkImageReslice> mFusionReslice;
203 vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
204 vtkSmartPointer<vtkImageActor> mFusionActor;
205 vtkSmartPointer<vtkCornerAnnotation> ca;
206 vtkSmartPointer<vtkCursor2D> crossCursor;
207 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
208 vtkSmartPointer<vtkActor2D> pdmA;
209 vtkSmartPointer<vvGlyphSource> mArrow;
210 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
211 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
212 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
213 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
214 vtkSmartPointer<vtkLookupTable> mVFColorLUT;
215 vtkSmartPointer<vtkActor> mVFActor;
216 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
217 vtkSmartPointer<vtkCursor3D> mCross;
218 vtkSmartPointer<vtkClipPolyData> mLandClipper;
219 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
220 vtkSmartPointer<vtkActor> mLandActor;
221 vtkSmartPointer<vtkBox> mClipBox;
222 vtkSmartPointer<vtkScalarBarActor> legend;
223 std::vector<vvMeshActor*> mSurfaceCutActors;
233 bool mUseReducedExtent;
234 int * mReducedExtent;
235 int * mInitialExtent;
238 void UpdateOrientation();
239 void UpdateDisplayExtent();
240 void ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
241 vtkImageData *targetImage, int targetExtent[6]);
242 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
243 void SetContourSlice();