2 /*=========================================================================
3 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
6 - University of LYON http://www.universite-lyon.fr/
7 - Léon Bérard cancer center http://www.centreleonberard.fr
8 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the copyright notices for more information.
14 It is distributed under dual licence
16 - BSD See included LICENSE.txt file
17 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
18 ===========================================================================**/
20 #ifndef VVSLICERMANAGER_H
21 #define VVSLICERMANAGER_H
32 #include <vtksys/SystemTools.hxx>
34 class vtkInteractorStyle;
35 class vtkRenderWindow;
39 #include "clitkCommon.h"
42 #include "vvImageReader.h"
45 class vvInteractorStyleNavigator;
50 //------------------------------------------------------------------------------
51 class vvSlicerManager : public QObject {
55 typedef enum {WORLD_SLICING, VOXELS_SLICING} SlicingPresetType;
56 vvSlicerManager(int numberOfSlicers);
59 std::string GetLastError() {
63 bool SetImage(std::string filename, vvImageReader::LoadedImageType type, int n=0, unsigned int slice=0);
64 void SetImage(vvImage::Pointer image);
65 bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0);
67 bool SetOverlay(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
68 bool SetFusion(std::string filename, int dim, std::string component);
69 bool SetFusionSequence(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
70 ///Set a VF by loading it from the disk
71 bool SetVF(std::string filename);
72 ///Set a VF from memory
73 bool SetVF(vvImage::Pointer vf,std::string filename);
74 ///Add a mesh to the slicers, with optional propagation using a vector field
75 void AddContour(vvMesh::Pointer ,bool propagate=false);
76 ///Toggle temporal superposition of contours
77 void ToggleContourSuperposition();
79 std::string GetFileName() { return mFileName; }
80 std::string GetBaseFileName() { return mBaseFileName; }
81 int GetBaseFileNameNumber() { return mBaseFileNameNumber; }
82 std::string GetVFName() { return mVFName; }
83 std::string GetOverlayName() { return mOverlayName; }
84 std::string GetFusionName() { return mFusionName; }
85 std::string GetListOfAbsoluteFilePathInOneString(const std::string &actorType);
87 ///Switch between nearest neighbor and linear interpolation
88 void ToggleInterpolation();
89 vvSlicer* GetSlicer(int i);
90 int GetSelectedSlicer() {
91 return mSelectedSlicer;
94 void UpdateSlicer(int num, bool state);
95 void SetSlicerWindow(int i, vtkRenderWindow* RW);
96 void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
98 int GetNumberOfSlicers() { return mSlicers.size(); }
99 vvImage::Pointer GetImage() { return mImage; }
100 vvImage::Pointer GetVF() { return mVF; }
101 int GetType() { return mType; }
102 void SetId(std::string id) { mId = id; }
103 std::string GetId() const { return mId; }
105 if (mImage) return mImage->GetNumberOfDimensions();
109 void SetFilename(std::string f, int number=0);
111 void SetSliceOrientation(int slicer, int orientation);
113 void SetTSlice(int slice);
114 void SetNextTSlice(int originating_slicer);
115 void SetPreviousTSlice(int originating_slicer);
116 void SetTSliceInSlicer(int tslice, int slicer);
118 void SetFusionSequenceTSlice(int slice);
120 void GenerateDefaultLookupTable();
121 void SetColorWindow(double s);
122 void SetColorLevel(double s);
123 void SetOverlayColorWindow(double s);
124 void SetOverlayColorLevel(double s);
125 void SetLinkOverlayWindowLevel(bool b);
126 void SetLocalColorWindowing(const int slicer, const bool bCtrlKey);
127 void SetOpacity(int i, double factor);
128 void SetColorMap(int colormap);
129 void SetPreset(int preset);
130 void SetOverlayColor(int color) {
131 mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
133 void SetFusionOpacity(int opacity) {
134 mFusionOpacity = opacity;
136 void SetFusionThresholdOpacity(int thresOpacity) {
137 mFusionThresOpacity = thresOpacity;
139 void SetFusionColorMap(int colorMap) {
140 mFusionColorMap = colorMap;
142 void SetFusionWindow(double window) {
143 mFusionWindow = window;
145 void SetFusionLevel(double level) {
146 mFusionLevel = level;
148 void SetFusionShowLegend(int show) {
149 mFusionShowLegend = show;
153 //set/get fusionSequence related data
154 void SetFusionSequenceFrameIndex(int sequenceFrameIndex) { mFusionSequenceFrameIndex = sequenceFrameIndex; }
155 void SetFusionSequenceSpatialSyncFlag(bool spatialSync) { mFusionSequenceSpatialSyncFlag = spatialSync; }
156 void SetFusionSequenceLength(unsigned int fusionSequenceNbFrames) { mFusionSequenceNbFrames = fusionSequenceNbFrames; }
157 void SetFusionSequenceMainTransformMatrix(vtkSmartPointer<vtkMatrix4x4> mat) {
158 mFusionSequenceMainTransform = vtkSmartPointer<vtkMatrix4x4>::New();
159 mFusionSequenceMainTransform->DeepCopy(mat);
161 void AddFusionSequenceInitialTransformMatrices(vtkSmartPointer<vtkMatrix4x4> mat) {
162 vtkSmartPointer<vtkMatrix4x4> tmpMat = vtkSmartPointer<vtkMatrix4x4>::New();
163 tmpMat->DeepCopy(mat);
164 mFusionSequenceListInitialTransformMatrices.push_back( tmpMat );
167 int GetFusionSequenceFrameIndex() { return mFusionSequenceFrameIndex; }
168 bool GetFusionSequenceSpatialSyncFlag() { return mFusionSequenceSpatialSyncFlag; }
169 unsigned int GetFusionSequenceNbFrames() { return mFusionSequenceNbFrames; }
170 const vtkSmartPointer<vtkMatrix4x4>& GetFusionSequenceMainTransformMatrix() {return mFusionSequenceMainTransform;}
171 const std::vector< vtkSmartPointer<vtkMatrix4x4> >& GetFusionSequenceInitialTransformMatrices() {return mFusionSequenceListInitialTransformMatrices;}
172 const vtkSmartPointer<vtkMatrix4x4>& GetFusionSequenceInitialTransformMatrixAtFrame(unsigned i) {
173 return mFusionSequenceListInitialTransformMatrices[i];
176 double GetColorWindow() const;
177 double GetColorLevel() const;
178 double GetOverlayColorWindow() const;
179 double GetOverlayColorLevel() const;
180 bool GetLinkOverlayWindowLevel() const;
184 int GetPreset() const {
187 SlicingPresetType GetSlicingPreset() {
188 return mSlicingPreset;
190 int GetOverlayColor() const {
191 return mOverlayColor;
193 int GetFusionOpacity() const {
194 return mFusionOpacity;
196 int GetFusionThresholdOpacity() const {
197 return mFusionThresOpacity;
199 int GetFusionColorMap() const {
200 return mFusionColorMap;
202 double GetFusionWindow() const {
203 return mFusionWindow;
205 double GetFusionLevel() const {
210 void SetCursorAndCornerAnnotationVisibility(int s);
211 void UpdateViews(int current, int slicer);
212 void UpdateLinked(int slicer);
213 void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
214 void ResetTransformationToIdentity(const std::string actorType);
217 void AddLink(std::string newId) {
218 mLinkedId.push_back(newId);
220 void RemoveLink(std::string oldId) {
221 mLinkedId.remove(oldId);
224 std::list<std::string> GetLinks() const {
229 return mLinkedId.size() > 0;
232 ///Remove the actor defined by its type and index (example: 3rd contour)
233 void RemoveActor(const std::string& actor_type, int overlay_index);
236 void ReloadOverlay();
238 void ReloadFusionSequence();
243 void UpdateInfoOnCursorPosition(int slicer);
244 void EmitMousePositionUpdated(int slicer);
245 void EmitKeyPressed(std::string keyPress);
246 void UpdateWindowLevel();
247 void UpdateSlice(int slicer);
248 void UpdateTSlice(int slicer);
249 void UpdateSliceRange(int slicer);
250 void SetSlicingPreset(SlicingPresetType preset);
252 vvLandmarks *GetLandmarks();
253 void AddLandmark(float x,float y,float z,float t);
255 void NextImage(int slicer);
256 void PrevImage(int slicer);
257 void LeftButtonReleaseEvent(int slicer);
258 void VerticalSliderHasChanged(int slicer, int slice);
259 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
262 void currentImageChanged(std::string id);
263 void currentPickedImageChanged(std::string id);
264 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
265 void UpdateVector(int display, double x, double y, double z, double value);
266 void UpdateOverlay(int display, double valueOver, double valueRef);
267 void UpdateFusion(int display, double valueFus);
268 void UpdateFusionSequence(int fusionSequenceFrameIndex, bool fusionSequenceSpatialSyncFlag, unsigned int fusionSequenceNbFrames);
269 void MousePositionUpdatedSignal(int slicer);
270 void KeyPressedSignal(std::string KeyPressed);
271 void UpdateOrientation(int slicer, int orientation);
272 void UpdateSlice(int slicer, int slice);
273 void UpdateTSlice(int slicer, int slice);
274 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
275 void WindowLevelChanged();
276 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
277 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
278 void LandmarkAdded();
279 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
280 void LeftButtonReleaseSignal(int slicer);
281 void AVerticalSliderHasChanged(int slicer, int slice);
284 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
286 vvImageReader::Pointer mReader;
287 vvImageReader::Pointer mOverlayReader;
288 vvImageReader::Pointer mFusionReader;
289 vvImageReader::Pointer mFusionSequenceReader;
290 vvImageReader::Pointer mVectorReader;
291 vvImage::Pointer mImage;
292 vvImage::Pointer mVF;
297 int mFusionThresOpacity;
299 double mFusionWindow;
301 bool mFusionShowLegend;
303 //fusionSequence related data
304 int mFusionSequenceFrameIndex;
305 bool mFusionSequenceSpatialSyncFlag;
306 unsigned int mFusionSequenceNbFrames;
307 vtkSmartPointer<vtkMatrix4x4> mFusionSequenceMainTransform;
308 std::vector< vtkSmartPointer<vtkMatrix4x4> > mFusionSequenceListInitialTransformMatrices;
311 SlicingPresetType mSlicingPreset;
312 vvImageReader::LoadedImageType mType;
313 std::string mVFComponent;
314 std::string mOverlayComponent;
315 std::string mFusionComponent;
316 std::string mFileName;
317 std::string mBaseFileName;
318 int mBaseFileNameNumber;
321 std::string mOverlayName;
322 std::string mFusionName;
324 std::string mLastError;
325 std::list<std::string> mLinkedId;
327 vvLandmarks* mLandmarks;
329 std::vector<int> mPreviousSlice;
330 std::vector<int> mPreviousTSlice;