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