]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
Merge branch 'master' into wipe
[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 "vvWipeImage.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 SelectWipeImage();
169   void SelectFusionImage();
170   //select the file(s) from the disk containing the image sequence to fuse
171   void SelectFusionSequence();
172   void SelectFusionSequenceCorrespondances();
173
174   void ResetTransformationToIdentity();
175
176   void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
177   void SetOverlayProperty(int color, int linked, double window, double level);
178   void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
179   void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag);
180
181   void GoToCursor();
182   void GoToLandmark();
183   void PlayPause();
184   void PlayNext();
185   void ChangeFrameRate(int rate) {
186     mFrameRate = rate;
187   }
188   void UpdateRenderWindows();
189   void UpdateMemoryUsage();
190   void show();
191   
192   static vvMainWindow* Instance(){return mSingleton;}
193   
194 protected:
195   
196   void createRecentlyOpenedFilesMenu();
197   void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
198   
199 private:
200
201   //variables
202   // std::vector<vvSlicerManager*> mSlicerManagers;
203   vvHelpDialog *help_dialog;
204   vvDocumentation *documentation;
205   vvDicomSeriesSelector *dicomSeriesSelector;
206   
207   vvWipeImage::Pointer mWipeImage;
208
209 #if CLITK_USE_PACS_CONNECTION
210   vvQPacsConnection *PacsConnection;
211 #endif
212
213   bool viewMode;
214   bool playMode;
215
216   //functions
217   void UpdateTree();
218   ///Adds a vector field to slicer manager index
219   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
220   void AddFieldEntry(QString filename,int index,bool from_disk);
221   void AddField(vvImage::Pointer vf,QString file,int index);
222   void InitDisplay();
223   ///Sets the render window and LUT for the last SlicerManager
224   void InitSlicers();
225   void DisplaySliders(int slicer, int window);
226   QString GetSizeInBytes(unsigned long size);
227   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
228   QString GetVectorIntAsString(std::vector<int> vectorInt);
229   int GetSlicerIndexFromItem(QTreeWidgetItem* item); //this actually returns the SlicerManager index TODO: rename it to GetSlicerManagerIndexFromItem
230   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
231   void SaveScreenshot(QVTKWidget *widget);
232   int GetImageDuplicateFilenameNumber(std::string filename);
233
234   QMenu contextMenu;
235   QMenu* recentlyOpenedFilesMenu;
236   //QMenu *AddSubImageMenu;
237   std::vector<QAction*> contextActions;
238   std::vector<QSlider*> horizontalSliders;
239   std::vector<QSlider*> verticalSliders;
240   int mFrameRate;
241   
242   std::string mCurrentSelectedImageId;
243   std::string mCurrentPickedImageId;
244   unsigned int mCurrentPickedImageIndex;
245
246   // vvMainWindowToolInfo * mCurrentToolInfo;
247   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
248
249   static vvMainWindow* mSingleton;
250
251   int mCurrentTime;
252   
253 };
254
255 #endif