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