UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-05-17)
usVirtualNeedle.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 __usVirtualNeedle_h_
39 #define __usVirtualNeedle_h_
40 
41 // VISP includes
42 #include <visp3/ustk_core/usConfig.h>
43 
44 #ifdef USTK_HAVE_VTK_QT
45 
46 #include <visp3/core/vpHomogeneousMatrix.h>
47 
48 #include <visp3/ustk_gui/usViewerWidget.h>
49 
50 #include <visp3/ustk_gui/usVTKConverter.h>
51 
52 // VTK includes
53 #include <vtkArrowSource.h>
54 #include <vtkCylinderSource.h>
55 #include <vtkInteractorStyleTrackballCamera.h>
56 #include <vtkMatrix4x4.h>
57 #include <vtkProperty.h>
58 #include <vtkRenderWindowInteractor.h>
59 #include <vtkSTLReader.h>
60 #include <vtkSTLWriter.h>
61 #include <vtkSmartPointer.h>
62 #include <vtkSphereSource.h>
63 
64 #include <QPaintEngine>
65 #include <QPainter>
66 
67 #include <vtkActor.h>
68 #include <vtkAxesActor.h>
69 #include <vtkPoints.h>
70 #include <vtkPolyDataMapper.h>
71 #include <vtkRenderWindow.h>
72 #include <vtkRenderer.h>
73 #include <vtkSmartPointer.h>
74 
75 // Qt includes
76 #if defined(USTK_HAVE_VTK_QT4)
77 #include <QApplication>
78 #include <QKeyEvent>
79 #include <QVTKWidget.h>
80 #include <QtGui/QGridLayout>
81 #include <QtGui/QMainWindow>
82 #include <QtGui/QPushButton>
83 #elif defined USTK_HAVE_VTK_QT5
84 #include <QApplication>
85 #include <QKeyEvent>
86 #if USTK_HAVE_VTK_VERSION < 0x090000
87 #include <QVTKWidget.h>
88 #else
89 #include <QVTKOpenGLWidget.h>
90 #endif
91 #include <QtWidgets/QGridLayout>
92 #include <QtWidgets/QMainWindow>
93 #include <QtWidgets/QPushButton>
94 #endif
95 
103 {
104  Q_OBJECT
105 public:
106  // Constructor/Destructor
107  usVirtualNeedle(QWidget *parent = NULL, Qt::WindowFlags f = Qt::WindowFlags());
108  virtual ~usVirtualNeedle() {}
109 
110  void keyPressEvent(QKeyEvent *event);
111 
112  vtkPoints *getMeshPoints();
113 
114  void setMeshInScene(vtkPolyData *mesh);
115 
116  // Catch paint events, in case we want to display some informations (writing in this widget) over the vtk scene
117  void paintEvent(QPaintEvent *event);
118 
119  void render();
120 
121 public slots:
122  void updateNeedlePosition(vpHomogeneousMatrix transform);
123 
124 private:
125  // mesh polydata
126  vtkPolyData *m_meshPolyData;
127  // needle mesh
128  vtkPolyData *m_meshNeedle;
129 
130  // actors
131  vtkSmartPointer<vtkActor> m_meshActor;
132  vtkSmartPointer<vtkActor> m_needleActor;
133 
134  // axes representation
135  vtkSmartPointer<vtkAxesActor> m_axesActor;
136 
137  // vtk renderer
138  vtkRenderer *renderer;
139 };
140 #endif
141 #endif // __usVirtualNeedle_h_
View used to render a vtk scene in a QWidget (based on QVTKWidget for Qt4, QVTKOpenGLWidget for Qt5)
Class used to render a virtual needle movable in a 3D environment.
usVirtualNeedle(QWidget *parent=NULL, Qt::WindowFlags f=Qt::WindowFlags())
virtual ~usVirtualNeedle()
vtkPoints * getMeshPoints()
void setMeshInScene(vtkPolyData *mesh)
void paintEvent(QPaintEvent *event)
void keyPressEvent(QKeyEvent *event)
void updateNeedlePosition(vpHomogeneousMatrix transform)