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 
28 #ifndef vtkContextScene_h
29 #define vtkContextScene_h
30 
31 #include "vtkRenderingContext2DModule.h" // For export macro
32 #include "vtkObject.h"
33 #include "vtkWeakPointer.h" // Needed for weak pointer to the window.
34 #include "vtkVector.h" // For vtkVector return type.
35 
36 class vtkContext2D;
38 class vtkTransform2D;
40 class vtkContextKeyEvent;
43 
44 class vtkAnnotationLink;
45 
46 class vtkRenderer;
48 
50 {
51 public:
52  vtkTypeMacro(vtkContextScene, vtkObject);
53  virtual void PrintSelf(ostream &os, vtkIndent indent);
54 
56  static vtkContextScene * New();
57 
60  virtual bool Paint(vtkContext2D *painter);
61 
64  unsigned int AddItem(vtkAbstractContextItem* item);
65 
69  bool RemoveItem(vtkAbstractContextItem* item);
70 
74  bool RemoveItem(unsigned int index);
75 
78  vtkAbstractContextItem* GetItem(unsigned int index);
79 
81  unsigned int GetNumberOfItems();
82 
84  void ClearItems();
85 
87  virtual void SetAnnotationLink(vtkAnnotationLink *link);
88 
90 
91  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
93 
95 
96  vtkSetVector2Macro(Geometry, int);
98 
100 
101  vtkGetVector2Macro(Geometry, int);
103 
105 
106  vtkSetMacro(UseBufferId, bool);
108 
110 
111  vtkGetMacro(UseBufferId, bool);
113 
115  virtual int GetViewWidth();
116 
118  virtual int GetViewHeight();
119 
121  int GetSceneWidth();
122 
124  int GetSceneHeight();
125 
127 
130  vtkSetMacro(ScaleTiles, bool);
131  vtkGetMacro(ScaleTiles, bool);
132  vtkBooleanMacro(ScaleTiles, bool);
134 
139  vtkVector2i GetLogicalTileScale();
140 
142 
144  virtual void SetRenderer(vtkRenderer *renderer);
145  virtual vtkRenderer* GetRenderer();
147 
149 
152  void SetDirty(bool isDirty);
153  bool GetDirty()const;
155 
156 //BTX
158  void ReleaseGraphicsResources();
159 
163  vtkWeakPointer<vtkContext2D> GetLastPainter();
164 
168  vtkAbstractContextBufferId *GetBufferId();
169 
171  virtual void SetTransform(vtkTransform2D *transform);
172 
174  vtkTransform2D* GetTransform();
175 
177  bool HasTransform() { return this->Transform != 0; }
178 
180 
181  enum {
182  SELECTION_NONE = 0,
186  SELECTION_TOGGLE
187  };
189 
190 protected:
191  vtkContextScene();
192  ~vtkContextScene();
193 
195  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
196 
198  virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
199 
201  virtual bool ButtonPressEvent(const vtkContextMouseEvent &event);
202 
204  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event);
205 
207  virtual bool DoubleClickEvent(const vtkContextMouseEvent &event);
208 
211  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent &event);
212 
214  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
215 
217  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
218 
221  virtual void PaintIds();
222 
224  void TestBufferIdSupport();
225 
229  vtkIdType GetPickedItem(int x, int y);
230 
233  vtkAbstractContextItem* GetPickedItem();
234 
236  void UpdateBufferId();
237 
239 
240  // Store the chart dimensions - width, height of scene in pixels
241  int Geometry[2];
242 
246 
248 
249  class Private;
250  Private *Storage;
252 
257 
259 
261 
264 
266 
269 
271 
274 
275 private:
276  vtkContextScene(const vtkContextScene &); // Not implemented.
277  void operator=(const vtkContextScene &); // Not implemented.
278 
279  typedef bool (vtkAbstractContextItem::* MouseEvents)(const vtkContextMouseEvent&);
280  bool ProcessItem(vtkAbstractContextItem* cur,
281  const vtkContextMouseEvent& event,
282  MouseEvents eventPtr);
283  void EventCopy(const vtkContextMouseEvent &event);
284 //ETX
285 };
286 
287 #endif //vtkContextScene_h
data structure to represent key events.
abstract base class for most VTK objects
Definition: vtkObject.h:61
Private implementation for scene/items.
abstract specification for renderers
Definition: vtkRenderer.h:62
vtkWeakPointer< vtkRenderer > Renderer
int vtkIdType
Definition: vtkType.h:247
vtkWeakPointer< vtkContext2D > LastPainter
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:56
An interactor for chart views It observes the user events (mouse events) and propagates them to the s...
virtual void PrintSelf(ostream &os, vtkIndent indent)
#define VTKRENDERINGCONTEXT2D_EXPORT
Provides a 2D scene for vtkContextItem objects.
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:38
describes linear transformations via a 3x3 matrix
2D array of ids, used for picking.
vtkContextScenePrivate * Children
vtkAbstractContextBufferId * BufferId
base class for items that are part of a vtkContextScene.
static vtkObject * New()
vtkTransform2D * Transform
vtkAnnotationLink * AnnotationLink