#include <QStyleOptionGraphicsItem>\r
\r
#include "QNEPort.h"\r
+#include "QNEConnection.h"\r
\r
// -------------------------------------------------------------------------\r
PipelineEditor::QNEBlock::\r
addInputPort( const QString& txt )\r
{\r
QNEInputPort* ip = new QNEInputPort( this );\r
+ ip->setExtendedName(\r
+ (\r
+ txt.toStdString( ) +\r
+ std::string( "@" ) +\r
+ this->namePort( ).toStdString( )\r
+ ).c_str( )\r
+ );\r
ip->setName( txt );\r
this->m_InputPorts[ txt.toStdString( ) ] = ip;\r
this->_configPort( ip );\r
addOutputPort( const QString& txt )\r
{\r
QNEOutputPort* op = new QNEOutputPort( this );\r
+ op->setExtendedName(\r
+ (\r
+ txt.toStdString( ) +\r
+ std::string( "@" ) +\r
+ this->namePort( ).toStdString( )\r
+ ).c_str( )\r
+ );\r
op->setName( txt );\r
this->m_OutputPorts[ txt.toStdString( ) ] = op;\r
this->_configPort( op );\r
return( op );\r
}\r
\r
+// -------------------------------------------------------------------------\r
+bool PipelineEditor::QNEBlock::\r
+extendInputPort( const QString& txt, QNEConnection* conn )\r
+{\r
+ auto p = this->m_InputPorts.find( txt.toStdString( ) );\r
+ auto i = this->m_ExtInputPorts.find( txt.toStdString( ) );\r
+ if( p != this->m_InputPorts.end( ) && i == this->m_ExtInputPorts.end( ) )\r
+ {\r
+ this->m_ExtInputPorts[ txt.toStdString( ) ] = conn;\r
+ return( true );\r
+ }\r
+ else\r
+ return( false );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+bool PipelineEditor::QNEBlock::\r
+extendOutputPort( const QString& txt, QNEConnection* conn )\r
+{\r
+ auto p = this->m_OutputPorts.find( txt.toStdString( ) );\r
+ auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) );\r
+ if( p != this->m_OutputPorts.end( ) && i == this->m_ExtOutputPorts.end( ) )\r
+ {\r
+ this->m_ExtOutputPorts[ txt.toStdString( ) ] = conn;\r
+ return( true );\r
+ }\r
+ else\r
+ return( false );\r
+}\r
+\r
// -------------------------------------------------------------------------\r
PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
inputPort( const QString& txt )\r
return( NULL );\r
}\r
\r
+// -------------------------------------------------------------------------\r
+QString PipelineEditor::QNEBlock::\r
+namePort( ) const\r
+{\r
+ return( this->m_NamePort->name( ) );\r
+}\r
+\r
// -------------------------------------------------------------------------\r
const PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
inputPort( const QString& txt ) const\r
}\r
\r
// -------------------------------------------------------------------------\r
-const QString& PipelineEditor::QNEBlock::\r
-namePort( ) const\r
+const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock::\r
+extendedInputPort( const QString& txt ) const\r
{\r
- return( this->m_NamePort->name( ) );\r
+ auto i = this->m_ExtInputPorts.find( txt.toStdString( ) );\r
+ if( i != this->m_ExtInputPorts.end( ) )\r
+ return( i->second );\r
+ else\r
+ return( NULL );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock::\r
+extendedOutputPort( const QString& txt ) const\r
+{\r
+ auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) );\r
+ if( i != this->m_ExtOutputPorts.end( ) )\r
+ return( i->second );\r
+ else\r
+ return( NULL );\r
}\r
\r
// -------------------------------------------------------------------------\r
port->setBlock( this );\r
\r
QFontMetrics fm( this->scene( )->font( ) );\r
- int w = fm.width( port->name( ) );\r
+ int w = fm.width( port->name( ) ) + ( 4 * port->radius( ) );\r
int h = fm.height( );\r
if( w > this->m_Width - this->m_HorzMargin )\r
this->m_Width = w + this->m_HorzMargin;\r
- this->m_Height += h;\r
+ this->m_Height = this->m_InputPorts.size( ) + this->m_OutputPorts.size( );\r
+ this->m_Height += 4;\r
+ this->m_Height *= h;\r
\r
QPainterPath pth;\r
pth.addRoundedRect(\r
if( p == NULL )\r
continue;\r
\r
- if( dynamic_cast< QNEOutputPort* >( p ) != NULL )\r
- p->setPos( this->m_Width / 2 + port->radius( ), y );\r
- else\r
- p->setPos( -this->m_Width / 2 - port->radius( ), y );\r
+ if( dynamic_cast< QNENamePort* >( i ) != NULL )\r
+ i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
+ else if( dynamic_cast< QNETypePort* >( i ) != NULL )\r
+ {\r
+ i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
+ y += h;\r
+ }\r
+ else if( dynamic_cast< QNEInputPort* >( i ) != NULL )\r
+ i->setPos( -this->m_Width / 2 - 2 * port->radius( ), y );\r
+ else if( dynamic_cast< QNEOutputPort* >( i ) != NULL )\r
+ i->setPos( this->m_Width / 2, y );\r
+\r
+ /* TODO\r
+ QNEPort* p = dynamic_cast< QNEPort* >( i );\r
+ if( p == NULL )\r
+ continue;\r
+\r
+ if( dynamic_cast< QNEOutputPort* >( p ) != NULL )\r
+ p->setPos( this->m_Width / 2 + port->radius( ), y );\r
+ else\r
+ p->setPos( -this->m_Width / 2 - port->radius( ), y );\r
+ */\r
y += h;\r
\r
} // rof\r