]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
- new multiple input selector
[clitk.git] / vv / vvSlicerManager.h
1 /*=========================================================================
2
3  Program:   vv
4  Language:  C++
5  Author :   Pierre Seroul (pierre.seroul@gmail.com)
6
7 Copyright (C) 2008
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 =========================================================================*/
24 #ifndef vvSlicerManager_h
25 #define vvSlicerManager_h
26
27 // std
28 #include <iostream>
29 #include <vector>
30 #include <string>
31
32 // QT
33 #include <QObject>
34
35 // VTK
36 #include <vtksys/SystemTools.hxx>
37 class vtkImageData;
38 class vtkInteractorStyle;
39 class vtkRenderWindow;
40 class vtkPolyData;
41
42 // VV
43 #include "vvConstants.h"
44 #include "clitkCommon.h"
45 #include "vvImage.h"
46 #include "vvMesh.h"
47 class vvSlicer;
48 class vvInteractorStyleNavigator;
49 class vvImageReader;
50 class vvImageReader;
51 class vvLandmarks;
52
53 class vvSlicerManager : public QObject {
54     Q_OBJECT
55
56 public:
57     vvSlicerManager(int numberOfSlicers);
58     ~vvSlicerManager();
59
60     std::string GetLastError() {
61         return mLastError;
62     }
63
64     bool SetImage(std::string filename,LoadedImageType type);
65     void SetImage(vvImage::Pointer image);
66     void SetExtractedImage(std::string filename, vvImage::Pointer image, int slice);
67     bool SetImages(std::vector<std::string> filenames,LoadedImageType type);
68
69     bool SetOverlay(std::string filename, int dim, std::string component);
70     bool SetFusion(std::string filename, int dim, std::string component);
71     ///Set a VF by loading it from the disk
72     bool SetVF(std::string filename);
73     ///Set a VF from memory
74     bool SetVF(vvImage::Pointer vf,std::string filename);
75     ///Add a mesh to the slicers, with optional propagation using a vector field
76     void AddContour(vvMesh::Pointer ,bool propagate=false);
77     ///Toggle temporal superposition of contours
78     void ToggleContourSuperposition();
79
80     std::string GetFileName() {
81         return mFileName;
82     }
83     std::string GetVFName() {
84         return mVFName;
85     }
86     std::string GetOverlayName() {
87         return mOverlayName;
88     }
89     std::string GetFusionName() {
90         return mFusionName;
91     }
92
93     ///Switch between nearest neighbor and linear interpolation
94     void ToggleInterpolation();
95     vvSlicer* GetSlicer(int i);
96     void UpdateSlicer(int num, bool state);
97     void SetSlicerWindow(int i, vtkRenderWindow* RW);
98     void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
99     int NumberOfSlicers() {
100         return mSlicers.size();
101     }
102     vvImage::Pointer GetImage() {
103         return mImage;
104     }
105     vvImage::Pointer GetVF() {
106         return mVF;
107     }
108     int GetDimension() {
109         if (mImage) return mImage->GetNumberOfDimensions();
110         else return -1;
111     }
112
113     int GetType() {
114         return mType;
115     }
116
117     void SetId(std::string id) {
118         mId = id;
119     }
120     std::string GetId() {
121         return mId;
122     }
123
124     void SetFilename(std::string f) {
125         mFileName = f;
126     }
127
128     void SetTSlice(int slice);
129     void SetNextTSlice(int originating_slicer);
130     void SetPreviousTSlice(int originating_slicer);
131     void SetTSliceInSlicer(int tslice, int slicer);
132
133     void GenerateDefaultLookupTable();
134     void SetColorWindow(double s);
135     void SetColorLevel(double s);
136     void SetLocalColorWindowing(const int slicer);
137     void SetOpacity(int i, double factor);
138     void SetColorMap();
139     void SetColorMap(int colormap);
140     void SetPreset(int preset);
141     void SetOverlayColor(int color) {
142         mOverlayColor = color;
143     }
144     void SetFusionOpacity(int opacity) {
145         mFusionOpacity = opacity;
146     }
147     void SetFusionColorMap(int colorMap) {
148         mFusionColorMap = colorMap;
149     }
150     void SetFusionWindow(int window) {
151         mFusionWindow = window;
152     }
153     void SetFusionLevel(int level) {
154         mFusionLevel = level;
155     }
156
157     double GetColorWindow();
158     double GetColorLevel();
159     int GetColorMap() {
160         return mColorMap;
161     }
162     int GetPreset() {
163         return mPreset;
164     }
165     int GetOverlayColor() {
166         return mOverlayColor;
167     }
168
169     int GetFusionOpacity() {
170         return mFusionOpacity;
171     }
172     int GetFusionColorMap() {
173         return mFusionColorMap;
174     }
175     double GetFusionWindow() {
176         return mFusionWindow;
177     }
178     double GetFusionLevel() {
179         return mFusionLevel;
180     }
181
182     void SetCursorVisibility(int s);
183     void UpdateViews(int current, int slicer);
184     void UpdateLinked(int slicer);
185     void Render();
186
187     void AddLink(std::string newId) {
188         mLinkedId.push_back(newId);
189     }
190     void RemoveLink(std::string oldId) {
191         mLinkedId.remove(oldId);
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 UpdateInfoOnCursorPosition(int slicer);
204     void UpdateWindowLevel();
205     void UpdateSlice(int slicer);
206     void UpdateTSlice(int slicer);
207     void UpdateSliceRange(int slicer);
208
209     vvLandmarks *GetLandmarks();
210     void AddLandmark(float x,float y,float z,float t);
211
212 signals :
213     void currentImageChanged(std::string id);
214     void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
215     void UpdateVector(int display, double x, double y, double z, double value);
216     void UpdateOverlay(int display, double valueOver, double valueRef);
217     void UpdateFusion(int display, double valueFus);
218     void UpdateWindows(int slicer, int view, int slice);
219     void UpdateSlice(int slicer, int slice);
220     void UpdateTSlice(int slicer, int slice);
221     void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
222     void WindowLevelChanged(double window, double level, int preset, int colormap);
223     void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
224     void LandmarkAdded();
225
226 protected:
227     std::vector<vvSlicer*> mSlicers;
228     vvImageReader* mReader;
229     vvImageReader* mOverlayReader;
230     vvImageReader* mFusionReader;
231     vvImage::Pointer mImage;
232     vvImage::Pointer mVF;
233     vvImageReader* mVectorReader;
234     int mColorMap;
235     int mOverlayColor;
236
237     int mFusionOpacity;
238     int mFusionColorMap;
239     double mFusionWindow;
240     double mFusionLevel;
241
242     int mPreset;
243     LoadedImageType mType;
244     std::string mVFComponent;
245     std::string mOverlayComponent;
246     std::string mFusionComponent;
247     std::string mFileName;
248     std::string mId;
249     std::string mVFName;
250     std::string mOverlayName;
251     std::string mFusionName;
252     std::string mVFId;
253     std::string mLastError;
254     std::list<std::string> mLinkedId;
255
256     vvLandmarks* mLandmarks;
257 };
258
259 #endif