OpenWalnut  1.5.0dev
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
WQtNetworkPort Class Referenceabstract

Abstract class to distinguish between input- and output ports from a module. More...

#include <WQtNetworkPort.h>

+ Inheritance diagram for WQtNetworkPort:
+ Collaboration diagram for WQtNetworkPort:

Public Member Functions

virtual int type () const =0
 Reimplementation from QGraphicsItem. More...
 
virtual void updateArrows ()
 The position of every arrow connected with this port is updating its position in the scene. More...
 
virtual void removeArrow (WQtNetworkArrow *arrow)
 Removes a specific arrow. More...
 
virtual void removeArrows ()
 Removes all connected arrows. More...
 
void alignPosition (int size, int portNumber, QRectF rect, bool outPort)
 Calculates the position inside a item for each port to get a correct alignment. More...
 
virtual void setOutPort (bool type)
 Set the type of the port. More...
 
virtual bool isOutPort ()
 Returns the porttype - true if outputport, false if inputport. More...
 
virtual QString getPortName ()
 Returns the portname. More...
 
virtual void setPortName (QString str)
 Set the Name. More...
 
virtual int getNumberOfArrows ()
 Return the number of connections. More...
 
virtual void addArrow (WQtNetworkArrow *arrow)
 Adds an arrow to the port. More...
 
virtual QList< WQtNetworkArrow * > getArrowList ()
 Get a QList of all arrows connected to this port. More...
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 Actually paints the port. More...
 

Static Public Member Functions

static float getMultiplePortWidth (size_t nbPorts)
 Calculates the spaced needed for the given amount of ports. More...
 

Protected Member Functions

void mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent)
 Start drawing an arrow temporary. More...
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *mouseEvent)
 Double click on port. More...
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent)
 Updates the temporary arrows endpoint. More...
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent)
 Send a connect request to kernel when start- and endport are connectable. More...
 

Protected Attributes

QList< WQtNetworkArrow * > m_arrows
 the connected arrows More...
 
bool m_isOutPort
 is the port an outport More...
 
QString m_name
 the portname More...
 

Private Attributes

WQtNetworkArrowm_arrow
 The arrow used to connect items. More...
 
bool m_brushNotSet
 used to indicate that the correct brush was not yet set. More...
 

Detailed Description

Abstract class to distinguish between input- and output ports from a module.

This class handels if a connection between two ports is possible or not.

Definition at line 44 of file WQtNetworkPort.h.

Member Function Documentation

◆ addArrow()

void WQtNetworkPort::addArrow ( WQtNetworkArrow arrow)
virtual

Adds an arrow to the port.

Parameters
arrowthe arrow to add

Definition at line 204 of file WQtNetworkPort.cpp.

References m_arrows.

Referenced by WQtNetworkEditor::event().

+ Here is the caller graph for this function:

◆ alignPosition()

void WQtNetworkPort::alignPosition ( int  size,
int  portNumber,
QRectF  rect,
bool  outPort 
)

Calculates the position inside a item for each port to get a correct alignment.

