]> 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   vvSlicerManager(int numberOfSlicers);
56   ~vvSlicerManager();
57
58   std::string GetLastError() {
59     return mLastError;
60   }
61
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);
65
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();
76
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; }
83   std::string GetListOfAbsoluteFilePathInOneString(const std::string &actorType);
84
85   ///Switch between nearest neighbor and linear interpolation
86   void ToggleInterpolation();
87   vvSlicer* GetSlicer(int i);
88   void UpdateSlicer(int num, bool state);
89   void SetSlicerWindow(int i, vtkRenderWindow* RW);
90   void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
91
92   int GetNumberOfSlicers()        { return mSlicers.size(); }
93   vvImage::Pointer GetImage()  { return mImage; }
94   vvImage::Pointer GetVF()     { return mVF; }
95   int GetType()                { return mType; }
96   void SetId(std::string id)   { mId = id; }
97   std::string GetId()          { return mId; }
98   int GetDimension() {
99     if (mImage) return mImage->GetNumberOfDimensions();
100     else return -1;
101   }
102
103   void SetFilename(std::string f, int number=0);
104
105   void SetSliceOrientation(int slicer, int orientation);
106   void SetTSlice(int slice);
107   void SetNextTSlice(int originating_slicer);
108   void SetPreviousTSlice(int originating_slicer);
109   void SetTSliceInSlicer(int tslice, int slicer);
110
111   void GenerateDefaultLookupTable();
112   void SetColorWindow(double s);
113   void SetColorLevel(double s);
114   void SetOverlayColorWindow(double s);
115   void SetOverlayColorLevel(double s);
116   void SetLinkOverlayWindowLevel(bool b);
117   void SetLocalColorWindowing(const int slicer, const bool bCtrlKey);
118   void SetOpacity(int i, double factor);
119   void SetColorMap(int colormap);
120   void SetPreset(int preset);
121   void SetOverlayColor(int color) {
122     mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
123   }
124   void SetFusionOpacity(int opacity) {
125     mFusionOpacity = opacity;
126   }
127   void SetFusionThresholdOpacity(int thresOpacity) {
128     mFusionThresOpacity = thresOpacity;
129   }
130   void SetFusionColorMap(int colorMap) {
131     mFusionColorMap = colorMap;
132   }
133   void SetFusionWindow(double window) {
134     mFusionWindow = window;
135   }
136   void SetFusionLevel(double level) {
137     mFusionLevel = level;
138   }
139   void SetFusionShowLegend(int show) {
140     mFusionShowLegend = show;
141   }
142
143   double GetColorWindow();
144   double GetColorLevel();
145   double GetOverlayColorWindow() const;
146   double GetOverlayColorLevel() const;
147   bool GetLinkOverlayWindowLevel() const;
148   int GetColorMap() {
149     return mColorMap;
150   }
151   int GetPreset() {
152     return mPreset;
153   }
154   int GetOverlayColor() const {
155     return mOverlayColor;
156   }
157   int GetFusionOpacity() const {
158     return mFusionOpacity;
159   }
160   int GetFusionThresholdOpacity() const {
161     return mFusionThresOpacity;
162   }
163   int GetFusionColorMap() const {
164     return mFusionColorMap;
165   }
166   double GetFusionWindow() const {
167     return mFusionWindow;
168   }
169   double GetFusionLevel() const {
170     return mFusionLevel;
171   }
172
173   void SetCursorAndCornerAnnotationVisibility(int s);
174   void UpdateViews(int current, int slicer);
175   void UpdateLinked(int slicer);
176   void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
177   void ResetTransformationToIdentity(const std::string actorType);
178   void Render();
179
180   void AddLink(std::string newId) {
181     mLinkedId.push_back(newId);
182   }
183   void RemoveLink(std::string oldId) {
184     mLinkedId.remove(oldId); 
185   }
186   
187   bool IsLinked() {
188     return mLinkedId.size() > 0;
189   }
190
191   ///Remove the actor defined by its type and index (example: 3rd contour)
192   void RemoveActor(const std::string& actor_type, int overlay_index);
193   void RemoveActors();
194   void Reload();
195   void ReloadOverlay();
196   void ReloadFusion();
197   void ReloadVF();
198
199   void Activated();
200   void Picked();
201   void UpdateInfoOnCursorPosition(int slicer);
202   void EmitMousePositionUpdated(int slicer);
203   void EmitKeyPressed(std::string keyPress);
204   void UpdateWindowLevel();
205   void UpdateSlice(int slicer);
206   void UpdateTSlice(int slicer);
207   void UpdateSliceRange(int slicer);
208
209   vvLandmarks *GetLandmarks();
210   void AddLandmark(float x,float y,float z,float t);
211   
212   void NextImage(int slicer);
213   void PrevImage(int slicer);
214   void LeftButtonReleaseEvent(int slicer);
215   void VerticalSliderHasChanged(int slicer, int slice);
216   double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
217
218 signals :
219   void currentImageChanged(std::string id);
220   void currentPickedImageChanged(std::string id);
221   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
222   void UpdateVector(int display, double x, double y, double z, double value);
223   void UpdateOverlay(int display, double valueOver, double valueRef);
224   void UpdateFusion(int display, double valueFus);
225   void MousePositionUpdatedSignal(int slicer);
226   void KeyPressedSignal(std::string KeyPressed);
227   void UpdateOrientation(int slicer, int orientation);
228   void UpdateSlice(int slicer, int slice);
229   void UpdateTSlice(int slicer, int slice);
230   void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
231   void WindowLevelChanged();
232   void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
233   void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
234   void LandmarkAdded();
235   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
236   void LeftButtonReleaseSignal(int slicer);
237   void AVerticalSliderHasChanged(int slicer, int slice);
238
239 protected:
240   std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
241   vvImageReader::Pointer mReader;
242   vvImageReader::Pointer mOverlayReader;
243   vvImageReader::Pointer mFusionReader;
244   vvImageReader::Pointer mVectorReader;
245   vvImage::Pointer mImage;
246   vvImage::Pointer mVF;
247   int mColorMap;
248   int mOverlayColor;
249
250   int mFusionOpacity;
251   int mFusionThresOpacity;
252   int mFusionColorMap;
253   double mFusionWindow;
254   double mFusionLevel;
255   bool mFusionShowLegend;
256
257   int mPreset;
258   vvImageReader::LoadedImageType mType;
259   std::string mVFComponent;
260   std::string mOverlayComponent;
261   std::string mFusionComponent;
262   std::string mFileName;
263   std::string mBaseFileName;
264   int mBaseFileNameNumber;
265   std::string mId;
266   std::string mVFName;
267   std::string mOverlayName;
268   std::string mFusionName;
269   std::string mVFId;
270   std::string mLastError;
271   std::list<std::string> mLinkedId;
272
273   vvLandmarks* mLandmarks;
274   
275   std::vector<int> mPreviousSlice;
276   std::vector<int> mPreviousTSlice;
277 };
278
279 #endif