16#ifndef ROOT7_RDrawingAttr
17#define ROOT7_RDrawingAttr
22#include <unordered_map>
26namespace Experimental {
28class RDrawingAttrBase;
29class RDrawingOptsBase;
46template <typename ENUM, class = typename std::enable_if<std::is_enum<ENUM>::value>
::type>
67template <typename ENUM, class = typename std::enable_if<std::is_enum<ENUM>::value>
::type>
76class RDrawingAttrHolder;
101 explicit Path(
const std::string &str):
fStr(str) {}
103 explicit Path(std::string &&str):
fStr(std::move(str)) {}
125 const std::string
Str()
const {
return fStr; }
232 return !(*
this == other);
243 using Map_t = std::unordered_map<std::string, std::string>;
266 const std::string *
AtIf(
const Path_t &path)
const;
A collection of graphics attributes, for instance everything describing a line: color,...
RDrawingAttrBase()=default
Construct a default, unnamed, unconnected attribute.
T Get(const Name &name) const
Get the attribute value for an attribute value of type T.
void Set(const Name &name, const T &val)
Insert or update the attribute value identified by name to the given value.
bool operator!=(const RDrawingAttrBase &other) const
Compare unequal to other RDrawingAttrBase. Returns the negated operator==.
static constexpr const FromOption_t FromOption
RDrawingAttrBase(const Name &name)
Construct a named attribute that does not have a parent; e.g.
std::string GetValueString(const Path &path) const
Get the attribute value as string, for a given attribute name.
RDrawingAttrBase(const RDrawingAttrBase &other)=default
Construct as a copy.
bool IsFromStyle(const Path &path) const
Return true if the attribute's value comes from the styles, i.e.
const Path & GetPath() const
Return the attribute names that lead to this attribute, starting with the topmost attribute,...
void SetValueString(const Name &name, const std::string &strVal)
Insert or update the attribute value identified by the valueIndex (in fValueNames) to the value strVa...
const std::weak_ptr< RDrawingAttrHolder > & GetHolderPtr() const
Actual attribute holder.
RDrawingAttrBase & operator=(const RDrawingAttrBase &rhs)
Copy-assign: this assigns the attribute values to this attribute, without changing the connected draw...
RDrawingAttrBase(RDrawingAttrBase &&other)=default
Construct as a moved-to.
RDrawingAttrBase(const Name &name, RDrawingOptsBase &opts)
Construct a top-most attribute from its holder.
bool operator==(const RDrawingAttrBase &other) const
Equality compare to other RDrawingAttrBase.
Path fPath
The chain of attribute names, as used in style files.
std::weak_ptr< RDrawingAttrHolder > fHolder
The container of the attribute values.
A container of (stringified) attributes for which values have been provided.
bool Equal(const RDrawingAttrHolder &other, const Path_t &thisPath, const Path_t &otherPath)
Equality compare the attributes within path to those of other within otherpath.
const std::string * AtIf(const Path_t &path) const
Get an attribute value as pointer to string, given its name path, or nullptr if the attribute does no...
std::vector< Map_t::const_iterator > GetAttributesInPath(const Path_t &path) const
Extract contained attributes for a given path (including sub-attributes); returns iterators to a subs...
const std::vector< std::string > & GetStyleClasses() const
Get the attribute style classes of these options.
std::string GetAttrFromStyle(const Path_t &path)
Get the (stringified) value of the named attribute from the Style.
RDrawingAttrBase::Path Path_t
void CopyAttributesInPath(const Path_t &targetPath, const RDrawingAttrHolder &source, const Path_t &sourcePath)
Copy attributes within otherPath into.
RDrawingAttrHolder()=default
RDrawingAttrHolder using only the default style.
Map_t fAttrNameVals
Map attribute paths to their values.
std::string & At(const Path_t &path)
Get an attribute value as string, given its name path.
RDrawingAttrHolder(const std::vector< std::string > &styleClasses)
RDrawingAttrHolder with an ordered collection of styles taking precedence before the default style.
void EraseAttributesInPath(const Path_t &path)
Erase all custom set attributes for a given path (including sub-attributes).
void SetStyleClasses(const std::vector< std::string > &styles)
Set the attribute style classes of these options.
std::unordered_map< std::string, std::string > Map_t
std::vector< std::string > fStyleClasses
Attribute style classes of these options that will be "summed" in order, e.g.
std::string ToAttributeString(const RColor &val)
Return a std::string representation of a RColor, suitable as input to ColorFromString().
RColor FromAttributeString(const std::string &str, const std::string &name, RColor *)
Initialize a RColor from a string value.
Namespace for new ROOT classes and functions.
Tag type to disambiguate construction from options.
An attribute name part, e.g. "line".
Name(const std::string &name)
Combination of names, e.g. "hist2d.box.line.width".
Path operator+(const Name &name) const
std::string fStr
Path in its dotted form.
bool operator==(const Path &rhs) const
const std::string Str() const
void Append(const Name &name)
bool operator!=(const Path &rhs) const
Path(const std::string &str)
Path & operator+=(const Name &name)