]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
First version of reslicing transform
[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 GetSlicingPreset() {
155     return mSlicingPreset;
156   }
157   int GetOverlayColor() const {
158     return mOverlayColor;
159   }
160   int GetFusionOpacity() const {
161     return mFusionOpacity;
162   }
163   int GetFusionThresholdOpacity() const {
164     return mFusionThresOpacity;
165   }
166   int GetFusionColorMap() const {
167     return mFusionColorMap;
168   }
169   double GetFusionWindow() const {
170     return mFusionWindow;
171   }
172   double GetFusionLevel() const {
173     return mFusionLevel;
174   }
175
176   void SetCursorAndCornerAnnotationVisibility(int s);
177   void UpdateViews(int current, int slicer);
178   void UpdateLinked(int slicer);
179   void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
180   void ResetTransformationToIdentity(const std::string actorType);
181   void Render();
182
183   void AddLink(std::string newId) {
184     mLinkedId.push_back(newId);
185   }
186   void RemoveLink(std::string oldId) {
187     mLinkedId.remove(oldId); 
188   }
189   
190   bool IsLinked() {
191     return mLinkedId.size() > 0;
192   }
193
194   ///Remove the actor defined by its type and index (example: 3rd contour)
195   void RemoveActor(const std::string& actor_type, int overlay_index);
196   void RemoveActors();
197   void Reload();
198   void ReloadOverlay();
199   void ReloadFusion();
200   void ReloadVF();
201
202   void Activated();
203   void Picked();
204   void UpdateInfoOnCursorPosition(int slicer);
205   void UpdateWindowLevel();
206   void UpdateSlice(int slicer);
207   void UpdateTSlice(int slicer);
208   void UpdateSliceRange(int slicer);
209   void SetSlicingPreset(int preset);
210
211   vvLandmarks *GetLandmarks();
212   void AddLandmark(float x,float y,float z,float t);
213   
214   void NextImage(int slicer);
215   void PrevImage(int slicer);
216   void LeftButtonReleaseEvent(int slicer);
217   void VerticalSliderHasChanged(int slicer, int slice);
218   double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
219
220 signals :
221   void currentImageChanged(std::string id);
222   void currentPickedImageChanged(std::string id);
223   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
224   void UpdateVector(int display, double x, double y, double z, double value);
225   void UpdateOverlay(int display, double valueOver, double valueRef);
226   void UpdateFusion(int display, double valueFus);
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   int mSlicingPreset;
259   vvImageReader::LoadedImageType mType;
260   std::string mVFComponent;
261   std::string mOverlayComponent;
262   std::string mFusionComponent;
263   std::string mFileName;
264   std::string mBaseFileName;
265   int mBaseFileNameNumber;
266   std::string mId;
267   std::string mVFName;
268   std::string mOverlayName;
269   std::string mFusionName;
270   std::string mVFId;
271   std::string mLastError;
272   std::list<std::string> mLinkedId;
273
274   vvLandmarks* mLandmarks;
275   
276   std::vector<int> mPreviousSlice;
277   std::vector<int> mPreviousTSlice;
278 };
279
280 #endif