LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::io::tikz_detail Namespace Reference

Functions

bool is_auto_generated (const TikzNode &nd)
 isAutoGeneratedNode: a ClassSwitch named CS_..._to_..., the name link gives the switch it inserts.
std::string output_anchor (const TikzNode &nd, const TikzOptions &opt)
 getOutputAnchor: a Queue's arrows leave its server circle when one is drawn; every other node, a Delay included, its box.
std::string self_loop (const std::string &id, const TikzNode &nd, const TikzOptions &opt)
 renderSelfLoop: the wide loop from the server circle of a Queue that draws one, the plain-node loop otherwise.
bool file_exists (const std::string &p)
bool ends_with (const std::string &s, const std::string &suf)
void write_text (const std::string &path, const std::string &text)
void copy_file (const std::string &from, const std::string &to)
std::string compile_pdf (const std::string &tex, const util::TempDir &dir)
 exportToPDF: compile tex in a fresh directory and return the PDF path.
std::string find_on_path (const std::string &cmd)
 The first executable named cmd on PATH, empty when there is none (TikZViewer.isCommandAvailable).
bool spawn_detached (const std::vector< std::string > &argv)
 Start argv detached (own session, std streams on /dev/null, double fork so no zombie); false if it cannot start.
bool display_pdf (const std::string &pdf)
 TikZViewer.displayPDF: a standalone viewer first, then the desktop default; false when neither is found.
const std::string & model_name (const TikzGraph &g)
template<class T>
const std::string & model_name (const qn::NetworkStruct< T > &sn)
template<class T>
const std::string & model_name (qn::Network< T > &m)
std::string java_sched_name (lang::SchedStrategy s)
 Java's SchedStrategy.name(): the enumerator spelling, which is the upper-cased text of sched_to_text.
std::string java_fixed (double v, int prec)
 Java's String.format("%." + prec + "f", v).
std::string sanitize_id (const std::string &name)
 name.replaceAll("[^a-zA-Z0-9]", "_"): one underscore per CODE POINT, so a UTF-8 sequence is one character.
void replace_all (std::string &s, const std::string &from, const std::string &to)
std::string escape_latex (std::string t)
 TikZNodeRenderer.escapeLatex, applied in the SAME sequence of whole-string replacements, so a backslash comes out as \textbackslash\{\}, exactly as the JAR's later brace replacement leaves it.
void reorder_by_barycenter (std::vector< std::size_t > &layer, const std::vector< std::vector< std::size_t > > &connections, const std::vector< std::size_t > &reference, std::size_t nnodes)
 reorderLayerByBarycenter: sort a layer by the mean position of its neighbours in the reference layer.
std::string styled_node (const std::string &style, const std::string &id, double x, double y, const std::string &body, const TikzNode &nd, const TikzOptions &opt)
 \node[style] (id) at (x,y) {body}; followed by the name label the options ask for.
std::string server_label (double c)
 String.valueOf(queue.getNumberOfServers()), the JAR's Integer.MAX_VALUE pool being infinity.

Variables

constexpr int kToolTimeout = 600
 Seconds a pdflatex or pdftoppm run may take before it is killed; a TikZ picture needs a few.

Function Documentation

◆ compile_pdf()

std::string line::io::tikz_detail::compile_pdf ( const std::string & tex,
const util::TempDir & dir )
inline

exportToPDF: compile tex in a fresh directory and return the PDF path.

The directory belongs to dir, so the caller copies the PDF out before it goes.

Definition at line 113 of file tikz.h.

References line::util::capture(), compile_pdf(), line::Error::Error(), line::util::ProcResult::exitCode, line::util::TempDir::file(), file_exists(), kToolTimeout, line::util::ProcResult::out, line::util::TempDir::path(), line::util::ProcResult::timedOut, and write_text().

Referenced by compile_pdf(), line::io::export_tikz(), line::io::tikz_export_png(), and line::io::tikz_view().

