2.2.6. DGPrinter.h

2.2.6.1. Class DGPrintData

class DGPrintData

This class is used to hold extra data about how a specific derivation graph is visualised.

2.2.6.1.1. Synopsis

struct DGPrintData {
    DGPrintData(std::shared_ptr<DG> dg);
    DGPrintData(const DGPrintData &other);
    DGPrintData(DGPrintData &&other);
    ~DGPrintData();
    lib::IO::DG::Write::Data &getData();
    lib::IO::DG::Write::Data &getData() const;
    std::shared_ptr<DG> getDG() const;
    void makeDuplicate(DerivationRef dRef, unsigned int eDup);
    void removeDuplicate(DerivationRef dRef, unsigned int eDup);
    void reconnectTail(DerivationRef dRef, unsigned int eDup, std::shared_ptr<Graph> g, unsigned int vDupTar); // TODO: make overload with explicit source
    void reconnectHead(DerivationRef dRef, unsigned int eDup, std::shared_ptr<Graph> g, unsigned int vDupTar); // TODO: make overload with explicit source
private:
    std::shared_ptr<DG> dg;
    std::unique_ptr<lib::IO::DG::Write::Data> data;
};

2.2.6.1.2. Details

DGPrintData(std::shared_ptr<DG> dg)

Construct a data object where all derivations have a single version, 0, connected to version 0 of all heads and tails.

std::shared_ptr<DG> getDG() const
Returns:the derivation graph the object holds data for.
void makeDuplicate(DerivationRef dRef, unsigned int eDup)

Create another version of the given derivation and give it the given duplicate number.

void removeDuplicate(DerivationRef dRef, unsigned int eDup)

Remove the version of the given derivation with the given duplicate number.

void reconnectTail(DerivationRef dRef, unsigned int eDup, std::shared_ptr<Graph> g, unsigned int vDupTar)

Reconnect an arbitrary version of the tail specified by the given graph in the derivation duplicate given.

void reconnectHead(DerivationRef dRef, unsigned int eDup, std::shared_ptr<Graph> g, unsigned int vDupTar)

Reconnect an arbitrary version of the head specified by the given graph in the derivation duplicate given.

2.2.6.2. Class DGPrinter

class DGPrinter

This class is used to configure how derivation graphs are visualised, how much is visualised and which extra properties are printed.

2.2.6.2.1. Synopsis

struct DGPrinter {
    DGPrinter();
    DGPrinter(const DGPrinter&) = delete;
    DGPrinter &operator=(const DGPrinter&) = delete;
    ~DGPrinter();
    lib::IO::DG::Write::Printer &getPrinter() const;
    GraphPrinter &getGraphPrinter();
    const GraphPrinter &getGraphPrinter() const;
    void setWithShortcutEdges(bool value);
    bool getWithShortcutEdges() const;
    void setWithGraphImages(bool value);
    bool getWithGraphImages() const;
    void setLabelsAsLatexMath(bool value);
    bool getLabelsAsLatexMath() const;
    void pushVertexVisible(std::function<bool(std::shared_ptr<Graph>, std::shared_ptr<DG>) > f);
    void popVertexVisible();
    void pushEdgeVisible(std::function<bool(DerivationRef) > f);
    void popEdgeVisible();
    void setWithShortcutEdgesAfterVisibility(bool value);
    bool getWithShortcutEdgesAfterVisibility() const;
    void setVertexLabelSep(std::string sep);
    const std::string &getVertexLabelSep();
    void setEdgeLabelSep(std::string sep);
    const std::string &getEdgeLabelSep();
    void pushVertexLabel(std::function<std::string(std::shared_ptr<Graph>, std::shared_ptr<DG>) > f);
    void popVertexLabel();
    void pushEdgeLabel(std::function<std::string(DerivationRef) > f);
    void popEdgeLabel();
    void setWithGraphName(bool value);
    bool getWithGraphName() const;
    void setWithRuleName(bool value);
    bool getWithRuleName() const;
    void setWithRuleId(bool value);
    bool getWithRuleId() const;
    void pushVertexColour(std::function<std::string(std::shared_ptr<Graph>, std::shared_ptr<DG>) > f, bool extendToEdges);
    void popVertexColour();
    void pushEdgeColour(std::function<std::string(DerivationRef) > f);
    void popEdgeColour();
private:
    std::unique_ptr<GraphPrinter> graphPrinter;
    std::unique_ptr<lib::IO::DG::Write::Printer> printer;
};

