m_HorzMargin( 20 ),\r
m_VertMargin( 5 ),\r
m_NamePort( NULL ),\r
- m_TypePort( NULL ),\r
m_Filter( filter ),\r
m_Editor( NULL )\r
{\r
\r
// Configure names\r
this->setNamePort( this->m_Filter->GetName( ) );\r
- this->_setTypePort( this->m_Filter->GetClassName( ) );\r
+ this->_setTypeInfo( this->m_Filter->GetClassName( ) );\r
\r
// Add input ports\r
auto inputs = this->m_Filter->GetInputsNames( );\r
\r
// -------------------------------------------------------------------------\r
void cpPipelineEditor::Block::\r
-_setTypePort( const QString& txt )\r
+_setTypeInfo( const QString& txt )\r
{\r
- /* TODO\r
- if( this->m_TypePort == NULL )\r
- this->m_TypePort = new TypePort( this );\r
- this->m_TypePort->setName( txt );\r
- this->_configPort( this->m_TypePort );\r
- */\r
this->setToolTip( txt );\r
}\r
\r
port->setBlock( this );\r
\r
QFontMetrics fm( this->scene( )->font( ) );\r
- int w = fm.width( port->name( ) ) + ( 4 * port->radius( ) );\r
+ this->m_Width = 0;\r
+ foreach( QGraphicsItem* i, this->children( ) )\r
+ {\r
+ Port* p = dynamic_cast< Port* >( i );\r
+ if( p == NULL )\r
+ continue;\r
+ int w = fm.width( p->name( ) ) + ( 4 * p->radius( ) );\r
+ if( w > this->m_Width - this->m_HorzMargin )\r
+ this->m_Width = w + this->m_HorzMargin;\r
+\r
+ } // rof\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 = this->m_InputPorts.size( ) + this->m_OutputPorts.size( );\r
- this->m_Height += 4;\r
+ this->m_Height += 3;\r
this->m_Height *= h;\r
\r
QPainterPath pth;\r
continue;\r
\r
if( dynamic_cast< NamePort* >( i ) != NULL )\r
- i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
- else if( dynamic_cast< TypePort* >( i ) != NULL )\r
{\r
i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
y += h;\r
QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
\r
if( selectedAction == configureAction )\r
- {\r
auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
- }\r
else if( selectedAction == updateAction )\r
this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
}\r
class Editor;\r
class Port;\r
class NamePort;\r
- class TypePort;\r
class InputPort;\r
class OutputPort;\r
\r
\r
protected:\r
QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
- void _setTypePort( const QString& txt );\r
+ void _setTypeInfo( const QString& txt );\r
void _configPort( Port* port );\r
\r
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt );\r
int m_Height;\r
\r
NamePort* m_NamePort;\r
- TypePort* m_TypePort;\r
std::map< std::string, InputPort* > m_InputPorts;\r
std::map< std::string, OutputPort* > m_OutputPorts;\r
\r
this->setZValue( -1 );\r
this->m_Port1 = NULL;\r
this->m_Port2 = NULL;\r
+ this->setFlag( QGraphicsItem::ItemIsSelectable );\r
}\r
\r
// -------------------------------------------------------------------------\r
return( this->m_Port2 );\r
}\r
\r
+#include <QPainter>\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Connection::\r
+paint(\r
+ QPainter* painter,\r
+ const QStyleOptionGraphicsItem* option,\r
+ QWidget* widget\r
+ )\r
+{\r
+ Q_UNUSED( option );\r
+ Q_UNUSED( widget );\r
+\r
+ if( this->isSelected( ) )\r
+ painter->setPen( QPen( Qt::red, 5 ) );\r
+ else\r
+ painter->setPen( QPen( Qt::black, 2 ) );\r
+ this->setBrush( Qt::NoBrush );\r
+ painter->drawPath( this->path( ) );\r
+}\r
+\r
// eof - $RCSfile$\r
inline int type( ) const\r
{ return( this->Type ); }\r
\r
+ virtual void paint(\r
+ QPainter* painter,\r
+ const QStyleOptionGraphicsItem* option,\r
+ QWidget* widget\r
+ );\r
+\r
private:\r
QPointF m_Pos1;\r
QPointF m_Pos2;\r
return( false );\r
}\r
\r
-// -------------------------------------------------------------------------\r
-cpPipelineEditor::TypePort::\r
-TypePort( QGraphicsItem* parent, QGraphicsScene* scene )\r
- : Superclass( parent, scene )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-cpPipelineEditor::TypePort::\r
-~TypePort( )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void cpPipelineEditor::TypePort::\r
-_updateLabels( )\r
-{\r
- QFont font( this->scene( )->font( ) );\r
- font.setItalic( true );\r
- this->m_Label->setFont( font );\r
- this->m_ExtendedLabel->setFont( font );\r
- this->setPath( QPainterPath( ) );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-bool cpPipelineEditor::TypePort::\r
-isConnected( Port* other )\r
-{\r
- return( false );\r
-}\r
-\r
// -------------------------------------------------------------------------\r
cpPipelineEditor::InputPort::\r
InputPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
virtual void _updateLabels( );\r
};\r
\r
- /**\r
- */\r
- class TypePort\r
- : public Port\r
- {\r
- public:\r
- typedef TypePort Self;\r
- typedef Port Superclass;\r
-\r
- enum { Type = Superclass::Type + 2 };\r
-\r
- public:\r
- TypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
- virtual ~TypePort( );\r
-\r
- virtual bool isConnected( Port* other );\r
- inline int type( ) const\r
- { return( this->Type ); }\r
-\r
- protected:\r
- virtual void _updateLabels( );\r
- };\r
-\r
/**\r
*/\r
class InputPort\r