Module Simantics/Scenegraph

This module is undocumented. This is a list of its definitions.

ALIGN_BOTTOM :: Integer

Vertical alignment for renderScaledAndAlignedSVG: put the content against the bottom edge.

ALIGN_CENTER :: Integer

Alignment for renderScaledAndAlignedSVG: center the content on the axis this value is given for. Any alignment value other than ALIGN_LEFT, ALIGN_RIGHT, ALIGN_TOP and ALIGN_BOTTOM centers as well.

ALIGN_LEFT :: Integer

Horizontal alignment for renderScaledAndAlignedSVG: put the content against the left edge.

ALIGN_RIGHT :: Integer

Horizontal alignment for renderScaledAndAlignedSVG: put the content against the right edge.

ALIGN_TOP :: Integer

Vertical alignment for renderScaledAndAlignedSVG: put the content against the top edge.

copyPaste :: ICanvasContext -> ICanvasContext -> [Resource] -> <Proc> Boolean
copyPaste sourceContext targetContext elements

Selects the diagram elements of the given resources in sourceContext, copies them and pastes them into targetContext, then waits until the source context has processed its event queue. Fails if the source diagram has no element for one of the resources. The result is always True.

createAffineTransform :: Double -> Double -> Double -> Double -> Double -> Double -> AffineTransform
createAffineTransform xx xy yx yy tx ty

Creates the affine transform

[xx yx | tx]
[xy yy | ty]

The argument order is the same as that of Position in Simantics/Diagram.

createG2DNodeModification :: [SVGNodeAssignment] -> [TransformationAssignment] -> G2DNodeModification
createG2DNodeModification svgAssignments transformAssignments

Creates a node modification whose SVG assignments are applied to every SVG node of the element and whose transform assignments are applied to the sub-elements they name.

createG2DNodeModification3 :: [SVGNodeAssignment] -> [TargetedSVGNodeAssignment] -> [TransformationAssignment] -> G2DNodeModification
createG2DNodeModification3 svgAssignments targetedSVGAssignments transformAssignments

As createG2DNodeModification, but takes in addition SVG assignments that are applied only to the SVG nodes of the sub-element each of them names.

createSVGNodeAssignment :: String -> String -> String -> SVGNodeAssignment
createSVGNodeAssignment elementId attributeNameOrId value

Creates an assignment that sets the attribute attributeNameOrId of the SVG element whose id is elementId to value. A leading # in attributeNameOrId is dropped. The special name $text replaces the text content of the element instead when it is a tspan, substituting - for a blank value. An assignment whose element is not in the document is ignored.

createTargetedSVGNodeAssignment :: a -> String -> String -> String -> TargetedSVGNodeAssignment
createTargetedSVGNodeAssignment singleElementKey elementId attributeNameOrId value

As createSVGNodeAssignment, but the assignment is applied only to the SVG nodes below the single element node whose key is singleElementKey.

createTransformationAssignment :: a -> AffineTransform -> TransformationAssignment
createTransformationAssignment key transform

Creates an assignment that sets the transform of the first child of the single element node whose key is key to transform. The transform replaces the transform already on that node, it is not composed with it.

disposeCanvasContext :: ICanvasContext -> <Proc> ()

Disposes the canvas context and releases the resources it holds. The context must not be used afterwards.

disposeSceneGraphProvider :: ICanvasSceneGraphProvider -> <Proc> ()

Disposes a scene graph provider and the scene graph it owns. Deprecated together with getICanvasSceneGraphProvider; the doWith functions dispose the provider for you.

doWithCanvasContext :: Resource -> (ICanvasContext -> <b> a) -> <Proc,Exception> a
doWithCanvasContext diagram f

As doWithICanvasSceneGraphProvider, but applies f to the canvas context into which the scene graph was loaded.

doWithICanvasSceneGraphProvider :: Resource -> (ICanvasSceneGraphProvider -> <b> a) -> <Proc,Exception> a
doWithICanvasSceneGraphProvider diagram f