◆ copy_file()

void line::io::tikz_detail::copy_file ( const std::string & from,
const std::string & to )
inline

Definition at line 97 of file tikz.h.

References copy_file(), and line::InputError::InputError().

Referenced by copy_file(), and line::io::export_tikz().

◆ display_pdf()

bool line::io::tikz_detail::display_pdf ( const std::string & pdf)
inline

TikZViewer.displayPDF: a standalone viewer first, then the desktop default; false when neither is found.

Definition at line 293 of file tikz.h.

References display_pdf(), find_on_path(), and spawn_detached().

Referenced by display_pdf(), and line::io::tikz_view().

◆ ends_with()

bool line::io::tikz_detail::ends_with ( const std::string & s,
const std::string & suf )
inline

Definition at line 86 of file tikz.h.

References ends_with().

Referenced by ends_with(), line::io::export_tikz(), and line::io::tikz_export_png().

◆ escape_latex()

std::string line::io::tikz_detail::escape_latex ( std::string t)
inline

TikZNodeRenderer.escapeLatex, applied in the SAME sequence of whole-string replacements, so a backslash comes out as \textbackslash\{\}, exactly as the JAR's later brace replacement leaves it.

Definition at line 161 of file tikz_graph.h.

References escape_latex(), and replace_all().

Referenced by escape_latex(), and styled_node().

◆ file_exists()

bool line::io::tikz_detail::file_exists ( const std::string & p)
inline

Definition at line 81 of file tikz.h.

References file_exists().

Referenced by compile_pdf(), file_exists(), and find_on_path().

◆ find_on_path()

std::string line::io::tikz_detail::find_on_path ( const std::string & cmd)
inline

The first executable named cmd on PATH, empty when there is none (TikZViewer.isCommandAvailable).

Definition at line 259 of file tikz.h.

References file_exists(), and find_on_path().

Referenced by display_pdf(), and find_on_path().

◆ is_auto_generated()

bool line::io::tikz_detail::is_auto_generated ( const TikzNode & nd)
inline

isAutoGeneratedNode: a ClassSwitch named CS_..._to_..., the name link gives the switch it inserts.

Definition at line 62 of file tikz.h.

References line::lang::ClassSwitch, is_auto_generated(), line::io::TikzNode::name, and line::io::TikzNode::type.

Referenced by is_auto_generated(), and line::io::to_tikz().

◆ java_fixed()

std::string line::io::tikz_detail::java_fixed ( double v,
int prec )
inline

Java's String.format("%." + prec + "f", v).

The digits are the shortest decimal expansion that reads back as v (what Double.toString prints), rounded half up at prec decimals, which is FormattedFloatingDecimal.applyPrecision. A negative value keeps its sign even when it rounds to zero, as Java's does ("-0.00").

Definition at line 79 of file tikz_graph.h.

References java_fixed().

Referenced by java_fixed(), styled_node(), and line::io::tikz_render_routed_edge().

◆ java_sched_name()

std::string line::io::tikz_detail::java_sched_name ( lang::SchedStrategy s)
inline

Java's SchedStrategy.name(): the enumerator spelling, which is the upper-cased text of sched_to_text.

Definition at line 63 of file tikz_graph.h.

References java_sched_name(), line::lang::NONE, and line::lang::sched_to_text().

Referenced by java_sched_name(), and line::io::tikz_graph().

◆ model_name() [1/3]

template<class T>
const std::string & line::io::tikz_detail::model_name ( const qn::NetworkStruct< T > & sn)

Definition at line 310 of file tikz.h.

References model_name().

◆ model_name() [2/3]

const std::string & line::io::tikz_detail::model_name ( const TikzGraph & g)
inline

Definition at line 308 of file tikz.h.

References model_name(), and line::io::TikzGraph::name.

Referenced by model_name(), model_name(), model_name(), and line::io::tikz_view().

◆ model_name() [3/3]

