]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / vv / vvSlicerManager.h
1
2 /*=========================================================================
3   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
4
5   Authors belong to: 
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
9
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.
13
14   It is distributed under dual licence
15
16   - BSD        See included LICENSE.txt file
17   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
18   ===========================================================================**/
19
20 #ifndef VVSLICERMANAGER_H
21 #define VVSLICERMANAGER_H
22
23 // std
24 #include <iostream>
25 #include <vector>
26 #include <string>
27
28 // QT
29 #include <QObject>
30
31 // VTK
32 #include <vtksys/SystemTools.hxx>
33 class vtkImageData;
34 class vtkInteractorStyle;
35 class vtkRenderWindow;
36 class vtkPolyData;
37
38 // VV
39 #include "clitkCommon.h"
40 #include "vvImage.h"
41 #include "vvMesh.h"
42 #include "vvImageReader.h"
43
44 class vvSlicer;
45 class vvInteractorStyleNavigator;
46 class vvImageReader;
47 class vvImageReader;
48 class vvLandmarks;
49
50 //------------------------------------------------------------------------------
51 class vvSlicerManager : public QObject {
52   Q_OBJECT
53
54   public:
55   typedef enum {WORLD_SLICING, VOXELS_SLICING} SlicingPresetType;
56   vvSlicerManager(int numberOfSlicers);
57   ~vvSlicerManager();
58
59   std::string GetLastError() {
60     return mLastError;
61   }
62
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);
66
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();
77
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);
85
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);
92
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; }
99   int GetDimension() {
100     if (mImage) return mImage->GetNumberOfDimensions();
101     else return -1;
102   }
103
104   void SetFilename(std::string f, int number=0);
105
106   void SetSliceOrientation(int slicer, int orientation);
107   int GetTSlice();
108   void SetTSlice(int slice);
109   void SetNextTSlice(int originating_slicer);
110   void SetPreviousTSlice(int originating_slicer);
111   void SetTSliceInSlicer(int tslice, int slicer);
112
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
125   }
126   void SetFusionOpacity(int opacity) {
127     mFusionOpacity = opacity;
128   }
129   void SetFusionThresholdOpacity(int thresOpacity) {
130     mFusionThresOpacity = thresOpacity;
131   }
132   void SetFusionColorMap(int colorMap) {
133     mFusionColorMap = colorMap;
134   }
135   void SetFusionWindow(double window) {
136     mFusionWindow = window;
137   }
138   void SetFusionLevel(double level) {
139     mFusionLevel = level;
140   }
141   void SetFusionShowLegend(int show) {
142     mFusionShowLegend = show;
143   }
144
145   double GetColorWindow();
146   double GetColorLevel();
147   double GetOverlayColorWindow() const;
148   double GetOverlayColorLevel() const;
149   bool GetLinkOverlayWindowLevel() const;
150   int GetColorMap() {
151     return mColorMap;
152   }
153   int GetPreset() {
154     return mPreset;
155   }
156   SlicingPresetType GetSlicingPreset() {
157     return mSlicingPreset;
158   }
159   int GetOverlayColor() const {
160     return mOverlayColor;
161   }
162   int GetFusionOpacity() const {
163     return mFusionOpacity;
164   }
165   int GetFusionThresholdOpacity() const {
166     return mFusionThresOpacity;
167   }
168   int GetFusionColorMap() const {
169     return mFusionColorMap;
170   }
171   double GetFusionWindow() const {
172     return mFusionWindow;
173   }
174   double GetFusionLevel() const {
175     return mFusionLevel;
176   }
177
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);
183   void Render();
184
185   void AddLink(std::string newId) {
186     mLinkedId.push_back(newId);
187   }
188   void RemoveLink(std::string oldId) {
189     mLinkedId.remove(oldId); 
190   }
191   
192   bool IsLinked() {
193     return mLinkedId.size() > 0;
194   }
195
196   ///Remove the actor defined by its type and index (example: 3rd contour)
197   void RemoveActor(const std::string& actor_type, int overlay_index);
198   void RemoveActors();
199   void Reload();
200   void ReloadOverlay();
201   void ReloadFusion();
202   void ReloadVF();
203
204   void Activated();
205   void Picked();
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);
212
213   vvLandmarks *GetLandmarks();
214   void AddLandmark(float x,float y,float z,float t);
215   
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);
221
222 signals :
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);
240
241 protected:
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;
249   int mColorMap;
250   int mOverlayColor;
251
252   int mFusionOpacity;
253   int mFusionThresOpacity;
254   int mFusionColorMap;
255   double mFusionWindow;
256   double mFusionLevel;
257   bool mFusionShowLegend;
258
259   int mPreset;
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;
268   std::string mId;
269   std::string mVFName;
270   std::string mOverlayName;
271   std::string mFusionName;
272   std::string mVFId;
273   std::string mLastError;
274   std::list<std::string> mLinkedId;
275
276   vvLandmarks* mLandmarks;
277   
278   std::vector<int> mPreviousSlice;
279   std::vector<int> mPreviousTSlice;
280 };
281
282 #endif