]> Creatis software - cpPlugins.git/blobdiff - lib/cpPipelineEditor/Block.cxx
Now it's broken :-(
[cpPlugins.git] / lib / cpPipelineEditor / Block.cxx
similarity index 54%
rename from appli/cpPipelineEditor/QNEBlock.cxx
rename to lib/cpPipelineEditor/Block.cxx
index 67f4a9bd477d873a924b5e357298233797170128..96e60f8c3d2698c6cca5edc6d8b80f1dfe775f55 100644 (file)
@@ -1,30 +1,4 @@
-/* Copyright (c) 2012, STANISLAW ADASZEWSKI\r
-   All rights reserved.\r
-\r
-   Redistribution and use in source and binary forms, with or without\r
-   modification, are permitted provided that the following conditions are met:\r
-   * Redistributions of source code must retain the above copyright\r
-   notice, this list of conditions and the following disclaimer.\r
-   * Redistributions in binary form must reproduce the above copyright\r
-   notice, this list of conditions and the following disclaimer in the\r
-   documentation and/or other materials provided with the distribution.\r
-   * Neither the name of STANISLAW ADASZEWSKI nor the\r
-   names of its contributors may be used to endorse or promote products\r
-   derived from this software without specific prior written permission.\r
-\r
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-   DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY\r
-   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
-   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-*/\r
-\r
-#include "QNEBlock.h"\r
+#include "Block.h"\r
 \r
 #include <QPen>\r
 #include <QGraphicsScene>\r
 #include <QPainter>\r
 #include <QStyleOptionGraphicsItem>\r
 \r
-#include "QNEPort.h"\r
-#include "QNEConnection.h"\r
+#include "Port.h"\r
+#include "Connection.h"\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEBlock::\r
-QNEBlock( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )\r
+cpPipelineEditor::Block::\r
+Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )\r
   : Superclass( parent, scene ),\r
     m_HorzMargin( 20 ),\r
     m_VertMargin( 5 ),\r
