Vuo  1.2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
VuoRendererComposition Class Reference

Description

Provides a canvas upon which nodes and cables can be rendered.

Public Types

enum  appExportResult { exportSuccess, exportBuildFailure, exportSaveFailure }
 Potential outcomes of an app export attempt: More...
 

Public Member Functions

 VuoRendererComposition (VuoComposition *baseComposition, bool renderMissingAsPresent=false, bool enableCaching=false)
 Creates a canvas upon which nodes and cables can be rendered.
 
void setBackgroundTransparent (bool transparent)
 Sets whether the composition should be rendered with a transparent background.
 
VuoRendererNodecreateRendererNode (VuoNode *baseNode)
 Creates a renderer detail for the base node.
 
void addNode (VuoNode *node, bool nodeShouldBeRendered=true)
 Adds a node to the underlying composition and (if nodeShouldBeRendered is true), to the canvas.
 
void addCable (VuoCable *cable)
 Adds a cable to the canvas and the underlying composition.
 
void removeNode (VuoRendererNode *rn)
 Removes a node from the canvas and the underlying composition.
 
void removeCable (VuoRendererCable *rc)
 Removes a cable from the canvas and the underlying composition.
 
void createAndConnectInputAttachments (VuoRendererNode *node, VuoCompiler *compiler)
 Creates and connects the appropriate input attachments to the provided node.
 
VuoRendererNodecreateAndConnectMakeListNode (VuoNode *toNode, VuoPort *toPort, VuoCompiler *compiler, VuoRendererCable *&rendererCable)
 Creates a "Make List" node, and creates a cable from the "Make List" node to the given input port.
 
void createAndConnectDictionaryAttachmentsForNode (VuoNode *node, VuoCompiler *compiler, set< VuoRendererNode * > &createdNodes, set< VuoRendererCable * > &createdCables)
 Creates the nodes and connecting cables that the input node will need to provide it with an input dictionary of keys and values, to be attached to the node's "values" input port.
 
vector< string > extractInputVariableListFromExpressionsConstant (string constant, string nodeClassName)
 Extracts the input variables from the provided "inputVariables" constant and returns the variables in an ordered list.
 
void addPublishedPort (VuoPublishedPort *publishedPort, bool isPublishedInput, VuoCompiler *compiler)
 Adds an existing VuoPublishedPort as one of this composition's published ports.
 
int removePublishedPort (VuoPublishedPort *publishedPort, bool isPublishedInput, VuoCompiler *compiler)
 Removes a published input or output VuoRendererPublishedPort from the list of published ports associated with this composition.
 
VuoRendererPublishedPortcreateRendererForPublishedPortInComposition (VuoPublishedPort *publishedPort, bool isPublishedInput)
 Creates a renderer detail for the pre-existing publishedPort, on the assumption that the published port provided already exists in the base composition and has an associated compiler detail.
 
void setPublishedPortName (VuoRendererPublishedPort *publishedPort, string name, VuoCompiler *compiler)
 Sets the name of the provided publishedPort to name; updates the composition's published pseudo-node and connected published cables accordingly.
 
string getUniquePublishedPortName (string baseName)
 Returns a string derived from the input baseName that is guaranteed to be unique among the published input and output port names for this composition.
 
vector< VuoRendererNode * > collapseTypecastNodes (void)
 Once all nodes and cables have been added to the scene, call this to convert each freestanding typecast node into a mini-node attached to its destination node.
 
VuoRendererTypecastPortcollapseTypecastNode (VuoRendererNode *rn)
 Convert a freestanding typecast node into a mini-node attached to its destination node; returns a pointer to the newly collapsed node.
 
void uncollapseTypecastNode (VuoRendererNode *typecastNode)
 Convert the collapsed typecast mini-node associated with the input typecastNode back into freestanding form.
 
VuoRendererNodeuncollapseTypecastNode (VuoRendererTypecastPort *typecast)
 Convert a collapsed typecast mini-node back into a freestanding node.
 
void clearInternalPortEligibilityHighlighting (void)
 Removes connection eligibility highlighting from all ports in the scene.
 
VuoNodegetPublishedInputNode (void)
 Returns the published input node associated with this composition.
 
VuoNodegetPublishedOutputNode (void)
 Returns the published output node associated with this composition.
 
bool getRenderActivity (void)
 Returns the boolean indicating whether recent activity (e.g., node executions, event firings) by components within this composition should be reflected in the rendering of the composition.
 
bool getRenderHiddenCables (void)
 Returns a boolean indicating whether hidden cables within this composition are currently displayed.
 
void setRenderHiddenCables (bool render)
 Sets the boolean indicating whether hidden cables within this composition are currently displayed.
 
QGraphicsItem::CacheMode getCurrentDefaultCacheMode ()
 Returns the current default cache mode for components of this composition, dependent on whether caching is enabled for this composition in general and on whether running composition activity is currently being reflected in the composition rendering.
 
map< VuoPort *, string > getResourcePathsRelativeToDir (QDir newDir)
 Maps all relative resource paths referenced within this composition's port constants to the corresponding paths appropriate for use after the composition has been relocated to newDir.
 
void bundleResourceFiles (string targetResourceDir, bool tmpFilesOnly=false)
 Copies resources referenced within the composition by relative URL into the provided targetResourceDir.
 
string takeSnapshot (void)
 Returns a string representation of the composition (to save its current state).
 
VuoRendererComposition::appExportResult exportApp (const QString &savePath, VuoCompiler *compiler, string &errString, VuoCompilerDriver *driver=NULL)
 Exports the composition as an OS X .app bundle.
 
- Public Member Functions inherited from VuoBaseDetail< VuoComposition >
 VuoBaseDetail (string description, VuoComposition *base)
 Creates a VuoComposition detail class.
 
VuoCompositiongetBase (void) const
 Returns the VuoComposition detail class instance's base class instance.
 
void setBase (VuoComposition *base)
 Sets the VuoComposition detail class instance's base class instance.
 

Static Public Member Functions

static bool isTmpFile (string filePath)
 Returns a boolean indicating whether the provided filePath is within the /tmp directory (or a subdirectory thereof).
 
static void setGridLineOpacity (int opacity)
 Specifies the opacity at which grid lines should be rendered on the canvas.
 
static int getGridLineOpacity ()
 Returns the opacity at which grid lines should be rendered on the canvas.
 
static QPoint quantizeToNearestGridLine (QPointF point, int gridSpacing)
 Quantizes the provided point to the nearest horizontal and vertical gridlines with the gridSpacing specified.
 
static string getDefaultCompositionDescription ()
 Returns the default composition description.
 
static void createAutoreleasePool (void)
 As a workaround for a bug in Qt 5.1.0-beta1 (https://b33p.net/kosada/node/4905), this function must be called to create the NSAutoreleasePool for a QApplication.
 
static bool hasURLType (VuoPort *port)
 Returns a boolean indicating whether the provided port expects a URL as input.
 

Static Public Attributes

static const int majorGridLineSpacing = 4*VuoRendererComposition::minorGridLineSpacing
 Distance, in pixels at 1:1 zoom, between major gridlines.
 
static const int minorGridLineSpacing = VuoRendererPort::portSpacing
 Distance, in pixels at 1:1 zoom, between minor gridlines.
 

Protected Member Functions

void drawBackground (QPainter *painter, const QRectF &rect)
 Draws the background of the scene using painter, before any items and the foreground are drawn.
 
void setRenderActivity (bool render)
 Sets the boolean indicating whether recent activity by components within this composition should be reflected in the rendering of the composition; if toggling from 'false' to 'true', resets the time of last activity for each component.
 
void setComponentCaching (QGraphicsItem::CacheMode)
 Sets the caching mode for each applicable graphics item within the composition to the provided cache mode.
 
void updateGeometryForAllComponents ()
 Prepares every component in the composition to be repainted.
 
bool isPortPublished (VuoRendererPort *port)
 Returns true if the internal port is connected to a published port.
 

Static Protected Member Functions

static bool isSupportedAudioFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported audio file.
 
static bool isSupportedImageFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported image file.
 
static bool isSupportedMeshFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported mesh file.
 
static bool isSupportedMovieFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported movie file.
 
static bool isSupportedSceneFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported scene file.
 
static bool isSupportedFeedFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported feed file.
 
static bool isSupportedDataFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported data file.
 
static bool isSupportedAppFile (string path)
 Returns a boolean indicating whether the file at the provided path is a supported app file.
 

Protected Attributes

VuoCompilerGraphvizParserparser
 The Graphviz parser instance used by this composition.
 
VuoRendererSignalersignaler
 The Qt signaler used by this composition.
 
VuoNodepublishedInputNode
 The published input node associated with this composition.
 
VuoNodepublishedOutputNode
 The published output node associated with this composition.
 
bool cachingEnabled
 Should item renderings be cached?
 
bool renderHiddenCables
 Should cables be rendered even if they have been hidden (made "wireless")?
 

Member Enumeration Documentation

Potential outcomes of an app export attempt:

Constructor & Destructor Documentation

VuoRendererComposition::VuoRendererComposition ( VuoComposition baseComposition,
bool  renderMissingAsPresent = false,
bool  enableCaching = false 
)

Creates a canvas upon which nodes and cables can be rendered.

The canvas initially contains the nodes, cables, and published ports in the base composition.

Parameters
baseCompositionThe VuoComposition to which the new VuoRendererComposition detail class should be attached.
renderMissingAsPresentSets whether node classes without implementations should be rendered as though their implementations are present. (Useful for prototyping node classes.)
enableCachingSets whether item renderings should be cached.

Member Function Documentation

void VuoRendererComposition::addCable ( VuoCable c)

Adds a cable to the canvas and the underlying composition.

If the cable doesn't have a renderer detail, one is created for it.

void VuoRendererComposition::addNode ( VuoNode n,
bool  nodeShouldBeRendered = true 
)

Adds a node to the underlying composition and (if nodeShouldBeRendered is true), to the canvas.

If the node is to be added to the canvas and doesn't have a renderer detail, one is created for it.

If a node with the same graphviz identifier as this node is already in the composition, changes the graphviz identifier of this node to be unique.

void VuoRendererComposition::addPublishedPort ( VuoPublishedPort publishedPort,
bool  isPublishedInput,
VuoCompiler compiler 
)

Adds an existing VuoPublishedPort as one of this composition's published ports.

void VuoRendererComposition::bundleResourceFiles ( string  targetResourceDir,
bool  tmpFilesOnly = false 
)

Copies resources referenced within the composition by relative URL into the provided targetResourceDir.

If tmpFilesOnly is true, bundles only files that are originally located within the /tmp directory or one of its subdirectories and ignores all others.

Helper function for VuoRendererComposition::exportApp(const QString &savePath) and VuoEditorWindow::on_saveCompositionAs_triggered().

void VuoRendererComposition::clearInternalPortEligibilityHighlighting ( void  )

Removes connection eligibility highlighting from all ports in the scene.

VuoRendererTypecastPort * VuoRendererComposition::collapseTypecastNode ( VuoRendererNode rn)

Convert a freestanding typecast node into a mini-node attached to its destination node; returns a pointer to the newly collapsed node.

vector< VuoRendererNode * > VuoRendererComposition::collapseTypecastNodes ( void  )

Once all nodes and cables have been added to the scene, call this to convert each freestanding typecast node into a mini-node attached to its destination node.

Returns a vector of pointers to the newly collapsed nodes.

void VuoRendererComposition::createAndConnectDictionaryAttachmentsForNode ( VuoNode node,
VuoCompiler compiler,
set< VuoRendererNode * > &  createdNodes,
set< VuoRendererCable * > &  createdCables 
)

Creates the nodes and connecting cables that the input node will need to provide it with an input dictionary of keys and values, to be attached to the node's "values" input port.

Parameters
nodeThe node that needs the dictionary attachments created.
compilerA compiler used to get the attachment node classes.
[out]createdNodesThe created nodes.
[out]createdCablesThe created cables.
void VuoRendererComposition::createAndConnectInputAttachments ( VuoRendererNode node,
VuoCompiler compiler 
)

Creates and connects the appropriate input attachments to the provided node.

VuoRendererNode * VuoRendererComposition::createAndConnectMakeListNode ( VuoNode toNode,
VuoPort toPort,
VuoCompiler compiler,
VuoRendererCable *&  rendererCable 
)

Creates a "Make List" node, and creates a cable from the "Make List" node to the given input port.

Parameters
toNodeThe node that contains toPort.
toPortThe input port. Assumed to be a data-and-event input port carrying list data.
compilerA compiler used to get the "Make List" node class.
[out]rendererCableThe created cable.
Returns
The created "Make List" node.
void VuoRendererComposition::createAutoreleasePool ( void  )
static

As a workaround for a bug in Qt 5.1.0-beta1 (https://b33p.net/kosada/node/4905), this function must be called to create the NSAutoreleasePool for a QApplication.

VuoRendererPublishedPort * VuoRendererComposition::createRendererForPublishedPortInComposition ( VuoPublishedPort publishedPort,
bool  isPublishedInput 
)

Creates a renderer detail for the pre-existing publishedPort, on the assumption that the published port provided already exists in the base composition and has an associated compiler detail.

VuoRendererNode * VuoRendererComposition::createRendererNode ( VuoNode baseNode)

Creates a renderer detail for the base node.

void VuoRendererComposition::drawBackground ( QPainter *  painter,
const QRectF &  rect 
)
protected

Draws the background of the scene using painter, before any items and the foreground are drawn.

Reimplementation of QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect).

VuoRendererComposition::appExportResult VuoRendererComposition::exportApp ( const QString &  savePath,
VuoCompiler compiler,
string &  errString,
VuoCompilerDriver driver = NULL 
)

Exports the composition as an OS X .app bundle.

Parameters
[in]savePathThe path where the .app is to be saved.
[in]compilerThe compiler to be used to generate the composition executable.
[out]errStringThe error message resulting from the export process, if any.
[in]driverThe protocol driver that should be applied to the exported composition. May be NULL.
Returns
An appExportResult value detailing the outcome of the export attempt.
vector< string > VuoRendererComposition::extractInputVariableListFromExpressionsConstant ( string  constant,
string  nodeClassName 
)

Extracts the input variables from the provided "inputVariables" constant and returns the variables in an ordered list.

Excludes variables that shouldn't be presented in the UI ("x" in the Calculate List node).

QGraphicsItem::CacheMode VuoRendererComposition::getCurrentDefaultCacheMode ( )

Returns the current default cache mode for components of this composition, dependent on whether caching is enabled for this composition in general and on whether running composition activity is currently being reflected in the composition rendering.

string VuoRendererComposition::getDefaultCompositionDescription ( )
static

Returns the default composition description.

int VuoRendererComposition::getGridLineOpacity ( )
static

Returns the opacity at which grid lines should be rendered on the canvas.

VuoNode * VuoRendererComposition::getPublishedInputNode ( void  )

Returns the published input node associated with this composition.

VuoNode * VuoRendererComposition::getPublishedOutputNode ( void  )

Returns the published output node associated with this composition.

bool VuoRendererComposition::getRenderActivity ( void  )

Returns the boolean indicating whether recent activity (e.g., node executions, event firings) by components within this composition should be reflected in the rendering of the composition.

bool VuoRendererComposition::getRenderHiddenCables ( void  )

Returns a boolean indicating whether hidden cables within this composition are currently displayed.

map< VuoPort *, string > VuoRendererComposition::getResourcePathsRelativeToDir ( QDir  newDir)

Maps all relative resource paths referenced within this composition's port constants to the corresponding paths appropriate for use after the composition has been relocated to newDir.

string VuoRendererComposition::getUniquePublishedPortName ( string  baseName)

Returns a string derived from the input baseName that is guaranteed to be unique among the published input and output port names for this composition.

bool VuoRendererComposition::hasURLType ( VuoPort port)
static

Returns a boolean indicating whether the provided port expects a URL as input.

Todo:
https://b33p.net/kosada/node/9204 Just check whether it has a VuoUrl type. For now, use hard-coded rules.

Helper function for VuoRendererComposition::hasRelativeReadURLConstantValue(VuoPort *port).

bool VuoRendererComposition::isPortPublished ( VuoRendererPort port)
protected

Returns true if the internal port is connected to a published port.

bool VuoRendererComposition::isSupportedAppFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported app file.

bool VuoRendererComposition::isSupportedAudioFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported audio file.

bool VuoRendererComposition::isSupportedDataFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported data file.

bool VuoRendererComposition::isSupportedFeedFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported feed file.

bool VuoRendererComposition::isSupportedImageFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported image file.

bool VuoRendererComposition::isSupportedMeshFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported mesh file.

bool VuoRendererComposition::isSupportedMovieFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported movie file.

bool VuoRendererComposition::isSupportedSceneFile ( string  path)
staticprotected

Returns a boolean indicating whether the file at the provided path is a supported scene file.

bool VuoRendererComposition::isTmpFile ( string  filePath)
static

Returns a boolean indicating whether the provided filePath is within the /tmp directory (or a subdirectory thereof).

QPoint VuoRendererComposition::quantizeToNearestGridLine ( QPointF  point,
int  gridSpacing 
)
static

Quantizes the provided point to the nearest horizontal and vertical gridlines with the gridSpacing specified.

void VuoRendererComposition::removeCable ( VuoRendererCable rc)

Removes a cable from the canvas and the underlying composition.

void VuoRendererComposition::removeNode ( VuoRendererNode rn)

Removes a node from the canvas and the underlying composition.

int VuoRendererComposition::removePublishedPort ( VuoPublishedPort publishedPort,
bool  isPublishedInput,
VuoCompiler compiler 
)

Removes a published input or output VuoRendererPublishedPort from the list of published ports associated with this composition.

Returns
The index within the list of published input port output ports at which the port was located, or -1 if not located.
void VuoRendererComposition::setBackgroundTransparent ( bool  transparent)

Sets whether the composition should be rendered with a transparent background.

void VuoRendererComposition::setComponentCaching ( QGraphicsItem::CacheMode  cacheMode)
protected

Sets the caching mode for each applicable graphics item within the composition to the provided cache mode.

void VuoRendererComposition::setGridLineOpacity ( int  opacity)
static

Specifies the opacity at which grid lines should be rendered on the canvas.

void VuoRendererComposition::setPublishedPortName ( VuoRendererPublishedPort publishedPort,
string  name,
VuoCompiler compiler 
)

Sets the name of the provided publishedPort to name; updates the composition's published pseudo-node and connected published cables accordingly.

void VuoRendererComposition::setRenderActivity ( bool  render)
protected

Sets the boolean indicating whether recent activity by components within this composition should be reflected in the rendering of the composition; if toggling from 'false' to 'true', resets the time of last activity for each component.

void VuoRendererComposition::setRenderHiddenCables ( bool  render)

Sets the boolean indicating whether hidden cables within this composition are currently displayed.

string VuoRendererComposition::takeSnapshot ( void  )

Returns a string representation of the composition (to save its current state).

void VuoRendererComposition::uncollapseTypecastNode ( VuoRendererNode typecastNode)

Convert the collapsed typecast mini-node associated with the input typecastNode back into freestanding form.

VuoRendererNode * VuoRendererComposition::uncollapseTypecastNode ( VuoRendererTypecastPort typecast)

Convert a collapsed typecast mini-node back into a freestanding node.

void VuoRendererComposition::updateGeometryForAllComponents ( )
protected

Prepares every component in the composition to be repainted.

Member Data Documentation

bool VuoRendererComposition::cachingEnabled
protected

Should item renderings be cached?

const int VuoRendererComposition::majorGridLineSpacing = 4*VuoRendererComposition::minorGridLineSpacing
static

Distance, in pixels at 1:1 zoom, between major gridlines.

const int VuoRendererComposition::minorGridLineSpacing = VuoRendererPort::portSpacing
static

Distance, in pixels at 1:1 zoom, between minor gridlines.

VuoCompilerGraphvizParser* VuoRendererComposition::parser
protected

The Graphviz parser instance used by this composition.

VuoNode* VuoRendererComposition::publishedInputNode
protected

The published input node associated with this composition.

VuoNode* VuoRendererComposition::publishedOutputNode
protected

The published output node associated with this composition.

bool VuoRendererComposition::renderHiddenCables
protected

Should cables be rendered even if they have been hidden (made "wireless")?

VuoRendererSignaler* VuoRendererComposition::signaler
protected

The Qt signaler used by this composition.


The documentation for this class was generated from the following files: