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://oncora1.lyon.fnclcc.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 SetTSlice(int slice);
105 void SetNextTSlice(int originating_slicer);
106 void SetPreviousTSlice(int originating_slicer);
107 void SetTSliceInSlicer(int tslice, int slicer);
109 void GenerateDefaultLookupTable();
110 void SetColorWindow(double s);
111 void SetColorLevel(double s);
112 void SetLocalColorWindowing(const int slicer);
113 void SetOpacity(int i, double factor);
115 void SetColorMap(int colormap);
116 void SetPreset(int preset);
117 void SetOverlayColor(int color) {
118 mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
120 void SetFusionOpacity(int opacity) {
121 mFusionOpacity = opacity;
123 void SetFusionColorMap(int colorMap) {
124 mFusionColorMap = colorMap;
126 void SetFusionWindow(double window) {
127 mFusionWindow = window;
129 void SetFusionLevel(double level) {
130 mFusionLevel = level;
133 double GetColorWindow();
134 double GetColorLevel();
141 int GetOverlayColor() {
142 return mOverlayColor;
145 int GetFusionOpacity() {
146 return mFusionOpacity;
148 int GetFusionColorMap() {
149 return mFusionColorMap;
151 double GetFusionWindow() {
152 return mFusionWindow;
154 double GetFusionLevel() {
158 void SetCursorAndCornerAnnotationVisibility(int s);
159 void UpdateViews(int current, int slicer);
160 void UpdateLinked(int slicer);
161 void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
164 void AddLink(std::string newId) {
165 mLinkedId.push_back(newId);
167 void RemoveLink(std::string oldId) {
168 mLinkedId.remove(oldId);
172 return mLinkedId.size() > 0;
175 ///Remove the actor defined by its type and index (example: 3rd contour)
176 void RemoveActor(const std::string& actor_type, int overlay_index);
179 void ReloadOverlay();
185 void UpdateInfoOnCursorPosition(int slicer);
186 void UpdateWindowLevel();
187 void UpdateSlice(int slicer);
188 void UpdateTSlice(int slicer);
189 void UpdateSliceRange(int slicer);
191 vvLandmarks *GetLandmarks();
192 void AddLandmark(float x,float y,float z,float t);
194 void NextImage(int slicer);
195 void PrevImage(int slicer);
196 void LeftButtonReleaseEvent(int slicer);
197 void VerticalSliderHasChanged(int slicer, int slice);
198 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
201 void currentImageChanged(std::string id);
202 void currentPickedImageChanged(std::string id);
203 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
204 void UpdateVector(int display, double x, double y, double z, double value);
205 void UpdateOverlay(int display, double valueOver, double valueRef);
206 void UpdateFusion(int display, double valueFus);
207 void UpdateWindows(int slicer, int view, int slice);
208 void UpdateSlice(int slicer, int slice);
209 void UpdateTSlice(int slicer, int slice);
210 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
211 void WindowLevelChanged(double window, double level, int preset, int colormap);
212 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
213 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
214 void LandmarkAdded();
215 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
216 void LeftButtonReleaseSignal(int slicer);
217 void AVerticalSliderHasChanged(int slicer, int slice);
220 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
221 vvImageReader::Pointer mReader;
222 vvImageReader::Pointer mOverlayReader;
223 vvImageReader::Pointer mFusionReader;
224 vvImageReader::Pointer mVectorReader;
225 vvImage::Pointer mImage;
226 vvImage::Pointer mVF;
232 double mFusionWindow;
236 vvImageReader::LoadedImageType mType;
237 std::string mVFComponent;
238 std::string mOverlayComponent;
239 std::string mFusionComponent;
240 std::string mFileName;
241 std::string mBaseFileName;
242 int mBaseFileNameNumber;
245 std::string mOverlayName;
246 std::string mFusionName;
248 std::string mLastError;
249 std::list<std::string> mLinkedId;
251 vvLandmarks* mLandmarks;
253 std::vector<int> mPreviousSlice;
254 std::vector<int> mPreviousTSlice;