]> Creatis software - clitk.git/blob - vv/vvMainWindow.h
Add smartpointer for vtk objects
[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://oncora1.lyon.fnclcc.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 "vvConstants.h"
28 #include "vvMesh.h"
29 #include "clitkMemoryUsage.h"
30
31 class vvSlicerManager;
32 class vvHelpDialog;
33 class vvDocumentation;
34 class vtkRenderWindowInteractor;
35 class vtkImageData;
36 class vtkRenderer;
37 class vvDicomSeriesSelector;
38
39 //------------------------------------------------------------------------------
40 class vvMainWindow: public vvMainWindowBase,
41                     private Ui::vvMainWindow
42 {
43   Q_OBJECT
44
45   public:
46   vvMainWindow();
47   ~vvMainWindow();
48   void LoadImages(std::vector<std::string> filenames, LoadedImageType type);
49   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
50   void AddField(QString file,int index);
51   void AddOverlayImage(int index, QString filename);
52   void AddFusionImage(int index, QString filename);
53   void AddROI(int index, QString filename);
54   ///Adds a mesh to a SlicerManager, with optional warping by vector field
55   void AddContour(int image_index, vvMesh::Pointer contour, bool propagation);
56   ///This is used to show an image when opened or computed
57   void ShowLastImage();
58
59   virtual void UpdateCurrentSlicer();
60   virtual QTabWidget * GetTab();
61   //vvMainWindowToolInfo * GetInfoForTool();
62 //   void AddRunningTool(vvToolCreatorBase * tool);
63
64 public slots:
65   ///Allows the user to open and select various surfaces contained in a dicom-struct file
66   void OpenDCStructContour();
67   ///Computes the MIP of the currently selected image and displays it
68   void ComputeMIP();
69   ///Computes the midposition image of a 4D sequence with a VF and displays it
70   void ComputeMidPosition();
71   void OpenImages();
72   ///Slot triggered by the dynamically-generated recent file menu actions
73   void OpenRecentImage();
74   void OpenImageWithTime();
75   void MergeImages();
76   void SliceImages();
77   void MergeImagesWithTime();
78   void OpenDicom();
79   ///Open a vtkPolyData surface mesh and display it over the current image
80   void OpenVTKContour();
81   void SaveAs();
82   void CurrentImageChanged(std::string id);
83   void ImageInfoChanged();
84   void ShowHelpDialog();
85   void ShowDocumentation();
86   void ComputeDeformableRegistration();
87   void WarpImage();
88   void ChangeViewMode();
89   void DisplayChanged(QTreeWidgetItem *item, int column);
90   void CloseImage(QTreeWidgetItem* item, int column);
91   void ReloadImage(QTreeWidgetItem* item, int column);
92   void MousePositionChanged(int visibility, double x, double y, double z, double X, double Y, double Z , double value);
93   void VectorChanged(int visibility, double x, double y, double z, double value);
94   void OverlayChanged(int visibility, double valueOver, double valueRef);
95   void FusionChanged(int visibility, double value);
96   void SegmentationOnCurrentImage();
97   void SurfaceViewerLaunch();
98
99   void WindowsChanged(int window, int view, int slice);
100   void WindowLevelChanged(double window, double level,int preset, int colormap);
101   void UpdateSlice(int slicer, int slice);
102   void UpdateTSlice(int slicer, int slice);
103   void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax);
104   void WindowLevelEdited();
105   void UpdateColorMap();
106   void UpdateWindowLevel();
107   void SwitchWindowLevel();
108   void ApplyWindowLevelToAllImages();
109   void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
110   void UpdateLinkedNavigation(std::string id, vvSlicerManager *sm);
111   void AddLink(QString image1,QString image2);
112   void RemoveLink(QString image1,QString image2);
113   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
114
115   ///Generic method called when any one of the horizontal sliders is moved
116   void HorizontalSliderMoved(int value,int column, int slicer_index);
117   void NOHorizontalSliderMoved();
118   void NEHorizontalSliderMoved();
119   void SOHorizontalSliderMoved();
120   void SEHorizontalSliderMoved();
121
122   void NOVerticalSliderChanged();
123   void NEVerticalSliderChanged();
124   void SOVerticalSliderChanged();
125   void SEVerticalSliderChanged();
126
127   void SaveNEScreenshot();
128   void SaveNOScreenshot();
129   void SaveSEScreenshot();
130   void SaveSOScreenshot();
131
132   void ShowContextMenu(QPoint point);
133   void CloseImage();
134   void ReloadImage();
135   void OpenField();
136   void SelectOverlayImage();
137   void SelectFusionImage();
138
139   void SetVFProperty(int subsampling,int scale,int lut, int width);
140   void SetOverlayProperty(int color);
141   void SetFusionProperty(int opacity,int colormap,double window,double level);
142
143   void GoToCursor();
144   void PlayPause();
145   void PlayNext();
146   void ChangeFrameRate(int rate) {
147     mFrameRate = rate;
148   }
149   void UpdateRenderWindows();
150   void UpdateMemoryUsage();
151
152 private:
153
154   //variables
155   // std::vector<vvSlicerManager*> mSlicerManagers;
156   vvHelpDialog *help_dialog;
157   vvDocumentation *documentation;
158   vvDicomSeriesSelector *dicomSeriesSelector;
159
160   bool viewMode;
161   bool playMode;
162
163   //functions
164   void UpdateTree();
165   ///Adds a vector field to slicer manager index
166   void WarpImage(vvSlicerManager* selected_slicer,int reference_phase);
167   void AddFieldEntry(QString filename,int index,bool from_disk);
168   void AddField(vvImage::Pointer vf,QString file,int index);
169   void InitDisplay();
170   ///Sets the render window and LUT for the last SlicerManager
171   void InitSlicers();
172   void DisplaySliders(int slicer, int window);
173   QString GetSizeInBytes(unsigned long size);
174   QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
175   QString GetVectorIntAsString(std::vector<int> vectorInt);
176   int GetSlicerIndexFromItem(QTreeWidgetItem* item);
177   QTreeWidgetItem* GetItemFromSlicerManager(vvSlicerManager* sm);
178   void SaveScreenshot(vtkImageData* image);
179   int GetImageDuplicateFilenameNumber(std::string filename);
180
181   QMenu contextMenu;
182   //QMenu *AddSubImageMenu;
183   std::vector<QAction*> contextActions;
184   std::vector<QSlider*> horizontalSliders;
185   std::vector<QSlider*> verticalSliders;
186   int mFrameRate;
187   
188   std::string mCurrentSelectedImageId;
189
190   // vvMainWindowToolInfo * mCurrentToolInfo;
191   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
192
193   static vvMainWindow * mSingleton;
194
195   int mCurrentTime;
196
197 };
198
199 #include "vvMainWindow.txx"
200
201 #endif