File indexing completed on 2025-01-18 10:11:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGLClip
0013 #define ROOT_TGLClip
0014
0015 #include "TGLPhysicalShape.h"
0016 #include "TGLOverlay.h"
0017
0018 class TGLRnrCtx;
0019 class TGLManipSet;
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class TGLClip : public TGLPhysicalShape
0032 {
0033 public:
0034 enum EMode
0035 {
0036 kOutside,
0037 kInside
0038 };
0039 enum EType
0040 {
0041 kClipNone = 0,
0042 kClipPlane,
0043 kClipBox
0044 };
0045
0046 protected:
0047 EMode fMode;
0048 UInt_t fTimeStamp;
0049 Bool_t fValid;
0050
0051 public:
0052 TGLClip(const TGLLogicalShape & logical, const TGLMatrix & transform, const float color[4]);
0053 ~TGLClip() override;
0054
0055 virtual void Modified() { TGLPhysicalShape::Modified(); IncTimeStamp(); }
0056
0057 virtual void Setup(const TGLBoundingBox & bbox) = 0;
0058 virtual void Setup(const TGLVector3&, const TGLVector3&);
0059
0060 EMode GetMode() const { return fMode; }
0061 void SetMode(EMode mode) { if (mode != fMode) { fMode = mode; ++fTimeStamp; } }
0062
0063 UInt_t TimeStamp() const { return fTimeStamp; }
0064 void IncTimeStamp() { ++fTimeStamp; }
0065
0066 Bool_t IsValid() const { return fValid; }
0067 void Invalidate() { fValid = kFALSE; }
0068
0069 void Draw(TGLRnrCtx & rnrCtx) const override;
0070 virtual void PlaneSet(TGLPlaneSet_t & set) const = 0;
0071
0072 ClassDefOverride(TGLClip,0);
0073 };
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 class TGLClipPlane : public TGLClip
0086 {
0087 private:
0088 static const float fgColor[4];
0089
0090 public:
0091 TGLClipPlane();
0092 ~TGLClipPlane() override;
0093
0094 void Setup(const TGLBoundingBox & bbox) override;
0095 void Setup(const TGLVector3& point, const TGLVector3& normal) override;
0096
0097 void Set(const TGLPlane & plane);
0098
0099 void PlaneSet(TGLPlaneSet_t & set) const override;
0100
0101 ClassDefOverride(TGLClipPlane, 0);
0102 };
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 class TGLClipBox : public TGLClip
0114 {
0115 private:
0116 static const float fgColor[4];
0117
0118 public:
0119 TGLClipBox();
0120 ~TGLClipBox() override;
0121
0122 void Setup(const TGLBoundingBox & bbox) override;
0123 void Setup(const TGLVector3& min_point, const TGLVector3& max_point) override;
0124
0125 void PlaneSet(TGLPlaneSet_t & set) const override;
0126
0127 ClassDefOverride(TGLClipBox, 0);
0128 };
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139 class TGLClipSet : public TGLOverlayElement
0140 {
0141 private:
0142 TGLClipSet(const TGLClipSet&) = delete;
0143 TGLClipSet& operator=(const TGLClipSet&) = delete;
0144
0145 protected:
0146 TGLClipPlane *fClipPlane;
0147 TGLClipBox *fClipBox;
0148 TGLClip *fCurrentClip;
0149
0150 Bool_t fAutoUpdate;
0151 Bool_t fShowClip;
0152 Bool_t fShowManip;
0153 TGLManipSet *fManip;
0154
0155 TGLBoundingBox fLastBBox;
0156
0157 public:
0158 TGLClipSet();
0159 ~TGLClipSet() override;
0160
0161 Bool_t MouseEnter(TGLOvlSelectRecord& selRec) override;
0162 Bool_t MouseStillInside(TGLOvlSelectRecord& selRec) override;
0163 Bool_t Handle(TGLRnrCtx& rnrCtx, TGLOvlSelectRecord& selRec,
0164 Event_t* event) override;
0165 void MouseLeave() override;
0166
0167 void Render(TGLRnrCtx& rnrCtx) override;
0168
0169 Bool_t IsClipping() const { return fCurrentClip != nullptr; }
0170 TGLClip* GetCurrentClip() const { return fCurrentClip; }
0171 void FillPlaneSet(TGLPlaneSet_t& set) const;
0172
0173
0174 void SetupClips(const TGLBoundingBox& sceneBBox);
0175 void SetupCurrentClip(const TGLBoundingBox& sceneBBox);
0176 void SetupCurrentClipIfInvalid(const TGLBoundingBox& sceneBBox);
0177
0178 void InvalidateClips();
0179 void InvalidateCurrentClip();
0180
0181 void GetClipState(TGLClip::EType type, Double_t data[6]) const;
0182 void SetClipState(TGLClip::EType type, const Double_t data[6]);
0183
0184 TGLClip::EType GetClipType() const;
0185 void SetClipType(TGLClip::EType type);
0186
0187
0188 Bool_t GetAutoUpdate() const { return fAutoUpdate; }
0189 void SetAutoUpdate(Bool_t aup) { fAutoUpdate = aup; }
0190 Bool_t GetShowManip() const { return fShowManip; }
0191 void SetShowManip(Bool_t show) { fShowManip = show; }
0192 Bool_t GetShowClip() const { return fShowClip; }
0193 void SetShowClip(Bool_t show) { fShowClip = show; }
0194
0195 ClassDefOverride(TGLClipSet, 0);
0196 };
0197
0198 #endif