Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
18class TGLRnrCtx;
19class 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
32{
33public:
34 enum EMode
35 {
36 kOutside, // Clip away what's outside
37 kInside // Clip away what's inside
38 };
39 enum EType
40 {
44 };
45
46protected:
50
51public:
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; }
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
85class TGLClipPlane : public TGLClip
86{
87private:
88 static const float fgColor[4]; //! Fixed color of clip plane
89
90public:
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
113class TGLClipBox : public TGLClip
114{
115private:
116 static const float fgColor[4]; //! Fixed color of clip box
117
118public:
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{
141private:
142 TGLClipSet(const TGLClipSet&); // Not implemented
143 TGLClipSet& operator=(const TGLClipSet&); // Not implemented
144
145protected:
148 TGLClip *fCurrentClip; //! the current clipping shape
149
154
156
157public:
158 TGLClipSet();
159 virtual ~TGLClipSet();
160
161 virtual Bool_t MouseEnter(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 != nullptr; }
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();
180
183
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
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
#define ClassDef(name, id)
Definition Rtypes.h:337
std::vector< TGLPlane > TGLPlaneSet_t
Definition TGLUtil.h:571
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Concrete clip box object.
Definition TGLClip.h:114
virtual void PlaneSet(TGLPlaneSet_t &set) const
Return set of 6 planes describing faces of the box but invert them so that they point inside of box.
Definition TGLClip.cxx:315
virtual void Setup(const TGLBoundingBox &bbox)
Setup the clip object for scene encompassed by bbox.
Definition TGLClip.cxx:279
TGLClipBox()
Fixed color of clip box.
Definition TGLClip.cxx:264
static const float fgColor[4]
Definition TGLClip.h:116
virtual ~TGLClipBox()
Destroy clip box object.
Definition TGLClip.cxx:272
Concrete clip plane object.
Definition TGLClip.h:86
virtual void PlaneSet(TGLPlaneSet_t &set) const
Return set of planes (actually a single one) describing this clip plane.
Definition TGLClip.cxx:242
static const float fgColor[4]
Definition TGLClip.h:88
virtual void Setup(const TGLBoundingBox &bbox)
Setup the clip object for scene encompassed by bbox.
Definition TGLClip.cxx:181
void Set(const TGLPlane &plane)
Update clip plane object to follow passed 'plane' equation.
Definition TGLClip.cxx:230
TGLClipPlane()
Fixed color of clip plane.
Definition TGLClip.cxx:161
virtual ~TGLClipPlane()
Destroy clip plane object.
Definition TGLClip.cxx:174
A collection of concrete TGLClip objects to be selected from.
Definition TGLClip.h:140
Bool_t fAutoUpdate
the current clipping shape
Definition TGLClip.h:150
void InvalidateClips()
Invalidate clip objects.
Definition TGLClip.cxx:455
virtual ~TGLClipSet()
Destructor.
Definition TGLClip.cxx:351
TGLClip * fCurrentClip
Definition TGLClip.h:148
Bool_t fShowManip
Definition TGLClip.h:152
TGLClip * GetCurrentClip() const
Definition TGLClip.h:170
TGLClipSet & operator=(const TGLClipSet &)
TGLManipSet * fManip
Definition TGLClip.h:153
void GetClipState(TGLClip::EType type, Double_t data[6]) const
Get state of clip object 'type' into data vector:
Definition TGLClip.cxx:477
void SetAutoUpdate(Bool_t aup)
Definition TGLClip.h:189
void SetClipState(TGLClip::EType type, const Double_t data[6])
Set state of clip object 'type' into data vector:
Definition TGLClip.cxx:524
TGLClipBox * fClipBox
Definition TGLClip.h:147
void FillPlaneSet(TGLPlaneSet_t &set) const
Forward request to fill the plane-set to the current clip.
Definition TGLClip.cxx:416
void SetShowClip(Bool_t show)
Definition TGLClip.h:193
virtual Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event)
Handle overlay event.
Definition TGLClip.cxx:379
void SetupCurrentClip(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition TGLClip.cxx:435
virtual void MouseLeave()
Mouse has left the element.
Definition TGLClip.cxx:389
void SetClipType(TGLClip::EType type)
Set current clip active in viewer - 'type' is one of kClipNone kClipPlane or kClipBox.
Definition TGLClip.cxx:580
Bool_t IsClipping() const
Definition TGLClip.h:169
void SetShowManip(Bool_t show)
Definition TGLClip.h:191
TGLClipSet()
Constructor.
Definition TGLClip.cxx:336
virtual Bool_t MouseStillInside(TGLOvlSelectRecord &selRec)
Definition TGLClip.cxx:367
Bool_t GetAutoUpdate() const
Definition TGLClip.h:188
TGLClipPlane * fClipPlane
Definition TGLClip.h:146
TGLBoundingBox fLastBBox
Definition TGLClip.h:155
Bool_t fShowClip
Definition TGLClip.h:151
TGLClipSet(const TGLClipSet &)
void SetupCurrentClipIfInvalid(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition TGLClip.cxx:445
virtual void Render(TGLRnrCtx &rnrCtx)
Render clip-shape and manipulator.
Definition TGLClip.cxx:397
Bool_t GetShowManip() const
Definition TGLClip.h:190
TGLClip::EType GetClipType() const
Get current type active in viewer - returns one of kClipNone kClipPlane or kClipBox.
Definition TGLClip.cxx:560
void SetupClips(const TGLBoundingBox &sceneBBox)
Setup clipping objects for given scene bounding box.
Definition TGLClip.cxx:425
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
Mouse has entered this element.
Definition TGLClip.cxx:362
Bool_t GetShowClip() const
Definition TGLClip.h:192
void InvalidateCurrentClip()
Invalidate current clip object.
Definition TGLClip.cxx:464
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition TGLClip.h:32
@ kClipBox
Definition TGLClip.h:43
@ kClipPlane
Definition TGLClip.h:42
@ kClipNone
Definition TGLClip.h:41
void IncTimeStamp()
Definition TGLClip.h:64
@ kOutside
Definition TGLClip.h:36
@ kInside
Definition TGLClip.h:37
virtual void Setup(const TGLBoundingBox &bbox)=0
UInt_t TimeStamp() const
Definition TGLClip.h:63
void Invalidate()
Definition TGLClip.h:67
EMode fMode
Definition TGLClip.h:47
virtual ~TGLClip()
Destroy clip object.
Definition TGLClip.cxx:101
virtual void Modified()
Definition TGLClip.h:55
UInt_t fTimeStamp
Definition TGLClip.h:48
virtual void PlaneSet(TGLPlaneSet_t &set) const =0
void SetMode(EMode mode)
Definition TGLClip.h:61
Bool_t fValid
Definition TGLClip.h:49
Bool_t IsValid() const
Definition TGLClip.h:66
EMode GetMode() const
Definition TGLClip.h:60
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
Combine all available manipulators in a collection.
Definition TGLManipSet.h:22
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition TGLUtil.h:598
An overlay element.
Definition TGLOverlay.h:23
Selection record for overlay objects.
Concrete physical shape - a GL drawable.
void Modified()
Call this after modifying the physical so that the information can be propagated to the object refere...
3D plane class - of format Ax + By + Cz + D = 0
Definition TGLUtil.h:525
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
3 component (x/y/z) vector class.
Definition TGLUtil.h:248
Event structure.
Definition GuiTypes.h:174
th1 Draw()