Parameters
sizethe total number of ports ( distinguished by in- and outport
portNumberthe number of the current port (distinguised by in- and outport
rectthe rect of the parent item
outPortis it an in- or outport

Definition at line 159 of file WQtNetworkPort.cpp.

Referenced by WQtNetworkItem::fitLook().

+ Here is the caller graph for this function:

◆ getArrowList()

QList< WQtNetworkArrow * > WQtNetworkPort::getArrowList ( )
virtual

Get a QList of all arrows connected to this port.

Returns
a QList of WQtNetworkArrows

Definition at line 199 of file WQtNetworkPort.cpp.

References m_arrows.

◆ getMultiplePortWidth()

float WQtNetworkPort::getMultiplePortWidth ( size_t  nbPorts)
static

Calculates the spaced needed for the given amount of ports.

Parameters
nbPortswidth of this amount of ports
Returns
the width

Definition at line 171 of file WQtNetworkPort.cpp.

Referenced by WQtNetworkItem::fitLook().

+ Here is the caller graph for this function:

◆ getNumberOfArrows()

int WQtNetworkPort::getNumberOfArrows ( )
virtual

Return the number of connections.

Returns
number of connections

Definition at line 217 of file WQtNetworkPort.cpp.

References m_arrows.

◆ getPortName()

QString WQtNetworkPort::getPortName ( )
virtual

Returns the portname.

Returns
portname

Definition at line 222 of file WQtNetworkPort.cpp.

References m_name.

Referenced by WQtNetworkInputPort::WQtNetworkInputPort(), and WQtNetworkOutputPort::WQtNetworkOutputPort().

+ Here is the caller graph for this function:

◆ isOutPort()

bool WQtNetworkPort::isOutPort ( )
virtual

Returns the porttype - true if outputport, false if inputport.

Returns
is it a outport?

Definition at line 237 of file WQtNetworkPort.cpp.

References m_isOutPort.

Referenced by paint(), WQtNetworkInputPort::WQtNetworkInputPort(), and WQtNetworkOutputPort::WQtNetworkOutputPort().

+ Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void WQtNetworkPort::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protected

Double click on port.

Parameters
mouseEventthe event

Definition at line 80 of file WQtNetworkPort.cpp.

References WQtNetworkInputPort::getConnector(), and WQtNetworkOutputPort::getConnector().

+ Here is the call graph for this function:

◆ mouseMoveEvent()

void WQtNetworkPort::mouseMoveEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protected

Updates the temporary arrows endpoint.

Arrow is colored green when connection possible, red if no connection is possible, or black when cursor doesent covers an WQtNetworkPort.

Parameters
mouseEventthe mouse event

Definition at line 139 of file WQtNetworkPort.cpp.

References m_arrow, and WQtNetworkArrow::moveDrag().

+ Here is the call graph for this function:

◆ mousePressEvent()

void WQtNetworkPort::mousePressEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protected

Start drawing an arrow temporary.

Parameters
mouseEventthe mouse event

Definition at line 113 of file WQtNetworkPort.cpp.

References m_arrow, and WQtNetworkArrow::startDrag().

+ Here is the call graph for this function:

◆ mouseReleaseEvent()

void WQtNetworkPort::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protected

Send a connect request to kernel when start- and endport are connectable.

Parameters
mouseEventthe mouse event

Definition at line 147 of file WQtNetworkPort.cpp.

References WQtNetworkArrow::doneDrag(), and m_arrow.

+ Here is the call graph for this function:

◆ paint()

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

Actually paints the port.

Parameters
painterthe painter
optionstyle options
widgetparent widget.

Definition at line 52 of file WQtNetworkPort.cpp.

References isOutPort(), and m_brushNotSet.

+ Here is the call graph for this function:

◆ removeArrow()

void WQtNetworkPort::removeArrow ( WQtNetworkArrow arrow)
virtual

Removes a specific arrow.

Parameters
arrowan arrow

Definition at line 176 of file WQtNetworkPort.cpp.

References m_arrows.

Referenced by WQtNetworkEditor::event(), and WQtNetworkArrow::~WQtNetworkArrow().

+ Here is the caller graph for this function:

◆ removeArrows()

void WQtNetworkPort::removeArrows ( )
virtual

Removes all connected arrows.

Definition at line 186 of file WQtNetworkPort.cpp.

References m_arrows.

◆ setOutPort()

void WQtNetworkPort::setOutPort ( bool  type)
virtual

Set the type of the port.

Parameters
typetrue if out / false if in

Definition at line 232 of file WQtNetworkPort.cpp.

References m_isOutPort, and type().

Referenced by WQtNetworkInputPort::WQtNetworkInputPort(), and WQtNetworkOutputPort::WQtNetworkOutputPort().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPortName()

void WQtNetworkPort::setPortName ( QString  str)
virtual

Set the Name.

Parameters
strportname as string

Definition at line 227 of file WQtNetworkPort.cpp.

References m_name.

Referenced by WQtNetworkInputPort::WQtNetworkInputPort(), and WQtNetworkOutputPort::WQtNetworkOutputPort().

+ Here is the caller graph for this function:

◆ type()

virtual int WQtNetworkPort::type ( ) const
pure virtual

Reimplementation from QGraphicsItem.

Returns
the type of the item as int

Implemented in WQtNetworkOutputPort, and WQtNetworkInputPort.

Referenced by setOutPort().

+ Here is the caller graph for this function:

◆ updateArrows()

void WQtNetworkPort::updateArrows ( )
virtual

The position of every arrow connected with this port is updating its position in the scene.

Definition at line 209 of file WQtNetworkPort.cpp.

References m_arrows, and WQtNetworkArrow::updatePosition().

Referenced by WQtNetworkItem::positionChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_arrow

WQtNetworkArrow* WQtNetworkPort::m_arrow
private

The arrow used to connect items.

Definition at line 191 of file WQtNetworkPort.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ m_arrows

QList< WQtNetworkArrow *> WQtNetworkPort::m_arrows
protected

the connected arrows

Definition at line 181 of file WQtNetworkPort.h.

Referenced by addArrow(), getArrowList(), getNumberOfArrows(), removeArrow(), removeArrows(), and updateArrows().

◆ m_brushNotSet

bool WQtNetworkPort::m_brushNotSet
private

used to indicate that the correct brush was not yet set.

Definition at line 193 of file WQtNetworkPort.h.

Referenced by paint().

◆ m_isOutPort

bool WQtNetworkPort::m_isOutPort
protected

is the port an outport

Definition at line 183 of file WQtNetworkPort.h.

Referenced by isOutPort(), and setOutPort().

◆ m_name

QString WQtNetworkPort::m_name
protected

the portname

Definition at line 185 of file WQtNetworkPort.h.

Referenced by getPortName(), and setPortName().


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