]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
Added linked navigation (zoom and pan)
[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   virtual QTabWidget * GetTab();
58   //vvMainWindowToolInfo * GetInfoForTool();
59 //   void AddRunningTool(vvToolCreatorBase * tool);
60
61 public slots:
62   ///Allows the user to open and select various surfaces contained in a dicom-struct file
63   void OpenDCStructContour();
64   ///Computes the MIP of the currently selected image and displays it
65   void ComputeMIP();
66   ///Computes the midposition image of a 4D sequence with a VF and displays it
67   void ComputeMidPosition();
68   void OpenImages();
69   ///Slot triggered by the dynamically-generated recent file menu actions
70   void OpenRecentImage();
71   void OpenImageWithTime();
72   void MergeImages();
73   void MergeImagesWithTime();
74   void OpenDicom();
75   ///Open a vtkPolyData surface mesh and display it over the current image
76   void OpenVTKContour();
77   void SaveAs();
78   void CurrentImageChanged(std::string id);
79   void ImageInfoChanged();
80   void ShowHelpDialog();
81   void ShowDocumentation();
82   void ComputeDeformableRegistration();
83   void WarpImage();
84   void ChangeViewMode();
85   void DisplayChanged(QTreeWidgetItem *item, int column);
86   void CloseImage(QTreeWidgetItem* item, int column);
87   void ReloadImage(QTreeWidgetItem* item, int column);
88   void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
89   void VectorChanged(int visibility, double x, double y, double z, double value);
90   void OverlayChanged(int visibility, double valueOver, double valueRef);
91   void FusionChanged(int visibility, double value);
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 UpdateLinkedNavigation(std::string id, vvSlicerManager *sm);
106   void AddLink(QString image1,QString image2);
107   void RemoveLink(QString image1,QString image2);
108   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
109
110   ///Generic method called when any one of the horizontal sliders is moved
111   void HorizontalSliderMoved(int value,int column, int slicer_index);
112   void NOHorizontalSliderMoved();
113   void NEHorizontalSliderMoved();
114   void SOHorizontalSliderMoved();
115   void SEHorizontalSliderMoved();
116
117   void NOVerticalSliderChanged();
118   void NEVerticalSliderChanged();
119   void SOVerticalSliderChanged();
120   void SEVerticalSliderChanged();
121
122   void SaveNEScreenshot();
123   void SaveNOScreenshot();
124   void SaveSEScreenshot();
125   void SaveSOScreenshot();
126
127   void ShowContextMenu(QPoint point);
128   //  void CropImage();
129   void SplitImage();
130   void CloseImage();
131   void ReloadImage();
132   void OpenField();
133   void SelectOverlayImage();
134   void AddFusionImage();
135
136   void SetVFProperty(int subsampling,int scale,int lut, int width);
137   void SetOverlayProperty(int color);
138   void SetFusionProperty(int opacity,int colormap,double window,double level);
139
140   void GoToCursor();
141   void PlayPause();
142   void PlayNext();
143   void ChangeFrameRate(int rate) {
144     mFrameRate = rate;
145   }
146   void UpdateRenderWindows();
147
148 private:
149
150   //variables
151   // std::vector<vvSlicerManager*> mSlicerManagers;
152   vvHelpDialog *help_dialog;
153   vvDocumentation *documentation;
154   vvDicomSeriesSelector *dicomSeriesSelector;
155
156   bool viewMode;
157   bool playMode;
158
159   //functions
160   void UpdateTree();
161   ///Adds a vector field to slicer manager index
162   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
163   void AddFieldEntry(QString filename,int index,bool from_disk);
164   void AddField(vvImage::Pointer vf,QString file,int index);
165   void InitDisplay();
166   ///Sets the render window and LUT for the last SlicerManager
167   void InitSlicers();
168   void DisplaySliders(int slicer, int window);
169   QString GetSizeInBytes(unsigned long size);
170   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
171   QString GetVectorIntAsString(std::vector<int> vectorInt);
172   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
173   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
174   void SaveScreenshot(vtkImageData* image);
175
176   QMenu contextMenu;
177   //QMenu *AddSubImageMenu;
178   std::vector<QAction*> contextActions;
179   std::vector<QSlider*> horizontalSliders;
180   std::vector<QSlider*> verticalSliders;
181   int mFrameRate;
182
183   // vvMainWindowToolInfo * mCurrentToolInfo;
184   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
185
186   static vvMainWindow * mSingleton;
187
188   int mCurrentTime;
189
190 };
191
192 #include "vvMainWindow.txx"
193
194 #endif