X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FcpPipelineEditor%2FQNEBlock.cxx;h=67f4a9bd477d873a924b5e357298233797170128;hb=c06908465eb6da50572779f423d1e2c9e03b68dd;hp=2b7ed51f6bc52f5580e4f9d6145f5086d0af1773;hpb=e3dc1dcc5279b279f0ed7e39ed87b902bab7778c;p=cpPlugins.git diff --git a/appli/cpPipelineEditor/QNEBlock.cxx b/appli/cpPipelineEditor/QNEBlock.cxx index 2b7ed51..67f4a9b 100644 --- a/appli/cpPipelineEditor/QNEBlock.cxx +++ b/appli/cpPipelineEditor/QNEBlock.cxx @@ -33,6 +33,7 @@ #include #include "QNEPort.h" +#include "QNEConnection.h" // ------------------------------------------------------------------------- PipelineEditor::QNEBlock:: @@ -95,6 +96,13 @@ PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock:: addInputPort( const QString& txt ) { QNEInputPort* ip = new QNEInputPort( this ); + ip->setExtendedName( + ( + txt.toStdString( ) + + std::string( "@" ) + + this->namePort( ).toStdString( ) + ).c_str( ) + ); ip->setName( txt ); this->m_InputPorts[ txt.toStdString( ) ] = ip; this->_configPort( ip ); @@ -106,12 +114,49 @@ PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock:: addOutputPort( const QString& txt ) { QNEOutputPort* op = new QNEOutputPort( this ); + op->setExtendedName( + ( + txt.toStdString( ) + + std::string( "@" ) + + this->namePort( ).toStdString( ) + ).c_str( ) + ); op->setName( txt ); this->m_OutputPorts[ txt.toStdString( ) ] = op; this->_configPort( op ); return( op ); } +// ------------------------------------------------------------------------- +bool PipelineEditor::QNEBlock:: +extendInputPort( const QString& txt, QNEConnection* conn ) +{ + auto p = this->m_InputPorts.find( txt.toStdString( ) ); + auto i = this->m_ExtInputPorts.find( txt.toStdString( ) ); + if( p != this->m_InputPorts.end( ) && i == this->m_ExtInputPorts.end( ) ) + { + this->m_ExtInputPorts[ txt.toStdString( ) ] = conn; + return( true ); + } + else + return( false ); +} + +// ------------------------------------------------------------------------- +bool PipelineEditor::QNEBlock:: +extendOutputPort( const QString& txt, QNEConnection* conn ) +{ + auto p = this->m_OutputPorts.find( txt.toStdString( ) ); + auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) ); + if( p != this->m_OutputPorts.end( ) && i == this->m_ExtOutputPorts.end( ) ) + { + this->m_ExtOutputPorts[ txt.toStdString( ) ] = conn; + return( true ); + } + else + return( false ); +} + // ------------------------------------------------------------------------- PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock:: inputPort( const QString& txt ) @@ -134,6 +179,13 @@ outputPort( const QString& txt ) return( NULL ); } +// ------------------------------------------------------------------------- +QString PipelineEditor::QNEBlock:: +namePort( ) const +{ + return( this->m_NamePort->name( ) ); +} + // ------------------------------------------------------------------------- const PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock:: inputPort( const QString& txt ) const @@ -157,10 +209,25 @@ outputPort( const QString& txt ) const } // ------------------------------------------------------------------------- -const QString& PipelineEditor::QNEBlock:: -namePort( ) const +const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock:: +extendedInputPort( const QString& txt ) const { - return( this->m_NamePort->name( ) ); + auto i = this->m_ExtInputPorts.find( txt.toStdString( ) ); + if( i != this->m_ExtInputPorts.end( ) ) + return( i->second ); + else + return( NULL ); +} + +// ------------------------------------------------------------------------- +const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock:: +extendedOutputPort( const QString& txt ) const +{ + auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) ); + if( i != this->m_ExtOutputPorts.end( ) ) + return( i->second ); + else + return( NULL ); } // ------------------------------------------------------------------------- @@ -210,11 +277,13 @@ _configPort( QNEPort* port ) port->setBlock( this ); QFontMetrics fm( this->scene( )->font( ) ); - int w = fm.width( port->name( ) ); + int w = fm.width( port->name( ) ) + ( 4 * port->radius( ) ); int h = fm.height( ); if( w > this->m_Width - this->m_HorzMargin ) this->m_Width = w + this->m_HorzMargin; - this->m_Height += h; + this->m_Height = this->m_InputPorts.size( ) + this->m_OutputPorts.size( ); + this->m_Height += 4; + this->m_Height *= h; QPainterPath pth; pth.addRoundedRect( @@ -232,10 +301,28 @@ _configPort( QNEPort* port ) if( p == NULL ) continue; - if( dynamic_cast< QNEOutputPort* >( p ) != NULL ) - p->setPos( this->m_Width / 2 + port->radius( ), y ); - else - p->setPos( -this->m_Width / 2 - port->radius( ), y ); + if( dynamic_cast< QNENamePort* >( i ) != NULL ) + i->setPos( -this->m_Width / 2 + port->radius( ), y ); + else if( dynamic_cast< QNETypePort* >( i ) != NULL ) + { + i->setPos( -this->m_Width / 2 + port->radius( ), y ); + y += h; + } + else if( dynamic_cast< QNEInputPort* >( i ) != NULL ) + i->setPos( -this->m_Width / 2 - 2 * port->radius( ), y ); + else if( dynamic_cast< QNEOutputPort* >( i ) != NULL ) + i->setPos( this->m_Width / 2, y ); + + /* TODO + QNEPort* p = dynamic_cast< QNEPort* >( i ); + if( p == NULL ) + continue; + + if( dynamic_cast< QNEOutputPort* >( p ) != NULL ) + p->setPos( this->m_Width / 2 + port->radius( ), y ); + else + p->setPos( -this->m_Width / 2 - port->radius( ), y ); + */ y += h; } // rof