VTK
dox/Charts/vtkContextScene.h
Go to the documentation of this file.
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 
00025 #ifndef __vtkContextScene_h
00026 #define __vtkContextScene_h
00027 
00028 #include "vtkObject.h"
00029 #include "vtkWeakPointer.h" // Needed for weak pointer to the window.
00030 #include "vtkVector.h" // Needed for vtkVector2f
00031 
00032 class vtkContext2D;
00033 class vtkContextItem;
00034 class vtkTransform2D;
00035 class vtkContextMouseEvent;
00036 
00037 class vtkInteractorStyle;
00038 class vtkAnnotationLink;
00039 
00040 class vtkRenderer;
00041 class vtkAbstractContextBufferId;
00042 
00043 class VTK_CHARTS_EXPORT vtkContextScene : public vtkObject
00044 {
00045 public:
00046   vtkTypeMacro(vtkContextScene, vtkObject);
00047   virtual void PrintSelf(ostream &os, vtkIndent indent);
00048 
00050   static vtkContextScene * New();
00051 
00054   virtual bool Paint(vtkContext2D *painter);
00055 
00057   void AddItem(vtkContextItem *item);
00058 
00060   int GetNumberOfItems();
00061 
00062   // Get the item at the specified index.
00063   vtkContextItem * GetItem(int index);
00064 
00066   virtual void SetAnnotationLink(vtkAnnotationLink *link);
00067 
00069 
00070   vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
00072 
00074 
00075   vtkSetVector2Macro(Geometry, int);
00077 
00079 
00080   vtkGetVector2Macro(Geometry, int);
00082 
00084 
00085   vtkSetMacro(UseBufferId, bool);
00087 
00089 
00090   vtkGetMacro(UseBufferId, bool);
00092 
00094   virtual int GetViewWidth();
00095 
00097   virtual int GetViewHeight();
00098 
00100   int GetSceneWidth();
00101 
00103   int GetSceneHeight();
00104 
00106   void SetInteractorStyle(vtkInteractorStyle *interactor);
00107 
00110   virtual void SetRenderer(vtkRenderer *renderer);
00111 
00115   void SetDirty(bool isDirty);
00116 
00117 //BTX
00119   void ReleaseGraphicsResources();
00120   
00124   vtkWeakPointer<vtkContext2D> GetLastPainter();
00125 
00129   vtkAbstractContextBufferId *GetBufferId();
00130 
00132   virtual void SetTransform(vtkTransform2D *transform);
00133 
00135   vtkTransform2D* GetTransform();
00136 
00138   bool HasTransform() { return this->Transform != 0; }
00139 
00140 protected:
00141   vtkContextScene();
00142   ~vtkContextScene();
00143 
00147   void CheckForRepaint();
00148 
00150 
00152   virtual void ProcessEvents(vtkObject* caller, unsigned long eventId,
00153                              void* callData);
00155 
00157   virtual void ProcessSelectionEvent(vtkObject* caller, void* callData);
00158 
00160   virtual void MouseMoveEvent(int x, int y);
00161 
00163   virtual void ButtonPressEvent(int button, int x, int y);
00164 
00166   virtual void ButtonReleaseEvent(int button, int x, int y);
00167 
00170   virtual void MouseWheelEvent(int delta, int x, int y);
00171 
00174   virtual void PaintIds();
00175 
00179   vtkIdType GetPickedItem(int x, int y);
00180 
00182   void UpdateBufferId();
00183 
00184   vtkAnnotationLink *AnnotationLink;
00185 
00186   // Store the chart dimensions - width, height of scene in pixels
00187   int Geometry[2];
00188 
00190 
00191   class Command;
00192   friend class Command;
00193   Command *Observer;
00195 
00197 
00198   class Private;
00199   Private *Storage;
00201 
00202   vtkWeakPointer<vtkContext2D> LastPainter;
00203 
00204   vtkWeakPointer<vtkRenderer> Renderer;
00205 
00206   vtkAbstractContextBufferId *BufferId;
00207   bool BufferIdDirty;
00208 
00209   bool UseBufferId;
00210 
00212   vtkTransform2D* Transform;
00213 
00215   void PerformTransform(vtkTransform2D *transform, vtkContextMouseEvent &mouse);
00216 
00217 private:
00218   vtkContextScene(const vtkContextScene &); // Not implemented.
00219   void operator=(const vtkContextScene &);   // Not implemented.
00220 //ETX
00221 };
00222 
00223 //BTX
00226 class vtkContextMouseEvent
00227 {
00228 public:
00230 
00231   enum {
00232     LEFT_BUTTON = 0,
00233     MIDDLE_BUTTON,
00234     RIGHT_BUTTON
00235   };
00237 
00239   vtkVector2f Pos;
00240 
00242   vtkVector2f ScenePos;
00243 
00245   vtkVector2i ScreenPos;
00246 
00248   vtkVector2f LastPos;
00249 
00251   vtkVector2f LastScenePos;
00252 
00254   vtkVector2i LastScreenPos;
00255 
00257   int Button;
00258 };
00259 //ETX
00260 
00261 #endif //__vtkContextScene_h