]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
Merge branch 'master' of tux.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::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();
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   int GetSelectedSlicer() {
90     return mSelectedSlicer;
91   }
92   
93   void UpdateSlicer(int num, bool state);
94   void SetSlicerWindow(int i, vtkRenderWindow* RW);
95   void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
96
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; }
103   int GetDimension() {
104     if (mImage) return mImage->GetNumberOfDimensions();
105     else return -1;
106   }
107
108   void SetFilename(std::string f, int number=0);
109
110   void SetSliceOrientation(int slicer, int orientation);
111   int GetTSlice();
112   void SetTSlice(int slice);
113   void SetNextTSlice(int originating_slicer);
114   void SetPreviousTSlice(int originating_slicer);
115   void SetTSliceInSlicer(int tslice, int slicer);
116
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
129   }
130   void SetFusionOpacity(int opacity) {
131     mFusionOpacity = opacity;
132   }
133   void SetFusionThresholdOpacity(int thresOpacity) {
134     mFusionThresOpacity = thresOpacity;
135   }
136   void SetFusionColorMap(int colorMap) {
137     mFusionColorMap = colorMap;
138   }
139   void SetFusionWindow(double window) {
140     mFusionWindow = window;
141   }
142   void SetFusionLevel(double level) {
143     mFusionLevel = level;
144   }
145   void SetFusionShowLegend(int show) {
146     mFusionShowLegend = show;
147   }
148
149   double GetColorWindow() const;
150   double GetColorLevel() const;
151   double GetOverlayColorWindow() const;
152   double GetOverlayColorLevel() const;
153   bool GetLinkOverlayWindowLevel() const;
154   int GetColorMap() {
155     return mColorMap;
156   }
157   int GetPreset() const {
158     return mPreset;
159   }
160   SlicingPresetType GetSlicingPreset() {
161     return mSlicingPreset;
162   }
163   int GetOverlayColor() const {
164     return mOverlayColor;
165   }
166   int GetFusionOpacity() const {
167     return mFusionOpacity;
168   }
169   int GetFusionThresholdOpacity() const {
170     return mFusionThresOpacity;
171   }
172   int GetFusionColorMap() const {
173     return mFusionColorMap;
174   }
175   double GetFusionWindow() const {
176     return mFusionWindow;
177   }
178   double GetFusionLevel() const {
179     return mFusionLevel;
180   }
181
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);
187   void Render();
188
189   void AddLink(std::string newId) {
190     mLinkedId.push_back(newId);
191   }
192   void RemoveLink(std::string oldId) {
193     mLinkedId.remove(oldId); 
194   }
195   
196   std::list<std::string> GetLinks() const {
197     return mLinkedId;
198   }
199   
200   bool IsLinked() {
201     return mLinkedId.size() > 0;
202   }
203
204   ///Remove the actor defined by its type and index (example: 3rd contour)
205   void RemoveActor(const std::string& actor_type, int overlay_index);
206   void RemoveActors();
207   void Reload();
208   void ReloadOverlay();
209   void ReloadFusion();
210   void ReloadVF();
211
212   void Activated();
213   void Picked();
214   void UpdateInfoOnCursorPosition(int slicer);
215   void UpdateWindowLevel();
216   void UpdateSlice(int slicer);
217   void UpdateTSlice(int slicer);
218   void UpdateSliceRange(int slicer);
219   void SetSlicingPreset(SlicingPresetType preset);
220
221   vvLandmarks *GetLandmarks();
222   void AddLandmark(float x,float y,float z,float t);
223   
224   void NextImage(int slicer);
225   void PrevImage(int slicer);
226   void LeftButtonReleaseEvent(int slicer);
227   void VerticalSliderHasChanged(int slicer, int slice);
228   double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
229
230 signals :
231   void currentImageChanged(std::string id);
232   void currentPickedImageChanged(std::string id);
233   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
234   void UpdateVector(int display, double x, double y, double z, double value);
235   void UpdateOverlay(int display, double valueOver, double valueRef);
236   void UpdateFusion(int display, double valueFus);
237   void UpdateOrientation(int slicer, int orientation);
238   void UpdateSlice(int slicer, int slice);
239   void UpdateTSlice(int slicer, int slice);
240   void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
241   void WindowLevelChanged();
242   void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
243   void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
244   void LandmarkAdded();
245   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
246   void LeftButtonReleaseSignal(int slicer);
247   void AVerticalSliderHasChanged(int slicer, int slice);
248
249 protected:
250   std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
251   int mSelectedSlicer;
252   vvImageReader::Pointer mReader;
253   vvImageReader::Pointer mOverlayReader;
254   vvImageReader::Pointer mFusionReader;
255   vvImageReader::Pointer mVectorReader;
256   vvImage::Pointer mImage;
257   vvImage::Pointer mVF;
258   int mColorMap;
259   int mOverlayColor;
260
261   int mFusionOpacity;
262   int mFusionThresOpacity;
263   int mFusionColorMap;
264   double mFusionWindow;
265   double mFusionLevel;
266   bool mFusionShowLegend;
267
268   int mPreset;
269   SlicingPresetType mSlicingPreset;
270   vvImageReader::LoadedImageType mType;
271   std::string mVFComponent;
272   std::string mOverlayComponent;
273   std::string mFusionComponent;
274   std::string mFileName;
275   std::string mBaseFileName;
276   int mBaseFileNameNumber;
277   std::string mId;
278   std::string mVFName;
279   std::string mOverlayName;
280   std::string mFusionName;
281   std::string mVFId;
282   std::string mLastError;
283   std::list<std::string> mLinkedId;
284
285   vvLandmarks* mLandmarks;
286   
287   std::vector<int> mPreviousSlice;
288   std::vector<int> mPreviousTSlice;
289 };
290
291 #endif