VTK  9.4.20251007
vtkAbstractContextItem.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
14
15#ifndef vtkAbstractContextItem_h
16#define vtkAbstractContextItem_h
17
18#include "vtkObject.h"
19#include "vtkRenderingContext2DModule.h" // For export macro
20#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
21
22VTK_ABI_NAMESPACE_BEGIN
23class vtkContext2D;
26class vtkContextScene;
28class vtkVector2f;
29
30class VTKRENDERINGCONTEXT2D_EXPORT VTK_MARSHALAUTO vtkAbstractContextItem : public vtkObject
31{
32public:
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35
41 virtual void Update();
42
46 virtual bool Paint(vtkContext2D* painter);
47
52 virtual bool PaintChildren(vtkContext2D* painter);
53
59
66
74
80 bool RemoveItem(vtkIdType index);
81
88
94
99
104
111
119
126
134
138 virtual bool Hit(const vtkContextMouseEvent& mouse);
139
145
151 virtual bool MouseEnterEvent(const vtkContextMouseEvent& mouse);
152
158 virtual bool MouseMoveEvent(const vtkContextMouseEvent& mouse);
159
165 virtual bool MouseLeaveEvent(const vtkContextMouseEvent& mouse);
166
172 virtual bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse);
173
180
186 virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse);
187
193 virtual bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta);
194
198 virtual bool KeyPressEvent(const vtkContextKeyEvent& key);
199
203 virtual bool KeyReleaseEvent(const vtkContextKeyEvent& key);
204
208 virtual void SetScene(vtkContextScene* scene);
209
213 vtkContextScene* GetScene() { return this->Scene; }
214
219 virtual void SetParent(vtkAbstractContextItem* parent);
220
226
230 virtual vtkVector2f MapToParent(const vtkVector2f& point);
231
235 virtual vtkVector2f MapFromParent(const vtkVector2f& point);
236
240 virtual vtkVector2f MapToScene(const vtkVector2f& point);
241
245 virtual vtkVector2f MapFromScene(const vtkVector2f& point);
246
248
251 virtual bool GetVisible()
252 {
253 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning Visible of "
254 << this->Visible);
255 return this->Visible;
256 }
257
259
261
265 vtkSetMacro(Visible, bool);
267
269
272 vtkGetMacro(Interactive, bool);
274
276
279 vtkSetMacro(Interactive, bool);
281
282protected:
285
289 virtual void ReleaseGraphicsCache();
290
295
300
307
312
317
318private:
320 void operator=(const vtkAbstractContextItem&) = delete;
321};
322
323VTK_ABI_NAMESPACE_END
324#endif // vtkContextItem_h
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
Mouse button double click event.
virtual vtkVector2f MapToParent(const vtkVector2f &point)
Maps the point to the parent coordinate system.
vtkContextScene * Scene
Point to the scene the item is on - can be null.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkContextScenePrivate * Children
This structure provides a list of children, along with convenience functions to paint the children et...
vtkAbstractContextItem * GetParent()
Get the parent item.
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool PaintChildren(vtkContext2D *painter)
Paint the children of the item, should be called whenever the children need to be rendered.
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
virtual vtkVector2f MapFromScene(const vtkVector2f &point)
Maps the point from the scene coordinate system.
bool Interactive
Store whether the item should respond to interactions (default is true).
virtual vtkAbstractContextItem * GetPickedItem(const vtkContextMouseEvent &mouse)
Return the item under the mouse.
vtkAbstractContextItem * Parent
Point to the parent item - can be null.
virtual bool KeyReleaseEvent(const vtkContextKeyEvent &key)
Key release event.
vtkContextScene * GetScene()
Get the vtkContextScene for the item, always set for an item in a scene.
vtkIdType Lower(vtkIdType index)
Lowers the child to the bottom of the item's stack.
virtual void SetParent(vtkAbstractContextItem *parent)
Set the parent item.
virtual vtkIdType StackUnder(vtkIdType child, vtkIdType above)
Lowers the child under the above sibling.
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Mouse enter event.
vtkAbstractContextItem * GetItem(vtkIdType index)
Get the item at the specified index.
virtual bool GetVisible()
Get the visibility of the item (should it be drawn).
~vtkAbstractContextItem() override
vtkIdType AddItem(vtkAbstractContextItem *item)
Add child items to this item.
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
Key press event.
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse)
Mouse leave event.
bool Visible
Store the visibility of the item (default is true).
virtual vtkVector2f MapFromParent(const vtkVector2f &point)
Maps the point from the parent coordinate system.
vtkIdType Raise(vtkIdType index)
Raises the child to the top of the item's stack.
virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta)
Mouse wheel event, positive delta indicates forward movement of the wheel.
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
virtual void ReleaseGraphicsCache()
Release cache entries created by this context item.
virtual vtkVector2f MapToScene(const vtkVector2f &point)
Maps the point to the scene coordinate system.
virtual vtkIdType StackAbove(vtkIdType index, vtkIdType under)
Raises the child above the under sibling.
virtual void ReleaseGraphicsResources()
Release graphics resources hold by the item.
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
vtkIdType GetItemIndex(vtkAbstractContextItem *item)
Get the index of the specified item in itemIndex.
vtkIdType GetNumberOfItems()
Get the number of child items.
void ClearItems()
Remove all child items from this item.
virtual void SetScene(vtkContextScene *scene)
Set the vtkContextScene for the item, always set for an item in a scene.
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
bool RemoveItem(vtkAbstractContextItem *item)
Remove child item from this item.
Class for drawing 2D primitives to a graphical context.
data structure to represent key events.
data structure to represent mouse events.
Private implementation for scene/items.
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition vtkIndent.h:29
const char * GetClassName() const
Return the class name as a string.
int vtkIdType
Definition vtkType.h:315
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)