VTK  9.1.0
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 
135 #ifndef vtkContextScene_h
136 #define vtkContextScene_h
137 
138 #include "vtkObject.h"
139 #include "vtkRenderingContext2DModule.h" // For export macro
140 #include "vtkVector.h" // For vtkVector return type.
141 #include "vtkWeakPointer.h" // Needed for weak pointer to the window.
142 
143 class vtkContext2D;
145 class vtkTransform2D;
147 class vtkContextKeyEvent;
150 
151 class vtkAnnotationLink;
152 
153 class vtkRenderer;
155 
156 class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject
157 {
158 public:
159  vtkTypeMacro(vtkContextScene, vtkObject);
160  void PrintSelf(ostream& os, vtkIndent indent) override;
161 
165  static vtkContextScene* New();
166 
170  virtual bool Paint(vtkContext2D* painter);
171 
176  unsigned int AddItem(vtkAbstractContextItem* item);
177 
184 
190  bool RemoveItem(unsigned int index);
191 
197 
201  unsigned int GetNumberOfItems();
202 
206  void ClearItems();
207 
212 
214 
217  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
219 
221 
224  vtkSetVector2Macro(Geometry, int);
226 
228 
231  vtkGetVector2Macro(Geometry, int);
233 
235 
238  vtkSetMacro(UseBufferId, bool);
240 
242 
245  vtkGetMacro(UseBufferId, bool);
247 
251  virtual int GetViewWidth();
252 
256  virtual int GetViewHeight();
257 
262 
267 
269 
274  vtkSetMacro(ScaleTiles, bool);
275  vtkGetMacro(ScaleTiles, bool);
276  vtkBooleanMacro(ScaleTiles, bool);
278 
286 
288 
292  virtual void SetRenderer(vtkRenderer* renderer);
295 
297 
302  void SetDirty(bool isDirty);
303  bool GetDirty() const;
305 
310 
317 
324 
328  virtual void SetTransform(vtkTransform2D* transform);
329 
334 
338  bool HasTransform() { return this->Transform != nullptr; }
339 
345  vtkIdType GetPickedItem(int x, int y);
346 
352 
356  enum
357  {
358  SELECTION_NONE = 0,
362  SELECTION_TOGGLE
363  };
364 
365 protected:
367  ~vtkContextScene() override;
368 
372  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
373 
377  virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
378 
382  virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
383 
387  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
388 
392  virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
393 
397  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
398 
402  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
403 
407  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
408 
413  virtual void PaintIds();
414 
419 
424 
426 
427  // Store the chart dimensions - width, height of scene in pixels
428  int Geometry[2];
429 
435 
437 
440  class Private;
441  Private* Storage;
443 
450 
452 
454 
457 
459 
462 
464 
469 
470 private:
471  vtkContextScene(const vtkContextScene&) = delete;
472  void operator=(const vtkContextScene&) = delete;
473 
474  typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
475  bool ProcessItem(
476  vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
477  void EventCopy(const vtkContextMouseEvent& event);
478 };
479 
480 #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:73
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
Inform the scene that something changed that requires a repaint of the scene.
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()
This should not be necessary as the context view should take care of rendering.
virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event)
Process a mouse button release event.
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
abstract specification for renderers
Definition: vtkRenderer.h:173
describes linear transformations via a 3x3 matrix
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:478
@ Transform
Definition: vtkX3D.h:47
@ index
Definition: vtkX3D.h:252
int vtkIdType
Definition: vtkType.h:332