]> Creatis software - cpPlugins.git/blobdiff - lib/cpPipelineEditor/Block.cxx
...
[cpPlugins.git] / lib / cpPipelineEditor / Block.cxx
index bce1197d8f6bb2ae2b34fb8f0447892abf89cb04..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,8 +41,8 @@ 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
   auto inputs = this->m_Filter->GetInputsNames( );\r
@@ -207,14 +211,8 @@ itemChange( GraphicsItemChange change, const QVariant& value )
 \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
@@ -225,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
@@ -250,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
@@ -287,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