25 #ifndef WQTNETWORKARROW_H
26 #define WQTNETWORKARROW_H
32 #include <QGraphicsLineItem>
33 #include <QGraphicsPathItem>
34 #include <QGraphicsScene>
35 #include <QGraphicsSceneMouseEvent>
38 #include "core/kernel/WModuleConnector.h"
130 QPainterPath
shape()
const;
139 QVariant
itemChange( GraphicsItemChange change,
const QVariant &value );
153 void moveDrag(
const QPointF& pos );
160 void doneDrag(
const QPointF& pos );
170 void paint( QPainter* painter,
const QStyleOptionGraphicsItem *option, QWidget *w );
This Class is needed for connecting two ports and drawing a line between them.
WQtNetworkInputPort * getEndPort()
Returns the WQtNetworkInputPort where the arrow ends.
void updatePosition(QPointF deviate=QPointF())
Calculated the new position of the lines endpoints in the scene.
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
If the cursor enters the arrow, the arrow becomes geen.
WQtNetworkArrow(WQtNetworkOutputPort *outPort, WQtNetworkInputPort *inPort)
Constructor.
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
Double click on port.
void changeColor(QColor color)
This method changes the color of the arrow.
bool m_snappedOff
gets true once the arrow was pulled far away from original click position.
WQtNetworkInputPort * m_endPort
the end port
~WQtNetworkArrow()
Destructor.
WQtNetworkOutputPort * getStartPort()
Returns the WQtNetworkOutputPort where the arrow starts.
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
Start drawing an arrow temporary.
QPointF m_clickPoint
position where the click event was created.
QPainterPath shape() const
Reimplementation from QGraphicsItem.
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
Send a connect request to kernel when start- and endport are connectable.
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
If the item is changed we want to get notified.
void doneDrag(const QPointF &pos)
Called when releasing the mouse.
QRectF boundingRect() const
Reimplementation form QGraphicsItem, because the arrowhead is added to the line.
int type() const
Reimplementation from QGraphicsItem.
QColor m_color
the current color
WQtNetworkInputPort * m_connectTo
connect to this port after mouse release.
bool m_connectionDisconnect
disconnect if true.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w)
Draw some customized stuff in the scene.
QPolygonF m_arrowHead
the arrowhead
WQtNetworkOutputPort * m_startPort
the start port
QLineF m_line
the line representing the arrow
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
If the cursor leaves the arrow, the arrow gets his default color.
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
Updates the temporary arrows endpoint.
void moveDrag(const QPointF &pos)
Update drag position.
WQtNetworkInputPort * findNearestCompatibleInput(QPointF pos, float maxDistance=100)
Search the next, compatible input port.
void startDrag(const QPointF &pos)
Start Drag.
This class represents the ports a module have.