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);
75 QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix, const int precision=3);
77 virtual void UpdateCurrentSlicer();
78 virtual QTabWidget * GetTab();
79 QTreeWidget* GetTree() { return DataTree; }
80 //vvMainWindowToolInfo * GetInfoForTool();
81 // void AddRunningTool(vvToolCreatorBase * tool);
84 ///Allows the user to open and select various surfaces contained in a dicom-struct file
85 void AddDCStructContour(int index, QString file);
86 void OpenDCStructContour();
87 ///Computes the midposition image of a 4D sequence with a VF and displays it
88 void ComputeMidPosition();
90 ///Slot triggered by the dynamically-generated recent file menu actions
91 void OpenRecentImage();
92 void OpenImageWithTime();
95 void MergeImagesWithTime();
97 #ifdef CLITK_USE_PACS_CONNECTION
100 ///Open a vtkPolyData surface mesh and display it over the current image
101 void OpenVTKContour();
103 void SaveCurrentState();
104 void ReadSavedState();
105 void CurrentImageChanged(std::string id);
106 void CurrentPickedImageChanged(std::string id);
107 void ImageInfoChanged();
108 void ShowHelpDialog();
109 void ShowDocumentation();
110 void PopupRegisterForm(bool checkCanPush=false);
111 void ComputeDeformableRegistration();
113 void ChangeViewMode();
114 void DisplayChanged(QTreeWidgetItem *item, int column);
115 void CloseImage(QTreeWidgetItem* item, int column);
116 void ReloadImage(QTreeWidgetItem* item, int column);
117 void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
118 void VectorChanged(int visibility, double x, double y, double z, double value);
119 void OverlayChanged(int visibility, double valueOver, double valueRef);
120 void FusionChanged(int visibility, double value);
121 //void FusionSequenceChanged(int visibility, double value);
122 void SegmentationOnCurrentImage();
123 void SurfaceViewerLaunch();
125 void WindowLevelChanged();
126 void UpdateSlice(int slicer, int slice);
127 void UpdateTSlice(int slicer, int slice, int code=-1);
128 void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
129 void WindowLevelEdited();
130 void SetWindowLevel(double w, double l);
131 void UpdateColorMap();
132 void UpdateWindowLevel();
133 void UpdateSlicingPreset();
134 void SwitchWindowLevel();
135 void ApplyWindowLevelToAllImages();
136 void ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax);
137 void ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax);
138 void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
139 void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
140 void AddLink(QString image1,QString image2,bool fromPanel = true);
141 void RemoveLink(QString image1,QString image2);
142 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
144 ///Generic method called when any one of the horizontal sliders is moved
145 void HorizontalSliderMoved(int value,int column, int slicer_index);
146 void NOHorizontalSliderMoved();
147 void NEHorizontalSliderMoved();
148 void SOHorizontalSliderMoved();
149 void SEHorizontalSliderMoved();
151 void NOVerticalSliderChanged();
152 void NEVerticalSliderChanged();
153 void SOVerticalSliderChanged();
154 void SEVerticalSliderChanged();
156 void SaveNEScreenshot();
157 void SaveNOScreenshot();
158 void SaveSEScreenshot();
159 void SaveSOScreenshot();
160 void SaveScreenshotAllSlices();
162 void ShowContextMenu(QPoint point);
166 void SelectOverlayImage();
167 void SelectFusionImage();
168 //select the file(s) from the disk containing the image sequence to fuse
169 void SelectFusionSequence();
170 void SelectFusionSequenceCorrespondances();
172 void ResetTransformationToIdentity();
174 void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
175 void SetOverlayProperty(int color, int linked, double window, double level);
176 void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
177 void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag);
183 void ChangeFrameRate(int rate) {
186 void UpdateRenderWindows();
187 void UpdateMemoryUsage();
192 void createRecentlyOpenedFilesMenu();
193 void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
198 // std::vector<vvSlicerManager*> mSlicerManagers;
199 vvHelpDialog *help_dialog;
200 vvDocumentation *documentation;
201 vvDicomSeriesSelector *dicomSeriesSelector;
203 #ifdef CLITK_USE_PACS_CONNECTION
204 vvQPacsConnection *PacsConnection;
212 ///Adds a vector field to slicer manager index
213 void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
214 void AddFieldEntry(QString filename,int index,bool from_disk);
215 void AddField(vvImage::Pointer vf,QString file,int index);
217 ///Sets the render window and LUT for the last SlicerManager
219 void DisplaySliders(int slicer, int window);
220 QString GetSizeInBytes(unsigned long size);
221 QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
222 QString GetVectorIntAsString(std::vector<int> vectorInt);
223 int GetSlicerIndexFromItem(QTreeWidgetItem* item); //this actually returns the SlicerManager index TODO: rename it to GetSlicerManagerIndexFromItem
224 QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
225 void SaveScreenshot(QVTKWidget *widget);
226 int GetImageDuplicateFilenameNumber(std::string filename);
229 QMenu* recentlyOpenedFilesMenu;
230 //QMenu *AddSubImageMenu;
231 std::vector<QAction*> contextActions;
232 std::vector<QSlider*> horizontalSliders;
233 std::vector<QSlider*> verticalSliders;
236 std::string mCurrentSelectedImageId;
237 std::string mCurrentPickedImageId;
238 unsigned int mCurrentPickedImageIndex;
240 // vvMainWindowToolInfo * mCurrentToolInfo;
241 // std::vector<vvToolCreatorBase*> mListOfRunningTool;
243 static vvMainWindow * mSingleton;