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() ;
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 ;
}
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 ;
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();
}
}
}
}
+
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());
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) {
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();
}
}
{
//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)) {
}
}
}
- 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();
{
if (o == myBrowseDlg && e->type() == QEvent::Close)
myBrowseDlg = 0;
+
return QObject::eventFilter(o, e);
}
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();
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()));
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() ) );
}
myWarning( false ),
myStep( false ),
myTrace( false ),
- myVerbose( false )
+ myVerbose( false ),
+ myGUIEventLoopFinished( true )
{
Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
theParent->setViewWidget(this);
}
-/**
+/**
* Called by thread when dataflow is executing
*/
void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) {
}
} else {
myThread->startThread(tr("MSG_GRAPH_STARTED"));
- sync();
+ //sync();
}
} else {
if (!dataflow->Run()) {
}
} else {
myThread->startThread(tr("MSG_GRAPH_STARTED"));
- sync();
+ //sync();
}
}
}
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
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);
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();
anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIORAttr->SetValue(dataflow->getIOR());
op->finish();
- if (aLocked) return false;
}
sync();
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);
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");
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);
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;
}
} 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();
QPtrList< SUPERV::GraphState > aStates;
myMain->startTimer();
+
+ myMain->myGUIEventLoopFinished = false;
+
while(myIsActive) {
myMain->getDataflow()->Event(aNode, aEvent, aState);
// qApp->unlock();
// VSR: 04/12/03 <---
+ myMain->myGUIEventLoopFinished = true;
+
QThread::exit();
}
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);
bool eventFilter( QObject* o, QEvent* e);
+ bool IsGUIEventLoopFinished() const { return myGUIEventLoopFinished; }
+
signals:
void KillMyThread(bool theValue);
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 {
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) {
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");
// Pane for Python script editing
//*****************************************************
SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane(QWidget* theParent)
- : QFrame(theParent),
- myIStream(0)
+ : QFrame(theParent)
{
QGridLayout* aEditLayout = new QGridLayout(this, 2, 4);
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
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++) {
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();
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 );
}
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;
};
#
#
#
-# File : SupervisionGUI_msg_en.po
+# File : SupervisorGUI_msg_en.po
# Module : SUPERV
msgid ""
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"
#:SUPERVGUI_Main.cxx:185
msgid "GRAPH_TITLE"
-msgstr "Supervision: "
+msgstr "Supervisor: "
#:SUPERVGUI_Main.cxx:195
msgid "MSG_GRAPH_STARTED"
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"
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"
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;
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 ) ;
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() ,
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 ,
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" );
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 ) ;
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;