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 typedef enum {WORLD_SLICING, VOXELS_SLICING} SlicingPresetType;
56 vvSlicerManager(int numberOfSlicers);
59 std::string GetLastError() {
63 bool SetImage(std::string filename, vvImageReader::LoadedImageType type, int n=0, unsigned int slice=0);
64 void SetImage(vvImage::Pointer image);
65 bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0);
67 bool SetOverlay(std::string filename, int dim, std::string component);
68 bool SetFusion(std::string filename, int dim, std::string component);
69 ///Set a VF by loading it from the disk
70 bool SetVF(std::string filename);
71 ///Set a VF from memory
72 bool SetVF(vvImage::Pointer vf,std::string filename);
73 ///Add a mesh to the slicers, with optional propagation using a vector field
74 void AddContour(vvMesh::Pointer ,bool propagate=false);
75 ///Toggle temporal superposition of contours
76 void ToggleContourSuperposition();
78 std::string GetFileName() { return mFileName; }
79 std::string GetBaseFileName() { return mBaseFileName; }
80 int GetBaseFileNameNumber() { return mBaseFileNameNumber; }
81 std::string GetVFName() { return mVFName; }
82 std::string GetOverlayName() { return mOverlayName; }
83 std::string GetFusionName() { return mFusionName; }
84 std::string GetListOfAbsoluteFilePathInOneString(const std::string &actorType);
86 ///Switch between nearest neighbor and linear interpolation
87 void ToggleInterpolation();
88 vvSlicer* GetSlicer(int i);
89 void UpdateSlicer(int num, bool state);
90 void SetSlicerWindow(int i, vtkRenderWindow* RW);
91 void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
93 int GetNumberOfSlicers() { return mSlicers.size(); }
94 vvImage::Pointer GetImage() { return mImage; }
95 vvImage::Pointer GetVF() { return mVF; }
96 int GetType() { return mType; }
97 void SetId(std::string id) { mId = id; }
98 std::string GetId() { return mId; }
100 if (mImage) return mImage->GetNumberOfDimensions();
104 void SetFilename(std::string f, int number=0);
106 void SetSliceOrientation(int slicer, int orientation);
108 void SetTSlice(int slice);
109 void SetNextTSlice(int originating_slicer);
110 void SetPreviousTSlice(int originating_slicer);
111 void SetTSliceInSlicer(int tslice, int slicer);
113 void GenerateDefaultLookupTable();
114 void SetColorWindow(double s);
115 void SetColorLevel(double s);
116 void SetOverlayColorWindow(double s);
117 void SetOverlayColorLevel(double s);
118 void SetLinkOverlayWindowLevel(bool b);
119 void SetLocalColorWindowing(const int slicer, const bool bCtrlKey);
120 void SetOpacity(int i, double factor);
121 void SetColorMap(int colormap);
122 void SetPreset(int preset);
123 void SetOverlayColor(int color) {
124 mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
126 void SetFusionOpacity(int opacity) {
127 mFusionOpacity = opacity;
129 void SetFusionThresholdOpacity(int thresOpacity) {
130 mFusionThresOpacity = thresOpacity;
132 void SetFusionColorMap(int colorMap) {
133 mFusionColorMap = colorMap;
135 void SetFusionWindow(double window) {
136 mFusionWindow = window;
138 void SetFusionLevel(double level) {
139 mFusionLevel = level;
141 void SetFusionShowLegend(int show) {
142 mFusionShowLegend = show;
145 double GetColorWindow();
146 double GetColorLevel();
147 double GetOverlayColorWindow() const;
148 double GetOverlayColorLevel() const;
149 bool GetLinkOverlayWindowLevel() const;
156 SlicingPresetType GetSlicingPreset() {
157 return mSlicingPreset;
159 int GetOverlayColor() const {
160 return mOverlayColor;
162 int GetFusionOpacity() const {
163 return mFusionOpacity;
165 int GetFusionThresholdOpacity() const {
166 return mFusionThresOpacity;
168 int GetFusionColorMap() const {
169 return mFusionColorMap;
171 double GetFusionWindow() const {
172 return mFusionWindow;
174 double GetFusionLevel() const {
178 void SetCursorAndCornerAnnotationVisibility(int s);
179 void UpdateViews(int current, int slicer);
180 void UpdateLinked(int slicer);
181 void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
182 void ResetTransformationToIdentity(const std::string actorType);
185 void AddLink(std::string newId) {
186 mLinkedId.push_back(newId);
188 void RemoveLink(std::string oldId) {
189 mLinkedId.remove(oldId);
193 return mLinkedId.size() > 0;
196 ///Remove the actor defined by its type and index (example: 3rd contour)
197 void RemoveActor(const std::string& actor_type, int overlay_index);
200 void ReloadOverlay();
206 void UpdateInfoOnCursorPosition(int slicer);
207 void UpdateWindowLevel();
208 void UpdateSlice(int slicer);
209 void UpdateTSlice(int slicer);
210 void UpdateSliceRange(int slicer);
211 void SetSlicingPreset(SlicingPresetType preset);
213 vvLandmarks *GetLandmarks();
214 void AddLandmark(float x,float y,float z,float t);
216 void NextImage(int slicer);
217 void PrevImage(int slicer);
218 void LeftButtonReleaseEvent(int slicer);
219 void VerticalSliderHasChanged(int slicer, int slice);
220 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
223 void currentImageChanged(std::string id);
224 void currentPickedImageChanged(std::string id);
225 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
226 void UpdateVector(int display, double x, double y, double z, double value);
227 void UpdateOverlay(int display, double valueOver, double valueRef);
228 void UpdateFusion(int display, double valueFus);
229 void UpdateOrientation(int slicer, int orientation);
230 void UpdateSlice(int slicer, int slice);
231 void UpdateTSlice(int slicer, int slice);
232 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
233 void WindowLevelChanged();
234 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
235 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
236 void LandmarkAdded();
237 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
238 void LeftButtonReleaseSignal(int slicer);
239 void AVerticalSliderHasChanged(int slicer, int slice);
242 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
243 vvImageReader::Pointer mReader;
244 vvImageReader::Pointer mOverlayReader;
245 vvImageReader::Pointer mFusionReader;
246 vvImageReader::Pointer mVectorReader;
247 vvImage::Pointer mImage;
248 vvImage::Pointer mVF;
253 int mFusionThresOpacity;
255 double mFusionWindow;
257 bool mFusionShowLegend;
260 SlicingPresetType mSlicingPreset;
261 vvImageReader::LoadedImageType mType;
262 std::string mVFComponent;
263 std::string mOverlayComponent;
264 std::string mFusionComponent;
265 std::string mFileName;
266 std::string mBaseFileName;
267 int mBaseFileNameNumber;
270 std::string mOverlayName;
271 std::string mFusionName;
273 std::string mLastError;
274 std::list<std::string> mLinkedId;
276 vvLandmarks* mLandmarks;
278 std::vector<int> mPreviousSlice;
279 std::vector<int> mPreviousTSlice;