UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
us3DSceneWidget.h
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 
38 #ifndef __us3DSceneWidget_h_
39 #define __us3DSceneWidget_h_
40 
41 // VISP includes
42 #include <visp3/ustk_core/usConfig.h>
43 
44 #ifdef USTK_HAVE_VTK_QT
45 
46 #include <visp3/ustk_gui/usViewerWidget.h>
47 
48 // VTK includes
49 #include <vtkAxesActor.h>
50 #include <vtkCubeSource.h>
51 #include <vtkCutter.h>
52 #include <vtkImageData.h>
53 #include <vtkImagePlaneWidget.h>
54 #include <vtkImageResliceMapper.h>
55 #include <vtkImageSlice.h>
56 #include <vtkPlane.h>
57 #include <vtkPolyDataMapper.h>
58 #include <vtkRenderWindow.h>
59 #include <vtkRenderer.h>
60 #include <vtkSmartPointer.h>
61 
62 // Qt includes
63 #if defined(USTK_HAVE_VTK_QT4)
64 #include <QApplication>
65 #include <QtGui/QGridLayout>
66 #include <QtGui/QMainWindow>
67 #include <QtGui/QPushButton>
68 #elif defined USTK_HAVE_VTK_QT5
69 #include <QApplication>
70 #include <QtWidgets/QGridLayout>
71 #include <QtWidgets/QMainWindow>
72 #include <QtWidgets/QPushButton>
73 #endif
74 
75 #if USTK_HAVE_VTK_VERSION < 0x090000
76 #include <QVTKWidget.h>
77 #else
78 #include <QVTKOpenGLStereoWidget.h>
79 #endif
80 
119 class VISP_EXPORT us3DSceneWidget : public usViewerWidget
120 {
121  Q_OBJECT
122 public:
123  // Constructor/Destructor
124  us3DSceneWidget(QWidget *parent = NULL, Qt::WindowFlags f = Qt::WindowFlags());
126 
127  vtkPolyData *getContour1();
128  vtkPolyData *getContour2();
129  vtkPolyData *getContour3();
130 
131  vtkImageData *getImageData();
132 
133  vtkPolyData *getMeshInPlane1();
134  vtkPolyData *getMeshInPlane2();
135  vtkPolyData *getMeshInPlane3();
136 
137  vtkPlane *getPlane1();
138  vtkPlane *getPlane2();
139  vtkPlane *getPlane3();
140 
141  void init();
142 
143  // Catch paint events, in case we want to display some informations (writing in this widget) over the vtk scene
144  void paintEvent(QPaintEvent *event);
145 
146  // Set image to display
147  void setImageData(vtkImageData *imageData);
148 
149  // Set planes
150  void setPlane1(vtkPlane *plane);
151  void setPlane2(vtkPlane *plane);
152  void setPlane3(vtkPlane *plane);
153  void setPlanes(vtkPlane *plane1, vtkPlane *plane2, vtkPlane *plane3);
154 
155 public slots:
156  //
157  void updateImageData(vtkImageData *imageData);
158  void updateMatrix1(vtkMatrix4x4 *matrix);
159  void updateMatrix2(vtkMatrix4x4 *matrix);
160  void updateMatrix3(vtkMatrix4x4 *matrix);
161 
162 signals:
166 
167 private:
168  // image
169  vtkImageData *imageData;
170 
171  // Cube for image bounds
172  vtkSmartPointer<vtkCubeSource> imageBoundsCube;
173 
174  // planes (containing geometrical informations)
175  vtkPlane *plane1;
176  vtkPlane *plane2;
177  vtkPlane *plane3;
178 
179  // mesh polydata
180  vtkPolyData *meshPolyData;
181 
182  // vtk mappers
183  vtkImageResliceMapper *imageResliceMapper1;
184  vtkImageResliceMapper *imageResliceMapper2;
185  vtkImageResliceMapper *imageResliceMapper3;
186 
187  // vtk actors
188  vtkImageSlice *imageSlice1;
189  vtkImageSlice *imageSlice2;
190  vtkImageSlice *imageSlice3;
191 
192  // Cutters for intersections between plane and volume borders
193  vtkSmartPointer<vtkCutter> cutter1;
194  vtkSmartPointer<vtkCutter> cutter2;
195  vtkSmartPointer<vtkCutter> cutter3;
196 
197  // Cutters for intersections between planes and mesh
198  vtkSmartPointer<vtkCutter> cutterPolyDataPlane1;
199  vtkSmartPointer<vtkCutter> cutterPolyDataPlane2;
200  vtkSmartPointer<vtkCutter> cutterPolyDataPlane3;
201 
202  // axes representation
203  vtkSmartPointer<vtkAxesActor> m_axesActor;
204 
205  // vtk renderer
206  vtkRenderer *renderer;
207 };
208 #endif
209 #endif // __us3DSceneWidget_h_
Class used to render a 3D vtk scene containing a vtkImageData in a QWidget (based on QVTKWidget).
void plane2Changed()
void plane3Changed()
void plane1Changed()
View used to render a vtk scene in a QWidget (based on QVTKWidget for Qt4, QVTKOpenGLWidget for Qt5)
void paintEvent(QPaintEvent *event)