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