Commit 3da5ca1e by Sebastian Eichelbaum

[DOC][STYLE]

parent 376433b5
......@@ -46,117 +46,117 @@ class WQtNetworkInputPort;
*/
class WQtNetworkArrow : public QGraphicsLineItem
{
public:
/**
* This customize the return value of type()
*/
enum
{
Type = UserType + 4
};
/**
* Constructor
*
* \param outPort the outputport that provide the data
* \param inPort the inputport that recive the data
*/
explicit WQtNetworkArrow( WQtNetworkOutputPort *outPort, WQtNetworkInputPort *inPort );
/**
* Destructor
*/
~WQtNetworkArrow();
/**
* Reimplementation from QGraphicsItem
* \return the type of the item as int
*/
int type() const;
/**
* Calculated the new position of the lines endpoints in the scene.
* Is called everytime the parentItem is changed or after construction.
*/
void updatePosition();
/**
* Returns the WQtNetworkOutputPort where the arrow starts.
*\return the WQtNetworkInputPort where the connection starts
*/
WQtNetworkOutputPort* getStartPort();
/**
* Returns the WQtNetworkInputPort where the arrow ends.
*\return the WQtNetworkInputPort where the connection ends
*/
WQtNetworkInputPort* getEndPort();
/**
* Reimplementation form QGraphicsItem, because the arrowhead is added
* to the line. Its needed that QGraphicsView knows which area needs to
* be redrawn.
* \return a QRectF that bounds the drawn object
*/
QRectF boundingRect() const;
/**
* Reimplementation from QGraphicsItem.
* Return the shape of this item as a QPainterPath in local coordinates
* \return shape as QPainterPath of this object
*/
QPainterPath shape() const;
/**
* If the item is changed we want to get notified.
*
* \param change
* \param value
* \return
*/
QVariant itemChange( GraphicsItemChange change, const QVariant &value );
protected:
/**
* Draw some customized stuff in the scene.
*
* \param painter
* \param option
* \param w
*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* w );
/**
* If the cursor enters the arrow, the arrow becomes geen.
*
* \param event the hover event
*/
void hoverEnterEvent( QGraphicsSceneHoverEvent * event );
/**
* If the cursor leaves the arrow, the arrow gets his default color.
*
* \param event the hover event
*/
void hoverLeaveEvent( QGraphicsSceneHoverEvent * event );
private:
/**
* This method changes the color of the arrow.
*
* \param color the choosen color
*/
void changeColor( QColor color );
WQtNetworkOutputPort *m_startPort; //!< the start port
WQtNetworkInputPort *m_endPort; //!< the end port
QColor m_color; //!< the current color
QPolygonF arrowHead; //!< the arrowhead
public:
/**
* This customize the return value of type()
*/
enum
{
Type = UserType + 4
};
/**
* Constructor
*
* \param outPort the outputport that provide the data
* \param inPort the inputport that recive the data
*/
explicit WQtNetworkArrow( WQtNetworkOutputPort *outPort, WQtNetworkInputPort *inPort );
/**
* Destructor
*/
~WQtNetworkArrow();
/**
* Reimplementation from QGraphicsItem
* \return the type of the item as int
*/
int type() const;
/**
* Calculated the new position of the lines endpoints in the scene.
* Is called everytime the parentItem is changed or after construction.
*/
void updatePosition();
/**
* Returns the WQtNetworkOutputPort where the arrow starts.
*\return the WQtNetworkInputPort where the connection starts
*/
WQtNetworkOutputPort* getStartPort();
/**
* Returns the WQtNetworkInputPort where the arrow ends.
*\return the WQtNetworkInputPort where the connection ends
*/
WQtNetworkInputPort* getEndPort();
/**
* Reimplementation form QGraphicsItem, because the arrowhead is added
* to the line. Its needed that QGraphicsView knows which area needs to
* be redrawn.
* \return a QRectF that bounds the drawn object
*/
QRectF boundingRect() const;
/**
* Reimplementation from QGraphicsItem.
* Return the shape of this item as a QPainterPath in local coordinates
* \return shape as QPainterPath of this object
*/
QPainterPath shape() const;
/**
* If the item is changed we want to get notified.
*
* \param change
* \param value
* \return
*/
QVariant itemChange( GraphicsItemChange change, const QVariant &value );
protected:
/**
* Draw some customized stuff in the scene.
*
* \param painter
* \param option
* \param w
*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* w );
/**
* If the cursor enters the arrow, the arrow becomes geen.
*
* \param event the hover event
*/
void hoverEnterEvent( QGraphicsSceneHoverEvent * event );
/**
* If the cursor leaves the arrow, the arrow gets his default color.
*
* \param event the hover event
*/
void hoverLeaveEvent( QGraphicsSceneHoverEvent * event );
private:
/**
* This method changes the color of the arrow.
*
* \param color the choosen color
*/
void changeColor( QColor color );
WQtNetworkOutputPort *m_startPort; //!< the start port
WQtNetworkInputPort *m_endPort; //!< the end port
QColor m_color; //!< the current color
QPolygonF arrowHead; //!< the arrowhead
};
#endif // WQTNETWORKARROW_H
......@@ -55,7 +55,6 @@ public:
/**
* default constructor
*
* \param title Title will be displayed above the widget
* \param parent The widget that manages this widget
*/
explicit WQtNetworkEditor( WMainWindow* parent = 0 );
......@@ -67,7 +66,7 @@ public:
/**
* Create a new WQtNetworkItem for a given WModule
* \param a new WModule
* \param module a new WModule
*/
void addModule( boost::shared_ptr< WModule > module );
......@@ -100,20 +99,18 @@ protected:
/**
* Everytime a module is associated, ready, connected, disconnected, removed or
* deleted the kernels emits a signal and here we look how to behave.
*
* \param event the event that should be handled here.
*/
virtual bool event( QEvent* event );
/**
* Determines compatible prototypes
* \return list of modules without possible input connectors
*/
WQtCombinerToolbar* createCompatibleButtons( boost::shared_ptr< WModule >module );
/**
* This event is called every 'timerID' in ms. If the WQtNetworkItems don't
* move as result of the calculated forces the timer won't be reseted.
*
* \param event the timer event
*/
void timerEvent( QTimerEvent *event );
void timerEvent( QTimerEvent* event );
private:
......
......@@ -37,120 +37,122 @@ class WQtNetworkArrow;
/**
* This class represents the ports a module have. Two ports from different
* modules can be connected by the corresponding ports.
*/
*/
class WQtNetworkInputPort : public WQtNetworkPort
{
public:
/**
* Constructor
* \param connector the related WModuleInputConnector
*/
explicit WQtNetworkInputPort( boost::shared_ptr<WModuleInputConnector> connector );
/**
* Destructor
*/
~WQtNetworkInputPort();
/**
* This customize the return value of type()
*/
enum
{
Type = UserType + 11
};
/**
* Reimplementation from QGraphicsItem
* \return the type of the item as int
*/
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 );
/**
* Removes all connected arrows
*/
void removeArrows();
/**
* 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 inOut 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
*/
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
QList< WQtNetworkArrow *> m_arrows; //!< the connected arrows
QString m_name; //!< the portname
boost::shared_ptr<WModuleInputConnector> m_connector; //!< the related WModuleInputConnector
public:
/**
* Constructor
* \param connector the related WModuleInputConnector
*/
explicit WQtNetworkInputPort( boost::shared_ptr<WModuleInputConnector> connector );
/**
* Destructor
*/
~WQtNetworkInputPort();
/**
* This customize the return value of type()
*/
enum
{
Type = UserType + 11
};
/**
* Reimplementation from QGraphicsItem
* \return the type of the item as int
*/
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 );
/**
* Removes all connected arrows
*/
void removeArrows();
/**
* 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
QList< WQtNetworkArrow *> m_arrows; //!< the connected arrows
QString m_name; //!< the portname
boost::shared_ptr<WModuleInputConnector> m_connector; //!< the related WModuleInputConnector
};
#endif // WQTNETWORKINPUTPORT_H
......@@ -43,171 +43,178 @@ class QGraphicsWidget;
*/
class WQtNetworkItem : public QGraphicsRectItem
{
public:
/**
* Constructor of the item.
*/
explicit WQtNetworkItem( WQtNetworkEditor *editor, boost::shared_ptr< WModule > module );
/**
* Destructor.
*/
virtual ~WQtNetworkItem();
/**
* This customize the return value of type()
*/
enum
{
Type = UserType + 20
};
/**
* Reimplementation from QGraphicsItem
* \return the type of the item as int
*/
int type() const;
/**
* Add a port to the item.
*/
void addInputPort( WQtNetworkInputPort *inPort );
/**
* Add a port to the item.
*/
void addOutputPort( WQtNetworkOutputPort *outPort );
/**
* Returns the item inports.
* \return the item inports
*/
QList< WQtNetworkInputPort *> getInPorts();
/**
* Returns the item outports
* \return the item outports
*/
QList< WQtNetworkOutputPort *> getOutPorts();
/**
* This method aligns the in- and outports as well as the modulename
* in a regular way.
*/
void fitLook();
/**
* Set the QGraphicsTextItem ( the caption ) of the item
*
* \param text the caption
*/
void setTextItem( QGraphicsTextItem *text );
/**
* Get the caption as QString
*
* \return the caption.
*/
QString getText();
/**
* Get the WModule represented by this object.
* \return the related WModule
*/
boost::shared_ptr< WModule > getModule();
/**
* Here the module can be enabled when the WModule is ready.
* \param active true if module is ready.
*/
void activate( bool active );
/**
* calculate new forces to layout the WQtNetworkItems in the
* WQtNetworkScene.
*/
void calculateForces();
/**
* Check if new calculated position is different from current. If yes
* the ne position is set and all connected WQtNetworkArrow are updated.
*
* \return true if items position has changed
*/
bool advance();
protected:
/**
* If the item is changed we want to get notified.
*
* \param change
* \param value
* \return
*/
QVariant itemChange( GraphicsItemChange change, const QVariant &value );
/**
* If the WQtNetworkItem is moved, then the contained ports have to update
* the connected WQtNetworkArrows for correct alignment.
*
* \param mouseEvent the mouse event
*/
void mouseMoveEvent( QGraphicsSceneMouseEvent *mouseEvent );
/**
* If the cursor enters the item, the item gets a green color.
*
* \param event the hover event
*/
void hoverEnterEvent( QGraphicsSceneHoverEvent *event );
/**
* If the cursor leaves the item, the item gets his default color.
*
* \param event the hover event
*/
void hoverLeaveEvent( QGraphicsSceneHoverEvent *event );
/**
* This method changes the coloration of gradient.
*
* \param color the choosen color
*/
void changeColor( QColor color );
/**
* Draw some customized stuff in the scene.
*
* \param painter
* \param option
* \param w
*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* w );
private:
boost::shared_ptr< WModule > m_module; //!< the module
QList< WQtNetworkInputPort *> m_inPorts; //!< the input ports of the item
QList< WQtNetworkOutputPort *> m_outPorts; //!< the output ports of the item
QLinearGradient m_gradient; //!< the gradient for a nice coloring of the item
QColor m_color; //!< the current color
QRectF m_rect; //!< the size of the items rect
float m_width; //!< the width of the rect
float m_height; //!< the height of the rect
QGraphicsTextItem *m_text; //!< the caption
QPointF m_newPos; //!< the new position in the WQtNetworkScene
WQtNetworkEditor *m_networkEditor; //!< the related WQtNetworkEditor
public:
/**
* Constructs new item in the network scene.
*
* \param editor the editor containing this item
* \param module the module represented by the item
*/
WQtNetworkItem( WQtNetworkEditor *editor, boost::shared_ptr< WModule > module );
/**
* Destructor.
*/
virtual ~WQtNetworkItem();
/**
* This customize the return value of type()
*/
enum
{
Type = UserType + 20
};
/**
* Reimplementation from QGraphicsItem
* \return the type of the item as int
*/
int type() const;
/**
* Add a port to the item.
*
* \param inPort the input port
*/
void addInputPort( WQtNetworkInputPort* inPort );
/**
* Add a port to the item.
*
* \param outPort the output port
*/
void addOutputPort( WQtNetworkOutputPort* outPort );
/**
* Returns the item inports.
* \return the item inports
*/
QList< WQtNetworkInputPort* > getInPorts();
/**
* Returns the item outports
* \return the item outports
*/
QList< WQtNetworkOutputPort* > getOutPorts();
/**
* This method aligns the in- and outports as well as the modulename
* in a regular way.
*/
void fitLook();
/**
* Set the QGraphicsTextItem ( the caption ) of the item
*
* \param text the caption
*/
void setTextItem( QGraphicsTextItem* text );
/**
* Get the caption as QString
*
* \return the caption.
*/
QString getText();
/**
* Get the WModule represented by this object.
* \return the related WModule
*/
boost::shared_ptr< WModule > getModule();
/**
* Here the module can be enabled when the WModule is ready.
* \param active true if module is ready.