1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef VVMAINWINDOW_H
20 #define VVMAINWINDOW_H
24 #include "ui_vvMainWindow.h"
25 #include "vvMainWindowBase.h"
26 #include "vvToolManager.h"
27 #include "vvImageReader.h"
29 #include "clitkMemoryUsage.h"
31 #include "vtkSmartPointer.h"
34 class vvSlicerManager;
36 class vvDocumentation;
37 class vtkRenderWindowInteractor;
41 class vvDicomSeriesSelector;
45 //------------------------------------------------------------------------------
46 class vvMainWindow: public vvMainWindowBase,
47 private Ui::vvMainWindow
54 void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
55 vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
56 void AddField(QString file,int index);
57 void AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
58 void AddFusionImage(int index, QString filename);
59 void AddROI(int index, QString filename);
60 //Process the sequence for fusion:
61 void AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
63 ///Adds a mesh to a SlicerManager, with optional warping by vector field
64 void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
65 ///This is used to show an image when opened or computed
67 void SaveCurrentStateAs(const std::string& stateFile);
68 void ReadSavedStateFile(const std::string& stateFile);
70 QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix, const int precision=3);
72 virtual void UpdateCurrentSlicer();
73 virtual QTabWidget * GetTab();
74 QTreeWidget* GetTree() { return DataTree; }
75 //vvMainWindowToolInfo * GetInfoForTool();
76 // void AddRunningTool(vvToolCreatorBase * tool);
79 ///Allows the user to open and select various surfaces contained in a dicom-struct file
80 void AddDCStructContour(int index, QString file);
81 void OpenDCStructContour();
82 ///Computes the midposition image of a 4D sequence with a VF and displays it
83 void ComputeMidPosition();
85 ///Slot triggered by the dynamically-generated recent file menu actions
86 void OpenRecentImage();
87 void OpenImageWithTime();
90 void MergeImagesWithTime();
92 ///Open a vtkPolyData surface mesh and display it over the current image
93 void OpenVTKContour();
95 void SaveCurrentState();
96 void ReadSavedState();
97 void CurrentImageChanged(std::string id);
98 void CurrentPickedImageChanged(std::string id);
99 void ImageInfoChanged();
100 void ShowHelpDialog();
101 void ShowDocumentation();
102 void PopupRegisterForm(bool checkCanPush=false);
103 void ComputeDeformableRegistration();
105 void ChangeViewMode();
106 void DisplayChanged(QTreeWidgetItem *item, int column);
107 void CloseImage(QTreeWidgetItem* item, int column);
108 void ReloadImage(QTreeWidgetItem* item, int column);
109 void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
110 void VectorChanged(int visibility, double x, double y, double z, double value);
111 void OverlayChanged(int visibility, double valueOver, double valueRef);
112 void FusionChanged(int visibility, double value);
113 //void FusionSequenceChanged(int visibility, double value);
114 void SegmentationOnCurrentImage();
115 void SurfaceViewerLaunch();
117 void WindowLevelChanged();
118 void UpdateSlice(int slicer, int slice);
119 void UpdateTSlice(int slicer, int slice);
120 void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
121 void WindowLevelEdited();
122 void SetWindowLevel(double w, double l);
123 void UpdateColorMap();
124 void UpdateWindowLevel();
125 void UpdateSlicingPreset();
126 void SwitchWindowLevel();
127 void ApplyWindowLevelToAllImages();
128 void ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax);
129 void ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax);
130 void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
131 void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
132 void AddLink(QString image1,QString image2,bool fromPanel = true);
133 void RemoveLink(QString image1,QString image2);
134 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
136 ///Generic method called when any one of the horizontal sliders is moved
137 void HorizontalSliderMoved(int value,int column, int slicer_index);
138 void NOHorizontalSliderMoved();
139 void NEHorizontalSliderMoved();
140 void SOHorizontalSliderMoved();
141 void SEHorizontalSliderMoved();
143 void NOVerticalSliderChanged();
144 void NEVerticalSliderChanged();
145 void SOVerticalSliderChanged();
146 void SEVerticalSliderChanged();
148 void SaveNEScreenshot();
149 void SaveNOScreenshot();
150 void SaveSEScreenshot();
151 void SaveSOScreenshot();
152 void SaveScreenshotAllSlices();
154 void ShowContextMenu(QPoint point);
158 void SelectOverlayImage();
159 void SelectFusionImage();
160 //select the file(s) from the disk containing the image sequence to fuse
161 void SelectFusionSequence();
163 void ResetTransformationToIdentity();
165 void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
166 void SetOverlayProperty(int color, int linked, double window, double level);
167 void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
168 void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames);
173 void ChangeFrameRate(int rate) {
176 void UpdateRenderWindows();
177 void UpdateMemoryUsage();
182 void createRecentlyOpenedFilesMenu();
183 void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
188 // std::vector<vvSlicerManager*> mSlicerManagers;
189 vvHelpDialog *help_dialog;
190 vvDocumentation *documentation;
191 vvDicomSeriesSelector *dicomSeriesSelector;
198 ///Adds a vector field to slicer manager index
199 void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
200 void AddFieldEntry(QString filename,int index,bool from_disk);
201 void AddField(vvImage::Pointer vf,QString file,int index);
203 ///Sets the render window and LUT for the last SlicerManager
205 void DisplaySliders(int slicer, int window);
206 QString GetSizeInBytes(unsigned long size);
207 QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
208 QString GetVectorIntAsString(std::vector<int> vectorInt);
209 int GetSlicerIndexFromItem(QTreeWidgetItem* item);
210 QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
211 void SaveScreenshot(QVTKWidget *widget);
212 int GetImageDuplicateFilenameNumber(std::string filename);
215 QMenu* recentlyOpenedFilesMenu;
216 //QMenu *AddSubImageMenu;
217 std::vector<QAction*> contextActions;
218 std::vector<QSlider*> horizontalSliders;
219 std::vector<QSlider*> verticalSliders;
222 std::string mCurrentSelectedImageId;
223 std::string mCurrentPickedImageId;
224 unsigned int mCurrentPickedImageIndex;
226 // vvMainWindowToolInfo * mCurrentToolInfo;
227 // std::vector<vvToolCreatorBase*> mListOfRunningTool;
229 static vvMainWindow * mSingleton;