VTK
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 
74  bool RemoveItem(vtkAbstractContextItem* item);
75 
81  bool RemoveItem(unsigned int index);
82 
87  vtkAbstractContextItem* GetItem(unsigned int index);
88 
92  unsigned int GetNumberOfItems();
93 
97  void ClearItems();
98 
102  virtual void SetAnnotationLink(vtkAnnotationLink* link);
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 
152  int GetSceneWidth();
153 
157  int GetSceneHeight();
158 
160 
165  vtkSetMacro(ScaleTiles, bool);
166  vtkGetMacro(ScaleTiles, bool);
167  vtkBooleanMacro(ScaleTiles, bool);
169 
176  vtkVector2i GetLogicalTileScale();
177 
179 
183  virtual void SetRenderer(vtkRenderer* renderer);
184  virtual vtkRenderer* GetRenderer();
186 
188 
193  void SetDirty(bool isDirty);
194  bool GetDirty() const;
196 
200  void ReleaseGraphicsResources();
201 
207  vtkWeakPointer<vtkContext2D> GetLastPainter();
208 
214  vtkAbstractContextBufferId* GetBufferId();
215 
219  virtual void SetTransform(vtkTransform2D* transform);
220 
224  vtkTransform2D* GetTransform();
225 
229  bool HasTransform() { return this->Transform != nullptr; }
230 
234  enum
235  {
236  SELECTION_NONE = 0,
240  SELECTION_TOGGLE
241  };
242 
243 protected:
244  vtkContextScene();
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 
296  void TestBufferIdSupport();
297 
303  vtkIdType GetPickedItem(int x, int y);
304 
309  vtkAbstractContextItem* GetPickedItem();
310 
314  void UpdateBufferId();
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
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:34
vtkContextKeyEvent
data structure to represent key events.
Definition: vtkContextKeyEvent.h:34
vtkIdType
int vtkIdType
Definition: vtkType.h:343
vtkAbstractContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkAbstractContextItem.h:40
vtkTransform2D
describes linear transformations via a 3x3 matrix
Definition: vtkTransform2D.h:45
vtkContextScene::BufferId
vtkAbstractContextBufferId * BufferId
Definition: vtkContextScene.h:346
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkContextScene::Children
vtkContextScenePrivate * Children
This structure provides a list of children, along with convenience functions to paint the children et...
Definition: vtkContextScene.h:340
vtkContextScene::SELECTION_DEFAULT
Definition: vtkContextScene.h:237
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkContextScene::BufferIdDirty
bool BufferIdDirty
Definition: vtkContextScene.h:347
vtkVector.h
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
vtkX3D::Transform
Definition: vtkX3D.h:47
vtkContextScene::SELECTION_SUBTRACTION
Definition: vtkContextScene.h:239
vtkContextScene::UseBufferId
bool UseBufferId
Definition: vtkContextScene.h:349
vtkAbstractContextBufferId
2D array of ids, used for picking.
Definition: vtkAbstractContextBufferId.h:46
vtkContextScene::BufferIdSupported
bool BufferIdSupported
Definition: vtkContextScene.h:352
vtkContextScene
Provides a 2D scene for vtkContextItem objects.
Definition: vtkContextScene.h:47
vtkContextScene::Transform
vtkTransform2D * Transform
The scene level transform.
Definition: vtkContextScene.h:359
vtkContextScene::ScaleTiles
bool ScaleTiles
Definition: vtkContextScene.h:354
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkContextScene::SELECTION_ADDITION
Definition: vtkContextScene.h:238
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkWeakPointer.h
vtkContextScene::Storage
Private * Storage
Definition: vtkContextScene.h:331
vtkContextScenePrivate
Private implementation for scene/items.
Definition: vtkContextScenePrivate.h:40
vtkObject.h
vtkContextInteractorStyle
An interactor for chart views.
Definition: vtkContextInteractorStyle.h:36
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:58
vtkContextScene::Renderer
vtkWeakPointer< vtkRenderer > Renderer
Definition: vtkContextScene.h:344
vtkContextScene::AnnotationLink
vtkAnnotationLink * AnnotationLink
Definition: vtkContextScene.h:316
vtkVector2i
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:419
vtkContextScene::BufferIdSupportTested
bool BufferIdSupportTested
Definition: vtkContextScene.h:351
vtkContextScene::HasTransform
bool HasTransform()
Check whether the scene has a transform.
Definition: vtkContextScene.h:229
vtkX3D::index
Definition: vtkX3D.h:252
vtkContextScene::LastPainter
vtkWeakPointer< vtkContext2D > LastPainter
Definition: vtkContextScene.h:342
vtkWeakPointer< vtkContext2D >