forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkRenderView.h
307 lines (263 loc) · 8.5 KB
/
vtkRenderView.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/*=========================================================================
Program: Visualization Toolkit
Module: vtkRenderView.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.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
/**
* @class vtkRenderView
* @brief A view containing a renderer.
*
*
* vtkRenderView is a view which contains a vtkRenderer. You may add vtkActors
* directly to the renderer, or add certain vtkDataRepresentation subclasses
* to the renderer. The render view supports drag selection with the mouse to
* select cells.
*
* This class is also the parent class for any more specialized view which uses
* a renderer.
*/
#ifndef vtkRenderView_h
#define vtkRenderView_h
#include "vtkRenderViewBase.h"
#include "vtkSmartPointer.h" // For SP ivars
#include "vtkViewsInfovisModule.h" // For export macro
class vtkAbstractTransform;
class vtkActor2D;
class vtkAlgorithmOutput;
class vtkArrayCalculator;
class vtkBalloonRepresentation;
class vtkDynamic2DLabelMapper;
class vtkHardwareSelector;
class vtkHoverWidget;
class vtkInteractorObserver;
class vtkLabelPlacementMapper;
class vtkPolyDataMapper2D;
class vtkSelection;
class vtkTextProperty;
class vtkTexture;
class vtkTexturedActor2D;
class vtkTransformCoordinateSystems;
class VTKVIEWSINFOVIS_EXPORT vtkRenderView : public vtkRenderViewBase
{
public:
static vtkRenderView* New();
vtkTypeMacro(vtkRenderView, vtkRenderViewBase);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* The render window interactor. Note that this requires special
* handling in order to do correctly - see the notes in the detailed
* description of vtkRenderViewBase.
*/
void SetInteractor(vtkRenderWindowInteractor* interactor) override;
/**
* The interactor style associated with the render view.
*/
virtual void SetInteractorStyle(vtkInteractorObserver* style);
/**
* Get the interactor style associated with the render view.
*/
virtual vtkInteractorObserver* GetInteractorStyle();
/**
* Set the render window for this view. Note that this requires special
* handling in order to do correctly - see the notes in the detailed
* description of vtkRenderViewBase.
*/
void SetRenderWindow(vtkRenderWindow* win) override;
enum
{
INTERACTION_MODE_2D,
INTERACTION_MODE_3D,
INTERACTION_MODE_UNKNOWN
};
void SetInteractionMode(int mode);
vtkGetMacro(InteractionMode, int);
/**
* Set the interaction mode for the view. Choices are:
* vtkRenderView::INTERACTION_MODE_2D - 2D interactor
* vtkRenderView::INTERACTION_MODE_3D - 3D interactor
*/
virtual void SetInteractionModeTo2D() { this->SetInteractionMode(INTERACTION_MODE_2D); }
virtual void SetInteractionModeTo3D() { this->SetInteractionMode(INTERACTION_MODE_3D); }
/**
* Updates the representations, then calls Render() on the render window
* associated with this view.
*/
void Render() override;
/**
* Applies a view theme to this view.
*/
void ApplyViewTheme(vtkViewTheme* theme) override;
//@{
/**
* Set the view's transform. All vtkRenderedRepresentations
* added to this view should use this transform.
*/
virtual void SetTransform(vtkAbstractTransform* transform);
vtkGetObjectMacro(Transform, vtkAbstractTransform);
//@}
//@{
/**
* Whether the view should display hover text.
*/
virtual void SetDisplayHoverText(bool b);
vtkGetMacro(DisplayHoverText, bool);
vtkBooleanMacro(DisplayHoverText, bool);
//@}
enum
{
SURFACE = 0,
FRUSTUM = 1
};
//@{
/**
* Sets the selection mode for the render view.
* SURFACE selection uses vtkHardwareSelector to perform a selection
* of visible cells.
* FRUSTUM selection just creates a view frustum selection, which will
* select everything in the frustum.
*/
vtkSetClampMacro(SelectionMode, int, 0, 1);
vtkGetMacro(SelectionMode, int);
void SetSelectionModeToSurface() { this->SetSelectionMode(SURFACE); }
void SetSelectionModeToFrustum() { this->SetSelectionMode(FRUSTUM); }
//@}
/**
* Add labels from an input connection with an associated text
* property. The output must be a vtkLabelHierarchy (normally the
* output of vtkPointSetToLabelHierarchy).
*/
virtual void AddLabels(vtkAlgorithmOutput* conn);
/**
* Remove labels from an input connection.
*/
virtual void RemoveLabels(vtkAlgorithmOutput* conn);
//@{
/**
* Set the icon sheet to use for rendering icons.
*/
virtual void SetIconTexture(vtkTexture* texture);
vtkGetObjectMacro(IconTexture, vtkTexture);
//@}
//@{
/**
* Set the size of each icon in the icon texture.
*/
vtkSetVector2Macro(IconSize, int);
vtkGetVector2Macro(IconSize, int);
//@}
//@{
/**
* Set the display size of the icon (which may be different from the icon
* size). By default, if this value is not set, the IconSize is used.
*/
vtkSetVector2Macro(DisplaySize, int);
int* GetDisplaySize();
void GetDisplaySize(int& dsx, int& dsy);
//@}
enum
{
NO_OVERLAP,
ALL
};
//@{
/**
* Label placement mode.
* NO_OVERLAP uses vtkLabelPlacementMapper, which has a faster startup time and
* works with 2D or 3D labels.
* ALL displays all labels (Warning: This may cause incredibly slow render
* times on datasets with more than a few hundred labels).
*/
virtual void SetLabelPlacementMode(int mode);
virtual int GetLabelPlacementMode();
virtual void SetLabelPlacementModeToNoOverlap() { this->SetLabelPlacementMode(NO_OVERLAP); }
virtual void SetLabelPlacementModeToAll() { this->SetLabelPlacementMode(ALL); }
//@}
enum
{
FREETYPE,
QT
};
//@{
/**
* Label render mode.
* FREETYPE uses the freetype label rendering.
* QT uses more advanced Qt-based label rendering.
*/
virtual void SetLabelRenderMode(int mode);
virtual int GetLabelRenderMode();
virtual void SetLabelRenderModeToFreetype() { this->SetLabelRenderMode(FREETYPE); }
virtual void SetLabelRenderModeToQt() { this->SetLabelRenderMode(QT); }
//@}
//@{
/**
* Whether to render on every mouse move.
*/
void SetRenderOnMouseMove(bool b);
vtkGetMacro(RenderOnMouseMove, bool);
vtkBooleanMacro(RenderOnMouseMove, bool);
//@}
protected:
vtkRenderView();
~vtkRenderView() override;
/**
* Called to process events.
* Captures StartEvent events from the renderer and calls Update().
* This may be overridden by subclasses to process additional events.
*/
void ProcessEvents(vtkObject* caller, unsigned long eventId, void* callData) override;
/**
* Generates the selection based on the view event and the selection mode.
*/
virtual void GenerateSelection(void* callData, vtkSelection* selection);
/**
* Called by the view when the renderer is about to render.
*/
void PrepareForRendering() override;
/**
* Called in PrepareForRendering to update the hover text.
*/
virtual void UpdateHoverText();
/**
* Enable or disable hovering based on DisplayHoverText ivar
* and interaction state.
*/
virtual void UpdateHoverWidgetState();
/**
* Update the pick render for queries for drag selections
* or hover ballooons.
*/
void UpdatePickRender();
int SelectionMode;
int LabelRenderMode;
bool DisplayHoverText;
bool Interacting;
bool InHoverTextRender;
bool InPickRender;
bool PickRenderNeedsUpdate;
vtkAbstractTransform* Transform;
vtkTexture* IconTexture;
int IconSize[2];
int DisplaySize[2];
int InteractionMode;
bool RenderOnMouseMove;
vtkSmartPointer<vtkRenderer> LabelRenderer;
vtkSmartPointer<vtkBalloonRepresentation> Balloon;
vtkSmartPointer<vtkLabelPlacementMapper> LabelPlacementMapper;
vtkSmartPointer<vtkTexturedActor2D> LabelActor;
vtkSmartPointer<vtkHoverWidget> HoverWidget;
vtkSmartPointer<vtkHardwareSelector> Selector;
private:
vtkRenderView(const vtkRenderView&) = delete;
void operator=(const vtkRenderView&) = delete;
};
#endif