]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 25 Jan 2016 00:15:51 +0000 (19:15 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 25 Jan 2016 00:15:51 +0000 (19:15 -0500)
lib/cpPipelineEditor/Block.cxx
lib/cpPipelineEditor/Block.h
lib/cpPipelineEditor/Connection.cxx
lib/cpPipelineEditor/Connection.h
lib/cpPipelineEditor/Port.cxx
lib/cpPipelineEditor/Port.h

index bce1197d8f6bb2ae2b34fb8f0447892abf89cb04..0cc3bd4c84c59a3268248acd54147d25bd0735b0 100644 (file)
@@ -20,7 +20,6 @@ Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )
     m_HorzMargin( 20 ),\r
     m_VertMargin( 5 ),\r
     m_NamePort( NULL ),\r
-    m_TypePort( NULL ),\r
     m_Filter( filter ),\r
     m_Editor( NULL )\r
 {\r
@@ -38,7 +37,7 @@ Block( TFilter* filter, QGraphicsItem* parent, QGraphicsScene* scene )
 \r
   // Configure names\r
   this->setNamePort( this->m_Filter->GetName( ) );\r
-  this->_setTypePort( this->m_Filter->GetClassName( ) );\r
+  this->_setTypeInfo( this->m_Filter->GetClassName( ) );\r
 \r
   // Add input ports\r
   auto inputs = this->m_Filter->GetInputsNames( );\r
@@ -207,14 +206,8 @@ itemChange( GraphicsItemChange change, const QVariant& value )
 \r
 // -------------------------------------------------------------------------\r
 void cpPipelineEditor::Block::\r
-_setTypePort( const QString& txt )\r
+_setTypeInfo( const QString& txt )\r
 {\r
-  /* TODO\r
-     if( this->m_TypePort == NULL )\r
-     this->m_TypePort = new TypePort( this );\r
-     this->m_TypePort->setName( txt );\r
-     this->_configPort( this->m_TypePort );\r
-  */\r
   this->setToolTip( txt );\r
 }\r
 \r
@@ -225,12 +218,20 @@ _configPort( Port* port )
   port->setBlock( this );\r
 \r
   QFontMetrics fm( this->scene( )->font( ) );\r
-  int w = fm.width( port->name( ) ) + ( 4 * port->radius( ) );\r
+  this->m_Width = 0;\r
+  foreach( QGraphicsItem* i, this->children( ) )\r
+  {\r
+    Port* p = dynamic_cast< Port* >( i );\r
+    if( p == NULL )\r
+      continue;\r
+    int w = fm.width( p->name( ) ) + ( 4 * p->radius( ) );\r
+    if( w > this->m_Width - this->m_HorzMargin )\r
+      this->m_Width = w + this->m_HorzMargin;\r
+\r
+  } // rof\r
   int h = fm.height( );\r
-  if( w > this->m_Width - this->m_HorzMargin )\r
-    this->m_Width = w + this->m_HorzMargin;\r
   this->m_Height = this->m_InputPorts.size( ) + this->m_OutputPorts.size( );\r
-  this->m_Height += 4;\r
+  this->m_Height += 3;\r
   this->m_Height *= h;\r
 \r
   QPainterPath pth;\r
@@ -250,8 +251,6 @@ _configPort( Port* port )
       continue;\r
 \r
     if( dynamic_cast< NamePort* >( i ) != NULL )\r
-      i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
-    else if( dynamic_cast< TypePort* >( i ) != NULL )\r
     {\r
       i->setPos( -this->m_Width / 2 + port->radius( ), y );\r
       y += h;\r
@@ -286,9 +285,7 @@ contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )
   QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
 \r
   if( selectedAction == configureAction )\r
-  {\r
     auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
-  }\r
   else if( selectedAction == updateAction )\r
     this->m_Editor->updateFilter( this->namePort( ).toStdString( ) );\r
 }\r
index b6a7b33a898f390d0fbddeb714513149c53ea5f1..bbdb0c61038a37d4c6c43576b8ffd801d0cefb78 100644 (file)
@@ -10,7 +10,6 @@ namespace cpPipelineEditor
   class Editor;\r
   class Port;\r
   class NamePort;\r
-  class TypePort;\r
   class InputPort;\r
   class OutputPort;\r
 \r
@@ -59,7 +58,7 @@ namespace cpPipelineEditor
 \r
   protected:\r
     QVariant itemChange( GraphicsItemChange change, const QVariant& value );\r
-    void _setTypePort( const QString& txt );\r
+    void _setTypeInfo( const QString& txt );\r
     void _configPort( Port* port );\r
 \r
     virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt );\r
