]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
basic GUI state loading/saving functionality
[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 "ui_vvMainWindow.h"
25 #include "vvMainWindowBase.h"
26 #include "vvToolManager.h"
27 #include "vvImageReader.h"
28 #include "vvMesh.h"
29 #include "clitkMemoryUsage.h"
30
31 #include "vtkSmartPointer.h"
32
33
34 class vvSlicerManager;
35 class vvHelpDialog;
36 class vvDocumentation;
37 class vtkRenderWindowInteractor;
38 class vtkImageData;
39 class vtkRenderer;
40 class vtkMatrix4x4;
41 class vvDicomSeriesSelector;
42 class vvSlicer;
43 class QTreeWidget;
44
45 //------------------------------------------------------------------------------
46 class vvMainWindow: public vvMainWindowBase,
47                     private Ui::vvMainWindow
48 {
49   Q_OBJECT
50
51   public:
52   vvMainWindow();
53   ~vvMainWindow();
54   void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
55   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
56   void AddField(QString file,int index);
57   void AddOverlayImage(int index, QString filename);
58   void AddFusionImage(int index, QString filename);
59   void AddROI(int index, QString filename);
60   ///Adds a mesh to a SlicerManager, with optional warping by vector field
61   void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
62   ///This is used to show an image when opened or computed
63   void ShowLastImage();
64   void SaveCurrentStateAs(const std::string& stateFile);
65   void ReadSavedStateFile(const std::string& stateFile);
66
67   virtual void UpdateCurrentSlicer();
68   virtual QTabWidget * GetTab();
69   QTreeWidget* GetTree() { return DataTree; }
70   //vvMainWindowToolInfo * GetInfoForTool();
71 //   void AddRunningTool(vvToolCreatorBase * tool);
72
73 public slots:
74   ///Allows the user to open and select various surfaces contained in a dicom-struct file
75   void OpenDCStructContour();
76   ///Computes the midposition image of a 4D sequence with a VF and displays it
77   void ComputeMidPosition();
78   void OpenImages();
79   ///Slot triggered by the dynamically-generated recent file menu actions
80   void OpenRecentImage();
81   void OpenImageWithTime();
82   void MergeImages();
83   void SliceImages();
84   void MergeImagesWithTime();
85   void OpenDicom();
86   ///Open a vtkPolyData surface mesh and display it over the current image
87   void OpenVTKContour();
88   void SaveAs();
89   void SaveCurrentState();
90   void ReadSavedState();
91   void CurrentImageChanged(std::string id);
92   void CurrentPickedImageChanged(std::string id);
93   void ImageInfoChanged();
94   void ShowHelpDialog();
95   void ShowDocumentation();
96   void PopupRegisterForm(bool checkCanPush=false);
97   void ComputeDeformableRegistration();
98   void WarpImage();
99   void ChangeViewMode();
100   void DisplayChanged(QTreeWidgetItem *item, int column);
101   void CloseImage(QTreeWidgetItem* item, int column);
102   void ReloadImage(QTreeWidgetItem* item, int column);
103   void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
104   void VectorChanged(int visibility, double x, double y, double z, double value);
105   void OverlayChanged(int visibility, double valueOver, double valueRef);
106   void FusionChanged(int visibility, double value);
107   void SegmentationOnCurrentImage();
108   void SurfaceViewerLaunch();
109
110   void WindowLevelChanged();
111   void UpdateSlice(int slicer, int slice);
112   void UpdateTSlice(int slicer, int slice);
113   void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
114   void WindowLevelEdited();
115   void SetWindowLevel(double w, double l);
116   void UpdateColorMap();
117   void UpdateWindowLevel();
118   void SwitchWindowLevel();
119   void ApplyWindowLevelToAllImages();
120   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
121   void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
122   void AddLink(QString image1,QString image2);
123   void RemoveLink(QString image1,QString image2);
124   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
125
126   ///Generic method called when any one of the horizontal sliders is moved
127   void HorizontalSliderMoved(int value,int column, int slicer_index);
128   void NOHorizontalSliderMoved();
129   void NEHorizontalSliderMoved();
130   void SOHorizontalSliderMoved();
131   void SEHorizontalSliderMoved();
132
133   void NOVerticalSliderChanged();
134   void NEVerticalSliderChanged();
135   void SOVerticalSliderChanged();
136   void SEVerticalSliderChanged();
137
138   void SaveNEScreenshot();
139   void SaveNOScreenshot();
140   void SaveSEScreenshot();
141   void SaveSOScreenshot();
142   void SaveScreenshotAllSlices();
143
144   void ShowContextMenu(QPoint point);
145   void CloseImage();
146   void ReloadImage();
147   void OpenField();
148   void SelectOverlayImage();
149   void SelectFusionImage();
150   void ResetTransformationToIdentity();
151
152   void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
153   void SetOverlayProperty(int color, int linked, double window, double level);
154   void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level);
155
156   void GoToCursor();
157   void PlayPause();
158   void PlayNext();
159   void ChangeFrameRate(int rate) {
160     mFrameRate = rate;
161   }
162   void UpdateRenderWindows();
163   void UpdateMemoryUsage();
164   void show();
165   
166 protected:
167   
168   void createRecentlyOpenedFilesMenu();
169   void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
170   
171 private:
172
173   //variables
174   // std::vector<vvSlicerManager*> mSlicerManagers;
175   vvHelpDialog *help_dialog;
176   vvDocumentation *documentation;
177   vvDicomSeriesSelector *dicomSeriesSelector;
178
179   bool viewMode;
180   bool playMode;
181
182   //functions
183   void UpdateTree();
184   ///Adds a vector field to slicer manager index
185   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
186   void AddFieldEntry(QString filename,int index,bool from_disk);
187   void AddField(vvImage::Pointer vf,QString file,int index);
188   void InitDisplay();
189   ///Sets the render window and LUT for the last SlicerManager
190   void InitSlicers();
191   void DisplaySliders(int slicer, int window);
192   QString GetSizeInBytes(unsigned long size);
193   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
194   QString GetVectorIntAsString(std::vector<int> vectorInt);
195   QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix);
196   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
197   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
198   void SaveScreenshot(QVTKWidget *widget);
199   int GetImageDuplicateFilenameNumber(std::string filename);
200
201   QMenu contextMenu;
202   QMenu* recentlyOpenedFilesMenu;
203   //QMenu *AddSubImageMenu;
204   std::vector<QAction*> contextActions;
205   std::vector<QSlider*> horizontalSliders;
206   std::vector<QSlider*> verticalSliders;
207   int mFrameRate;
208   
209   std::string mCurrentSelectedImageId;
210   std::string mCurrentPickedImageId;
211   unsigned int mCurrentPickedImageIndex;
212
213   // vvMainWindowToolInfo * mCurrentToolInfo;
214   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
215
216   static vvMainWindow * mSingleton;
217
218   int mCurrentTime;
219   
220 };
221
222 #endif