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>
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);
98 ///Reimplemented from vtkImageViewer2 to add polydata support
101 return (unsigned int)mImage->GetVTKImages().size() - 1;
104 void SetOpacity(double s);
105 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
106 void SetDisplayMode(bool i);
107 void FlipHorizontalView();
108 void FlipVerticalView();
109 static double GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component=0);
111 ///Sets the camera to fit the image in the window
114 void SetVFSubSampling(int sub);
115 int GetVFSubSampling() {
118 void SetVFScale(int scale);
119 void SetVFWidth(int width);
123 void SetVFLog(int log);
128 void SetFileName(std::string filename) {
129 mFileName = filename;
131 std::string GetFileName() {
135 double* GetCursorPosition() {
139 void SetCurrentPosition(double x, double y, double z, int t);
140 double* GetCurrentPosition() {
144 void UpdateCursorPosition();
145 void SetCursorVisibility(bool s);
147 bool GetCursorVisibility();
148 void SetCursorColor(int r,int g, int b);
150 void SetCornerAnnotationVisibility(bool s);
151 bool GetCornerAnnotationVisibility();
153 void GetExtremasAroundMousePointer(double & min, double & max);
155 void UpdateLandmarks();
156 void ForceUpdateDisplayExtent();
158 int* GetDisplayExtent();
159 /**Add a polydata to be displayed as a contour over the image
160 ** the contour can be propagated to a time sequence using a motion field */
161 void AddContour(vvMesh::Pointer contours,bool propagate);
162 ///Toggle temporal superposition of contours
163 void ToggleContourSuperposition();
165 virtual void SetColorWindow(double s);
166 virtual void SetColorLevel(double s);
169 void EnableReducedExtent(bool b);
170 void SetReducedExtent(int * ext);
172 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
173 int GetOrientation();
176 double* GetVFColor() {
179 void SetVFColor(double r, double g, double b);
185 std::string mFileName;
186 vvImage::Pointer mImage;
187 vvImage::Pointer mOverlay;
188 vvImage::Pointer mFusion;
189 vvImage::Pointer mVF;
191 vvLandmarks* mLandmarks;
193 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
194 vtkSmartPointer<vvBlendImageActor> mOverlayActor;
195 vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
196 vtkSmartPointer<vtkImageActor> mFusionActor;
197 vtkSmartPointer<vtkCornerAnnotation> ca;
198 vtkSmartPointer<vtkCursor2D> crossCursor;
199 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
200 vtkSmartPointer<vtkActor2D> pdmA;
201 vtkSmartPointer<vvGlyphSource> mArrow;
202 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
203 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
204 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
205 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
206 vtkSmartPointer<vtkLookupTable> mVFColorLUT;
207 vtkSmartPointer<vtkActor> mVFActor;
208 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
209 vtkSmartPointer<vtkCursor3D> mCross;
210 vtkSmartPointer<vtkClipPolyData> mLandClipper;
211 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
212 vtkSmartPointer<vtkActor> mLandActor;
213 vtkSmartPointer<vtkBox> mClipBox;
214 vtkSmartPointer<vtkScalarBarActor> legend;
215 std::vector<vvMeshActor*> mSurfaceCutActors;
225 bool mUseReducedExtent;
226 int * mReducedExtent;
227 int * mInitialExtent;
230 void UpdateOrientation();
231 void UpdateDisplayExtent();
232 void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
233 void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
234 void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
235 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
236 void SetContourSlice();