@@ -72,7 +71,6 @@ namespace cpPipelineEditor
     int m_Height;\r
 \r
     NamePort* m_NamePort;\r
-    TypePort* m_TypePort;\r
     std::map< std::string, InputPort* >  m_InputPorts;\r
     std::map< std::string, OutputPort* > m_OutputPorts;\r
 \r
index 59f66c01af8f4e43a0b806113931e2f368960a83..0d5eea259f9f205824960dbbceafd1e812cc4731 100644 (file)
@@ -15,6 +15,7 @@ Connection( QGraphicsItem* parent, QGraphicsScene* scene )
   this->setZValue( -1 );\r
   this->m_Port1 = NULL;\r
   this->m_Port2 = NULL;\r
+  this->setFlag( QGraphicsItem::ItemIsSelectable );\r
 }\r
 \r
 // -------------------------------------------------------------------------\r
@@ -115,4 +116,25 @@ port2( ) const
   return( this->m_Port2 );\r
 }\r
 \r
+#include <QPainter>\r
+\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Connection::\r
+paint(\r
+  QPainter* painter,\r
+  const QStyleOptionGraphicsItem* option,\r
+  QWidget* widget\r
+  )\r
+{\r
+  Q_UNUSED( option );\r
+  Q_UNUSED( widget );\r
+\r
+  if( this->isSelected( ) )\r
+    painter->setPen( QPen( Qt::red, 5 ) );\r
+  else\r
+    painter->setPen( QPen( Qt::black, 2 ) );\r
+  this->setBrush( Qt::NoBrush );\r
+  painter->drawPath( this->path( ) );\r
+}\r
+\r
 // eof - $RCSfile$\r
index b7eb26e548c9c28406dfb6b43942f83883694757..94b86766181b528c3cf64b7fc176fe4446a6ee0f 100644 (file)
@@ -36,6 +36,12 @@ namespace cpPipelineEditor
     inline int type( ) const\r
       { return( this->Type ); }\r
 \r
+    virtual void paint(\r
+      QPainter* painter,\r
+      const QStyleOptionGraphicsItem* option,\r
+      QWidget* widget\r
+      );\r
+\r
   private:\r
     QPointF m_Pos1;\r
     QPointF m_Pos2;\r
index a2125f7383330bf2082ece043a3b8ec03339fb1b..b447b0ac41a64e4b34f0aa5d3ba862b8d4af37d8 100644 (file)
@@ -124,37 +124,6 @@ isConnected( Port* other )
   return( false );\r
 }\r
 \r
-// -------------------------------------------------------------------------\r
-cpPipelineEditor::TypePort::\r
-TypePort( QGraphicsItem* parent, QGraphicsScene* scene )\r
-  : Superclass( parent, scene )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-cpPipelineEditor::TypePort::\r
-~TypePort( )\r
-{\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-void cpPipelineEditor::TypePort::\r
-_updateLabels( )\r
-{\r
-  QFont font( this->scene( )->font( ) );\r
-  font.setItalic( true );\r
-  this->m_Label->setFont( font );\r
-  this->m_ExtendedLabel->setFont( font );\r
-  this->setPath( QPainterPath( ) );\r
-}\r
-\r
-// -------------------------------------------------------------------------\r
-bool cpPipelineEditor::TypePort::\r
-isConnected( Port* other )\r
-{\r
-  return( false );\r
-}\r
-\r
 // -------------------------------------------------------------------------\r
 cpPipelineEditor::InputPort::\r
 InputPort( QGraphicsItem* parent, QGraphicsScene* scene )\r
index 18bcd94ff9231cd162699262be8880073f9edc05..4daafd0b7a32e57f54b6fdacc485233dc0e2d595 100644 (file)
@@ -89,29 +89,6 @@ namespace cpPipelineEditor
     virtual void _updateLabels( );\r
   };\r
 \r
-  /**\r
-   */\r
-  class TypePort\r
-    : public Port\r
-  {\r
-  public:\r
-    typedef TypePort Self;\r
-    typedef Port     Superclass;\r
-\r
-    enum { Type = Superclass::Type + 2 };\r
-\r
-  public:\r
-    TypePort( QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL );\r
-    virtual ~TypePort( );\r
-\r
-    virtual bool isConnected( Port* other );\r
-    inline int type( ) const\r
-      { return( this->Type ); }\r
-\r
-  protected:\r
-    virtual void _updateLabels( );\r
-  };\r
-\r
   /**\r
    */\r
   class InputPort\r