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 enum WindowLevelPreset {
62 //------------------------------------------------------------------------------
63 class vvSlicerManager : public QObject {
67 typedef enum {WORLD_SLICING, VOXELS_SLICING} SlicingPresetType;
68 vvSlicerManager(int numberOfSlicers);
71 std::string GetLastError() {
75 bool SetImage(std::string filename, vvImageReader::LoadedImageType type, int n=0, unsigned int slice=0);
76 void SetImage(vvImage::Pointer image);
77 bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0);
79 bool SetOverlay(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
80 bool SetFusion(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type);
81 bool SetFusionSequence(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
82 ///Set a VF by loading it from the disk
83 bool SetVF(std::string filename);
84 ///Set a VF from memory
85 bool SetVF(vvImage::Pointer vf,std::string filename);
86 ///Add a mesh to the slicers, with optional propagation using a vector field
87 void AddContour(vvMesh::Pointer ,bool propagate=false);
88 ///Toggle temporal superposition of contours
89 void ToggleContourSuperposition();
91 std::string GetFileName() { return mFileName; }
92 std::string GetBaseFileName() { return mBaseFileName; }
93 int GetBaseFileNameNumber() { return mBaseFileNameNumber; }
94 std::string GetVFName() { return mVFName; }
95 std::string GetOverlayName() { return mOverlayName; }
96 std::string GetFusionName() { return mFusionName; }
97 std::string GetListOfAbsoluteFilePathInOneString(const std::string &actorType);
99 ///Switch between nearest neighbor and linear interpolation
100 void ToggleInterpolation();
101 vvSlicer* GetSlicer(int i);
102 int GetSelectedSlicer() {
103 return mSelectedSlicer;
106 void UpdateSlicer(int num, bool state);
107 void SetSlicerWindow(int i, vtkRenderWindow* RW);
108 void SetInteractorStyleNavigator(int i,vtkInteractorStyle* style);
110 int GetNumberOfSlicers() { return mSlicers.size(); }
111 vvImage::Pointer GetImage() { return mImage; }
112 vvImage::Pointer GetVF() { return mVF; }
113 int GetType() { return mType; }
114 void SetId(std::string id) { mId = id; }
115 std::string GetId() const { return mId; }
117 if (mImage) return mImage->GetNumberOfDimensions();
121 void SetFilename(std::string f, int number=0);
123 void SetSliceOrientation(int slicer, int orientation);
125 void SetTSlice(int slice, bool updateLinkedImages = true);
126 void SetNextTSlice(int originating_slicer);
127 void SetPreviousTSlice(int originating_slicer);
128 void SetTSliceInSlicer(int tslice, int slicer);
130 void SetFusionSequenceTSlice(int slice);
132 void GenerateDefaultLookupTable();
133 void SetColorWindow(double s);
134 void SetColorLevel(double s);
135 void SetOverlayColorWindow(double s);
136 void SetOverlayColorLevel(double s);
137 void SetLinkOverlayWindowLevel(bool b);
138 void SetLocalColorWindowing(const int slicer, const bool bCtrlKey);
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/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component
145 void SetFusionOpacity(int opacity) {
146 mFusionOpacity = opacity;
148 void SetFusionThresholdOpacity(int thresOpacity) {
149 mFusionThresOpacity = thresOpacity;
151 void SetFusionColorMap(int colorMap) {
152 mFusionColorMap = colorMap;
154 void SetFusionWindow(double window) {
155 mFusionWindow = window;
157 void SetFusionLevel(double level) {
158 mFusionLevel = level;
160 void SetFusionShowLegend(int show) {
161 mFusionShowLegend = show;
165 //set/get fusionSequence related data
166 void SetFusionSequenceFrameIndex(int sequenceFrameIndex) { mFusionSequenceFrameIndex = sequenceFrameIndex; }
167 void SetFusionSequenceSpatialSyncFlag(bool spatialSync) { mFusionSequenceSpatialSyncFlag = spatialSync; }
168 void SetFusionSequenceTemporalSyncFlag(bool temporalSync) { mFusionSequenceTemporalSyncFlag = temporalSync; }
169 void SetFusionSequenceLength(unsigned int fusionSequenceNbFrames) { mFusionSequenceNbFrames = fusionSequenceNbFrames; }
170 void SetFusionSequenceMainTransformMatrix(vtkSmartPointer<vtkMatrix4x4> mat) {
171 mFusionSequenceMainTransform = vtkSmartPointer<vtkMatrix4x4>::New();
172 mFusionSequenceMainTransform->DeepCopy(mat);
174 void AddFusionSequenceInitialTransformMatrices(vtkSmartPointer<vtkMatrix4x4> mat) {
175 vtkSmartPointer<vtkMatrix4x4> tmpMat = vtkSmartPointer<vtkMatrix4x4>::New();
176 tmpMat->DeepCopy(mat);
177 mFusionSequenceListInitialTransformMatrices.push_back( tmpMat );
179 void SetFusionSequenceIndexOfLinkedManager(int index) { mFusionSequenceIndexLinkedManager = index; }
180 void SetFusionSequenceCorrespondances(std::vector<unsigned> s) { mFusionSequenceCorrespondances = s; }
182 void SetFusionSequenceInvolvmentCode(int code) { mFusionSequenceInvolvementCode=code; }
183 int GetFusionSequenceInvolvmentCode() { return mFusionSequenceInvolvementCode;}
184 bool IsInvolvedInFusionSequence() {return (!(mFusionSequenceInvolvementCode==-1));}
185 bool IsMainSequenceOfFusionSequence() {return (mFusionSequenceInvolvementCode==0);}
186 bool IsSecondarySequenceOfFusionSequence() {return (mFusionSequenceInvolvementCode==1);}
188 int GetFusionSequenceIndexOfLinkedManager() { return mFusionSequenceIndexLinkedManager; }
189 int GetFusionSequenceFrameIndex() { return mFusionSequenceFrameIndex; }
190 bool GetFusionSequenceSpatialSyncFlag() { return mFusionSequenceSpatialSyncFlag; }
191 bool GetFusionSequenceTemporalSyncFlag() { return mFusionSequenceTemporalSyncFlag; }
192 unsigned int GetFusionSequenceNbFrames() { return mFusionSequenceNbFrames; }
193 const vtkSmartPointer<vtkMatrix4x4>& GetFusionSequenceMainTransformMatrix() {return mFusionSequenceMainTransform;}
194 const std::vector< vtkSmartPointer<vtkMatrix4x4> >& GetFusionSequenceInitialTransformMatrices() {return mFusionSequenceListInitialTransformMatrices;}
195 const vtkSmartPointer<vtkMatrix4x4>& GetFusionSequenceInitialTransformMatrixAtFrame(unsigned i) {
196 return mFusionSequenceListInitialTransformMatrices[i];
198 const std::vector<unsigned>& GetFusionSequenceCorrespondances() {return mFusionSequenceCorrespondances;}
200 double GetColorWindow() const;
201 double GetColorLevel() const;
202 double GetOverlayColorWindow() const;
203 double GetOverlayColorLevel() const;
204 bool GetLinkOverlayWindowLevel() const;
208 int GetPreset() const {
211 SlicingPresetType GetSlicingPreset() {
212 return mSlicingPreset;
214 int GetOverlayColor() const {
215 return mOverlayColor;
217 int GetFusionOpacity() const {
218 return mFusionOpacity;
220 int GetFusionThresholdOpacity() const {
221 return mFusionThresOpacity;
223 int GetFusionColorMap() const {
224 return mFusionColorMap;
226 double GetFusionWindow() const {
227 return mFusionWindow;
229 double GetFusionLevel() const {
234 void SetCursorAndCornerAnnotationVisibility(int s);
235 void UpdateViews(int current, int slicer);
236 void UpdateLinked(int slicer);
237 void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
238 void ResetTransformationToIdentity(const std::string actorType);
241 void AddLink(std::string newId) {
242 mLinkedId.push_back(newId);
244 void RemoveLink(std::string oldId) {
245 mLinkedId.remove(oldId);
248 std::list<std::string> GetLinks() const {
253 return mLinkedId.size() > 0;
256 ///Remove the actor defined by its type and index (example: 3rd contour)
257 void RemoveActor(const std::string& actor_type, int overlay_index);
260 void ReloadOverlay();
262 void ReloadFusionSequence();
267 void UpdateInfoOnCursorPosition(int slicer);
268 void EmitMousePositionUpdated(int slicer);
269 void EmitKeyPressed(std::string keyPress);
270 void UpdateWindowLevel();
271 void UpdateSlice(int slicer);
272 void UpdateTSlice(int slicer);
273 void UpdateSliceRange(int slicer);
274 void SetSlicingPreset(SlicingPresetType preset);
276 vvLandmarks *GetLandmarks();
277 void AddNewLandmark(float x,float y,float z,float t);
278 void AddLandmarkProfile(float x,float y,float z,float t);
280 void NextImage(int slicer);
281 void PrevImage(int slicer);
282 void LeftButtonReleaseEvent(int slicer);
283 void VerticalSliderHasChanged(int slicer, int slice);
284 double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
287 void AddLandmark(float x,float y,float z,float t);
290 void callAddLandmark(float x,float y,float z,float t);
291 void currentImageChanged(std::string id);
292 void currentPickedImageChanged(std::string id);
293 void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
294 void UpdateVector(int display, double x, double y, double z, double value);
295 void UpdateOverlay(int display, double valueOver, double valueRef);
296 void UpdateFusion(int display, double valueFus);
297 void UpdateFusionSequence(int fusionSequenceFrameIndex, bool fusionSequenceSpatialSyncFlag, unsigned int fusionSequenceNbFrames);
298 void MousePositionUpdatedSignal(int slicer);
299 void KeyPressedSignal(std::string KeyPressed);
300 void UpdateOrientation(int slicer, int orientation);
301 void UpdateSlice(int slicer, int slice);
302 void UpdateTSlice(int slicer, int slice, int code);
303 void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax);
304 void WindowLevelChanged();
305 void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
306 void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*);
307 void LandmarkAdded();
308 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
309 void LeftButtonReleaseSignal(int slicer);
310 void AVerticalSliderHasChanged(int slicer, int slice);
313 std::vector< vtkSmartPointer<vvSlicer> > mSlicers;
315 vvImageReader::Pointer mReader;
316 vvImageReader::Pointer mOverlayReader;
317 vvImageReader::Pointer mFusionReader;
318 vvImageReader::Pointer mFusionSequenceReader;
319 vvImageReader::Pointer mVectorReader;
320 vvImage::Pointer mImage;
321 vvImage::Pointer mVF;
326 int mFusionThresOpacity;
328 double mFusionWindow;
330 bool mFusionShowLegend;
332 //Fusion of sequences related data
333 int mFusionSequenceInvolvementCode; //-1: not involved, 0: main sequence(CT), 1: secondary sequence (US)
334 int mFusionSequenceIndexLinkedManager; //index of the other sequence involved in the visualization
335 int mFusionSequenceFrameIndex; //temporal index of the current image in the sequence (<->TSlice)
336 unsigned int mFusionSequenceNbFrames; //number of frames in the temporal sequence
337 bool mFusionSequenceSpatialSyncFlag, mFusionSequenceTemporalSyncFlag; //flags indicating whether the spatial/temporal synchronization are actives
338 vtkSmartPointer<vtkMatrix4x4> mFusionSequenceMainTransform;
339 std::vector< vtkSmartPointer<vtkMatrix4x4> > mFusionSequenceListInitialTransformMatrices;
340 std::vector<unsigned> mFusionSequenceCorrespondances;
343 SlicingPresetType mSlicingPreset;
344 vvImageReader::LoadedImageType mType;
345 std::string mVFComponent;
346 std::string mOverlayComponent;
347 std::string mFusionComponent;
348 std::string mFileName;
349 std::string mBaseFileName;
350 int mBaseFileNameNumber;
353 std::string mOverlayName;
354 std::string mFusionName;
356 std::string mLastError;
357 std::list<std::string> mLinkedId;
359 vvLandmarks* mLandmarks;
361 std::vector<int> mPreviousSlice;
362 std::vector<int> mPreviousTSlice;