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 "vtkRenderingContext2DModule.h" // For export macro 00032 #include "vtkObject.h" 00033 #include "vtkWeakPointer.h" // Needed for weak pointer to the window. 00034 00035 class vtkContext2D; 00036 class vtkAbstractContextItem; 00037 class vtkTransform2D; 00038 class vtkContextMouseEvent; 00039 class vtkContextKeyEvent; 00040 class vtkContextScenePrivate; 00041 class vtkContextInteractorStyle; 00042 00043 class vtkAnnotationLink; 00044 00045 class vtkRenderer; 00046 class vtkAbstractContextBufferId; 00047 00048 class VTKRENDERINGCONTEXT2D_EXPORT vtkContextScene : public vtkObject 00049 { 00050 public: 00051 vtkTypeMacro(vtkContextScene, vtkObject); 00052 virtual void PrintSelf(ostream &os, vtkIndent indent); 00053 00055 static vtkContextScene * New(); 00056 00059 virtual bool Paint(vtkContext2D *painter); 00060 00063 unsigned int AddItem(vtkAbstractContextItem* item); 00064 00068 bool RemoveItem(vtkAbstractContextItem* item); 00069 00073 bool RemoveItem(unsigned int index); 00074 00077 vtkAbstractContextItem* GetItem(unsigned int index); 00078 00080 unsigned int GetNumberOfItems(); 00081 00083 void ClearItems(); 00084 00086 virtual void SetAnnotationLink(vtkAnnotationLink *link); 00087 00089 00090 vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink); 00092 00094 00095 vtkSetVector2Macro(Geometry, int); 00097 00099 00100 vtkGetVector2Macro(Geometry, int); 00102 00104 00105 vtkSetMacro(UseBufferId, bool); 00107 00109 00110 vtkGetMacro(UseBufferId, bool); 00112 00114 virtual int GetViewWidth(); 00115 00117 virtual int GetViewHeight(); 00118 00120 int GetSceneWidth(); 00121 00123 int GetSceneHeight(); 00124 00126 00129 vtkSetMacro(ScaleTiles, bool); 00130 vtkGetMacro(ScaleTiles, bool); 00131 vtkBooleanMacro(ScaleTiles, bool); 00133 00136 virtual void SetRenderer(vtkRenderer *renderer); 00137 00139 00142 void SetDirty(bool isDirty); 00143 bool GetDirty()const; 00145 00146 //BTX 00148 void ReleaseGraphicsResources(); 00149 00153 vtkWeakPointer<vtkContext2D> GetLastPainter(); 00154 00158 vtkAbstractContextBufferId *GetBufferId(); 00159 00161 virtual void SetTransform(vtkTransform2D *transform); 00162 00164 vtkTransform2D* GetTransform(); 00165 00167 bool HasTransform() { return this->Transform != 0; } 00168 00170 00171 enum { 00172 SELECTION_NONE = 0, 00173 SELECTION_DEFAULT, 00174 SELECTION_ADDITION, 00175 SELECTION_SUBTRACTION, 00176 SELECTION_TOGGLE 00177 }; 00179 00180 protected: 00181 vtkContextScene(); 00182 ~vtkContextScene(); 00183 00185 virtual bool ProcessSelectionEvent(unsigned int rect[5]); 00186 00188 virtual bool MouseMoveEvent(const vtkContextMouseEvent &event); 00189 00191 virtual bool ButtonPressEvent(const vtkContextMouseEvent &event); 00192 00194 virtual bool ButtonReleaseEvent(const vtkContextMouseEvent &event); 00195 00197 virtual bool DoubleClickEvent(const vtkContextMouseEvent &event); 00198 00201 virtual bool MouseWheelEvent(int delta, const vtkContextMouseEvent &event); 00202 00204 virtual bool KeyPressEvent(const vtkContextKeyEvent& keyEvent); 00205 00207 virtual bool KeyReleaseEvent(const vtkContextKeyEvent& keyEvent); 00208 00211 virtual void PaintIds(); 00212 00214 void TestBufferIdSupport(); 00215 00219 vtkIdType GetPickedItem(int x, int y); 00220 00223 vtkAbstractContextItem* GetPickedItem(); 00224 00226 void UpdateBufferId(); 00227 00228 vtkAnnotationLink *AnnotationLink; 00229 00230 // Store the chart dimensions - width, height of scene in pixels 00231 int Geometry[2]; 00232 00235 friend class vtkContextInteractorStyle; 00236 00238 00239 class Private; 00240 Private *Storage; 00242 00246 vtkContextScenePrivate* Children; 00247 00248 vtkWeakPointer<vtkContext2D> LastPainter; 00249 00250 vtkWeakPointer<vtkRenderer> Renderer; 00251 00252 vtkAbstractContextBufferId *BufferId; 00253 bool BufferIdDirty; 00254 00255 bool UseBufferId; 00256 00257 bool BufferIdSupportTested; 00258 bool BufferIdSupported; 00259 00260 bool ScaleTiles; 00261 00263 vtkTransform2D* Transform; 00264 00265 private: 00266 vtkContextScene(const vtkContextScene &); // Not implemented. 00267 void operator=(const vtkContextScene &); // Not implemented. 00268 00269 typedef bool (vtkAbstractContextItem::* MouseEvents)(const vtkContextMouseEvent&); 00270 bool ProcessItem(vtkAbstractContextItem* cur, 00271 const vtkContextMouseEvent& event, 00272 MouseEvents eventPtr); 00273 void EventCopy(const vtkContextMouseEvent &event); 00274 //ETX 00275 }; 00276 00277 #endif //__vtkContextScene_h