1 /*=========================================================================
4 Module: $RCSfile: vvSlicer.h,v $
6 Date: $Date: 2010/01/06 13:31:57 $
7 Version: $Revision: 1.1 $
8 Author : Pierre Seroul (pierre.seroul@gmail.com)
11 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12 CREATIS-LRMN http://www.creatis.insa-lyon.fr
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.
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.
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/>.
26 =========================================================================*/
33 #include "vvLandmarks.h"
35 #include "vtkImageViewer2.h"
37 #include <vvMeshActor.h>
38 #include <vtkSmartPointer.h>
43 class vtkPolyDataMapper2D;
45 class vtkClipPolyData;
48 class vtkCornerAnnotation;
50 class vtkPolyDataMapper2D;
51 class vtkPolyDataMapper;
58 class vtkAssignAttribute;
59 class vtkScalarBarActor;
62 class vvSlicer: public vtkImageViewer2
65 static vvSlicer *New();
66 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
67 void PrintSelf(ostream& os, vtkIndent indent);
69 void SetImage(vvImage::Pointer inputImages);
70 vvImage::Pointer GetImage() {
74 void SetOverlay(vvImage::Pointer inputOverlay);
75 vvImage::Pointer GetOverlay() {
79 vtkImageMapToWindowLevelColors* GetOverlayMapper();
80 vtkImageActor* GetOverlayActor() ;
81 vtkImageMapToWindowLevelColors* GetFusionMapper() ;
82 vtkImageActor* GetFusionActor() ;
83 vtkActor* GetVFActor() ;
84 vtkCornerAnnotation* GetAnnotation() ;
86 void SetFusion(vvImage::Pointer inputFusion);
87 vvImage::Pointer GetFusion() {
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);
97 void SetVF(vvImage::Pointer vf);
102 void SetLandmarks(vvLandmarks* landmarks);
103 void SetTSlice(int t);
104 void SetSliceOrientation(int orientation);
106 ///Reimplemented from vtkImageViewer2 to add polydata support
107 void SetSlice(int s);
109 return mImage->GetVTKImages().size() - 1;
112 void SetOpacity(double s);
113 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
114 void SetDisplayMode(bool i);
115 void FlipHorizontalView();
116 void FlipVerticalView();
118 ///Sets the camera to fit the image in the window
121 void SetVFSubSampling(int sub);
122 int GetVFSubSampling() {
125 void SetVFScale(int scale);
129 void SetVFLog(int log);
134 void SetFileName(std::string filename) {
135 mFileName = filename;
137 std::string GetFileName() {
141 double* GetCursorPosition() {
145 void SetCurrentPosition(double x, double y, double z, int t);
146 double* GetCurrentPosition() {
150 void UpdateCursorPosition();
151 void SetCursorVisibility(bool s);
152 bool GetCursorVisibility();
153 void SetCursorColor(int r,int g, int b);
155 void UpdateLandmarks();
156 void ForceUpdateDisplayExtent();
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();
169 std::string mFileName;
170 vvImage::Pointer mImage;
171 vvImage::Pointer mOverlay;
172 vvImage::Pointer mFusion;
173 vvImage::Pointer mVF;
175 vvLandmarks* mLandmarks;
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;
200 std::vector<vvMeshActor*> mSurfaceCutActors;
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();