]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
Merge branch 'master' of /home/romulo/creatis/clitk3-git-shared/clitk3
[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
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);
90
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; }
97   int GetDimension() {
98     if (mImage) return mImage->GetNumberOfDimensions();
99     else return -1;
100   }
101
102   void SetFilename(std::string f, int number=0);
103
104   void SetTSlice(int slice);
105   void SetNextTSlice(int originating_slicer);
106   void SetPreviousTSlice(int originating_slicer);
107   void SetTSliceInSlicer(int tslice, int slicer);
108
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);
114   void SetColorMap();
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
119   }
120   void SetFusionOpacity(int opacity) {
121     mFusionOpacity = opacity;
122   }
123   void SetFusionColorMap(int colorMap) {
124     mFusionColorMap = colorMap;
125   }
126   void SetFusionWindow(double window) {
127     mFusionWindow = window;
128   }
129   void SetFusionLevel(double level) {
130     mFusionLevel = level;
131   }
132
133   double GetColorWindow();
134   double GetColorLevel();
135   int GetColorMap() {
136     return mColorMap;
137   }
138   int GetPreset() {
139     return mPreset;
140   }
141   int GetOverlayColor() {
142     return mOverlayColor;
143   }
144
145   int GetFusionOpacity() {
146     return mFusionOpacity;
147   }
148   int GetFusionColorMap() {
149     return mFusionColorMap;
150   }
151   double GetFusionWindow() {
152     return mFusionWindow;
153   }
154   double GetFusionLevel() {
155     return mFusionLevel;
156   }
157
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);
162   void Render();
163
164   void AddLink(std::string newId) {
165     mLinkedId.push_back(newId);
166   }
167   void RemoveLink(std::string oldId) {
168     mLinkedId.remove(oldId); 
169   }
170   
171   bool IsLinked() {
172     return mLinkedId.size() > 0;
173   }
174
175   ///Remove the actor defined by its type and index (example: 3rd contour)
176   void RemoveActor(const std::string& actor_type, int overlay_index);
177   void RemoveActors();
178   void Reload();
179   void ReloadOverlay();
180   void ReloadFusion();
181   void ReloadVF();
182
183   void Activated();
184   void Picked();
185   void UpdateInfoOnCursorPosition(int slicer);
186   void UpdateWindowLevel();
187   void UpdateSlice(int slicer);
188   void UpdateTSlice(int slicer);
189   void UpdateSliceRange(int slicer);
190
191   vvLandmarks *GetLandmarks();
192   void AddLandmark(float x,float y,float z,float t);
193   
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);
199
200 signals :
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);
218
219 protected:
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;
227   int mColorMap;
228   int mOverlayColor;
229
230   int mFusionOpacity;
231   int mFusionColorMap;
232   double mFusionWindow;
233   double mFusionLevel;
234
235   int mPreset;
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;
243   std::string mId;
244   std::string mVFName;
245   std::string mOverlayName;
246   std::string mFusionName;
247   std::string mVFId;
248   std::string mLastError;
249   std::list<std::string> mLinkedId;
250
251   vvLandmarks* mLandmarks;
252   
253   std::vector<int> mPreviousSlice;
254   std::vector<int> mPreviousTSlice;
255 };
256
257 #endif