X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPipelineEditor%2FBlock.cxx;h=cd32453cb0c8299d9ec78cdfb7102360b3894c7d;hb=e2fb8817731f6231d34941a208e46b36dad425b2;hp=bce1197d8f6bb2ae2b34fb8f0447892abf89cb04;hpb=273699a71c538630c162de031f0c95014319311d;p=cpPlugins.git diff --git a/lib/cpPipelineEditor/Block.cxx b/lib/cpPipelineEditor/Block.cxx index bce1197..cd32453 100644 --- a/lib/cpPipelineEditor/Block.cxx +++ b/lib/cpPipelineEditor/Block.cxx @@ -9,18 +9,22 @@ #include #include +#include + #include "Port.h" #include "Connection.h" #include "Editor.h" // ------------------------------------------------------------------------- cpPipelineEditor::Block:: -Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene ) +Block( + TFilter* filter, const QString& name, + QGraphicsItem* parent, QGraphicsScene* scene + ) : Superclass( parent, scene ), m_HorzMargin( 20 ), m_VertMargin( 5 ), m_NamePort( NULL ), - m_TypePort( NULL ), m_Filter( filter ), m_Editor( NULL ) { @@ -37,8 +41,8 @@ Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene ) this->m_Height = this->m_VertMargin; // Configure names - this->setNamePort( this->m_Filter->GetName( ) ); - this->_setTypePort( this->m_Filter->GetClassName( ) ); + this->setNamePort( name ); + this->_setTypeInfo( this->m_Filter->GetClassName( ) ); // Add input ports auto inputs = this->m_Filter->GetInputsNames( ); @@ -207,14 +211,8 @@ itemChange( GraphicsItemChange change, const QVariant& value ) // ------------------------------------------------------------------------- void cpPipelineEditor::Block:: -_setTypePort( const QString& txt ) +_setTypeInfo( const QString& txt ) { - /* TODO - if( this->m_TypePort == NULL ) - this->m_TypePort = new TypePort( this ); - this->m_TypePort->setName( txt ); - this->_configPort( this->m_TypePort ); - */ this->setToolTip( txt ); } @@ -225,12 +223,20 @@ _configPort( Port* port ) port->setBlock( this ); QFontMetrics fm( this->scene( )->font( ) ); - int w = fm.width( port->name( ) ) + ( 4 * port->radius( ) ); + this->m_Width = 0; + foreach( QGraphicsItem* i, this->children( ) ) + { + Port* p = dynamic_cast< Port* >( i ); + if( p == NULL ) + continue; + int w = fm.width( p->name( ) ) + ( 4 * p->radius( ) ); + if( w > this->m_Width - this->m_HorzMargin ) + this->m_Width = w + this->m_HorzMargin; + + } // rof int h = fm.height( ); - if( w > this->m_Width - this->m_HorzMargin ) - this->m_Width = w + this->m_HorzMargin; this->m_Height = this->m_InputPorts.size( ) + this->m_OutputPorts.size( ); - this->m_Height += 4; + this->m_Height += 3; this->m_Height *= h; QPainterPath pth; @@ -250,8 +256,6 @@ _configPort( Port* port ) continue; if( dynamic_cast< NamePort* >( i ) != NULL ) - i->setPos( -this->m_Width / 2 + port->radius( ), y ); - else if( dynamic_cast< TypePort* >( i ) != NULL ) { i->setPos( -this->m_Width / 2 + port->radius( ), y ); y += h; @@ -287,7 +291,8 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt ) if( selectedAction == configureAction ) { - auto res = this->m_Filter->ExecConfigurationDialog( NULL ); + auto dlg = this->m_Filter->CreateQtDialog( ); + dlg->exec( ); } else if( selectedAction == updateAction ) this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );