VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
28 
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkContext2D;
32 class vtkTransform2D;
34 class vtkContextKeyEvent;
37 
38 class vtkAnnotationLink;
39 
40 class vtkRenderer;
42 
43 class VTKRENDERINGCONTEXT2D_EXPORT VTK_MARSHALAUTO vtkContextScene : public vtkObject
44 {
45 public:
46  vtkTypeMacro(vtkContextScene, vtkObject);
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
52  static vtkContextScene* New();
53 
57  virtual bool Paint(vtkContext2D* painter);
58 
63  unsigned int AddItem(vtkAbstractContextItem* item);
64 
70  bool RemoveItem(vtkAbstractContextItem* item);
71 
77  bool RemoveItem(unsigned int index);
78 
83  vtkAbstractContextItem* GetItem(unsigned int index);
84 
88  unsigned int GetNumberOfItems() VTK_FUTURE_CONST;
89 
93  void ClearItems();
94  void RemoveAllItems() { this->ClearItems(); }
95 
99  virtual void SetAnnotationLink(vtkAnnotationLink* link);
100 
102 
105  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
107 
109 
112  vtkSetVector2Macro(Origin, int);
113  vtkGetVector2Macro(Origin, int);
115 
117 
120  vtkSetVector2Macro(Geometry, int);
122 
124 
127  vtkGetVector2Macro(Geometry, int);
129 
131 
134  vtkSetMacro(UseBufferId, bool);
136 
138 
141  vtkGetMacro(UseBufferId, bool);
143 
150  virtual int GetViewWidth();
151 
158  virtual int GetViewHeight();
159 
164  virtual int GetSceneLeft();
165 
170  virtual int GetSceneBottom();
171 
175  int GetSceneWidth();
176 
180  int GetSceneHeight();
181 
183 
188  vtkSetMacro(ScaleTiles, bool);
189  vtkGetMacro(ScaleTiles, bool);
190  vtkBooleanMacro(ScaleTiles, bool);
192 
199  vtkVector2i GetLogicalTileScale();
200 
202 
206  virtual void SetRenderer(vtkRenderer* renderer);
207  virtual vtkRenderer* GetRenderer();
209 
211 
216  void SetDirty(bool isDirty);
217  bool GetDirty() const;
219 
223  void ReleaseGraphicsResources();
224 
230  vtkWeakPointer<vtkContext2D> GetLastPainter();
231 
237  vtkAbstractContextBufferId* GetBufferId();
238 
242  virtual void SetTransform(vtkTransform2D* transform);
243 
247  vtkTransform2D* GetTransform();
248 
252  bool HasTransform() { return this->Transform != nullptr; }
253 
259  vtkIdType GetPickedItem(int x, int y);
260 
265  vtkAbstractContextItem* GetPickedItem();
266 
271  {
272  SELECTION_DEFAULT = 0, // selection = newSelection
273  SELECTION_ADDITION, // selection = prevSelection | newSelection
274  SELECTION_SUBTRACTION, // selection = prevSelection & !newSelection
275  SELECTION_TOGGLE // selection = prevSelection ^ newSelection
276  };
277 
278 protected:
279  vtkContextScene();
280  ~vtkContextScene() override;
281 
285  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
286 
290  virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
291 
295  virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
296 
300  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
301 
305  virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
306 
310  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
311 
315  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
316 
320  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
321 
326  virtual void PaintIds();
327 
331  void TestBufferIdSupport();
332 
336  void UpdateBufferId();
337 
339 
340  // Store the chart origin - left, bottom of scene in pixels
341  int Origin[2];
342  // Store the chart dimensions - width, height of scene in pixels
343  int Geometry[2];
344 
350 
352 
355  class Private;
356  Private* Storage;
358 
365 
367 
369 
372 
374 
377 
379 
384 
385 private:
386  vtkContextScene(const vtkContextScene&) = delete;
387  void operator=(const vtkContextScene&) = delete;
388 
389  typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
390  bool ProcessItem(
391  vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
392  void EventCopy(const vtkContextMouseEvent& event);
393 };
394 
395 VTK_ABI_NAMESPACE_END
396 #endif // vtkContextScene_h
data structure to represent key events.
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:63
vtkWeakPointer< vtkRenderer > Renderer
bool HasTransform()
Check whether the scene has a transform.
int vtkIdType
Definition: vtkType.h:363
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:410
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.
#define VTK_MARSHALAUTO
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