]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 25 Jan 2016 22:41:08 +0000 (17:41 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 25 Jan 2016 22:41:08 +0000 (17:41 -0500)
lib/cpPipelineEditor/Canvas.cxx
lib/cpPipelineEditor/Canvas.h
lib/cpPipelineEditor/Editor.cxx
lib/cpPipelineEditor/Editor.h

index 29897fbd163d299bd7cf4761b50c238ce43587de..b8027d959d78b7014d2151143cd34c6e780239c2 100644 (file)
@@ -44,6 +44,49 @@ editor( ) const
   return( this->m_Editor );
 }
 
+// -------------------------------------------------------------------------
+void cpPipelineEditor::Canvas::
+keyPressEvent( QKeyEvent* event )
+{
+  static const int del_key = 16777223;
+  if( event->key( ) == del_key )
+  {
+    auto _items = this->items( );
+    auto i = _items.begin( );
+    while( i != _items.end( ) )
+    {
+      if( ( *i )->isSelected( ) )
+      {
+        Block* b = dynamic_cast< Block* >( *i );
+        Connection* c = dynamic_cast< Connection* >( *i );
+        if( b != NULL )
+        {
+          if( this->m_Editor->deleteFilter( b->namePort( ).toStdString( ) ) )
+            delete b;
+        }
+        else if( c != NULL )
+        {
+          if(
+            this->m_Editor->deleteConnection(
+              c->port1( )->block( )->namePort( ).toStdString( ),
+              c->port2( )->block( )->namePort( ).toStdString( ),
+              c->port1( )->name( ).toStdString( ),
+              c->port2( )->name( ).toStdString( )
+              )
+            )
+            delete c;
+
+        } // fi
+        i = _items.end( );
+      }
+      else
+        i++;
+
+    } // elihw
+
+  } // fi
+}
+
 // -------------------------------------------------------------------------
 void cpPipelineEditor::Canvas::
 wheelEvent( QWheelEvent* event )
index c327a696ae7b0c5ac08fb335f6ce9147c337f3d7..eb57a233b56b57d57ac46de76e48c87f89028bc6 100644 (file)
@@ -27,9 +27,9 @@ namespace cpPipelineEditor
 
   protected:
     /* TODO
-       void keyPressEvent( QKeyEvent* event );
        void timerEvent( QTimerEvent* event );
     */
+    void keyPressEvent( QKeyEvent* event );
     void wheelEvent( QWheelEvent* event );
 
     void dragEnterEvent( QDragEnterEvent* event );
index f74ce6eba238c5005f458a31eb9ca8dd79057ac8..736feccf567f3d70baa0f624896a1acac131945e 100644 (file)
@@ -127,6 +127,31 @@ createFilter( const std::string& filter, const QPointF& pnt )
     return( "" );\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+bool cpPipelineEditor::Editor::\r
+deleteFilter( const std::string& name )\r
+{\r
+  std::cout << name << std::endl;\r
+#error delete filter\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
+#error delete connection\r
+  return( false );\r
+}\r
+\r
 // -------------------------------------------------------------------------\r
 void cpPipelineEditor::Editor::\r
 install( QGraphicsScene* s )\r
index ca273b21fe6d1808429f4a9260dfbd31e2f50bca..bceeecd2e5042ece89b34933493b94bc594e2ee6 100644 (file)
@@ -57,6 +57,11 @@ namespace cpPipelineEditor
       const std::string& filter,\r
       const QPointF& pnt = QPointF( qreal( 0 ), qreal( 0 ) )\r
       );\r
+    bool deleteFilter( const std::string& name );\r
+    bool deleteConnection(\r
+      const std::string& src, const std::string& des,\r
+      const std::string& in, const std::string& out\r
+      );\r
 \r
     void install( QGraphicsScene* s );\r
     bool eventFilter( QObject* o, QEvent* e );\r