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