]> Creatis software - clitk.git/blob - vv/vvSlicer.h
Command line options --window --level. Both are required to be accounted for.
[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 vvBlendImageActor;
38 class vtkBox;
39 class vtkCornerAnnotation;
40 class vtkExtractVOI;
41 class vtkPolyDataMapper2D;
42 class vtkPolyDataMapper;
43 class vtkGlyph3D;
44 class vvGlyph2D;
45 class vvGlyphSource;
46 class vtkCursor3D;
47 class vtkCutter;
48 class vtkAssignAttribute;
49 class vtkScalarBarActor;
50 class vtkTransform;
51 class vtkImageReslice;
52
53 class vvSlicer: public vtkImageViewer2
54 {
55 public:
56     static vvSlicer *New();
57     vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
58     void PrintSelf(ostream& os, vtkIndent indent);
59
60     void SetImage(vvImage::Pointer inputImages);
61     vvImage::Pointer GetImage() {
62         return mImage;
63     }
64
65     void SetOverlay(vvImage::Pointer inputOverlay);
66     vvImage::Pointer GetOverlay() {
67         return mOverlay;
68     }
69
70     vtkImageMapToWindowLevelColors* GetOverlayMapper(); 
71     vvBlendImageActor* GetOverlayActor() ;
72     vtkImageMapToWindowLevelColors* GetFusionMapper() ;
73     vtkImageActor* GetFusionActor() ;
74     vtkActor* GetVFActor() ;
75     vtkCornerAnnotation* GetAnnotation();
76     
77     void SetFusion(vvImage::Pointer inputFusion);
78     vvImage::Pointer GetFusion() {
79         return mFusion;
80     }
81
82     /**Set an actor's visibility ("overlay, fusion, vf, contour...")
83        Overlay index is the index of the overlay by type, eg. if there are
84        5 contours and we want to activate the 3rd one, pass 2 **/
85     void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
86     void RemoveActor(const std::string& actor_type, int overlay_index);
87
88     void SetVF(vvImage::Pointer vf);
89     vvImage *GetVF() {
90         return mVF;
91     }
92
93     void SetLandmarks(vvLandmarks* landmarks);
94     void SetTSlice(int t);
95     void SetSliceOrientation(int orientation);
96     int GetTSlice();
97     ///Reimplemented from vtkImageViewer2 to add polydata support
98     void SetSlice(int s);
99     int GetTMax() {
100         return (unsigned int)mImage->GetVTKImages().size() - 1;
101     }
102
103     void SetOpacity(double s);
104     void SetRenderWindow(int orientation, vtkRenderWindow * rw);
105     void SetDisplayMode(bool i);
106     void FlipHorizontalView();
107     void FlipVerticalView();
108     void Render();
109     ///Sets the camera to fit the image in the window
110     void ResetCamera();
111
112     void SetVFSubSampling(int sub);
113     int GetVFSubSampling() {
114         return mSubSampling;
115     }
116     void SetVFScale(int scale);
117     void SetVFWidth(int width);
118     int GetVFScale() {
119         return mScale;
120     }
121     void SetVFLog(int log);
122     int GetVFLog() {
123         return mVFLog;
124     }
125
126     void SetFileName(std::string filename) {
127         mFileName = filename;
128     }
129     std::string GetFileName() {
130         return mFileName;
131     }
132
133     double* GetCursorPosition() {
134         return mCursor;
135     }
136
137     void SetCurrentPosition(double x, double y, double z, int t);
138     double* GetCurrentPosition() {
139         return mCurrent;
140     }
141
142     void UpdateCursorPosition();
143     void SetCursorVisibility(bool s);
144     bool GetCursorVisibility();
145     void SetCursorColor(int r,int g, int b);
146
147     void GetExtremasAroundMousePointer(double & min, double & max);
148
149     void UpdateLandmarks();
150     void ForceUpdateDisplayExtent();
151
152     int* GetDisplayExtent();
153     /**Add a polydata to be displayed as a contour over the image
154     ** the contour can be propagated to a time sequence using a motion field */
155     void AddContour(vvMesh::Pointer contours,bool propagate);
156     ///Toggle temporal superposition of contours
157     void ToggleContourSuperposition();
158
159     virtual void SetColorWindow(double s);
160     virtual void SetColorLevel(double s);
161
162     
163     void EnableReducedExtent(bool b);
164     void SetReducedExtent(int * ext);
165
166     void ClipDisplayedExtent(int extent[6], int refExtent[6]);
167     int GetOrientation();
168     int * GetExtent();
169
170 protected:
171     vvSlicer();
172     ~vvSlicer();
173
174     std::string mFileName;
175     vvImage::Pointer mImage;
176     vvImage::Pointer mOverlay;
177     vvImage::Pointer mFusion;
178     vvImage::Pointer mVF;
179
180     vvLandmarks* mLandmarks;
181
182     vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
183     vtkSmartPointer<vvBlendImageActor> mOverlayActor;
184     vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
185     vtkSmartPointer<vtkImageActor> mFusionActor;
186     vtkSmartPointer<vtkCornerAnnotation> ca;
187     vtkSmartPointer<vtkCursor2D> crossCursor;
188     vtkSmartPointer<vtkPolyDataMapper2D> pdm;
189     vtkSmartPointer<vtkActor2D> pdmA;
190     vtkSmartPointer<vvGlyphSource> mArrow;
191     vtkSmartPointer<vtkAssignAttribute> mAAFilter;
192     vtkSmartPointer<vtkExtractVOI> mVOIFilter;
193     vtkSmartPointer<vvGlyph2D> mGlyphFilter;
194     vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
195     vtkSmartPointer<vtkActor> mVFActor;
196     vtkSmartPointer<vtkGlyph3D> mLandGlyph;
197     vtkSmartPointer<vtkCursor3D> mCross;
198     vtkSmartPointer<vtkClipPolyData> mLandClipper;
199     vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
200     vtkSmartPointer<vtkActor> mLandActor;
201     vtkSmartPointer<vtkBox> mClipBox;
202     vtkSmartPointer<vtkScalarBarActor> legend;
203     std::vector<vvMeshActor*> mSurfaceCutActors;
204
205     int mCurrentTSlice;
206     double mCurrent[3];
207     double mCursor[4];
208     int mSubSampling;
209     int mScale;
210     int mVFLog;
211     int mVFWidth;
212     bool mUseReducedExtent;
213     int * mReducedExtent;
214     int * mInitialExtent;
215
216 private:
217     void UpdateOrientation();
218     void UpdateDisplayExtent();
219     void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
220     void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
221     void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
222     ///Sets the surfaces to be cut on the image slice: update the vtkCutter
223     void SetContourSlice();
224
225
226 };
227 #endif