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, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
59 void AddROI(int index, QString filename);
61 //Process the sequence for fusion:
62 void AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
64 void AddLandmarks(int index, std::vector<std::string>);
65 ///Adds a mesh to a SlicerManager, with optional warping by vector field
66 void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
67 ///This is used to show an image when opened or computed
69 void SaveCurrentStateAs(const std::string& stateFile);
70 void ReadSavedStateFile(const std::string& stateFile);
73 virtual void UpdateCurrentSlicer();
74 virtual QTabWidget * GetTab();
75 QTreeWidget* GetTree() { return DataTree; }
76 //vvMainWindowToolInfo * GetInfoForTool();
77 // void AddRunningTool(vvToolCreatorBase * tool);
80 ///Allows the user to open and select various surfaces contained in a dicom-struct file
81 void AddDCStructContour(int index, QString file);
82 void OpenDCStructContour();
83 ///Computes the midposition image of a 4D sequence with a VF and displays it
84 void ComputeMidPosition();
86 ///Slot triggered by the dynamically-generated recent file menu actions
87 void OpenRecentImage();
88 void OpenImageWithTime();
91 void MergeImagesWithTime();
93 ///Open a vtkPolyData surface mesh and display it over the current image
94 void OpenVTKContour();
96 void SaveCurrentState();
97 void ReadSavedState();
98 void CurrentImageChanged(std::string id);
99 void CurrentPickedImageChanged(std::string id);
100 void ImageInfoChanged();
101 void ShowHelpDialog();
102 void ShowDocumentation();
103 void PopupRegisterForm(bool checkCanPush=false);
104 void ComputeDeformableRegistration();
106 void ChangeViewMode();
107 void DisplayChanged(QTreeWidgetItem *item, int column);
108 void CloseImage(QTreeWidgetItem* item, int column);
109 void ReloadImage(QTreeWidgetItem* item, int column);
110 void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
111 void VectorChanged(int visibility, double x, double y, double z, double value);
112 void OverlayChanged(int visibility, double valueOver, double valueRef);
113 void FusionChanged(int visibility, double value);
114 //void FusionSequenceChanged(int visibility, double value);
115 void SegmentationOnCurrentImage();
116 void SurfaceViewerLaunch();
118 void WindowLevelChanged();
119 void UpdateSlice(int slicer, int slice);
120 void UpdateTSlice(int slicer, int slice, int code=-1);
121 void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
122 void WindowLevelEdited();
123 void SetWindowLevel(double w, double l);
124 void UpdateColorMap();
125 void UpdateWindowLevel();
126 void UpdateSlicingPreset();
127 void SwitchWindowLevel();
128 void ApplyWindowLevelToAllImages();
129 void ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax);
130 void ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax);
131 void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
132 void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
133 void AddLink(QString image1,QString image2,bool fromPanel = true);
134 void RemoveLink(QString image1,QString image2);
135 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
137 ///Generic method called when any one of the horizontal sliders is moved
138 void HorizontalSliderMoved(int value,int column, int slicer_index);
139 void NOHorizontalSliderMoved();
140 void NEHorizontalSliderMoved();
141 void SOHorizontalSliderMoved();
142 void SEHorizontalSliderMoved();
144 void NOVerticalSliderChanged();
145 void NEVerticalSliderChanged();
146 void SOVerticalSliderChanged();
147 void SEVerticalSliderChanged();
149 void SaveNEScreenshot();
150 void SaveNOScreenshot();
151 void SaveSEScreenshot();
152 void SaveSOScreenshot();
153 void SaveScreenshotAllSlices();
155 void ShowContextMenu(QPoint point);
159 void SelectOverlayImage();
160 void SelectFusionImage();
161 //select the file(s) from the disk containing the image sequence to fuse
162 void SelectFusionSequence();
163 void SelectFusionSequenceCorrespondances();
165 void ResetTransformationToIdentity();
167 void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
168 void SetOverlayProperty(int color, int linked, double window, double level);
169 void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
170 void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag);
176 void ChangeFrameRate(int rate) {
179 void UpdateRenderWindows();
180 void UpdateMemoryUsage();
185 void createRecentlyOpenedFilesMenu();
186 void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
191 // std::vector<vvSlicerManager*> mSlicerManagers;
192 vvHelpDialog *help_dialog;
193 vvDocumentation *documentation;
194 vvDicomSeriesSelector *dicomSeriesSelector;
201 ///Adds a vector field to slicer manager index
202 void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
203 void AddFieldEntry(QString filename,int index,bool from_disk);
204 void AddField(vvImage::Pointer vf,QString file,int index);
206 ///Sets the render window and LUT for the last SlicerManager
208 void DisplaySliders(int slicer, int window);
209 QString GetSizeInBytes(unsigned long size);
210 QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
211 QString GetVectorIntAsString(std::vector<int> vectorInt);
212 int GetSlicerIndexFromItem(QTreeWidgetItem* item); //this actually returns the SlicerManager index TODO: rename it to GetSlicerManagerIndexFromItem
213 QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
214 void SaveScreenshot(QVTKWidget *widget);
215 int GetImageDuplicateFilenameNumber(std::string filename);
218 QMenu* recentlyOpenedFilesMenu;
219 //QMenu *AddSubImageMenu;
220 std::vector<QAction*> contextActions;
221 std::vector<QSlider*> horizontalSliders;
222 std::vector<QSlider*> verticalSliders;
225 std::string mCurrentSelectedImageId;
226 std::string mCurrentPickedImageId;
227 unsigned int mCurrentPickedImageIndex;
229 // vvMainWindowToolInfo * mCurrentToolInfo;
230 // std::vector<vvToolCreatorBase*> mListOfRunningTool;
232 static vvMainWindow * mSingleton;