Loads the scene graph of the given diagram resource and applies f to the provider that owns it. The index root and the RVI of the diagram are resolved in a read transaction of their own. The provider is disposed when f returns or fails.

editNodeText :: ICanvasContext -> String -> String -> String -> <Proc> String
editNodeText context module previousValue newValue

Finds the text node whose text is exactly module, then among the text nodes under the same parent the one whose text is exactly previousValue, and replaces its text with newValue as if the user had edited it in place. Returns a message telling which of the three cases occurred: the text was replaced, the module node was found but no value node under it matched, or no node matched module at all.

getAllNodes :: ICanvasContext -> String

Returns a string of the form All nodes: N, where N is the number of scene graph root nodes reachable from the root of the scene graph plus one. A canvas context has exactly one scene graph, so N is 2. Use getCount for the number of nodes the scene graph actually contains.

getBackgroundColor :: ICanvasContext -> Maybe [Integer]

Returns the background color of the canvas context as the four element list [red, green, blue, alpha] with components between 0 and 255, or Nothing if the context does not set a background color.

getBackgroundNodes :: ICanvasContext -> String

Returns a string of the form BackgroundNodes: N, where N is the number of nodes that paint the diagram background in the scene graph of the context.

getBoundsNodes :: ICanvasContext -> String

Returns a string of the form BoundsNodes: N, where N is the number of control bounds nodes in the scene graph of the context.

getCanvasContext :: ICanvasSceneGraphProvider -> ICanvasContext

Returns the canvas context into which the provider loaded the scene graph.

getConnectionNodes :: ICanvasContext -> String

Returns a string of the form ConnectionNodes: N, where N is the number of connection nodes in the scene graph of the context.

getCount :: ICanvasContext -> String

Returns a string of the form Node count: N, where N is the total number of nodes in the scene graph of the context, the root included.

getDataNodes :: ICanvasContext -> String

Returns a string of the form DataNodes: N, where N is the number of data nodes, which hold shared data inside the scene graph and render nothing, in the scene graph of the context.

getDecorationNodes :: ICanvasContext -> String

Returns a string of the form DecorationNodes: N, where N is the number of SVG decoration nodes, the ones diagram profiles add on top of elements, in the scene graph of the context.

getDiagramContext :: ICanvasSceneGraphProvider -> ICanvasContext

Returns the canvas context of a scene graph provider. Same as getCanvasContext.

getICanvasSceneGraphProvider :: Resource -> Resource -> String -> <Proc> ICanvasSceneGraphProvider
getICanvasSceneGraphProvider model diagram diagramRVI

Loads the scene graph of diagram and returns the provider that owns it. model is the index root the diagram belongs to and diagramRVI locates the diagram below it.

Deprecated because nothing disposes the returned provider. Use doWithICanvasSceneGraphProvider or doWithCanvasContext instead.

getItemNodes :: ICanvasContext -> String

Returns a string of the form ItemNodes: N, where N is the number of trend item nodes in the scene graph of the context.

getNavigationNodes :: ICanvasContext -> String

Returns a string of the form NavigationNodes: N, where N is the number of navigation nodes, which carry the pan and zoom transform of the view, in the scene graph of the context.

getNodeCount :: Resource -> <Proc> String

Loads the scene graph of the given configuration composite and returns its node count as getCount does. The scene graph provider that this loads is never disposed.

getNodeText :: Resource -> String -> <Proc> String
getNodeText diagram nodeName

Loads the scene graph of diagram, which is the configuration composite of a diagram, and returns the text of its text node nodeName as getText does, or the string No node found. The scene graph provider that this loads is never disposed.

getNodeTransform :: Resource -> String -> <Proc> String
getNodeTransform diagram nodeName

Loads the scene graph of diagram, which is the configuration composite of a diagram, and returns the transform of its text node nodeName as getTransform does, or the string No node found. The scene graph provider that this loads is never disposed.

