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;
51 class vvSlicer: public vtkImageViewer2
54 static vvSlicer *New();
55 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
56 void PrintSelf(ostream& os, vtkIndent indent);
58 void SetImage(vvImage::Pointer inputImages);
59 vvImage::Pointer GetImage() {
63 void SetOverlay(vvImage::Pointer inputOverlay);
64 vvImage::Pointer GetOverlay() {
68 vtkImageMapToWindowLevelColors* GetOverlayMapper();
69 vtkImageActor* GetOverlayActor() ;
70 vtkImageMapToWindowLevelColors* GetFusionMapper() ;
71 vtkImageActor* GetFusionActor() ;
72 vtkActor* GetVFActor() ;
73 vtkCornerAnnotation* GetAnnotation() ;
75 void SetFusion(vvImage::Pointer inputFusion);
76 vvImage::Pointer GetFusion() {
80 /**Set an actor's visibility ("overlay, fusion, vf, contour...")
81 Overlay index is the index of the overlay by type, eg. if there are
82 5 contours and we want to activate the 3rd one, pass 2 **/
83 void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
84 void RemoveActor(const std::string& actor_type, int overlay_index);
86 void SetVF(vvImage::Pointer vf);
91 void SetLandmarks(vvLandmarks* landmarks);
92 void SetTSlice(int t);
93 void SetSliceOrientation(int orientation);
95 ///Reimplemented from vtkImageViewer2 to add polydata support
98 return mImage->GetVTKImages().size() - 1;
101 void SetOpacity(double s);
102 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
103 void SetDisplayMode(bool i);
104 void FlipHorizontalView();
105 void FlipVerticalView();
107 ///Sets the camera to fit the image in the window
110 void SetVFSubSampling(int sub);
111 int GetVFSubSampling() {
114 void SetVFScale(int scale);
118 void SetVFLog(int log);
123 void SetFileName(std::string filename) {
124 mFileName = filename;
126 std::string GetFileName() {
130 double* GetCursorPosition() {
134 void SetCurrentPosition(double x, double y, double z, int t);
135 double* GetCurrentPosition() {
139 void UpdateCursorPosition();
140 void SetCursorVisibility(bool s);
141 bool GetCursorVisibility();
142 void SetCursorColor(int r,int g, int b);
144 void GetExtremasAroundMousePointer(double & min, double & max);
146 void UpdateLandmarks();
147 void ForceUpdateDisplayExtent();
149 int* GetDisplayExtent();
150 /**Add a polydata to be displayed as a contour over the image
151 ** the contour can be propagated to a time sequence using a motion field */
152 void AddContour(vvMesh::Pointer contours,bool propagate);
153 ///Toggle temporal superposition of contours
154 void ToggleContourSuperposition();
156 virtual void SetColorWindow(double s);
157 virtual void SetColorLevel(double s);
160 void EnableReducedExtent(bool b);
161 void SetReducedExtent(int * ext);
167 std::string mFileName;
168 vvImage::Pointer mImage;
169 vvImage::Pointer mOverlay;
170 vvImage::Pointer mFusion;
171 vvImage::Pointer mVF;
173 vvLandmarks* mLandmarks;
175 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
176 vtkSmartPointer<vtkImageActor> mOverlayActor;
177 vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
178 vtkSmartPointer<vtkImageActor> mFusionActor;
179 vtkSmartPointer<vtkCornerAnnotation> ca;
180 vtkSmartPointer<vtkCursor2D> crossCursor;
181 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
182 vtkSmartPointer<vtkActor2D> pdmA;
183 vtkSmartPointer<vvGlyphSource> mArrow;
184 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
185 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
186 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
187 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
188 vtkSmartPointer<vtkActor> mVFActor;
189 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
190 vtkSmartPointer<vtkCursor3D> mCross;
191 vtkSmartPointer<vtkClipPolyData> mLandClipper;
192 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
193 vtkSmartPointer<vtkActor> mLandActor;
194 vtkSmartPointer<vtkBox> mClipBox;
195 vtkSmartPointer<vtkScalarBarActor> legend;
197 std::vector<vvMeshActor*> mSurfaceCutActors;
205 bool mUseReducedExtent;
206 int * mReducedExtent;
207 int * mInitialExtent;
210 void UpdateOrientation();
211 void UpdateDisplayExtent();
212 void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
213 void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
214 void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
215 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
216 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
217 void SetContourSlice();