Logo ROOT   6.08/07
Reference Guide
TGLClip.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_TGLClip
13 #define ROOT_TGLClip
14 
15 #include "TGLPhysicalShape.h"
16 #include "TGLOverlay.h"
17 
18 class TGLRnrCtx;
19 class TGLManipSet;
20 
21 //////////////////////////////////////////////////////////////////////////
22 // //
23 // TGLClip //
24 // //
25 // Abstract clipping shape - derives from TGLPhysicalShape //
26 // Adds clip mode (inside/outside) and pure virtual method to //
27 // approximate shape as set of planes. This plane set is used to perform//
28 // interactive clipping using OpenGL clip planes. //
29 //////////////////////////////////////////////////////////////////////////
30 
31 class TGLClip : public TGLPhysicalShape
32 {
33 public:
34  enum EMode
35  {
36  kOutside, // Clip away what's outside
37  kInside // Clip away what's inside
38  };
39  enum EType
40  {
41  kClipNone = 0,
44  };
45 
46 protected:
50 
51 public:
52  TGLClip(const TGLLogicalShape & logical, const TGLMatrix & transform, const float color[4]);
53  virtual ~TGLClip();
54 
56 
57  virtual void Setup(const TGLBoundingBox & bbox) = 0;
58  virtual void Setup(const TGLVector3&, const TGLVector3&);
59 
60  EMode GetMode() const { return fMode; }
61  void SetMode(EMode mode) { if (mode != fMode) { fMode = mode; ++fTimeStamp; } }
62 
63  UInt_t TimeStamp() const { return fTimeStamp; }
64  void IncTimeStamp() { ++fTimeStamp; }
65 
66  Bool_t IsValid() const { return fValid; }
67  void Invalidate() { fValid = kFALSE; }
68 
69  virtual void Draw(TGLRnrCtx & rnrCtx) const;
70  virtual void PlaneSet(TGLPlaneSet_t & set) const = 0;
71 
72  ClassDef(TGLClip,0); // abstract clipping object
73 };
74 
75 //////////////////////////////////////////////////////////////////////////
76 // //
77 // TGLClipPlane //
78 // //
79 // Concrete clip plane object. This can be translated in all directions //
80 // rotated about the Y/Z local axes (the in-plane axes). It cannot be //
81 // scaled. //
82 // //
83 //////////////////////////////////////////////////////////////////////////
84 
85 class TGLClipPlane : public TGLClip
86 {
87 private:
88  static const float fgColor[4]; //! Fixed color of clip plane
89 
90 public:
91  TGLClipPlane();
92  virtual ~TGLClipPlane();
93 
94  virtual void Setup(const TGLBoundingBox & bbox);
95  virtual void Setup(const TGLVector3& point, const TGLVector3& normal);
96 
97  void Set(const TGLPlane & plane);
98 
99  virtual void PlaneSet(TGLPlaneSet_t & set) const;
100 
101  ClassDef(TGLClipPlane, 0); // clipping plane
102 };
103 
104 //////////////////////////////////////////////////////////////////////////
105 // //
106 // TGLClipBox //
107 // //
108 // Concrete clip box object. Can be translated, rotated and scaled in //
109 // all (xyz) axes. //
110 // //
111 //////////////////////////////////////////////////////////////////////////
112 
113 class TGLClipBox : public TGLClip
114 {
115 private:
116  static const float fgColor[4]; //! Fixed color of clip box
117 
118 public:
119  TGLClipBox();
120  virtual ~TGLClipBox();
121 
122  virtual void Setup(const TGLBoundingBox & bbox);
123  virtual void Setup(const TGLVector3& min_point, const TGLVector3& max_point);
124 
125  virtual void PlaneSet(TGLPlaneSet_t & set) const;
126 
127  ClassDef(TGLClipBox, 0); // clipping box
128 };
129 
130 //////////////////////////////////////////////////////////////////////////
131 //
132 // TGLClipSet
133 //
134 // A collection of all available clipping objects, to be used by higher
135 // level objects. For the time being by TGLViewer/Scene.
136 //
137 //////////////////////////////////////////////////////////////////////////
138 
140 {
141 private:
142  TGLClipSet(const TGLClipSet&); // Not implemented
143  TGLClipSet& operator=(const TGLClipSet&); // Not implemented
144 
145 protected:
148  TGLClip *fCurrentClip; //! the current clipping shape
149 
154 
156 
157 public:
158  TGLClipSet();
159  virtual ~TGLClipSet();
160 
161  virtual Bool_t MouseEnter(TGLOvlSelectRecord& selRec);
162  virtual Bool_t MouseStillInside(TGLOvlSelectRecord& selRec);
163  virtual Bool_t Handle(TGLRnrCtx& rnrCtx, TGLOvlSelectRecord& selRec,
164  Event_t* event);
165  virtual void MouseLeave();
166 
167  virtual void Render(TGLRnrCtx& rnrCtx);
168 
169  Bool_t IsClipping() const { return fCurrentClip != 0; }
170  TGLClip* GetCurrentClip() const { return fCurrentClip; }
171  void FillPlaneSet(TGLPlaneSet_t& set) const;
172 
173  // Clipping
174  void SetupClips(const TGLBoundingBox& sceneBBox);
175  void SetupCurrentClip(const TGLBoundingBox& sceneBBox);
176  void SetupCurrentClipIfInvalid(const TGLBoundingBox& sceneBBox);
177 
178  void InvalidateClips();
179  void InvalidateCurrentClip();
180 
181  void GetClipState(TGLClip::EType type, Double_t data[6]) const;
182  void SetClipState(TGLClip::EType type, const Double_t data[6]);
183 
184  TGLClip::EType GetClipType() const;
185  void SetClipType(TGLClip::EType type);
186 
187  // Clip control flags
188  Bool_t GetAutoUpdate() const { return fAutoUpdate; }
189  void SetAutoUpdate(Bool_t aup) { fAutoUpdate = aup; }
190  Bool_t GetShowManip() const { return fShowManip; }
191  void SetShowManip(Bool_t show) { fShowManip = show; }
192  Bool_t GetShowClip() const { return fShowClip; }
193  void SetShowClip(Bool_t show) { fShowClip = show; }
194 
195  ClassDef(TGLClipSet, 0); // A collection of supported clip-objects
196 };
197 
198 #endif
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
TGLClip * GetCurrentClip() const
Definition: TGLClip.h:170
Bool_t fShowManip
Definition: TGLClip.h:152
void SetShowManip(Bool_t show)
Definition: TGLClip.h:191
virtual void Setup(const TGLBoundingBox &bbox)=0
Bool_t IsValid() const
Definition: TGLClip.h:66
virtual ~TGLClip()
Destroy clip object.
Definition: TGLClip.cxx:101
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:600
Bool_t fValid
Definition: TGLClip.h:49
void SetMode(EMode mode)
Definition: TGLClip.h:61
EMode fMode
Definition: TGLClip.h:47
virtual void Modified()
Definition: TGLClip.h:55
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:31
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void SetShowClip(Bool_t show)
Definition: TGLClip.h:193
Concrete clip box object.
Definition: TGLClip.h:113
Bool_t GetShowClip() const
Definition: TGLClip.h:192
void Modified()
Call this after modifying the physical so that the information can be propagated to the object refere...
TGLBoundingBox fLastBBox
Definition: TGLClip.h:155
Combine all available manipulators in a collection.
Definition: TGLManipSet.h:21
An overlay element.
Definition: TGLOverlay.h:22
TGLClipPlane * fClipPlane
Definition: TGLClip.h:146
Concrete physical shape - a GL drawable.
UInt_t fTimeStamp
Definition: TGLClip.h:48
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t fShowClip
Definition: TGLClip.h:151
3 component (x/y/z) vector class.
Definition: TGLUtil.h:250
EMode GetMode() const
Definition: TGLClip.h:60
Bool_t GetShowManip() const
Definition: TGLClip.h:190
TGLClip * fCurrentClip
Definition: TGLClip.h:148
Concrete clip plane object.
Definition: TGLClip.h:85
void IncTimeStamp()
Definition: TGLClip.h:64
TGLPhysicalShape & operator=(const TGLPhysicalShape &)
virtual void PlaneSet(TGLPlaneSet_t &set) const =0
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw out clipping object with blending and back + front filling.
Definition: TGLClip.cxx:120
Bool_t GetAutoUpdate() const
Definition: TGLClip.h:188
unsigned int UInt_t
Definition: RtypesCore.h:42
A collection of concrete TGLClip objects to be selected from.
Definition: TGLClip.h:139
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
void SetAutoUpdate(Bool_t aup)
Definition: TGLClip.h:189
std::vector< TGLPlane > TGLPlaneSet_t
Definition: TGLUtil.h:574
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
TGLManipSet * fManip
Definition: TGLClip.h:153
TGLClip(const TGLLogicalShape &logical, const TGLMatrix &transform, const float color[4])
Construct a stand-alone physical clipping object.
Definition: TGLClip.cxx:89
Bool_t fAutoUpdate
the current clipping shape
Definition: TGLClip.h:150
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
UInt_t TimeStamp() const
Definition: TGLClip.h:63
TGLClipBox * fClipBox
Definition: TGLClip.h:147
Bool_t IsClipping() const
Definition: TGLClip.h:169
void Invalidate()
Definition: TGLClip.h:67
def normal(shape, name=None)
Selection record for overlay objects.
3D plane class - of format Ax + By + Cz + D = 0
Definition: TGLUtil.h:529