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;
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 SelectWipeImage();
169 void SelectFusionImage();
170 //select the file(s) from the disk containing the image sequence to fuse
171 void SelectFusionSequence();
172 void SelectFusionSequenceCorrespondances();
174 void ResetTransformationToIdentity();
176 void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
177 void SetOverlayProperty(int color, int linked, double window, double level);
178 void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
179 void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag);
185 void ChangeFrameRate(int rate) {
188 void UpdateRenderWindows();
189 void UpdateMemoryUsage();
192 static vvMainWindow* Instance(){return mSingleton;}
196 void createRecentlyOpenedFilesMenu();
197 void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
202 // std::vector<vvSlicerManager*> mSlicerManagers;
203 vvHelpDialog *help_dialog;
204 vvDocumentation *documentation;
205 vvDicomSeriesSelector *dicomSeriesSelector;
207 vvWipeImage::Pointer mWipeImage;
209 #if CLITK_USE_PACS_CONNECTION
210 vvQPacsConnection *PacsConnection;
218 ///Adds a vector field to slicer manager index
219 void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
220 void AddFieldEntry(QString filename,int index,bool from_disk);
221 void AddField(vvImage::Pointer vf,QString file,int index);
223 ///Sets the render window and LUT for the last SlicerManager
225 void DisplaySliders(int slicer, int window);
226 QString GetSizeInBytes(unsigned long size);
227 QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
228 QString GetVectorIntAsString(std::vector<int> vectorInt);
229 int GetSlicerIndexFromItem(QTreeWidgetItem* item); //this actually returns the SlicerManager index TODO: rename it to GetSlicerManagerIndexFromItem
230 QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
231 void SaveScreenshot(QVTKWidget *widget);
232 int GetImageDuplicateFilenameNumber(std::string filename);
235 QMenu* recentlyOpenedFilesMenu;
236 //QMenu *AddSubImageMenu;
237 std::vector<QAction*> contextActions;
238 std::vector<QSlider*> horizontalSliders;
239 std::vector<QSlider*> verticalSliders;
242 std::string mCurrentSelectedImageId;
243 std::string mCurrentPickedImageId;
244 unsigned int mCurrentPickedImageIndex;
246 // vvMainWindowToolInfo * mCurrentToolInfo;
247 // std::vector<vvToolCreatorBase*> mListOfRunningTool;
249 static vvMainWindow* mSingleton;