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