]> Creatis software - clitk.git/blob - vv/vvSlicer.h
Initial revision
[clitk.git] / vv / vvSlicer.h
1 /*=========================================================================
2
3  Program:   vv
4  Module:    $RCSfile: vvSlicer.h,v $
5  Language:  C++
6  Date:      $Date: 2010/01/06 13:31:57 $
7  Version:   $Revision: 1.1 $
8  Author :   Pierre Seroul (pierre.seroul@gmail.com)
9
10 Copyright (C) 2008
11 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12 CREATIS-LRMN http://www.creatis.insa-lyon.fr
13
14 This program is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, version 3 of the License.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
26 =========================================================================*/
27 #ifndef __vvSlicer_h
28 #define __vvSlicer_h
29
30 #include <iostream>
31 #include <vector>
32
33 #include "vvLandmarks.h"
34 #include "vvImage.h"
35 #include "vtkImageViewer2.h"
36 #include "vvMesh.h"
37 #include <vvMeshActor.h>
38 #include <vtkSmartPointer.h>
39
40 class vtkActor;
41 class vtkActor2D;
42 class vtkCursor2D;
43 class vtkPolyDataMapper2D;
44 class vtkProperty2D;
45 class vtkClipPolyData;
46 class vtkImageActor;
47 class vtkBox;
48 class vtkCornerAnnotation;
49 class vtkExtractVOI;
50 class vtkPolyDataMapper2D;
51 class vtkPolyDataMapper;
52 class vtkGlyph3D;
53 class vvGlyph2D;
54 class vvGlyphSource;
55 class vtkCursor3D;
56 class vtkCutter;
57 class vtkPlane;
58 class vtkAssignAttribute;
59 class vtkScalarBarActor;
60
61
62 class vvSlicer: public vtkImageViewer2
63 {
64 public:
65     static vvSlicer *New();
66     vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
67     void PrintSelf(ostream& os, vtkIndent indent);
68
69     void SetImage(vvImage::Pointer inputImages);
70     vvImage::Pointer GetImage() {
71         return mImage;
72     }
73
74     void SetOverlay(vvImage::Pointer inputOverlay);
75     vvImage::Pointer GetOverlay() {
76         return mOverlay;
77     }
78
79     vtkImageMapToWindowLevelColors* GetOverlayMapper(); 
80     vtkImageActor* GetOverlayActor() ;
81     vtkImageMapToWindowLevelColors* GetFusionMapper() ;
82     vtkImageActor* GetFusionActor() ;
83     vtkActor* GetVFActor() ;
84     vtkCornerAnnotation* GetAnnotation() ;
85
86     void SetFusion(vvImage::Pointer inputFusion);
87     vvImage::Pointer GetFusion() {
88         return mFusion;
89     }
90
91     /**Set an actor's visibility ("overlay, fusion, vf, contour...")
92        Overlay index is the index of the overlay by type, eg. if there are
93        5 contours and we want to activate the 3rd one, pass 2 **/
94     void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
95     void RemoveActor(const std::string& actor_type, int overlay_index);
96
97     void SetVF(vvImage::Pointer vf);
98     vvImage *GetVF() {
99         return mVF;
100     }
101
102     void SetLandmarks(vvLandmarks* landmarks);
103     void SetTSlice(int t);
104     void SetSliceOrientation(int orientation);
105     int GetTSlice();
106     ///Reimplemented from vtkImageViewer2 to add polydata support
107     void SetSlice(int s);
108     int GetTMax() {
109         return mImage->GetVTKImages().size() - 1;
110     }
111
112     void SetOpacity(double s);
113     void SetRenderWindow(int orientation, vtkRenderWindow * rw);
114     void SetDisplayMode(bool i);
115     void FlipHorizontalView();
116     void FlipVerticalView();
117     void Render();
118     ///Sets the camera to fit the image in the window
119     void ResetCamera();
120
121     void SetVFSubSampling(int sub);
122     int GetVFSubSampling() {
123         return mSubSampling;
124     }
125     void SetVFScale(int scale);
126     int GetVFScale() {
127         return mScale;
128     }
129     void SetVFLog(int log);
130     int GetVFLog() {
131         return mVFLog;
132     }
133
134     void SetFileName(std::string filename) {
135         mFileName = filename;
136     }
137     std::string GetFileName() {
138         return mFileName;
139     }
140
141     double* GetCursorPosition() {
142         return mCursor;
143     }
144
145     void SetCurrentPosition(double x, double y, double z, int t);
146     double* GetCurrentPosition() {
147         return mCurrent;
148     }
149
150     void UpdateCursorPosition();
151     void SetCursorVisibility(bool s);
152     bool GetCursorVisibility();
153     void SetCursorColor(int r,int g, int b);
154
155     void UpdateLandmarks();
156     void ForceUpdateDisplayExtent();
157
158     int* GetDisplayExtent();
159     /**Add a polydata to be displayed as a contour over the image
160     ** the contour can be propagated to a time sequence using a motion field */
161     void AddContour(vvMesh::Pointer contours,bool propagate);
162     ///Toggle temporal superposition of contours
163     void ToggleContourSuperposition();
164
165 protected:
166     vvSlicer();
167     ~vvSlicer();
168
169     std::string mFileName;
170     vvImage::Pointer mImage;
171     vvImage::Pointer mOverlay;
172     vvImage::Pointer mFusion;
173     vvImage::Pointer mVF;
174
175     vvLandmarks* mLandmarks;
176
177     vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
178     vtkSmartPointer<vtkImageActor> mOverlayActor;
179     vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
180     vtkSmartPointer<vtkImageActor> mFusionActor;
181     vtkSmartPointer<vtkCornerAnnotation> ca;
182     vtkSmartPointer<vtkCursor2D> crossCursor;
183     vtkSmartPointer<vtkPolyDataMapper2D> pdm;
184     vtkSmartPointer<vtkActor2D> pdmA;
185     vtkSmartPointer<vvGlyphSource> mArrow;
186     vtkSmartPointer<vtkAssignAttribute> mAAFilter;
187     vtkSmartPointer<vtkExtractVOI> mVOIFilter;
188     vtkSmartPointer<vvGlyph2D> mGlyphFilter;
189     vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
190     vtkSmartPointer<vtkActor> mVFActor;
191     vtkSmartPointer<vtkGlyph3D> mLandGlyph;
192     vtkSmartPointer<vtkCursor3D> mCross;
193     vtkSmartPointer<vtkClipPolyData> mLandClipper;
194     vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
195     vtkSmartPointer<vtkActor> mLandActor;
196     vtkSmartPointer<vtkBox> mClipBox;
197     vtkSmartPointer<vtkPlane> mSlicePlane;
198     vtkSmartPointer<vtkScalarBarActor> legend;
199
200     std::vector<vvMeshActor*> mSurfaceCutActors;
201
202     int mCurrentTSlice;
203     double mCurrent[3];
204     double mCursor[4];
205     int mSubSampling;
206     int mScale;
207     int mVFLog;
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