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 "vtkVersion.h"
25 #if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9
26 #include "ui_vvMainWindow.h"
28 #include "ui_vvMainWindowVTK7.h"
30 #include "vvMainWindowBase.h"
31 #include "vvToolManager.h"
32 #include "vvImageReader.h"
34 #include "clitkMemoryUsage.h"
36 #include "vtkSmartPointer.h"
39 class vvSlicerManager;
41 class vvDocumentation;
42 class vtkRenderWindowInteractor;
46 class vvDicomSeriesSelector;
47 #if CLITK_USE_PACS_CONNECTION
48 class vvQPacsConnection;
53 //------------------------------------------------------------------------------
54 class vvMainWindow: public vvMainWindowBase,
55 private Ui::vvMainWindow
62 void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
63 vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
64 void AddField(QString file,int index);
65 bool CheckAddedImage(int index, QString imageType);
66 void AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
67 void AddFusionImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
68 void AddROI(int index, QString filename);
70 //Process the sequence for fusion:
71 void AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
73 void AddLandmarks(int index, std::vector<std::string>);
74 ///Adds a mesh to a SlicerManager, with optional warping by vector field
75 void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
76 ///This is used to show an image when opened or computed
78 void SaveCurrentStateAs(const std::string& stateFile);
79 void ReadSavedStateFile(const std::string& stateFile);
82 virtual void UpdateCurrentSlicer();
83 virtual QTabWidget * GetTab();
84 QTreeWidget* GetTree() { return DataTree; }
85 //vvMainWindowToolInfo * GetInfoForTool();
86 // void AddRunningTool(vvToolCreatorBase * tool);
89 ///Allows the user to open and select various surfaces contained in a dicom-struct file
90 void AddDCStructContour(int index, QString file);
91 void OpenDCStructContour();
92 ///Computes the midposition image of a 4D sequence with a VF and displays it
93 void ComputeMidPosition();
95 ///Slot triggered by the dynamically-generated recent file menu actions
96 void OpenRecentImage();
97 void OpenImageWithTime();
100 void MergeImagesWithTime();
102 #if CLITK_USE_PACS_CONNECTION
105 ///Open a vtkPolyData surface mesh and display it over the current image
106 void OpenVTKContour();
108 void SaveCurrentState();
109 void ReadSavedState();
110 void CurrentImageChanged(std::string id);
111 void CurrentPickedImageChanged(std::string id);
112 void ImageInfoChanged();
113 void ShowHelpDialog();
114 void ShowDocumentation();
115 void PopupRegisterForm(bool checkCanPush=false);
116 void ComputeDeformableRegistration();
118 void ChangeViewMode();
119 void DisplayChanged(QTreeWidgetItem *item, int column);
120 void CloseImage(QTreeWidgetItem* item, int column);
121 void ReloadImage(QTreeWidgetItem* item, int column);
122 void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
123 void VectorChanged(int visibility, double x, double y, double z, double value);
124 void OverlayChanged(int visibility, double valueOver, double valueRef);
125 void FusionChanged(int visibility, double value);
126 //void FusionSequenceChanged(int visibility, double value);
127 void SegmentationOnCurrentImage();
128 void SurfaceViewerLaunch();
130 void WindowLevelChanged();
131 void UpdateSlice(int slicer, int slice);
132 void UpdateTSlice(int slicer, int slice, int code=-1);
133 void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
134 void WindowLevelEdited();
135 void SetWindowLevel(double w, double l);
136 void UpdateColorMap();
137 void UpdateWindowLevel();
138 void UpdateSlicingPreset();
139 void SwitchWindowLevel();
140 void ApplyWindowLevelToAllImages();
141 void ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax);
142 void ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax);
143 void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
144 void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
145 void AddLink(QString image1,QString image2,bool fromPanel = true);
146 void RemoveLink(QString image1,QString image2);
147 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
149 ///Generic method called when any one of the horizontal sliders is moved
150 void HorizontalSliderMoved(int value,int column, int slicer_index);
151 void NOHorizontalSliderMoved();
152 void NEHorizontalSliderMoved();
153 void SOHorizontalSliderMoved();
154 void SEHorizontalSliderMoved();
156 void NOVerticalSliderChanged();
157 void NEVerticalSliderChanged();
158 void SOVerticalSliderChanged();
159 void SEVerticalSliderChanged();
161 void SaveNEScreenshot();
162 void SaveNOScreenshot();
163 void SaveSEScreenshot();
164 void SaveSOScreenshot();
165 void SaveScreenshotAllSlices();
167 void ShowContextMenu(QPoint point);
171 void SelectOverlayImage();
172 void SelectFusionImage();
173 //select the file(s) from the disk containing the image sequence to fuse
174 void SelectFusionSequence();
175 void SelectFusionSequenceCorrespondances();
177 void ResetTransformationToIdentity();
179 void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
180 void SetOverlayProperty(int color, int linked, double window, double level);
181 void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
182 void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag);
188 void ChangeFrameRate(int rate) {
191 void UpdateRenderWindows();
192 void UpdateMemoryUsage();
197 void createRecentlyOpenedFilesMenu();
198 void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
203 // std::vector<vvSlicerManager*> mSlicerManagers;
204 vvHelpDialog *help_dialog;
205 vvDocumentation *documentation;
206 vvDicomSeriesSelector *dicomSeriesSelector;
208 #if CLITK_USE_PACS_CONNECTION
209 vvQPacsConnection *PacsConnection;
217 ///Adds a vector field to slicer manager index
218 void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
219 void AddFieldEntry(QString filename,int index,bool from_disk);
220 void AddField(vvImage::Pointer vf,QString file,int index);
222 ///Sets the render window and LUT for the last SlicerManager
224 void DisplaySliders(int slicer, int window);
225 QString GetSizeInBytes(unsigned long size);
226 QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
227 QString GetVectorIntAsString(std::vector<int> vectorInt);
228 int GetSlicerIndexFromItem(QTreeWidgetItem* item); //this actually returns the SlicerManager index TODO: rename it to GetSlicerManagerIndexFromItem
229 QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
230 #if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9
231 void SaveScreenshot(QVTKOpenGLNativeWidget *widget);
233 void SaveScreenshot(QVTKWidget *widget);
235 int GetImageDuplicateFilenameNumber(std::string filename);
238 QMenu* recentlyOpenedFilesMenu;
239 //QMenu *AddSubImageMenu;
240 std::vector<QAction*> contextActions;
241 std::vector<QSlider*> horizontalSliders;
242 std::vector<QSlider*> verticalSliders;
245 std::string mCurrentSelectedImageId;
246 std::string mCurrentPickedImageId;
247 unsigned int mCurrentPickedImageIndex;
249 // vvMainWindowToolInfo * mCurrentToolInfo;
250 // std::vector<vvToolCreatorBase*> mListOfRunningTool;
252 static vvMainWindow * mSingleton;