#include <QStyleOptionGraphicsItem>\r
#include <QGraphicsWidget>\r
\r
+#include <cpPlugins/ParametersQtDialog.h>\r
+\r
#include "Port.h"\r
#include "Connection.h"\r
+#include "Editor.h"\r
\r
// -------------------------------------------------------------------------\r
cpPipelineEditor::Block::\r
-Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )\r
+Block(\r
+ TFilter* filter, const QString& name,\r
+ QGraphicsItem* parent, QGraphicsScene* scene\r
+ )\r
: Superclass( parent, scene ),\r
m_HorzMargin( 20 ),\r
m_VertMargin( 5 ),\r
m_NamePort( NULL ),\r
- m_TypePort( NULL ),\r
- m_Filter( filter )\r
+ m_Filter( filter ),\r
+ m_Editor( NULL )\r
{\r
QPainterPath p;\r
p.addRoundedRect( -50, -15, 100, 30, 5, 5 );\r
this->m_Height = this->m_VertMargin;\r
\r
// Configure names\r
- this->setNamePort( this->m_Filter->GetName( ) );\r
- this->_setTypePort( this->m_Filter->GetClassName( ) );\r
+ this->setNamePort( name );\r
+ this->_setTypeInfo( this->m_Filter->GetClassName( ) );\r
\r
// Add input ports\r
- std::set< std::string > inputs;\r
- this->m_Filter->GetInputsNames( inputs );\r
+ auto inputs = this->m_Filter->GetInputsNames( );\r
for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt )\r
this->addInputPort( iIt->c_str( ) );\r
\r
// Add output ports\r
- std::set< std::string > outputs;\r
- this->m_Filter->GetOutputsNames( outputs );\r
+ auto outputs = this->m_Filter->GetOutputsNames( );\r
for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )\r
this->addOutputPort( oIt->c_str( ) );\r
}\r
{\r
}\r
\r
+// -------------------------------------------------------------------------\r
+cpPipelineEditor::Editor* cpPipelineEditor::Block::\r
+editor( )\r
+{\r
+ return( this->m_Editor );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+const cpPipelineEditor::Editor* cpPipelineEditor::Block::\r
+editor( ) const\r
+{\r
+ return( this->m_Editor );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Block::\r
+setEditor( cpPipelineEditor::Editor* editor )\r
+{\r
+ this->m_Editor = editor;\r
+}\r
+\r
// -------------------------------------------------------------------------\r
void cpPipelineEditor::Block::\r
setNamePort( const QString& txt )\r
\r
// -------------------------------------------------------------------------\r
void cpPipelineEditor::Block::\r
-_setTypePort( const QString& txt )\r
+_setTypeInfo( const QString& txt )\r
{\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
+ this->setToolTip( txt );\r
}\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
\r
if( selectedAction == configureAction )\r
{\r
- auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
+ auto dlg = this->m_Filter->CreateQtDialog( );\r
+ dlg->exec( );\r
}\r
else if( selectedAction == updateAction )\r
- {\r
- } // fi\r
+ this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
}\r
\r
// eof - $RCSfile$\r