]> Creatis software - clitk.git/blob - vv/vvSlicer.h
- small correction about Render (a bit less unuseful Render)
[clitk.git] / vv / vvSlicer.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
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
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef __vvSlicer_h
19 #define __vvSlicer_h
20 #include <iostream>
21 #include <vector>
22
23 #include "vvLandmarks.h"
24 #include "vvImage.h"
25 #include "vtkImageViewer2.h"
26 #include "vvMesh.h"
27 #include <vvMeshActor.h>
28 #include <vtkSmartPointer.h>
29
30 class vtkActor;
31 class vtkActor2D;
32 class vtkCursor2D;
33 class vtkPolyDataMapper2D;
34 class vtkProperty2D;
35 class vtkClipPolyData;
36 class vtkImageActor;
37 class vtkBox;
38 class vtkCornerAnnotation;
39 class vtkExtractVOI;
40 class vtkPolyDataMapper2D;
41 class vtkPolyDataMapper;
42 class vtkGlyph3D;
43 class vvGlyph2D;
44 class vvGlyphSource;
45 class vtkCursor3D;
46 class vtkCutter;
47 class vtkAssignAttribute;
48 class vtkScalarBarActor;
49 class vtkTransform;
50 class vtkImageReslice;
51
52 class vvSlicer: public vtkImageViewer2
53 {
54 public:
55     static vvSlicer *New();
56     vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
57     void PrintSelf(ostream& os, vtkIndent indent);
58
59     void SetImage(vvImage::Pointer inputImages);
60     vvImage::Pointer GetImage() {
61         return mImage;
62     }
63
64     void SetOverlay(vvImage::Pointer inputOverlay);
65     vvImage::Pointer GetOverlay() {
66         return mOverlay;
67     }
68
69     vtkImageMapToWindowLevelColors* GetOverlayMapper(); 
70     vtkImageActor* GetOverlayActor() ;
71     vtkImageMapToWindowLevelColors* GetFusionMapper() ;
72     vtkImageActor* GetFusionActor() ;
73     vtkActor* GetVFActor() ;
74     vtkCornerAnnotation* GetAnnotation();
75     
76     void SetFusion(vvImage::Pointer inputFusion);
77     vvImage::Pointer GetFusion() {
78         return mFusion;
79     }
80
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);
86
87     void SetVF(vvImage::Pointer vf);
88     vvImage *GetVF() {
89         return mVF;
90     }
91
92     void SetLandmarks(vvLandmarks* landmarks);
93     void SetTSlice(int t);
94     void SetSliceOrientation(int orientation);
95     int GetTSlice();
96     ///Reimplemented from vtkImageViewer2 to add polydata support
97     void SetSlice(int s);
98     int GetTMax() {
99         return mImage->GetVTKImages().size() - 1;
100     }
101
102     void SetOpacity(double s);
103     void SetRenderWindow(int orientation, vtkRenderWindow * rw);
104     void SetDisplayMode(bool i);
105     void FlipHorizontalView();
106     void FlipVerticalView();
107     void Render();
108     ///Sets the camera to fit the image in the window
109     void ResetCamera();
110
111     void SetVFSubSampling(int sub);
112     int GetVFSubSampling() {
113         return mSubSampling;
114     }
115     void SetVFScale(int scale);
116     void SetVFWidth(int width);
117     int GetVFScale() {
118         return mScale;
119     }
120     void SetVFLog(int log);
121     int GetVFLog() {
122         return mVFLog;
123     }
124
125     void SetFileName(std::string filename) {
126         mFileName = filename;
127     }
128     std::string GetFileName() {
129         return mFileName;
130     }
131
132     double* GetCursorPosition() {
133         return mCursor;
134     }
135
136     void SetCurrentPosition(double x, double y, double z, int t);
137     double* GetCurrentPosition() {
138         return mCurrent;
139     }
140
141     void UpdateCursorPosition();
142     void SetCursorVisibility(bool s);
143     bool GetCursorVisibility();
144     void SetCursorColor(int r,int g, int b);
145
146     void GetExtremasAroundMousePointer(double & min, double & max);
147
148     void UpdateLandmarks();
149     void ForceUpdateDisplayExtent();
150
151     int* GetDisplayExtent();
152     /**Add a polydata to be displayed as a contour over the image
153     ** the contour can be propagated to a time sequence using a motion field */
154     void AddContour(vvMesh::Pointer contours,bool propagate);
155     ///Toggle temporal superposition of contours
156     void ToggleContourSuperposition();
157
158     virtual void SetColorWindow(double s);
159     virtual void SetColorLevel(double s);
160
161     
162     void EnableReducedExtent(bool b);
163     void SetReducedExtent(int * ext);
164
165     void ClipDisplayedExtent(int extent[6], int refExtent[6]);
166     int GetOrientation();
167     int * GetExtent();
168
169 protected:
170     vvSlicer();
171     ~vvSlicer();
172
173     std::string mFileName;
174     vvImage::Pointer mImage;
175     vvImage::Pointer mOverlay;
176     vvImage::Pointer mFusion;
177     vvImage::Pointer mVF;
178
179     vvLandmarks* mLandmarks;
180
181     vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
182     vtkSmartPointer<vtkImageActor> mOverlayActor;
183     vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
184     vtkSmartPointer<vtkImageActor> mFusionActor;
185     vtkSmartPointer<vtkCornerAnnotation> ca;
186     vtkSmartPointer<vtkCursor2D> crossCursor;
187     vtkSmartPointer<vtkPolyDataMapper2D> pdm;
188     vtkSmartPointer<vtkActor2D> pdmA;
189     vtkSmartPointer<vvGlyphSource> mArrow;
190     vtkSmartPointer<vtkAssignAttribute> mAAFilter;
191     vtkSmartPointer<vtkExtractVOI> mVOIFilter;
192     vtkSmartPointer<vvGlyph2D> mGlyphFilter;
193     vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
194     vtkSmartPointer<vtkActor> mVFActor;
195     vtkSmartPointer<vtkGlyph3D> mLandGlyph;
196     vtkSmartPointer<vtkCursor3D> mCross;
197     vtkSmartPointer<vtkClipPolyData> mLandClipper;
198     vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
199     vtkSmartPointer<vtkActor> mLandActor;
200     vtkSmartPointer<vtkBox> mClipBox;
201     vtkSmartPointer<vtkScalarBarActor> legend;
202     std::vector<vvMeshActor*> mSurfaceCutActors;
203
204     int mCurrentTSlice;
205     double mCurrent[3];
206     double mCursor[4];
207     int mSubSampling;
208     int mScale;
209     int mVFLog;
210     int mVFWidth;
211     bool mUseReducedExtent;
212     int * mReducedExtent;
213     int * mInitialExtent;
214
215 private:
216     void UpdateOrientation();
217     void UpdateDisplayExtent();
218     void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
219     void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
220     void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
221     ///Sets the surfaces to be cut on the image slice: update the vtkCutter
222     void SetContourSlice();
223
224
225 };
226 #endif