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