Frapper  1.0a
Public Types | Public Slots | Signals | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Frapper::NodeGraphicsItem Class Reference

Class for graphical representation of scene objects. More...

#include <NodeGraphicsItem.h>

Inheritance diagram for Frapper::NodeGraphicsItem:
Inheritance graph
[legend]
Collaboration diagram for Frapper::NodeGraphicsItem:
Collaboration graph
[legend]

Public Types

enum  PinDisplayMode { PDM_All, PDM_Connected, PDM_Collapsed }
 Nested enumeration of pin display modes that define how many pins will be displayed in the node graphics item. More...
 

Public Slots

void setSelected (bool selected)
 Removes the association to the given ConnectionGraphicsItem from the node graphics item.
 
void createConnection (PinGraphicsItem *pinItem, Parameter *parameter)
 Begins or ends creating a connection between nodes. Is called when a parameter represented by a pin has been clicked.
 
void refresh ()
 Refresh the graphics item to reflect changes in the node that it represents.
 

Signals

void connectionRequested (Parameter *sourceParameter, Parameter *targetParameter)
 Signal that is emitted when a connection between the given parameters should be created.
 
void connectionRequested (Node *sourceNode, Node *targetNode)
 Signal that is emitted when a connection between the given nodes should be created. (connect by name)
 
void nodeGraphicsItemMoved (const QPointF &pos)
 Signal that is emitted when the item has been moved to a new position.
 

Public Member Functions

 NodeGraphicsItem (Node *node, QPointF position, const QColor &color)
 Constructor of the NodeGraphicsItem class.
 
 ~NodeGraphicsItem ()
 Destructor of the NodeGraphicsItem class.
 
void setEnabled (bool enabled)
 Enables or disables the graphics item.
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
 Paints the graphics item into a graphics view.
 
NodegetNode () const
 Returns the node that the graphics item represents.
 
void resetNode ()
 Resets the node to 0.
 
void bringToFront ()
 Sets the z-index of the graphics item so that it will be drawn over all other graphics items in the scene.
 
void addConnectionItem (ConnectionGraphicsItem *item)
 Associates a ConnectionGraphicsItem with the node graphics item.
 
void removeConnectionItem (ConnectionGraphicsItem *item)
 Removes the association to the given ConnectionGraphicsItem from the node graphics item.
 
void removeConnectionItems ()
 Removes all ConnectionGraphicsItem associations from the node graphics item.
 
void setPinDisplayMode (PinDisplayMode pinDisplayMode)
 Sets the pin display mode for the item to the given mode.
 
- Public Member Functions inherited from Frapper::BaseRectItem
 BaseRectItem (const QColor &color, bool actAsButton=false, QGraphicsItem *parent=0)
 Constructor of the BaseRectItem class.
 
 ~BaseRectItem ()
 Destructor of the BaseRectItem class.
 
QRectF boundingRect () const
 Returns the bounding rectangle of the graphics item.
 
QColor getColor () const
 Returns the item's base color.
 

Static Public Attributes

static const int ItemWidth = 60
 The standard width for the items.
 
static const int ItemBaseHeight = 44
 The base height for the items.
 
static const int ItemPinRowHeight = 12
 The height of a row of pins.
 

Protected Member Functions

void mousePressEvent (QGraphicsSceneMouseEvent *event)
 Event handler that reacts to mouse press events.
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 Event handler that reacts to mouse release events.
 
void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
 Event handler that reacts to context menu events.
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 Processing on changed item.
 
- Protected Member Functions inherited from Frapper::BaseRectItem
void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 Event handler that reacts to hover enter events.
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 Event handler that reacts to hover leave events.
 
void mousePressEvent (QGraphicsSceneMouseEvent *event)
 Event handler that reacts to mouse press events.
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 Event handler that reacts to mouse release events.
 

Private Slots

void connectByNameClicked ()
 Connect by name has been clicked in context menu.
 
