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