]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
Remove verbose for travis
[clitk.git] / vv / vvMainWindow.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
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
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18
19 #ifndef VVMAINWINDOW_H
20 #define VVMAINWINDOW_H
21
22 #include <iostream>
23 #include <vector>
24 #include "vtkVersion.h"
25 #if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9
26 #include "ui_vvMainWindow.h"
27 #else
28 #include "ui_vvMainWindowVTK7.h"
29 #endif
30 #include "vvMainWindowBase.h"
31 #include "vvToolManager.h"
32 #include "vvImageReader.h"
33 #include "vvMesh.h"
34 #include "clitkMemoryUsage.h"
35
36 #include "vtkSmartPointer.h"
37
38
39 class vvSlicerManager;
40 class vvHelpDialog;
41 class vvDocumentation;
42 class vtkRenderWindowInteractor;
43 class vtkImageData;
44 class vtkRenderer;
45 class vtkMatrix4x4;
46 class vvDicomSeriesSelector;
47 #if CLITK_USE_PACS_CONNECTION
48 class vvQPacsConnection;
49 #endif
50 class vvSlicer;
51 class QTreeWidget;
52
53 //------------------------------------------------------------------------------
54 class vvMainWindow: public vvMainWindowBase,
55                     private Ui::vvMainWindow
56 {
57   Q_OBJECT
58
59   public:
60   vvMainWindow();
61   ~vvMainWindow();
62   void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
63   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
64   void AddField(QString file,int index);
65   bool CheckAddedImage(int index, QString imageType);
66   void AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
67   void AddFusionImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
68   void AddROI(int index, QString filename);
69
70   //Process the sequence for fusion:
71   void AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
72
73   void AddLandmarks(int index, std::vector<std::string>);
74 ///Adds a mesh to a SlicerManager, with optional warping by vector field
75   void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
76   ///This is used to show an image when opened or computed
77   void ShowLastImage();
78   void SaveCurrentStateAs(const std::string& stateFile);
79   void ReadSavedStateFile(const std::string& stateFile);
80         void LinkAllImages();
81
82   virtual void UpdateCurrentSlicer();
83   virtual QTabWidget * GetTab();
84   QTreeWidget* GetTree() { return DataTree; }
85   //vvMainWindowToolInfo * GetInfoForTool();
86 //   void AddRunningTool(vvToolCreatorBase * tool);
87
88 public slots:
89   ///Allows the user to open and select various surfaces contained in a dicom-struct file
90   void AddDCStructContour(int index, QString file);
91   void OpenDCStructContour();
92   ///Computes the midposition image of a 4D sequence with a VF and displays it
93   void ComputeMidPosition();
94   void OpenImages();
95   ///Slot triggered by the dynamically-generated recent file menu actions
96   void OpenRecentImage();
97   void OpenImageWithTime();
98   void MergeImages();
99   void SliceImages();
100   void MergeImagesWithTime();
101   void OpenDicom();
102 #if CLITK_USE_PACS_CONNECTION
103   void ConnectPacs();
104 #endif
105   ///Open a vtkPolyData surface mesh and display it over the current image
106   void OpenVTKContour();
107   void SaveAs();
108   void SaveCurrentState();
109   void ReadSavedState();
110   void CurrentImageChanged(std::string id);
111   void CurrentPickedImageChanged(std::string id);
112   void ImageInfoChanged();
113   void ShowHelpDialog();
114   void ShowDocumentation();
115   void PopupRegisterForm(bool checkCanPush=false);
116   void ComputeDeformableRegistration();
117   void WarpImage();
118   void ChangeViewMode();
119   void DisplayChanged(QTreeWidgetItem *item, int column);
120   void CloseImage(QTreeWidgetItem* item, int column);
121   void ReloadImage(QTreeWidgetItem* item, int column);
122   void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
123   void VectorChanged(int visibility, double x, double y, double z, double value);
124   void OverlayChanged(int visibility, double valueOver, double valueRef);
125   void FusionChanged(int visibility, double value);
126   //void FusionSequenceChanged(int visibility, double value);
127   void SegmentationOnCurrentImage();
128   void SurfaceViewerLaunch();
129
130   void WindowLevelChanged();
131   void UpdateSlice(int slicer, int slice);
132   void UpdateTSlice(int slicer, int slice, int code=-1);
133   void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
134   void WindowLevelEdited();
135   void SetWindowLevel(double w, double l);
136   void UpdateColorMap();
137   void UpdateWindowLevel();
138   void UpdateSlicingPreset();
139   void SwitchWindowLevel();
140   void ApplyWindowLevelToAllImages();
141   void ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax);
142   void ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax);
143   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
144   void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
145   void AddLink(QString image1,QString image2,bool fromPanel = true);
146   void RemoveLink(QString image1,QString image2);
147   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
148
149   ///Generic method called when any one of the horizontal sliders is moved
150   void HorizontalSliderMoved(int value,int column, int slicer_index);
151   void NOHorizontalSliderMoved();
152   void NEHorizontalSliderMoved();
153   void SOHorizontalSliderMoved();
154   void SEHorizontalSliderMoved();
155
156   void NOVerticalSliderChanged();
157   void NEVerticalSliderChanged();
158   void SOVerticalSliderChanged();
159   void SEVerticalSliderChanged();
160
161   void SaveNEScreenshot();
162   void SaveNOScreenshot();
163   void SaveSEScreenshot();
164   void SaveSOScreenshot();
165   void SaveScreenshotAllSlices();
166
167   void ShowContextMenu(QPoint point);
168   void CloseImage();
169   void ReloadImage();
170   void OpenField();
171   void SelectOverlayImage();
172   void SelectFusionImage();
173   //select the file(s) from the disk containing the image sequence to fuse
174   void SelectFusionSequence();
175   void SelectFusionSequenceCorrespondances();
176
177   void ResetTransformationToIdentity();
178
179   void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
180   void SetOverlayProperty(int color, int linked, double window, double level);
181   void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
182   void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag);
183
184   void GoToCursor();
185   void GoToLandmark();
186   void PlayPause();
187   void PlayNext();
188   void ChangeFrameRate(int rate) {
189     mFrameRate = rate;
190   }
191   void UpdateRenderWindows();
192   void UpdateMemoryUsage();
193   void show();
194   
195 protected:
196   
197   void createRecentlyOpenedFilesMenu();
198   void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
199   
200 private:
201
202   //variables
203   // std::vector<vvSlicerManager*> mSlicerManagers;
204   vvHelpDialog *help_dialog;
205   vvDocumentation *documentation;
206   vvDicomSeriesSelector *dicomSeriesSelector;
207
208 #if CLITK_USE_PACS_CONNECTION
209   vvQPacsConnection *PacsConnection;
210 #endif
211
212   bool viewMode;
213   bool playMode;
214
215   //functions
216   void UpdateTree();
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);
221   void InitDisplay();
222   ///Sets the render window and LUT for the last SlicerManager
223   void InitSlicers();
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 #if (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) || VTK_MAJOR_VERSION >= 9
231   void SaveScreenshot(QVTKOpenGLNativeWidget *widget);
232 #else
233   void SaveScreenshot(QVTKWidget *widget);
234 #endif
235   int GetImageDuplicateFilenameNumber(std::string filename);
236
237   QMenu contextMenu;
238   QMenu* recentlyOpenedFilesMenu;
239   //QMenu *AddSubImageMenu;
240   std::vector<QAction*> contextActions;
241   std::vector<QSlider*> horizontalSliders;
242   std::vector<QSlider*> verticalSliders;
243   int mFrameRate;
244   
245   std::string mCurrentSelectedImageId;
246   std::string mCurrentPickedImageId;
247   unsigned int mCurrentPickedImageIndex;
248
249   // vvMainWindowToolInfo * mCurrentToolInfo;
250   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
251
252   static vvMainWindow * mSingleton;
253
254   int mCurrentTime;
255   
256 };
257
258 #endif