void updatePinDisplayMode (QAction *action)
 Updates the node's pin display mode according to the triggered action.
 

Private Member Functions

void updatePins ()
 Updates the item according to the pin display mode set to display all pins, only connected pins, or all pins in one collapsed pin.
 
void disableOtherPins (PinGraphicsItem *pinItem, Parameter *parameter)
 Disables all pins in the node item that are of a different parameter type or the same connector types as the parameter that was clicked. Also disables all of the node item's flags. The whole node will be disabled if there are no enabled pins left.
 
void beginCreatingConnection (PinGraphicsItem *pinItem, Parameter *parameter)
 Begins creating a connection between parameters of nodes by creating a new (temporary) connection graphics item that has the given pin as one of its end points. Is called when a parameter represented by a pin is clicked.
 
void endCreatingConnection (PinGraphicsItem *pinItem, Parameter *parameter)
 Ends creating a connection between parameters of nodes by keeping the temporarily created connection graphics item that has the given pin as one of its end points, or destroying it when creating the connection is aborted. Is called when a parameter represented by a pin is clicked.
 

Private Attributes

Nodem_node
 The node that the graphics item represents.
 
FlagGraphicsItemm_evalFlagItem
 The node's eval flag item.
 
ViewFlagGraphicsItemm_viewFlagItem
 The node's view flag item.
 
PinDisplayMode m_pinDisplayMode
 The pin display mode that defines how many pins will be displayed in the node graphics item.
 
QList< PinGraphicsItem * > m_inputPins
 The list of input pins to display in the item.
 
QList< PinGraphicsItem * > m_outputPins
 The list of output pins to display in the item.
 
QMap< unsigned int,
ConnectionGraphicsItem * > 
m_connectionItems
 All ConnectionGraphicsItems connected to this item.
 
QMenu m_nodeContextMenu
 The node context menu.
 
QMenu m_pinContextMenu
 The pin context menu.
 

Static Private Attributes

static int s_numberOfNodeGraphicsItems = 0
 The number of node graphics items created for the current scene.
 

Additional Inherited Members

- Protected Attributes inherited from Frapper::BaseRectItem
QColor m_color
 The item's base color.
 
bool m_actAsButton
 Flag that states whether the item should act as a button.
 
bool m_hovered
 Flag that states whether the item is currently hovered by the mouse pointer.
 
bool m_clicked
 Flag that states whether the item is currently clicked by the mouse pointer (i.e. a mouse button is pressed).
 

Detailed Description

Class for graphical representation of scene objects.

Inheritance Diagram
dot_inline_dotgraph_6.png
[legend]

Member Enumeration Documentation

Nested enumeration of pin display modes that define how many pins will be displayed in the node graphics item.

Enumerator:
PDM_All 
PDM_Connected 
PDM_Collapsed 

Constructor & Destructor Documentation

Frapper::NodeGraphicsItem::NodeGraphicsItem ( Node node,
QPointF  position,
const QColor &  color 
)

Constructor of the NodeGraphicsItem class.

Constructors and Destructors.

Parameters
nodeThe node that the graphics item represents.
positionThe initial position for the graphics item.
colorThe color in which to draw the graphics item.

Constructor of the NodeGraphicsItem class.

Parameters
nodeThe node that the graphics item represents.
positionThe initial position for the graphics item.
colorThe color in which to draw the graphics item.
Frapper::NodeGraphicsItem::~NodeGraphicsItem ( )

Destructor of the NodeGraphicsItem class.

Member Function Documentation

void Frapper::NodeGraphicsItem::setEnabled ( bool  enabled)

Enables or disables the graphics item.

Public Functions.

Parameters
enabledThe new enabled state for the item.

Enables or disables the graphics item.

Parameters
enabledThe new enabled state for the item.
void Frapper::NodeGraphicsItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = 0 
)
virtual

Paints the graphics item into a graphics view.

Parameters
painterThe object to use for painting.
optionStyle options for painting the graphics item.
widgetThe widget into which to paint the graphics item.

