]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
Added linked navigation (zoom and pan)
[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://oncora1.lyon.fnclcc.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 "vvConstants.h"
40 #include "clitkCommon.h"
41 #include "vvImage.h"
42 #include "vvMesh.h"
43 class vvSlicer;
44 class vvInteractorStyleNavigator;
45 class vvImageReader;
46 class vvImageReader;
47 class vvLandmarks;
48
49 //------------------------------------------------------------------------------
50 class vvSlicerManager : public QObject {
51   Q_OBJECT
52
53   public:
54   vvSlicerManager(int numberOfSlicers);
55   ~vvSlicerManager();
56
57   std::string GetLastError() {
58     return mLastError;
59   }
60
61   bool SetImage(std::string filename,LoadedImageType type, int n=0);
62   void SetImage(vvImage::Pointer image);
63   void SetExtractedImage(std::string filename, vvImage::Pointer image, int slice);
64   bool SetImages(std::vector<std::string> filenames, 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 NumberOfSlicers()        { 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);
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(int window) {
127     mFusionWindow = window;
128   }
129   void SetFusionLevel(int 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 SetCursorVisibility(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   ///Remove the actor defined by its type and index (example: 3rd contour)
172   void RemoveActor(const std::string& actor_type, int overlay_index);
173   void RemoveActors();
174   void Reload();
175   void ReloadOverlay();
176   void ReloadFusion();
177   void ReloadVF();
178
179   void Activated();
180   void UpdateInfoOnCursorPosition(int slicer);
181   void UpdateWindowLevel();
182   void UpdateSlice(int slicer);
183   void UpdateTSlice(int slicer);
184   void UpdateSliceRange(int slicer);
185
186   vvLandmarks *GetLandmarks();
187   void AddLandmark(float x,float y,float z,float t);
188   
189   void NextImage(int slicer);
190   void PrevImage(int slicer);
191   void LeftButtonReleaseEvent(int slicer);
192   void VerticalSliderHasChanged(int slicer, int slice);
193
194 signals :
195   void currentImageChanged(std::string id);
196   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
197   void UpdateVector(int display, double x, double y, double z, double value);
198   void UpdateOverlay(int display, double valueOver, double valueRef);
199   void UpdateFusion(int display, double valueFus);
200   void UpdateWindows(int slicer, int view, int slice);
201   void UpdateSlice(int slicer, int slice);
202   void UpdateTSlice(int slicer, int slice);
203   void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
204   void WindowLevelChanged(double window, double level, int preset, int colormap);
205   void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
206   void UpdateLinkedNavigation(std::string, vvSlicerManager*);
207   void LandmarkAdded();
208   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
209   void LeftButtonReleaseSignal(int slicer);
210   void AVerticalSliderHasChanged(int slicer, int slice);
211
212 protected:
213   std::vector<vvSlicer*> mSlicers;
214   vvImageReader* mReader;
215   vvImageReader* mOverlayReader;
216   vvImageReader* mFusionReader;
217   vvImage::Pointer mImage;
218   vvImage::Pointer mVF;
219   vvImageReader* mVectorReader;
220   int mColorMap;
221   int mOverlayColor;
222
223   int mFusionOpacity;
224   int mFusionColorMap;
225   double mFusionWindow;
226   double mFusionLevel;
227
228   int mPreset;
229   LoadedImageType mType;
230   std::string mVFComponent;
231   std::string mOverlayComponent;
232   std::string mFusionComponent;
233   std::string mFileName;
234   std::string mBaseFileName;
235   int mBaseFileNameNumber;
236   std::string mId;
237   std::string mVFName;
238   std::string mOverlayName;
239   std::string mFusionName;
240   std::string mVFId;
241   std::string mLastError;
242   std::list<std::string> mLinkedId;
243
244   vvLandmarks* mLandmarks;
245   
246   std::vector<int> mPreviousSlice;
247   std::vector<int> mPreviousTSlice;
248 };
249
250 #endif