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::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
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 int GetSelectedSlicer() {
90 return mSelectedSlicer;
93 void UpdateSlicer(int num, bool state);
94 void SetSlicerWindow(int i, vtkRenderWindow* RW);
95 void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
97 int GetNumberOfSlicers() { return mSlicers.size(); }
98 vvImage::Pointer GetImage() { return mImage; }
99 vvImage::Pointer GetVF() { return mVF; }
100 int GetType() { return mType; }
101 void SetId(std::string id) { mId = id; }
102 std::string GetId() { return mId; }
104 if (mImage) return mImage->GetNumberOfDimensions();
108 void SetFilename(std::string f, int number=0);
110 void SetSliceOrientation(int slicer, int orientation);
112 void SetTSlice(int slice);
113 void SetNextTSlice(int originating_slicer);
114 void SetPreviousTSlice(int originating_slicer);
115 void SetTSliceInSlicer(int tslice, int slicer);
117 void GenerateDefaultLookupTable();
118 void SetColorWindow(double s);
119 void SetColorLevel(double s);
120 void SetOverlayColorWindow(double s);
121 void SetOverlayColorLevel(double s);
122 void SetLinkOverlayWindowLevel(bool b);
123 void SetLocalColorWindowing(const int slicer, const bool bCtrlKey);
124 void SetOpacity(int i, double factor);
125 void SetColorMap(int colormap);
126 void SetPreset(int preset);
127 void SetOverlayColor(int color) {
128 mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
130 void SetFusionOpacity(int opacity) {
131 mFusionOpacity = opacity;
133 void SetFusionThresholdOpacity(int thresOpacity) {
134 mFusionThresOpacity = thresOpacity;
136 void SetFusionColorMap(int colorMap) {
137 mFusionColorMap = colorMap;
139 void SetFusionWindow(double window) {
140 mFusionWindow = window;
142 void SetFusionLevel(double level) {
143 mFusionLevel = level;
145 void SetFusionShowLegend(int show) {
146 mFusionShowLegend = show;
149 double GetColorWindow();
150 double GetColorLevel();
151 double GetOverlayColorWindow() const;
152 double GetOverlayColorLevel() const;
153 bool GetLinkOverlayWindowLevel() const;
160 SlicingPresetType GetSlicingPreset() {
161 return mSlicingPreset;
163 int GetOverlayColor() const {
164 return mOverlayColor;
166 int GetFusionOpacity() const {
167 return mFusionOpacity;
169 int GetFusionThresholdOpacity() const {
170 return mFusionThresOpacity;
172 int GetFusionColorMap() const {
173 return mFusionColorMap;
175 double GetFusionWindow() const {
176 return mFusionWindow;
178 double GetFusionLevel() const {
182 void SetCursorAndCornerAnnotationVisibility(int s);
183 void UpdateViews(int current, int slicer);
184 void UpdateLinked(int slicer);
185 void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
186 void ResetTransformationToIdentity(const std::string actorType);
189 void AddLink(std::string newId) {
190 mLinkedId.push_back(newId);
192 void RemoveLink(std::string oldId) {
193 mLinkedId.remove(oldId);
197 return mLinkedId.size() > 0;
200 ///Remove the actor defined by its type and index (example: 3rd contour)
201 void RemoveActor(const std::string& actor_type, int overlay_index);
204 void ReloadOverlay();
210 void UpdateInfoOnCursorPosition(int slicer);
211 void UpdateWindowLevel();
212 void UpdateSlice(int slicer);
213 void UpdateTSlice(int slicer);
214 void UpdateSliceRange(int slicer);
215 void SetSlicingPreset(SlicingPresetType preset);
217 vvLandmarks *GetLandmarks();
218 void AddLandmark(float x,float y,float z,float t);
220 void NextImage(int slicer);
221 void PrevImage(int slicer);
222 void LeftButtonReleaseEvent(int slicer);
223 void VerticalSliderHasChanged(int slicer, int slice);
224 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
227 void currentImageChanged(std::string id);
228 void currentPickedImageChanged(std::string id);
229 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
230 void UpdateVector(int display, double x, double y, double z, double value);
231 void UpdateOverlay(int display, double valueOver, double valueRef);
232 void UpdateFusion(int display, double valueFus);
233 void UpdateOrientation(int slicer, int orientation);
234 void UpdateSlice(int slicer, int slice);
235 void UpdateTSlice(int slicer, int slice);
236 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
237 void WindowLevelChanged();
238 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
239 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
240 void LandmarkAdded();
241 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
242 void LeftButtonReleaseSignal(int slicer);
243 void AVerticalSliderHasChanged(int slicer, int slice);
246 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
248 vvImageReader::Pointer mReader;
249 vvImageReader::Pointer mOverlayReader;
250 vvImageReader::Pointer mFusionReader;
251 vvImageReader::Pointer mVectorReader;
252 vvImage::Pointer mImage;
253 vvImage::Pointer mVF;
258 int mFusionThresOpacity;
260 double mFusionWindow;
262 bool mFusionShowLegend;
265 SlicingPresetType mSlicingPreset;
266 vvImageReader::LoadedImageType mType;
267 std::string mVFComponent;
268 std::string mOverlayComponent;
269 std::string mFusionComponent;
270 std::string mFileName;
271 std::string mBaseFileName;
272 int mBaseFileNameNumber;
275 std::string mOverlayName;
276 std::string mFusionName;
278 std::string mLastError;
279 std::list<std::string> mLinkedId;
281 vvLandmarks* mLandmarks;
283 std::vector<int> mPreviousSlice;
284 std::vector<int> mPreviousTSlice;