From: asv Date: Tue, 11 Jan 2005 10:53:17 +0000 (+0000) Subject: The following bug was fixed: X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a164acd26c188796149cd962da42f9e5608a61f4;p=modules%2Fsuperv.git The following bug was fixed: for Loop node, removal of an Input Port automatically removes the corresponding Output Port. So for Loops the oldPorts list (removed before creation of new ports) should be filtered to include only Input Ports. --- diff --git a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx index d0410f6..eb8d83c 100644 --- a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx +++ b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx @@ -13,6 +13,7 @@ using namespace std; #include "SUPERVGUI_ManagePortsDlg.h" #include "SUPERVGUI_CanvasNode.h" #include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_CanvasControlNode.h" #include "SUPERVGUI.h" #include @@ -272,6 +273,16 @@ void SUPERVGUI_ManagePortsDlg::init() connect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&))); myNode->getMain()->lockedGraph( true ); + + // asv : 11.01.05 : if a node is a loop node, then only INPUT ports can be added/removed + if ( myNode->getNodeType() == SUPERV::LoopNode ) { + myOutList->setEnabled( false ); + anAddOutputBtn->setEnabled( false ); + aDeleteOutputBtn->setEnabled( false ); + anUpOutputBtn->setEnabled( false ); + aDownOutputBtn->setEnabled( false ); + } + } /** @@ -288,18 +299,34 @@ void SUPERVGUI_ManagePortsDlg::accept() { SUPERV_INode aINode = myNode->getInlineNode(); if ( !SUPERV_isNull( aINode ) ) { int i; + const bool isLoop = ( myNode->getNodeType() == SUPERV::LoopNode ); // 1.1 delete all ports (delete CanvasPorts, they delete SUPERV_Ports) QObjectList* oldPorts = myNode->queryList("SUPERVGUI_CanvasPort"); QObjectListIt it( *oldPorts ); // iterate over the old ports QObject *obj; + // asv : 11.01.05 : fix for a bug: for Loop node, removal of an Input Port + // automatically removes the corresponding Output Port. So for Loops the + // oldPorts list should be filtered to include only Input Ports. + // But I'll filter Gate-s as well.. + QObjectList portsToRemove; while ( (obj = it.current()) != 0 ) { ++it; - if ( !((SUPERVGUI_CanvasPort*)obj)->getEngine()->IsGate() ) // never do anything with Gate ports - ((SUPERVGUI_CanvasPort*)obj)->remove(); + SUPERV::Port_var aPort = ((SUPERVGUI_CanvasPort*)obj)->getEngine(); + if ( !aPort->IsGate() && ( !isLoop || aPort->IsInput() ) ) + portsToRemove.append( obj ); } delete oldPorts; // delete the list, not the objects + + // portsToRemove list contains: + // for Loop node: all INPUT ports except Gates + // for other Inline: all INPUT and OUTPUT ports except Gates + it = QObjectListIt( portsToRemove ); + while ( (obj = it.current()) != 0 ) { + ++it; + ((SUPERVGUI_CanvasPort*)obj)->remove(); + } // 1.2 create new ports in INode and CanvasPort in myNode PortListItem* item; @@ -308,8 +335,15 @@ void SUPERVGUI_ManagePortsDlg::accept() { item = (PortListItem*)myInList->item( i ); aPort = aINode->InPort( item->PortName.latin1(), item->PortType.latin1() ); myNode->createPort( aPort.in() ); + // asv : 11.01.05 : for Loop nodes do the same as in SUPERVGUI_CanvasStartNode::addInputPort() + if ( isLoop ) { + SUPERVGUI_CanvasStartNode* aStartLoopNode = (SUPERVGUI_CanvasStartNode*)myNode; + aStartLoopNode->merge(); + aStartLoopNode->getCoupled()->merge(); + } } - for ( i = 0; i < myOutList->count(); i++ ) { + // creating Out-ports, except LoopNode-s + for ( i = 0; i < myOutList->count() && !isLoop; i++ ) { item = (PortListItem*)myOutList->item( i ); aPort = aINode->OutPort( item->PortName.latin1(), item->PortType.latin1() ); myNode->createPort( aPort.in() ); @@ -392,6 +426,9 @@ void SUPERVGUI_ManagePortsDlg::addPort( QListBox* theLB ) { } } +/** + * called on 'X' button press - remove selected port item + */ void SUPERVGUI_ManagePortsDlg::removePort( QListBox* theLB ) { if ( !theLB ) return; @@ -401,6 +438,9 @@ void SUPERVGUI_ManagePortsDlg::removePort( QListBox* theLB ) { delete theLB->item( i ); } +/** + * called on up/down key press - move the selected list box item from position 'from' to position 'to' + */ void SUPERVGUI_ManagePortsDlg::moveItem( QListBox* theLB, const int from, const int to ) { if ( !theLB ) return; @@ -420,6 +460,9 @@ void SUPERVGUI_ManagePortsDlg::moveItem( QListBox* theLB, const int from, const connect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*))); } +/** + * move the selected item UP + */ void SUPERVGUI_ManagePortsDlg::moveUp( QListBox* theLB ) { if ( !theLB ) return; @@ -427,6 +470,9 @@ void SUPERVGUI_ManagePortsDlg::moveUp( QListBox* theLB ) { moveItem( theLB, i, i-1 ); } +/** + * move the selected item DOWN + */ void SUPERVGUI_ManagePortsDlg::moveDown( QListBox* theLB ) { if ( !theLB ) return; @@ -503,7 +549,6 @@ void SUPERVGUI_ManagePortsDlg::itemChanged( QListBoxItem * item ) { /*! * Port parameters dialog definition (taken from SUPERVGUI_Node.cxx without change) */ - SUPERVGUI_PortParamsDlg::SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames) : QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), myPortsNames( thePortsNames )