]> Creatis software - clitk.git/blob - vv/vvSlicer.h
added the new headers
[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
50
51 class vvSlicer: public vtkImageViewer2
52 {
53 public:
54     static vvSlicer *New();
55     vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
56     void PrintSelf(ostream& os, vtkIndent indent);
57
58     void SetImage(vvImage::Pointer inputImages);
59     vvImage::Pointer GetImage() {
60         return mImage;
61     }
62
63     void SetOverlay(vvImage::Pointer inputOverlay);
64     vvImage::Pointer GetOverlay() {
65         return mOverlay;
66     }
67
68     vtkImageMapToWindowLevelColors* GetOverlayMapper(); 
69     vtkImageActor* GetOverlayActor() ;
70     vtkImageMapToWindowLevelColors* GetFusionMapper() ;
71     vtkImageActor* GetFusionActor() ;
72     vtkActor* GetVFActor() ;
73     vtkCornerAnnotation* GetAnnotation() ;
74
75     void SetFusion(vvImage::Pointer inputFusion);
76     vvImage::Pointer GetFusion() {
77         return mFusion;
78     }
79
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);
85
86     void SetVF(vvImage::Pointer vf);
87     vvImage *GetVF() {
88         return mVF;
89     }
90
91     void SetLandmarks(vvLandmarks* landmarks);
92     void SetTSlice(int t);
93     void SetSliceOrientation(int orientation);
94     int GetTSlice();
95     ///Reimplemented from vtkImageViewer2 to add polydata support
96     void SetSlice(int s);
97     int GetTMax() {
98         return mImage->GetVTKImages().size() - 1;
99     }
100
101     void SetOpacity(double s);
102     void SetRenderWindow(int orientation, vtkRenderWindow * rw);
103     void SetDisplayMode(bool i);
104     void FlipHorizontalView();
105     void FlipVerticalView();
106     void Render();
107     ///Sets the camera to fit the image in the window
108     void ResetCamera();
109
110     void SetVFSubSampling(int sub);
111     int GetVFSubSampling() {
112         return mSubSampling;
113     }
114     void SetVFScale(int scale);
115     int GetVFScale() {
116         return mScale;
117     }
118     void SetVFLog(int log);
119     int GetVFLog() {
120         return mVFLog;
121     }
122
123     void SetFileName(std::string filename) {
124         mFileName = filename;
125     }
126     std::string GetFileName() {
127         return mFileName;
128     }
129
130     double* GetCursorPosition() {
131         return mCursor;
132     }
133
134     void SetCurrentPosition(double x, double y, double z, int t);
135     double* GetCurrentPosition() {
136         return mCurrent;
137     }
138
139     void UpdateCursorPosition();
140     void SetCursorVisibility(bool s);
141     bool GetCursorVisibility();
142     void SetCursorColor(int r,int g, int b);
143
144     void GetExtremasAroundMousePointer(double & min, double & max);
145
146     void UpdateLandmarks();
147     void ForceUpdateDisplayExtent();
148
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();
155
156     virtual void SetColorWindow(double s);
157     virtual void SetColorLevel(double s);
158
159     
160     void EnableReducedExtent(bool b);
161     void SetReducedExtent(int * ext);
162
163 protected:
164     vvSlicer();
165     ~vvSlicer();
166
167     std::string mFileName;
168     vvImage::Pointer mImage;
169     vvImage::Pointer mOverlay;
170     vvImage::Pointer mFusion;
171     vvImage::Pointer mVF;
172
173     vvLandmarks* mLandmarks;
174
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;
196
197     std::vector<vvMeshActor*> mSurfaceCutActors;
198
199     int mCurrentTSlice;
200     double mCurrent[3];
201     double mCursor[4];
202     int mSubSampling;
203     int mScale;
204     int mVFLog;
205     bool mUseReducedExtent;
206     int * mReducedExtent;
207     int * mInitialExtent;
208
209 private:
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();
218
219
220 };
221 #endif