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