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() const { 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() const;
150 double GetColorLevel() const;
151 double GetOverlayColorWindow() const;
152 double GetOverlayColorLevel() const;
153 bool GetLinkOverlayWindowLevel() const;
157 int GetPreset() 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);
196 std::list<std::string> GetLinks() const {
201 return mLinkedId.size() > 0;
204 ///Remove the actor defined by its type and index (example: 3rd contour)
205 void RemoveActor(const std::string& actor_type, int overlay_index);
208 void ReloadOverlay();
214 void UpdateInfoOnCursorPosition(int slicer);
215 void EmitMousePositionUpdated(int slicer);
216 void EmitKeyPressed(std::string keyPress);
217 void UpdateWindowLevel();
218 void UpdateSlice(int slicer);
219 void UpdateTSlice(int slicer);
220 void UpdateSliceRange(int slicer);
221 void SetSlicingPreset(SlicingPresetType preset);
223 vvLandmarks *GetLandmarks();
224 void AddLandmark(float x,float y,float z,float t);
226 void NextImage(int slicer);
227 void PrevImage(int slicer);
228 void LeftButtonReleaseEvent(int slicer);
229 void VerticalSliderHasChanged(int slicer, int slice);
230 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
233 void currentImageChanged(std::string id);
234 void currentPickedImageChanged(std::string id);
235 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
236 void UpdateVector(int display, double x, double y, double z, double value);
237 void UpdateOverlay(int display, double valueOver, double valueRef);
238 void UpdateFusion(int display, double valueFus);
239 void MousePositionUpdatedSignal(int slicer);
240 void KeyPressedSignal(std::string KeyPressed);
241 void UpdateOrientation(int slicer, int orientation);
242 void UpdateSlice(int slicer, int slice);
243 void UpdateTSlice(int slicer, int slice);
244 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
245 void WindowLevelChanged();
246 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
247 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
248 void LandmarkAdded();
249 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
250 void LeftButtonReleaseSignal(int slicer);
251 void AVerticalSliderHasChanged(int slicer, int slice);
254 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
256 vvImageReader::Pointer mReader;
257 vvImageReader::Pointer mOverlayReader;
258 vvImageReader::Pointer mFusionReader;
259 vvImageReader::Pointer mVectorReader;
260 vvImage::Pointer mImage;
261 vvImage::Pointer mVF;
266 int mFusionThresOpacity;
268 double mFusionWindow;
270 bool mFusionShowLegend;
273 SlicingPresetType mSlicingPreset;
274 vvImageReader::LoadedImageType mType;
275 std::string mVFComponent;
276 std::string mOverlayComponent;
277 std::string mFusionComponent;
278 std::string mFileName;
279 std::string mBaseFileName;
280 int mBaseFileNameNumber;
283 std::string mOverlayName;
284 std::string mFusionName;
286 std::string mLastError;
287 std::list<std::string> mLinkedId;
289 vvLandmarks* mLandmarks;
291 std::vector<int> mPreviousSlice;
292 std::vector<int> mPreviousTSlice;