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 
29 #ifndef vtkContextScene_h
30 #define vtkContextScene_h
31 
32 #include "vtkRenderingContext2DModule.h" // For export macro
33 #include "vtkObject.h"
34 #include "vtkWeakPointer.h" // Needed for weak pointer to the window.
35 #include "vtkVector.h" // For vtkVector return type.
36 
37 class vtkContext2D;
39 class vtkTransform2D;
41 class vtkContextKeyEvent;
44 
45 class vtkAnnotationLink;
46 
47 class vtkRenderer;
49 
50 class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject
51 {
52 public:
53  vtkTypeMacro(vtkContextScene, vtkObject);
54  void PrintSelf(ostream &os, vtkIndent indent) override;
55 
59  static vtkContextScene * New();
60 
64  virtual bool Paint(vtkContext2D *painter);
65 
70  unsigned int AddItem(vtkAbstractContextItem* item);
71 
78 
84  bool RemoveItem(unsigned int index);
85 
91 
95  unsigned int GetNumberOfItems();
96 
100  void ClearItems();
101 
106 
108 
111  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
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 
145  virtual int GetViewWidth();
146 
150  virtual int GetViewHeight();
151 
156 
161 
163 
168  vtkSetMacro(ScaleTiles, bool);
169  vtkGetMacro(ScaleTiles, bool);
170  vtkBooleanMacro(ScaleTiles, bool);
172 
180 
182 
186  virtual void SetRenderer(vtkRenderer *renderer);
189 
191 
196  void SetDirty(bool isDirty);
197  bool GetDirty()const;
199 
204 
211 
218 
222  virtual void SetTransform(vtkTransform2D *transform);
223 
228 
232  bool HasTransform() { return this->Transform != nullptr; }
233 
237  enum {
238  SELECTION_NONE = 0,
242  SELECTION_TOGGLE
243  };
244 
245 protected:
247  ~vtkContextScene() override;
248 
252  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
253 
257  virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
258 
262  virtual bool ButtonPressEvent(const vtkContextMouseEvent &event);
263 
267  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event);
268 
272  virtual bool DoubleClickEvent(const vtkContextMouseEvent &event);
273 
277  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent &event);
278 
282  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
283 
287  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
288 
293  virtual void PaintIds();
294 
299 
305  vtkIdType GetPickedItem(int x, int y);
306 
312 
317 
319 
320  // Store the chart dimensions - width, height of scene in pixels
321  int Geometry[2];
322 
328 
330 
333  class Private;
334  Private *Storage;
336 
343 
345 
347 
350 
352 
355 
357 
362 
363 private:
364  vtkContextScene(const vtkContextScene &) = delete;
365  void operator=(const vtkContextScene &) = delete;
366 
367  typedef bool (vtkAbstractContextItem::* MouseEvents)(const vtkContextMouseEvent&);
368  bool ProcessItem(vtkAbstractContextItem* cur,
369  const vtkContextMouseEvent& event,
370  MouseEvents eventPtr);
371  void EventCopy(const vtkContextMouseEvent &event);
372 
373 };
374 
375 #endif //vtkContextScene_h
vtkContextScene::GetLogicalTileScale
vtkVector2i GetLogicalTileScale()
The tile scale of the target vtkRenderWindow.
vtkContextScene::SetRenderer
virtual void SetRenderer(vtkRenderer *renderer)
This should not be necessary as the context view should take care of rendering.
vtkContextScene::ReleaseGraphicsResources
void ReleaseGraphicsResources()
Release graphics resources hold by the scene.
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:41
vtkContextScene::Paint
virtual bool Paint(vtkContext2D *painter)
Paint event for the chart, called whenever the chart needs to be drawn.
vtkContextScene::GetPickedItem
vtkAbstractContextItem * GetPickedItem()
Return the item under the mouse.
vtkContextKeyEvent
data structure to represent key events.
Definition: vtkContextKeyEvent.h:35
vtkContextScene::RemoveItem
bool RemoveItem(vtkAbstractContextItem *item)
Remove child item from this item.
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkAbstractContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkAbstractContextItem.h:41
vtkTransform2D
describes linear transformations via a 3x3 matrix
Definition: vtkTransform2D.h:52
vtkContextScene::BufferId
vtkAbstractContextBufferId * BufferId
Definition: vtkContextScene.h:348
vtkContextScene::Children
vtkContextScenePrivate * Children
This structure provides a list of children, along with convenience functions to paint the children et...
Definition: vtkContextScene.h:342
vtkContextScene::GetSceneHeight
int GetSceneHeight()
Get the height of the scene.
vtkContextScene::TestBufferIdSupport
void TestBufferIdSupport()
Test if BufferId is supported by the OpenGL context.
vtkContextScene::ButtonPressEvent
virtual bool ButtonPressEvent(const vtkContextMouseEvent &event)
Process a mouse button press event.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkContextScene::BufferIdDirty
bool BufferIdDirty
Definition: vtkContextScene.h:349
vtkVector.h
vtkContextScene::SetAnnotationLink
virtual void SetAnnotationLink(vtkAnnotationLink *link)
Set the vtkAnnotationLink for the chart.
vtkContextScene::SetTransform
virtual void SetTransform(vtkTransform2D *transform)
Set the transform for the scene.
vtkContextScene::GetPickedItem
vtkIdType GetPickedItem(int x, int y)
Return the item id under mouse cursor at position (x,y).
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:59
vtkContextScene::DoubleClickEvent
virtual bool DoubleClickEvent(const vtkContextMouseEvent &event)
Process a mouse button double click event.
vtkContextScene::UseBufferId
bool UseBufferId
Definition: vtkContextScene.h:351
vtkContextScene::New
static vtkContextScene * New()
Creates a 2D Painter object.
vtkAbstractContextBufferId
2D array of ids, used for picking.
Definition: vtkAbstractContextBufferId.h:47
vtkContextScene::BufferIdSupported
bool BufferIdSupported
Definition: vtkContextScene.h:354
vtkContextScene::GetLastPainter
vtkWeakPointer< vtkContext2D > GetLastPainter()
Last painter used.
vtkContextScene
Provides a 2D scene for vtkContextItem objects.
Definition: vtkContextScene.h:51
vtkContextScene::Transform
vtkTransform2D * Transform
The scene level transform.
Definition: vtkContextScene.h:361
ADIOS::Transform
Transform
Definition: ADIOSDefs.h:41
vtkContextScene::SELECTION_ADDITION
@ SELECTION_ADDITION
Definition: vtkContextScene.h:240
vtkContextScene::GetNumberOfItems
unsigned int GetNumberOfItems()
Get the number of child items.
vtkContextScene::ClearItems
void ClearItems()
Remove all child items from this item.
vtkContextScene::KeyPressEvent
virtual bool KeyPressEvent(const vtkContextKeyEvent &keyEvent)
Process a key press event.
vtkContextScene::GetViewWidth
virtual int GetViewWidth()
Get the width of the view.
vtkContextScene::ScaleTiles
bool ScaleTiles
Definition: vtkContextScene.h:356
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkContextScene::SetDirty
void SetDirty(bool isDirty)
Inform the scene that something changed that requires a repaint of the scene.
vtkContextScene::GetRenderer
virtual vtkRenderer * GetRenderer()
vtkWeakPointer.h
vtkContextScene::Storage
Private * Storage
Definition: vtkContextScene.h:333
vtkContextScene::MouseWheelEvent
virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent &event)
Process a mouse wheel event where delta is the movement forward or back.
vtkContextScene::SELECTION_DEFAULT
@ SELECTION_DEFAULT
Definition: vtkContextScene.h:239
vtkContextScene::PaintIds
virtual void PaintIds()
Paint the scene in a special mode to build a cache for picking.
vtkContextScenePrivate
Private implementation for scene/items.
Definition: vtkContextScenePrivate.h:41
vtkContextScene::vtkContextScene
vtkContextScene()
vtkContextScene::GetBufferId
vtkAbstractContextBufferId * GetBufferId()
Return buffer id.
vtkObject.h
vtkContextScene::RemoveItem
bool RemoveItem(unsigned int index)
Remove child item from this item.
vtkContextScene::AddItem
unsigned int AddItem(vtkAbstractContextItem *item)
Add child items to this item.
vtkContextInteractorStyle
An interactor for chart views.
Definition: vtkContextInteractorStyle.h:40
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkContextScene::GetItem
vtkAbstractContextItem * GetItem(unsigned int index)
Get the item at the specified index.
vtkContextScene::Renderer
vtkWeakPointer< vtkRenderer > Renderer
Definition: vtkContextScene.h:346
vtkContextScene::~vtkContextScene
~vtkContextScene() override
vtkContextScene::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkContextScene::SELECTION_SUBTRACTION
@ SELECTION_SUBTRACTION
Definition: vtkContextScene.h:241
vtkContextScene::AnnotationLink
vtkAnnotationLink * AnnotationLink
Definition: vtkContextScene.h:318
vtkContextScene::UpdateBufferId
void UpdateBufferId()
Make sure the buffer id used for picking is up-to-date.
vtkVector2i
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:409
vtkContextScene::BufferIdSupportTested
bool BufferIdSupportTested
Definition: vtkContextScene.h:353
vtkContextScene::GetTransform
vtkTransform2D * GetTransform()
Get the transform for the scene.
vtkContextScene::HasTransform
bool HasTransform()
Check whether the scene has a transform.
Definition: vtkContextScene.h:232
vtkContextScene::ProcessSelectionEvent
virtual bool ProcessSelectionEvent(unsigned int rect[5])
Process a rubber band selection event.
vtkContextScene::GetViewHeight
virtual int GetViewHeight()
Get the height of the view.
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkContextScene::MouseMoveEvent
virtual bool MouseMoveEvent(const vtkContextMouseEvent &event)
Process a mouse move event.
vtkContextScene::LastPainter
vtkWeakPointer< vtkContext2D > LastPainter
Definition: vtkContextScene.h:344
vtkContextScene::ButtonReleaseEvent
virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event)
Process a mouse button release event.
vtkWeakPointer< vtkContext2D >
vtkContextScene::GetDirty
bool GetDirty() const
vtkContextScene::KeyReleaseEvent
virtual bool KeyReleaseEvent(const vtkContextKeyEvent &keyEvent)
Process a key release event.
vtkContextScene::GetSceneWidth
int GetSceneWidth()
Get the width of the scene.