Implements Frapper::BaseRectItem.

Node * Frapper::NodeGraphicsItem::getNode ( ) const

Returns the node that the graphics item represents.

Returns
The node that the graphics item represents.
void Frapper::NodeGraphicsItem::resetNode ( )

Resets the node to 0.

Should be called when the node that the graphics item represents will be destroyed.

Temporary. Should be replaced by improved code when destroying nodes in the scene model.

void Frapper::NodeGraphicsItem::bringToFront ( )

Sets the z-index of the graphics item so that it will be drawn over all other graphics items in the scene.

void Frapper::NodeGraphicsItem::addConnectionItem ( ConnectionGraphicsItem item)

Associates a ConnectionGraphicsItem with the node graphics item.

Parameters
itemThe item to associate with the node graphics item.
void Frapper::NodeGraphicsItem::removeConnectionItem ( ConnectionGraphicsItem item)

Removes the association to the given ConnectionGraphicsItem from the node graphics item.

Parameters
itemThe item to no longer associate with the node graphics item.
void Frapper::NodeGraphicsItem::removeConnectionItems ( )

Removes all ConnectionGraphicsItem associations from the node graphics item.

void Frapper::NodeGraphicsItem::setPinDisplayMode ( NodeGraphicsItem::PinDisplayMode  pinDisplayMode)

Sets the pin display mode for the item to the given mode.

Parameters
pinDisplayModeThe pin display mode to set for the item.
void Frapper::NodeGraphicsItem::setSelected ( bool  selected)
slot

Removes the association to the given ConnectionGraphicsItem from the node graphics item.

Public Slots.

Parameters
itemThe item to no longer associate with the node graphics item. Updates the selected state of the graphics item according to the given value.

This function is needed because QGraphicsItem::setSelected() is not a slot.

Parameters
selectedThe new selected state for the graphics item.

Updates the selected state of the graphics item according to the given value.

This function is needed because QGraphicsItem::setSelected() is not a slot.

Parameters
selectedThe new selected state for the graphics item.
void Frapper::NodeGraphicsItem::createConnection ( PinGraphicsItem pinItem,
Parameter parameter 
)
slot

Begins or ends creating a connection between nodes. Is called when a parameter represented by a pin has been clicked.

Parameters
pinItemThe pin graphics item representing the parameter.
parameterThe parameter that was clicked.
void Frapper::NodeGraphicsItem::refresh ( )
slot

Refresh the graphics item to reflect changes in the node that it represents.

void Frapper::NodeGraphicsItem::connectionRequested ( Parameter sourceParameter,
Parameter targetParameter 
)
signal

Signal that is emitted when a connection between the given parameters should be created.

The parameters to be connected must have the same parameter type.

Parameters
sourceParameterThe output parameter of the source node to connect.
targetParameterThe input parameter of the target node to connect.
void Frapper::NodeGraphicsItem::connectionRequested ( Node sourceNode,
Node targetNode 
)
signal

Signal that is emitted when a connection between the given nodes should be created. (connect by name)

The parameters to be connected must have the same parameter type.

Parameters
sourceNodeThe source node.
targetNodeThe target node.
void Frapper::NodeGraphicsItem::nodeGraphicsItemMoved ( const QPointF &  pos)
signal

Signal that is emitted when the item has been moved to a new position.

Parameters
posThe position that the item has moved to.
void Frapper::NodeGraphicsItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
protected

Event handler that reacts to mouse press events.

Protected Functions.

Parameters
eventThe object containing details about the event.

Event handler that reacts to mouse press events.

Parameters
eventThe object containing details about the event.
void Frapper::NodeGraphicsItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
protected

Event handler that reacts to mouse release events.

Parameters
eventThe object containing details about the event.
void Frapper::NodeGraphicsItem::contextMenuEvent ( QGraphicsSceneContextMenuEvent *  event)
protected

Event handler that reacts to context menu events.

