Commit 37fc6a2e authored by Robert Frohl's avatar Robert Frohl
Browse files

[CHANGE] - (re)moved unnecessary code from NetworkPort, NetworkInputPort and...

[CHANGE] - (re)moved unnecessary code from NetworkPort, NetworkInputPort and NetworkOutputPort to better fit the inheritance
parent 57f88a16
......@@ -28,18 +28,11 @@
#include <QtGui/QGraphicsRectItem>
#include "WQtNetworkEditorGlobals.h"
#include "WQtNetworkInputPort.h"
WQtNetworkInputPort::WQtNetworkInputPort( boost::shared_ptr<WModuleInputConnector> connector )
: WQtNetworkPort()
{
setRect( 0.0, 0.0, WNETWORKPORT_SIZEX, WNETWORKPORT_SIZEY );
setBrush( Qt::gray );
setPen( QPen( Qt::red, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
setAcceptsHoverEvents( true );
setPortName( connector.get()->getName().c_str() );
setOutPort( connector.get()->isOutputConnector() );
m_connector = connector;
......@@ -68,58 +61,7 @@ int WQtNetworkInputPort::type() const
return Type;
}
void WQtNetworkInputPort::addArrow( WQtNetworkArrow *arrow )
{
m_arrows.append( arrow );
}
void WQtNetworkInputPort::removeArrow( WQtNetworkArrow *arrow )
{
int index = m_arrows.indexOf( arrow );
if (index != -1)
m_arrows.removeAt( index );
}
QList< WQtNetworkArrow *> WQtNetworkInputPort::getArrowList()
{
return m_arrows;
}
QString WQtNetworkInputPort::getPortName()
{
return m_name;
}
void WQtNetworkInputPort::setPortName( QString str )
{
m_name = str;
}
int WQtNetworkInputPort::getNumberOfArrows()
{
return m_arrows.size();
}
boost::shared_ptr<WModuleInputConnector> WQtNetworkInputPort::getConnector()
{
return m_connector;
}
void WQtNetworkInputPort::updateArrows()
{
foreach( WQtNetworkArrow *arrow, m_arrows )
{
arrow->updatePosition();
}
}
void WQtNetworkInputPort::setOutPort( bool type )
{
m_isOutPort = type;
}
bool WQtNetworkInputPort::isOutPort()
{
return m_isOutPort;
}
......@@ -29,7 +29,6 @@
#include "../../../kernel/WModuleInputConnector.h"
#include "WQtNetworkPort.h"
#include "WQtNetworkArrow.h"
// forward declaration
class WQtNetworkArrow;
......@@ -67,85 +66,14 @@ public:
*/
int type() const;
/**
* Every Arrow connected with this port is updating its position in the
* scene.
*/
void updateArrows();
/**
* Removes a specific arrow
* \param arrow an arrow
*/
void removeArrow( WQtNetworkArrow *arrow );
/**
* Calculates the position inside a item for each port to get a correct
* alignment
* \param size the total number of ports ( distinguished by in- and
* outport
* \param portNumber the number of the current port (distinguised by in-
* and outport
* \param rect the rect of the parent item
* \param outPort is it an in- or outport
*/
void alignPosition( int size, int portNumber, QRectF rect, bool outPort );
/**
* Set the type of the port.
* \param type true if out / false if in
*/
void setOutPort( bool type );
/**
* Returns the porttype.
* \return is it a outport
*/
bool isOutPort();
/**
* Returns the Name.
* \return Name
*/
QString getPortName();
/**
* Set the Name
* \param str Name as string
*/
void setPortName( QString str );
/**
* Return the number of connections
* \return number of connections
*/
int getNumberOfArrows();
/**
* Returns the WModuleInputConnecter that belongs to this object.
* \return a WModuleInputConnector
*/
boost::shared_ptr<WModuleInputConnector> getConnector();
/**
* Adds an arrow to the port
*
* \param arrow the arrow to add
*/
void addArrow( WQtNetworkArrow* arrow );
/**
* Get a QList of all arrows connected to this port
* \return a QList of WQtNetworkArrows
*/
QList< WQtNetworkArrow *> getArrowList();
private:
bool m_isOutPort; //!< is the port an outport
QString m_name; //!< the portname
boost::shared_ptr<WModuleInputConnector> m_connector; //!< the related WModuleInputConnector
};
#endif // WQTNETWORKINPUTPORT_H
......@@ -28,18 +28,11 @@
#include <QtGui/QGraphicsRectItem>
#include "WQtNetworkEditorGlobals.h"
#include "WQtNetworkOutputPort.h"
WQtNetworkOutputPort::WQtNetworkOutputPort( boost::shared_ptr<WModuleOutputConnector> connector )
: WQtNetworkPort()
{
setRect( 0.0, 0.0, WNETWORKPORT_SIZEX, WNETWORKPORT_SIZEY );
setBrush( Qt::gray );
setPen( QPen( Qt::red, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
setAcceptsHoverEvents( true );
setPortName( connector.get()->getName().c_str() );
setOutPort( connector.get()->isOutputConnector() );
m_connector = connector;
......@@ -68,58 +61,8 @@ int WQtNetworkOutputPort::type() const
return Type;
}
void WQtNetworkOutputPort::addArrow( WQtNetworkArrow *arrow )
{
m_arrows.append( arrow );
}
void WQtNetworkOutputPort::removeArrow( WQtNetworkArrow *arrow )
{
int index = m_arrows.indexOf( arrow );
if (index != -1)
m_arrows.removeAt( index );
}
QList< WQtNetworkArrow *> WQtNetworkOutputPort::getArrowList()
{
return m_arrows;
}
QString WQtNetworkOutputPort::getPortName()
{
return m_name;
}
void WQtNetworkOutputPort::setPortName( QString str )
{
m_name = str;
}
int WQtNetworkOutputPort::getNumberOfArrows()
{
return m_arrows.size();
}
boost::shared_ptr<WModuleOutputConnector> WQtNetworkOutputPort::getConnector()
{
return m_connector;
}
void WQtNetworkOutputPort::updateArrows()
{
foreach( WQtNetworkArrow *arrow, m_arrows )
{
arrow->updatePosition();
}
}
void WQtNetworkOutputPort::setOutPort( bool type )
{
m_isOutPort = type;
}
bool WQtNetworkOutputPort::isOutPort()
{
return m_isOutPort;
}
......@@ -29,7 +29,6 @@
#include "../../../kernel/WModuleOutputConnector.h"
#include "WQtNetworkPort.h"
#include "WQtNetworkArrow.h"
// forward declaration
class WQtNetworkArrow;
......@@ -68,18 +67,6 @@ public:
*/
int type() const;
/**
* Every Arrow connected with this port is updating its position in the
* scene.
*/
void updateArrows();
/**
* Removes a specific arrow
* \param arrow a specific arrow
*/
void removeArrow( WQtNetworkArrow *arrow );
/**
* Calculates the position inside a item for each port to get a correct
* alignment
......@@ -90,38 +77,7 @@ public:
* \param rect the rect of the parent item
* \param outPort is it an in- or outport
*/
void alignPosition( int size, int portNumber, QRectF rect, bool outPort );
/**
* Set the type of the port.
* \param type true if out / false if in
*/
void setOutPort( bool type );
/**
* Returns the porttype.
* \return is it a outport
*/
bool isOutPort();
/**
* Returns the Name.
* \return Name
*/
QString getPortName();
/**
* Set the Name
* \param str Name as string
*/
void setPortName( QString str );
/**
* Return the number of connections
*
* \return number of connections
*/
int getNumberOfArrows();
//void alignPosition( int size, int portNumber, QRectF rect, bool outPort );
/**
* Returns the WModuleOutputConnecter that belongs to this object.
......@@ -129,25 +85,8 @@ public:
*/
boost::shared_ptr<WModuleOutputConnector> getConnector();
/**
* Adds an arrow to the port
*
* \param arrow the arrow to add
*/
void addArrow( WQtNetworkArrow *arrow );
/**
* Get a QList of all arrows connected to this port
* \return a QList of WQtNetworkArrows
*/
QList< WQtNetworkArrow *> getArrowList();
private:
bool m_isOutPort; //!< is the port an outport
QString m_name; //!< the portname
boost::shared_ptr<WModuleOutputConnector> m_connector; //!< the related WModuleInputConnector
};
#endif // WQTNETWORKOUTPUTPORT_H
......@@ -39,6 +39,11 @@
WQtNetworkPort::WQtNetworkPort()
{
setRect( 0.0, 0.0, WNETWORKPORT_SIZEX, WNETWORKPORT_SIZEY );
setBrush( Qt::gray );
setPen( QPen( Qt::red, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
setAcceptsHoverEvents( true );
}
WQtNetworkPort::~WQtNetworkPort()
......@@ -181,6 +186,14 @@ void WQtNetworkPort::alignPosition( int size, int portNumber, QRectF rect, bool
}
}
void WQtNetworkPort::removeArrow( WQtNetworkArrow *arrow )
{
int index = m_arrows.indexOf( arrow );
if (index != -1)
m_arrows.removeAt( index );
}
void WQtNetworkPort::removeArrows()
{
foreach( WQtNetworkArrow *arrow, m_arrows )
......@@ -194,3 +207,46 @@ void WQtNetworkPort::removeArrows()
}
}
QList< WQtNetworkArrow *> WQtNetworkPort::getArrowList()
{
return m_arrows;
}
void WQtNetworkPort::addArrow( WQtNetworkArrow *arrow )
{
m_arrows.append( arrow );
}
void WQtNetworkPort::updateArrows()
{
foreach( WQtNetworkArrow *arrow, m_arrows )
{
arrow->updatePosition();
}
}
int WQtNetworkPort::getNumberOfArrows()
{
return m_arrows.size();
}
QString WQtNetworkPort::getPortName()
{
return m_name;
}
void WQtNetworkPort::setPortName( QString str )
{
m_name = str;
}
void WQtNetworkPort::setOutPort( bool type )
{
m_isOutPort = type;
}
bool WQtNetworkPort::isOutPort()
{
return m_isOutPort;
}
......@@ -29,6 +29,8 @@
#include <QtGui/QGraphicsLineItem>
#include "WQtNetworkArrow.h"
#include "WQtNetworkEditorGlobals.h"
#include "WQtNetworkPort.h"
// forward declaration
//class WQtNetworkArrow;
......@@ -57,13 +59,13 @@ public:
* The position of every arrow connected with this port is updating its position in the
* scene.
*/
virtual void updateArrows() = 0;
virtual void updateArrows();
/**
* Removes a specific arrow.
* \param arrow an arrow
*/
virtual void removeArrow( WQtNetworkArrow *arrow ) = 0;
virtual void removeArrow( WQtNetworkArrow *arrow );
/**
* Removes all connected arrows.
......@@ -86,46 +88,46 @@ public:
* Set the type of the port.
* \param type true if out / false if in
*/
virtual void setOutPort( bool type ) = 0;
virtual void setOutPort( bool type );
/**
* Returns the porttype - true if outputport, false if inputport
* \return is it a outport?
*/
virtual bool isOutPort() = 0;
virtual bool isOutPort();
/**
* Returns the portname.
* \return portname
*/
virtual QString getPortName() = 0;
virtual QString getPortName();
/**
* Set the Name
* \param str portname as string
*/
virtual void setPortName( QString str ) = 0;
virtual void setPortName( QString str );
/**
* Return the number of connections
*
* \return number of connections
*/
virtual int getNumberOfArrows() = 0;
virtual int getNumberOfArrows();
/**
* Adds an arrow to the port
*
* \param arrow the arrow to add
*/
virtual void addArrow( WQtNetworkArrow* arrow ) = 0;
virtual void addArrow( WQtNetworkArrow* arrow );
/**
* Get a QList of all arrows connected to this port
*
* \return a QList of WQtNetworkArrows
*/
virtual QList< WQtNetworkArrow* > getArrowList() = 0;
virtual QList< WQtNetworkArrow* > getArrowList();
protected:
......@@ -155,6 +157,10 @@ protected:
QList< WQtNetworkArrow *> m_arrows; //!< the connected arrows
bool m_isOutPort; //!< is the port an outport
QString m_name; //!< the portname
private:
QGraphicsLineItem * line; //!< the temporary line when you connect two ports
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment