]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/Block.cxx
PolyLine updated.
[cpPlugins.git] / lib / cpBaseQtApplication / Block.cxx
index 77a8e5635c113623662713b77c5c964e23df7295..5ee8f08776a639c1c3b8ea217207a9926a8b0465 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,7 +42,13 @@ 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
@@ -112,13 +119,7 @@ cpBaseQtApplication::InputPort* cpBaseQtApplication::Block::
 addInputPort( const QString& txt )\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
+  ip->setExtendedName( "" );\r
   ip->setName( txt );\r
   this->m_InputPorts[ txt.toStdString( ) ] = ip;\r
   this->_configPort( ip );\r
@@ -130,13 +131,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 +283,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 +297,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