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