/* Copyright (c) 2012, STANISLAW ADASZEWSKI All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of STANISLAW ADASZEWSKI nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __PIPELINEEDITOR__QNEPORT__H__ #define __PIPELINEEDITOR__QNEPORT__H__ #include namespace PipelineEditor { class QNEBlock; class QNEConnection; /** */ class QNEPort : public QGraphicsPathItem { public: typedef QNEPort Self; typedef QGraphicsPathItem Superclass; enum { Type = QGraphicsItem::UserType + 1 }; public: QNEPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~QNEPort( ); void setBlock( QNEBlock* b ); inline QNEBlock* block( ) const { return( this->m_Block ); } virtual void setName( const QString& n ); inline const QString& name( ) const { return( this->m_Name ); } void setPtr( quint64 p ); inline quint64 ptr( ) { return( this->m_Ptr ); } inline int radius( ) const { return( this->m_Radius ); } virtual bool isConnected( QNEPort* other ) = 0; inline int type( ) const { return( this->Type ); } protected: QNEBlock* m_Block; QString m_Name; QGraphicsTextItem* m_Label; int m_Radius; int m_Margin; quint64 m_Ptr; }; /** */ class QNENamePort : public QNEPort { public: typedef QNENamePort Self; typedef QNEPort Superclass; enum { Type = Superclass::Type + 1 }; public: QNENamePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~QNENamePort( ); virtual void setName( const QString& n ); virtual bool isConnected( QNEPort* other ); inline int type( ) const { return( this->Type ); } }; /** */ class QNETypePort : public QNEPort { public: typedef QNETypePort Self; typedef QNEPort Superclass; enum { Type = Superclass::Type + 2 }; public: QNETypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~QNETypePort( ); virtual void setName( const QString& n ); virtual bool isConnected( QNEPort* other ); inline int type( ) const { return( this->Type ); } }; /** */ class QNEInputPort : public QNEPort { public: typedef QNEInputPort Self; typedef QNEPort Superclass; enum { Type = Superclass::Type + 3 }; public: QNEInputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~QNEInputPort( ); virtual void setName( const QString& n ); virtual bool isConnected( QNEPort* other ); inline int type( ) const { return( this->Type ); } void setConnection( QNEConnection* c ); inline QNEConnection* connection( ) { return( this->m_Connection ); } inline const QNEConnection* connection( ) const { return( this->m_Connection ); } inline bool hasConnection( ) const { return( this->m_Connection != NULL ); } protected: QVariant itemChange( GraphicsItemChange change, const QVariant& value ); protected: QNEConnection* m_Connection; }; /** */ class QNEOutputPort : public QNEPort { public: typedef QNEOutputPort Self; typedef QNEPort Superclass; enum { Type = Superclass::Type + 4 }; public: QNEOutputPort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL ); virtual ~QNEOutputPort( ); virtual void setName( const QString& n ); virtual bool isConnected( QNEPort* other ); inline int type( ) const { return( this->Type ); } inline QVector< QNEConnection* >& connections( ) { return( this->m_Connections ); } inline const QVector< QNEConnection* >& connections( ) const { return( this->m_Connections ); } protected: QVariant itemChange( GraphicsItemChange change, const QVariant& value ); protected: QVector< QNEConnection* > m_Connections; }; } // ecapseman #endif // __PIPELINEEDITOR__QNEPORT__H__ // eof - $RCSfile$