]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
12aaaf1a5f0b8d6f0d5a41d40f0d7bfe16092110
[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 class QTreeWidget;
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, vvImageReader::LoadedImageType type);
55   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
56   void AddField(QString file,int index);
57   void AddOverlayImage(int index, QString filename);
58   void AddFusionImage(int index, QString filename);
59   void AddROI(int index, QString filename);
60   ///Adds a mesh to a SlicerManager, with optional warping by vector field
61   void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
62   ///This is used to show an image when opened or computed
63   void ShowLastImage();
64   void SaveCurrentStateAs(const std::string& stateFile);
65   void ReadSavedStateFile(const std::string& stateFile);
66         void LinkAllImages();
67
68   virtual void UpdateCurrentSlicer();
69   virtual QTabWidget * GetTab();
70   QTreeWidget* GetTree() { return DataTree; }
71   //vvMainWindowToolInfo * GetInfoForTool();
72 //   void AddRunningTool(vvToolCreatorBase * tool);
73
74 public slots:
75   ///Allows the user to open and select various surfaces contained in a dicom-struct file
76   void OpenDCStructContour();
77   ///Computes the midposition image of a 4D sequence with a VF and displays it
78   void ComputeMidPosition();
79   void OpenImages();
80   ///Slot triggered by the dynamically-generated recent file menu actions
81   void OpenRecentImage();
82   void OpenImageWithTime();
83   void MergeImages();
84   void SliceImages();
85   void MergeImagesWithTime();
86   void OpenDicom();
87   ///Open a vtkPolyData surface mesh and display it over the current image
88   void OpenVTKContour();
89   void SaveAs();
90   void SaveCurrentState();
91   void ReadSavedState();
92   void CurrentImageChanged(std::string id);
93   void CurrentPickedImageChanged(std::string id);
94   void ImageInfoChanged();
95   void ShowHelpDialog();
96   void ShowDocumentation();
97   void PopupRegisterForm(bool checkCanPush=false);
98   void ComputeDeformableRegistration();
99   void WarpImage();
100   void ChangeViewMode();
101   void DisplayChanged(QTreeWidgetItem *item, int column);
102   void CloseImage(QTreeWidgetItem* item, int column);
103   void ReloadImage(QTreeWidgetItem* item, int column);
104   void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
105   void VectorChanged(int visibility, double x, double y, double z, double value);
106   void OverlayChanged(int visibility, double valueOver, double valueRef);
107   void FusionChanged(int visibility, double value);
108   void SegmentationOnCurrentImage();
109   void SurfaceViewerLaunch();
110
111   void WindowLevelChanged();
112   void UpdateSlice(int slicer, int slice);
113   void UpdateTSlice(int slicer, int slice);
114   void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
115   void WindowLevelEdited();
116   void SetWindowLevel(double w, double l);
117   void UpdateColorMap();
118   void UpdateWindowLevel();
119   void SwitchWindowLevel();
120   void ApplyWindowLevelToAllImages();
121   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
122   void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm, vvSlicer* refSlicer);
123   void AddLink(QString image1,QString image2);
124   void RemoveLink(QString image1,QString image2);
125   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
126
127   ///Generic method called when any one of the horizontal sliders is moved
128   void HorizontalSliderMoved(int value,int column, int slicer_index);
129   void NOHorizontalSliderMoved();
130   void NEHorizontalSliderMoved();
131   void SOHorizontalSliderMoved();
132   void SEHorizontalSliderMoved();
133
134   void NOVerticalSliderChanged();
135   void NEVerticalSliderChanged();
136   void SOVerticalSliderChanged();
137   void SEVerticalSliderChanged();
138
139   void SaveNEScreenshot();
140   void SaveNOScreenshot();
141   void SaveSEScreenshot();
142   void SaveSOScreenshot();
143   void SaveScreenshotAllSlices();
144
145   void ShowContextMenu(QPoint point);
146   void CloseImage();
147   void ReloadImage();
148   void OpenField();
149   void SelectOverlayImage();
150   void SelectFusionImage();
151   void ResetTransformationToIdentity();
152
153   void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
154   void SetOverlayProperty(int color, int linked, double window, double level);
155   void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level);
156
157   void GoToCursor();
158   void PlayPause();
159   void PlayNext();
160   void ChangeFrameRate(int rate) {
161     mFrameRate = rate;
162   }
163   void UpdateRenderWindows();
164   void UpdateMemoryUsage();
165   void show();
166   
167 protected:
168   
169   void createRecentlyOpenedFilesMenu();
170   void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
171   
172 private:
173
174   //variables
175   // std::vector<vvSlicerManager*> mSlicerManagers;
176   vvHelpDialog *help_dialog;
177   vvDocumentation *documentation;
178   vvDicomSeriesSelector *dicomSeriesSelector;
179
180   bool viewMode;
181   bool playMode;
182
183   //functions
184   void UpdateTree();
185   ///Adds a vector field to slicer manager index
186   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
187   void AddFieldEntry(QString filename,int index,bool from_disk);
188   void AddField(vvImage::Pointer vf,QString file,int index);
189   void InitDisplay();
190   ///Sets the render window and LUT for the last SlicerManager
191   void InitSlicers();
192   void DisplaySliders(int slicer, int window);
193   QString GetSizeInBytes(unsigned long size);
194   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
195   QString GetVectorIntAsString(std::vector<int> vectorInt);
196   QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix);
197   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
198   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
199   void SaveScreenshot(QVTKWidget *widget);
200   int GetImageDuplicateFilenameNumber(std::string filename);
201
202   QMenu contextMenu;
203   QMenu* recentlyOpenedFilesMenu;
204   //QMenu *AddSubImageMenu;
205   std::vector<QAction*> contextActions;
206   std::vector<QSlider*> horizontalSliders;
207   std::vector<QSlider*> verticalSliders;
208   int mFrameRate;
209   
210   std::string mCurrentSelectedImageId;
211   std::string mCurrentPickedImageId;
212   unsigned int mCurrentPickedImageIndex;
213
214   // vvMainWindowToolInfo * mCurrentToolInfo;
215   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
216
217   static vvMainWindow * mSingleton;
218
219   int mCurrentTime;
220   
221 };
222
223 #endif