@@ -75,27 +49,26 @@ QNEBlock( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEBlock::\r
-~QNEBlock( )\r
+cpPipelineEditor::Block::\r
+~Block( )\r
 {\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 setNamePort( const QString& txt )\r
 {\r
   if( this->m_NamePort == NULL )\r
-    this->m_NamePort = new QNENamePort( this );\r
+    this->m_NamePort = new NamePort( this );\r
   this->m_NamePort->setName( txt );\r
-  this->m_Filter->SetName( txt.toStdString( ) );\r
   this->_configPort( this->m_NamePort );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::InputPort* cpPipelineEditor::Block::\r
 addInputPort( const QString& txt )\r
 {\r
-  QNEInputPort* ip = new QNEInputPort( this );\r
+  InputPort* ip = new InputPort( this );\r
   ip->setExtendedName(\r
     (\r
       txt.toStdString( ) +\r
@@ -110,10 +83,10 @@ addInputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::OutputPort* cpPipelineEditor::Block::\r
 addOutputPort( const QString& txt )\r
 {\r
-  QNEOutputPort* op = new QNEOutputPort( this );\r
+  OutputPort* op = new OutputPort( this );\r
   op->setExtendedName(\r
     (\r
       txt.toStdString( ) +\r
@@ -128,37 +101,7 @@ addOutputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-bool PipelineEditor::QNEBlock::\r
-extendInputPort( const QString& txt, QNEConnection* conn )\r
-{\r
-  auto p = this->m_InputPorts.find( txt.toStdString( ) );\r
-  auto i = this->m_ExtInputPorts.find( txt.toStdString( ) );\r
-  if( p != this->m_InputPorts.end( ) && i == this->m_ExtInputPorts.end( ) )\r
-  {\r
-    this->m_ExtInputPorts[ txt.toStdString( ) ] = conn;\r
-    return( true );\r
-  }\r
-  else\r
-    return( false );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-bool PipelineEditor::QNEBlock::\r
-extendOutputPort( const QString& txt, QNEConnection* conn )\r
-{\r
-  auto p = this->m_OutputPorts.find( txt.toStdString( ) );\r
-  auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) );\r
-  if( p != this->m_OutputPorts.end( ) && i == this->m_ExtOutputPorts.end( ) )\r
-  {\r
-    this->m_ExtOutputPorts[ txt.toStdString( ) ] = conn;\r
-    return( true );\r
-  }\r
-  else\r
-    return( false );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::InputPort* cpPipelineEditor::Block::\r
 inputPort( const QString& txt )\r
 {\r
   auto i = this->m_InputPorts.find( txt.toStdString( ) );\r
@@ -169,7 +112,7 @@ inputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+cpPipelineEditor::OutputPort* cpPipelineEditor::Block::\r
 outputPort( const QString& txt )\r
 {\r
   auto o = this->m_OutputPorts.find( txt.toStdString( ) );\r
@@ -180,14 +123,14 @@ outputPort( const QString& txt )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-QString PipelineEditor::QNEBlock::\r
+QString cpPipelineEditor::Block::\r
 namePort( ) const\r
 {\r
   return( this->m_NamePort->name( ) );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-const PipelineEditor::QNEInputPort* PipelineEditor::QNEBlock::\r
+const cpPipelineEditor::InputPort* cpPipelineEditor::Block::\r
 inputPort( const QString& txt ) const\r
 {\r
   auto i = this->m_InputPorts.find( txt.toStdString( ) );\r
@@ -198,7 +141,7 @@ inputPort( const QString& txt ) const
 }\r
 \r
 // -------------------------------------------------------------------------\r
-const PipelineEditor::QNEOutputPort* PipelineEditor::QNEBlock::\r
+const cpPipelineEditor::OutputPort* cpPipelineEditor::Block::\r
 outputPort( const QString& txt ) const\r
 {\r
   auto o = this->m_OutputPorts.find( txt.toStdString( ) );\r
@@ -209,29 +152,7 @@ outputPort( const QString& txt ) const
 }\r
 \r
 // -------------------------------------------------------------------------\r
-const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock::\r
-extendedInputPort( const QString& txt ) const\r
-{\r
-  auto i = this->m_ExtInputPorts.find( txt.toStdString( ) );\r
-  if( i != this->m_ExtInputPorts.end( ) )\r
-    return( i->second );\r
-  else\r
-    return( NULL );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-const PipelineEditor::QNEConnection* PipelineEditor::QNEBlock::\r
-extendedOutputPort( const QString& txt ) const\r
-{\r
-  auto i = this->m_ExtOutputPorts.find( txt.toStdString( ) );\r
-  if( i != this->m_ExtOutputPorts.end( ) )\r
-    return( i->second );\r
-  else\r
-    return( NULL );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 paint(\r
   QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget\r
   )\r
@@ -254,25 +175,25 @@ paint(
 }\r
 \r
 // -------------------------------------------------------------------------\r
-QVariant PipelineEditor::QNEBlock::\r
+QVariant cpPipelineEditor::Block::\r
 itemChange( GraphicsItemChange change, const QVariant& value )\r
 {\r
   return( value );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 _setTypePort( const QString& txt )\r
 {\r
   if( this->m_TypePort == NULL )\r
-    this->m_TypePort = new QNETypePort( this );\r
+    this->m_TypePort = new TypePort( 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
+void cpPipelineEditor::Block::\r
+_configPort( Port* port )\r
 {\r
   port->setBlock( this );\r
 \r
@@ -297,28 +218,28 @@ _configPort( QNEPort* port )
   int y = -this->m_Height / 2 + this->m_VertMargin + port->radius( );\r
   foreach( QGraphicsItem* i, this->children( ) )\r
   {\r
-    QNEPort* p = dynamic_cast< QNEPort* >( i );\r
+    Port* p = dynamic_cast< Port* >( i );\r
     if( p == NULL )\r
       continue;\r
 \r
-    if( dynamic_cast< QNENamePort* >( i ) != NULL )\r
+    if( dynamic_cast< NamePort* >( i ) != NULL )\r
       i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
-    else if( dynamic_cast< QNETypePort* >( i ) != NULL )\r
+    else if( dynamic_cast< TypePort* >( i ) != NULL )\r
     {\r
       i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
       y += h;\r
     }\r
-    else if( dynamic_cast< QNEInputPort* >( i ) != NULL )\r
+    else if( dynamic_cast< InputPort* >( i ) != NULL )\r
       i->setPos( -this->m_Width / 2 - 2 * port->radius( ), y );\r
-    else if( dynamic_cast< QNEOutputPort* >( i ) != NULL )\r
+    else if( dynamic_cast< OutputPort* >( i ) != NULL )\r
       i->setPos( this->m_Width / 2, y );\r
 \r
     /* TODO\r
-       QNEPort* p = dynamic_cast< QNEPort* >( i );\r
+       Port* p = dynamic_cast< Port* >( i );\r
        if( p == NULL )\r
        continue;\r
 \r
-       if( dynamic_cast< QNEOutputPort* >( p ) != NULL )\r
+       if( dynamic_cast< OutputPort* >( p ) != NULL )\r
        p->setPos( this->m_Width / 2 + port->radius( ), y );\r
        else\r
        p->setPos( -this->m_Width / 2 - port->radius( ), y );\r
@@ -329,10 +250,10 @@ _configPort( QNEPort* port )
 }\r
 \r
 // -------------------------------------------------------------------------\r
-void PipelineEditor::QNEBlock::\r
+void cpPipelineEditor::Block::\r
 mouseReleaseEvent( QGraphicsSceneMouseEvent* evt )\r
 {\r
-  if( this->m_Filter.IsNotNull( ) )\r
+  if( this->m_Filter != NULL )\r
     this->m_Filter->SetViewCoords(\r
       this->scenePos( ).x( ), this->scenePos( ).y( )\r
       );\r