VTK  9.3.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 
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 
69  bool RemoveItem(vtkAbstractContextItem* item);
70 
76  bool RemoveItem(unsigned int index);
77 
82  vtkAbstractContextItem* GetItem(unsigned int index);
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 
173  int GetSceneWidth();
174 
178  int GetSceneHeight();
179 
181 
186  vtkSetMacro(ScaleTiles, bool);
187  vtkGetMacro(ScaleTiles, bool);
188  vtkBooleanMacro(ScaleTiles, bool);
190 
197  vtkVector2i GetLogicalTileScale();
198 
200 
204  virtual void SetRenderer(vtkRenderer* renderer);
205  virtual vtkRenderer* GetRenderer();
207 
209 
214  void SetDirty(bool isDirty);
215  bool GetDirty() const;
217 
221  void ReleaseGraphicsResources();
222 
228  vtkWeakPointer<vtkContext2D> GetLastPainter();
229 
235  vtkAbstractContextBufferId* GetBufferId();
236 
240  virtual void SetTransform(vtkTransform2D* transform);
241 
245  vtkTransform2D* GetTransform();
246 
250  bool HasTransform() { return this->Transform != nullptr; }
251 
257  vtkIdType GetPickedItem(int x, int y);
258 
263  vtkAbstractContextItem* GetPickedItem();
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:
277  vtkContextScene();
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 
329  void TestBufferIdSupport();
330 
334  void UpdateBufferId();
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
data structure to represent key events.
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Private implementation for scene/items.
abstract specification for renderers
Definition: vtkRenderer.h:61
vtkWeakPointer< vtkRenderer > Renderer
bool HasTransform()
Check whether the scene has a transform.
int vtkIdType
Definition: vtkType.h:315
vtkWeakPointer< vtkContext2D > LastPainter
SelectionModifier
Enum of valid selection modes for charts in the scene.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
An interactor for chart views.
Provides a 2D scene for vtkContextItem objects.
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:440
describes linear transformations via a 3x3 matrix
2D array of ids, used for picking.
vtkContextScenePrivate * Children
This structure provides a list of children, along with convenience functions to paint the children et...
vtkAbstractContextBufferId * BufferId
base class for items that are part of a vtkContextScene.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkTransform2D * Transform
The scene level transform.
vtkAnnotationLink * AnnotationLink