VTK  9.3.0
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
29#ifndef vtkContextScene_h
30#define vtkContextScene_h
31
32#include "vtkObject.h"
33#include "vtkRenderingContext2DModule.h" // For export macro
34#include "vtkVector.h" // For vtkVector return type.
35#include "vtkWeakPointer.h" // Needed for weak pointer to the window.
36
37VTK_ABI_NAMESPACE_BEGIN
38class vtkContext2D;
40class vtkTransform2D;
45
47
48class vtkRenderer;
50
51class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject
52{
53public:
54 vtkTypeMacro(vtkContextScene, vtkObject);
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
61
65 virtual bool Paint(vtkContext2D* painter);
66
71 unsigned int AddItem(vtkAbstractContextItem* item);
72
79
85 bool RemoveItem(unsigned int index);
86
91 vtkAbstractContextItem* GetItem(unsigned int index);
92
96 unsigned int GetNumberOfItems();
97
102
107
109
112 vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
114
116
119 vtkSetVector2Macro(Origin, int);
120 vtkGetVector2Macro(Origin, int);
122
124
127 vtkSetVector2Macro(Geometry, int);
129
131
134 vtkGetVector2Macro(Geometry, int);
136
138
141 vtkSetMacro(UseBufferId, bool);
143
145
148 vtkGetMacro(UseBufferId, bool);
150
157 virtual int GetViewWidth();
158
165 virtual int GetViewHeight();
166
171 virtual int GetSceneLeft();
172
177 virtual int GetSceneBottom();
178
183
188
190
195 vtkSetMacro(ScaleTiles, bool);
196 vtkGetMacro(ScaleTiles, bool);
197 vtkBooleanMacro(ScaleTiles, bool);
199
207
209
213 virtual void SetRenderer(vtkRenderer* renderer);
216
218
223 void SetDirty(bool isDirty);
224 bool GetDirty() const;
226
231
238
245
249 virtual void SetTransform(vtkTransform2D* transform);
250
255
259 bool HasTransform() { return this->Transform != nullptr; }
260
267
273
278 {
279 SELECTION_DEFAULT = 0, // selection = newSelection
280 SELECTION_ADDITION, // selection = prevSelection | newSelection
281 SELECTION_SUBTRACTION, // selection = prevSelection & !newSelection
282 SELECTION_TOGGLE // selection = prevSelection ^ newSelection
283 };
284
285protected:
288
292 virtual bool ProcessSelectionEvent(unsigned int rect[5]);
293
297 virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
298
302 virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
303
307 virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
308
312 virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
313
317 virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
318
322 virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
323
327 virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
328
333 virtual void PaintIds();
334
339
344
346
347 // Store the chart origin - left, bottom of scene in pixels
348 int Origin[2];
349 // Store the chart dimensions - width, height of scene in pixels
350 int Geometry[2];
351
357
359
362 class Private;
363 Private* Storage;
365
372
374
376
379
381
384
386
391
392private:
393 vtkContextScene(const vtkContextScene&) = delete;
394 void operator=(const vtkContextScene&) = delete;
395
396 typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
397 bool ProcessItem(
398 vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
399 void EventCopy(const vtkContextMouseEvent& event);
400};
401
402VTK_ABI_NAMESPACE_END
403#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.
Provides a 2D scene for vtkContextItem objects.
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.
unsigned int GetNumberOfItems()
Get the number of child items.
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.
static vtkContextScene * New()
Creates a 2D Painter object.
virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event)
Process a mouse button release event.
a simple class to control print indentation
Definition vtkIndent.h:38
abstract base class for most VTK objects
Definition vtkObject.h:58
abstract specification for renderers
Definition vtkRenderer.h:68
describes linear transformations via a 3x3 matrix
Some derived classes for the different vectors commonly used.
Definition vtkVector.h:420
a weak reference to a vtkObject.
int vtkIdType
Definition vtkType.h:315