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; }
83 std::string GetListOfAbsoluteFilePathInOneString(const std::string &actorType);
85 ///Switch between nearest neighbor and linear interpolation
86 void ToggleInterpolation();
87 vvSlicer* GetSlicer(int i);
88 void UpdateSlicer(int num, bool state);
89 void SetSlicerWindow(int i, vtkRenderWindow* RW);
90 void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
92 int GetNumberOfSlicers() { return mSlicers.size(); }
93 vvImage::Pointer GetImage() { return mImage; }
94 vvImage::Pointer GetVF() { return mVF; }
95 int GetType() { return mType; }
96 void SetId(std::string id) { mId = id; }
97 std::string GetId() { return mId; }
99 if (mImage) return mImage->GetNumberOfDimensions();
103 void SetFilename(std::string f, int number=0);
105 void SetSliceOrientation(int slicer, int orientation);
106 void SetTSlice(int slice);
107 void SetNextTSlice(int originating_slicer);
108 void SetPreviousTSlice(int originating_slicer);
109 void SetTSliceInSlicer(int tslice, int slicer);
111 void GenerateDefaultLookupTable();
112 void SetColorWindow(double s);
113 void SetColorLevel(double s);
114 void SetOverlayColorWindow(double s);
115 void SetOverlayColorLevel(double s);
116 void SetLinkOverlayWindowLevel(bool b);
117 void SetLocalColorWindowing(const int slicer, const bool bCtrlKey);
118 void SetOpacity(int i, double factor);
119 void SetColorMap(int colormap);
120 void SetPreset(int preset);
121 void SetOverlayColor(int color) {
122 mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
124 void SetFusionOpacity(int opacity) {
125 mFusionOpacity = opacity;
127 void SetFusionThresholdOpacity(int thresOpacity) {
128 mFusionThresOpacity = thresOpacity;
130 void SetFusionColorMap(int colorMap) {
131 mFusionColorMap = colorMap;
133 void SetFusionWindow(double window) {
134 mFusionWindow = window;
136 void SetFusionLevel(double level) {
137 mFusionLevel = level;
139 void SetFusionShowLegend(int show) {
140 mFusionShowLegend = show;
143 double GetColorWindow();
144 double GetColorLevel();
145 double GetOverlayColorWindow() const;
146 double GetOverlayColorLevel() const;
147 bool GetLinkOverlayWindowLevel() const;
154 int GetOverlayColor() const {
155 return mOverlayColor;
157 int GetFusionOpacity() const {
158 return mFusionOpacity;
160 int GetFusionThresholdOpacity() const {
161 return mFusionThresOpacity;
163 int GetFusionColorMap() const {
164 return mFusionColorMap;
166 double GetFusionWindow() const {
167 return mFusionWindow;
169 double GetFusionLevel() const {
173 void SetCursorAndCornerAnnotationVisibility(int s);
174 void UpdateViews(int current, int slicer);
175 void UpdateLinked(int slicer);
176 void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
177 void ResetTransformationToIdentity(const std::string actorType);
180 void AddLink(std::string newId) {
181 mLinkedId.push_back(newId);
183 void RemoveLink(std::string oldId) {
184 mLinkedId.remove(oldId);
188 return mLinkedId.size() > 0;
191 ///Remove the actor defined by its type and index (example: 3rd contour)
192 void RemoveActor(const std::string& actor_type, int overlay_index);
195 void ReloadOverlay();
201 void UpdateInfoOnCursorPosition(int slicer);
202 void EmitMousePositionUpdated(int slicer);
203 void EmitKeyPressed(std::string keyPress);
204 void UpdateWindowLevel();
205 void UpdateSlice(int slicer);
206 void UpdateTSlice(int slicer);
207 void UpdateSliceRange(int slicer);
209 vvLandmarks *GetLandmarks();
210 void AddLandmark(float x,float y,float z,float t);
212 void NextImage(int slicer);
213 void PrevImage(int slicer);
214 void LeftButtonReleaseEvent(int slicer);
215 void VerticalSliderHasChanged(int slicer, int slice);
216 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
219 void currentImageChanged(std::string id);
220 void currentPickedImageChanged(std::string id);
221 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
222 void UpdateVector(int display, double x, double y, double z, double value);
223 void UpdateOverlay(int display, double valueOver, double valueRef);
224 void UpdateFusion(int display, double valueFus);
225 void MousePositionUpdatedSignal(int slicer);
226 void KeyPressedSignal(std::string KeyPressed);
227 void UpdateOrientation(int slicer, int orientation);
228 void UpdateSlice(int slicer, int slice);
229 void UpdateTSlice(int slicer, int slice);
230 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
231 void WindowLevelChanged();
232 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
233 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
234 void LandmarkAdded();
235 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
236 void LeftButtonReleaseSignal(int slicer);
237 void AVerticalSliderHasChanged(int slicer, int slice);
240 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
241 vvImageReader::Pointer mReader;
242 vvImageReader::Pointer mOverlayReader;
243 vvImageReader::Pointer mFusionReader;
244 vvImageReader::Pointer mVectorReader;
245 vvImage::Pointer mImage;
246 vvImage::Pointer mVF;
251 int mFusionThresOpacity;
253 double mFusionWindow;
255 bool mFusionShowLegend;
258 vvImageReader::LoadedImageType mType;
259 std::string mVFComponent;
260 std::string mOverlayComponent;
261 std::string mFusionComponent;
262 std::string mFileName;
263 std::string mBaseFileName;
264 int mBaseFileNameNumber;
267 std::string mOverlayName;
268 std::string mFusionName;
270 std::string mLastError;
271 std::list<std::string> mLinkedId;
273 vvLandmarks* mLandmarks;
275 std::vector<int> mPreviousSlice;
276 std::vector<int> mPreviousTSlice;