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