]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
- autotool
[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 #include "vvMainWindowBase.h"
33 #include "vvToolManager.h"
34 #include "vvConstants.h"
35 #include "vvMesh.h"
36
37 class vvSlicerManager;
38 class vvHelpDialog;
39 class vvDocumentation;
40 class vtkRenderWindowInteractor;
41 class vtkImageData;
42 class vtkRenderer;
43 class vvDicomSeriesSelector;
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, LoadedImageType type);
55   void AddImage(vvImage::Pointer image,std::string filename);
56   void AddImage(vvSlicerManager * m);
57   void AddField(QString file,int index);
58   void AddOverlayImage(int index, QString filename);
59   ///Adds a mesh to a SlicerManager, with optional warping by vector field
60   void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
61   ///This is used to show an image when opened or computed
62   void ShowLastImage();
63
64   virtual void UpdateCurrentSlicer();
65   //vvMainWindowToolInfo * GetInfoForTool();
66 //   void AddRunningTool(vvToolCreatorBase * tool);
67
68 public slots:
69   ///Allows the user to open and select various surfaces contained in a dicom-struct file
70   void OpenDCStructContour();
71   ///Computes the MIP of the currently selected image and displays it
72   void ComputeMIP();
73   ///Computes the midposition image of a 4D sequence with a VF and displays it
74   void ComputeMidPosition();
75   void OpenImages();
76   ///Slot triggered by the dynamically-generated recent file menu actions
77   void OpenRecentImage();
78   void OpenImageWithTime();
79   void MergeImages();
80   void MergeImagesWithTime();
81   void OpenDicom();
82   ///Open a vtkPolyData surface mesh and display it over the current image
83   void OpenVTKContour();
84   void SaveAs();
85   void CurrentImageChanged(std::string id);
86   void ImageInfoChanged();
87   void ShowHelpDialog();
88   void ShowDocumentation();
89   void ComputeDeformableRegistration();
90   void WarpImage();
91   void ChangeViewMode();
92   void DisplayChanged(QTreeWidgetItem *item, int column);
93   void CloseImage(QTreeWidgetItem* item, int column);
94   void ReloadImage(QTreeWidgetItem* item, int column);
95   void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
96   void VectorChanged(int visibility, double x, double y, double z, double value);
97   void OverlayChanged(int visibility, double valueOver, double valueRef);
98   void FusionChanged(int visibility, double value);
99   void ResampleCurrentImage();
100   void SegmentationOnCurrentImage();
101   void SurfaceViewerLaunch();
102
103   void WindowsChanged(int window, int view, int slice);
104   void WindowLevelChanged(double window, double level,int preset, int colormap);
105   void UpdateSlice(int slicer, int slice);
106   void UpdateTSlice(int slicer, int slice);
107   void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
108   void WindowLevelEdited();
109   void UpdateColorMap();
110   void UpdateWindowLevel();
111   void SwitchWindowLevel();
112   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
113   void AddLink(QString image1,QString image2);
114   void RemoveLink(QString image1,QString image2);
115
116   ///Generic method called when any one of the horizontal sliders is moved
117   void HorizontalSliderMoved(int value,int column, int slicer_index);
118   void NOHorizontalSliderMoved();
119   void NEHorizontalSliderMoved();
120   void SOHorizontalSliderMoved();
121   void SEHorizontalSliderMoved();
122
123   void NOVerticalSliderChanged();
124   void NEVerticalSliderChanged();
125   void SOVerticalSliderChanged();
126   void SEVerticalSliderChanged();
127
128   void SaveNEScreenshot();
129   void SaveNOScreenshot();
130   void SaveSEScreenshot();
131   void SaveSOScreenshot();
132
133   void ShowContextMenu(QPoint point);
134   //  void CropImage();
135   void SplitImage();
136   void CloseImage();
137   void ReloadImage();
138   void OpenField();
139   void SelectOverlayImage();
140   void AddFusionImage();
141
142   void SetVFProperty(int subsampling,int scale,int lut);
143   void SetOverlayProperty(int color);
144   void SetFusionProperty(int opacity,int colormap,double window,double level);
145
146   void GoToCursor();
147   void PlayPause();
148   void PlayNext();
149   void ChangeFrameRate(int rate) {
150     mFrameRate = rate;
151   }
152   void UpdateRenderWindows();
153
154 // signals:
155 //   void SlicerManagersHasChanged();
156
157 private:
158
159   //variables
160   // std::vector<vvSlicerManager*> mSlicerManagers;
161   vvHelpDialog *help_dialog;
162   vvDocumentation *documentation;
163   vvDicomSeriesSelector *dicomSeriesSelector;
164
165   QString mInputPathName;
166   bool viewMode;
167   bool playMode;
168
169   //functions
170   void UpdateTree();
171   ///Adds a vector field to slicer manager index
172   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
173   void AddFieldEntry(QString filename,int index,bool from_disk);
174   void AddField(vvImage::Pointer vf,QString file,int index);
175   void InitDisplay();
176   ///Sets the render window and LUT for the last SlicerManager
177   void InitSlicers();
178   void DisplaySliders(int slicer, int window);
179   QString GetSizeInBytes(unsigned long size);
180   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
181   QString GetVectorIntAsString(std::vector<int> vectorInt);
182   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
183   void SaveScreenshot(vtkImageData* image);
184
185   QMenu contextMenu;
186   //QMenu *AddSubImageMenu;
187   std::vector<QAction*> contextActions;
188   std::vector<QSlider*> horizontalSliders;
189   std::vector<QSlider*> verticalSliders;
190   int mFrameRate;
191
192   // vvMainWindowToolInfo * mCurrentToolInfo;
193   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
194
195   static vvMainWindow * mSingleton;
196 };
197
198 #include "vvMainWindow.txx"
199
200 #endif