]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
Romulo:
[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 #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
43 //------------------------------------------------------------------------------
44 class vvMainWindow: public vvMainWindowBase,
45                     private Ui::vvMainWindow
46 {
47   Q_OBJECT
48
49   public:
50   vvMainWindow();
51   ~vvMainWindow();
52   void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
53   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
54   void AddField(QString file,int index);
55   void AddOverlayImage(int index, QString filename);
56   void AddFusionImage(int index, QString filename);
57   void AddROI(int index, QString filename);
58   ///Adds a mesh to a SlicerManager, with optional warping by vector field
59   void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
60   ///This is used to show an image when opened or computed
61   void ShowLastImage();
62
63   virtual void UpdateCurrentSlicer();
64   virtual QTabWidget * GetTab();
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 SliceImages();
81   void MergeImagesWithTime();
82   void OpenDicom();
83   ///Open a vtkPolyData surface mesh and display it over the current image
84   void OpenVTKContour();
85   void SaveAs();
86   void CurrentImageChanged(std::string id);
87   void CurrentPickedImageChanged(std::string id);
88   void ImageInfoChanged();
89   void ShowHelpDialog();
90   void ShowDocumentation();
91   void ComputeDeformableRegistration();
92   void WarpImage();
93   void ChangeViewMode();
94   void DisplayChanged(QTreeWidgetItem *item, int column);
95   void CloseImage(QTreeWidgetItem* item, int column);
96   void ReloadImage(QTreeWidgetItem* item, int column);
97   void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
98   void VectorChanged(int visibility, double x, double y, double z, double value);
99   void OverlayChanged(int visibility, double valueOver, double valueRef);
100   void FusionChanged(int visibility, double value);
101   void SegmentationOnCurrentImage();
102   void SurfaceViewerLaunch();
103
104   void WindowsChanged(int window, int view, int slice);
105   void WindowLevelChanged(double window, double level,int preset, int colormap);
106   void UpdateSlice(int slicer, int slice);
107   void UpdateTSlice(int slicer, int slice);
108   void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
109   void WindowLevelEdited();
110   void UpdateColorMap();
111   void UpdateWindowLevel();
112   void SwitchWindowLevel();
113   void ApplyWindowLevelToAllImages();
114   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
115   void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm);
116   void AddLink(QString image1,QString image2);
117   void RemoveLink(QString image1,QString image2);
118   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
119
120   ///Generic method called when any one of the horizontal sliders is moved
121   void HorizontalSliderMoved(int value,int column, int slicer_index);
122   void NOHorizontalSliderMoved();
123   void NEHorizontalSliderMoved();
124   void SOHorizontalSliderMoved();
125   void SEHorizontalSliderMoved();
126
127   void NOVerticalSliderChanged();
128   void NEVerticalSliderChanged();
129   void SOVerticalSliderChanged();
130   void SEVerticalSliderChanged();
131
132   void SaveNEScreenshot();
133   void SaveNOScreenshot();
134   void SaveSEScreenshot();
135   void SaveSOScreenshot();
136
137   void ShowContextMenu(QPoint point);
138   void CloseImage();
139   void ReloadImage();
140   void OpenField();
141   void SelectOverlayImage();
142   void SelectFusionImage();
143
144   void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
145   void SetOverlayProperty(int color);
146   void SetFusionProperty(int opacity,int colormap,double window,double level);
147
148   void GoToCursor();
149   void PlayPause();
150   void PlayNext();
151   void ChangeFrameRate(int rate) {
152     mFrameRate = rate;
153   }
154   void UpdateRenderWindows();
155   void UpdateMemoryUsage();
156
157 private:
158
159   //variables
160   // std::vector<vvSlicerManager*> mSlicerManagers;
161   vvHelpDialog *help_dialog;
162   vvDocumentation *documentation;
163   vvDicomSeriesSelector *dicomSeriesSelector;
164
165   bool viewMode;
166   bool playMode;
167
168   //functions
169   void UpdateTree();
170   ///Adds a vector field to slicer manager index
171   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
172   void AddFieldEntry(QString filename,int index,bool from_disk);
173   void AddField(vvImage::Pointer vf,QString file,int index);
174   void InitDisplay();
175   ///Sets the render window and LUT for the last SlicerManager
176   void InitSlicers();
177   void DisplaySliders(int slicer, int window);
178   QString GetSizeInBytes(unsigned long size);
179   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
180   QString GetVectorIntAsString(std::vector<int> vectorInt);
181   QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix);
182   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
183   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
184   void SaveScreenshot(vtkImageData* image);
185   int GetImageDuplicateFilenameNumber(std::string filename);
186
187   QMenu contextMenu;
188   //QMenu *AddSubImageMenu;
189   std::vector<QAction*> contextActions;
190   std::vector<QSlider*> horizontalSliders;
191   std::vector<QSlider*> verticalSliders;
192   int mFrameRate;
193   
194   std::string mCurrentSelectedImageId;
195   std::string mCurrentPickedImageId;
196   unsigned int mCurrentPickedImageIndex;
197
198   // vvMainWindowToolInfo * mCurrentToolInfo;
199   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
200
201   static vvMainWindow * mSingleton;
202
203   int mCurrentTime;
204   
205 };
206
207 #include "vvMainWindow.txx"
208
209 #endif