Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/ROOT/REveText.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/eve7:$Id$
0002 // Author: Waad Alshehri, 2023
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2019, 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 ROOT7_REveText
0013 #define ROOT7_REveText
0014 
0015 #include <ROOT/REveShape.hxx>
0016 #include <ROOT/REveVector.hxx>
0017 
0018 namespace ROOT {
0019 namespace Experimental {
0020 
0021 //------------------------------------------------------------------------------
0022 // REveText
0023 //------------------------------------------------------------------------------
0024 
0025 class REveText : public REveShape
0026 {
0027 private:
0028    REveText(const REveText &) = delete;
0029    REveText &operator=(const REveText &) = delete;
0030 
0031 protected:
0032    std::string fText {"<no-text>"};
0033    std::string fFont {"LiberationSans-Regular"};
0034    REveVector  fPosition {0, 0, 0};
0035    Float_t     fFontSize {80};
0036    Float_t     fFontHinting {1.0};
0037    Float_t     fExtraBorder {0.2}; // border around text in font-size units
0038    Int_t       fMode {1}; // default mode is in relative screen coordinates [0,1]
0039    Color_t     fTextColor {kMagenta};
0040    // UChar_t     fTextAlpha {255}; // Better than main transparency -- to be fixed.
0041 
0042    static std::string sSdfFontDir;
0043 
0044    static bool SetDefaultSdfFontDir();
0045 
0046 public:
0047    REveText(const Text_t *n = "REveText", const Text_t *t = "");
0048    virtual ~REveText() {}
0049 
0050     Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0051    void BuildRenderData() override;
0052 
0053    void ComputeBBox() override;
0054 
0055    std::string GetText() const { return fText; }
0056    void SetText(std::string_view text) { fText = text; StampObjProps(); }
0057 
0058    std::string GetFont() const { return fFont; }
0059    void SetFont(std::string_view font) { fFont = font; StampObjProps();}
0060 
0061    Float_t GetFontSize() const { return fFontSize; }
0062    void SetFontSize(float size) { fFontSize = size; StampObjProps();}
0063 
0064    Int_t GetMode() const { return fMode; }
0065    void SetMode(Int_t mode) { fMode = mode;}
0066 
0067    Float_t GetFontHinting() const { return fFontHinting; }
0068    void SetFontHinting(Float_t fontHinting) { fFontHinting = fontHinting; StampObjProps();}
0069 
0070    Float_t GetExtraBorder() const { return fExtraBorder; }
0071    void SetExtraBorder(float size) { fExtraBorder = size; StampObjProps();}
0072 
0073    REveVector GetPosition() const { return fPosition; }
0074    const REveVector& RefPosition() const { return fPosition; }
0075    void SetPosition(const REveVector& position) { fPosition = position;}
0076    void SetPosX(float x) { fPosition.fX = x; StampObjProps(); }
0077    void SetPosY(float y) { fPosition.fY = y; StampObjProps(); }
0078 
0079    Color_t GetTextColor() const { return fTextColor; }
0080    void SetTextColor(Color_t color) { fTextColor = color; StampObjProps();}
0081 
0082    // UChar_t GetTextAlpha() const { return fTextAlpha; }
0083    // void SetTextAlpha(UChar_t c) { fTextAlpha = c; StampObjProps(); }
0084 
0085    static bool SetSdfFontDir(std::string_view dir, bool require_write_access = true);
0086    static bool AssertSdfFont(std::string_view font_name, std::string_view ttf_font);
0087 };
0088 
0089 } // namespace Experimental
0090 } // namespace ROOT
0091 
0092 #endif