Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 09:25:38

0001 // @(#)root/gl:$Id$
0002 // Author:  Matevz and Alja Tadel  20/02/2009
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 // clang++ <v20 (-Wshadow) complains about shadowing GuiTypes.h global enum ECursor. Let's silence warning:
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 // clang++ <v20 (-Wshadow) complains about shadowing GuiTypes.h global variable kNone. Let's silence warning:
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;           // x position [0, 1]
0058    Float_t           fPosY;           // y position [0, 1]
0059    Float_t           fWidth;
0060    Float_t           fHeight;
0061 
0062    Int_t             fMouseX, fMouseY; ///<! last mouse position
0063    EDrag             fDrag;            ///<!
0064    Float_t           fDrawW,  fDrawH;  ///<! width and height when drawing
0065    Float_t           fTextSizeDrag;    ///<! text-size at start of drag
0066 
0067    TGLVector3        fPointer;         // picked location in 3D space
0068    Bool_t            fActive;          // active item identifier
0069 
0070    TGMainFrame      *fMainFrame;       // editors
0071    TGTextEdit       *fTextEdit;        // editors
0072 
0073    static Color_t    fgBackColor;
0074    static Color_t    fgTextColor;
0075 
0076    TGLViewer        *fParent;
0077 
0078    TString           fText;           // annotation text
0079    Float_t           fTextSize;       // relative font size
0080    TGLFont           fFont;           // font used to render labels
0081    TGLFont           fMenuFont;       // font used to render menu buttons
0082    TGLFont::ETextAlignH_e fTextAlign;
0083 
0084    Color_t           fBackColor;      // background color
0085    Color_t           fTextColor;      // text color
0086    Char_t            fTransparency;   // transparency of background
0087 
0088    Bool_t            fDrawRefLine;    // draw 3D refrence line
0089    Bool_t            fUseColorSet;    // use color set from rnrCtx
0090    Bool_t            fAllowClose;     // allow closing via 'X' button
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); // GL-annotation.
0133 };
0134 
0135 #endif