File indexing completed on 2026-09-08 09:25:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGLAnnotation
0013 #define ROOT_TGLAnnotation
0014
0015 #include "TGLOverlay.h"
0016 #include "TGLUtil.h"
0017 #include "TGLFontManager.h"
0018
0019 class TGLViewer;
0020 class TGLViewerBase;
0021 class TGLFont;
0022 class TGTextEdit;
0023 class TGMainFrame;
0024
0025 class TGLAnnotation : public TGLOverlayElement
0026 {
0027 private:
0028 TGLAnnotation(const TGLAnnotation&) = delete;
0029 TGLAnnotation& operator=(const TGLAnnotation&) = delete;
0030
0031 protected:
0032 enum EDrag {
0033
0034 #if defined(__clang__) && __clang_major__ < 20
0035 #pragma clang diagnostic push
0036 #pragma clang diagnostic ignored "-Wshadow"
0037 #endif
0038 kMove,
0039 #if defined(__clang__) && __clang_major__ < 20
0040 #pragma clang diagnostic pop
0041 #endif
0042 kResize,
0043
0044 #if defined(__clang__) && __clang_major__ < 20
0045 #pragma clang diagnostic push
0046 #pragma clang diagnostic ignored "-Wshadow"
0047 #endif
0048 kNone };
0049 #if defined(__clang__) && __clang_major__ < 20
0050 #pragma clang diagnostic pop
0051 #endif
0052 enum ENameStack { kMoveID, kEditID, kDeleteID, kResizeID };
0053
0054 void MakeEditor();
0055 Char_t GetLineTransparency() const;
0056
0057 Float_t fPosX;
0058 Float_t fPosY;
0059 Float_t fWidth;
0060 Float_t fHeight;
0061
0062 Int_t fMouseX, fMouseY;
0063 EDrag fDrag;
0064 Float_t fDrawW, fDrawH;
0065 Float_t fTextSizeDrag;
0066
0067 TGLVector3 fPointer;
0068 Bool_t fActive;
0069
0070 TGMainFrame *fMainFrame;
0071 TGTextEdit *fTextEdit;
0072
0073 static Color_t fgBackColor;
0074 static Color_t fgTextColor;
0075
0076 TGLViewer *fParent;
0077
0078 TString fText;
0079 Float_t fTextSize;
0080 TGLFont fFont;
0081 TGLFont fMenuFont;
0082 TGLFont::ETextAlignH_e fTextAlign;
0083
0084 Color_t fBackColor;
0085 Color_t fTextColor;
0086 Char_t fTransparency;
0087
0088 Bool_t fDrawRefLine;
0089 Bool_t fUseColorSet;
0090 Bool_t fAllowClose;
0091
0092 public:
0093 TGLAnnotation(TGLViewerBase *parent, const char *text, Float_t posx, Float_t posy);
0094 TGLAnnotation(TGLViewerBase *parent, const char *text, Float_t posx, Float_t posy, TGLVector3 ref);
0095 ~TGLAnnotation() override;
0096
0097 void SetText(const TString& x) { fText = x; }
0098 const TString& GetText() const { return fText; }
0099
0100 void SetTransparency(Char_t x) { fTransparency = x; }
0101 Char_t GetTransparency() const { return fTransparency; }
0102
0103 void SetUseColorSet(Bool_t x) { fUseColorSet = x; }
0104 Bool_t GetUseColorSet() const { return fUseColorSet; }
0105
0106 void SetBackColor(Color_t x) { fBackColor = x; }
0107 Color_t GetBackColor() const { return fBackColor; }
0108
0109 void SetTextColor(Color_t x) { fTextColor = x; }
0110 Color_t GetTextColor() const { return fTextColor; }
0111
0112 void SetTextSize(Float_t x) { fTextSize = x; }
0113 Float_t GetTextSize() const { return fTextSize; }
0114
0115 void SetAllowClose(Bool_t x) { fAllowClose = x; }
0116 Bool_t GetAllowClose() const { return fAllowClose; }
0117
0118 TGLFont::ETextAlignH_e GetTextAlign() const { return fTextAlign; }
0119 void SetTextAlign(TGLFont::ETextAlignH_e a) { fTextAlign = a; }
0120
0121 Bool_t MouseEnter(TGLOvlSelectRecord& selRec) override;
0122 Bool_t Handle(TGLRnrCtx& rnrCtx, TGLOvlSelectRecord& selRec,
0123 Event_t* event) override;
0124 void MouseLeave() override;
0125
0126 void CloseEditor();
0127
0128 void UpdateText();
0129
0130 void Render(TGLRnrCtx& rnrCtx) override;
0131
0132 ClassDefOverride(TGLAnnotation, 0);
0133 };
0134
0135 #endif