1 /*=========================================================================
5 Author : Pierre Seroul (pierre.seroul@gmail.com)
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 =========================================================================*/
30 #include "vvLandmarks.h"
32 #include "vtkImageViewer2.h"
34 #include <vvMeshActor.h>
35 #include <vtkSmartPointer.h>
40 class vtkPolyDataMapper2D;
42 class vtkClipPolyData;
45 class vtkCornerAnnotation;
47 class vtkPolyDataMapper2D;
48 class vtkPolyDataMapper;
54 class vtkAssignAttribute;
55 class vtkScalarBarActor;
58 class vvSlicer: public vtkImageViewer2
61 static vvSlicer *New();
62 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
63 void PrintSelf(ostream& os, vtkIndent indent);
65 void SetImage(vvImage::Pointer inputImages);
66 vvImage::Pointer GetImage() {
70 void SetOverlay(vvImage::Pointer inputOverlay);
71 vvImage::Pointer GetOverlay() {
75 vtkImageMapToWindowLevelColors* GetOverlayMapper();
76 vtkImageActor* GetOverlayActor() ;
77 vtkImageMapToWindowLevelColors* GetFusionMapper() ;
78 vtkImageActor* GetFusionActor() ;
79 vtkActor* GetVFActor() ;
80 vtkCornerAnnotation* GetAnnotation() ;
82 void SetFusion(vvImage::Pointer inputFusion);
83 vvImage::Pointer GetFusion() {
87 /**Set an actor's visibility ("overlay, fusion, vf, contour...")
88 Overlay index is the index of the overlay by type, eg. if there are
89 5 contours and we want to activate the 3rd one, pass 2 **/
90 void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
91 void RemoveActor(const std::string& actor_type, int overlay_index);
93 void SetVF(vvImage::Pointer vf);
98 void SetLandmarks(vvLandmarks* landmarks);
99 void SetTSlice(int t);
100 void SetSliceOrientation(int orientation);
102 ///Reimplemented from vtkImageViewer2 to add polydata support
103 void SetSlice(int s);
105 return mImage->GetVTKImages().size() - 1;
108 void SetOpacity(double s);
109 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
110 void SetDisplayMode(bool i);
111 void FlipHorizontalView();
112 void FlipVerticalView();
114 ///Sets the camera to fit the image in the window
117 void SetVFSubSampling(int sub);
118 int GetVFSubSampling() {
121 void SetVFScale(int scale);
125 void SetVFLog(int log);
130 void SetFileName(std::string filename) {
131 mFileName = filename;
133 std::string GetFileName() {
137 double* GetCursorPosition() {
141 void SetCurrentPosition(double x, double y, double z, int t);
142 double* GetCurrentPosition() {
146 void UpdateCursorPosition();
147 void SetCursorVisibility(bool s);
148 bool GetCursorVisibility();
149 void SetCursorColor(int r,int g, int b);
151 void GetExtremasAroundMousePointer(double & min, double & max);
153 void UpdateLandmarks();
154 void ForceUpdateDisplayExtent();
156 int* GetDisplayExtent();
157 /**Add a polydata to be displayed as a contour over the image
158 ** the contour can be propagated to a time sequence using a motion field */
159 void AddContour(vvMesh::Pointer contours,bool propagate);
160 ///Toggle temporal superposition of contours
161 void ToggleContourSuperposition();
163 virtual void SetColorWindow(double s);
164 virtual void SetColorLevel(double s);
167 void EnableReducedExtent(bool b);
168 void SetReducedExtent(int * ext);
174 std::string mFileName;
175 vvImage::Pointer mImage;
176 vvImage::Pointer mOverlay;
177 vvImage::Pointer mFusion;
178 vvImage::Pointer mVF;
180 vvLandmarks* mLandmarks;
182 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
183 vtkSmartPointer<vtkImageActor> 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;
204 std::vector<vvMeshActor*> mSurfaceCutActors;
212 bool mUseReducedExtent;
213 int * mReducedExtent;
214 int * mInitialExtent;
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 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
223 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
224 void SetContourSlice();