VTK  9.2.6
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
38#ifndef vtkContextScene_h
39#define vtkContextScene_h
40
41#include "vtkObject.h"
42#include "vtkRenderingContext2DModule.h" // For export macro
43#include "vtkVector.h" // For vtkVector return type.
44#include "vtkWeakPointer.h" // Needed for weak pointer to the window.
45
46class vtkContext2D;
48class vtkTransform2D;
53
55
56class vtkRenderer;
58
59class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject
60{
61public:
62 vtkTypeMacro(vtkContextScene, vtkObject);
63 void PrintSelf(ostream& os, vtkIndent indent) override;
64
69
73 virtual bool Paint(vtkContext2D* painter);
74
79 unsigned int AddItem(vtkAbstractContextItem* item);
80
87
93 bool RemoveItem(unsigned int index);
94
99 vtkAbstractContextItem* GetItem(unsigned int index);
100
104 unsigned int GetNumberOfItems();
105
110
115
117
120 vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
122
124
127 vtkSetVector2Macro(Geometry, int);
129
131
134 vtkGetVector2Macro(Geometry, int);
136
138
141 vtkSetMacro(UseBufferId, bool);
143
145
148 vtkGetMacro(UseBufferId, bool);
150
154 virtual int GetViewWidth();
155
159 virtual int GetViewHeight();
160
165
170
172
177 vtkSetMacro(ScaleTiles, bool);
178 vtkGetMacro(ScaleTiles, bool);
179 vtkBooleanMacro(ScaleTiles, bool);
181
189
191
195 virtual void SetRenderer(vtkRenderer* renderer);
198
200
205 void SetDirty(bool isDirty);
206 bool GetDirty() const;
208
213
220
227
231 virtual void SetTransform(vtkTransform2D* transform);
232
237
241 bool HasTransform() { return this->Transform != nullptr; }
242
249
255
260 {
261 SELECTION_DEFAULT = 0, // selection = newSelection
262 SELECTION_ADDITION, // selection = prevSelection | newSelection
263 SELECTION_SUBTRACTION, // selection = prevSelection & !newSelection
264 SELECTION_TOGGLE // selection = prevSelection ^ newSelection
265 };
266
267protected:
270
274 virtual bool ProcessSelectionEvent(unsigned int rect[5]);
275
279 virtual bool MouseMoveEvent(const vtkContextMouseEvent& event);
280
284 virtual bool ButtonPressEvent(const vtkContextMouseEvent& event);
285
289 virtual bool ButtonReleaseEvent(const vtkContextMouseEvent& event);
290
294 virtual bool DoubleClickEvent(const vtkContextMouseEvent& event);
295
299 virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent& event);
300
304 virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
305
309 virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
310
315 virtual void PaintIds();
316
321
326
328
329 // Store the chart dimensions - width, height of scene in pixels
330 int Geometry[2];
331
337
339
342 class Private;
343 Private* Storage;
345
352
354
356
359
361
364
366
371
372private:
373 vtkContextScene(const vtkContextScene&) = delete;
374 void operator=(const vtkContextScene&) = delete;
375
376 typedef bool (vtkAbstractContextItem::*MouseEvents)(const vtkContextMouseEvent&);
377 bool ProcessItem(
378 vtkAbstractContextItem* cur, const vtkContextMouseEvent& event, MouseEvents eventPtr);
379 void EventCopy(const vtkContextMouseEvent& event);
380};
381
382#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.
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.
unsigned int GetNumberOfItems()
Get the number of child items.
vtkAbstractContextBufferId * BufferId
void UpdateBufferId()
Make sure the buffer id used for picking is up-to-date.
SelectionModifier
Enum of valid selection modes for charts in the scene.
virtual bool KeyPressEvent(const vtkContextKeyEvent &keyEvent)
Process a key press event.
virtual int GetViewHeight()
Get the height of the view.
bool RemoveItem(unsigned int index)
Remove child item from this item.
vtkWeakPointer< vtkContext2D > LastPainter
vtkWeakPointer< vtkContext2D > GetLastPainter()
Last painter used.
vtkVector2i GetLogicalTileScale()
The tile scale of the target vtkRenderWindow.
vtkTransform2D * GetTransform()
Get the transform for the scene.
bool GetDirty() const
Inform the scene that something changed that requires a repaint of the scene.
vtkAbstractContextBufferId * GetBufferId()
Return buffer id.
int GetSceneHeight()
Get the height of the scene.
vtkAbstractContextItem * GetPickedItem()
Return the item under the mouse.
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.
vtkAbstractContextItem * GetItem(unsigned int index)
Get the item at the specified index.
virtual vtkRenderer * GetRenderer()
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).
vtkTransform2D * Transform
The scene level transform.
virtual bool ButtonPressEvent(const vtkContextMouseEvent &event)
Process a mouse button press event.
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.
static vtkContextScene * New()
Creates a 2D Painter object.
virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event)
Process a mouse button release event.
a simple class to control print indentation
Definition vtkIndent.h:49
abstract base class for most VTK objects
Definition vtkObject.h:72
abstract specification for renderers
Definition vtkRenderer.h:82
describes linear transformations via a 3x3 matrix
Some derived classes for the different vectors commonly used.
Definition vtkVector.h:431
a weak reference to a vtkObject.
int vtkIdType
Definition vtkType.h:332