forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkQWidgetRepresentation.h
154 lines (128 loc) · 4.46 KB
/
vtkQWidgetRepresentation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*=========================================================================
Program: Visualization Toolkit
Module: vtkQWidgetRepresentation.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkQWidgetRepresentation
* @brief a class defining the representation for a vtkQWidgetWidget
*
* This class renders a QWidget as a simple vtkPlaneSource with a vtkTexture
* that contains a vtkQWidgetTexture which imports the OpenGL texture handle
* from Qt into the vtk scene. Qt and VTK may need to be useing the same
* graphics context.
*/
#ifndef vtkQWidgetRepresentation_h
#define vtkQWidgetRepresentation_h
#include "vtkGUISupportQtModule.h" // For export macro
#include "vtkWidgetRepresentation.h"
class QWidget;
class vtkActor;
class vtkCellPicker;
class vtkOpenGLTexture;
class vtkPlaneSource;
class vtkPolyDataAlgorithm;
class vtkPolyDataMapper;
class vtkQWidgetTexture;
class VTKGUISUPPORTQT_EXPORT vtkQWidgetRepresentation : public vtkWidgetRepresentation
{
public:
/**
* Instantiate the class.
*/
static vtkQWidgetRepresentation* New();
///@{
/**
* Standard methods for the class.
*/
vtkTypeMacro(vtkQWidgetRepresentation, vtkWidgetRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) override;
///@}
/**
* Satisfies superclass API. This returns a pointer to the underlying
* PolyData (which represents the plane).
*/
vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
/**
* Satisfies the superclass API. This will change the state of the widget
* to match changes that have been made to the underlying PolyDataSource
*/
void UpdatePlacement(void);
///@{
/**
* Methods to interface with the vtkImplicitPlaneWidget2.
*/
void PlaceWidget(double bounds[6]) override;
void BuildRepresentation() override;
int ComputeComplexInteractionState(vtkRenderWindowInteractor* iren, vtkAbstractWidget* widget,
unsigned long event, void* calldata, int modify = 0) override;
///@}
///@{
/**
* Methods supporting the rendering process.
*/
double* GetBounds() VTK_SIZEHINT(6) override;
void GetActors(vtkPropCollection* pc) override;
void ReleaseGraphicsResources(vtkWindow*) override;
int RenderOpaqueGeometry(vtkViewport*) override;
int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
vtkTypeBool HasTranslucentPolygonalGeometry() override;
///@}
// Manage the state of the widget
enum _InteractionState
{
Outside = 0,
Inside
};
///@{
/**
* The interaction state may be set from a widget (e.g.,
* vtkQWidgetWidget) or other object. This controls how the
* interaction with the widget proceeds. Normally this method is used as
* part of a handshaking process with the widget: First
* ComputeInteractionState() is invoked that returns a state based on
* geometric considerations (i.e., cursor near a widget feature), then
* based on events, the widget may modify this further.
*/
vtkSetClampMacro(InteractionState, int, Outside, Inside);
///@}
/**
* Set the QWidget this representation will render
*/
void SetWidget(QWidget* w);
/**
* Get the QWidgetTexture used by the representation
*/
vtkGetObjectMacro(QWidgetTexture, vtkQWidgetTexture);
/**
* Get the vtkPlaneSouce used by this representation. This can be useful
* to set the Origin, Point1, Point2 of the plane source directly.
*/
vtkGetObjectMacro(PlaneSource, vtkPlaneSource);
/**
* Get the widget coordinates as computed in the last call to
* ComputeComplexInteractionState.
*/
vtkGetVector2Macro(WidgetCoordinates, float);
protected:
vtkQWidgetRepresentation();
~vtkQWidgetRepresentation() override;
float WidgetCoordinates[2];
vtkPlaneSource* PlaneSource;
vtkPolyDataMapper* PlaneMapper;
vtkActor* PlaneActor;
vtkOpenGLTexture* PlaneTexture;
vtkQWidgetTexture* QWidgetTexture;
vtkCellPicker* Picker;
// Register internal Pickers within PickingManager
void RegisterPickers() override;
private:
vtkQWidgetRepresentation(const vtkQWidgetRepresentation&) = delete;
void operator=(const vtkQWidgetRepresentation&) = delete;
};
#endif