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