template<class T>
const std::string & line::io::tikz_detail::model_name ( qn::Network< T > & m)

Definition at line 312 of file tikz.h.

References model_name(), and line::qn::Network< T >::raw_struct().

◆ output_anchor()

std::string line::io::tikz_detail::output_anchor ( const TikzNode & nd,
const TikzOptions & opt )
inline

getOutputAnchor: a Queue's arrows leave its server circle when one is drawn; every other node, a Delay included, its box.

Definition at line 68 of file tikz.h.

References output_anchor(), line::lang::Queue, and line::io::TikzNode::type.

Referenced by output_anchor(), and line::io::to_tikz().

◆ reorder_by_barycenter()

void line::io::tikz_detail::reorder_by_barycenter ( std::vector< std::size_t > & layer,
const std::vector< std::vector< std::size_t > > & connections,
const std::vector< std::size_t > & reference,
std::size_t nnodes )
inline

reorderLayerByBarycenter: sort a layer by the mean position of its neighbours in the reference layer.

Definition at line 40 of file tikz_layout.h.

References reorder_by_barycenter().

Referenced by reorder_by_barycenter(), and line::io::tikz_layout().

◆ replace_all()

void line::io::tikz_detail::replace_all ( std::string & s,
const std::string & from,
const std::string & to )
inline

Definition at line 148 of file tikz_graph.h.

References replace_all().

Referenced by escape_latex(), and replace_all().

◆ sanitize_id()

std::string line::io::tikz_detail::sanitize_id ( const std::string & name)
inline

name.replaceAll("[^a-zA-Z0-9]", "_"): one underscore per CODE POINT, so a UTF-8 sequence is one character.

Definition at line 134 of file tikz_graph.h.

References sanitize_id().

Referenced by sanitize_id(), line::io::tikz_render_node(), and line::io::to_tikz().

◆ self_loop()

std::string line::io::tikz_detail::self_loop ( const std::string & id,
const TikzNode & nd,
const TikzOptions & opt )
inline

renderSelfLoop: the wide loop from the server circle of a Queue that draws one, the plain-node loop otherwise.

Definition at line 73 of file tikz.h.

References line::lang::Queue, self_loop(), and line::io::TikzNode::type.

Referenced by self_loop(), and line::io::to_tikz().

◆ server_label()

std::string line::io::tikz_detail::server_label ( double c)
inline

String.valueOf(queue.getNumberOfServers()), the JAR's Integer.MAX_VALUE pool being infinity.

Definition at line 178 of file tikz_node_renderer.h.

References server_label().

Referenced by server_label(), and line::io::tikz_render_node().

◆ spawn_detached()

bool line::io::tikz_detail::spawn_detached ( const std::vector< std::string > & argv)
inline

Start argv detached (own session, std streams on /dev/null, double fork so no zombie); false if it cannot start.

Definition at line 272 of file tikz.h.

References spawn_detached().

Referenced by display_pdf(), and spawn_detached().

◆ styled_node()

std::string line::io::tikz_detail::styled_node ( const std::string & style,
const std::string & id,
double x,
double y,
const std::string & body,
const TikzNode & nd,
const TikzOptions & opt )
inline

\node[style] (id) at (x,y) {body}; followed by the name label the options ask for.

Definition at line 168 of file tikz_node_renderer.h.

References escape_latex(), java_fixed(), line::io::TikzNode::name, and styled_node().

Referenced by styled_node(), and line::io::tikz_render_node().

◆ write_text()

void line::io::tikz_detail::write_text ( const std::string & path,
const std::string & text )
inline

Variable Documentation

◆ kToolTimeout

int line::io::tikz_detail::kToolTimeout = 600
constexpr

Seconds a pdflatex or pdftoppm run may take before it is killed; a TikZ picture needs a few.

Definition at line 107 of file tikz.h.

Referenced by compile_pdf(), and line::io::tikz_export_png().