Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLManip.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Richard Maunder 16/09/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGLManip
13 #define ROOT_TGLManip
14 
15 #include "TVirtualGL.h"
16 #include "TPoint.h"
17 #include "GuiTypes.h"
18 #include "TGLUtil.h"
19 
20 class TGLPhysicalShape;
21 class TGLVertex3;
22 class TGLVector3;
23 class TGLCamera;
24 class TGLRect;
25 class TGLBoundingBox;
26 
27 
28 class TGLManip : public TVirtualGLManip
29 {
30 protected:
31  TGLPhysicalShape *fShape; //! manipulated shape
32  UInt_t fSelectedWidget; //! active width (axis) component
33  Bool_t fActive; //! manipulator is active?
34 
35  // Mouse tracking - in WINDOW coords
36  TPoint fFirstMouse; //! first (start) mouse position (in WINDOW coords)
37  TPoint fLastMouse; //! last (latest) mouse position (in WINDOW coords)
38 
39  TGLManip(const TGLManip&);
40  TGLManip& operator=(const TGLManip&);
41 
42  void CalcDrawScale(const TGLBoundingBox& box, const TGLCamera& camera,
43  Double_t& base, TGLVector3 axis[3]) const;
44 
45  const UChar_t* ColorFor(UInt_t widget) const;
46 
47 public:
48  TGLManip();
49  TGLManip(TGLPhysicalShape* shape);
50  virtual ~TGLManip();
51 
52  UInt_t GetSelectedWidget() const { return fSelectedWidget; }
53  void SetSelectedWidget(UInt_t s) { fSelectedWidget = s; }
54 
55  Bool_t GetActive() const { return fActive; }
56  void SetActive(Bool_t a) { fActive = a; }
57 
58  void Attach(TGLPhysicalShape* shape) { fShape = shape; }
59  TGLPhysicalShape * GetAttached() const { return fShape; }
60 
61  virtual void Draw(const TGLCamera& camera) const = 0;
62  // CRAPPY TVirtualGLManip TTTT, just override it here
63  virtual Bool_t Select(const TGLCamera&, const TGLRect&, const TGLBoundingBox&) { return kFALSE; }
64 
65  virtual Bool_t HandleButton(const Event_t& event, const TGLCamera& camera);
66  virtual Bool_t HandleMotion(const Event_t& event, const TGLCamera& camera);
67 
68  ClassDef(TGLManip, 0); // abstract base GL manipulator widget
69 };
70 
71 #endif