Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveText.hxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Author: Waad Alshehri, 2023
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT7_REveText
13#define ROOT7_REveText
14
15#include <ROOT/REveShape.hxx>
16#include <ROOT/REveVector.hxx>
17
18namespace ROOT {
19namespace Experimental {
20
21//------------------------------------------------------------------------------
22// REveText
23//------------------------------------------------------------------------------
24
25class REveText : public REveShape
26{
27private:
28 REveText(const REveText &) = delete;
29 REveText &operator=(const REveText &) = delete;
30
31protected:
32 // clang-format off
33 std::string fText {"<no-text>"};
34 /// Default must be a face ROOT ships: only Liberation Mono and Serif are in
35 /// $ROOTSYS/fonts, not Sans. Serif is also what the viewer axes hardcode.
36 std::string fFont {"LiberationSerif-Regular"};
40 Float_t fExtraBorder {0.2}; // border around text in font-size units
41 Int_t fMode {1}; // default mode is in relative screen coordinates [0,1]
42 Bool_t fResizable {true}; // can the client resize it by dragging the corner grip
43 Float_t fFontWeight {0.f}; // synthetic bold; 0 is the font as authored
44 Int_t fAlignH {0}; // EAlignH_e: which point of the box the position refers to
45 Int_t fAlignV {0}; // EAlignV_e
46 std::string fClickMir; // MIR the client sends when this text is clicked; empty = not a button
47 ElementId_t fClickTargetId{0}; // element the MIR is addressed to; 0 means this element
48 REveAunt *fClickAunt{nullptr}; //! target held as an aunt, so its death is noticed
50 // clang-format on
51 // UChar_t fTextAlpha {255}; // Better than main transparency -- to be fixed.
52
53 static std::string sSdfFontDir;
54
55 static bool SetDefaultSdfFontDir();
56
57public:
58 /// Anchoring: SetPosition() gives where the text goes, these give which point
59 /// of it lands there. kOriginH/kOriginV, the default, is the text origin; the
60 /// others are relative to the text box.
61 // clang-format off
64 // clang-format on
65
66 REveText(const Text_t *n = "REveText", const Text_t *t = "");
67 virtual ~REveText() {}
68
69 Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
70 void BuildRenderData() override;
71
72 void ComputeBBox() override;
73
74 // clang-format off
75 std::string GetText() const { return fText; }
76 void SetText(const std::string &text) { fText = text; StampObjProps(); }
77
78 std::string GetFont() const { return fFont; }
79 void SetFont(const std::string &font) { fFont = font; StampObjProps();}
80
81 Float_t GetFontSize() const { return fFontSize; }
83
84 Int_t GetMode() const { return fMode; }
86
87 /// Whether the client may resize this element by dragging its corner grip.
88 /// Moving is governed by SetPickable(), so a pickable element that is not
89 /// resizable can be repositioned but keeps its size.
90 Bool_t GetResizable() const { return fResizable; }
92
93 Int_t GetAlignH() const { return fAlignH; }
94 Int_t GetAlignV() const { return fAlignV; }
96
97 void SetClickAction(const std::string &mir, REveElement *target = nullptr);
98 const std::string &GetClickMir() const { return fClickMir; }
100
101 void RemoveAunt(REveAunt *au) override;
102
103 /// Stroke weight, applied by moving the SDF threshold rather than loading a
104 /// heavier face, so it is continuous and needs no second atlas. Worth a
105 /// small positive value for text only a few pixels tall.
108
110 void SetFontHinting(Float_t fontHinting) { fFontHinting = fontHinting; StampObjProps();}
111 // clang-format on
112
115
116 REveVector GetPosition() const { return fPosition; }
117 const REveVector& RefPosition() const { return fPosition; }
118 void SetPosition(const REveVector& position) { fPosition = position;}
119 void SetPosX(float x) { fPosition.fX = x; StampObjProps(); }
120 void SetPosY(float y) { fPosition.fY = y; StampObjProps(); }
121
122 Color_t GetTextColor() const { return fTextColor; }
123 void SetTextColor(Color_t color) { fTextColor = color; StampObjProps();}
124
125 // UChar_t GetTextAlpha() const { return fTextAlpha; }
126 // void SetTextAlpha(UChar_t c) { fTextAlpha = c; StampObjProps(); }
127
128 static bool SetSdfFontDir(const std::string &dir, bool require_write_access = true);
129 static bool AssertSdfFont(const std::string &font_name, const std::string &ttf_font);
130};
131
132} // namespace Experimental
133} // namespace ROOT
134
135#endif
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Color_t
Color number (short)
Definition RtypesCore.h:100
char Text_t
General string (char)
Definition RtypesCore.h:77
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
@ kMagenta
Definition Rtypes.h:66
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char text
void SetExtraBorder(float size)
Definition REveText.hxx:114
static std::string sSdfFontDir
Definition REveText.hxx:53
void SetTextAlign(Int_t h, Int_t v)
Definition REveText.hxx:95
void SetMode(Int_t mode)
Definition REveText.hxx:85
void SetFontHinting(Float_t fontHinting)
Definition REveText.hxx:110
Float_t GetFontHinting() const
Definition REveText.hxx:109
void SetFontWeight(Float_t w)
Definition REveText.hxx:107
void SetText(const std::string &text)
Definition REveText.hxx:76
Color_t GetTextColor() const
Definition REveText.hxx:122
void SetPosition(const REveVector &position)
Definition REveText.hxx:118
REveText(const REveText &)=delete
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
Definition REveText.cxx:74
const REveVector & RefPosition() const
Definition REveText.hxx:117
const std::string & GetClickMir() const
Definition REveText.hxx:98
Float_t GetFontSize() const
Definition REveText.hxx:81
void ComputeBBox() override
Compute bounding-box of the data.
Definition REveText.cxx:112
void SetTextColor(Color_t color)
Definition REveText.hxx:123
std::string GetFont() const
Definition REveText.hxx:78
std::string fFont
Default must be a face ROOT ships: only Liberation Mono and Serif are in $ROOTSYS/fonts,...
Definition REveText.hxx:36
static bool SetDefaultSdfFontDir()
Set default SDF font directory based on write permissions in the ui5 directory, WebGui....
Definition REveText.cxx:168
void SetClickAction(const std::string &mir, REveElement *target=nullptr)
Fill core part of JSON representation.
Definition REveText.cxx:40
ElementId_t GetClickTargetId() const
Definition REveText.hxx:99
REveText & operator=(const REveText &)=delete
EAlignH_e
Anchoring: SetPosition() gives where the text goes, these give which point of it lands there.
Definition REveText.hxx:62
void SetResizable(Bool_t r)
Definition REveText.hxx:91
void RemoveAunt(REveAunt *au) override
Clear the click action when the click target is destroyed, so the button does not keep an id that may...
Definition REveText.cxx:63
static bool AssertSdfFont(const std::string &font_name, const std::string &ttf_font)
Check if font exists, otherwise try to create it.
Definition REveText.cxx:213
REveVector GetPosition() const
Definition REveText.hxx:116
Float_t GetFontWeight() const
Stroke weight, applied by moving the SDF threshold rather than loading a heavier face,...
Definition REveText.hxx:106
std::string GetText() const
Definition REveText.hxx:75
Color_t fTextColor
target held as an aunt, so its death is noticed
Definition REveText.hxx:49
Bool_t GetResizable() const
Whether the client may resize this element by dragging its corner grip.
Definition REveText.hxx:90
void SetFontSize(float size)
Definition REveText.hxx:82
static bool SetSdfFontDir(const std::string &dir, bool require_write_access=true)
Set location where SDF fonts and their metrics data are stored or are to be created via the AssertSdf...
Definition REveText.cxx:133
Float_t GetExtraBorder() const
Definition REveText.hxx:113
void SetFont(const std::string &font)
Definition REveText.hxx:79
void BuildRenderData() override
Crates 3D point array for rendering.
Definition REveText.cxx:101
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16