ClingraphBackend#
Extends ClingoBackend with functionality to render and interact with clingraph images.
Warning
To use this backend you might need to manually install Graphviz. See the clingraph instalaltion for details.
Examples
This backend will allow the use of clingraph images inside a canvas element.
To use this feature, the user must provide a clingraph visualization encoding via the command line in argument --clingraph-files
.
The input to this encoding will be the domain-state (same input as for the ui-files).
Tip
The clingraph encoding will also have information about brave, and cautious consequences. So dont be afraid to use it in the graphs!
A clinguin canvas
is enhanced with an attribute image_type
.
When the value for this attirbute starts with clingraph
it will be substituted by the ClingraphBackend for the svg
representation of the graph.
By default the graph named default
will be used, another graph with name X
can be used by setting the image type to clingraph__X
Note
To use this backend with the TkinterFrontend, you must provide the option --intermediate-format=png
.
Examples
Creates a canvas in a window that will contain the default clingraph graph
elem(c, canvas, window).
attr(c, image_type, clingraph).
Interacting with the graph#
To interact with the clingraph nodes/edges, additional steps must be made.
Each node/edge must be added to the UI as an element inside the canvas using the type svg_node
(svg_edge
).
This type of elements require the identifier of the clingraph node/edge in argument clingraph_id
to link the interactivity with the svg element generated by clingraph.
Examples
Continuation of the previous example.
elem(n(X), svg_node, c).
attr(n(X), clingraph_id, X):- node(X).
node(X)
is generated in the ui-files
Tip
Notice that the clingraph nodes are not accesible by the ui-files. Therefore, nodes of the clingraph images have to be generated again in this encoding.
Consider separating the clingraph node generation into a diferent encoding, and then including it in the UI and clingraph encodings.
Warning
The interactive feature only work in web based frontends, not in Tkinter.
Note
update
actions applied to clingraph elements (svg_nodes) will update the html style, not the graphviz properties.
Therefore, it can be used to set things like visibility and opacity but not internal clingraph values.
Public operations#
Can be used as OPERATION in the actions of the ui-state Also includes all public operations from the ClingoBackend.
- class ClingraphBackend[source]
Extends ClingoBackend. With this Backend it is possible to include clingraph images in the UI. The image is rendered based on a visualization encoding every time the UI is updated. Then, they are sent the client as Base64 encoding.
Domain state constructors#
Important
The domain state also inclues domain constructors from the ClingoBackend