forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkScenePicker.h
142 lines (119 loc) · 4.52 KB
/
vtkScenePicker.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
/*=========================================================================
Program: Visualization Toolkit
Module: vtkScenePicker.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 vtkScenePicker
* @brief Picks an entire viewport at one shot.
*
* The Scene picker, unlike conventional pickers picks an entire viewport at
* one shot and caches the result, which can be retrieved later.
* The utility of the class arises during <b>Actor Selection</b>. Let's
* say you have a couple of polygonal objects in your scene and you wish to
* have a status bar that indicates the object your mouse is over. Picking
* repeatedly every time your mouse moves would be very slow. The
* scene picker automatically picks your viewport every time the camera is
* changed and caches the information. Additionally, it observes the
* vtkRenderWindowInteractor to avoid picking during interaction, so that
* you still maintain your interactivity. In effect, the picker does an
* additional pick-render of your scene every time you stop interacting with
* your scene. As an example, see Rendering/TestScenePicker.
*
* @warning
* - Unlike a vtkHoverWidget, this class is not timer based. The hover widget
* picks a scene when the mouse is over an actor for a specified duration.
* - This class uses a vtkHardwareSelector under the hood. Hence, it will
* work only for actors that have opaque geomerty and are rendered by a
* vtkPolyDataMapper.
*
* @sa
* vtkHoverWidget vtkHardwareSelector
*/
#ifndef vtkScenePicker_h
#define vtkScenePicker_h
#include "vtkRenderingCoreModule.h" // For export macro
#include "vtkObject.h"
class vtkRenderer;
class vtkProp;
class vtkHardwareSelector;
class vtkRenderWindowInteractor;
class vtkScenePickerSelectionRenderCommand;
class VTKRENDERINGCORE_EXPORT vtkScenePicker : public vtkObject
{
friend class vtkRenderer;
friend class vtkScenePickerSelectionRenderCommand;
public:
static vtkScenePicker* New();
vtkTypeMacro(vtkScenePicker, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
//@{
/**
* Set the renderer. Scene picks are restricted to the viewport.
*/
virtual void SetRenderer(vtkRenderer*);
vtkGetObjectMacro(Renderer, vtkRenderer);
//@}
/**
* Get cell id at the pick position.
* Returns -1 if no cell was picked.
* Makes sense only after Pick has been called.
*/
vtkIdType GetCellId(int displayPos[2]);
/**
* Get cell id at the pick position.
* Returns -1 if no cell was picked.
* Makes sense only after Pick has been called.
*/
vtkIdType GetVertexId(int displayPos[2]);
/**
* Get actor at the pick position.
* Returns NULL if none.
* Makes sense only after Pick has been called.
*/
vtkProp* GetViewProp(int displayPos[2]);
//@{
/**
* Vertex picking (using the method GetVertexId()), required
* additional resources and can slow down still render time by
* 5-10%. Enabled by default.
*/
vtkSetMacro(EnableVertexPicking, int);
vtkGetMacro(EnableVertexPicking, int);
vtkBooleanMacro(EnableVertexPicking, int);
//@}
protected:
vtkScenePicker();
~vtkScenePicker();
// Pick render entire viewport
// Automatically invoked from vtkRenderer at the end of a still render.
void PickRender();
// Pick render a region of the renderwindow
void PickRender(int x0, int y0, int x1, int y1);
// Internal update method retrieves info from the Selector
void Update(int displayPos[2]);
// The RenderWindowInteractor must be set, so that avoid scene picks (which
// involve extra renders) during interaction. This is done by observing the
// RenderWindowInteractor for start and end interaction events.
void SetInteractor(vtkRenderWindowInteractor *);
int EnableVertexPicking;
vtkHardwareSelector* Selector;
vtkRenderer* Renderer;
vtkRenderWindowInteractor* Interactor;
vtkIdType VertId;
vtkIdType CellId;
vtkProp* Prop;
bool NeedToUpdate;
int LastQueriedDisplayPos[2];
vtkScenePickerSelectionRenderCommand* SelectionRenderCommand;
vtkTimeStamp PickRenderTime;
private:
vtkScenePicker(const vtkScenePicker&) VTK_DELETE_FUNCTION;
void operator=(const vtkScenePicker&) VTK_DELETE_FUNCTION;
};
#endif