From: admin Date: Thu, 20 Jan 2005 06:27:14 +0000 (+0000) Subject: Merge with OCC_development_01 X-Git-Tag: V2_2_0a1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=72e4c8f5e1a0e0001cdb9cb1de59e0495966fd0c;p=modules%2Fsuperv.git Merge with OCC_development_01 --- diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.hxx b/src/GraphEditor/DataFlowEditor_DataFlow.hxx index 336a9e3..174aded 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.hxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.hxx @@ -213,10 +213,12 @@ namespace GraphEditor { bool IsValid() ; bool IsExecutable() ; - void Executing( bool b = true ) ; + void Executing() ; // asv : removed a bool parameter, use Editing() to set _Executing = false; bool IsExecuting() ; + void Editing() ; bool IsEditing() ; + bool UnValid() ; void EditedAfterExecution(bool EditedAfterExecution ) ; bool EditedAfterExecution() ; diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.lxx b/src/GraphEditor/DataFlowEditor_DataFlow.lxx index e09bb9f..b5519aa 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.lxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.lxx @@ -428,29 +428,17 @@ inline bool GraphEditor::DataFlow::IsExecutable() { return GraphEditor::OutNode::IsExecutable() ; } -inline void GraphEditor::DataFlow::Executing( bool b ) { - cdebug << "Executing _Executing = " << b << endl ; - _Executing = b ; +inline void GraphEditor::DataFlow::Executing() { + cdebug << "Executing() : set _Executing = true " << endl ; + _Executing = true ; } inline bool GraphEditor::DataFlow::IsExecuting() { -/* - if ( _DataFlowExecutor ) { - cdebug << " IsDone " << _DataFlowExecutor->IsDone() << " State " << _DataFlowExecutor->State() ; - } - cdebug << endl ; - if ( _Executing && _DataFlowExecutor ) { - if ( _DataFlowExecutor->IsDone() ) { - _Executing = false ; - } - } -*/ return _Executing ; } - inline void GraphEditor::DataFlow::Editing() { - cdebug << "Editing _Executing = false " << endl ; + cdebug << "Editing() : set _Executing = false " << endl ; _Executing = false ; } diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index 810a7c5..b1d8b2c 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -1302,7 +1302,7 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName , exit( 0 ) ; } if ( _EventNodes.size() > 0 ) { - cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" + cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue " << *aNodeName << " " << anEvent << " " << aState << endl ; } return RetVal ; diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index e4c6bf3..bf390ac 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -366,9 +366,12 @@ void SUPERVGUI::renameDataflow() { QString nm = QString( aName->Value() ); nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm ); if ( !nm.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); + // sak : 24.11.04 : fix for PAL6898 : if rename fails (study locked), + // a message box is displayed, and cursor is "wait cursor". We think that "wait cursor" + // is not neccessary here, because the rename operation is fast. + //QApplication::setOverrideCursor( Qt::waitCursor ); study->renameIObject( IObject, nm ); - QApplication::restoreOverrideCursor(); + //QApplication::restoreOverrideCursor(); } } } @@ -606,15 +609,24 @@ void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, b } + void SUPERVGUI::deleteObject() { SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() ); if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return; - + + // sak : 24.11.04 : fix for PAL6899 : if the study is locked - warn the user and return. + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + if ( aStudy->GetProperties()->IsLocked() ) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED")); + return; + } + + // sak : 24.11.04 : fix for PAL6901 : Incorrect deletion of the objects : pressing ESC button + // emitted "YES" button click, now it is corrected, and treated as "NO" button click. if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_ASK_DELETE"), - QMessageBox::No, - QMessageBox::Yes) == QMessageBox::No) + QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes) return; SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); @@ -623,7 +635,6 @@ void SUPERVGUI::deleteObject() { bool aIsOwner, aIsDataflow; whatIsSelected(anIObj, aIsOwner, aIsDataflow); - SALOMEDS::Study_var aStudy = study->getStudyDocument(); SALOMEDS::SObject_var aObj = aStudy->FindObjectID( anIObj->getEntry() ); if (!aObj->_is_nil()) { if (aIsDataflow) { diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx index dd0939e..7a95cb0 100644 --- a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx @@ -433,6 +433,13 @@ void SUPERVGUI_GetValueDlg::accept() { myPortESNode->sync(); else { myPortCanvas->sync(); + + // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status + if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) { + SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent(); + aNode->sync(); + } + myPortCanvas->getMain()->getCanvas()->update(); } } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx index 273f161..9a9f532 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx @@ -273,8 +273,9 @@ void SUPERVGUI_CanvasNode::sync() { //MESSAGE("===> SUPERVGUI_CanvasNode::sync() " << myNode->Name() << ", state " << myNode->State()); + const bool isExecuting = myMain->getDataflow()->IsExecuting(); //if myNode is a MacroNode then set it state to state of its subgraph - if (myNode->IsMacro() && myMain->getDataflow()->IsExecuting()) { + if ( myNode->IsMacro() && isExecuting ) { // get SubGraph from MacroNode SUPERV_Graph aMacro = SUPERV::Graph::_narrow(myNode); if (!SUPERV_isNull(aMacro)) { @@ -291,8 +292,15 @@ void SUPERVGUI_CanvasNode::sync() } } } - else - getPrs()->setState(myNode->State()); + else { + SUPERV::GraphState aState = myNode->State(); + + // asv : 18.11.04 : fix for 6170 : after execution is finished, nodes' status must be reset. + if ( !isExecuting && myMain->IsGUIEventLoopFinished() && (aState == SUPERV::DoneState || + aState == SUPERV::KillState || aState == SUPERV::StopState ) ) + aState = SUPERV::EditingState; + getPrs()->setState(aState); + } // update child ports const QObjectList* list = children(); @@ -481,6 +489,7 @@ bool SUPERVGUI_CanvasNode::eventFilter( QObject* o, QEvent* e ) { if (o == myBrowseDlg && e->type() == QEvent::Close) myBrowseDlg = 0; + return QObject::eventFilter(o, e); } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx index dd0e981..172d416 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx @@ -90,7 +90,8 @@ SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGU myPopup = new QPopupMenu(viewport()); - if (myMain->isEditable()) { + const bool isEdit = myMain->isEditable(); + if (isEdit) { myPopup->insertItem(tr("MSG_ADD_NODE"), myMain, SLOT(addNode())); myPopup->insertItem(tr("MSG_INS_FILE"), myMain, SLOT(insertFile())); myPopup->insertSeparator(); @@ -118,7 +119,7 @@ SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGU myPopup->insertSeparator(); myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy())); - myPopup->insertItem(tr("MSG_CHANGE_INFO"), myMain, SLOT(changeInformation())); + myPopup->insertItem(tr(isEdit ? "MSG_CHANGE_INFO" : "MSG_INFO"), myMain, SLOT(changeInformation())); myPopup->insertSeparator(); myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), myMain, SLOT(copy())); diff --git a/src/SUPERVGUI/SUPERVGUI_Information.cxx b/src/SUPERVGUI/SUPERVGUI_Information.cxx index 5ee9b3c..fe1c270 100644 --- a/src/SUPERVGUI/SUPERVGUI_Information.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Information.cxx @@ -147,18 +147,31 @@ SUPERVGUI_Information::SUPERVGUI_Information(SUPERV_CNode node, bool isReadOnly) GroupButtonsLayout->setAlignment( Qt::AlignTop ); GroupButtonsLayout->setSpacing( 6 ); GroupButtonsLayout->setMargin( 11 ); - - QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); - QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); - GroupButtonsLayout->addWidget( okB, 0, 0 ); - GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); - GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + // fix for PAL6904: when isReadOnly is set ON (the dataflow was imported) then only "CLOSE" button + // should be present instead of 2 buttons OK and Cancel. + QPushButton* cancelB; + if ( !isReadOnly || node->IsFactory() ) { + /*added node->IsFactory() because only for Factory nodes we ALWAYS have editable "Container" field */ + QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + connect( okB, SIGNAL( clicked() ), this, SLOT( okButton() ) ); + cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); + GroupButtonsLayout->addWidget( okB, 0, 0 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + } + else { + cancelB = new QPushButton( tr( "BUT_CLOSE" ), GroupButtons ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 0 ); + GroupButtonsLayout->addWidget( cancelB, 0, 1 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + } TopLayout->addWidget( TopGroup, 0, 0 ); TopLayout->addWidget( GroupButtons, 1, 0 ); + TopLayout->setRowStretch( 0, 1 ); + TopLayout->setRowStretch( 1, 0 ); - connect( okB, SIGNAL( clicked() ), this, SLOT( okButton() ) ); connect( cancelB, SIGNAL( clicked() ), this, SLOT( koButton() ) ); } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 59344f1..93cfd42 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -139,7 +139,8 @@ SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* th myWarning( false ), myStep( false ), myTrace( false ), - myVerbose( false ) + myVerbose( false ), + myGUIEventLoopFinished( true ) { Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)"); theParent->setViewWidget(this); @@ -307,7 +308,7 @@ void SUPERVGUI_Main::syncAsync() { } -/** +/** * Called by thread when dataflow is executing */ void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) { @@ -614,7 +615,7 @@ void SUPERVGUI_Main::run() { } } else { myThread->startThread(tr("MSG_GRAPH_STARTED")); - sync(); + //sync(); } } else { if (!dataflow->Run()) { @@ -624,7 +625,7 @@ void SUPERVGUI_Main::run() { } } else { myThread->startThread(tr("MSG_GRAPH_STARTED")); - sync(); + //sync(); } } } @@ -960,14 +961,19 @@ bool SUPERVGUI_Main::addStudy() { Trace("SUPERVGUI_Main::addStudy"); if (myIsFromStudy) return false; if ((SUPERV_isNull(dataflow))) return false; - + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + bool aLocked = aStudy->GetProperties()->IsLocked(); + // asv : 23.11.04 : if the study is locked -- then we can't put anything in it. + // fix for PAL6852. + if ( aLocked ) + return false; + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; SALOMEDS::AttributeIOR_var anIORAttr; SALOMEDS::AttributePixMap_var aPixmap; - bool aLocked = aStudy->GetProperties()->IsLocked(); QAD_Operation* op = new SALOMEGUI_ImportOperation( study ); // searching dataflow @@ -977,7 +983,6 @@ bool SUPERVGUI_Main::addStudy() { if (aComponent->_is_nil()) { // is supervision component not found, then create it QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study ); anOperation->start(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); aComponent = aBuilder->NewComponent(STUDY_SUPERVISION); anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -987,7 +992,6 @@ bool SUPERVGUI_Main::addStudy() { aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine()); - if (aLocked) aStudy->GetProperties()->SetLocked(true); anOperation->finish(); } op->start(); @@ -999,7 +1003,6 @@ bool SUPERVGUI_Main::addStudy() { anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); anIORAttr->SetValue(dataflow->getIOR()); op->finish(); - if (aLocked) return false; } sync(); @@ -1081,28 +1084,35 @@ SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStud bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { Trace("SUPERVGUI_Main::putDataStudy"); + // static variable to ensure that only one instance (thread) is executing this function static bool isIn = false; - if (isIn) return true; else isIn = true; + if (isIn) + return true; + else + isIn = true; SALOMEDS::Study_var aStudy = study->getStudyDocument(); + bool aLocked = aStudy->GetProperties()->IsLocked(); + // asv : 23.11.04 : if the study is locked -- then we can't put anything in it. + // fix for PAL6852. + if ( aLocked ) { + isIn = false; + return false; + } + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; SALOMEDS::AttributeIOR_var anIORAttr; SALOMEDS::AttributePixMap_var aPixmap; bool aTransaction = false; - bool aLocked = aStudy->GetProperties()->IsLocked(); - // QAD_Operation* op = new SALOMEGUI_ImportOperation( study ); // searching dataflow SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR()); if (aSO->_is_nil()) { // create new dataflow SObject SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION); if (aComponent->_is_nil()) { // is supervision component not found, then create it - //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study ); - //anOperation->start(); aBuilder->NewCommand(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); aComponent = aBuilder->NewComponent(STUDY_SUPERVISION); anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -1113,12 +1123,9 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine()); - if (aLocked) aStudy->GetProperties()->SetLocked(true); - // anOperation->finish(); aBuilder->CommitCommand(); } aTransaction = true; - //op->start(); aBuilder->NewCommand(); aSO = aBuilder->NewObject(aComponent); anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName"); @@ -1128,19 +1135,14 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); anIORAttr->SetValue(dataflow->getIOR()); } - //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study ); + aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO - QString("Run ") + myRunTime.toString() /*, anOperation*/, &aTransaction); - aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name()/*, anOperation*/, &aTransaction); // get node SO - aSO = SearchOrCreateSOWithName(aStudy, aSO, inout/*, anOperation*/, &aTransaction); // get in/out SO - aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name()/*, anOperation*/, &aTransaction); // get port SO - - if (aLocked) { - if (aTransaction) aBuilder->CommitCommand(); - //op->finish(); - isIn = false; - return false; - } + QString("Run ") + myRunTime.toString(), &aTransaction); + aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name(), &aTransaction); // get node SO + aSO = SearchOrCreateSOWithName(aStudy, aSO, inout, &aTransaction); // get in/out SO + aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name(), &aTransaction); // get port SO + + if (aTransaction) aBuilder->CommitCommand(); anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR"); anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); @@ -1168,14 +1170,12 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { if (!aTransaction) { aTmpSO = aSO; aTransaction = true; - //op->start(); aBuilder->NewCommand(); } aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, ""); aBuilder->Addreference(aSO, aTmpSO); } else { // can't publish object: abort transaction if (aTransaction) aBuilder->AbortCommand(); - //op->abort(); isIn = false; return false; } @@ -1187,14 +1187,12 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { } else { if (!aTransaction) { aTransaction = true; - // op->start(); aBuilder->NewCommand(); } anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition } if (aTransaction) - //op->finish(); aBuilder->CommitCommand(); if (!myThread->running()) study->updateObjBrowser(); @@ -1429,6 +1427,9 @@ void SUPERVGUI_Thread::run() QPtrList< SUPERV::GraphState > aStates; myMain->startTimer(); + + myMain->myGUIEventLoopFinished = false; + while(myIsActive) { myMain->getDataflow()->Event(aNode, aEvent, aState); @@ -1540,6 +1541,8 @@ void SUPERVGUI_Thread::run() // qApp->unlock(); // VSR: 04/12/03 <--- + myMain->myGUIEventLoopFinished = true; + QThread::exit(); } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index 043a915..b0f04c0 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -50,6 +50,10 @@ class SUPERVGUI_Thread; class SUPERVGUI_Main: public SUPERVGraph_View { Q_OBJECT + // asv : 18.11.04 : making Thread class a friend in order to allow it to modify + // a private field myGUIEventLoopFinished + friend class SUPERVGUI_Thread; + public: //SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool fromIOR); //SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool isModify, const char* filename); @@ -127,6 +131,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View { bool eventFilter( QObject* o, QEvent* e); + bool IsGUIEventLoopFinished() const { return myGUIEventLoopFinished; } + signals: void KillMyThread(bool theValue); @@ -203,6 +209,12 @@ class SUPERVGUI_Main: public SUPERVGraph_View { QPtrList< char * > myEventNodes ; QPtrList< SUPERV::GraphState > myStates ; QTimer* myTimer; + + // asv : 18.11.04 : fix for bug 6170 : this field is FALSE when SUPERVGUI_Thread + // is inside event loop during graph execution. dataflow->IsDone() returns true + // BEFORE all events are handled (a few of them are still being processed in GUI thread), + // and for bug 6170 it is neccessary to know exactly when GUI events processing stops.. + bool myGUIEventLoopFinished; }; class SUPERVGUI_Thread : public QObject, public QThread { diff --git a/src/SUPERVGUI/SUPERVGUI_Node.cxx b/src/SUPERVGUI/SUPERVGUI_Node.cxx index 74cf9ea..6594235 100644 --- a/src/SUPERVGUI/SUPERVGUI_Node.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Node.cxx @@ -117,7 +117,14 @@ SUPERVGUI_Node::~SUPERVGUI_Node() void SUPERVGUI_Node::sync() { - setState(myNode->State()); + // asv : 18.11.04 : fix for 6170 : after execution is finished, nodes' status must be reset. + // this code here seems to be executed only in Table View (array). + SUPERV::GraphState aState = myNode->State(); + if ( !myMain->getDataflow()->IsExecuting() && myMain->IsGUIEventLoopFinished() && + (aState == SUPERV::DoneState || aState == SUPERV::KillState || aState == SUPERV::StopState ) ) + aState = SUPERV::EditingState; + + setState( aState ); } void SUPERVGUI_Node::syncOnEvent(SUPERV::GraphState theStateFromEvent) { diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx index 026c1ae..e43928e 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -152,7 +152,7 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): QHGroupBox* aAddBox2 = new QHGroupBox(tr("TIT_ADDNODE"), aPythonPane); aAddBox2->setInsideSpacing(20); - QLabel* aTypeLbl = new QLabel(tr("LBL_NODETYPE"), aAddBox2); + /*QLabel* aTypeLbl = */new QLabel(tr("LBL_NODETYPE"), aAddBox2); myTypeCombo = new QComboBox(aAddBox2); myTypeCombo->insertItem("Computation"); @@ -699,8 +699,7 @@ void SUPERVGUI_Service::tabChanged(QWidget* theWidget) { // Pane for Python script editing //***************************************************** SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane(QWidget* theParent) - : QFrame(theParent), - myIStream(0) + : QFrame(theParent) { QGridLayout* aEditLayout = new QGridLayout(this, 2, 4); @@ -724,6 +723,45 @@ SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane(QWidget* theParent) aEditLayout->addMultiCellWidget(myText, 1, 1, 0, 3); } +/** + * Searches for text beginning with "def" and ending with any meanful character at + * beginning of line. Starts searching with current position of given stream. + * Fills the myPyFunctions with strings corresponding to found fucntions. + */ +void SUPERVGUI_PythonEditPane::initPyFunctions( QTextStream& theStream ) { + + if ( theStream.atEnd() ) + return; + + QString aPyFunction; + QString aLine = theStream.readLine(); + + while ( !theStream.atEnd() ) { // not EOF + + // asv : 23.11.04 : fix for PAL6870 : skip empty lines in the beginning or between functions + // find("def)==0 -> analizing only global function definitions which start with 0 indentation + while ( !aLine.isNull() && aLine.find( "def" ) != 0 ) + aLine = theStream.readLine(); + + if ( !aLine.isNull() && aLine.find("def") == 0 ) { + aPyFunction += aLine; + aPyFunction += '\n'; + + // read function body + aLine = theStream.readLine(); + // asv : 23.11.04 : added "|| aLine.isEmpty()" - fix for PAL6870. readLine() returns an empty + // string for "\n" string, it trails \n caracter. but we accept such lines.. + while ( !aLine.isNull() && ( aLine.isEmpty() || aLine[0].isSpace() ) ) { + aPyFunction += aLine; + aPyFunction += '\n'; + aLine = theStream.readLine(); + } + + myPyFunctions << aPyFunction; + aPyFunction.setLength( 0 ); + } + } +} /** * Load existing Python script @@ -736,77 +774,50 @@ void SUPERVGUI_PythonEditPane::loadFile() { true); if (aFileName.isEmpty()) return; - myFile = new QFile(aFileName); - if (!myFile->open(IO_ReadOnly)) { + QFile aFile( aFileName ); + if (!aFile.open(IO_ReadOnly)) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_LOADSCRIPT")); return; } - myIStream = new QTextStream(myFile); - if (myIStream->atEnd()) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), - tr("MSG_EMTY_FILE")); - myNextBtn->setEnabled(false); - delete myIStream; - myIStream = 0; - myFile->close(); - delete myFile; + myPyFunctions.clear(); + myPyIndex = -1; + myNextBtn->setEnabled( false ); + myText->clear(); + + QTextStream aFileReader(&aFile); + if ( aFileReader.atEnd() ) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_EMTY_FILE")); + aFile.close(); return; } - myNextBtn->setEnabled(true); - readFunction(); + + initPyFunctions( aFileReader ); + + if ( myPyFunctions.size() ) { + myNextBtn->setEnabled( true ); + myPyIndex = 0; + readFunction(); + } } - /** * Finds and Reads a function from current position in the opened file + * asv : Comment above is old! Present model: just take an already read string = PyFunction + * from the list which is filled in loadFile(). */ void SUPERVGUI_PythonEditPane::readFunction() { - if (!myIStream) return; - - while (!myIStream->atEnd()) { - QString aLine = myIStream->readLine(); - if (aLine.isNull()) return; - - // find first function - int aDefPos = aLine.find("def"); - if (aDefPos == 0) { // only not a class members - myText->clear(); - // find name - /*int aStart = aLine.find(" ", aDefPos); - int aEnd = aLine.find("(", aStart); - QString aName = aLine.mid(aStart, (aEnd-aStart)); - aName = aName.stripWhiteSpace(); - myNameEdt->setText(aName);*/ - - // find input params - /*aStart = aEnd+1; - aEnd = aLine.find(")", aStart); - QString aParams = aLine.mid(aStart, (aEnd-aStart)); - aParams = aParams.stripWhiteSpace(); - myParamEdt->setText(aParams);*/ - - myText->append(aLine); - // read body - QString aBodyLine = myIStream->readLine(); - while ((!aBodyLine.isNull()) && aBodyLine[0].isSpace()) { - myText->append(aBodyLine); - aBodyLine = myIStream->readLine(); - } - return; - } - } - QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), - tr("MSG_NOMORE_FUNCTIONS")); - delete myIStream; - myIStream = 0; - myNextBtn->setEnabled(false); - myFile->close(); - delete myFile; + myText->clear(); + if ( myPyIndex != -1 && myPyFunctions.size() && myPyFunctions.size() > myPyIndex ) + myText->append( myPyFunctions[ myPyIndex++ ] ); + if ( myPyFunctions.size() <= myPyIndex ) // last index was reached + myNextBtn->setEnabled( false ); } - +/** + * Returns the text after "def" and before "(" -- first defined function name + */ QString SUPERVGUI_PythonEditPane::getFuncName() { QString aName(""); for (int i=0; i < myText->paragraphs(); i++) { @@ -822,14 +833,20 @@ QString SUPERVGUI_PythonEditPane::getFuncName() { return aName; } - +/** + * Returns the contents of the myText widget without trailing spacing + */ SUPERV_Strings SUPERVGUI_PythonEditPane::getFunction() { SUPERV_Strings aStrings = new SUPERV::ListOfStrings(); aStrings->length(myText->paragraphs()); for (int i=0; i < myText->paragraphs(); i++) { QString aLine = myText->text(i); - if (!aLine.right(1).compare(" ")) - aLine = aLine.remove(aLine.length()-1,1); + // asv : 30.11.04 - why do we have to remove trailing spaces?? + // it's user's responsibility to enter correct Python code, we don't do anything with it. + // if (..) -- initial, while(..) -- my improvement, but also commented out -- needless. + //if (!aLine.right(1).compare(" ")) // replaced with the line below -- loop + //while (aLine.at(aLine.length()-1).isSpace()) // remove trailing spaces + // aLine = aLine.remove(aLine.length()-1,1); aStrings[i] = CORBA::string_dup(aLine.latin1()); } return aStrings._retn(); @@ -840,6 +857,12 @@ void SUPERVGUI_PythonEditPane::setFunction(SUPERV_Strings theStr) { int aLen = theStr->length(); for (int i=0; i < aLen; i++) myText->append(QString(theStr[i])); + + // asv : 30.11.04 : 2.7 - Inline node function editor improvement + // 2.7.1 - set focus to editor widget on editor window opening + // 2.7.2 - scroll to the beginning of function on editor window opening + myText->setFocus(); + myText->ensureVisible( 0,0 ); } diff --git a/src/SUPERVGUI/SUPERVGUI_Service.h b/src/SUPERVGUI/SUPERVGUI_Service.h index 92c195d..9a2f161 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.h +++ b/src/SUPERVGUI/SUPERVGUI_Service.h @@ -58,15 +58,18 @@ class SUPERVGUI_PythonEditPane: public QFrame { void readFunction(); private: - - //QLineEdit* myNameEdt; - //QLineEdit* myParamEdt; - QTextEdit* myText; - //QLineEdit* myOutParamEdt; + QTextEdit* myText; QPushButton* myNextBtn; - QTextStream* myIStream; - QFile* myFile; + // fills myPyFunctions list. called from loadFile() after user selects a file. + void initPyFunctions( QTextStream& ); + + // list of Python functions. filled in loadFile(), strings (functions) retrieved + // in readFunction() + QStringList myPyFunctions; + + // index of currently displayed Python function + int myPyIndex; }; diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index 72c0451..caa00ee 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -21,7 +21,7 @@ # # # -# File : SupervisionGUI_msg_en.po +# File : SupervisorGUI_msg_en.po # Module : SUPERV msgid "" @@ -83,10 +83,25 @@ msgstr "Delete Link" msgid "MSG_ORTHO_LINE" msgstr "Ortho Mode" -#:SUPERVGUI_Main.cxx:146 +#warnings - all of them must be Supervisor Warning.. msgid "WARNING" msgstr "Supervisor Warning" +msgid "SUPERVGUI_CanvasControlNode::WARNING" +msgstr "Supervisor Warning" + +msgid "SUPERVGUI::WARNING" +msgstr "Supervisor Warning" + +msgid "SUPERVGUI_CanvasPort::WARNING" +msgstr "Supervisor Warning" + +msgid "SUPERVGUI_Main::WARNING" +msgstr "Supervisor Warning" + +msgid "SUPERVGUI_Service::WARNING" +msgstr "Supervisor Warning" + #:SUPERVGUI_Main.cxx:147 msgid "MSG_DF_RUNNING" msgstr "Dataflow Is Currently Running" @@ -101,7 +116,7 @@ msgstr "Kill Execution" #:SUPERVGUI_Main.cxx:185 msgid "GRAPH_TITLE" -msgstr "Supervision: " +msgstr "Supervisor: " #:SUPERVGUI_Main.cxx:195 msgid "MSG_GRAPH_STARTED" @@ -325,7 +340,7 @@ msgid "MSG_CANT_CHOOSE_SERVICE" msgstr "Can't Choose a Service in a Component" msgid "MSG_NO_SUPERVISION_WINDOW" -msgstr "No Supervision Window Selected to Add Nodes in a Dataflow" +msgstr "No Supervisor Window Has Been Selected to Add Nodes in a Dataflow" msgid "MSG_SKETCH_LINK" msgstr "Sketch Link" @@ -397,28 +412,28 @@ msgid "MSG_GRAPH_ISRUN" msgstr "Dataflow is still executing. Kill it?" msgid "MSG_NOWINDOW_TO_SUSPEND" -msgstr "No Supervision Window Selected to Suspend or Resume a Dataflow" +msgstr "No Supervisor Window Has Been Selected to Suspend or Resume a Dataflow" msgid "MSG_NOWINDOW_TO_ADD" -msgstr "No Supervision Window Selected to add new components" +msgstr "No Supervisor Window Has Been Selected to add new components" msgid "MSG_NOWINDOW_TO_EXPORT" -msgstr "No Supervision Window Selected to Export a Dataflow" +msgstr "No Supervisor Window Has Been Selected to Export a Dataflow" msgid "MSG_CANT_LOAD_SUPERV" -msgstr "Cannot Find or Load Supervision Component" +msgstr "Cannot Find or Load Supervisor Component" msgid "MSG_CANT_NARROW_SUPERV" -msgstr "Cannot _narrow Supervision Component" +msgstr "Cannot _narrow Supervisor Component" msgid "MSG_NOWINDOW_TO_RELOAD" -msgstr "No Supervision Window Selected to Reload a Dataflow" +msgstr "No Supervisor Window Has Been Selected to Reload a Dataflow" msgid "MSG_NOWINDOW_TO_RUN" -msgstr "No Supervision Window Selected to Run a Dataflow" +msgstr "No Supervisor Window Has Been Selected to Run a Dataflow" msgid "MSG_NOWINDOW_TO_KILL" -msgstr "No Supervision Window Selected to Kill a Dataflow" +msgstr "No Supervisor Window Has Been Selected to Kill a Dataflow" msgid "MSG_IMPORT" msgstr "Import Dataflow" diff --git a/src/Supervision/CNode_Impl.cxx b/src/Supervision/CNode_Impl.cxx index 1175c00..1813fcd 100644 --- a/src/Supervision/CNode_Impl.cxx +++ b/src/Supervision/CNode_Impl.cxx @@ -1917,9 +1917,11 @@ long CNode_Impl::CpuUsed() { bool CNode_Impl::IsExecuting() { bool RetVal = false; if ( !IsMacro() && DataFlowEditor() && DataFlowEditor()->Executor() ) { - if ( DataFlowEditor()->IsExecuting() && DataFlowEditor()->Executor()->IsDone() ) - DataFlowEditor()->Executing( false ); - + // asv : the statement below normally does not return true, Executor_OutNode + // sets Editor->Editing() after finishing of execution (see Executor_OutNode.cxx) + if ( DataFlowEditor()->IsExecuting() && DataFlowEditor()->Executor()->IsDone() ) { + DataFlowEditor()->Editing(); + } RetVal = DataFlowEditor()->IsExecuting(); } return RetVal; diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx index 3af8ebd..726e574 100644 --- a/src/Supervision/Graph_Impl.cxx +++ b/src/Supervision/Graph_Impl.cxx @@ -46,11 +46,7 @@ static void CreateEditor( CORBA::ORB_ptr orb , const SUPERV::KindOfNode aKindOfNode , string & dbgfile , GraphEditor::DataFlow ** aDataFlowEditor ) { -// string dbgfile = "/tmp/" ; bool aXmlFile = false ; - dbgfile = "/tmp/" ; - dbgfile += instanceName ; - dbgfile += "_" ; int lenname = strlen( aDataFlowName ) ; char * theDataFlowName = new char [ lenname+1 ] ; strcpy( theDataFlowName , aDataFlowName ) ; @@ -72,12 +68,28 @@ static void CreateEditor( CORBA::ORB_ptr orb , strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ; } } + string theDataFlowInstanceName = theDataFlowName ; -// if ( !aXmlFile ) { -// theDataFlowInstanceName = theAutomaton->GraphInstanceName( theDataFlowName ) ; -// } + + // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir. + // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py. + dbgfile = "/tmp/logs/" ; + dbgfile += getenv( "USER" ) ; + dbgfile += "/" ; + dbgfile += instanceName ; + dbgfile += "_" ; dbgfile += theDataFlowInstanceName ; dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ; + FILE* f = fopen ( dbgfile.c_str(), "a" ); + if ( f ) { // check if file can be opened for writing + fclose( f ); + } + else { // if file can't be opened - use a guaranteed temp file name + char* aTempNam = tempnam( NULL, NULL ); + dbgfile = aTempNam; + free ( aTempNam ); + } + SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ; *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService , theDataFlowInstanceName.c_str() , dbgfile.c_str() , @@ -94,24 +106,37 @@ static void CreateExecutor( CORBA::ORB_ptr orb , const SUPERV::KindOfNode aKindOfNode , string & dbgfile , GraphExecutor::DataFlow ** aDataFlowExecutor ) { -// string dbgfile = "/tmp/" ; - dbgfile = "/tmp/" ; - dbgfile += instanceName ; - dbgfile += "_" ; int lenname = strlen( aDataFlowName ) ; char * theDataFlowName = new char [ lenname+1 ] ; strcpy( theDataFlowName , aDataFlowName ) ; if ( aDataFlowName ) { strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ; } + string theDataFlowInstanceName = theDataFlowName ; + + // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir. + // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py. + dbgfile = "/tmp/logs/" ; + dbgfile += getenv( "USER" ) ; + dbgfile += "/" ; + dbgfile += instanceName ; + dbgfile += "_" ; dbgfile += theDataFlowInstanceName ; dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ; - ostringstream astr ; astr << theAutomaton->ExecNumber() ; dbgfile += astr.str() ; dbgfile += string( "_Exec.log" ) ; + FILE* f = fopen ( dbgfile.c_str(), "a" ); + if ( f ) { // check if file can be opened for writing + fclose( f ); + } + else { // if file can't be opened - use a guaranteed temp file name + char* aTempNam = tempnam( NULL, NULL ); + dbgfile = aTempNam; + free ( aTempNam ); + } SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ; *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService , @@ -1619,7 +1644,10 @@ bool Graph_Impl::IsValid() { bool Graph_Impl::IsExecutable() { // beginService( "Graph_Impl::IsExecutable" ); bool RetVal = false ; - if ( !IsMacro() ) { + + // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" -> + // subgraphs are not executable by themselves, RetVal = false.. + if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) { RetVal = DataFlowEditor()->IsExecutable() ; } // endService( "Graph_Impl::IsExecutable" ); diff --git a/src/Supervision/Port_Impl.cxx b/src/Supervision/Port_Impl.cxx index 55a69f5..6aba031 100644 --- a/src/Supervision/Port_Impl.cxx +++ b/src/Supervision/Port_Impl.cxx @@ -176,11 +176,16 @@ bool Port_Impl::Input( const CORBA::Any * anAny ) { else if ( _DataFlowEditor->IsExecuting() ) { GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + /* commenting out the lines below because it seems to be never executed + Editor::_Executing flag is set OFF in Executor::OutNode on execution finished + and in CNode_Impl class (also not called probably) // asv: turn off Editor::_Executing flag if ( _DataFlowExecutor->IsDone() ) { - _DataFlowEditor->Executing( false ); + _DataFlowEditor->Executing( false ); } - else { + else + */ + if ( !_DataFlowExecutor->IsDone() ) { RetVal = _DataFlowExecutor->ChangeInputData( _DataFlowNode->Name() , _DataFlowPort->PortName() , *anAny ) ; diff --git a/src/Supervision/SuperV_Impl.cxx b/src/Supervision/SuperV_Impl.cxx index b5bf8f3..ad556e9 100644 --- a/src/Supervision/SuperV_Impl.cxx +++ b/src/Supervision/SuperV_Impl.cxx @@ -489,8 +489,8 @@ SALOMEDS::TMPFile* SuperV_Impl::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA: aGraph->Export(strdup(aFullName)); delete(aFullName); - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.in(), aSeq.in(), false); + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.in(), aSeq.in(), true); // Assign an ID = 1 the the type SUPERV::Graph theObjectID = 1;