Parameters
eventThe object containing details about the event.
QVariant Frapper::NodeGraphicsItem::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
protected

Processing on changed item.

void Frapper::NodeGraphicsItem::updatePins ( )
private

Updates the item according to the pin display mode set to display all pins, only connected pins, or all pins in one collapsed pin.

Private Functions.

void Frapper::NodeGraphicsItem::disableOtherPins ( PinGraphicsItem pinItem,
Parameter parameter 
)
private

Disables all pins in the node item that are of a different parameter type or the same connector types as the parameter that was clicked. Also disables all of the node item's flags. The whole node will be disabled if there are no enabled pins left.

Disables all pins in the node item that are of a different parameter type or the same pin types as the parameter that was clicked. Also disables all of the node item's flags. The whole node will be disabled if there are no enabled pins left.

Parameters
pinItemThe pin graphics item representing the parameter that was clicked.
parameterThe parameter that was clicked.
void Frapper::NodeGraphicsItem::beginCreatingConnection ( PinGraphicsItem pinItem,
Parameter parameter 
)
private

Begins creating a connection between parameters of nodes by creating a new (temporary) connection graphics item that has the given pin as one of its end points. Is called when a parameter represented by a pin is clicked.

Parameters
pinItemThe pin graphics item representing the parameter that was clicked.
parameterThe parameter that was clicked.
See Also
parameterClicked
endCreatingConnection
void Frapper::NodeGraphicsItem::endCreatingConnection ( PinGraphicsItem pinItem,
Parameter parameter 
)
private

Ends creating a connection between parameters of nodes by keeping the temporarily created connection graphics item that has the given pin as one of its end points, or destroying it when creating the connection is aborted. Is called when a parameter represented by a pin is clicked.

Parameters
pinItemThe pin graphics item representing the parameter that was clicked.
parameterThe parameter that was clicked.
See Also
parameterClicked
beginCreatingConnection
void Frapper::NodeGraphicsItem::connectByNameClicked ( )
privateslot

Connect by name has been clicked in context menu.

void Frapper::NodeGraphicsItem::updatePinDisplayMode ( QAction *  action)
privateslot

Updates the node's pin display mode according to the triggered action.

Private Slots.

Parameters
actionThe action that was triggered.

Updates the node's pin display mode according to the triggered action.

Parameters
actionThe action that was triggered.

Member Data Documentation

const int Frapper::NodeGraphicsItem::ItemWidth = 60
static

The standard width for the items.

const int Frapper::NodeGraphicsItem::ItemBaseHeight = 44
static

The base height for the items.

const int Frapper::NodeGraphicsItem::ItemPinRowHeight = 12
static

The height of a row of pins.

int Frapper::NodeGraphicsItem::s_numberOfNodeGraphicsItems = 0
staticprivate

The number of node graphics items created for the current scene.

Private Static Data.

Node* Frapper::NodeGraphicsItem::m_node
private

The node that the graphics item represents.

FlagGraphicsItem* Frapper::NodeGraphicsItem::m_evalFlagItem
private

The node's eval flag item.

ViewFlagGraphicsItem* Frapper::NodeGraphicsItem::m_viewFlagItem
private

The node's view flag item.

PinDisplayMode Frapper::NodeGraphicsItem::m_pinDisplayMode
private

The pin display mode that defines how many pins will be displayed in the node graphics item.

QList<PinGraphicsItem *> Frapper::NodeGraphicsItem::m_inputPins
private

The list of input pins to display in the item.

QList<PinGraphicsItem *> Frapper::NodeGraphicsItem::m_outputPins
private

The list of output pins to display in the item.

QMap<unsigned int, ConnectionGraphicsItem *> Frapper::NodeGraphicsItem::m_connectionItems
private

All ConnectionGraphicsItems connected to this item.

QMenu Frapper::NodeGraphicsItem::m_nodeContextMenu
private

The node context menu.

QMenu Frapper::NodeGraphicsItem::m_pinContextMenu
private

The pin context menu.


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