]> Creatis software - cpPlugins.git/blobdiff - lib/cpPipelineEditor/Editor.cxx
MPR objects updated
[cpPlugins.git] / lib / cpPipelineEditor / Editor.cxx
index 9ab6b35537b5af476da1c5c4ed7a7b68ad607fa7..289ee46431d2e8e51dc0e5f51eb64a658396cd67 100644 (file)
@@ -11,6 +11,7 @@
 #include <QGraphicsSceneResizeEvent>\r
 #include <QGraphicsSceneWheelEvent>\r
 #include <QInputDialog>\r
+#include <QMessageBox>\r
 \r
 #include "Port.h"\r
 #include "Connection.h"\r
@@ -73,10 +74,16 @@ setWorkspace( TWorkspace* ws )
   auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( );\r
   auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( );\r
   for( ; vIt != vIt_end; ++vIt )\r
-    this->_createBlock(\r
+  {\r
+    auto b = this->_createBlock(\r
       dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ),\r
+      vIt->first.c_str( ),\r
       QPointF( vIt->second->GetViewX( ), vIt->second->GetViewY( ) )\r
       );\r
+    if( b != NULL )\r
+      this->m_Graph->SetVertex( vIt->first, b );\r
+\r
+  } // rof\r
 \r
   // Add edges\r
   auto rIt = this->m_Workspace->GetGraph( )->BeginEdgesRows( );\r
@@ -112,20 +119,51 @@ setWorkspace( TWorkspace* ws )
 \r
 // -------------------------------------------------------------------------\r
 std::string cpPipelineEditor::Editor::\r
-createFilter( const std::string& filter, const QPointF& pnt )\r
+createFilter(\r
+  const std::string& category,\r
+  const std::string& filter,\r
+  const QPointF& pnt\r
+  )\r
 {\r
   std::string name = filter;\r
   while( this->m_Workspace->HasFilter( name ) )\r
     name += std::string( "_" );\r
-  if( this->m_Workspace->CreateFilter( filter, name ) )\r
+  if( this->m_Workspace->CreateFilter( category, filter, name ) )\r
   {\r
-    this->_createBlock( this->m_Workspace->GetFilter( name ), pnt );\r
+    auto b = this->_createBlock(\r
+      this->m_Workspace->GetFilter( name ),\r
+      name.c_str( ),\r
+      pnt\r
+      );\r
     return( name );\r
   }\r
   else\r
     return( "" );\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+bool cpPipelineEditor::Editor::\r
+deleteFilter( const std::string& name )\r
+{\r
+  std::cout << name << std::endl;\r
+  return( false );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+bool cpPipelineEditor::Editor::\r
+deleteConnection(\r
+  const std::string& src, const std::string& des,\r
+  const std::string& in, const std::string& out\r
+  )\r
+{\r
+  std::cout\r
+    << src << " "\r
+    << des << " "\r
+    << in << " "\r
+    << out << std::endl;\r
+  return( false );\r
+}\r
+\r
 // -------------------------------------------------------------------------\r
 void cpPipelineEditor::Editor::\r
 install( QGraphicsScene* s )\r
@@ -149,19 +187,19 @@ itemAt( const QPointF& pos )
 \r
 // -------------------------------------------------------------------------\r
 cpPipelineEditor::Block* cpPipelineEditor::Editor::\r
-_createBlock( TFilter* f, const QPointF& pnt )\r
+_createBlock( TFilter* f, const QString& name, const QPointF& pnt )\r
 {\r
   if( f == NULL )\r
     return( NULL );\r
 \r
   // Add block\r
-  Block* b = new Block( f, 0, this->m_Scene );\r
+  Block* b = new Block( f, name, 0, this->m_Scene );\r
+  b->setEditor( this );\r
   b->setPos( pnt );\r
 \r
   // Mark exposed inputs\r
   auto& e_in = this->m_Workspace->GetExposedInputPorts( );\r
-  std::set< std::string > f_in;\r
-  f->GetInputsNames( f_in );\r
+  auto f_in = f->GetInputsNames( );\r
   for( auto iIt = f_in.begin( ); iIt != f_in.end( ); ++iIt )\r
   {\r
     auto eIt = e_in.begin( );\r
@@ -180,8 +218,7 @@ _createBlock( TFilter* f, const QPointF& pnt )
 \r
   // Mark exposed outputs\r
   auto& e_out = this->m_Workspace->GetExposedOutputPorts( );\r
-  std::set< std::string > f_out;\r
-  f->GetOutputsNames( f_out );\r
+  auto f_out = f->GetOutputsNames( );\r
   for( auto iIt = f_out.begin( ); iIt != f_out.end( ); ++iIt )\r
   {\r
     auto eIt = e_out.begin( );\r
@@ -198,8 +235,6 @@ _createBlock( TFilter* f, const QPointF& pnt )
 \r
   } // rof\r
 \r
-  // Keep a trace of this visual graph\r
-  this->m_Graph->SetVertex( f->GetName( ), b );\r
   return( b );\r
 }\r
 \r
@@ -232,6 +267,40 @@ eventFilter( QObject* o, QEvent* e )
   return( this->Superclass::eventFilter( o, e ) );\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+updateFilter( const std::string& filter_name )\r
+{\r
+  emit execFilter( filter_name );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+showOutputData(\r
+  const std::string& filter_name, const std::string& output_name\r
+  )\r
+{\r
+  emit showFilterOutput( filter_name, output_name );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+hideOutputData(\r
+  const std::string& filter_name, const std::string& output_name\r
+  )\r
+{\r
+  emit hideFilterOutput( filter_name, output_name );\r
+}\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Editor::\r
+visualPropertiesOutputData(\r
+  const std::string& filter_name, const std::string& output_name\r
+  )\r
+{\r
+  emit visualPropertiesFilterOutput( filter_name, output_name );\r
+}\r
+\r
 // -------------------------------------------------------------------------\r
 cpPipelineEditor_Editor_Callback_CODE( ContextMenu )\r
 {\r
@@ -311,15 +380,11 @@ cpPipelineEditor_Editor_Callback_CODE( MouseDoubleClick )
           old_name.toStdString( ),\r
           new_name.toStdString( )\r
           );\r
-        if( ok )\r
-        {\r
-          block->setNamePort( new_name );\r
-          this->m_Workspace->RenameFilter(\r
-            old_name.toStdString( ),\r
-            new_name.toStdString( )\r
-            );\r
-\r
-        } // fi\r
+        block->setNamePort( new_name );\r
+        this->m_Workspace->RenameFilter(\r
+          old_name.toStdString( ),\r
+          new_name.toStdString( )\r
+          );\r
 \r
       } // fi\r
     }\r