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://oncora1.lyon.fnclcc.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>
34 class vtkPolyDataMapper2D;
36 class vtkClipPolyData;
38 class vvBlendImageActor;
40 class vtkCornerAnnotation;
42 class vtkPolyDataMapper2D;
43 class vtkPolyDataMapper;
49 class vtkAssignAttribute;
50 class vtkScalarBarActor;
52 class vtkImageReslice;
54 class vvSlicer: public vtkImageViewer2
57 static vvSlicer *New();
58 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
59 void PrintSelf(ostream& os, vtkIndent indent);
61 void SetImage(vvImage::Pointer inputImages);
62 vvImage::Pointer GetImage() {
66 void SetOverlay(vvImage::Pointer inputOverlay);
67 vvImage::Pointer GetOverlay() {
70 vtkImageMapToWindowLevelColors* GetOverlayMapper();
71 vvBlendImageActor* GetOverlayActor() ;
72 vtkImageMapToWindowLevelColors* GetFusionMapper() ;
73 vtkImageActor* GetFusionActor() ;
74 vtkActor* GetVFActor() ;
75 vtkCornerAnnotation* GetAnnotation();
77 void SetFusion(vvImage::Pointer inputFusion);
78 vvImage::Pointer GetFusion() {
82 /**Set an actor's visibility ("overlay, fusion, vf, contour...")
83 Overlay index is the index of the overlay by type, eg. if there are
84 5 contours and we want to activate the 3rd one, pass 2 **/
85 void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
86 void RemoveActor(const std::string& actor_type, int overlay_index);
88 void SetVF(vvImage::Pointer vf);
93 void SetLandmarks(vvLandmarks* landmarks);
94 void SetTSlice(int t);
95 void SetSliceOrientation(int orientation);
97 ///Reimplemented from vtkImageViewer2 to add polydata support
100 return (unsigned int)mImage->GetVTKImages().size() - 1;
103 void SetOpacity(double s);
104 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
105 void SetDisplayMode(bool i);
106 void FlipHorizontalView();
107 void FlipVerticalView();
108 static double GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component=0);
110 ///Sets the camera to fit the image in the window
113 void SetVFSubSampling(int sub);
114 int GetVFSubSampling() {
117 void SetVFScale(int scale);
118 void SetVFWidth(int width);
122 void SetVFLog(int log);
127 void SetFileName(std::string filename) {
128 mFileName = filename;
130 std::string GetFileName() {
134 double* GetCursorPosition() {
138 void SetCurrentPosition(double x, double y, double z, int t);
139 double* GetCurrentPosition() {
143 void UpdateCursorPosition();
144 void SetCursorVisibility(bool s);
145 bool GetCursorVisibility();
146 void SetCursorColor(int r,int g, int b);
148 void GetExtremasAroundMousePointer(double & min, double & max);
150 void UpdateLandmarks();
151 void ForceUpdateDisplayExtent();
153 int* GetDisplayExtent();
154 /**Add a polydata to be displayed as a contour over the image
155 ** the contour can be propagated to a time sequence using a motion field */
156 void AddContour(vvMesh::Pointer contours,bool propagate);
157 ///Toggle temporal superposition of contours
158 void ToggleContourSuperposition();
160 virtual void SetColorWindow(double s);
161 virtual void SetColorLevel(double s);
164 void EnableReducedExtent(bool b);
165 void SetReducedExtent(int * ext);
167 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
168 int GetOrientation();
175 std::string mFileName;
176 vvImage::Pointer mImage;
177 vvImage::Pointer mOverlay;
178 vvImage::Pointer mFusion;
179 vvImage::Pointer mVF;
181 vvLandmarks* mLandmarks;
183 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
184 vtkSmartPointer<vvBlendImageActor> mOverlayActor;
185 vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
186 vtkSmartPointer<vtkImageActor> mFusionActor;
187 vtkSmartPointer<vtkCornerAnnotation> ca;
188 vtkSmartPointer<vtkCursor2D> crossCursor;
189 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
190 vtkSmartPointer<vtkActor2D> pdmA;
191 vtkSmartPointer<vvGlyphSource> mArrow;
192 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
193 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
194 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
195 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
196 vtkSmartPointer<vtkActor> mVFActor;
197 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
198 vtkSmartPointer<vtkCursor3D> mCross;
199 vtkSmartPointer<vtkClipPolyData> mLandClipper;
200 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
201 vtkSmartPointer<vtkActor> mLandActor;
202 vtkSmartPointer<vtkBox> mClipBox;
203 vtkSmartPointer<vtkScalarBarActor> legend;
204 std::vector<vvMeshActor*> mSurfaceCutActors;
213 bool mUseReducedExtent;
214 int * mReducedExtent;
215 int * mInitialExtent;
218 void UpdateOrientation();
219 void UpdateDisplayExtent();
220 void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
221 void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
222 void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
223 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
224 void SetContourSlice();