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