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