]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/Block.cxx
...
[cpPlugins.git] / lib / cpBaseQtApplication / Block.cxx
index 77a8e5635c113623662713b77c5c964e23df7295..352c566b149e3857642c4d75befe15686b4a9b33 100644 (file)
@@ -13,6 +13,7 @@
 #include <cpBaseQtApplication/Port.h>\r
 #include <cpBaseQtApplication/Connection.h>\r
 #include <cpBaseQtApplication/Editor.h>\r
+#include <cpPlugins/BaseObjects/Widget.h>\r
 \r
 // -------------------------------------------------------------------------\r
 cpBaseQtApplication::Block::\r
@@ -41,12 +42,24 @@ Block(
 \r
   // Configure names\r
   this->setNamePort( name );\r
-  this->_setTypeInfo( this->m_Filter->GetClassName( ) );\r
+  this->_setTypeInfo(\r
+    (\r
+      std::string( this->m_Filter->GetClassCategory( ) ) +\r
+      std::string( "::" ) +\r
+      std::string( this->m_Filter->GetClassName( ) )\r
+      ).c_str( )\r
+    );\r
 \r
   // Add input ports\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
+    this->addInputPort(\r
+      iIt->c_str( ),\r
+      this->m_Filter->IsInputMultiple( iIt->c_str( ) )\r
+      );\r
+\r
+  } // rof\r
 \r
   // Add output ports\r
   auto outputs = this->m_Filter->GetOutputsNames( );\r
@@ -109,16 +122,10 @@ setNamePort( const QString& txt )
 \r
 // -------------------------------------------------------------------------\r
 cpBaseQtApplication::InputPort* cpBaseQtApplication::Block::\r
-addInputPort( const QString& txt )\r
+addInputPort( const QString& txt, bool multiple )\r
 {\r
-  InputPort* ip = new InputPort( this );\r
-  ip->setExtendedName(\r
-    (\r
-      txt.toStdString( ) +\r
-      std::string( "@" ) +\r
-      this->namePort( ).toStdString( )\r
-      ).c_str( )\r
-    );\r
+  InputPort* ip = new InputPort( this, multiple );\r
+  ip->setExtendedName( "" );\r
   ip->setName( txt );\r
   this->m_InputPorts[ txt.toStdString( ) ] = ip;\r
   this->_configPort( ip );\r
@@ -130,13 +137,7 @@ cpBaseQtApplication::OutputPort* cpBaseQtApplication::Block::
 addOutputPort( const QString& txt )\r
 {\r
   OutputPort* op = new OutputPort( this );\r
-  op->setExtendedName(\r
-    (\r
-      txt.toStdString( ) +\r
-      std::string( "@" ) +\r
-      this->namePort( ).toStdString( )\r
-      ).c_str( )\r
-    );\r
+  op->setExtendedName( "" );\r
   op->setName( txt );\r
   this->m_OutputPorts[ txt.toStdString( ) ] = op;\r
   this->_configPort( op );\r
@@ -288,7 +289,7 @@ _configPort( Port* port )
 void cpBaseQtApplication::Block::\r
 mouseReleaseEvent( QGraphicsSceneMouseEvent* evt )\r
 {\r
-  if( this->m_Filter != NULL )\r
+  if( this->m_Filter.IsNotNull( ) )\r
     this->m_Filter->SetViewCoords(\r
       this->scenePos( ).x( ), this->scenePos( ).y( )\r
       );\r
@@ -302,14 +303,27 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )
   QMenu menu;\r
   QAction* configureAction = menu.addAction( "Configure" );\r
   QAction* updateAction = menu.addAction( "Update" );\r
-  QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
+  auto widget =\r
+    dynamic_cast< cpPlugins::BaseObjects::Widget* >(\r
+      this->m_Filter.GetPointer( )\r
+      );\r
+  QAction* enableAction = NULL;\r
+  if( widget != NULL )\r
+    enableAction =\r
+      menu.addAction( ( widget->GetEnabled( ) )? "Disable": "Enable" );\r
 \r
+  QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
   if( selectedAction == configureAction )\r
   {\r
     auto dlg = this->m_Filter->CreateQDialog( );\r
     if( dlg != NULL )\r
       dlg->exec( );\r
   }\r
+  else if( selectedAction == enableAction )\r
+  {\r
+    if( widget != NULL )\r
+      widget->SetEnabled( !( widget->GetEnabled( ) ) );\r
+  }\r
   else if( selectedAction == updateAction )\r
     this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
 }\r