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