]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
- binarize tool
[clitk.git] / vv / vvMainWindow.h
1 /*=========================================================================
2
3  Program:   vv
4  Language:  C++
5  Author :   Pierre Seroul (pierre.seroul@gmail.com)
6
7 Copyright (C) 2008
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20   You should have received a copy of the GNU General Public License
21   along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23   =========================================================================*/
24
25 #ifndef vvMainWindow_h
26 #define vvMainWindow_h
27
28 #include <iostream>
29 #include <vector>
30
31 #include "ui_vvMainWindow.h"
32
33 #include "vvConstants.h"
34 #include "vvImage.h"
35 #include "vvMesh.h"
36 #include "vvToolManager.h"
37 #include "clitkCommon.h"
38
39 class vvSlicerManager;
40 class vvHelpDialog;
41 class vvDocumentation;
42 class vtkRenderWindowInteractor;
43 class vtkImageData;
44 class vtkRenderer;
45 class vvDicomSeriesSelector;
46
47 //------------------------------------------------------------------------------
48 struct vvMainWindowToolInfo {
49   QMenu * mMenuTools;
50   std::vector<vvSlicerManager*> * mSlicerManagers;
51   int mSlicerManagerCurrentIndex;
52 };
53 //------------------------------------------------------------------------------
54
55
56 //------------------------------------------------------------------------------
57 class vvMainWindow : public QMainWindow, private Ui::vvMainWindow
58 {
59   Q_OBJECT
60
61   public:
62   vvMainWindow();
63   ~vvMainWindow();
64   void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
65   void AddImage(vvImage::Pointer image,std::string filename);
66   void AddImage(vvSlicerManager * m);
67   void AddField(QString file,int index);
68   void AddOverlayImage(int index, QString filename);
69   ///Adds a mesh to a SlicerManager, with optional warping by vector field
70   void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
71   ///This is used to show an image when opened or computed
72   void ShowLastImage();
73
74   vvMainWindowToolInfo * GetInfoForTool();
75
76 public slots:
77   ///Allows the user to open and select various surfaces contained in a dicom-struct file
78   void OpenDCStructContour();
79   ///Computes the MIP of the currently selected image and displays it
80   void ComputeMIP();
81   ///Computes the midposition image of a 4D sequence with a VF and displays it
82   void ComputeMidPosition();
83   void OpenImages();
84   ///Slot triggered by the dynamically-generated recent file menu actions
85   void OpenRecentImage();
86   void OpenImageWithTime();
87   void MergeImages();
88   void MergeImagesWithTime();
89   void OpenDicom();
90   ///Open a vtkPolyData surface mesh and display it over the current image
91   void OpenVTKContour();
92   void SaveAs();
93   void CurrentImageChanged(std::string id);
94   void ImageInfoChanged();
95   void ShowHelpDialog();
96   void ShowDocumentation();
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 ResampleCurrentImage();
108   void SegmentationOnCurrentImage();
109   void SurfaceViewerLaunch();
110
111   void WindowsChanged(int window, int view, int slice);
112   void WindowLevelChanged(double window, double level,int preset, int colormap);
113   void UpdateSlice(int slicer, int slice);
114   void UpdateTSlice(int slicer, int slice);
115   void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
116   void WindowLevelEdited();
117   void UpdateColorMap();
118   void UpdateWindowLevel();
119   void SwitchWindowLevel();
120   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
121   void AddLink(QString image1,QString image2);
122   void RemoveLink(QString image1,QString image2);
123
124   ///Generic method called when any one of the horizontal sliders is moved
125   void HorizontalSliderMoved(int value,int column, int slicer_index);
126   void NOHorizontalSliderMoved();
127   void NEHorizontalSliderMoved();
128   void SOHorizontalSliderMoved();
129   void SEHorizontalSliderMoved();
130
131   void NOVerticalSliderChanged();
132   void NEVerticalSliderChanged();
133   void SOVerticalSliderChanged();
134   void SEVerticalSliderChanged();
135
136   void SaveNEScreenshot();
137   void SaveNOScreenshot();
138   void SaveSEScreenshot();
139   void SaveSOScreenshot();
140
141   void ShowContextMenu(QPoint point);
142   void CropImage();
143   void SplitImage();
144   void CloseImage();
145   void ReloadImage();
146   void OpenField();
147   void SelectOverlayImage();
148   void AddFusionImage();
149
150   void SetVFProperty(int subsampling,int scale,int lut);
151   void SetOverlayProperty(int color);
152   void SetFusionProperty(int opacity,int colormap,double window,double level);
153
154   void GoToCursor();
155   void PlayPause();
156   void PlayNext();
157   void ChangeFrameRate(int rate) {
158     mFrameRate = rate;
159   }
160   void UpdateRenderWindows();
161
162 // signals:
163 //   void SlicerManagersHasChanged();
164
165 private:
166
167   //variables
168   std::vector<vvSlicerManager*> mSlicerManagers;
169   vvHelpDialog *help_dialog;
170   vvDocumentation *documentation;
171   vvDicomSeriesSelector *dicomSeriesSelector;
172
173   QString mInputPathName;
174   bool viewMode;
175   bool playMode;
176
177   //functions
178   void UpdateTree();
179   ///Adds a vector field to slicer manager index
180   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
181   void AddFieldEntry(QString filename,int index,bool from_disk);
182   void AddField(vvImage::Pointer vf,QString file,int index);
183   void InitDisplay();
184   ///Sets the render window and LUT for the last SlicerManager
185   void InitSlicers();
186   void DisplaySliders(int slicer, int window);
187   QString GetSizeInBytes(unsigned long size);
188   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
189   QString GetVectorIntAsString(std::vector<int> vectorInt);
190   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
191   void SaveScreenshot(vtkImageData* image);
192
193   QMenu contextMenu;
194   //QMenu *AddSubImageMenu;
195   std::vector<QAction*> contextActions;
196   std::vector<QSlider*> horizontalSliders;
197   std::vector<QSlider*> verticalSliders;
198   int mFrameRate;
199
200   vvMainWindowToolInfo * mCurrentToolInfo;
201
202   static vvMainWindow * mSingleton;
203 };
204
205 #include "vvMainWindow.txx"
206
207 #endif