1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
23 #include "vvLandmarks.h"
26 #include "vvMeshActor.h"
28 #include <vtkSmartPointer.h>
29 #include <vtkImageViewer2.h>
30 #include <vtkImageReslice.h>
31 #include <vtkImageMapToColors.h>
36 class vtkPolyDataMapper2D;
38 class vtkClipPolyData;
40 class vvBlendImageActor;
42 class vtkCornerAnnotation;
44 class vtkPolyDataMapper2D;
45 class vtkPolyDataMapper;
51 class vtkAssignAttribute;
52 class vtkScalarBarActor;
54 class vtkImageReslice;
56 class vvSlicer: public vtkImageViewer2
59 static vvSlicer *New();
60 vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
61 void PrintSelf(ostream& os, vtkIndent indent);
63 void SetImage(vvImage::Pointer inputImages);
64 vvImage::Pointer GetImage() {
68 void SetOverlay(vvImage::Pointer inputOverlay);
69 vvImage::Pointer GetOverlay() {
72 vtkImageMapToWindowLevelColors* GetOverlayMapper();
73 vvBlendImageActor* GetOverlayActor() ;
74 vtkImageMapToColors* GetFusionMapper() ;
75 vtkImageActor* GetFusionActor() ;
76 vtkActor* GetVFActor() ;
77 vtkCornerAnnotation* GetAnnotation();
79 void SetFusion(vvImage::Pointer inputFusion);
80 vvImage::Pointer GetFusion() {
83 void ShowFusionLegend(bool show) { showFusionLegend = show; }
85 /**Get/Set an actor's visibility ("overlay, fusion, vf, contour...")
86 Overlay index is the index of the overlay by type, eg. if there are
87 5 contours and we want to activate the 3rd one, pass 2 **/
88 bool GetActorVisibility(const std::string& actor_type, int overlay_index);
89 void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
90 void RemoveActor(const std::string& actor_type, int overlay_index);
92 void SetVF(vvImage::Pointer vf);
97 void SetLandmarks(vvLandmarks* landmarks);
98 void SetTSlice(int t);
99 void SetSliceOrientation(int orientation);
100 void AdjustResliceToSliceOrientation(vtkImageReslice *reslice);
102 ///Reimplemented from vtkImageViewer2 to add polydata support
103 void SetSlice(int s);
105 return (unsigned int)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();
113 static double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component=0);
115 ///Sets the camera to fit the image in the window
118 void SetVFSubSampling(int sub);
119 int GetVFSubSampling() {
122 void SetVFScale(int scale);
123 void SetVFWidth(int width);
127 void SetVFLog(int log);
132 void SetFileName(std::string filename) {
133 mFileName = filename;
135 std::string GetFileName() {
139 double* GetCursorPosition() {
143 void SetCurrentPosition(double x, double y, double z, int t);
144 double* GetCurrentPosition() {
148 void UpdateCursorPosition();
149 void SetCursorVisibility(bool s);
151 bool GetCursorVisibility();
152 void SetCursorColor(int r,int g, int b);
154 void SetCornerAnnotationVisibility(bool s);
155 bool GetCornerAnnotationVisibility();
157 void GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform);
159 void UpdateLandmarks();
160 void ForceUpdateDisplayExtent();
162 int* GetDisplayExtent();
163 /**Add a polydata to be displayed as a contour over the image
164 ** the contour can be propagated to a time sequence using a motion field */
165 void AddContour(vvMesh::Pointer contours,bool propagate);
166 ///Toggle temporal superposition of contours
167 void ToggleContourSuperposition();
169 virtual void SetColorWindow(double s);
170 virtual void SetColorLevel(double s);
172 double GetOverlayColorWindow();
173 double GetOverlayColorLevel();
174 bool GetLinkOverlayWindowLevel() { return mLinkOverlayWindowLevel; }
176 void SetOverlayColorWindow(double s);
177 void SetOverlayColorLevel(double s);
178 void SetLinkOverlayWindowLevel(bool b) { mLinkOverlayWindowLevel = b; }
181 * When it is enabled, beware of a call to GetExtent.
182 * we must have setted mReducedExtent otherwhise random values
183 * are returned by GetExtent
185 void EnableReducedExtent(bool b);
186 void SetReducedExtent(int * ext);
188 void ClipDisplayedExtent(int extent[6], int refExtent[6]);
189 int GetOrientation();
192 double* GetVFColor() {
195 void SetVFColor(double r, double g, double b);
201 std::string mFileName;
202 vvImage::Pointer mImage;
203 vvImage::Pointer mOverlay;
204 vvImage::Pointer mFusion;
205 vvImage::Pointer mVF;
207 vvLandmarks* mLandmarks;
209 vtkSmartPointer<vtkImageReslice> mImageReslice;
210 vtkSmartPointer<vtkImageReslice> mOverlayReslice;
211 vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
212 vtkSmartPointer<vvBlendImageActor> mOverlayActor;
213 vtkSmartPointer<vtkImageReslice> mFusionReslice;
214 vtkSmartPointer<vtkImageMapToColors> mFusionMapper;
215 vtkSmartPointer<vtkImageActor> mFusionActor;
216 vtkSmartPointer<vtkCornerAnnotation> ca;
217 vtkSmartPointer<vtkCursor2D> crossCursor;
218 vtkSmartPointer<vtkPolyDataMapper2D> pdm;
219 vtkSmartPointer<vtkActor2D> pdmA;
220 vtkSmartPointer<vvGlyphSource> mArrow;
221 vtkSmartPointer<vtkAssignAttribute> mAAFilter;
222 vtkSmartPointer<vtkExtractVOI> mVOIFilter;
223 vtkSmartPointer<vvGlyph2D> mGlyphFilter;
224 vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
225 vtkSmartPointer<vtkLookupTable> mVFColorLUT;
226 vtkSmartPointer<vtkActor> mVFActor;
227 vtkSmartPointer<vtkGlyph3D> mLandGlyph;
228 vtkSmartPointer<vtkCursor3D> mCross;
229 vtkSmartPointer<vtkClipPolyData> mLandClipper;
230 vtkSmartPointer<vtkPolyDataMapper> mLandMapper;
231 vtkSmartPointer<vtkActor> mLandActor;
232 vtkSmartPointer<vtkBox> mClipBox;
233 vtkSmartPointer<vtkScalarBarActor> legend;
234 std::vector<vvMeshActor*> mSurfaceCutActors;
244 bool mUseReducedExtent;
245 int * mReducedExtent;
246 int * mInitialExtent;
247 bool mLinkOverlayWindowLevel;
248 bool showFusionLegend;
251 void UpdateOrientation();
252 void UpdateDisplayExtent();
253 void ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
254 vtkImageData *targetImage, int targetExtent[6]);
255 ///Sets the surfaces to be cut on the image slice: update the vtkCutter
256 void SetContourSlice();