![]() |
aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
|
Classes | |
| struct | CausalDotStyle |
| The style of a causal model (section causal): nodeBgColor and nodeFgColor are the ones of the observed variables. More... | |
| struct | DotArcOptions |
| the options of an arc or an edge : an empty text (no value for the width) means "not given" More... | |
| struct | DotAttribute |
| An attribute of a graph, a node or an edge : key="value". More... | |
| struct | DotNodeOptions |
| the options of a node : an empty text means "not given", so that the value of the configuration is used More... | |
| class | DotOptions |
| The options given to a toDot(const DotOptions&). More... | |
| class | DotStyle |
| The look shared by all the graphs: size, direction, layout, colors of the arcs and of the nodes. More... | |
| class | DotWriter |
| Writes a graph in the dot language, statement after statement, in the order of the calls. More... | |
| struct | DynamicBNDotStyle |
| The style of a dynamic Bayesian network (section dynamicBN) : the colors of its clusters. More... | |
| struct | FactorGraphDotStyle |
| The style of a factor graph (section factorgraph): layout, nodeBgColor and nodeFgColor are the ones of the variables. More... | |
| struct | InfluenceDiagramDotStyle |
| The style of an influence diagram (section influenceDiagram). More... | |
| struct | JunctionTreeDotStyle |
| The style of a junction tree (section notebook): size is the size of the tree, not the one of its map. More... | |
| struct | Rgb |
| a color given by its three components, each one between 0 and 255 More... | |
Typedefs | |
| using | DotAttributes = std::vector< DotAttribute > |
| a list of attributes | |
Functions | |
| bool | parseColor (std::string_view color, Rgb &rgb) |
| Reads a color as it is written in a dot attribute. | |
| double | brightness (const Rgb &rgb) |
| Perceived brightness of a color, between 0 (black) and 255 (white): 0.299 R + 0.587 G +
0.114 B. | |
| std::string | contrastColor (const Rgb &rgb) |
| The text color which is readable on a background: white if its brightness is at most 153, black otherwise. | |
| std::string | resolveFgColor (std::string_view fgColor, std::string_view bgColor, std::string_view fallback) |
| The font color to use on a background, once the special value adaptive is resolved. | |
| void | writePreamble (DotWriter &writer, const DotStyle &style, const DotOptions &options, std::string_view defaultLabel="") |
| Writes the beginning of a graph, as pyAgrum displays it. | |
| DotAttributes | nodeAttributes (const DotStyle &style, const DotNodeOptions *options, std::string_view defaultLabel="", std::string_view defaultTooltip="") |
| The attributes of a node : its label and tooltip, and its colors if the options give some. | |
| DotAttributes | arcAttributes (const DotArcOptions *options) |
| The attributes of an arc or an edge given by the options : color, penwidth, label, tooltip and the ones given with setArcAttribute. | |
| void | addDefaultAttribute (DotAttributes &attributes, std::string_view key, std::string_view value) |
| Adds an attribute at the beginning of the list, unless the list already gives a value for this key : the value given by the caller of the toDot() wins over the one of the class. | |
| std::string | configFgColor (std::string_view section, std::string_view key) |
| A font color of the configuration, resolved against the background color which goes with it. | |
Variables | |
| constexpr std::string_view | ADAPTIVE_COLOR = "adaptive" |
| the special value of a font color: black or white, according to the brightness of the background | |
| using gum::dot::DotAttributes = std::vector< DotAttribute > |
a list of attributes
Definition at line 74 of file dotWriter.h.
| GUM_SHARED_PUBLIC void gum::dot::addDefaultAttribute | ( | DotAttributes & | attributes, |
| std::string_view | key, | ||
| std::string_view | value ) |
Adds an attribute at the beginning of the list, unless the list already gives a value for this key : the value given by the caller of the toDot() wins over the one of the class.
Definition at line 127 of file dotElements.cpp.
References addDefaultAttribute().
Referenced by gum::CausalModel< GUM_SCALAR >::_toDot_(), addDefaultAttribute(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
| GUM_SHARED_PUBLIC DotAttributes gum::dot::arcAttributes | ( | const DotArcOptions * | options | ) |
The attributes of an arc or an edge given by the options : color, penwidth, label, tooltip and the ones given with setArcAttribute.
Empty if there is no options.
Definition at line 112 of file dotElements.cpp.
References arcAttributes(), gum::dot::DotArcOptions::attributes, gum::dot::DotArcOptions::color, gum::dot::DotArcOptions::label, gum::dot::DotWriter::number(), gum::dot::DotArcOptions::tooltip, and gum::dot::DotArcOptions::width.
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::CausalModel< GUM_SCALAR >::_toDot_(), arcAttributes(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::DiGraph::toDot(), gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), gum::MixedGraph::toDot(), gum::PAG::toDot(), gum::PDAG::toDot(), and gum::UndiGraph::toDot().
Perceived brightness of a color, between 0 (black) and 255 (white): 0.299 R + 0.587 G + 0.114 B.
Definition at line 274 of file dotColor.cpp.
References brightness().
Referenced by brightness().
| GUM_SHARED_PUBLIC std::string gum::dot::configFgColor | ( | std::string_view | section, |
| std::string_view | key ) |
A font color of the configuration, resolved against the background color which goes with it.
The background color is the key of the same section whose suffix FgColor is replaced by BgColor (nodeFgColor goes with nodeBgColor). The special value adaptive is resolved by gum::dot::resolveFgColor, with the color of the arcs (key arcColor of the section notebook) when the background is not a color that can be interpreted.
| section | the section of the configuration (notebook, causal...). |
| key | the key of the font color, which ends with FgColor. |
| InvalidArgument | if key does not end with FgColor. |
| SyntaxError | if the font color or the background color is not a key of the configuration. |
Definition at line 78 of file dotStyle.cpp.
References configFgColor(), GUM_ERROR, and resolveFgColor().
Referenced by configFgColor(), gum::dot::CausalDotStyle::read(), gum::dot::FactorGraphDotStyle::read(), gum::dot::InfluenceDiagramDotStyle::read(), gum::dot::JunctionTreeDotStyle::read(), and gum::dot::DotStyle::readCredalNet().
| GUM_SHARED_PUBLIC std::string gum::dot::contrastColor | ( | const Rgb & | rgb | ) |
The text color which is readable on a background: white if its brightness is at most 153, black otherwise.
Definition at line 276 of file dotColor.cpp.
References contrastColor().
Referenced by contrastColor(), and resolveFgColor().
| GUM_SHARED_PUBLIC DotAttributes gum::dot::nodeAttributes | ( | const DotStyle & | style, |
| const DotNodeOptions * | options, | ||
| std::string_view | defaultLabel = "", | ||
| std::string_view | defaultTooltip = "" ) |
The attributes of a node : its label and tooltip, and its colors if the options give some.
What the options do not give is not written, so the default look of the preamble applies. A background color without font color gets an adaptive font color, black or white according to the background. The attributes given with setNodeAttribute come last.
| style | the look of the graph. |
| options | the options of the node, or nullptr if there is none. |
| defaultLabel | the label of the node if the options give none (none if empty). |
| defaultTooltip | the tooltip of the node if the options give none (none if empty). |
Definition at line 80 of file dotElements.cpp.
References ADAPTIVE_COLOR, gum::dot::DotStyle::arcColor, gum::dot::DotNodeOptions::attributes, gum::dot::DotNodeOptions::bgColor, gum::dot::DotNodeOptions::fgColor, gum::dot::DotNodeOptions::label, nodeAttributes(), gum::dot::DotStyle::nodeBgColor, resolveFgColor(), and gum::dot::DotNodeOptions::tooltip.
Referenced by gum::KTBN< GUM_SCALAR >::_timeSlicesToDot_(), gum::CausalModel< GUM_SCALAR >::_toDot_(), gum::BayesNet< double >::maxNonOneParam(), nodeAttributes(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph(), and gum::NodeGraphPart::writeDotNode().
Reads a color as it is written in a dot attribute.
The accepted spellings are #RGB, #RGBA, #RRGGBB, #RRGGBBAA (hexadecimal digits in any case; the transparency is ignored) and the 146 names of the HTML colors (burlywood, DarkBlue... whatever the case), with or without surrounding double quotes. Any other spelling (transparent, /blues9/3, 0.5 0.5 0.5, an unknown name...) is not interpretable.
| color | the spelling of the color. |
| rgb | receives the components if (and only if) the function returns true. |
Definition at line 245 of file dotColor.cpp.
References parseColor(), and gum::toLower().
Referenced by parseColor(), and resolveFgColor().
| GUM_SHARED_PUBLIC std::string gum::dot::resolveFgColor | ( | std::string_view | fgColor, |
| std::string_view | bgColor, | ||
| std::string_view | fallback ) |
The font color to use on a background, once the special value adaptive is resolved.
| fgColor | the configured font color. If it is not adaptive (whatever the case), it is returned as is. |
| bgColor | the background color the text is drawn on. |
| fallback | returned when fgColor is adaptive and bgColor is not interpretable (transparent, an unknown name...): usually the color of the arcs, which follows the light or dark theme. |
Definition at line 280 of file dotColor.cpp.
References ADAPTIVE_COLOR, contrastColor(), parseColor(), resolveFgColor(), and gum::toLower().
Referenced by configFgColor(), nodeAttributes(), gum::dot::FactorGraphDotStyle::read(), and resolveFgColor().
| GUM_SHARED_PUBLIC void gum::dot::writePreamble | ( | DotWriter & | writer, |
| const DotStyle & | style, | ||
| const DotOptions & | options, | ||
| std::string_view | defaultLabel = "" ) |
Writes the beginning of a graph, as pyAgrum displays it.
| writer | the writer, just created. |
| style | the look of the graph, read from the configuration. |
| options | the options given by the caller. |
| defaultLabel | the label of the graph if the options give none (for instance the name of a model). |
Definition at line 52 of file dotElements.cpp.
References gum::dot::DotStyle::arcColor, gum::dot::DotWriter::edgeDefaults(), gum::dot::DotWriter::graphAttributes(), gum::dot::DotOptions::label(), gum::dot::DotOptions::layout(), gum::dot::DotStyle::layout, gum::dot::DotStyle::nodeBgColor, gum::dot::DotWriter::nodeDefaults(), gum::dot::DotStyle::nodeFgColor, gum::dot::DotOptions::rankDir(), gum::dot::DotStyle::rankDir, gum::dot::DotOptions::size(), gum::dot::DotStyle::size, and writePreamble().
Referenced by gum::CausalModel< GUM_SCALAR >::_toDot_(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toDot(), gum::DiGraph::toDot(), gum::EssentialGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MarkovBlanket::toDot(), gum::MixedGraph::toDot(), gum::PAG::toDot(), gum::PDAG::toDot(), gum::UndiGraph::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph(), and writePreamble().
|
inlineconstexpr |
the special value of a font color: black or white, according to the brightness of the background
Definition at line 68 of file dotColor.h.
Referenced by nodeAttributes(), gum::dot::FactorGraphDotStyle::read(), and resolveFgColor().