VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkContextScene.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 00028 #ifndef __vtkContextScene_h 00029 #define __vtkContextScene_h 00030 00031 #include "vtkObject.h" 00032 #include "vtkWeakPointer.h" // Needed for weak pointer to the window. 00033 00034 class vtkContext2D; 00035 class vtkAbstractContextItem; 00036 class vtkTransform2D; 00037 class vtkContextMouseEvent; 00038 class vtkContextKeyEvent; 00039 class vtkContextScenePrivate; 00040 class vtkContextInteractorStyle; 00041 00042 class vtkAnnotationLink; 00043 00044 class vtkRenderer; 00045 class vtkAbstractContextBufferId; 00046 00047 class VTK_CHARTS_EXPORT vtkContextScene : public vtkObject 00048 { 00049 public: 00050 vtkTypeMacro(vtkContextScene, vtkObject); 00051 virtual void PrintSelf(ostream &os, vtkIndent indent); 00052 00054 static vtkContextScene * New(); 00055 00058 virtual bool Paint(vtkContext2D *painter); 00059 00062 unsigned int AddItem(vtkAbstractContextItem* item); 00063 00067 bool RemoveItem(vtkAbstractContextItem* item); 00068 00072 bool RemoveItem(unsigned int index); 00073 00076 vtkAbstractContextItem* GetItem(unsigned int index); 00077 00079 unsigned int GetNumberOfItems(); 00080 00082 void ClearItems(); 00083 00085 virtual void SetAnnotationLink(vtkAnnotationLink *link); 00086 00088 00089 vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink); 00091 00093 00094 vtkSetVector2Macro(Geometry, int); 00096 00098 00099 vtkGetVector2Macro(Geometry, int); 00101 00103 00104 vtkSetMacro(UseBufferId, bool); 00106 00108 00109 vtkGetMacro(UseBufferId, bool); 00111 00113 virtual int GetViewWidth(); 00114 00116 virtual int GetViewHeight(); 00117 00119 int GetSceneWidth(); 00120 00122 int GetSceneHeight(); 00123 00125 00128 vtkSetMacro(ScaleTiles, bool); 00129 vtkGetMacro(ScaleTiles, bool); 00130 vtkBooleanMacro(ScaleTiles, bool); 00132 00135 virtual void SetRenderer(vtkRenderer *renderer); 00136 00138 00141 void SetDirty(bool isDirty); 00142 bool GetDirty()const; 00144 00145 //BTX 00147 void ReleaseGraphicsResources(); 00148 00152 vtkWeakPointer<vtkContext2D> GetLastPainter(); 00153 00157 vtkAbstractContextBufferId *GetBufferId(); 00158 00160 virtual void SetTransform(vtkTransform2D *transform); 00161 00163 vtkTransform2D* GetTransform(); 00164 00166 bool HasTransform() { return this->Transform != 0; } 00167 00169 00170 enum { 00171 SELECTION_NONE = 0, 00172 SELECTION_DEFAULT, 00173 SELECTION_ADDITION, 00174 SELECTION_SUBTRACTION, 00175 SELECTION_TOGGLE 00176 }; 00178 00179 protected: 00180 vtkContextScene(); 00181 ~vtkContextScene(); 00182 00184 virtual bool ProcessSelectionEvent(unsigned int rect[5]); 00185 00187 virtual bool MouseMoveEvent(const vtkContextMouseEvent &event); 00188 00190 virtual bool ButtonPressEvent(const vtkContextMouseEvent &event); 00191 00193 virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event); 00194 00196 virtual bool DoubleClickEvent(const vtkContextMouseEvent &event); 00197 00200 virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent &event); 00201 00203 virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent); 00204 00206 virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent); 00207 00210 virtual void PaintIds(); 00211 00213 void TestBufferIdSupport(); 00214 00218 vtkIdType GetPickedItem(int x, int y); 00219 00222 vtkAbstractContextItem* GetPickedItem(); 00223 00225 void UpdateBufferId(); 00226 00227 vtkAnnotationLink *AnnotationLink; 00228 00229 // Store the chart dimensions - width, height of scene in pixels 00230 int Geometry[2]; 00231 00234 friend class vtkContextInteractorStyle; 00235 00237 00238 class Private; 00239 Private *Storage; 00241 00245 vtkContextScenePrivate* Children; 00246 00247 vtkWeakPointer<vtkContext2D> LastPainter; 00248 00249 vtkWeakPointer<vtkRenderer> Renderer; 00250 00251 vtkAbstractContextBufferId *BufferId; 00252 bool BufferIdDirty; 00253 00254 bool UseBufferId; 00255 00256 bool BufferIdSupportTested; 00257 bool BufferIdSupported; 00258 00259 bool ScaleTiles; 00260 00262 vtkTransform2D* Transform; 00263 00264 private: 00265 vtkContextScene(const vtkContextScene &); // Not implemented. 00266 void operator=(const vtkContextScene &); // Not implemented. 00267 00268 typedef bool (vtkAbstractContextItem::* MouseEvents)(const vtkContextMouseEvent&); 00269 bool ProcessItem(vtkAbstractContextItem* cur, 00270 const vtkContextMouseEvent& event, 00271 MouseEvents eventPtr); 00272 void EventCopy(const vtkContextMouseEvent &event); 00273 //ETX 00274 }; 00275 00276 #endif //__vtkContextScene_h