getParentNodes :: ICanvasContext -> String

Returns a string of the form ParentNodes: N, where N is the number of nodes that can have children in the scene graph of the context, the root included.

getSceneGraphProvider :: Resource -> <Proc> ICanvasSceneGraphProvider
getSceneGraphProvider diagram

Loads the scene graph of diagram, which is the configuration composite of a diagram, and returns the provider that owns it. The model is the index root of the composite and the scene graph is loaded for the RVI / followed by the name of the composite, so only diagrams directly under the model are found. Fails if the composite has no index root.

Nothing disposes the returned provider. Prefer doWithICanvasSceneGraphProvider, which does.

getSceneGraphProvider2 :: ICanvasContext -> Resource -> <Proc> ICanvasSceneGraphProvider
getSceneGraphProvider2 context diagram

As getSceneGraphProvider, but loads the scene graph into the given canvas context, for instance one created by workerThreadCanvasContext.

getSingleElementNodes :: ICanvasContext -> String

Returns a string of the form SingleElementNodes: N, where N is the number of single element nodes, one per diagram element, in the scene graph of the context. Connection nodes are single element nodes and are counted here as well.

getText :: ICanvasContext -> String -> String
getText context nodeName

Returns the text of the text node whose name under its parent node is nodeName, or the string No node found if the scene graph has no such text node.

getTextNodes :: ICanvasContext -> String

Returns a string of the form TextNodes: N, where N is the number of text nodes and text grid nodes in the scene graph of the context.

getTransform :: ICanvasContext -> String -> String
getTransform context nodeName

Returns the transform of the text node whose name under its parent node is nodeName, formatted the way Java prints an affine transform, or the string No node found if the scene graph has no such text node. The transform is the one set on the node itself, not the transform accumulated from the root of the scene graph.

inverseTransform :: AffineTransform -> (Double, Double) -> (Double, Double)
inverseTransform t (x, y)

Applies the inverse of the affine transform t to the point (x, y) and returns the transformed point. Fails if t cannot be inverted.

loadSceneGraphProvider :: ICanvasContext -> Resource -> Resource -> String -> <Proc> ICanvasSceneGraphProvider
loadSceneGraphProvider context model diagram diagramRVI

Loads the scene graph of diagram into the scene graph of context and returns the provider that owns it. model is the index root the diagram belongs to and diagramRVI locates the diagram below it. Waits for the scene graph to be fully populated, at most 30 seconds. The caller is responsible for disposing the returned provider.

renderSVG :: ICanvasContext -> <Proc> String

Renders the diagram of the canvas context into an SVG document sized to fit its content and returns the document as a string.

renderScaledAndAlignedSVG :: ICanvasContext -> Double -> Double -> Integer -> Integer -> <Proc> String
renderScaledAndAlignedSVG context width height ax ay

Renders the diagram into an SVG document of width by height pixels, scaling the content to fit and placing it according to ax (ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT) and ay (ALIGN_TOP, ALIGN_CENTER or ALIGN_BOTTOM). Giving -1 for both width and height sizes the document to the content, in which case the alignments are ignored.

renderScaledSVG :: ICanvasContext -> Double -> Double -> <Proc> String

Render an SVG with known width and height in pixels: renderScaledSVG context width height

sceneGraphTest :: ICanvasContext -> String -> String -> <Proc> String
sceneGraphTest context module value

Searches the text nodes of the scene graph for nodes whose text is exactly module and exactly value, and returns a sentence stating which of the two were found. Node counts are printed to standard output on the way.

transform :: AffineTransform -> (Double, Double) -> (Double, Double)
transform t (x, y)

Applies the affine transform t to the point (x, y) and returns the transformed point.

workerThreadCanvasContext :: String -> <Proc> ICanvasContext

Creates a canvas context with an empty scene graph that renders on a new worker thread with the given name. Disposing the context also stops that thread.