00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGLClip
00013 #define ROOT_TGLClip
00014
00015 #include "TGLPhysicalShape.h"
00016 #include "TGLOverlay.h"
00017
00018 class TGLRnrCtx;
00019 class TGLManipSet;
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 class TGLClip : public TGLPhysicalShape
00032 {
00033 public:
00034 enum EMode { kOutside,
00035 kInside
00036 };
00037
00038 protected:
00039 EMode fMode;
00040 UInt_t fTimeStamp;
00041 Bool_t fValid;
00042
00043 public:
00044 TGLClip(const TGLLogicalShape & logical, const TGLMatrix & transform, const float color[4]);
00045 virtual ~TGLClip();
00046
00047 virtual void Modified() { TGLPhysicalShape::Modified(); IncTimeStamp(); }
00048
00049 virtual void Setup(const TGLBoundingBox & bbox) = 0;
00050 virtual void Setup(const TGLVector3&, const TGLVector3&);
00051
00052 EMode GetMode() const { return fMode; }
00053 void SetMode(EMode mode) { if (mode != fMode) { fMode = mode; ++fTimeStamp; } }
00054
00055 UInt_t TimeStamp() const { return fTimeStamp; }
00056 void IncTimeStamp() { ++fTimeStamp; }
00057
00058 Bool_t IsValid() const { return fValid; }
00059 void Invalidate() { fValid = kFALSE; }
00060
00061 virtual void Draw(TGLRnrCtx & rnrCtx) const;
00062 virtual void PlaneSet(TGLPlaneSet_t & set) const = 0;
00063
00064 ClassDef(TGLClip,0);
00065 };
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 class TGLClipPlane : public TGLClip
00078 {
00079 private:
00080 static const float fgColor[4];
00081
00082 public:
00083 TGLClipPlane();
00084 virtual ~TGLClipPlane();
00085
00086 virtual void Setup(const TGLBoundingBox & bbox);
00087 virtual void Setup(const TGLVector3& point, const TGLVector3& normal);
00088
00089 void Set(const TGLPlane & plane);
00090
00091 virtual void PlaneSet(TGLPlaneSet_t & set) const;
00092
00093 ClassDef(TGLClipPlane, 0);
00094 };
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 class TGLClipBox : public TGLClip
00106 {
00107 private:
00108 static const float fgColor[4];
00109
00110 public:
00111 TGLClipBox();
00112 virtual ~TGLClipBox();
00113
00114 virtual void Setup(const TGLBoundingBox & bbox);
00115 virtual void Setup(const TGLVector3& min_point, const TGLVector3& max_point);
00116
00117 virtual void PlaneSet(TGLPlaneSet_t & set) const;
00118
00119 ClassDef(TGLClipBox, 0);
00120 };
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 class TGLClipSet : public TGLOverlayElement
00132 {
00133 private:
00134 TGLClipSet(const TGLClipSet&);
00135 TGLClipSet& operator=(const TGLClipSet&);
00136
00137 protected:
00138 TGLClipPlane *fClipPlane;
00139 TGLClipBox *fClipBox;
00140 TGLClip *fCurrentClip;
00141
00142 Bool_t fAutoUpdate;
00143 Bool_t fShowClip;
00144 Bool_t fShowManip;
00145 TGLManipSet *fManip;
00146
00147 TGLBoundingBox fLastBBox;
00148
00149 public:
00150 TGLClipSet();
00151 virtual ~TGLClipSet();
00152
00153 virtual Bool_t MouseEnter(TGLOvlSelectRecord& selRec);
00154 virtual Bool_t MouseStillInside(TGLOvlSelectRecord& selRec);
00155 virtual Bool_t Handle(TGLRnrCtx& rnrCtx, TGLOvlSelectRecord& selRec,
00156 Event_t* event);
00157 virtual void MouseLeave();
00158
00159 virtual void Render(TGLRnrCtx& rnrCtx);
00160
00161 Bool_t IsClipping() const { return fCurrentClip != 0; }
00162 TGLClip* GetCurrentClip() const { return fCurrentClip; }
00163 void FillPlaneSet(TGLPlaneSet_t& set) const;
00164
00165
00166 void SetupClips(const TGLBoundingBox& sceneBBox);
00167 void SetupCurrentClip(const TGLBoundingBox& sceneBBox);
00168 void SetupCurrentClipIfInvalid(const TGLBoundingBox& sceneBBox);
00169
00170 void InvalidateClips();
00171 void InvalidateCurrentClip();
00172
00173 void GetClipState(EClipType type, Double_t data[6]) const;
00174 void SetClipState(EClipType type, const Double_t data[6]);
00175
00176 EClipType GetClipType() const;
00177 void SetClipType(EClipType type);
00178
00179
00180 Bool_t GetAutoUpdate() const { return fAutoUpdate; }
00181 void SetAutoUpdate(Bool_t aup) { fAutoUpdate = aup; }
00182 Bool_t GetShowManip() const { return fShowManip; }
00183 void SetShowManip(Bool_t show) { fShowManip = show; }
00184 Bool_t GetShowClip() const { return fShowClip; }
00185 void SetShowClip(Bool_t show) { fShowClip = show; }
00186
00187 ClassDef(TGLClipSet, 0);
00188 };
00189
00190 #endif