]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
1/ some minor changes for compilation under windows / VC++ 2010 Express
[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);
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
163   void ResetTransformationToIdentity();
164
165   void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
166   void SetOverlayProperty(int color, int linked, double window, double level);
167   void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level, bool showLegend);
168   void SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames);
169
170   void GoToCursor();
171   void PlayPause();
172   void PlayNext();
173   void ChangeFrameRate(int rate) {
174     mFrameRate = rate;
175   }
176   void UpdateRenderWindows();
177   void UpdateMemoryUsage();
178   void show();
179   
180 protected:
181   
182   void createRecentlyOpenedFilesMenu();
183   void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
184   
185 private:
186
187   //variables
188   // std::vector<vvSlicerManager*> mSlicerManagers;
189   vvHelpDialog *help_dialog;
190   vvDocumentation *documentation;
191   vvDicomSeriesSelector *dicomSeriesSelector;
192
193   bool viewMode;
194   bool playMode;
195
196   //functions
197   void UpdateTree();
198   ///Adds a vector field to slicer manager index
199   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
200   void AddFieldEntry(QString filename,int index,bool from_disk);
201   void AddField(vvImage::Pointer vf,QString file,int index);
202   void InitDisplay();
203   ///Sets the render window and LUT for the last SlicerManager
204   void InitSlicers();
205   void DisplaySliders(int slicer, int window);
206   QString GetSizeInBytes(unsigned long size);
207   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
208   QString GetVectorIntAsString(std::vector<int> vectorInt);
209   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
210   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
211   void SaveScreenshot(QVTKWidget *widget);
212   int GetImageDuplicateFilenameNumber(std::string filename);
213
214   QMenu contextMenu;
215   QMenu* recentlyOpenedFilesMenu;
216   //QMenu *AddSubImageMenu;
217   std::vector<QAction*> contextActions;
218   std::vector<QSlider*> horizontalSliders;
219   std::vector<QSlider*> verticalSliders;
220   int mFrameRate;
221   
222   std::string mCurrentSelectedImageId;
223   std::string mCurrentPickedImageId;
224   unsigned int mCurrentPickedImageIndex;
225
226   // vvMainWindowToolInfo * mCurrentToolInfo;
227   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
228
229   static vvMainWindow * mSingleton;
230
231   int mCurrentTime;
232   
233 };
234
235 #endif