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);
146 bool GetCursorVisibility();
147 void SetCursorColor(int r,int g, int b);
149 void SetCornerAnnotationVisibility(bool s);
150 bool GetCornerAnnotationVisibility();
152 void GetExtremasAroundMousePointer(double & min, double & max);
154 void UpdateLandmarks();
155 void ForceUpdateDisplayExtent();
157 int* GetDisplayExtent();
158 /**Add a polydata to be displayed as a contour over the image
159 ** the contour can be propagated to a time sequence using a motion field */
160 void AddContour(vvMesh::Pointer contours,bool propagate);
161 ///Toggle temporal superposition of contours
162 void ToggleContourSuperposition();
164 virtual void SetColorWindow(double s);
165 virtual void SetColorLevel(double s);
168 void EnableReducedExtent(bool b);
169 void SetReducedExtent(int * ext);
171 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
172 int GetOrientation();
175 double* GetVFColor() {
178 void SetVFColor(double r, double g, double b);
184 std::string mFileName;
185 vvImage::Pointer mImage;
186 vvImage::Pointer mOverlay;
187 vvImage::Pointer mFusion;
188 vvImage::Pointer mVF;
190 vvLandmarks* mLandmarks;
192 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
193 vtkSmartPointer<vvBlendImageActor> mOverlayActor;
194 vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
195 vtkSmartPointer<vtkImageActor> mFusionActor;
196 vtkSmartPointer<vtkCornerAnnotation> ca;
197 vtkSmartPointer<vtkCursor2D> crossCursor;
198 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
199 vtkSmartPointer<vtkActor2D> pdmA;
200 vtkSmartPointer<vvGlyphSource> mArrow;
201 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
202 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
203 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
204 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
205 vtkSmartPointer<vtkLookupTable> mVFColorLUT;
206 vtkSmartPointer<vtkActor> mVFActor;
207 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
208 vtkSmartPointer<vtkCursor3D> mCross;
209 vtkSmartPointer<vtkClipPolyData> mLandClipper;
210 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
211 vtkSmartPointer<vtkActor> mLandActor;
212 vtkSmartPointer<vtkBox> mClipBox;
213 vtkSmartPointer<vtkScalarBarActor> legend;
214 std::vector<vvMeshActor*> mSurfaceCutActors;
224 bool mUseReducedExtent;
225 int * mReducedExtent;
226 int * mInitialExtent;
229 void UpdateOrientation();
230 void UpdateDisplayExtent();
231 void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
232 void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
233 void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
234 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
235 void SetContourSlice();