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