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 "vtkObject.h"
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 
48 {
49 public:
50  vtkTypeMacro(vtkContextScene, vtkObject);
51  virtual void PrintSelf(ostream &os, vtkIndent indent);
52 
54  static vtkContextScene * New();
55 
58  virtual bool Paint(vtkContext2D *painter);
59 
62  unsigned int AddItem(vtkAbstractContextItem* item);
63 
67  bool RemoveItem(vtkAbstractContextItem* item);
68 
72  bool RemoveItem(unsigned int index);
73 
76  vtkAbstractContextItem* GetItem(unsigned int index);
77 
79  unsigned int GetNumberOfItems();
80 
82  void ClearItems();
83 
85  virtual void SetAnnotationLink(vtkAnnotationLink *link);
86 
88 
89  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
91 
93 
94  vtkSetVector2Macro(Geometry, int);
96 
98 
99  vtkGetVector2Macro(Geometry, int);
101 
103 
104  vtkSetMacro(UseBufferId, bool);
106 
108 
109  vtkGetMacro(UseBufferId, bool);
111 
113  virtual int GetViewWidth();
114 
116  virtual int GetViewHeight();
117 
119  int GetSceneWidth();
120 
122  int GetSceneHeight();
123 
125 
128  vtkSetMacro(ScaleTiles, bool);
129  vtkGetMacro(ScaleTiles, bool);
130  vtkBooleanMacro(ScaleTiles, bool);
132 
135  virtual void SetRenderer(vtkRenderer *renderer);
136 
138 
141  void SetDirty(bool isDirty);
142  bool GetDirty()const;
144 
145 //BTX
147  void ReleaseGraphicsResources();
148 
152  vtkWeakPointer<vtkContext2D> GetLastPainter();
153 
157  vtkAbstractContextBufferId *GetBufferId();
158 
160  virtual void SetTransform(vtkTransform2D *transform);
161 
163  vtkTransform2D* GetTransform();
164 
166  bool HasTransform() { return this->Transform != 0; }
167 
169 
170  enum {
171  SELECTION_NONE = 0,
175  SELECTION_TOGGLE
176  };
178 
179 protected:
180  vtkContextScene();
181  ~vtkContextScene();
182 
184  virtual bool ProcessSelectionEvent(unsigned int rect[5]);
185 
187  virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
188 
190  virtual bool ButtonPressEvent(const vtkContextMouseEvent &event);
191 
193  virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event);
194 
196  virtual bool DoubleClickEvent(const vtkContextMouseEvent &event);
197 
200  virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent &event);
201 
203  virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent);
204 
206  virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent);
207 
210  virtual void PaintIds();
211 
213  void TestBufferIdSupport();
214 
218  vtkIdType GetPickedItem(int x, int y);
219 
222  vtkAbstractContextItem* GetPickedItem();
223 
225  void UpdateBufferId();
226 
228 
229  // Store the chart dimensions - width, height of scene in pixels
230  int Geometry[2];
231 
235 
237 
238  class Private;
239  Private *Storage;
241 
246 
248 
250 
253 
255 
258 
260 
263 
264 private:
265  vtkContextScene(const vtkContextScene &); // Not implemented.
266  void operator=(const vtkContextScene &); // Not implemented.
267 
268  typedef bool (vtkAbstractContextItem::* MouseEvents)(const vtkContextMouseEvent&);
269  bool ProcessItem(vtkAbstractContextItem* cur,
270  const vtkContextMouseEvent& event,
271  MouseEvents eventPtr);
272  void EventCopy(const vtkContextMouseEvent &event);
273 //ETX
274 };
275 
276 #endif //__vtkContextScene_h