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, QString filename);
58 void AddFusionImage(int index, QString filename);
59 void AddROI(int index, QString filename);
60 ///Adds a mesh to a SlicerManager, with optional warping by vector field
61 void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
62 ///This is used to show an image when opened or computed
64 void SaveCurrentStateAs(const std::string& stateFile);
65 void ReadSavedStateFile(const std::string& stateFile);
68 virtual void UpdateCurrentSlicer();
69 virtual QTabWidget * GetTab();
70 QTreeWidget* GetTree() { return DataTree; }
71 //vvMainWindowToolInfo * GetInfoForTool();
72 // void AddRunningTool(vvToolCreatorBase * tool);
75 ///Allows the user to open and select various surfaces contained in a dicom-struct file
76 void OpenDCStructContour();
77 ///Computes the midposition image of a 4D sequence with a VF and displays it
78 void ComputeMidPosition();
80 ///Slot triggered by the dynamically-generated recent file menu actions
81 void OpenRecentImage();
82 void OpenImageWithTime();
85 void MergeImagesWithTime();
87 ///Open a vtkPolyData surface mesh and display it over the current image
88 void OpenVTKContour();
90 void SaveCurrentState();
91 void ReadSavedState();
92 void CurrentImageChanged(std::string id);
93 void CurrentPickedImageChanged(std::string id);
94 void ImageInfoChanged();
95 void ShowHelpDialog();
96 void ShowDocumentation();
97 void PopupRegisterForm(bool checkCanPush=false);
98 void ComputeDeformableRegistration();
100 void ChangeViewMode();
101 void DisplayChanged(QTreeWidgetItem *item, int column);
102 void CloseImage(QTreeWidgetItem* item, int column);
103 void ReloadImage(QTreeWidgetItem* item, int column);
104 void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
105 void VectorChanged(int visibility, double x, double y, double z, double value);
106 void OverlayChanged(int visibility, double valueOver, double valueRef);
107 void FusionChanged(int visibility, double value);
108 void SegmentationOnCurrentImage();
109 void SurfaceViewerLaunch();
111 void WindowLevelChanged();
112 void UpdateSlice(int slicer, int slice);
113 void UpdateTSlice(int slicer, int slice);
114 void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
115 void WindowLevelEdited();
116 void SetWindowLevel(double w, double l);
117 void UpdateColorMap();
118 void UpdateWindowLevel();
119 void SwitchWindowLevel();
120 void ApplyWindowLevelToAllImages();
121 void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
122 void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
123 void AddLink(QString image1,QString image2);
124 void RemoveLink(QString image1,QString image2);
125 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
127 ///Generic method called when any one of the horizontal sliders is moved
128 void HorizontalSliderMoved(int value,int column, int slicer_index);
129 void NOHorizontalSliderMoved();
130 void NEHorizontalSliderMoved();
131 void SOHorizontalSliderMoved();
132 void SEHorizontalSliderMoved();
134 void NOVerticalSliderChanged();
135 void NEVerticalSliderChanged();
136 void SOVerticalSliderChanged();
137 void SEVerticalSliderChanged();
139 void SaveNEScreenshot();
140 void SaveNOScreenshot();
141 void SaveSEScreenshot();
142 void SaveSOScreenshot();
143 void SaveScreenshotAllSlices();
145 void ShowContextMenu(QPoint point);
149 void SelectOverlayImage();
150 void SelectFusionImage();
151 void ResetTransformationToIdentity();
153 void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
154 void SetOverlayProperty(int color, int linked, double window, double level);
155 void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level);
160 void ChangeFrameRate(int rate) {
163 void UpdateRenderWindows();
164 void UpdateMemoryUsage();
169 void createRecentlyOpenedFilesMenu();
170 void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
175 // std::vector<vvSlicerManager*> mSlicerManagers;
176 vvHelpDialog *help_dialog;
177 vvDocumentation *documentation;
178 vvDicomSeriesSelector *dicomSeriesSelector;
185 ///Adds a vector field to slicer manager index
186 void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
187 void AddFieldEntry(QString filename,int index,bool from_disk);
188 void AddField(vvImage::Pointer vf,QString file,int index);
190 ///Sets the render window and LUT for the last SlicerManager
192 void DisplaySliders(int slicer, int window);
193 QString GetSizeInBytes(unsigned long size);
194 QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
195 QString GetVectorIntAsString(std::vector<int> vectorInt);
196 QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix);
197 int GetSlicerIndexFromItem(QTreeWidgetItem* item);
198 QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
199 void SaveScreenshot(QVTKWidget *widget);
200 int GetImageDuplicateFilenameNumber(std::string filename);
203 QMenu* recentlyOpenedFilesMenu;
204 //QMenu *AddSubImageMenu;
205 std::vector<QAction*> contextActions;
206 std::vector<QSlider*> horizontalSliders;
207 std::vector<QSlider*> verticalSliders;
210 std::string mCurrentSelectedImageId;
211 std::string mCurrentPickedImageId;
212 unsigned int mCurrentPickedImageIndex;
214 // vvMainWindowToolInfo * mCurrentToolInfo;
215 // std::vector<vvToolCreatorBase*> mListOfRunningTool;
217 static vvMainWindow * mSingleton;