#include "QAD_Application.h"
#include "SUPERVGUI_Def.h"
#include "QAD_RightFrame.h"
+#include "SALOME_Event.hxx"
#include "SUPERVGraph_ViewFrame.h"
#include <qlayout.h>
#include <qfile.h>
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
Standard_CString ior = anIOR->Value();
- dataflow = Supervision.getEngine()->getGraph(ior);
+ dataflow = Supervision.getEngine()->getStreamGraph(ior);
if (SUPERV_isNull(dataflow)) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
close();
close();
}
} else {
- dataflow = Supervision.getEngine()->Graph(MAIN_NEW);
+ dataflow = Supervision.getEngine()->StreamGraph(MAIN_NEW);
if (SUPERV_isNull(dataflow)) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_DF"));
close();
Trace("SUPERVGUI_Main::SUPERVGUI_Main (file)")
theParent->setViewWidget(this);
if (isModify) {
- dataflow = Supervision.getEngine()->Graph(f);
+ dataflow = Supervision.getEngine()->StreamGraph(f);
} else {
- dataflow = Supervision.getEngine()->GraphE(f);
+ dataflow = Supervision.getEngine()->StreamGraphE(f);
}
if (SUPERV_isNull(dataflow)) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
myThread = new SUPERVGUI_Thread();
myThread->setMain(this);
+ connect(this, SIGNAL(KillMyThread(bool)), myThread, SLOT(KillThread(bool)));
myIsKilled = false;
//myIsRunned = false;
delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
if (!SUPERV_isNull(dataflow)) {
if (dataflow->IsExecuting()) {
- if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"),
+ if (QMessageBox::warning(QAD_Application::getDesktop(),
+ tr("WARNING"),
tr("MSG_DF_RUNNING"),
tr("MSG_DF_EXECUTION"),
tr("MSG_DF_KILL")) == 1) {
- dataflow->Kill();
+ if (dataflow->Kill()) {
+ if (myThread->running())
+ myThread->wait();
+ }
+ }
+ else {
+ emit KillMyThread(true);
+ if (myThread->running())
+ myThread->wait();
}
}
+ else {
+ emit KillMyThread(true);
+ if (myThread->running())
+ myThread->wait();
+ }
}
}
}
}
+void SUPERVGUI_Main::changeDSGraphParameters() {
+ SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly());
+ if (aDlg->exec() )
+ sync();
+ delete aDlg;
+}
+
void SUPERVGUI_Main::syncAsync() {
Trace("SUPERVGUI_Main::syncAsync")
QTimer::singleShot(1, this, SLOT(sync()));
SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
(aStudyFrame->getRightFrame()->getViewFrame());
if(aViewFrame){
- SUPERV_Graph aNewGraph = dataflow->Copy();
+ SUPERV_Graph aNewGraph = dataflow->StreamCopy();
QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
aNewName += dataflow->Name();
aNewGraph->SetName(aNewName);
//if (myIsRunned) {
if (!dataflow->ReRun()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
+ if (dataflow->State() == SUPERV::ErrorState) {
+ kill();
+ }
} else {
myThread->startThread(tr("MSG_GRAPH_STARTED"));
- //syncNotification();
sync();
}
} else {
if (!dataflow->Run()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
+ if (dataflow->State() == SUPERV::ErrorState) {
+ kill();
+ }
} else {
myThread->startThread(tr("MSG_GRAPH_STARTED"));
- //syncNotification();
- //myIsRunned = true;
sync();
}
}
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
} else {
myThread->startThread(tr("MSG_GRAPH_STARTED"));
- //syncNotification();
}
}
else {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
} else {
myThread->startThread(tr("MSG_GRAPH_STARTED"));
- //syncNotification();
}
}
}
Trace("SUPERVGUI_Main::showPopup");
// To check is Supervision active?
if (myIsLocked) return;
+ //if (dataflow->IsExecuting()) return;
//if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
}
}
-
-
/******************************* SUPERVGUI_Thread class ****************************************/
SUPERVGUI_Thread::SUPERVGUI_Thread()
:QThread()
void SUPERVGUI_Thread::stopThread(const char* m)
{
- //myIsActive = false;
- //myMain->sync();
myMain->getMessage()->setMessage(m);
}
myMain = theMain;
}
+void SUPERVGUI_Thread::KillThread(bool theValue)
+{
+ myMutex.lock();
+ myIsActive = !(theValue);
+ myMutex.unlock();
+}
+
+typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
+
void SUPERVGUI_Thread::run()
{
SUPERV_CNode aNode = NULL;
if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
||
- aEvent == SUPERV::NoEvent && aState == SUPERV::NoState) {
+ aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
+ ||
+ aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
if (myMain->getEventNodes().count()) {
myMain->removeEventNodes();
}
case SUPERV_Error :
stopThread(tr("MSG_GRAPH_ABORTED"));
break;
+
+ case SUPERV_Kill:
+ stopThread(tr("MSG_GRAPH_KILLED"));
+ break;
}
break;
//if list not empty call execute() -> sync()
char * aNodeName = *(myMain->getEventNodes().getFirst());
SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
- qApp->lock();
- myMain->execute(aNodeName,aNodeState); //this is from main
- qApp->unlock();
+
+ // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
+ ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
+
myMain->removeFirstEN();
myMain->removeFirstS();
+
}
aPrevNode = aNode;