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 "ui_vvMainWindow.h"
26 #include "vvMainWindowBase.h"
27 #include "vvToolManager.h"
28 #include "vvImageReader.h"
30 #include "clitkMemoryUsage.h"
32 #include "vtkSmartPointer.h"
35 class vvSlicerManager;
37 class vvDocumentation;
38 class vtkRenderWindowInteractor;
42 class vvDicomSeriesSelector;
43 #if CLITK_USE_PACS_CONNECTION
44 class vvQPacsConnection;
49 //------------------------------------------------------------------------------
50 class vvMainWindow: public vvMainWindowBase,
51 private Ui::vvMainWindow
58 void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
59 vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
60 void AddField(QString file,int index);
61 bool CheckAddedImage(int index, QString imageType);
62 void AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
63 void AddFusionImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
64 void AddROI(int index, QString filename);
66 //Process the sequence for fusion:
67 void AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
69 void AddLandmarks(int index, std::vector<std::string>);
70 ///Adds a mesh to a SlicerManager, with optional warping by vector field
71 void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
72 ///This is used to show an image when opened or computed
74 void SaveCurrentStateAs(const std::string& stateFile);
75 void ReadSavedStateFile(const std::string& stateFile);
78 virtual void UpdateCurrentSlicer();
79 virtual QTabWidget * GetTab();
80 QTreeWidget* GetTree() { return DataTree; }
81 //vvMainWindowToolInfo * GetInfoForTool();
82 // void AddRunningTool(vvToolCreatorBase * tool);
85 ///Allows the user to open and select various surfaces contained in a dicom-struct file
86 void AddDCStructContour(int index, QString file);
87 void OpenDCStructContour();
88 ///Computes the midposition image of a 4D sequence with a VF and displays it
89 void ComputeMidPosition();
91 ///Slot triggered by the dynamically-generated recent file menu actions
92 void OpenRecentImage();
93 void OpenImageWithTime();
96 void MergeImagesWithTime();
98 #if CLITK_USE_PACS_CONNECTION
101 ///Open a vtkPolyData surface mesh and display it over the current image
102 void OpenVTKContour();
104 void SaveCurrentState();
105 void ReadSavedState();
106 void CurrentImageChanged(std::string id);
107 void CurrentPickedImageChanged(std::string id);
108 void ImageInfoChanged();
109 void ShowHelpDialog();
110 void ShowDocumentation();
111 void PopupRegisterForm(bool checkCanPush=false);
112 void ComputeDeformableRegistration();
114 void ChangeViewMode();
115 void DisplayChanged(QTreeWidgetItem *item, int column);
116 void CloseImage(QTreeWidgetItem* item, int column);
117 void ReloadImage(QTreeWidgetItem* item, int column);
118 void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
119 void VectorChanged(int visibility, double x, double y, double z, double value);
120 void OverlayChanged(int visibility, double valueOver, double valueRef);
121 void FusionChanged(int visibility, double value);
122 //void FusionSequenceChanged(int visibility, double value);
123 void SegmentationOnCurrentImage();
124 void SurfaceViewerLaunch();
126 void WindowLevelChanged();
127 void UpdateSlice(int slicer, int slice);
128 void UpdateTSlice(int slicer, int slice, int code=-1);
129 void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
130 void WindowLevelEdited();
131 void SetWindowLevel(double w, double l);
132 void UpdateColorMap();
133 void UpdateWindowLevel();
134 void UpdateSlicingPreset();
135 void SwitchWindowLevel();
136 void ApplyWindowLevelToAllImages();
137 void ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax);
138 void ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax);
139 void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
140 void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
141 void AddLink(QString image1,QString image2,bool fromPanel = true);
142 void RemoveLink(QString image1,QString image2);
143 void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
145 ///Generic method called when any one of the horizontal sliders is moved
146 void HorizontalSliderMoved(int value,int column, int slicer_index);
147 void NOHorizontalSliderMoved();
148 void NEHorizontalSliderMoved();
149 void SOHorizontalSliderMoved();
150 void SEHorizontalSliderMoved();
152 void NOVerticalSliderChanged();
153 void NEVerticalSliderChanged();
154 void SOVerticalSliderChanged();
155 void SEVerticalSliderChanged();
157 void SaveNEScreenshot();
158 void SaveNOScreenshot();
159 void SaveSEScreenshot();
160 void SaveSOScreenshot();
161 void SaveScreenshotAllSlices();
163 void ShowContextMenu(QPoint point);
167 void SelectOverlayImage();
168 void SelectFusionImage();
169 //select the file(s) from the disk containing the image sequence to fuse
170 void SelectFusionSequence();
171 void SelectFusionSequenceCorrespondances();
173 void ResetTransformationToIdentity();
175 void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
176 void SetOverlayProperty(int color, int linked, double window, double level);
177 void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
178 void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag);
184 void ChangeFrameRate(int rate) {
187 void UpdateRenderWindows();
188 void UpdateMemoryUsage();
193 void createRecentlyOpenedFilesMenu();
194 void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
196 // Drag and drop event handlers
197 virtual void dragEnterEvent(QDragEnterEvent *event);
198 virtual void dropEvent(QDropEvent *event);
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 void SaveScreenshot(QVTKWidget *widget);
231 int GetImageDuplicateFilenameNumber(std::string filename);
234 QMenu* recentlyOpenedFilesMenu;
235 //QMenu *AddSubImageMenu;
236 std::vector<QAction*> contextActions;
237 std::vector<QSlider*> horizontalSliders;
238 std::vector<QSlider*> verticalSliders;
241 std::string mCurrentSelectedImageId;
242 std::string mCurrentPickedImageId;
243 unsigned int mCurrentPickedImageIndex;
245 // vvMainWindowToolInfo * mCurrentToolInfo;
246 // std::vector<vvToolCreatorBase*> mListOfRunningTool;
248 static vvMainWindow * mSingleton;