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