2.2.6.2.2. Details

GraphPrinter &getGraphPrinter()
const GraphPrinter &getGraphPrinter() const
Returns:a reference to the GraphPrinter used for graphs in vertices of the DG.
void setWithShortcutEdges(bool value)
bool getWithShortcutEdges() const

Control whether or not hyperedges \((T, H)\) with \(|T| = |H| = 1\) are printed as a simple arrow without the usual rectangle.

void setWithGraphImages(bool value)
bool getWithGraphImages() const

Control whether or not each vertex is printed with a image of its graph in it.

void setLabelsAsLatexMath(bool value)
bool getLabelsAsLatexMath() const

Control whether or not labels on vertices and hyperedges are put inline \(\LaTeX\) math. Specifically, a label label is written as $\mathrm{label'}$, with label' being label with all space characters escaped.

void pushVertexVisible(std::function<bool(std::shared_ptr<Graph>, std::shared_ptr<DG>)> f)

Add another function controlling the visibility of vertices. All visibility functions must return true for a vertex to be visible.

void popVertexVisible()

Remove the last pushed vertex visibility function.

void pushEdgeVisible(std::function<bool(DerivationRef)> f)

Add another function controlling the visibility of hyperedges. All visibility functions must return true for a hyperedge to be visible.

void popEdgeVisible()

Remove the last pushed hyperedge visibility function.

void setWithShortcutEdgesAfterVisibility(bool value)
bool getWithShortcutEdgesAfterVisibility() const

Control whether or not hyperedges are depicted as simple arrows when all but 1 head and tail are hidden.

void setVertexLabelSep(std::string sep)
const std::string &getVertexLabelSep()

Set/get the string used as separator between each part of each vertex label.

void setEdgeLabelSep(std::string sep)
const std::string &getEdgeLabelSep()

Set/get the string used as separator between each part of each edge label.

void pushVertexLabel(std::function<std::string(std::shared_ptr<Graph>, std::shared_ptr<DG>)> f)

Add another function for vertex labelling. The result of this function is appended to each label.

void popVertexLabel()

Remove the last pushed vertex labelling function.

void pushEdgeLabel(std::function<std::string(DerivationRef)> f)

Add another function for edge labelling. The result of this function is appended to each label.

void popEdgeLabel()

Remove the last pushed edge labelling function.

void setWithGraphName(bool value)
bool getWithGraphName() const

Control whether or not graph names are appended to the vertex labels (see also pushVertexLabel()).

void setWithRuleName(bool value)
bool getWithRuleName() const

Control whether or not rules names are appended to the edge labels (see also pushEdgeLabel()).

void setWithRuleId(bool value)
bool getWithRuleId() const

Control whether or not rules IDs are appended to the edge labels (see also pushEdgeLabel()).

void pushVertexColour(std::function<std::string(std::shared_ptr<Graph>, std::shared_ptr<DG>)> f, bool extendToEdges, )

Add another function for colouring vertices. The final colour of a vertex is the result of the first colour function returning a non-empty string. The functions are evaluated in the order they are pushed and the resulting string is used directly as a colour in Tikz. A hyperedge is also coloured if at least one head and one tail can be coloured with a colour for which extendToEdges is true. In this case, the hyperedge (and a subset of the head and tail connectors) is coloured with the first applicable colour. The edge extension of vertex colour takes lower precedence than explicitly added hyperedge colouring functions.

void popVertexColour()

Remove the last pushed vertex colouring function.

void pushEdgeColour(std::function<std::string(DerivationRef)> f)

Add another function for colouring hyperedges. The final colour of a hyperedge (and all of its head and tail connectors) is the result of the first colour function returning a non-empty string.

void popEdgeColour()

Remove the last pushed hyperedge colouring function.