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;
55 class vtkAssignAttribute;
56 class vtkScalarBarActor;
59 class vvSlicer: public vtkImageViewer2
62 static vvSlicer *New();
63 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
64 void PrintSelf(ostream& os, vtkIndent indent);
66 void SetImage(vvImage::Pointer inputImages);
67 vvImage::Pointer GetImage() {
71 void SetOverlay(vvImage::Pointer inputOverlay);
72 vvImage::Pointer GetOverlay() {
76 vtkImageMapToWindowLevelColors* GetOverlayMapper();
77 vtkImageActor* GetOverlayActor() ;
78 vtkImageMapToWindowLevelColors* GetFusionMapper() ;
79 vtkImageActor* GetFusionActor() ;
80 vtkActor* GetVFActor() ;
81 vtkCornerAnnotation* GetAnnotation() ;
83 void SetFusion(vvImage::Pointer inputFusion);
84 vvImage::Pointer GetFusion() {
88 /**Set an actor's visibility ("overlay, fusion, vf, contour...")
89 Overlay index is the index of the overlay by type, eg. if there are
90 5 contours and we want to activate the 3rd one, pass 2 **/
91 void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
92 void RemoveActor(const std::string& actor_type, int overlay_index);
94 void SetVF(vvImage::Pointer vf);
99 void SetLandmarks(vvLandmarks* landmarks);
100 void SetTSlice(int t);
101 void SetSliceOrientation(int orientation);
103 ///Reimplemented from vtkImageViewer2 to add polydata support
104 void SetSlice(int s);
106 return mImage->GetVTKImages().size() - 1;
109 void SetOpacity(double s);
110 void SetRenderWindow(int orientation, vtkRenderWindow * rw);
111 void SetDisplayMode(bool i);
112 void FlipHorizontalView();
113 void FlipVerticalView();
115 ///Sets the camera to fit the image in the window
118 void SetVFSubSampling(int sub);
119 int GetVFSubSampling() {
122 void SetVFScale(int scale);
126 void SetVFLog(int log);
131 void SetFileName(std::string filename) {
132 mFileName = filename;
134 std::string GetFileName() {
138 double* GetCursorPosition() {
142 void SetCurrentPosition(double x, double y, double z, int t);
143 double* GetCurrentPosition() {
147 void UpdateCursorPosition();
148 void SetCursorVisibility(bool s);
149 bool GetCursorVisibility();
150 void SetCursorColor(int r,int g, int b);
152 void UpdateLandmarks();
153 void ForceUpdateDisplayExtent();
155 int* GetDisplayExtent();
156 /**Add a polydata to be displayed as a contour over the image
157 ** the contour can be propagated to a time sequence using a motion field */
158 void AddContour(vvMesh::Pointer contours,bool propagate);
159 ///Toggle temporal superposition of contours
160 void ToggleContourSuperposition();
162 virtual void SetColorWindow(double s);
163 virtual void SetColorLevel(double s);
165 void EnableReducedExtent(bool b);
166 void SetReducedExtent(int * ext);
172 std::string mFileName;
173 vvImage::Pointer mImage;
174 vvImage::Pointer mOverlay;
175 vvImage::Pointer mFusion;
176 vvImage::Pointer mVF;
178 vvLandmarks* mLandmarks;
180 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
181 vtkSmartPointer<vtkImageActor> mOverlayActor;
182 vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
183 vtkSmartPointer<vtkImageActor> mFusionActor;
184 vtkSmartPointer<vtkCornerAnnotation> ca;
185 vtkSmartPointer<vtkCursor2D> crossCursor;
186 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
187 vtkSmartPointer<vtkActor2D> pdmA;
188 vtkSmartPointer<vvGlyphSource> mArrow;
189 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
190 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
191 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
192 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
193 vtkSmartPointer<vtkActor> mVFActor;
194 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
195 vtkSmartPointer<vtkCursor3D> mCross;
196 vtkSmartPointer<vtkClipPolyData> mLandClipper;
197 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
198 vtkSmartPointer<vtkActor> mLandActor;
199 vtkSmartPointer<vtkBox> mClipBox;
200 vtkSmartPointer<vtkPlane> mSlicePlane;
201 vtkSmartPointer<vtkScalarBarActor> legend;
203 std::vector<vvMeshActor*> mSurfaceCutActors;
211 bool mUseReducedExtent;
212 int * mReducedExtent;
215 void UpdateOrientation();
216 void UpdateDisplayExtent();
217 void ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int extent[6]);
218 void ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
219 void ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]);
220 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
221 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
222 void SetContourSlice();