VTK  9.6.1
vtkContextScene.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
19
20#ifndef vtkContextScene_h
21#define vtkContextScene_h
22
23#include "vtkObject.h"
24#include "vtkRenderingContext2DModule.h" // For export macro
25#include "vtkVector.h" // For vtkVector return type.
26#include "vtkWeakPointer.h" // Needed for weak pointer to the window.
27#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
28
29VTK_ABI_NAMESPACE_BEGIN
30class vtkContext2D;
32class vtkTransform2D;
37
39
40class vtkRenderer;
42
43class VTKRENDERINGCONTEXT2D_EXPORT VTK_MARSHALAUTO vtkContextScene : public vtkObject
44{
45public:
46 vtkTypeMacro(vtkContextScene, vtkObject);
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
53
57 virtual bool Paint(vtkContext2D* painter);
58
63 unsigned int AddItem(vtkAbstractContextItem* item);
64
71
77 bool RemoveItem(unsigned int index);
78
83 vtkAbstractContextItem* GetItem(unsigned int index);
84
88 unsigned int GetNumberOfItems() VTK_FUTURE_CONST;
89
93 void ClearItems();
94 void RemoveAllItems() { this->ClearItems(); }
95
100
102
107
109
112 vtkSetVector2Macro(Origin, int);
113 vtkGetVector2Macro(Origin, int);
115
117
120 vtkSetVector2Macro(Geometry, int);
122
124
127 vtkGetVector2Macro(Geometry, int);
129
131
134 vtkSetMacro(UseBufferId, bool);
136
138
141 vtkGetMacro(UseBufferId, bool);
143
150 virtual int GetViewWidth();
151
158 virtual int GetViewHeight();
159
164 virtual int GetSceneLeft();
165
170 virtual int GetSceneBottom();
171
176
181
183
188 vtkSetMacro(ScaleTiles, bool);
189 vtkGetMacro(ScaleTiles, bool);
190 vtkBooleanMacro(ScaleTiles, bool);
192
200
202
206 virtual void SetRenderer(vtkRenderer* renderer);
209
211
216 void SetDirty(bool isDirty);
217 bool GetDirty() const;
219
224
231
238
242 virtual void SetTransform(vtkTransform2D* transform);
243
248
252 bool HasTransform() { return this->Transform != nullptr; }
253
260
266
271 {
272 SELECTION_DEFAULT = 0, // selection = newSelection
273 SELECTION_ADDITION, // selection = prevSelection | newSelection
274 SELECTION_SUBTRACTION, // selection = prevSelection & !newSelection
275 SELECTION_TOGGLE // selection = prevSelection ^ newSelection
276 };
277
278protected:
281
285 virtual bool ProcessSelectionEvent(unsigned int rect[5]);
286
290 virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
291
295 virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
296
300 virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
301
305 virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
306
310 virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
311
315 virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
316
320 virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
321
326 virtual void PaintIds();
327
332
337
339
340 // Store the chart origin - left, bottom of scene in pixels
341 int Origin[2];
342 // Store the chart dimensions - width, height of scene in pixels
343 int Geometry[2];
344
350
352
355 class Private;
356 Private* Storage;
358
365
367
369
372
374
377
379
384
385private:
386 vtkContextScene(const vtkContextScene&) = delete;
387 void operator=(const vtkContextScene&) = delete;
388
389 typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
390 bool ProcessItem(
391 vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
392 void EventCopy(const vtkContextMouseEvent& event);
393};
394
395VTK_ABI_NAMESPACE_END
396#endif // vtkContextScene_h
2D array of ids, used for picking.
base class for items that are part of a vtkContextScene.
Class for drawing 2D primitives to a graphical context.
An interactor for chart views.
data structure to represent key events.
data structure to represent mouse events.
Private implementation for scene/items.
unsigned int AddItem(vtkAbstractContextItem *item)
Add child items to this item.
~vtkContextScene() override
bool RemoveItem(vtkAbstractContextItem *item)
Remove child item from this item.
virtual void SetTransform(vtkTransform2D *transform)
Set the transform for the scene.
virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent &event)
Process a mouse wheel event where delta is the movement forward or back.
virtual void SetAnnotationLink(vtkAnnotationLink *link)
Set the vtkAnnotationLink for the chart.
void ClearItems()
Remove all child items from this item.
vtkWeakPointer< vtkRenderer > Renderer
vtkAnnotationLink * AnnotationLink
virtual void PaintIds()
Paint the scene in a special mode to build a cache for picking.
void SetDirty(bool isDirty)
Inform the scene that something changed that requires a repaint of the scene.
virtual int GetSceneLeft()
Get the left of the scene in screen coordinates.
vtkAbstractContextBufferId * BufferId
virtual int GetSceneBottom()
Get the bottom of the scene in screen coordinates.
void UpdateBufferId()
Make sure the buffer id used for picking is up-to-date.
SelectionModifier
Enum of valid selection modes for charts in the scene.
virtual bool KeyPressEvent(const vtkContextKeyEvent &keyEvent)
Process a key press event.
virtual int GetViewHeight()
Get the height of the view (render window) containing this scene.
bool RemoveItem(unsigned int index)
Remove child item from this item.
vtkWeakPointer< vtkContext2D > LastPainter
vtkWeakPointer< vtkContext2D > GetLastPainter()
Last painter used.
vtkVector2i GetLogicalTileScale()
The tile scale of the target vtkRenderWindow.
vtkTransform2D * GetTransform()
Get the transform for the scene.
bool GetDirty() const
Inform the scene that something changed that requires a repaint of the scene.
vtkAbstractContextBufferId * GetBufferId()
Return buffer id.
int GetSceneHeight()
Get the height of the scene.
vtkAbstractContextItem * GetPickedItem()
Return the item under the mouse.
virtual bool Paint(vtkContext2D *painter)
Paint event for the chart, called whenever the chart needs to be drawn.
void ReleaseGraphicsResources()
Release graphics resources hold by the scene.
virtual bool DoubleClickEvent(const vtkContextMouseEvent &event)
Process a mouse button double click event.
virtual void SetRenderer(vtkRenderer *renderer)
This should not be necessary as the context view should take care of rendering.
vtkAbstractContextItem * GetItem(unsigned int index)
Get the item at the specified index.
virtual vtkRenderer * GetRenderer()
This should not be necessary as the context view should take care of rendering.
virtual int GetViewWidth()
Get the width of the view (render window) containing this scene.
void TestBufferIdSupport()
Test if BufferId is supported by the OpenGL context.
vtkContextScenePrivate * Children
This structure provides a list of children, along with convenience functions to paint the children et...
bool HasTransform()
Check whether the scene has a transform.
virtual bool ProcessSelectionEvent(unsigned int rect[5])
Process a rubber band selection event.
int GetSceneWidth()
Get the width of the scene.
virtual bool MouseMoveEvent(const vtkContextMouseEvent &event)
Process a mouse move event.
vtkIdType GetPickedItem(int x, int y)
Return the item id under mouse cursor at position (x,y).
vtkTransform2D * Transform
The scene level transform.
virtual bool ButtonPressEvent(const vtkContextMouseEvent &event)
Process a mouse button press event.
virtual bool KeyReleaseEvent(const vtkContextKeyEvent &keyEvent)
Process a key release event.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
friend class vtkContextInteractorStyle
The vtkContextInteractorStyle class delegates all of the events to the scene, accessing protected API...
static vtkContextScene * New()
Creates a 2D Painter object.
unsigned int GetNumberOfItems() VTK_FUTURE_CONST
Get the number of child items.
virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event)
Process a mouse button release event.
a simple class to control print indentation
Definition vtkIndent.h:29
abstract specification for renderers
Definition vtkRenderer.h:64
describes linear transformations via a 3x3 matrix
Some derived classes for the different vectors commonly used.
Definition vtkVector.h:411
a weak reference to a vtkObject.
int vtkIdType
Definition vtkType.h:368
#define VTK_MARSHALAUTO