VTK  9.0.2
vtkContextScene.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkContextScene.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
26 #ifndef vtkContextScene_h
27 #define vtkContextScene_h
28 
29 #include "vtkObject.h"
30 #include "vtkRenderingContext2DModule.h" // For export macro
31 #include "vtkVector.h" // For vtkVector return type.
32 #include "vtkWeakPointer.h" // Needed for weak pointer to the window.
33 
34 class vtkContext2D;
36 class vtkTransform2D;
38 class vtkContextKeyEvent;
41 
42 class vtkAnnotationLink;
43 
44 class vtkRenderer;
46 
47 class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject
48 {
49 public:
50  vtkTypeMacro(vtkContextScene, vtkObject);
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
56  static vtkContextScene* New();
57 
61  virtual bool Paint(vtkContext2D* painter);
62 
67  unsigned int AddItem(vtkAbstractContextItem* item);
68 
75 
81  bool RemoveItem(unsigned int index);
82 
88 
92  unsigned int GetNumberOfItems();
93 
97  void ClearItems();
98 
103 
105 
108  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
110 
112 
115  vtkSetVector2Macro(Geometry, int);
117 
119 
122  vtkGetVector2Macro(Geometry, int);
124 
126 
129  vtkSetMacro(UseBufferId, bool);
131 
133 
136  vtkGetMacro(UseBufferId, bool);
138 
142  virtual int GetViewWidth();
143 
147  virtual int GetViewHeight();
148 
153 
158 
160 
165  vtkSetMacro(ScaleTiles, bool);
166  vtkGetMacro(ScaleTiles, bool);
167  vtkBooleanMacro(ScaleTiles, bool);
169 
177 
179 
183  virtual void SetRenderer(vtkRenderer* renderer);
186 
188 
193  void SetDirty(bool isDirty);
194  bool GetDirty() const;
196 
201 
208 
215 
219  virtual void SetTransform(vtkTransform2D* transform);
220 
225 
229  bool HasTransform() { return this->Transform != nullptr; }
230 
234  enum
235  {
236  SELECTION_NONE = 0,
240  SELECTION_TOGGLE
241  };
242 
243 protected:
245  ~vtkContextScene() override;
246 
250  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
251 
255  virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
256 
260  virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
261 
265  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
266 
270  virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
271 
275  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
276 
280  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
281 
285  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
286 
291  virtual void PaintIds();
292 
297 
303  vtkIdType GetPickedItem(int x, int y);
304 
310 
315 
317 
318  // Store the chart dimensions - width, height of scene in pixels
319  int Geometry[2];
320 
326 
328 
331  class Private;
332  Private* Storage;
334 
341 
343 
345 
348 
350 
353 
355 
360 
361 private:
362  vtkContextScene(const vtkContextScene&) = delete;
363  void operator=(const vtkContextScene&) = delete;
364 
365  typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
366  bool ProcessItem(
367  vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
368  void EventCopy(const vtkContextMouseEvent& event);
369 };
370 
371 #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:53
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.
vtkAbstractContextBufferId * BufferId
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.
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.
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
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.
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()
virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event)
Process a mouse button release event.
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
abstract specification for renderers
Definition: vtkRenderer.h:68
describes linear transformations via a 3x3 matrix
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:420
@ Transform
Definition: vtkX3D.h:47
@ index
Definition: vtkX3D.h:252
int vtkIdType
Definition: vtkType.h:338