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