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