]> Creatis software - cpPlugins.git/blobdiff - lib/cpPipelineEditor/Block.cxx
...
[cpPlugins.git] / lib / cpPipelineEditor / Block.cxx
index f27a7c8878a2ed74200e64abfa3c29a027f2678a..cd32453cb0c8299d9ec78cdfb7102360b3894c7d 100644 (file)
@@ -9,18 +9,22 @@
 #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_Editor( NULL )\r
 {\r
@@ -37,18 +41,16 @@ Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )
   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
@@ -209,12 +211,9 @@ itemChange( GraphicsItemChange change, const QVariant& value )
 \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
@@ -224,12 +223,20 @@ _configPort( Port* port )
   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
@@ -249,8 +256,6 @@ _configPort( Port* port )
       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
@@ -286,7 +291,8 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )
 \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
     this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r