]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
added the new headers
[clitk.git] / vv / vvSlicerManager.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef vvSlicerManager_h
19 #define vvSlicerManager_h
20 #include <iostream>
21 #include <vector>
22 #include <string>
23
24 // QT
25 #include <QObject>
26
27 // VTK
28 #include <vtksys/SystemTools.hxx>
29 class vtkImageData;
30 class vtkInteractorStyle;
31 class vtkRenderWindow;
32 class vtkPolyData;
33
34 // VV
35 #include "vvConstants.h"
36 #include "clitkCommon.h"
37 #include "vvImage.h"
38 #include "vvMesh.h"
39 class vvSlicer;
40 class vvInteractorStyleNavigator;
41 class vvImageReader;
42 class vvImageReader;
43 class vvLandmarks;
44
45 class vvSlicerManager : public QObject {
46     Q_OBJECT
47
48 public:
49     vvSlicerManager(int numberOfSlicers);
50     ~vvSlicerManager();
51
52     std::string GetLastError() {
53         return mLastError;
54     }
55
56     bool SetImage(std::string filename,LoadedImageType type);
57     void SetImage(vvImage::Pointer image);
58     void SetExtractedImage(std::string filename, vvImage::Pointer image, int slice);
59     bool SetImages(std::vector<std::string> filenames,LoadedImageType type);
60
61     bool SetOverlay(std::string filename, int dim, std::string component);
62     bool SetFusion(std::string filename, int dim, std::string component);
63     ///Set a VF by loading it from the disk
64     bool SetVF(std::string filename);
65     ///Set a VF from memory
66     bool SetVF(vvImage::Pointer vf,std::string filename);
67     ///Add a mesh to the slicers, with optional propagation using a vector field
68     void AddContour(vvMesh::Pointer ,bool propagate=false);
69     ///Toggle temporal superposition of contours
70     void ToggleContourSuperposition();
71
72     std::string GetFileName() {
73         return mFileName;
74     }
75     std::string GetVFName() {
76         return mVFName;
77     }
78     std::string GetOverlayName() {
79         return mOverlayName;
80     }
81     std::string GetFusionName() {
82         return mFusionName;
83     }
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     int NumberOfSlicers() {
92         return mSlicers.size();
93     }
94     vvImage::Pointer GetImage() {
95         return mImage;
96     }
97     vvImage::Pointer GetVF() {
98         return mVF;
99     }
100     int GetDimension() {
101         if (mImage) return mImage->GetNumberOfDimensions();
102         else return -1;
103     }
104
105     int GetType() {
106         return mType;
107     }
108
109     void SetId(std::string id) {
110         mId = id;
111     }
112     std::string GetId() {
113         return mId;
114     }
115
116     void SetFilename(std::string f) {
117         mFileName = f;
118     }
119
120     void SetTSlice(int slice);
121     void SetNextTSlice(int originating_slicer);
122     void SetPreviousTSlice(int originating_slicer);
123     void SetTSliceInSlicer(int tslice, int slicer);
124
125     void GenerateDefaultLookupTable();
126     void SetColorWindow(double s);
127     void SetColorLevel(double s);
128     void SetLocalColorWindowing(const int slicer);
129     void SetOpacity(int i, double factor);
130     void SetColorMap();
131     void SetColorMap(int colormap);
132     void SetPreset(int preset);
133     void SetOverlayColor(int color) {
134         mOverlayColor = color;
135     }
136     void SetFusionOpacity(int opacity) {
137         mFusionOpacity = opacity;
138     }
139     void SetFusionColorMap(int colorMap) {
140         mFusionColorMap = colorMap;
141     }
142     void SetFusionWindow(int window) {
143         mFusionWindow = window;
144     }
145     void SetFusionLevel(int level) {
146         mFusionLevel = level;
147     }
148
149     double GetColorWindow();
150     double GetColorLevel();
151     int GetColorMap() {
152         return mColorMap;
153     }
154     int GetPreset() {
155         return mPreset;
156     }
157     int GetOverlayColor() {
158         return mOverlayColor;
159     }
160
161     int GetFusionOpacity() {
162         return mFusionOpacity;
163     }
164     int GetFusionColorMap() {
165         return mFusionColorMap;
166     }
167     double GetFusionWindow() {
168         return mFusionWindow;
169     }
170     double GetFusionLevel() {
171         return mFusionLevel;
172     }
173
174     void SetCursorVisibility(int s);
175     void UpdateViews(int current, int slicer);
176     void UpdateLinked(int slicer);
177     void Render();
178
179     void AddLink(std::string newId) {
180         mLinkedId.push_back(newId);
181     }
182     void RemoveLink(std::string oldId) {
183         mLinkedId.remove(oldId);
184     }
185
186     ///Remove the actor defined by its type and index (example: 3rd contour)
187     void RemoveActor(const std::string& actor_type, int overlay_index);
188     void RemoveActors();
189     void Reload();
190     void ReloadOverlay();
191     void ReloadFusion();
192     void ReloadVF();
193
194     void Activated();
195     void UpdateInfoOnCursorPosition(int slicer);
196     void UpdateWindowLevel();
197     void UpdateSlice(int slicer);
198     void UpdateTSlice(int slicer);
199     void UpdateSliceRange(int slicer);
200
201     vvLandmarks *GetLandmarks();
202     void AddLandmark(float x,float y,float z,float t);
203
204 signals :
205     void currentImageChanged(std::string id);
206     void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
207     void UpdateVector(int display, double x, double y, double z, double value);
208     void UpdateOverlay(int display, double valueOver, double valueRef);
209     void UpdateFusion(int display, double valueFus);
210     void UpdateWindows(int slicer, int view, int slice);
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 LandmarkAdded();
217
218 protected:
219     std::vector<vvSlicer*> mSlicers;
220     vvImageReader* mReader;
221     vvImageReader* mOverlayReader;
222     vvImageReader* mFusionReader;
223     vvImage::Pointer mImage;
224     vvImage::Pointer mVF;
225     vvImageReader* mVectorReader;
226     int mColorMap;
227     int mOverlayColor;
228
229     int mFusionOpacity;
230     int mFusionColorMap;
231     double mFusionWindow;
232     double mFusionLevel;
233
234     int mPreset;
235     LoadedImageType mType;
236     std::string mVFComponent;
237     std::string mOverlayComponent;
238     std::string mFusionComponent;
239     std::string mFileName;
240     std::string mId;
241     std::string mVFName;
242     std::string mOverlayName;
243     std::string mFusionName;
244     std::string mVFId;
245     std::string mLastError;
246     std::list<std::string> mLinkedId;
247
248     vvLandmarks* mLandmarks;
249 };
250
251 #endif