Class: GraphDiagramCanvas

GraphDiagramCanvas(query, name, size)

The graph diagram class is the main class for dealing with graph diagram canvases. The graph diagram class stores a graph using two lists one for the nodes of the graph and one for the edges of the graph.

Constructor

new GraphDiagramCanvas(query, name, size)

Construct a graph diagram canvas widget instance and draw it to the screen.
Parameters:
Name Type Description
query string String containing html id of the canvas we are constructing for.
name string String containing the instrument name that this widget corresponds to.
size number Sizes of nodes.
Source:

Members

coord

The coords of the mouse.
Source:

curInputs

The number of inputs for the next node to be constructed.
Source:

curName

The textual name of the next node to be constructed.
Source:

curOutputStyle

The output style of the next node. This should either be the string "FUNCTIONAL" or the string "MACRO". In functional output style code is emitted using csound opcode functional notation (without typing). In macro output style code is emitted as is but with some inputs substituted for text based macros of the form @ where n is an integer.
Source:

curOutputs

The output format for the outputs of the next node to be constructed. This is a string in csv format. Each entry is the variable type prefix from csound of the corresponding output. The node outputs are specified in order in the list from left to right.
Source:

edgeList

The list of edges for this graph.
Source:

inputMode

The current input mode.
Source:

inputModes

The various input modes of this widget. Node mode is used to input nodes by mouse left click. Delete mode is used to delete nodes by mouse left click. Edge mode is used to connect an edge from one node to another via a sequence of mouseclicks.
Source:

instrumentName

The name of this instrument.
Source:

nodeList

The list of nodes for this graph.
Source:

scaleAmt

Amount scale changes by.
Source:

startEdgeNodeType

The type of node that the edge starts from while building an edge (either a node input or a node output).
Source:

translateAmt

Amount translate changes by.
Source:

workingEdge

The edge we are currently building.
Source:

workingStartNode

The first node clicked while building an edge.
Source:

Methods

circleCoord(c)

Draw a circle around the input coord.
Parameters:
Name Type Description
c object The center point to draw the circle around.
Source:

configureNode(name, inputs, outputs, style)

Configure the nodes that are created on left click in node mode.
Parameters:
Name Type Description
name string String containing html id of the canvas we are constructing for.
inputs number The number of inputs to the node.
outputs string The csv formatted list of outputs.
style string The style of output for the node (should be "FUNCTIONAL" or "MACRO").
Source:

draw()

Draw the current state of the widget to the screen.
Source:

drawRectangleOutline(c1, c2)

Draw a rectangle outline with the given points.
Parameters:
Name Type Description
c1 object Object denoting top left coord of rectangle.
c2 object Object denoting bottom right coord of rectangle.
Source:

edgeDelete()

Delete the currently selected edge.
Source:

getName()

Get the name of the instrument associated with this parameter widget.
Source:
Returns:
The above mentioned name.

helperText()

Prints helper text to the top right corner of the widget.
Source:

leftClickDown()

Handle when mouse left click is pressed down.
Source:

mButtonClick(ev)

Handles button clicks from the user.
Parameters:
Name Type Description
ev event The event containing the button click we are handling.
Source:

nodeDelete()

Delete the currently selected node.
Source:

reconfigure(file)

Set up the state of the widget based on the input file. Takes in a 2d array file[i][j] where i indexes across the # delimited sections specified in toText() and j indexes across the individual lines per section.
Parameters:
Name Type Description
file object The file as a double array of strings to load the graph from.
Source:

renderToText()

Render the graph described by the graph into properly formed csound instrument code.
Source:
Returns:
The string containing the above mentioned code.

screenToWorldCoords(p)

Converts the coordinates of the input point in screen coordinates to local/world coordinates.
Parameters:
Name Type Description
p object Point to convert.
Source:
Returns:
A new point with transformed x and y coords.

toText()

Output a data format representing the current graph. The format is organized into sections delimited by lines of #s. The first section contains graph structure data with nodes replaced by their indices in the nodeList. The next sections contain node data with output/input adjacency list nodes replaced by indices. the last two sections are the input/output adjacency lists in terms of the above indices. This allows us to recreate the various adjacency lists from scratch when we decide to read this file. The individual lines for data are stored using more toText() methods or stringify (though perhaps later) we will do this differently.
Source:
Returns:
the above mentioned format (as a string).

updateMouseCoordinates()

Update the current coordinates of the mouse.
Source: