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

Description

Renders a node's port in a QGraphicsScene.

Typically automatically created by a VuoRendererNode instance.

Public Member Functions

 VuoRendererPort (VuoPort *basePort, VuoRendererSignaler *signaler, bool isOutput, bool isRefreshPort, bool isDonePort, bool isFunctionPort)
 Creates a renderer detail for the specified base port.
 
QRectF boundingRect (void) const
 Returns the bounding rectangle of this port (and its optional name and plug).
 
QPainterPath shape (void) const
 Returns the shape of the rendered port, for use in collision detection, hit tests, and QGraphicsScene::items() functions.
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 Draws an input or output port (both standard ports and refresh/done/function ports).
 
VuoRendererPublishedPortgetProxyPublishedSidebarPort (void) const
 Returns this port's published port sidebar renderering proxy, or NULL if it has none.
 
void setProxyPublishedSidebarPort (VuoRendererPublishedPort *proxyPort)
 If set, this port will not be drawn; its drawing will be handled by proxySidebarPort.
 
bool getEligibleForSelection ()
 Returns a boolean indicating whether this port has been deemed eligible for selection based on its proximity to the cursor.
 
void setEligibleForDirectConnection (bool eligible)
 Sets the boolean indicating whether this port is eligible for direct connection to the cable currently being dragged between ports.
 
void setEligibleForConnectionViaTypecast (bool eligible)
 Sets the boolean indicating whether this port is eligible for typecast-assisted connection to the cable currently being dragged between ports.
 
void extendedHoverEnterEvent (bool cableDragUnderway=false)
 Handle mouse hover start events generated by custom code making use of an extended hover range.
 
void extendedHoverMoveEvent (bool cableDragUnderway=false)
 Handle mouse hover move events generated by custom code making use of an extended hover range.
 
void extendedHoverLeaveEvent ()
 Handle mouse hover leave events generated by custom code making use of an extended hover range.
 
