VTK  9.3.20240329
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 
89 #ifndef vtkContextScene_h
90 #define vtkContextScene_h
91 
92 #include "vtkObject.h"
93 #include "vtkRenderingContext2DModule.h" // For export macro
94 #include "vtkVector.h" // For vtkVector return type.
95 #include "vtkWeakPointer.h" // Needed for weak pointer to the window.
96 
97 VTK_ABI_NAMESPACE_BEGIN
98 class vtkContext2D;
100 class vtkTransform2D;
102 class vtkContextKeyEvent;
105 
106 class vtkAnnotationLink;
107 
108 class vtkRenderer;
110 
111 class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject
112 {
113 public:
114  vtkTypeMacro(vtkContextScene, vtkObject);
115  void PrintSelf(ostream& os, vtkIndent indent) override;
116 
120  static vtkContextScene* New();
121 
125  virtual bool Paint(vtkContext2D* painter);
126 
131  unsigned int AddItem(vtkAbstractContextItem* item);
132 
139 
145  bool RemoveItem(unsigned int index);
146 
152 
156  unsigned int GetNumberOfItems();
157 
161  void ClearItems();
162 
167 
169 
172  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
174 
176 
179  vtkSetVector2Macro(Origin, int);
180  vtkGetVector2Macro(Origin, int);
182 
184 
187  vtkSetVector2Macro(Geometry, int);
189 
191 
194  vtkGetVector2Macro(Geometry, int);
196 
198 
201  vtkSetMacro(UseBufferId, bool);
203 
205 
208  vtkGetMacro(UseBufferId, bool);
210 
217  virtual int GetViewWidth();
218 
225  virtual int GetViewHeight();
226 
231  virtual int GetSceneLeft();
232 
237  virtual int GetSceneBottom();
238 
243 
248 
250 
255  vtkSetMacro(ScaleTiles, bool);
256  vtkGetMacro(ScaleTiles, bool);
257  vtkBooleanMacro(ScaleTiles, bool);
259 
267 
269 
273  virtual void SetRenderer(vtkRenderer* renderer);
276 
278 
283  void SetDirty(bool isDirty);
284  bool GetDirty() const;
286 
291 
298 
305 
309  virtual void SetTransform(vtkTransform2D* transform);
310 
315 
319  bool HasTransform() { return this->Transform != nullptr; }
320 
326  vtkIdType GetPickedItem(int x, int y);
327 
333 
338  {
339  SELECTION_DEFAULT = 0, // selection = newSelection
340  SELECTION_ADDITION, // selection = prevSelection | newSelection
341  SELECTION_SUBTRACTION, // selection = prevSelection & !newSelection
342  SELECTION_TOGGLE // selection = prevSelection ^ newSelection
343  };
344 
345 protected:
347  ~vtkContextScene() override;
348 
352  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
353 
357  virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
358 
362  virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
363 
367  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
368 
372  virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
373 
377  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
378 
382  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
383 
387  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
388 
393  virtual void PaintIds();
394 
399 
404 
406 
407  // Store the chart origin - left, bottom of scene in pixels
408  int Origin[2];
409  // Store the chart dimensions - width, height of scene in pixels
410  int Geometry[2];
411 
417 
419 
422  class Private;
423  Private* Storage;
425 
432 
434 
436 
439 
441 
444 
446 
451 
452 private:
453  vtkContextScene(const vtkContextScene&) = delete;
454  void operator=(const vtkContextScene&) = delete;
455 
456  typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
457  bool ProcessItem(
458  vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
459  void EventCopy(const vtkContextMouseEvent& event);
460 };
461 
462 VTK_ABI_NAMESPACE_END
463 #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:69
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:108
abstract base class for most VTK objects
Definition: vtkObject.h:162
abstract specification for renderers
Definition: vtkRenderer.h:172
describes linear transformations via a 3x3 matrix
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:470
@ Transform
Definition: vtkX3D.h:41
@ index
Definition: vtkX3D.h:246
int vtkIdType
Definition: vtkType.h:315