]> 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::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 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);
222
223   vvLandmarks *GetLandmarks();
224   void AddLandmark(float x,float y,float z,float t);
225   
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);
231
232 signals :
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);
252
253 protected:
254   std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
255   int mSelectedSlicer;
256   vvImageReader::Pointer mReader;
257   vvImageReader::Pointer mOverlayReader;
258   vvImageReader::Pointer mFusionReader;
259   vvImageReader::Pointer mVectorReader;
260   vvImage::Pointer mImage;
261   vvImage::Pointer mVF;
262   int mColorMap;
263   int mOverlayColor;
264
265   int mFusionOpacity;
266   int mFusionThresOpacity;
267   int mFusionColorMap;
268   double mFusionWindow;
269   double mFusionLevel;
270   bool mFusionShowLegend;
271
272   int mPreset;
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;
281   std::string mId;
282   std::string mVFName;
283   std::string mOverlayName;
284   std::string mFusionName;
285   std::string mVFId;
286   std::string mLastError;
287   std::list<std::string> mLinkedId;
288
289   vvLandmarks* mLandmarks;
290   
291   std::vector<int> mPreviousSlice;
292   std::vector<int> mPreviousTSlice;
293 };
294
295 #endif