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