X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUPERVGUI%2FSUPERVGUI_CanvasControlNode.cxx;h=9a81a1802e0faeca62ebf5554089cc69505db545;hb=cbb0219fe6d6bf11f98f2306c2855fef1eaa2d44;hp=21991ae60dd263c14737acc85bf496d8c17adec6;hpb=b7b531f894fd0a967071ce2b05e0ced7b4743f3b;p=modules%2Fsuperv.git diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx index 21991ae..9a81a18 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx @@ -9,13 +9,16 @@ using namespace std; #include "SUPERVGUI_CanvasControlNode.h" #include "SUPERVGUI_CanvasControlNodePrs.h" +#include "SUPERVGUI_CanvasCellNodePrs.h" #include "SUPERVGUI_Main.h" +#include "SUPERVGUI.h" #include "SUPERVGUI_Canvas.h" -#include "SUPERVGUI_ControlNode.h" // access to SelectInlineDlg #include "QAD_FileDlg.h" #include "QAD_Application.h" +#include + //===================================================================== // Compute node //===================================================================== @@ -185,8 +188,10 @@ void SUPERVGUI_CanvasGotoNode::linkToNode() { SUPERVGUI_SelectInlineDlg* aDlg = new SUPERVGUI_SelectInlineDlg(getMain()); if (aDlg->exec()) { QString aNodeName = aDlg->getName(); - getGotoNode()->SetCoupled(aNodeName.latin1()); - getMain()->getCanvas()->sync(); + if (!aNodeName.isEmpty()) { //implement additional check from GUI side for bug PAL7007 + getGotoNode()->SetCoupled(aNodeName.latin1()); + getMain()->getCanvas()->sync(); + } } delete aDlg; } @@ -242,10 +247,174 @@ void SUPERVGUI_CanvasMacroNode::exportDataflow() "*.xml", tr("TTL_EXPORT_DATAFLOW"), false); - if (!aFileName.isEmpty()) { + if ( !aFileName.isEmpty() ) { + // asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, + // a backup copy of an existing file must be created (in case Export fails..) + QString aBackupFile = SUPERVGUI::createBackupFile( aFileName ); + if (!aGraph->Export(aFileName.latin1())) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING")); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING").arg(aBackupFile)); + } + // remove a backup file if export was successfull + else if ( !aBackupFile.isNull() && !aBackupFile.isEmpty() ) { + QFile::remove( aBackupFile ); + } + } + } +} + +//===================================================================== +// Cell node: node for table view +//===================================================================== +SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode(QObject* theParent, + SUPERVGUI_Main* theMain, + SUPERV_CNode theNode): + SUPERVGUI_CanvasNode(theParent, theMain, theNode, true) +{ + Trace("SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode"); + + myIsControl = false; + myIsStart = false; + + //check for control nodes + if (getEngine()->IsLoop() || getEngine()->IsSwitch()) { + myIsControl = true; + myIsStart = true; + } + if (getEngine()->IsEndLoop() || getEngine()->IsEndSwitch()) + myIsControl = true; +} + +QPopupMenu* SUPERVGUI_CanvasCellNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent); + popup->setItemEnabled(myDeleteItem, false); + return popup; +} + +void SUPERVGUI_CanvasCellNode::setPairCell(SUPERVGUI_CanvasCellNode* thePairCell) { + if (myIsControl) { //only for ControlNode + myPairCell = thePairCell; + } + else + myPairCell = 0; +} + +SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasCellNode::getPairCell() { + return myPairCell; +} + +void SUPERVGUI_CanvasCellNode::sync() { + MESSAGE("===> SUPERVGUI_CanvasCellNode::sync() " << getEngine()->Name() << ", state " << getEngine()->State()); + + const bool isExecuting = getMain()->getDataflow()->IsExecuting(); + //if getEngine() is a MacroNode then set it state to state of its subgraph + if ( getEngine()->IsMacro() && isExecuting ) { + // get SubGraph from MacroNode + SUPERV_Graph aMacro = SUPERV::Graph::_narrow(getEngine()); + if (!SUPERV_isNull(aMacro)) { + SUPERV_Graph aGraph; + if (aMacro->IsStreamMacro()) + aGraph = aMacro->StreamObjRef(); + else + aGraph = aMacro->FlowObjRef(); + if (!SUPERV_isNull(aGraph)) { + if (aGraph->State() != SUPERV::UndefinedState && aGraph->State() != SUPERV::NoState) + getPrs()->setState(aGraph->State()); + else + getPrs()->setState(getEngine()->State()); } } } + else { + getPrs()->setState(getEngine()->State()); + } +} + +/*bool SUPERVGUI_CanvasCellNode::setNodeName(QString aName) +{ + bool result = SUPERVGUI_CanvasNode::setNodeName(aName); + if (result && myPairCell) { + result = myPairCell->getEngine()->SetName((QString(tr("ENDNODE_PREFIX"))+aName).latin1()); + if (result) { + setName(myPairCell->getEngine()->Name()); + myPairCell->getPrs()->updateInfo(); + } + else { + QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_RENAMENODE" ) ); + } + } + return result; +}*/ + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasCellNode::createPrs() const +{ + MESSAGE(" -> SUPERVGUI_CanvasCellNode::createPrs()"); + SUPERVGUI_CanvasNodePrs* aPrs = + new SUPERVGUI_CanvasCellNodePrs(getMain()->getCanvasArray(), + (SUPERVGUI_CanvasCellNode*)this); + MESSAGE(" -> SUPERVGUI_CanvasCellNode::createPrs() 11"); + return aPrs; +} + +SUPERVGUI_CanvasCellEndNode::SUPERVGUI_CanvasCellEndNode( QObject* theParent, + SUPERVGUI_Main* theMain, + SUPERV_CNode theNode, + SUPERVGUI_CanvasCellNode* theStart): + SUPERVGUI_CanvasCellNode(theParent, theMain, theNode) +{ + //set start cell for end cell as pair + myPairCell = theStart; + //set end cell for start cell as pair + myPairCell->setPairCell(dynamic_cast(this)); +} + +//----------------------------------------------------------- +//*************** Select Inline node dialog****************** +// Taken from SUPERVGUI_ControlNode.cxx without change +//----------------------------------------------------------- + +SUPERVGUI_SelectInlineDlg::SUPERVGUI_SelectInlineDlg(SUPERVGUI_Main* theMain) + :QDialog(theMain, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + setSizeGripEnabled( true ); + setCaption(tr("TIT_FUNC_PYTHON")); + QGridLayout* aMainLayout = new QGridLayout(this, 2, 2, 7, 4); + + QLabel* aLabel = new QLabel("Connect to", this ); + aMainLayout->addWidget(aLabel, 0, 0); + + myCombo = new QComboBox(this); + myCombo->clear(); //for the additional check from GUI side for bug PAL7007 + SUPERV_Nodes aNodesList = theMain->getDataflow()->Nodes(); + int i; + for (i = 0; i < aNodesList->INodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->INodes[i]->Name())); + } + for (i = 0; i < aNodesList->LNodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->LNodes[i]->Name())); + } + for (i = 0; i < aNodesList->SNodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->SNodes[i]->Name())); + } + aMainLayout->addWidget(myCombo, 0, 1); + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( aOKBtn ); + + aBtnLayout->addStretch(); + + QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + aBtnLayout->addWidget( aCancelBtn ); + + aMainLayout->addMultiCellWidget(aBtnBox, 1, 1, 0, 1); }