]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
Merge branch 'master' of /home/dsarrut/clitk3.server
[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://www.centreleonberard.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 "vvImageReader.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 class vvSlicer;
43
44 //------------------------------------------------------------------------------
45 class vvMainWindow: public vvMainWindowBase,
46                     private Ui::vvMainWindow
47 {
48   Q_OBJECT
49
50   public:
51   vvMainWindow();
52   ~vvMainWindow();
53   void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
54   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
55   void AddField(QString file,int index);
56   void AddOverlayImage(int index, QString filename);
57   void AddFusionImage(int index, QString filename);
58   void AddROI(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   virtual QTabWidget * GetTab();
66   //vvMainWindowToolInfo * GetInfoForTool();
67 //   void AddRunningTool(vvToolCreatorBase * tool);
68
69 public slots:
70   ///Allows the user to open and select various surfaces contained in a dicom-struct file
71   void OpenDCStructContour();
72   ///Computes the midposition image of a 4D sequence with a VF and displays it
73   void ComputeMidPosition();
74   void OpenImages();
75   ///Slot triggered by the dynamically-generated recent file menu actions
76   void OpenRecentImage();
77   void OpenImageWithTime();
78   void MergeImages();
79   void SliceImages();
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 CurrentPickedImageChanged(std::string id);
87   void ImageInfoChanged();
88   void ShowHelpDialog();
89   void ShowDocumentation();
90   void PopupRegisterForm(bool checkCanPush=false);
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 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 ApplyWindowLevelToAllImages();
113   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
114   void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
115   void AddLink(QString image1,QString image2);
116   void RemoveLink(QString image1,QString image2);
117   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
118
119   ///Generic method called when any one of the horizontal sliders is moved
120   void HorizontalSliderMoved(int value,int column, int slicer_index);
121   void NOHorizontalSliderMoved();
122   void NEHorizontalSliderMoved();
123   void SOHorizontalSliderMoved();
124   void SEHorizontalSliderMoved();
125
126   void NOVerticalSliderChanged();
127   void NEVerticalSliderChanged();
128   void SOVerticalSliderChanged();
129   void SEVerticalSliderChanged();
130
131   void SaveNEScreenshot();
132   void SaveNOScreenshot();
133   void SaveSEScreenshot();
134   void SaveSOScreenshot();
135
136   void ShowContextMenu(QPoint point);
137   void CloseImage();
138   void ReloadImage();
139   void OpenField();
140   void SelectOverlayImage();
141   void SelectFusionImage();
142   void ResetTransformationToIdentity();
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 tresOpacity, 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   void show();
157   
158 protected:
159   
160   void createRecentlyOpenedFilesMenu();
161   void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
162   
163 private:
164
165   //variables
166   // std::vector<vvSlicerManager*> mSlicerManagers;
167   vvHelpDialog *help_dialog;
168   vvDocumentation *documentation;
169   vvDicomSeriesSelector *dicomSeriesSelector;
170
171   bool viewMode;
172   bool playMode;
173
174   //functions
175   void UpdateTree();
176   ///Adds a vector field to slicer manager index
177   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
178   void AddFieldEntry(QString filename,int index,bool from_disk);
179   void AddField(vvImage::Pointer vf,QString file,int index);
180   void InitDisplay();
181   ///Sets the render window and LUT for the last SlicerManager
182   void InitSlicers();
183   void DisplaySliders(int slicer, int window);
184   QString GetSizeInBytes(unsigned long size);
185   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
186   QString GetVectorIntAsString(std::vector<int> vectorInt);
187   QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix);
188   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
189   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
190   void SaveScreenshot(QVTKWidget *widget);
191   int GetImageDuplicateFilenameNumber(std::string filename);
192
193   QMenu contextMenu;
194   QMenu* recentlyOpenedFilesMenu;
195   //QMenu *AddSubImageMenu;
196   std::vector<QAction*> contextActions;
197   std::vector<QSlider*> horizontalSliders;
198   std::vector<QSlider*> verticalSliders;
199   int mFrameRate;
200   
201   std::string mCurrentSelectedImageId;
202   std::string mCurrentPickedImageId;
203   unsigned int mCurrentPickedImageIndex;
204
205   // vvMainWindowToolInfo * mCurrentToolInfo;
206   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
207
208   static vvMainWindow * mSingleton;
209
210   int mCurrentTime;
211   
212 };
213
214 #endif