2 /*=========================================================================
3 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
6 - University of LYON http://www.universite-lyon.fr/
7 - Léon Bérard cancer center http://www.centreleonberard.fr
8 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the copyright notices for more information.
14 It is distributed under dual licence
16 - BSD See included LICENSE.txt file
17 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
18 ===========================================================================**/
20 #ifndef VVSLICERMANAGER_H
21 #define VVSLICERMANAGER_H
32 #include <vtksys/SystemTools.hxx>
34 class vtkInteractorStyle;
35 class vtkRenderWindow;
39 #include "clitkCommon.h"
42 #include "vvImageReader.h"
45 class vvInteractorStyleNavigator;
50 //------------------------------------------------------------------------------
51 class vvSlicerManager : public QObject {
55 vvSlicerManager(int numberOfSlicers);
58 std::string GetLastError() {
62 bool SetImage(std::string filename, vvImageReader::LoadedImageType type, int n=0, unsigned int slice=0);
63 void SetImage(vvImage::Pointer image);
64 bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0);
66 bool SetOverlay(std::string filename, int dim, std::string component);
67 bool SetFusion(std::string filename, int dim, std::string component);
68 ///Set a VF by loading it from the disk
69 bool SetVF(std::string filename);
70 ///Set a VF from memory
71 bool SetVF(vvImage::Pointer vf,std::string filename);
72 ///Add a mesh to the slicers, with optional propagation using a vector field
73 void AddContour(vvMesh::Pointer ,bool propagate=false);
74 ///Toggle temporal superposition of contours
75 void ToggleContourSuperposition();
77 std::string GetFileName() { return mFileName; }
78 std::string GetBaseFileName() { return mBaseFileName; }
79 int GetBaseFileNameNumber() { return mBaseFileNameNumber; }
80 std::string GetVFName() { return mVFName; }
81 std::string GetOverlayName() { return mOverlayName; }
82 std::string GetFusionName() { return mFusionName; }
84 ///Switch between nearest neighbor and linear interpolation
85 void ToggleInterpolation();
86 vvSlicer* GetSlicer(int i);
87 void UpdateSlicer(int num, bool state);
88 void SetSlicerWindow(int i, vtkRenderWindow* RW);
89 void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
91 int GetNumberOfSlicers() { return mSlicers.size(); }
92 vvImage::Pointer GetImage() { return mImage; }
93 vvImage::Pointer GetVF() { return mVF; }
94 int GetType() { return mType; }
95 void SetId(std::string id) { mId = id; }
96 std::string GetId() { return mId; }
98 if (mImage) return mImage->GetNumberOfDimensions();
102 void SetFilename(std::string f, int number=0);
104 void SetSliceOrientation(int slicer, int orientation);
105 void SetTSlice(int slice);
106 void SetNextTSlice(int originating_slicer);
107 void SetPreviousTSlice(int originating_slicer);
108 void SetTSliceInSlicer(int tslice, int slicer);
110 void GenerateDefaultLookupTable();
111 void SetColorWindow(double s);
112 void SetColorLevel(double s);
113 void SetLocalColorWindowing(const int slicer);
114 void SetOpacity(int i, double factor);
116 void SetColorMap(int colormap);
117 void SetPreset(int preset);
118 void SetOverlayColor(int color) {
119 mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
121 void SetFusionOpacity(int opacity) {
122 mFusionOpacity = opacity;
124 void SetFusionColorMap(int colorMap) {
125 mFusionColorMap = colorMap;
127 void SetFusionWindow(double window) {
128 mFusionWindow = window;
130 void SetFusionLevel(double level) {
131 mFusionLevel = level;
134 double GetColorWindow();
135 double GetColorLevel();
142 int GetOverlayColor() {
143 return mOverlayColor;
146 int GetFusionOpacity() {
147 return mFusionOpacity;
149 int GetFusionColorMap() {
150 return mFusionColorMap;
152 double GetFusionWindow() {
153 return mFusionWindow;
155 double GetFusionLevel() {
159 void SetCursorAndCornerAnnotationVisibility(int s);
160 void UpdateViews(int current, int slicer);
161 void UpdateLinked(int slicer);
162 void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
165 void AddLink(std::string newId) {
166 mLinkedId.push_back(newId);
168 void RemoveLink(std::string oldId) {
169 mLinkedId.remove(oldId);
173 return mLinkedId.size() > 0;
176 ///Remove the actor defined by its type and index (example: 3rd contour)
177 void RemoveActor(const std::string& actor_type, int overlay_index);
180 void ReloadOverlay();
186 void UpdateInfoOnCursorPosition(int slicer);
187 void UpdateWindowLevel();
188 void UpdateSlice(int slicer);
189 void UpdateTSlice(int slicer);
190 void UpdateSliceRange(int slicer);
192 vvLandmarks *GetLandmarks();
193 void AddLandmark(float x,float y,float z,float t);
195 void NextImage(int slicer);
196 void PrevImage(int slicer);
197 void LeftButtonReleaseEvent(int slicer);
198 void VerticalSliderHasChanged(int slicer, int slice);
199 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
202 void currentImageChanged(std::string id);
203 void currentPickedImageChanged(std::string id);
204 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
205 void UpdateVector(int display, double x, double y, double z, double value);
206 void UpdateOverlay(int display, double valueOver, double valueRef);
207 void UpdateFusion(int display, double valueFus);
208 void UpdateWindows(int slicer, int view, int slice);
209 void UpdateOrientation(int slicer, int orientation);
210 void UpdateSlice(int slicer, int slice);
211 void UpdateTSlice(int slicer, int slice);
212 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
213 void WindowLevelChanged(double window, double level, int preset, int colormap);
214 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
215 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
216 void LandmarkAdded();
217 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
218 void LeftButtonReleaseSignal(int slicer);
219 void AVerticalSliderHasChanged(int slicer, int slice);
222 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
223 vvImageReader::Pointer mReader;
224 vvImageReader::Pointer mOverlayReader;
225 vvImageReader::Pointer mFusionReader;
226 vvImageReader::Pointer mVectorReader;
227 vvImage::Pointer mImage;
228 vvImage::Pointer mVF;
234 double mFusionWindow;
238 vvImageReader::LoadedImageType mType;
239 std::string mVFComponent;
240 std::string mOverlayComponent;
241 std::string mFusionComponent;
242 std::string mFileName;
243 std::string mBaseFileName;
244 int mBaseFileNameNumber;
247 std::string mOverlayName;
248 std::string mFusionName;
250 std::string mLastError;
251 std::list<std::string> mLinkedId;
253 vvLandmarks* mLandmarks;
255 std::vector<int> mPreviousSlice;
256 std::vector<int> mPreviousTSlice;