]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 12 Jan 2016 23:52:46 +0000 (18:52 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 12 Jan 2016 23:52:46 +0000 (18:52 -0500)
appli/cpPipelineEditor/QNEBlock.cxx
appli/cpPipelineEditor/QNEBlock.h
appli/cpPipelineEditor/QNEConnection.cxx
appli/cpPipelineEditor/QNEConnection.h
appli/cpPipelineEditor/QNodesEditor.cxx
appli/cpPipelineEditor/QNodesEditor.h
appli/cpPipelineEditor/QNodesEditorCanvas.cxx
appli/cpPipelineEditor/cpPipelineEditor.cxx
lib/cpPlugins/Interface/WorkspaceIO.cxx

index 5d6f16c4e6b1e674ae0c49e8ab7c6608de89cbe2..2b7ed51f6bc52f5580e4f9d6145f5086d0af1773 100644 (file)
@@ -55,6 +55,22 @@ QNEBlock( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )
 \r
   this->m_Width = this->m_HorzMargin;\r
   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
+\r
+  // Add input ports\r
+  std::set< std::string > inputs;\r
+  this->m_Filter->GetInputsNames( inputs );\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
+  for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )\r
+    this->addOutputPort( oIt->c_str( ) );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -75,75 +91,76 @@ setNamePort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
-setTypePort( const QString& txt )\r
-{\r
-  if( this->m_TypePort == NULL )\r
-    this->m_TypePort = new QNETypePort( this );\r
-  this->m_TypePort->setName( txt );\r
-  this->_configPort( this->m_TypePort );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
 addInputPort( const QString& txt )\r
 {\r
   QNEInputPort* ip = new QNEInputPort( this );\r
   ip->setName( txt );\r
-  this->m_InputPorts.push_back( ip );\r
+  this->m_InputPorts[ txt.toStdString( ) ] = ip;\r
   this->_configPort( ip );\r
+  return( ip );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
 addOutputPort( const QString& txt )\r
 {\r
   QNEOutputPort* op = new QNEOutputPort( this );\r
   op->setName( txt );\r
-  this->m_OutputPorts.push_back( op );\r
+  this->m_OutputPorts[ txt.toStdString( ) ] = op;\r
   this->_configPort( op );\r
+  return( op );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-QVector< PipelineEditor::QNEPort* > PipelineEditor::QNEBlock::\r
-ports( )\r
+PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+inputPort( const QString& txt )\r
 {\r
-  QVector< QNEPort* > res;\r
-  foreach( QGraphicsItem* i, this->childItems( ) )\r
-  {\r
-    QNEPort* p = dynamic_cast< QNEPort* >( i );\r
-    if( p != NULL )\r
-      res.append( p );\r
-\r
-  } // rof\r
-  return( res );\r
+  auto i = this->m_InputPorts.find( txt.toStdString( ) );\r
+  if( i != this->m_InputPorts.end( ) )\r
+    return( i->second );\r
+  else\r
+    return( NULL );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEBlock* PipelineEditor::QNEBlock::\r
-clone( )\r
+PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+outputPort( const QString& txt )\r
 {\r
-  QNEBlock* b = new QNEBlock( this->m_Filter, 0, this->scene( ) );\r
-  foreach( QGraphicsItem* i, this->childItems( ) )\r
-  {\r
-    QNENamePort* np = dynamic_cast< QNENamePort* >( i );\r
-    if( np != NULL )\r
-      b->setNamePort( np->name( ) );\r
-\r
-    QNETypePort* tp = dynamic_cast< QNETypePort* >( i );\r
-    if( tp != NULL )\r
-      b->setTypePort( tp->name( ) );\r
+  auto o = this->m_OutputPorts.find( txt.toStdString( ) );\r
+  if( o != this->m_OutputPorts.end( ) )\r
+    return( o->second );\r
+  else\r
+    return( NULL );\r
+}\r
 \r
-    QNEInputPort* ip = dynamic_cast< QNEInputPort* >( i );\r
-    if( ip != NULL )\r
-      b->addInputPort( ip->name( ) );\r
+// -------------------------------------------------------------------------\r
+const PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+inputPort( const QString& txt ) const\r
+{\r
+  auto i = this->m_InputPorts.find( txt.toStdString( ) );\r
+  if( i != this->m_InputPorts.end( ) )\r
+    return( i->second );\r
+  else\r
+    return( NULL );\r
+}\r
 \r
-    QNEOutputPort* op = dynamic_cast< QNEOutputPort* >( i );\r
-    if( op != NULL )\r
-      b->addOutputPort( op->name( ) );\r
+// -------------------------------------------------------------------------\r
+const PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+outputPort( const QString& txt ) const\r
+{\r
+  auto o = this->m_OutputPorts.find( txt.toStdString( ) );\r
+  if( o != this->m_OutputPorts.end( ) )\r
+    return( o->second );\r
+  else\r
+    return( NULL );\r
+}\r
 \r
-  } // rof\r
-  return( b );\r
+// -------------------------------------------------------------------------\r
+const QString& PipelineEditor::QNEBlock::\r
+namePort( ) const\r
+{\r
+  return( this->m_NamePort->name( ) );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -176,6 +193,16 @@ itemChange( GraphicsItemChange change, const QVariant& value )
   return( value );\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+void PipelineEditor::QNEBlock::\r
+_setTypePort( const QString& txt )\r
+{\r
+  if( this->m_TypePort == NULL )\r
+    this->m_TypePort = new QNETypePort( this );\r
+  this->m_TypePort->setName( txt );\r
+  this->_configPort( this->m_TypePort );\r
+}\r
+\r
 // -------------------------------------------------------------------------\r
 void PipelineEditor::QNEBlock::\r
 _configPort( QNEPort* port )\r
@@ -214,4 +241,15 @@ _configPort( QNEPort* port )
   } // rof\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+void PipelineEditor::QNEBlock::\r
+mouseReleaseEvent( QGraphicsSceneMouseEvent* evt )\r
+{\r
+  if( this->m_Filter.IsNotNull( ) )\r
+    this->m_Filter->SetViewCoords(\r
+      this->scenePos( ).x( ), this->scenePos( ).y( )\r
+      );\r
+  this->Superclass::mouseReleaseEvent( evt );\r
+}\r
+\r
 // eof - $RCSfile$\r
index dfe51991deb45c99bc576038c46b6a26853c4029..d1a398ee81330715559be639ebf10dc88a896abe 100644 (file)
@@ -56,30 +56,15 @@ namespace PipelineEditor
     virtual ~QNEBlock( );\r
 \r
     void setNamePort( const QString& txt );\r
-    void setTypePort( const QString& txt );\r
-    void addInputPort( const QString& txt );\r
-    void addOutputPort( const QString& txt );\r
-    QVector< QNEPort* > ports( );\r
-\r
-    inline QNENamePort* namePort( )\r
-      { return( this->m_NamePort ); }\r
-    inline QNETypePort* typePort( )\r
-      { return( this->m_TypePort ); }\r
-    inline QVector< QNEInputPort* >& inputPorts( )\r
-      { return( this->m_InputPorts ); }\r
-    inline QVector< QNEOutputPort* >& outputPorts( )\r
-      { return( this->m_OutputPorts ); }\r
-\r
-    inline const QNENamePort* namePort( ) const\r
-      { return( this->m_NamePort ); }\r
-    inline const QNETypePort* typePort( ) const\r
-      { return( this->m_TypePort ); }\r
-    inline const QVector< QNEInputPort* >& inputPorts( ) const\r
-      { return( this->m_InputPorts ); }\r
-    inline const QVector< QNEOutputPort* >& outputPorts( ) const\r
-      { return( this->m_OutputPorts ); }\r
-\r
-    QNEBlock* clone( );\r
+    QNEInputPort* addInputPort( const QString& txt );\r
+    QNEOutputPort* addOutputPort( const QString& txt );\r
+    QNEInputPort* inputPort( const QString& txt );\r
+    QNEOutputPort* outputPort( const QString& txt );\r
+\r
+    const QString& namePort( ) const;\r
+    const QNEInputPort* inputPort( const QString& txt ) const;\r
+    const QNEOutputPort* outputPort( const QString& txt ) const;\r
+\r
     inline int type( ) const\r
       { return( this->Type ); }\r
 \r
@@ -91,8 +76,11 @@ namespace PipelineEditor
     \r
   protected:\r
     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
+    void _setTypePort( const QString& txt );\r
     void _configPort( QNEPort* port );\r
 \r
+    virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt );\r
+\r
   private:\r
     int m_HorzMargin;\r
     int m_VertMargin;\r
@@ -101,8 +89,8 @@ namespace PipelineEditor
 \r
     QNENamePort* m_NamePort;\r
     QNETypePort* m_TypePort;\r
-    QVector< QNEInputPort* >  m_InputPorts;\r
-    QVector< QNEOutputPort* > m_OutputPorts;\r
+    std::map< std::string, QNEInputPort* >  m_InputPorts;\r
+    std::map< std::string, QNEOutputPort* > m_OutputPorts;\r
 \r
     TFilter::Pointer m_Filter;\r
   };\r
index eb0f3bb36691cfd2c6f3598282d6b149f723438d..df84c8186102373ffdbd5ee5777280bc06a3d947 100644 (file)
@@ -47,13 +47,12 @@ QNEConnection( QGraphicsItem* parent, QGraphicsScene* scene )
 PipelineEditor::QNEConnection::\r
 ~QNEConnection( )\r
 {\r
-  QNEOutputPort* op = dynamic_cast< QNEOutputPort* >( this->m_Port1 );\r
-  if( op != NULL )\r
-    op->connections( ).remove( op->connections( ).indexOf( this ) );\r
+  if( this->m_Port1 != NULL )\r
+    this->m_Port1->connections( ).\r
+      remove( this->m_Port1->connections( ).indexOf( this ) );\r
 \r
-  QNEInputPort* ip = dynamic_cast< QNEInputPort* >( this->m_Port2 );\r
-  if( ip != NULL )\r
-    ip->setConnection( NULL );\r
+  if( this->m_Port2 != NULL )\r
+    this->m_Port2->setConnection( NULL );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -72,28 +71,26 @@ setPos2( const QPointF& p )
 \r
 // -------------------------------------------------------------------------\r
 void PipelineEditor::QNEConnection::\r
-setPort1( QNEPort* p )\r
+setPort1( QNEOutputPort* p )\r
 {\r
-  QNEOutputPort* op = dynamic_cast< QNEOutputPort* >( p );\r
-  if( op != NULL )\r
+  if( p != NULL )\r
   {\r
-    op->connections( ).append( this );\r
-    this->m_Port1 = op;\r
+    p->connections( ).append( this );\r
+    this->m_Port1 = p;\r
 \r
   } // fi\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
 void PipelineEditor::QNEConnection::\r
-setPort2( QNEPort* p )\r
+setPort2( QNEInputPort* p )\r
 {\r
-  QNEInputPort* ip = dynamic_cast< QNEInputPort* >( p );\r
-  if( ip != NULL )\r
+  if( p != NULL )\r
   {\r
-    if( ip->connection( ) == NULL )\r
+    if( p->connection( ) == NULL )\r
     {\r
-      ip->setConnection( this );\r
-      this->m_Port2 = ip;\r
+      p->setConnection( this );\r
+      this->m_Port2 = p;\r
 \r
     } // fi\r
 \r
@@ -125,14 +122,14 @@ updatePath( )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEPort* PipelineEditor::QNEConnection::\r
+PipelineEditor::QNEOutputPort* PipelineEditor::QNEConnection::\r
 port1( ) const\r
 {\r
   return( this->m_Port1 );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEPort* PipelineEditor::QNEConnection::\r
+PipelineEditor::QNEInputPort* PipelineEditor::QNEConnection::\r
 port2( ) const\r
 {\r
   return( this->m_Port2 );\r
index 7e5a12e41a2a9415f8f6f8001e6ae05809e61556..bbed7dddcb6580136d14a298050b303e7bb11a4d 100644 (file)
@@ -31,7 +31,8 @@
 \r
 namespace PipelineEditor\r
 {\r
-  class QNEPort;\r
+  class QNEInputPort;\r
+  class QNEOutputPort;\r
 \r
   /**\r
    */\r
@@ -50,12 +51,12 @@ namespace PipelineEditor
 \r
     void setPos1( const QPointF& p );\r
     void setPos2( const QPointF& p );\r
-    void setPort1( QNEPort* p );\r
-    void setPort2( QNEPort* p );\r
+    void setPort1( QNEOutputPort* p );\r
+    void setPort2( QNEInputPort* p );\r
     void updatePosFromPorts( );\r
     void updatePath( );\r
-    QNEPort* port1( ) const;\r
-    QNEPort* port2( ) const;\r
+    QNEOutputPort* port1( ) const;\r
+    QNEInputPort* port2( ) const;\r
 \r
     inline int type( ) const\r
       { return( this->Type ); }\r
@@ -63,8 +64,8 @@ namespace PipelineEditor
   private:\r
     QPointF m_Pos1;\r
     QPointF m_Pos2;\r
-    QNEPort* m_Port1;\r
-    QNEPort* m_Port2;\r
+    QNEOutputPort* m_Port1;\r
+    QNEInputPort*  m_Port2;\r
   };\r
 \r
 } // ecapseman\r
index 21008db5e9a27a2b13ccb4b9ad08f7e8e08f85f3..051adde37951d18bb0b5294b46574e29f233f554 100644 (file)
@@ -97,47 +97,25 @@ setWorkspace( TWorkspace* ws )
   auto rIt_end = this->m_Workspace->GetGraph( )->EndEdgesRows( );\r
   for( ; rIt != rIt_end; ++rIt )\r
   {\r
-    if( !this->m_Graph->HasVertexIndex( rIt->first ) )\r
-      continue;\r
     QNEBlock* orig = this->m_Graph->GetVertex( rIt->first );\r
-    if( orig == NULL )\r
-      continue;\r
-    QVector< QNEOutputPort* >& oPorts = orig->outputPorts( );\r
-\r
     auto cIt = rIt->second.begin( );\r
     for( ; cIt != rIt->second.end( ); ++cIt )\r
     {\r
-      if( !this->m_Graph->HasVertexIndex( cIt->first ) )\r
-        continue;\r
       QNEBlock* dest = this->m_Graph->GetVertex( cIt->first );\r
-      if( dest == NULL )\r
-        continue;\r
-      QVector< QNEInputPort* >& iPorts = dest->inputPorts( );\r
-\r
       auto eIt = cIt->second.begin( );\r
       for( ; eIt != cIt->second.end( ); ++eIt )\r
       {\r
-        QNEOutputPort* op = NULL;\r
-        auto opIt = oPorts.begin( );\r
-        for( ; opIt != oPorts.end( ) && op == NULL; ++opIt )\r
-          if( ( *opIt )->name( ).toStdString( ) == eIt->first )\r
-            op = *opIt;\r
-\r
-        QNEInputPort* ip = NULL;\r
-        auto ipIt = iPorts.begin( );\r
-        for( ; ipIt != iPorts.end( ) && ip == NULL; ++ipIt )\r
-          if( ( *ipIt )->name( ).toStdString( ) == eIt->second )\r
-            ip = *ipIt;\r
-\r
+        QNEOutputPort* op = orig->outputPort( eIt->first.c_str( ) );\r
+        QNEInputPort* ip = dest->inputPort( eIt->second.c_str( ) );\r
         if( op == NULL || ip == NULL )\r
           continue;\r
 \r
-        QNEConnection* conn = new QNEConnection( 0, this->m_Scene );\r
-        conn->setPort1( op );\r
-        conn->setPort2( ip );\r
-        conn->updatePosFromPorts( );\r
-        conn->updatePath( );\r
-        this->m_Graph->AddConnection( rIt->first, cIt->first, conn );\r
+        QNEConnection* c = new QNEConnection( 0, this->m_Scene );\r
+        c->setPort1( op );\r
+        c->setPort2( ip );\r
+        c->updatePosFromPorts( );\r
+        c->updatePath( );\r
+        this->m_Graph->AddConnection( rIt->first, cIt->first, c );\r
 \r
       } // rof\r
 \r
@@ -162,25 +140,6 @@ createFilter( const std::string& filter, const QPointF& pnt )
     return( "" );\r
 }\r
 \r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNodesEditor::\r
-synchronizeBlockPositions( )\r
-{\r
-  auto bIt = this->m_Graph->BeginVertices( );\r
-  auto fIt = this->m_Workspace->GetGraph( )->BeginVertices( );\r
-  while(\r
-    bIt != this->m_Graph->EndVertices( ) &&\r
-    fIt != this->m_Workspace->GetGraph( )->EndVertices( )\r
-    )\r
-  {\r
-    auto pos = bIt->second->scenePos( );\r
-    fIt->second->SetViewCoords( pos.x( ), pos.y( ) );\r
-    bIt++;\r
-    fIt++;\r
-\r
-  } // elihw\r
-}\r
-\r
 // -------------------------------------------------------------------------\r
 void PipelineEditor::QNodesEditor::\r
 install( QGraphicsScene* s )\r
@@ -211,22 +170,8 @@ _CreateBlock( TFilter* f, const QPointF& pnt )
 \r
   // Add block\r
   QNEBlock* b = new QNEBlock( f, 0, this->m_Scene );\r
-  b->setNamePort( f->GetName( ) );\r
-  b->setTypePort( f->GetClassName( ) );\r
   b->setPos( pnt );\r
 \r
-  // Add input ports\r
-  std::set< std::string > inputs;\r
-  f->GetInputsNames( inputs );\r
-  for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt )\r
-    b->addInputPort( iIt->c_str( ) );\r
-\r
-  // Add output ports\r
-  std::set< std::string > outputs;\r
-  f->GetOutputsNames( outputs );\r
-  for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )\r
-    b->addOutputPort( oIt->c_str( ) );\r
-\r
   // Keep a trace of this visual graph\r
   this->m_Graph->SetVertex( f->GetName( ), b );\r
 }\r
@@ -245,7 +190,7 @@ _DoubleClick( QGraphicsSceneMouseEvent* evt, QGraphicsItem* item )
 \r
     if( block != NULL )\r
     {\r
-      QString old_name = block->namePort( )->name( );\r
+      QString old_name = block->namePort( );\r
       bool ok;\r
       QString new_name =\r
         QInputDialog::getText(\r
@@ -273,26 +218,6 @@ _DoubleClick( QGraphicsSceneMouseEvent* evt, QGraphicsItem* item )
         } // fi\r
 \r
       } // fi\r
-\r
-      /* TODO\r
-         auto ports = block->ports( );\r
-         std::string name = "";\r
-         for(\r
-         auto pIt = ports.begin( );\r
-         pIt != ports.end( ) && name == "";\r
-         ++pIt\r
-         )\r
-         if(\r
-         ( *pIt )->portFlags( ) && QNEPort::NamePort == QNEPort::NamePort\r
-         )\r
-         name = ( *pIt )->portName( ).toStdString( );\r
-         if( name == "" )\r
-         return;\r
-         TFilter* filter = this->m_Workspace->GetFilter( name );\r
-         if( filter != NULL )\r
-         {\r
-         } // fi\r
-      */\r
     }\r
     else if( port != NULL )\r
     {\r
@@ -463,6 +388,37 @@ eventFilter( QObject* o, QEvent* e )
         } // fi\r
       }\r
       break;\r
+      case Qt::RightButton:\r
+      {\r
+        QNEInputPort* in_port =\r
+          dynamic_cast< QNEInputPort* >( this->itemAt( evt->scenePos( ) ) );\r
+        QNEOutputPort* out_port =\r
+          dynamic_cast< QNEOutputPort* >( this->itemAt( evt->scenePos( ) ) );\r
+        if( in_port != NULL )\r
+        {\r
+          if( in_port->connection( ) == NULL )\r
+          {\r
+            this->m_Conn = new QNEConnection( 0, this->m_Scene );\r
+            this->m_Conn->setPort2( in_port );\r
+            this->m_Conn->setPos1( evt->scenePos( ) );\r
+            this->m_Conn->setPos2( in_port->scenePos( ) );\r
+            this->m_Conn->updatePath( );\r
+            return( true );\r
+\r
+          } // fi\r
+        }\r
+        else if( out_port != NULL )\r
+        {\r
+          this->m_Conn = new QNEConnection( 0, this->m_Scene );\r
+          this->m_Conn->setPort1( out_port );\r
+          this->m_Conn->setPos1( out_port->scenePos( ) );\r
+          this->m_Conn->setPos2( evt->scenePos( ) );\r
+          this->m_Conn->updatePath( );\r
+          return( true );\r
+\r
+        } // fi\r
+      }\r
+      break;\r
       default:\r
         break;\r
 \r
@@ -498,14 +454,14 @@ eventFilter( QObject* o, QEvent* e )
               this->m_Conn->updatePath( );\r
 \r
               this->m_Workspace->Connect(\r
-                port1->block( )->namePort( )->name( ).toStdString( ),\r
-                port2->block( )->namePort( )->name( ).toStdString( ),\r
+                port1->block( )->namePort( ).toStdString( ),\r
+                port2->block( )->namePort( ).toStdString( ),\r
                 port1->name( ).toStdString( ),\r
                 port2->name( ).toStdString( )\r
                 );\r
               this->m_Graph->AddConnection(\r
-                port1->block( )->namePort( )->name( ).toStdString( ),\r
-                port2->block( )->namePort( )->name( ).toStdString( ),\r
+                port1->block( )->namePort( ).toStdString( ),\r
+                port2->block( )->namePort( ).toStdString( ),\r
                 this->m_Conn\r
                 );\r
 \r
@@ -520,6 +476,55 @@ eventFilter( QObject* o, QEvent* e )
         delete this->m_Conn;\r
         this->m_Conn = NULL;\r
         return( true );\r
+      }\r
+      else if( this->m_Conn != NULL && evt->button( ) == Qt::RightButton )\r
+      {\r
+        QNEOutputPort* port1 = this->m_Conn->port1( );\r
+        QNEInputPort* port2 = this->m_Conn->port2( );\r
+\r
+        if( port1 != NULL && port2 == NULL )\r
+        {\r
+          if(\r
+            dynamic_cast< QNEInputPort* >(\r
+              this->itemAt( evt->scenePos( ) )\r
+              ) == NULL\r
+            )\r
+          {\r
+            port2 = new QNEInputPort( NULL, this->m_Scene );\r
+            port2->setName( port1->name( ) );\r
+            port2->setPos( evt->scenePos( ) );\r
+            this->m_Conn->setPos2( evt->scenePos( ) );\r
+            this->m_Conn->setPort2( port2 );\r
+            this->m_Conn->updatePath( );\r
+          }\r
+          else\r
+            delete this->m_Conn;\r
+          this->m_Conn = NULL;\r
+          return( true );\r
+        }\r
+        else if( port1 == NULL && port2 != NULL )\r
+        {\r
+          if(\r
+            dynamic_cast< QNEOutputPort* >(\r
+              this->itemAt( evt->scenePos( ) )\r
+              ) == NULL\r
+            /*&&\r
+            port2->connection( ) == NULL*/\r
+            )\r
+          {\r
+            port1 = new QNEOutputPort( NULL, this->m_Scene );\r
+            port1->setName( port2->name( ) );\r
+            port1->setPos( evt->scenePos( ) );\r
+            this->m_Conn->setPos1( evt->scenePos( ) );\r
+            this->m_Conn->setPort1( port1 );\r
+            this->m_Conn->updatePath( );\r
+          }\r
+          else\r
+            delete this->m_Conn;\r
+          this->m_Conn = NULL;\r
+          return( true );\r
+\r
+        } // fi\r
 \r
       } // fi\r
 \r
index a47b6bf738b666d4a40f290bf6d6dc8c00f31f6e..f338d91a8a08566c437ac41d50584079f946e8d0 100644 (file)
@@ -68,9 +68,8 @@ namespace PipelineEditor
 \r
     std::string createFilter(\r
       const std::string& filter,\r
-      const QPointF& pnt = QPointF( )\r
+      const QPointF& pnt = QPointF( qreal( 0 ), qreal( 0 ) )\r
       );\r
-    void synchronizeBlockPositions( );\r
 \r
     void install( QGraphicsScene* s );\r
     bool eventFilter( QObject* o, QEvent* e );\r
index d253f78f8e9288cf7c7a14bf98c4ceec40d5f494..e5d914fca5f1f58c859e9daa28078a3f2ab7e737 100644 (file)
@@ -104,7 +104,7 @@ dropEvent( QDropEvent* event )
   QList< QTreeWidgetItem* > items = tree->selectedItems( );
   for( auto iIt = items.begin( ); iIt != items.end( ); ++iIt )
     this->m_Editor->createFilter(
-      ( *iIt )->text( 0 ).toStdString( ), event->pos( )
+      ( *iIt )->text( 0 ).toStdString( ), this->mapToScene( event->pos( ) )
       );
 }
 
index 088edbcf999652ec976ddf31bf81b20aa88f3920..6bda2a75087139d916155dfd18612aca04a1ffc7 100644 (file)
@@ -243,7 +243,6 @@ _ActionSaveWorkspace( )
     return;
   std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
 
-  this->m_UI->Canvas->editor( )->synchronizeBlockPositions( );
   std::string err = this->m_Workspace->SaveWorkspace( fname );
   if( err != "" )
     QMessageBox::critical(
index ce81b8639ff7089b188e6953ce1bb255dcabf8cf..7e7a2bd5b63423ac9e7b114b04658a03850a7bba 100644 (file)
@@ -20,8 +20,7 @@ LoadWorkspace( const std::string& fname )
   {
     const char* class_value = filter->Attribute( "class" );
     const char* name_value = filter->Attribute( "name" );
-    float viewX = float( 0 );
-    float viewY = float( 0 );
+    float viewX = float( 0 ), viewY = float( 0 );
     filter->QueryFloatAttribute( "ViewX", &viewX );
     filter->QueryFloatAttribute( "ViewY", &viewY );
     if( class_value != NULL && name_value != NULL )