]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
Corrected tooltip with absolute file path
[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 SetLocalColorWindowing(const int slicer);
115   void SetOpacity(int i, double factor);
116   void SetColorMap();
117   void SetColorMap(int colormap);
118   void SetPreset(int preset);
119   void SetOverlayColor(int color) {
120     mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
121   }
122   void SetFusionOpacity(int opacity) {
123     mFusionOpacity = opacity;
124   }
125   void SetFusionColorMap(int colorMap) {
126     mFusionColorMap = colorMap;
127   }
128   void SetFusionWindow(double window) {
129     mFusionWindow = window;
130   }
131   void SetFusionLevel(double level) {
132     mFusionLevel = level;
133   }
134
135   double GetColorWindow();
136   double GetColorLevel();
137   int GetColorMap() {
138     return mColorMap;
139   }
140   int GetPreset() {
141     return mPreset;
142   }
143   int GetOverlayColor() {
144     return mOverlayColor;
145   }
146
147   int GetFusionOpacity() {
148     return mFusionOpacity;
149   }
150   int GetFusionColorMap() {
151     return mFusionColorMap;
152   }
153   double GetFusionWindow() {
154     return mFusionWindow;
155   }
156   double GetFusionLevel() {
157     return mFusionLevel;
158   }
159
160   void SetCursorAndCornerAnnotationVisibility(int s);
161   void UpdateViews(int current, int slicer);
162   void UpdateLinked(int slicer);
163   void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
164   void Render();
165
166   void AddLink(std::string newId) {
167     mLinkedId.push_back(newId);
168   }
169   void RemoveLink(std::string oldId) {
170     mLinkedId.remove(oldId); 
171   }
172   
173   bool IsLinked() {
174     return mLinkedId.size() > 0;
175   }
176
177   ///Remove the actor defined by its type and index (example: 3rd contour)
178   void RemoveActor(const std::string& actor_type, int overlay_index);
179   void RemoveActors();
180   void Reload();
181   void ReloadOverlay();
182   void ReloadFusion();
183   void ReloadVF();
184
185   void Activated();
186   void Picked();
187   void UpdateInfoOnCursorPosition(int slicer);
188   void UpdateWindowLevel();
189   void UpdateSlice(int slicer);
190   void UpdateTSlice(int slicer);
191   void UpdateSliceRange(int slicer);
192
193   vvLandmarks *GetLandmarks();
194   void AddLandmark(float x,float y,float z,float t);
195   
196   void NextImage(int slicer);
197   void PrevImage(int slicer);
198   void LeftButtonReleaseEvent(int slicer);
199   void VerticalSliderHasChanged(int slicer, int slice);
200   double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
201
202 signals :
203   void currentImageChanged(std::string id);
204   void currentPickedImageChanged(std::string id);
205   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
206   void UpdateVector(int display, double x, double y, double z, double value);
207   void UpdateOverlay(int display, double valueOver, double valueRef);
208   void UpdateFusion(int display, double valueFus);
209   void UpdateWindows(int slicer, int view, int slice);
210   void UpdateOrientation(int slicer, int orientation);
211   void UpdateSlice(int slicer, int slice);
212   void UpdateTSlice(int slicer, int slice);
213   void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
214   void WindowLevelChanged(double window, double level, int preset, int colormap);
215   void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
216   void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
217   void LandmarkAdded();
218   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
219   void LeftButtonReleaseSignal(int slicer);
220   void AVerticalSliderHasChanged(int slicer, int slice);
221
222 protected:
223   std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
224   vvImageReader::Pointer mReader;
225   vvImageReader::Pointer mOverlayReader;
226   vvImageReader::Pointer mFusionReader;
227   vvImageReader::Pointer mVectorReader;
228   vvImage::Pointer mImage;
229   vvImage::Pointer mVF;
230   int mColorMap;
231   int mOverlayColor;
232
233   int mFusionOpacity;
234   int mFusionColorMap;
235   double mFusionWindow;
236   double mFusionLevel;
237
238   int mPreset;
239   vvImageReader::LoadedImageType mType;
240   std::string mVFComponent;
241   std::string mOverlayComponent;
242   std::string mFusionComponent;
243   std::string mFileName;
244   std::string mBaseFileName;
245   int mBaseFileNameNumber;
246   std::string mId;
247   std::string mVFName;
248   std::string mOverlayName;
249   std::string mFusionName;
250   std::string mVFId;
251   std::string mLastError;
252   std::list<std::string> mLinkedId;
253
254   vvLandmarks* mLandmarks;
255   
256   std::vector<int> mPreviousSlice;
257   std::vector<int> mPreviousTSlice;
258 };
259
260 #endif