NodeGraphicsItem Class Reference

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

#include <NodeGraphicsItem.h>

Inheritance diagram for NodeGraphicsItem:

Inheritance graph
[legend]
Collaboration diagram for NodeGraphicsItem:

Collaboration graph
[legend]

List of all members.

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.

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.

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.


Detailed Description

Class for graphical representation of scene objects.

Inheritance Diagram

inline_dotgraph_8.dot
[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

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

Constructor of the NodeGraphicsItem class.

Constructors and Destructors.

Parameters:
node The node that the graphics item represents.
position The initial position for the graphics item.
color The color in which to draw the graphics item.
Constructor of the NodeGraphicsItem class.

Parameters:
node The node that the graphics item represents.
position The initial position for the graphics item.
color The color in which to draw the graphics item.

NodeGraphicsItem::~NodeGraphicsItem (  ) 

Destructor of the NodeGraphicsItem class.


Member Function Documentation

void NodeGraphicsItem::setEnabled ( bool  enabled  ) 

Enables or disables the graphics item.

Public Functions.

Parameters:
enabled The new enabled state for the item.
Enables or disables the graphics item.

Parameters:
enabled The new enabled state for the item.

void NodeGraphicsItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = 0 
) [virtual]

Paints the graphics item into a graphics view.

Parameters:
painter The object to use for painting.
option Style options for painting the graphics item.
widget The widget into which to paint the graphics item.

Implements BaseRectItem.

Node * NodeGraphicsItem::getNode (  )  const

Returns the node that the graphics item represents.

Returns:
The node that the graphics item represents.

void 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 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 NodeGraphicsItem::addConnectionItem ( ConnectionGraphicsItem item  ) 

Associates a ConnectionGraphicsItem with the node graphics item.

Parameters:
item The item to associate with the node graphics item.

void NodeGraphicsItem::removeConnectionItem ( ConnectionGraphicsItem item  ) 

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

Parameters:
item The item to no longer associate with the node graphics item.

void NodeGraphicsItem::removeConnectionItems (  ) 

Removes all ConnectionGraphicsItem associations from the node graphics item.

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

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

Parameters:
pinDisplayMode The pin display mode to set for the item.

void NodeGraphicsItem::setSelected ( bool  selected  )  [slot]

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

Public Slots.

Parameters:
item The 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:
selected The 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:
selected The new selected state for the graphics item.

void 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:
pinItem The pin graphics item representing the parameter.
parameter The parameter that was clicked.

void NodeGraphicsItem::refresh (  )  [slot]

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

void 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:
sourceParameter The output parameter of the source node to connect.
targetParameter The input parameter of the target node to connect.

void 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:
sourceNode The source node.
targetNode The target node.

void NodeGraphicsItem::nodeGraphicsItemMoved ( const QPointF &  pos  )  [signal]

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

Parameters:
pos The position that the item has moved to.

void NodeGraphicsItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event  )  [protected]

Event handler that reacts to mouse press events.

Protected Functions.

Parameters:
event The object containing details about the event.
Event handler that reacts to mouse press events.

Parameters:
event The object containing details about the event.

Reimplemented from BaseRectItem.

void NodeGraphicsItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event  )  [protected]

Event handler that reacts to mouse release events.

Parameters:
event The object containing details about the event.

Reimplemented from BaseRectItem.

void NodeGraphicsItem::contextMenuEvent ( QGraphicsSceneContextMenuEvent *  event  )  [protected]

Event handler that reacts to context menu events.

Parameters:
event The object containing details about the event.

QVariant NodeGraphicsItem::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
) [protected]

Processing on changed item.

void 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 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:
pinItem The pin graphics item representing the parameter that was clicked.
parameter The parameter that was clicked.

void 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:
pinItem The pin graphics item representing the parameter that was clicked.
parameter The parameter that was clicked.
See also:
parameterClicked

endCreatingConnection

void 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:
pinItem The pin graphics item representing the parameter that was clicked.
parameter The parameter that was clicked.
See also:
parameterClicked

beginCreatingConnection

void NodeGraphicsItem::connectByNameClicked (  )  [private, slot]

Connect by name has been clicked in context menu.

void NodeGraphicsItem::updatePinDisplayMode ( QAction *  action  )  [private, slot]

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

Private Slots.

Parameters:
action The action that was triggered.
Updates the node's pin display mode according to the triggered action.

Parameters:
action The action that was triggered.


Member Data Documentation

const int NodeGraphicsItem::ItemWidth = 60 [static]

The standard width for the items.

const int NodeGraphicsItem::ItemBaseHeight = 44 [static]

The base height for the items.

const int NodeGraphicsItem::ItemPinRowHeight = 12 [static]

The height of a row of pins.

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

Private Static Data.

The node that the graphics item represents.

The node's eval flag item.

The node's view flag item.

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

The list of input pins to display in the item.

The list of output pins to display in the item.

All ConnectionGraphicsItems connected to this item.

The node context menu.

The pin context menu.


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

Generated on Wed Feb 24 15:01:01 2010 for Frapper by  doxygen 1.5.9