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 
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 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkContext2D;
31 class vtkTransform2D;
33 class vtkContextKeyEvent;
36 
37 class vtkAnnotationLink;
38 
39 class vtkRenderer;
41 
42 class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject
43 {
44 public:
45  vtkTypeMacro(vtkContextScene, vtkObject);
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
51  static vtkContextScene* New();
52 
56  virtual bool Paint(vtkContext2D* painter);
57 
62  unsigned int AddItem(vtkAbstractContextItem* item);
63 
70 
76  bool RemoveItem(unsigned int index);
77 
83 
87  unsigned int GetNumberOfItems();
88 
92  void ClearItems();
93 
97  virtual void SetAnnotationLink(vtkAnnotationLink* link);
98 
100 
103  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
105 
107 
110  vtkSetVector2Macro(Origin, int);
111  vtkGetVector2Macro(Origin, int);
113 
115 
118  vtkSetVector2Macro(Geometry, int);
120 
122 
125  vtkGetVector2Macro(Geometry, int);
127 
129 
132  vtkSetMacro(UseBufferId, bool);
134 
136 
139  vtkGetMacro(UseBufferId, bool);
141 
148  virtual int GetViewWidth();
149 
156  virtual int GetViewHeight();
157 
162  virtual int GetSceneLeft();
163 
168  virtual int GetSceneBottom();
169 
174 
179 
181 
186  vtkSetMacro(ScaleTiles, bool);
187  vtkGetMacro(ScaleTiles, bool);
188  vtkBooleanMacro(ScaleTiles, bool);
190 
198 
200 
204  virtual void SetRenderer(vtkRenderer* renderer);
207 
209 
214  void SetDirty(bool isDirty);
215  bool GetDirty() const;
217 
222 
229 
236 
240  virtual void SetTransform(vtkTransform2D* transform);
241 
246 
250  bool HasTransform() { return this->Transform != nullptr; }
251 
257  vtkIdType GetPickedItem(int x, int y);
258 
264 
269  {
270  SELECTION_DEFAULT = 0, // selection = newSelection
271  SELECTION_ADDITION, // selection = prevSelection | newSelection
272  SELECTION_SUBTRACTION, // selection = prevSelection & !newSelection
273  SELECTION_TOGGLE // selection = prevSelection ^ newSelection
274  };
275 
276 protected:
278  ~vtkContextScene() override;
279 
283  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
284 
288  virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
289 
293  virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
294 
298  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
299 
303  virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
304 
308  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
309 
313  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
314 
318  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
319 
324  virtual void PaintIds();
325 
330 
335 
337 
338  // Store the chart origin - left, bottom of scene in pixels
339  int Origin[2];
340  // Store the chart dimensions - width, height of scene in pixels
341  int Geometry[2];
342 
348 
350 
353  class Private;
354  Private* Storage;
356 
363 
365 
367 
370 
372 
375 
377 
382 
383 private:
384  vtkContextScene(const vtkContextScene&) = delete;
385  void operator=(const vtkContextScene&) = delete;
386 
387  typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
388  bool ProcessItem(
389  vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
390  void EventCopy(const vtkContextMouseEvent& event);
391 };
392 
393 VTK_ABI_NAMESPACE_END
394 #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.
Definition: vtkContext2D.h:50
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.
vtkTransform2D * GetTransform()
Get the transform for 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.
vtkAbstractContextItem * GetItem(unsigned int index)
Get the item at the specified index.
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.
vtkWeakPointer< vtkContext2D > GetLastPainter()
Last painter used.
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.
vtkAbstractContextBufferId * GetBufferId()
Return buffer id.
bool RemoveItem(unsigned int index)
Remove child item from this item.
vtkWeakPointer< vtkContext2D > LastPainter
vtkVector2i GetLogicalTileScale()
The tile scale of the target vtkRenderWindow.
bool GetDirty() const
Inform the scene that something changed that requires a repaint of the scene.
int GetSceneHeight()
Get the height of the scene.
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.
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).
static vtkContextScene * New()
Creates a 2D Painter object.
vtkTransform2D * Transform
The scene level transform.
virtual bool ButtonPressEvent(const vtkContextMouseEvent &event)
Process a mouse button press event.
vtkAbstractContextItem * GetPickedItem()
Return the item under the mouse.
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.
virtual vtkRenderer * GetRenderer()
This should not be necessary as the context view should take care of rendering.
virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event)
Process a mouse button release event.
a simple class to control print indentation
Definition: vtkIndent.h:29
abstract base class for most VTK objects
Definition: vtkObject.h:52
abstract specification for renderers
Definition: vtkRenderer.h:62
describes linear transformations via a 3x3 matrix
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:411
@ Transform
Definition: vtkX3D.h:41
@ index
Definition: vtkX3D.h:246
int vtkIdType
Definition: vtkType.h:315