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