]> Creatis software - clitk.git/blob - vv/vvSlicerManager.h
- add "convert to" in context menu
[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
21 #include <iostream>
22 #include <vector>
23 #include <string>
24
25 // QT
26 #include <QObject>
27
28 // VTK
29 #include <vtksys/SystemTools.hxx>
30 class vtkImageData;
31 class vtkInteractorStyle;
32 class vtkRenderWindow;
33 class vtkPolyData;
34
35 // VV
36 #include "vvConstants.h"
37 #include "clitkCommon.h"
38 #include "vvImage.h"
39 #include "vvMesh.h"
40 class vvSlicer;
41 class vvInteractorStyleNavigator;
42 class vvImageReader;
43 class vvImageReader;
44 class vvLandmarks;
45
46 class vvSlicerManager : public QObject {
47     Q_OBJECT
48
49 public:
50     vvSlicerManager(int numberOfSlicers);
51     ~vvSlicerManager();
52
53     std::string GetLastError() {
54         return mLastError;
55     }
56
57     bool SetImage(std::string filename,LoadedImageType type);
58     void SetImage(vvImage::Pointer image);
59     void SetExtractedImage(std::string filename, vvImage::Pointer image, int slice);
60     bool SetImages(std::vector<std::string> filenames,LoadedImageType type);
61
62     bool SetOverlay(std::string filename, int dim, std::string component);
63     bool SetFusion(std::string filename, int dim, std::string component);
64     ///Set a VF by loading it from the disk
65     bool SetVF(std::string filename);
66     ///Set a VF from memory
67     bool SetVF(vvImage::Pointer vf,std::string filename);
68     ///Add a mesh to the slicers, with optional propagation using a vector field
69     void AddContour(vvMesh::Pointer ,bool propagate=false);
70     ///Toggle temporal superposition of contours
71     void ToggleContourSuperposition();
72
73     std::string GetFileName() {
74         return mFileName;
75     }
76     std::string GetVFName() {
77         return mVFName;
78     }
79     std::string GetOverlayName() {
80         return mOverlayName;
81     }
82     std::string GetFusionName() {
83         return mFusionName;
84     }
85
86     ///Switch between nearest neighbor and linear interpolation
87     void ToggleInterpolation();
88     vvSlicer* GetSlicer(int i);
89     void UpdateSlicer(int num, bool state);
90     void SetSlicerWindow(int i, vtkRenderWindow* RW);
91     void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
92     int NumberOfSlicers() {
93         return mSlicers.size();
94     }
95     vvImage::Pointer GetImage() {
96         return mImage;
97     }
98     vvImage::Pointer GetVF() {
99         return mVF;
100     }
101     int GetDimension() {
102         if (mImage) return mImage->GetNumberOfDimensions();
103         else return -1;
104     }
105
106     int GetType() {
107         return mType;
108     }
109
110     void SetId(std::string id) {
111         mId = id;
112     }
113     std::string GetId() {
114         return mId;
115     }
116
117     void SetFilename(std::string f);
118
119     void SetTSlice(int slice);
120     void SetNextTSlice(int originating_slicer);
121     void SetPreviousTSlice(int originating_slicer);
122     void SetTSliceInSlicer(int tslice, int slicer);
123
124     void GenerateDefaultLookupTable();
125     void SetColorWindow(double s);
126     void SetColorLevel(double s);
127     void SetLocalColorWindowing(const int slicer);
128     void SetOpacity(int i, double factor);
129     void SetColorMap();
130     void SetColorMap(int colormap);
131     void SetPreset(int preset);
132     void SetOverlayColor(int color) {
133         mOverlayColor = color;
134     }
135     void SetFusionOpacity(int opacity) {
136         mFusionOpacity = opacity;
137     }
138     void SetFusionColorMap(int colorMap) {
139         mFusionColorMap = colorMap;
140     }
141     void SetFusionWindow(int window) {
142         mFusionWindow = window;
143     }
144     void SetFusionLevel(int level) {
145         mFusionLevel = level;
146     }
147
148     double GetColorWindow();
149     double GetColorLevel();
150     int GetColorMap() {
151         return mColorMap;
152     }
153     int GetPreset() {
154         return mPreset;
155     }
156     int GetOverlayColor() {
157         return mOverlayColor;
158     }
159
160     int GetFusionOpacity() {
161         return mFusionOpacity;
162     }
163     int GetFusionColorMap() {
164         return mFusionColorMap;
165     }
166     double GetFusionWindow() {
167         return mFusionWindow;
168     }
169     double GetFusionLevel() {
170         return mFusionLevel;
171     }
172
173     void SetCursorVisibility(int s);
174     void UpdateViews(int current, int slicer);
175     void UpdateLinked(int slicer);
176     void Render();
177
178     void AddLink(std::string newId) {
179         mLinkedId.push_back(newId);
180     }
181     void RemoveLink(std::string oldId) {
182         mLinkedId.remove(oldId);
183     }
184
185     ///Remove the actor defined by its type and index (example: 3rd contour)
186     void RemoveActor(const std::string& actor_type, int overlay_index);
187     void RemoveActors();
188     void Reload();
189     void ReloadOverlay();
190     void ReloadFusion();
191     void ReloadVF();
192
193     void Activated();
194     void UpdateInfoOnCursorPosition(int slicer);
195     void UpdateWindowLevel();
196     void UpdateSlice(int slicer);
197     void UpdateTSlice(int slicer);
198     void UpdateSliceRange(int slicer);
199
200     vvLandmarks *GetLandmarks();
201     void AddLandmark(float x,float y,float z,float t);
202
203 signals :
204     void currentImageChanged(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 UpdateSlice(int slicer, int slice);
211     void UpdateTSlice(int slicer, int slice);
212     void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
213     void WindowLevelChanged(double window, double level, int preset, int colormap);
214     void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
215     void LandmarkAdded();
216
217 protected:
218     std::vector<vvSlicer*> mSlicers;
219     vvImageReader* mReader;
220     vvImageReader* mOverlayReader;
221     vvImageReader* mFusionReader;
222     vvImage::Pointer mImage;
223     vvImage::Pointer mVF;
224     vvImageReader* mVectorReader;
225     int mColorMap;
226     int mOverlayColor;
227
228     int mFusionOpacity;
229     int mFusionColorMap;
230     double mFusionWindow;
231     double mFusionLevel;
232
233     int mPreset;
234     LoadedImageType mType;
235     std::string mVFComponent;
236     std::string mOverlayComponent;
237     std::string mFusionComponent;
238     std::string mFileName;
239     std::string mId;
240     std::string mVFName;
241     std::string mOverlayName;
242     std::string mFusionName;
243     std::string mVFId;
244     std::string mLastError;
245     std::list<std::string> mLinkedId;
246
247     vvLandmarks* mLandmarks;
248 };
249
250 #endif