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"
25 #include "vtkImageViewer2.h"
27 #include <vvMeshActor.h>
28 #include <vtkSmartPointer.h>
33 class vtkPolyDataMapper2D;
35 class vtkClipPolyData;
38 class vtkCornerAnnotation;
40 class vtkPolyDataMapper2D;
41 class vtkPolyDataMapper;
47 class vtkAssignAttribute;
48 class vtkScalarBarActor;
50 class vtkImageReslice;
52 class vvSlicer: public vtkImageViewer2
55 static vvSlicer *New();
56 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
57 void PrintSelf(ostream& os, vtkIndent indent);
59 void SetImage(vvImage::Pointer inputImages);
60 vvImage::Pointer GetImage() {
64 void SetOverlay(vvImage::Pointer inputOverlay);
65 vvImage::Pointer GetOverlay() {
69 vtkImageMapToWindowLevelColors* GetOverlayMapper();
70 vtkImageActor* GetOverlayActor() ;
71 vtkImageMapToWindowLevelColors* GetFusionMapper() ;
72 vtkImageActor* GetFusionActor() ;
73 vtkActor* GetVFActor() ;
74 vtkCornerAnnotation* GetAnnotation();
76 void SetFusion(vvImage::Pointer inputFusion);
77 vvImage::Pointer GetFusion() {
81 /**Set an actor's visibility ("overlay, fusion, vf, contour...")
82 Overlay index is the index of the overlay by type, eg. if there are
83 5 contours and we want to activate the 3rd one, pass 2 **/
84 void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
85 void RemoveActor(const std::string& actor_type, int overlay_index);
87 void SetVF(vvImage::Pointer vf);
92 void SetLandmarks(vvLandmarks* landmarks);
93 void SetTSlice(int t);
94 void SetSliceOrientation(int orientation);
96 ///Reimplemented from vtkImageViewer2 to add polydata support
99 return mImage->GetVTKImages().size() - 1;
102 void SetOpacity(double s);
103 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
104 void SetDisplayMode(bool i);
105 void FlipHorizontalView();
106 void FlipVerticalView();
108 ///Sets the camera to fit the image in the window
111 void SetVFSubSampling(int sub);
112 int GetVFSubSampling() {
115 void SetVFScale(int scale);
119 void SetVFLog(int log);
124 void SetFileName(std::string filename) {
125 mFileName = filename;
127 std::string GetFileName() {
131 double* GetCursorPosition() {
135 void SetCurrentPosition(double x, double y, double z, int t);
136 double* GetCurrentPosition() {
140 void UpdateCursorPosition();
141 void SetCursorVisibility(bool s);
142 bool GetCursorVisibility();
143 void SetCursorColor(int r,int g, int b);
145 void GetExtremasAroundMousePointer(double & min, double & max);
147 void UpdateLandmarks();
148 void ForceUpdateDisplayExtent();
150 int* GetDisplayExtent();
151 /**Add a polydata to be displayed as a contour over the image
152 ** the contour can be propagated to a time sequence using a motion field */
153 void AddContour(vvMesh::Pointer contours,bool propagate);
154 ///Toggle temporal superposition of contours
155 void ToggleContourSuperposition();
157 virtual void SetColorWindow(double s);
158 virtual void SetColorLevel(double s);
161 void EnableReducedExtent(bool b);
162 void SetReducedExtent(int * ext);
164 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
165 int GetOrientation();
172 std::string mFileName;
173 vvImage::Pointer mImage;
174 vvImage::Pointer mOverlay;
175 vvImage::Pointer mFusion;
176 vvImage::Pointer mVF;
178 vvLandmarks* mLandmarks;
180 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
181 vtkSmartPointer<vtkImageActor> mOverlayActor;
182 vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
183 vtkSmartPointer<vtkImageActor> mFusionActor;
184 vtkSmartPointer<vtkCornerAnnotation> ca;
185 vtkSmartPointer<vtkCursor2D> crossCursor;
186 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
187 vtkSmartPointer<vtkActor2D> pdmA;
188 vtkSmartPointer<vvGlyphSource> mArrow;
189 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
190 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
191 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
192 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
193 vtkSmartPointer<vtkActor> mVFActor;
194 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
195 vtkSmartPointer<vtkCursor3D> mCross;
196 vtkSmartPointer<vtkClipPolyData> mLandClipper;
197 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
198 vtkSmartPointer<vtkActor> mLandActor;
199 vtkSmartPointer<vtkBox> mClipBox;
200 vtkSmartPointer<vtkScalarBarActor> legend;
201 std::vector<vvMeshActor*> mSurfaceCutActors;
209 bool mUseReducedExtent;
210 int * mReducedExtent;
211 int * mInitialExtent;
214 void UpdateOrientation();
215 void UpdateDisplayExtent();
216 void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
217 void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
218 void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
219 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
220 void SetContourSlice();