]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
h now hides corner annotations as well
[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, unsigned int slice=0);
62   void SetImage(vvImage::Pointer image);
63   bool SetImages(std::vector<std::string> filenames, LoadedImageType type, int n=0);
64
65   bool SetOverlay(std::string filename, int dim, std::string component);
66   bool SetFusion(std::string filename, int dim, std::string component);
67   ///Set a VF by loading it from the disk
68   bool SetVF(std::string filename);
69   ///Set a VF from memory
70   bool SetVF(vvImage::Pointer vf,std::string filename);
71   ///Add a mesh to the slicers, with optional propagation using a vector field
72   void AddContour(vvMesh::Pointer ,bool propagate=false);
73   ///Toggle temporal superposition of contours
74   void ToggleContourSuperposition();
75
76   std::string GetFileName()      { return mFileName; }
77   std::string GetBaseFileName()  { return mBaseFileName; }
78   int GetBaseFileNameNumber()    { return mBaseFileNameNumber; }
79   std::string GetVFName()        { return mVFName; }
80   std::string GetOverlayName()   { return mOverlayName; }
81   std::string GetFusionName()    { return mFusionName; }
82
83   ///Switch between nearest neighbor and linear interpolation
84   void ToggleInterpolation();
85   vvSlicer* GetSlicer(int i);
86   void UpdateSlicer(int num, bool state);
87   void SetSlicerWindow(int i, vtkRenderWindow* RW);
88   void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
89
90   int GetNumberOfSlicers()        { return mSlicers.size(); }
91   vvImage::Pointer GetImage()  { return mImage; }
92   vvImage::Pointer GetVF()     { return mVF; }
93   int GetType()                { return mType; }
94   void SetId(std::string id)   { mId = id; }
95   std::string GetId()          { return mId; }
96   int GetDimension() {
97     if (mImage) return mImage->GetNumberOfDimensions();
98     else return -1;
99   }
100
101   void SetFilename(std::string f, int number=0);
102
103   void SetTSlice(int slice);
104   void SetNextTSlice(int originating_slicer);
105   void SetPreviousTSlice(int originating_slicer);
106   void SetTSliceInSlicer(int tslice, int slicer);
107
108   void GenerateDefaultLookupTable();
109   void SetColorWindow(double s);
110   void SetColorLevel(double s);
111   void SetLocalColorWindowing(const int slicer);
112   void SetOpacity(int i, double factor);
113   void SetColorMap();
114   void SetColorMap(int colormap);
115   void SetPreset(int preset);
116   void SetOverlayColor(int color) {
117     mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
118   }
119   void SetFusionOpacity(int opacity) {
120     mFusionOpacity = opacity;
121   }
122   void SetFusionColorMap(int colorMap) {
123     mFusionColorMap = colorMap;
124   }
125   void SetFusionWindow(double window) {
126     mFusionWindow = window;
127   }
128   void SetFusionLevel(double level) {
129     mFusionLevel = level;
130   }
131
132   double GetColorWindow();
133   double GetColorLevel();
134   int GetColorMap() {
135     return mColorMap;
136   }
137   int GetPreset() {
138     return mPreset;
139   }
140   int GetOverlayColor() {
141     return mOverlayColor;
142   }
143
144   int GetFusionOpacity() {
145     return mFusionOpacity;
146   }
147   int GetFusionColorMap() {
148     return mFusionColorMap;
149   }
150   double GetFusionWindow() {
151     return mFusionWindow;
152   }
153   double GetFusionLevel() {
154     return mFusionLevel;
155   }
156
157   void SetCursorAndCornerAnnotationVisibility(int s);
158   void UpdateViews(int current, int slicer);
159   void UpdateLinked(int slicer);
160   void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
161   void Render();
162
163   void AddLink(std::string newId) {
164     mLinkedId.push_back(newId);
165   }
166   void RemoveLink(std::string oldId) {
167     mLinkedId.remove(oldId); 
168   }
169
170   ///Remove the actor defined by its type and index (example: 3rd contour)
171   void RemoveActor(const std::string& actor_type, int overlay_index);
172   void RemoveActors();
173   void Reload();
174   void ReloadOverlay();
175   void ReloadFusion();
176   void ReloadVF();
177
178   void Activated();
179   void Picked();
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   double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
194
195 signals :
196   void currentImageChanged(std::string id);
197   void currentPickedImageChanged(std::string id);
198   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
199   void UpdateVector(int display, double x, double y, double z, double value);
200   void UpdateOverlay(int display, double valueOver, double valueRef);
201   void UpdateFusion(int display, double valueFus);
202   void UpdateWindows(int slicer, int view, int slice);
203   void UpdateSlice(int slicer, int slice);
204   void UpdateTSlice(int slicer, int slice);
205   void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
206   void WindowLevelChanged(double window, double level, int preset, int colormap);
207   void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
208   void UpdateLinkedNavigation(std::string, vvSlicerManager*);
209   void LandmarkAdded();
210   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
211   void LeftButtonReleaseSignal(int slicer);
212   void AVerticalSliderHasChanged(int slicer, int slice);
213
214 protected:
215   std::vector<vvSlicer*> mSlicers;
216   vvImageReader* mReader;
217   vvImageReader* mOverlayReader;
218   vvImageReader* mFusionReader;
219   vvImage::Pointer mImage;
220   vvImage::Pointer mVF;
221   vvImageReader* mVectorReader;
222   int mColorMap;
223   int mOverlayColor;
224
225   int mFusionOpacity;
226   int mFusionColorMap;
227   double mFusionWindow;
228   double mFusionLevel;
229
230   int mPreset;
231   LoadedImageType mType;
232   std::string mVFComponent;
233   std::string mOverlayComponent;
234   std::string mFusionComponent;
235   std::string mFileName;
236   std::string mBaseFileName;
237   int mBaseFileNameNumber;
238   std::string mId;
239   std::string mVFName;
240   std::string mOverlayName;
241   std::string mFusionName;
242   std::string mVFId;
243   std::string mLastError;
244   std::list<std::string> mLinkedId;
245
246   vvLandmarks* mLandmarks;
247   
248   std::vector<int> mPreviousSlice;
249   std::vector<int> mPreviousTSlice;
250 };
251
252 #endif