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