bool canConnectDirectlyWithoutSpecializationTo (VuoRendererPort *toPort)
 Returns a boolean indicating whether there may be a cable attached directly from this port to toPort, taking into account the respective port types (input vs.
 
bool canConnectDirectlyWithSpecializationTo (VuoRendererPort *toPort)
 Returns a boolean indicating whether there may be a cable attached directly from this port to toPort, taking into account the respective port types (input vs.
 
bool canConnectDirectlyWithSpecializationTo (VuoRendererPort *toPort, VuoRendererPort **portToSpecialize, string &specializedTypeName)
 Returns a boolean indicating whether there may be a cable attached directly from this port to toPort, taking into account the respective port types (input vs.
 
bool isConnectedTo (VuoRendererPort *toPort)
 Returns a boolean indicating whether there is a cable connecting this port to toPort.
 
bool getInput (void) const
 Returns a boolean indicating whether this port is an input port.
 
bool getOutput (void) const
 Returns a boolean indicating whether this port is an output port.
 
bool getRefreshPort (void) const
 Returns true if this port is a refresh port.
 
bool getDonePort (void) const
 Returns true if this port is a done port.
 
bool getFunctionPort (void) const
 Returns true if this port is a function port.
 
void updateGeometry ()
 Schedules a redraw of this port.
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 Updates the port to reflect changes in state.
 
QPainterPath getPortPath (qreal inset) const
 Returns a closed path representing the port's circle/triangle.
 
VuoRendererMakeListNodegetAttachedInputDrawer (void) const
 Returns the collapsed "Make List" node attached to this input port, or NULL if none.
 
virtual QRectF getPortConstantTextRect (void) const
 Returns a rect enclosing the string representation of the port's constant value.
 
VuoTypegetDataType (void) const
 Returns the data type associated with this port, or NULL if there is no associated data type.
 
bool isConstant (void) const
 Returns true if this port has a constant data value.
 
string getConstantAsString (void) const
 Returns the string representation of this port's constant data value, or an empty string if it has none.
 
string getConstantAsStringToRender (void) const
 Returns the string representation of this port's constant data value as it should be rendered in its constant data flag, or an empty string if it has no currently assigned constant data value.
 
void setConstant (string constantValue)
 Sets this port's constant data value to that represented by the provided constantValue string.
 
VuoRendererPublishedPortgetPublishedPort () const
 Returns a pointer to the VuoRendererPublishedPort associated with this port, or NULL if this port is not currently published.
 
VuoRendererNodegetUnderlyingParentNode (void) const
 Returns a pointer to the node to which this port belongs in the underlying Graphviz (.dot/.vuo) representation of the composition.
 
VuoRendererNodegetRenderedParentNode (void) const
 Returns a pointer to the node currently rendered as this port's parent.
 
VuoRendererPortgetTypecastParentPort () const
 Returns this port's typecast parent port, or NULL if it has none.
 
void setTypecastParentPort (VuoRendererPort *typecastParentPort)
 Sets this port's typecast parent port.
 
bool supportsDisconnectionByDragging (void)
 Returns a boolean indicating whether this port supports cable disconnection by dragging from the port.
 
void resetTimeLastEventFired ()
 Resets the time that the last event was fired to a value that causes the port to be painted as if activity-rendering were disabled.
 
void setFiredEvent ()
 Updates the port's state to indicate that it has just fired an event.
 
void setFadePercentageSinceEventFired (qreal percentage)
 Updates the port's state to indicate that it fired an event at such a time that its fade percentage should now be equal to percentage.
 
void setCacheModeForPortAndChildren (QGraphicsItem::CacheMode mode)
 Sets the cache mode of this port, and any child ports, to mode.
 
vector< QGraphicsItemAnimation * > getAnimations ()
 Returns the 'Show Events'-mode animations associated with this port.
 
void setAnimated (bool animated)
 Sets the boolean indicating whether this port is an animation, and not itself a component of the base composition.
 
- Public Member Functions inherited from VuoBaseDetail< VuoPort >
 VuoBaseDetail (string description, VuoPort *base)
 Creates a VuoNode detail class.
 
VuoPortgetBase (void) const
 Returns the VuoNode detail class instance's base class instance.
 
void setBase (VuoPort *base)
 Sets the VuoNode detail class instance's base class instance.
 

Static Public Member Functions

static QPainterPath getPortConstantPath (QRectF innerPortRect, QString text, QPainterPath *outsetPath, bool isTypecast=false)
 Returns a path representing the frame of a port constant.
 
static QRectF getPortRect (void)
 Returns a rectangle encompassing the port's circle.
 
- Static Public Member Functions inherited from VuoRendererItem
static void setDrawBoundingRects (bool drawBoundingRects)
 Specifies whether bounding rects will be shown the next time the QGraphicsScene is rendered.
 
static void drawRect (QPainter *painter, QRectF rect)
 Draws a rect, for debugging.
 

Static Public Attributes

static const qreal portRadius = VuoRendererFonts::thickPenWidth*0.3625
 Radius, in pixels at 1:1 zoom, of a circular port.
 
static const qreal portSpacing = VuoRendererFonts::thickPenWidth*3.0/4.0
 Vertical distance, in pixels at 1:1 zoom, between the center points of two ports.
 
static const qreal portContainerMargin = VuoRendererFonts::thickPenWidth / 6.
 Vertical distance, in pixels at 1:1 zoom, between the outer edge of the first/last port and the node frame rect.
 
static const qreal portInset = 1
 The vertical and horizontal inset used when rendering a port shape within its outer port rect.
 
static const qreal constantFlagHeight = VuoRendererFonts::thickPenWidth*0.6
 Height, in pixels at 1:1 zoom, of a constant flag.
 

Protected Member Functions

void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 Handle mouse double-click events.
 
void keyPressEvent (QKeyEvent *event)
 Handle key-press events.
 
void paintWithOptions (QPainter *painter, bool sidebarPaintMode)
 Draws an input or output port, with customized options: If sidebarPaintMode is true, paints the port for display within the "Published Port" sidebar.
 
QRectF boundingRectWithOptions (bool sidebarPaintMode) const
 Returns the bounding rectangle of this port, with customized options: If sidebarPaintMode is true, returns the bounding rect of the port for display within the "Published Port" sidebar.
 
bool portNameRenderingEnabled (bool sidebarPaintMode) const
 Returns a boolean indicating whether the port name should be rendered along with this port, taking into account the port's own attributes as well as whether the port will be rendered within a published port sidebar, as indicated by sidebarPaintMode.
 
QRectF getNameRect (bool sidebarPaintMode=false) const
 Returns the cached bounding box of the port's label.
 
void updateNameRect (bool sidebarPaintMode)
 Updates the cached bounding box of the port's label.
 
bool isOnDrawer (void) const
 Returns true if this port is part of a drawer (a collapsed Make List node).
 
void updateEnabledStatus ()
 Determines whether this port will accept mouse events based on the port's current attributes.
 
QPainterPath getFunctionPortGlyph (void) const
 Returns a path representing the glyph for function ports.
 
void paintPortName (QPainter *painter, VuoRendererColors *colors, bool sidebarPaintMode)
 Paints the port's label.
 
void paintEventBarrier (QPainter *painter, VuoRendererColors *colors, bool sidebarPaintMode)
 Paints the port's event wall or door.
 
string getPointStringForCoords (QList< double >) const
 Given a list of coordinates, returns the string representation of the point consisting of those coordinate values as it should be rendered within a constant data flag.
 
- Protected Member Functions inherited from VuoRendererItem
void drawBoundingRect (QPainter *painter)
 Draws this item's bounding rect, for debugging.
 
bool getRenderActivity ()
 Retrieves the composition-wide boolean indicating whether recent activity (e.g., a node execution or event firing) by this item should be reflected in its rendering.
 
QGraphicsItem::CacheMode getCurrentDefaultCacheMode ()
 Returns the current default cache mode for components of this composition.
 

Static Protected Member Functions

static QRectF getPortConstantTextRectForText (QString text)
 Returns a rect enclosing the specified text.
 
- Static Protected Member Functions inherited from VuoRendererItem
static void addRoundedCorner (QPainterPath &path, bool drawLine, QPointF sharpCornerPoint, qreal radius, bool isTop, bool isLeft)
 Appends a line (or move) and curve to path, to produce a clockwise-wound rounded corner near sharpCornerPoint.
 

Protected Attributes

bool isRefreshPort
 Is this port a refresh port?
 
bool isDonePort
 Is this port a done port?
 
QRectF nameRect
 The bounding box of the port's label when rendered on the canvas.
 
QRectF nameRectForSidebarMode
 The bounding box of the port's label when rendered in the "Published Port" sidebar.
 
VuoRendererSignalersignaler
 The Qt signaler used by this port.
 

Friends

class VuoRendererPublishedPort
 VuoRendererPublishedPort needs paintWithOptions(...) and boundingRectWithOptions(...)
 
class TestVuoRenderer
 

Additional Inherited Members

- Public Types inherited from VuoRendererItem
enum  activityState { notTrackingActivity = -1, activityInProgress = 0 }
 Special composition component activity states. More...
 

Constructor & Destructor Documentation

VuoRendererPort::VuoRendererPort ( VuoPort basePort,
VuoRendererSignaler signaler,
bool  isOutput,
bool  isRefreshPort,
bool  isDonePort,
bool  isFunctionPort 
)

Creates a renderer detail for the specified base port.

Member Function Documentation

QRectF VuoRendererPort::boundingRect ( void  ) const

Returns the bounding rectangle of this port (and its optional name and plug).

QRectF VuoRendererPort::boundingRectWithOptions ( bool  sidebarPaintMode) const
protected

Returns the bounding rectangle of this port, with customized options: If sidebarPaintMode is true, returns the bounding rect of the port for display within the "Published Port" sidebar.

Otherwise, returns the bounding rect of the port for display on the canvas.

bool VuoRendererPort::canConnectDirectlyWithoutSpecializationTo ( VuoRendererPort toPort)

Returns a boolean indicating whether there may be a cable attached directly from this port to toPort, taking into account the respective port types (input vs.

output; event-only vs. event+data; respective data types).

If the connection would require one or both ports to be specialized, returns false. (But see VuoRendererPort::canConnectDirectlyWithSpecializationTo(...).)

bool VuoRendererPort::canConnectDirectlyWithSpecializationTo ( VuoRendererPort toPort)

Returns a boolean indicating whether there may be a cable attached directly from this port to toPort, taking into account the respective port types (input vs.

output; event-only vs. event+data; respective data types), and the possibility that one port may be specialized in preparation for the connection.

Convenience function for VuoRendererPort::canConnectDirectlyWithSpecializationTo(const VuoRendererPort *toPort, VuoRendererPort **portToSpecialize, string &specializedTypeName), for use when only the returned boolean and none of the other output parameter values are needed.

bool VuoRendererPort::canConnectDirectlyWithSpecializationTo ( VuoRendererPort toPort,
VuoRendererPort **  portToSpecialize,
string &  specializedTypeName 
)

Returns a boolean indicating whether there may be a cable attached directly from this port to toPort, taking into account the respective port types (input vs.

output; event-only vs. event+data; respective data types), and the possibility that one port may be specialized in preparation for the connection.

Parameters
[out]toPortThe port to consider connecting to.
[out]portToSpecializeThe port, either this port or toPort, that will require specialization in order for the connection to be completed. Does not account for potential cascade effects. May be NULL, if the connection may be completed without specialization.
[out]specializedTypeNameThe name of the specialized port type with which the generic port type is to be replaced.
Todo:
(https://b33p.net/kosada/node/7032)
void VuoRendererPort::extendedHoverEnterEvent ( bool  cableDragUnderway = false)

Handle mouse hover start events generated by custom code making use of an extended hover range.

void VuoRendererPort::extendedHoverLeaveEvent ( )

Handle mouse hover leave events generated by custom code making use of an extended hover range.

void VuoRendererPort::extendedHoverMoveEvent ( bool  cableDragUnderway = false)

Handle mouse hover move events generated by custom code making use of an extended hover range.

If the optional highlightOnlyIfConnectable boolean is set to true, enable hover highlighting for this port only if the port is eligible for connection to the cable currently being connected.

vector< QGraphicsItemAnimation * > VuoRendererPort::getAnimations ( )

Returns the 'Show Events'-mode animations associated with this port.

VuoRendererMakeListNode * VuoRendererPort::getAttachedInputDrawer ( void  ) const

Returns the collapsed "Make List" node attached to this input port, or NULL if none.

string VuoRendererPort::getConstantAsString ( void  ) const

Returns the string representation of this port's constant data value, or an empty string if it has none.

string VuoRendererPort::getConstantAsStringToRender ( void  ) const

Returns the string representation of this port's constant data value as it should be rendered in its constant data flag, or an empty string if it has no currently assigned constant data value.

Todo:
Implement with input viewers (https://b33p.net/kosada/node/5700)
VuoType * VuoRendererPort::getDataType ( void  ) const

Returns the data type associated with this port, or NULL if there is no associated data type.

bool VuoRendererPort::getDonePort ( void  ) const

Returns true if this port is a done port.

bool VuoRendererPort::getEligibleForSelection ( )

Returns a boolean indicating whether this port has been deemed eligible for selection based on its proximity to the cursor.

bool VuoRendererPort::getFunctionPort ( void  ) const

Returns true if this port is a function port.

QPainterPath VuoRendererPort::getFunctionPortGlyph ( void  ) const
protected

Returns a path representing the glyph for function ports.

bool VuoRendererPort::getInput ( void  ) const

Returns a boolean indicating whether this port is an input port.

QRectF VuoRendererPort::getNameRect ( bool  sidebarPaintMode = false) const
protected

Returns the cached bounding box of the port's label.

bool VuoRendererPort::getOutput ( void  ) const

Returns a boolean indicating whether this port is an output port.

string VuoRendererPort::getPointStringForCoords ( QList< double >  coordList) const
protected

Given a list of coordinates, returns the string representation of the point consisting of those coordinate values as it should be rendered within a constant data flag.

Helper function for VuoRendererPort::getConstantAsStringToRender().

QPainterPath VuoRendererPort::getPortConstantPath ( QRectF  innerPortRect,
QString  text,
QPainterPath *  outsetPath,
bool  isTypecast = false 
)
static

Returns a path representing the frame of a port constant.

If outsetPath is not NULL, it is given a path that can be stroked with a pen of width 1 without overlapping the returned path.

QRectF VuoRendererPort::getPortConstantTextRect ( void  ) const
virtual

Returns a rect enclosing the string representation of the port's constant value.

If the port does not have a constant value, returns a null rect.

Reimplemented in VuoRendererTypecastPort.

QRectF VuoRendererPort::getPortConstantTextRectForText ( QString  text)
staticprotected

Returns a rect enclosing the specified text.

QPainterPath VuoRendererPort::getPortPath ( qreal  inset) const

Returns a closed path representing the port's circle/triangle.

Does not include constant flag (see getPortConstantPath).

QRectF VuoRendererPort::getPortRect ( void  )
static

Returns a rectangle encompassing the port's circle.

VuoRendererPublishedPort * VuoRendererPort::getProxyPublishedSidebarPort ( void  ) const

Returns this port's published port sidebar renderering proxy, or NULL if it has none.

VuoRendererPublishedPort * VuoRendererPort::getPublishedPort ( void  ) const

Returns a pointer to the VuoRendererPublishedPort associated with this port, or NULL if this port is not currently published.

Assumption: A given internal port will have at most one externally visible published port aliased to it.

Todo:
Is there a way to avoid accessing the VuoRendererComposition like this?
Todo:
Handle an output port connected to multiple published output ports.
bool VuoRendererPort::getRefreshPort ( void  ) const

Returns true if this port is a refresh port.

VuoRendererNode * VuoRendererPort::getRenderedParentNode ( void  ) const

Returns a pointer to the node currently rendered as this port's parent.

For ports belonging to typecast nodes, this value will change depending whether the typecast is currently free-standing (in which case that is the node that will be returned) or collapsed (in which case the downstream node to which the typecast is attached is the one that will be returned).

VuoRendererPort * VuoRendererPort::getTypecastParentPort ( ) const

Returns this port's typecast parent port, or NULL if it has none.

VuoRendererNode * VuoRendererPort::getUnderlyingParentNode ( void  ) const

Returns a pointer to the node to which this port belongs in the underlying Graphviz (.dot/.vuo) representation of the composition.

For a given port, this value will never change. For typecast ports, this method will always return the original parent typecast node, regardless of whether the typecast is currently free-standing or collapsed.

bool VuoRendererPort::isConnectedTo ( VuoRendererPort toPort)

Returns a boolean indicating whether there is a cable connecting this port to toPort.

bool VuoRendererPort::isConstant ( void  ) const

Returns true if this port has a constant data value.

bool VuoRendererPort::isOnDrawer ( void  ) const
protected

Returns true if this port is part of a drawer (a collapsed Make List node).

QVariant VuoRendererPort::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)

Updates the port to reflect changes in state.

void VuoRendererPort::keyPressEvent ( QKeyEvent *  event)
protected

Handle key-press events.

void VuoRendererPort::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  event)
protected

Handle mouse double-click events.

void VuoRendererPort::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)

Draws an input or output port (both standard ports and refresh/done/function ports).

void VuoRendererPort::paintEventBarrier ( QPainter *  painter,
VuoRendererColors colors,
bool  sidebarPaintMode 
)
protected

Paints the port's event wall or door.

void VuoRendererPort::paintPortName ( QPainter *  painter,
VuoRendererColors colors,
bool  sidebarPaintMode 
)
protected

Paints the port's label.

void VuoRendererPort::paintWithOptions ( QPainter *  painter,
bool  sidebarPaintMode 
)
protected

Draws an input or output port, with customized options: If sidebarPaintMode is true, paints the port for display within the "Published Port" sidebar.

Otherwise, paints the port for display on the canvas.

Todo:
Implement with input viewers (https://b33p.net/kosada/node/5700)
bool VuoRendererPort::portNameRenderingEnabled ( bool  sidebarPaintMode) const
protected

Returns a boolean indicating whether the port name should be rendered along with this port, taking into account the port's own attributes as well as whether the port will be rendered within a published port sidebar, as indicated by sidebarPaintMode.

void VuoRendererPort::resetTimeLastEventFired ( )

Resets the time that the last event was fired to a value that causes the port to be painted as if activity-rendering were disabled.

void VuoRendererPort::setAnimated ( bool  animated)

Sets the boolean indicating whether this port is an animation, and not itself a component of the base composition.

void VuoRendererPort::setCacheModeForPortAndChildren ( QGraphicsItem::CacheMode  mode)

Sets the cache mode of this port, and any child ports, to mode.

void VuoRendererPort::setConstant ( string  constantValue)

Sets this port's constant data value to that represented by the provided constantValue string.

void VuoRendererPort::setEligibleForConnectionViaTypecast ( bool  eligible)

Sets the boolean indicating whether this port is eligible for typecast-assisted connection to the cable currently being dragged between ports.

void VuoRendererPort::setEligibleForDirectConnection ( bool  eligible)

Sets the boolean indicating whether this port is eligible for direct connection to the cable currently being dragged between ports.

void VuoRendererPort::setFadePercentageSinceEventFired ( qreal  percentage)

Updates the port's state to indicate that it fired an event at such a time that its fade percentage should now be equal to percentage.

void VuoRendererPort::setFiredEvent ( )

Updates the port's state to indicate that it has just fired an event.

void VuoRendererPort::setProxyPublishedSidebarPort ( VuoRendererPublishedPort proxySidebarPort)

If set, this port will not be drawn; its drawing will be handled by proxySidebarPort.

Used for ports belonging to "vuo.in" or "vuo.out" nodes, to be rendered within the published port sidebars rather than on the canvas.

void VuoRendererPort::setTypecastParentPort ( VuoRendererPort typecastParentPort)

Sets this port's typecast parent port.

QPainterPath VuoRendererPort::shape ( void  ) const

Returns the shape of the rendered port, for use in collision detection, hit tests, and QGraphicsScene::items() functions.

bool VuoRendererPort::supportsDisconnectionByDragging ( void  )

Returns a boolean indicating whether this port supports cable disconnection by dragging from the port.

void VuoRendererPort::updateEnabledStatus ( )
protected

Determines whether this port will accept mouse events based on the port's current attributes.

void VuoRendererPort::updateGeometry ( )

Schedules a redraw of this port.

void VuoRendererPort::updateNameRect ( bool  sidebarPaintMode)
protected

Updates the cached bounding box of the port's label.

Friends And Related Function Documentation

friend class VuoRendererPublishedPort
friend

VuoRendererPublishedPort needs paintWithOptions(...) and boundingRectWithOptions(...)

Member Data Documentation

const qreal VuoRendererPort::constantFlagHeight = VuoRendererFonts::thickPenWidth*0.6
static

Height, in pixels at 1:1 zoom, of a constant flag.

bool VuoRendererPort::isDonePort
protected

Is this port a done port?

bool VuoRendererPort::isRefreshPort
protected

Is this port a refresh port?

QRectF VuoRendererPort::nameRect
protected

The bounding box of the port's label when rendered on the canvas.

QRectF VuoRendererPort::nameRectForSidebarMode
protected

The bounding box of the port's label when rendered in the "Published Port" sidebar.

const qreal VuoRendererPort::portContainerMargin = VuoRendererFonts::thickPenWidth / 6.
static

Vertical distance, in pixels at 1:1 zoom, between the outer edge of the first/last port and the node frame rect.

const qreal VuoRendererPort::portInset = 1
static

The vertical and horizontal inset used when rendering a port shape within its outer port rect.

const qreal VuoRendererPort::portRadius = VuoRendererFonts::thickPenWidth*0.3625
static

Radius, in pixels at 1:1 zoom, of a circular port.

const qreal VuoRendererPort::portSpacing = VuoRendererFonts::thickPenWidth*3.0/4.0
static

Vertical distance, in pixels at 1:1 zoom, between the center points of two ports.

VuoRendererSignaler* VuoRendererPort::signaler
protected

The Qt signaler used by this port.


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