1 // SUPERV SUPERVGUI : GUI for Supervisor component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SUPERVGUI_Main.cxx
25 // Author : Francis KLOSS
29 #include "QAD_Splitter.h"
30 #include "QAD_LeftFrame.h"
31 #include "QAD_ObjectBrowser.h"
32 #include "QAD_ObjectBrowserItem.h"
33 #include "QAD_PyEditor.h"
34 #include "QAD_Message.h"
35 #include "QAD_FileDlg.h"
36 #include "QAD_Application.h"
37 #include "SUPERVGUI_Def.h"
38 #include "QAD_RightFrame.h"
39 #include "SALOME_Event.hxx"
40 #include "SUPERVGraph_ViewFrame.h"
43 #include "SUPERVGUI_Main.h"
44 #include "SUPERVGUI.h"
45 #include "SUPERVGUI_ComputeNode.h"
46 #include "SUPERVGUI_ControlNode.h"
47 #include "NOTIFICATION.hxx"
48 #include "SUPERVGUI_Notification.h"
49 #include "SALOMEGUI_ImportOperation.h"
50 #include "SUPERVGUI_Information.h"
51 #include "SUPERVGUI_CanvasControlNode.h"
52 #include <qvalidator.h>
55 asv 20.10.04: removed 2 SUPERVGUI_Main constructors. there is only ONE way
56 to create a Main object now: with a non-null DataFlow as a 3d parameter
57 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool fromIOR)
58 : SUPERVGraph_View(theParent),
61 myLogFileName( QString::null ),
68 Trace("SUPERVGUI_Main::SUPERVGUI_Main (new)");
69 theParent->setViewWidget(this);
71 //SUPERVGUI_Main* am = Supervision.getMain();
72 QAD_ObjectBrowser* ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser();
74 // ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser();
76 //ob = am->objectBrowser;
78 QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)(ob->getListView()->currentItem());
79 SALOMEDS::SObject_var obj = theDesktop->getActiveStudy()->getStudyDocument()->FindObjectID(item->getEntry().latin1());
80 SALOMEDS::GenericAttribute_var anAttr;
81 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
82 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
83 Standard_CString ior = anIOR->Value();
84 dataflow = Supervision.getEngine()->getStreamGraph(ior);
85 if (SUPERV_isNull(dataflow)) {
86 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
92 QMessageBox::warning(0, tr("ERROR"), tr("MSG_NOACCESS_BY_IOR"));
96 dataflow = Supervision.getEngine()->StreamGraph(MAIN_NEW);
97 if (SUPERV_isNull(dataflow)) {
98 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_DF"));
106 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool isModify, const char* f)
107 : SUPERVGraph_View(theParent),
110 myLogFileName( QString::null ),
117 Trace("SUPERVGUI_Main::SUPERVGUI_Main (file)")
118 theParent->setViewWidget(this);
120 dataflow = Supervision.getEngine()->StreamGraph(f);
122 dataflow = Supervision.getEngine()->StreamGraphE(f);
124 if (SUPERV_isNull(dataflow)) {
125 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
133 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, SUPERV_Graph theDataFlow )
134 : SUPERVGraph_View(theParent),
137 myLogFileName( QString::null ),
143 myGUIEventLoopFinished( true )
145 Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
146 theParent->setViewWidget(this);
147 dataflow = theDataFlow;
148 if (SUPERV_isNull(dataflow)) {
149 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY"));
156 void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
157 Trace("SUPERVGUI_Main::init");
158 if (theDesktop) myNService = theDesktop->getNameService();
164 myThread = new SUPERVGUI_Thread();
165 myThread->setMain(this);
168 myCurrentView = CANVAS;
169 myIsFromStudy = false;
171 study = theDesktop->getActiveStudy();
173 SALOMEDS::Study_var studyDoc = study->getStudyDocument();
174 bool aLocked = studyDoc->GetProperties()->IsLocked();
175 SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
176 SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
177 SALOMEDS::GenericAttribute_var anAttr;
178 SALOMEDS::AttributeName_var aName;
179 SALOMEDS::AttributePixMap_var aPixmap;
180 if (father->_is_nil()) {
181 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
183 if (aLocked) studyDoc->GetProperties()->SetLocked(false);
184 father = builder->NewComponent(STUDY_SUPERVISION);
185 anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
186 aName = SALOMEDS::AttributeName::_narrow(anAttr);
187 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
189 anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
190 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
191 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
193 builder->DefineComponentInstance(father, Supervision.getEngine());
194 if (aLocked) studyDoc->GetProperties()->SetLocked(true);
198 objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
201 graph = new SUPERVGUI_Graph(this);
203 array = new SUPERVGUI_Array(this);
205 myCanvas = new SUPERVGUI_Canvas(this);
206 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
208 message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
209 notification = new NOTIFICATION_Consumer();
211 QBoxLayout * layout = new QVBoxLayout(this);
212 layout->setMargin(0);
213 layout->setSpacing(0);
214 layout->addWidget(graph);
215 layout->addWidget(array);
216 layout->addWidget(myCanvasView);
218 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
223 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
224 myLogFile = fopen( myLogFileName.latin1(), "a" );
225 if ( myLogFile == NULL )
228 myTimer = new QTimer( this );
229 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
232 SUPERVGUI_Main::~SUPERVGUI_Main() {
233 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
235 // close all opened SubGraphs
236 QMap<QString, QAD_StudyFrame*>::iterator it;
237 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
238 it.data()->removeEventFilter(this);
239 it.data()->disconnect();
242 QAD_Study* aStudy = it.data()->getStudy();
243 aStudy->removeStudyFrame(it.data());
246 mySubGraphMap.clear();
248 QAD_StudyFrame* aSubGraph;
249 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
250 aSubGraph->removeEventFilter(this);
255 if ( myLogFile != NULL) {
258 graph->removeLinks();
260 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
261 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
266 void SUPERVGUI_Main::filterNotification() {
267 Trace("SUPERVGUI_Main::filterNotification");
268 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
269 dlg->setFiltered( myFiltered );
270 dlg->setLogged( myLogged, myLogFileName );
271 dlg->setWarning( myWarning );
272 dlg->setStep( myStep );
273 dlg->setTrace( myTrace );
274 dlg->setVerbose( myVerbose );
275 if ( dlg->exec() == QDialog::Accepted ) {
276 myLogged = dlg->getLogged();
277 myLogFileName = dlg->getLogFile();
278 myFiltered = dlg->getFiltered();
279 myWarning = dlg->getWarning();
280 myStep = dlg->getStep();
281 myTrace = dlg->getTrace();
282 myVerbose = dlg->getVerbose();
284 if ( myLogFile != NULL) {
288 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
289 myLogFile = fopen( myLogFileName.latin1(), "a" );
290 if ( myLogFile == NULL ) {
292 QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
298 void SUPERVGUI_Main::changeDSGraphParameters() {
299 SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly());
305 void SUPERVGUI_Main::syncAsync() {
306 Trace("SUPERVGUI_Main::syncAsync")
307 QTimer::singleShot(1, this, SLOT(sync()));
312 * Called by thread when dataflow is executing
314 void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) {
315 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
316 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
317 if (aNode) aNode->sync();
320 SUPERVGUI_Node* aNodePrs;
321 SUPERVGUI_GraphNode* aGraphNodePrs;
322 if (myCurrentView == TABLE) {
323 aNodePrs = (SUPERVGUI_Node*) array->child(theNodeName, "SUPERVGUI_Node");
324 aGraphNodePrs = (SUPERVGUI_GraphNode*) array->child(theNodeName, "SUPERVGUI_GraphNode");
326 aNodePrs = (SUPERVGUI_Node*) graph->child(theNodeName, "SUPERVGUI_Node");
327 aGraphNodePrs = (SUPERVGUI_GraphNode*) graph->child(theNodeName, "SUPERVGUI_GraphNode");
330 aGraphNodePrs->sync();
333 aNodePrs->syncOnEvent(theNodeState);
339 void SUPERVGUI_Main::sync() {
340 Trace("SUPERVGUI_Main::sync")
341 if ((SUPERV_isNull(dataflow))) return;
342 QString t = tr("GRAPH_TITLE");
344 t += dataflow->Name();
347 study->updateObjBrowser();
348 if (myCurrentView == TABLE) {
350 } else if (myCurrentView == GRAPH) {
359 void SUPERVGUI_Main::showTable() {
360 if (myCurrentView == TABLE) return;
362 if (array->create()) {
363 if (myCurrentView == GRAPH)
366 myCanvasView->hide();
367 myCurrentView = TABLE;
373 void SUPERVGUI_Main::showFullGraph() {
374 if (myCurrentView == TABLE) {
378 else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
379 myCanvasView->hide();
382 myCurrentView = GRAPH;
384 graph->setFullView();
388 void SUPERVGUI_Main::showContolFlow() {
390 if (myCurrentView == TABLE) {
394 else if (myCurrentView == GRAPH) {
398 myCurrentView = CONTROLFLOW;
399 myCanvas->setControlView();
402 myCanvasView->show();
406 void SUPERVGUI_Main::showCanvas() {
407 if (myCurrentView == CANVAS) return;
410 if (myCurrentView == TABLE) {
414 else if (myCurrentView == GRAPH) {
418 myCurrentView = CANVAS;
419 myCanvas->setFullView();
422 myCanvasView->show();
427 bool SUPERVGUI_Main::exportDataflow(QString theFile) {
428 Trace("SUPERVGUI_Main::exportDataflow");
429 if ((SUPERV_isNull(dataflow))) return false;
431 if (!theFile.isEmpty()) {
432 if (!dataflow->Export(theFile.latin1())) {
433 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING"));
440 void SUPERVGUI_Main::insertFile() {
441 Trace("SUPERVGUI_Main::insertFile")
442 if ((SUPERV_isNull(dataflow))) return;
444 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
447 tr("MSG_GRAPH_INSERT"),
450 if (dataflow->Import(f.latin1())) {
451 if (myCurrentView == TABLE) {
455 else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
460 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
465 void SUPERVGUI_Main::copy() {
466 Trace("SUPERVGUI_Main::copy");
467 if (dataflow->ThreadsMax() == 0) {
468 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
471 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
472 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
473 (aStudyFrame->getRightFrame()->getViewFrame());
475 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
476 if (dataflow->IsStreamGraph()) {
477 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
478 if (SUPERV_isNull(aSGraph)) {
479 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
482 aNewGraph = aSGraph->StreamCopy();
485 aNewGraph = dataflow->Copy();
487 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
488 aNewName += dataflow->Name();
489 aNewGraph->SetName(aNewName);
490 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
491 Supervision.getDesktop(),
493 study->showFrame(aStudyFrame);
497 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
499 if (theNode->IsMacro()) {
500 // get SubGraph from MacroNode
501 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
503 if (aMacro->IsStreamMacro())
504 aGraph = aMacro->StreamObjRef();
506 aGraph = aMacro->FlowObjRef();
509 if (SUPERV_isNull(aGraph)) {
510 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
514 QString aGraphName = aGraph->Name();
515 QAD_StudyFrame* aStudyFrame;
516 if (mySubGraphs.contains(aGraphName)) {
517 aStudyFrame = mySubGraphs[aGraphName];
518 aStudyFrame->setActiveWindow();
519 aStudyFrame->setFocus();
522 aStudyFrame = Supervision.createGraph();
524 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
525 (aStudyFrame->getRightFrame()->getViewFrame());
527 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
528 Supervision.getDesktop(),
530 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
531 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
532 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
533 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
534 aStudyFrame->installEventFilter(this);
536 mySubGraphs.insert(aGraphName, aStudyFrame);
537 mySubGraphMap.insert(aGraphName, theNode->Name());
542 study->showFrame(aStudyFrame);
543 if (!correct) myLastGraph = aStudyFrame;
548 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
550 // workaround to get close event
551 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
552 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
553 onSubGraphClosed(aFrame);
555 return SUPERVGraph_View::eventFilter(o, e);
558 // workaround to fix PAL6255 -> opened SubGraph is not on top
559 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
562 QAD_StudyFrame* aFrame = myLastGraph;
564 aFrame->setActiveWindow();
569 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
571 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
572 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
573 theStudyFrame->removeEventFilter(this);
574 disconnect(theStudyFrame, 0, this, 0);
576 SUPERVGraph_View* view = supervFrame->getViewWidget();
577 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
579 QString aGraphName = aGraph->getDataflow()->Name();
580 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
581 if (it != mySubGraphMap.end()) {
582 QString aNodeName = it.data();
583 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
584 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
589 mySubGraphMap.remove(it);
591 mySubGraphs.remove(aGraphName);
596 void SUPERVGUI_Main::run() {
597 Trace("SUPERVGUI_Main::run")
598 if ((SUPERV_isNull(dataflow))) return;
600 if (dataflow->IsEditing()) {
601 if (!dataflow->IsValid()) {
602 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
603 } else if (!dataflow->IsExecutable()) {
604 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
605 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
606 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
608 myRunTime = QDateTime::currentDateTime();
611 if (!dataflow->ReRun()) {
612 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
613 if (dataflow->State() == SUPERV::ErrorState) {
617 myThread->startThread(tr("MSG_GRAPH_STARTED"));
621 if (!dataflow->Run()) {
622 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
623 if (dataflow->State() == SUPERV::ErrorState) {
627 myThread->startThread(tr("MSG_GRAPH_STARTED"));
633 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
639 void SUPERVGUI_Main::startExecute() {
640 Trace("SUPERVGUI_Main::startExecute")
641 if ((SUPERV_isNull(dataflow))) return;
643 if (dataflow->IsEditing()) {
644 if (!dataflow->IsValid()) {
645 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
646 } else if (!dataflow->IsExecutable()) {
647 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
648 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
649 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
651 myRunTime = QDateTime::currentDateTime();
654 if (!dataflow->ReStart()) {
655 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
657 myThread->startThread(tr("MSG_GRAPH_STARTED"));
661 if (!dataflow->Start()) {
662 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
664 myThread->startThread(tr("MSG_GRAPH_STARTED"));
669 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
674 void SUPERVGUI_Main::kill() {
675 Trace("SUPERVGUI_Main::kill")
676 if ((SUPERV_isNull(dataflow))) return;
678 if (dataflow->IsEditing()) {
679 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
680 } else if (dataflow->Kill()) {
682 myThread->stopThread(tr("MSG_GRAPH_KILLED"));
685 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
689 void SUPERVGUI_Main::suspendResume() {
690 Trace("SUPERVGUI_Main::suspendResume")
691 if ((SUPERV_isNull(dataflow))) return;
693 if (dataflow->IsEditing()) {
694 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
695 } else if (dataflow->State() == SUPERV_Suspend) {
696 if (dataflow->Resume()) {
697 myThread->startThread(tr("MSG_DF_RESUMED"));
699 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
702 if (dataflow->Suspend()) {
704 myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
706 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
711 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
712 Trace("SUPERVGUI_Main::stopRestart")
713 if ((SUPERV_isNull(dataflow))) return;
715 if (dataflow->IsEditing()) {
716 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
717 } else if (dataflow->State() == SUPERV_Stop) {
718 if (dataflow->ReStart()) {
719 message->setMessage(tr("MSG_DF_RESTARTED"));
722 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
725 if (dataflow->Stop()) {
728 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
733 void SUPERVGUI_Main::addNode() {
734 Trace("SUPERVGUI_Main::addNode");
735 if (SUPERV_isNull(dataflow)) return;
737 if (dataflow->IsExecuting()) {
738 if (QMessageBox::warning(QAD_Application::getDesktop(),
739 tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
740 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
746 Supervision.getBrowser()->choose();
750 * Add Computation node
752 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
753 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
754 switch (myCurrentView) {
757 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
758 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
759 graph->addChild(aNode, theNode->X(), theNode->Y());
770 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
771 aNode->move(theNode->X(), theNode->Y());
772 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
783 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
784 switch (myCurrentView) {
787 SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode);
788 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
789 graph->addChild(aNode, theNode->X(), theNode->Y());
800 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
801 aNode->move(theNode->X(), theNode->Y());
802 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
813 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
814 switch (myCurrentView) {
817 SUPERVGUI_StartControlNode* aStartPrs =
818 new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode);
819 SUPERVGUI_EndControlNode* aEndPrs =
820 new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs);
822 graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y());
823 graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y());
824 graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y());
825 graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y());
827 aStartPrs->updateLinksPrs();
828 aEndPrs->updateLinksPrs();
832 graph->repaintContents();
842 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
843 aStartNode->move(theStartNode->X(), theStartNode->Y());
844 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
846 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
847 aEndNode->move(theEndNode->X(), theEndNode->Y());
848 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
862 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
863 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
864 switch (myCurrentView) {
867 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
868 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
869 graph->addChild(aNode, theNode->X(), theNode->Y());
880 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
881 aNode->move(theNode->X(), theNode->Y());
882 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
891 SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() {
892 Trace("SUPERVGUI_Main::getGraph")
896 SUPERVGUI_Array* SUPERVGUI_Main::getArray() {
897 Trace("SUPERVGUI_Main::getArray")
901 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
902 Trace("SUPERVGUI_Main::getCanvas")
906 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
907 Trace("SUPERVGUI_Main::getCanvasView")
908 return(myCanvasView);
911 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
912 Trace("SUPERVGUI_Main::getDataflow")
916 QAD_Message* SUPERVGUI_Main::getMessage() {
917 Trace("SUPERVGUI_Main::getMessage")
921 QAD_Study* SUPERVGUI_Main::getStudy() {
922 Trace("SUPERVGUI_Main::getStudy")
926 bool SUPERVGUI_Main::isArrayShown() {
927 Trace("SUPERVGUI_Main::isArrayShown")
928 return(myCurrentView == TABLE);
931 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
932 Trace("SUPERVGUI_Main::showPopup");
933 // To check is Supervision active?
934 if (myIsLocked) return;
935 //if (dataflow->IsExecuting()) return;
937 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
938 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
941 if (e->button() == RightButton) {
942 p->exec(e->globalPos());
948 void SUPERVGUI_Main::changeInformation() {
949 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
953 /* Trace("SUPERVGUI_Main::changeInformation")
954 if (Supervision.information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly())) {
959 // returns false, if can't add dataflow into the study
960 bool SUPERVGUI_Main::addStudy() {
961 Trace("SUPERVGUI_Main::addStudy");
962 if (myIsFromStudy) return false;
963 if ((SUPERV_isNull(dataflow))) return false;
965 SALOMEDS::Study_var aStudy = study->getStudyDocument();
966 bool aLocked = aStudy->GetProperties()->IsLocked();
967 // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
972 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
973 SALOMEDS::GenericAttribute_var anAttr;
974 SALOMEDS::AttributeName_var aName;
975 SALOMEDS::AttributeIOR_var anIORAttr;
976 SALOMEDS::AttributePixMap_var aPixmap;
977 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
979 // searching dataflow
980 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
981 if (aSO->_is_nil()) { // create new dataflow SObject
982 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
983 if (aComponent->_is_nil()) { // is supervision component not found, then create it
984 QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
985 anOperation->start();
986 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
987 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
988 aName = SALOMEDS::AttributeName::_narrow(anAttr);
989 //aName->SetValue(STUDY_SUPERVISION);
990 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
991 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
992 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
993 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
994 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
995 anOperation->finish();
998 aSO = aBuilder->NewObject(aComponent);
999 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1000 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1001 aName->SetValue(dataflow->Name());
1002 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1003 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1004 anIORAttr->SetValue(dataflow->getIOR());
1009 Supervision.unregisterGraph(this);
1010 Supervision.registerGraph(dataflow->getIOR(), this);
1011 myIsFromStudy = true;
1016 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
1017 Trace("SUPERVGUI_Main::chooseData")
1019 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
1020 if (!id.isEmpty()) {
1021 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
1022 SALOMEDS::GenericAttribute_var anAttr;
1023 SALOMEDS::AttributeIOR_var anIOR;
1024 Standard_CString ior = "";
1025 if (object->FindAttribute(anAttr, "AttributeIOR")) {
1026 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1027 ior = anIOR->Value();
1028 portIn->setValue(ior);
1032 setCursor(Supervision.getCursor());
1033 objectBrowser->setCursor(Supervision.getCursor());
1034 Supervision.putInfo("");
1040 void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) {
1041 Trace("SUPERVGUI_Main::setData")
1044 setCursor(forbiddenCursor);
1045 objectBrowser->setCursor(pointingHandCursor);
1046 Supervision.putInfo(tr("MSG_CHOOSE_DATA"));
1049 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
1050 const SALOMEDS::SObject_var theSO,
1051 const char* theName,
1052 //QAD_Operation* theOperation,
1054 SALOMEDS::SObject_var aResult;
1055 SALOMEDS::AttributeName_var aName;
1056 SALOMEDS::GenericAttribute_var anAttr;
1057 if (!*theStarted) { // optimisation
1058 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
1059 for (; anIterator->More(); anIterator->Next()) {
1060 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
1061 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1062 if (strcmp(aName->Value(), theName) == 0) {
1063 aResult = anIterator->Value();
1069 if (!aResult->_is_nil()) return aResult;
1071 SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
1074 //theOperation->start();
1075 aBuilder->NewCommand();
1077 aResult = aBuilder->NewObject(theSO);
1078 anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
1079 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1080 aName->SetValue(theName);
1084 bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) {
1085 Trace("SUPERVGUI_Main::putDataStudy");
1087 // static variable to ensure that only one instance (thread) is executing this function
1088 static bool isIn = false;
1094 SALOMEDS::Study_var aStudy = study->getStudyDocument();
1095 bool aLocked = aStudy->GetProperties()->IsLocked();
1096 // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
1103 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1104 SALOMEDS::GenericAttribute_var anAttr;
1105 SALOMEDS::AttributeName_var aName;
1106 SALOMEDS::AttributeIOR_var anIORAttr;
1107 SALOMEDS::AttributePixMap_var aPixmap;
1108 bool aTransaction = false;
1110 // searching dataflow
1111 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
1112 if (aSO->_is_nil()) { // create new dataflow SObject
1113 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
1114 if (aComponent->_is_nil()) { // is supervision component not found, then create it
1115 aBuilder->NewCommand();
1116 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
1117 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
1118 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1119 //aName->SetValue(STUDY_SUPERVISION);
1120 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
1122 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
1123 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
1124 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
1125 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
1126 aBuilder->CommitCommand();
1128 aTransaction = true;
1129 aBuilder->NewCommand();
1130 aSO = aBuilder->NewObject(aComponent);
1131 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1132 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1133 aName->SetValue(dataflow->Name());
1134 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1135 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1136 anIORAttr->SetValue(dataflow->getIOR());
1139 aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO
1140 QString("Run ") + myRunTime.toString(), &aTransaction);
1141 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name(), &aTransaction); // get node SO
1142 aSO = SearchOrCreateSOWithName(aStudy, aSO, inout, &aTransaction); // get in/out SO
1143 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name(), &aTransaction); // get port SO
1145 if (aTransaction) aBuilder->CommitCommand();
1147 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1148 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1149 if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) {
1153 // set object value to the study: if object is external, then put it with
1154 // help of the specific component - owner
1156 // get according component driver for result object
1157 SALOME_LifeCycleCORBA aLCC(myNService);
1158 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
1159 if (!aFNode->_is_nil()) {
1160 Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
1161 aFNode->GetComponentName());
1162 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
1163 if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
1164 CORBA::Object_ptr anObject = new CORBA::Object();
1165 CORBA::Any* anAny = p->ToAny();
1166 (*anAny) >>= anObject;
1168 if (aDriver->CanPublishInStudy(anObject)) {
1169 SALOMEDS::SObject_var aTmpSO;
1170 if (!aTransaction) {
1172 aTransaction = true;
1173 aBuilder->NewCommand();
1175 aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, "");
1176 aBuilder->Addreference(aSO, aTmpSO);
1177 } else { // can't publish object: abort transaction
1178 if (aTransaction) aBuilder->AbortCommand();
1182 } else { // component has no drivel, but could store IORs (like Calculator)
1183 SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR(p->ToString());
1184 if (!CORBA::is_nil(anIORSO)) aBuilder->Addreference(aSO, anIORSO);
1188 if (!aTransaction) {
1189 aTransaction = true;
1190 aBuilder->NewCommand();
1192 anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
1196 aBuilder->CommitCommand();
1197 if (!myThread->running())
1198 study->updateObjBrowser();
1204 void SUPERVGUI_Main::ActivatePanning()
1206 if (graph->isVisible()) {
1207 graph->ActivatePanning();
1208 } else if (array->isVisible()) {
1209 array->ActivatePanning();
1210 } else if (myCanvasView->isVisible()) {
1211 myCanvasView->ActivatePanning();
1216 void SUPERVGUI_Main::ResetView()
1218 if (graph->isVisible()) {
1220 } else if (array->isVisible()) {
1222 } else if (myCanvasView->isVisible()) {
1223 myCanvasView->ResetView();
1228 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1229 myIsFromStudy = theToStudy;
1230 graph->setAsFromStudy(theToStudy);
1231 array->setAsFromStudy(theToStudy);
1232 myCanvas->setAsFromStudy(theToStudy);
1235 void SUPERVGUI_Main::checkIsInStudy() {
1236 if (!myIsFromStudy) return;
1238 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1239 SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1240 SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1241 SALOMEDS::SObject_var aDataflowLbl;
1242 SALOMEDS::GenericAttribute_var anAttr;
1244 for (; aChildIterator->More(); aChildIterator->Next()) {
1245 aDataflowLbl = aChildIterator->Value();
1246 if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1249 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1250 if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1252 // This Graph considered as in study but in study it is not exists
1253 Supervision.unregisterGraph(this);
1254 setAsFromStudy(false);
1257 void SUPERVGUI_Main::syncNotification() {
1267 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1268 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1270 mess += "NOTIF: "; mess += graph;
1271 mess += " / " ; mess += node;
1272 mess += " / " ; mess += type;
1273 mess += " / " ; mess += message;
1274 getMessage()->setMessage(mess.latin1());
1279 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1280 char* sender, long counter, char* date, long stamp) {
1281 Trace("SUPERVGUI_Main::isFiltered");
1283 if (strcmp(getDataflow()->Name(), graph) == 0) {
1285 QObjectList* nodes = queryList("SUPERVGUI_Node");
1286 QObjectListIt i(*nodes);
1287 while ((n=(SUPERVGUI_Node*)i.current()) != 0) {
1289 if (strcmp(n->name(), node) == 0) {
1290 if (strcmp(type, NOTIF_WARNING) == 0) {
1292 } else if (strcmp(type, NOTIF_STEP) == 0) {
1294 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1296 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1303 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1304 fprintf( myLogFile, "NOTIF %ld\t%s\t%s\t%ld\t%s\t%s\t%s\t%s\n", stamp, date, sender, counter, graph, node, type, message );
1305 fflush( myLogFile );
1311 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1316 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1318 array->setPaletteBackgroundColor(color);
1319 graph->setPaletteBackgroundColor(color);
1320 myCanvas->setBackgroundColor(color);
1321 myCanvasView->setPaletteBackgroundColor(color.light());
1323 SUPERVGraph_View::setPaletteBackgroundColor(color);
1326 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1327 return myEventNodes;
1330 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1331 myEventNodes = theEventNodes;
1334 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1338 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1339 myStates = theStates;
1342 int SUPERVGUI_Main::getNodesNumber() {
1343 //create a list of nodes of the graph
1344 SUPERV_Nodes nodes = getDataflow()->Nodes();
1345 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1346 nodes->INodes.length() + nodes->GNodes.length() +
1347 nodes->LNodes.length() + nodes->SNodes.length();
1351 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1355 void SUPERVGUI_Main::startTimer() {
1356 myTimer->start(500);
1359 void SUPERVGUI_Main::executionFinished() {
1360 getStudy()->updateObjBrowser();
1364 void SUPERVGUI_Main::checkExecution() {
1365 if (myThread->finished()) {
1367 executionFinished();
1371 /******************************* SUPERVGUI_Thread class ****************************************/
1372 SUPERVGUI_Thread::SUPERVGUI_Thread()
1378 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1380 //it is a virtual destructor and needs to be determine here
1383 void SUPERVGUI_Thread::startThread(const char* m)
1389 myMain->getMessage()->setMessage(m);
1394 void SUPERVGUI_Thread::stopThread(const char* m)
1396 myMain->getMessage()->setMessage(m);
1399 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1404 void SUPERVGUI_Thread::KillThread(bool theValue)
1407 myIsActive = !(theValue);
1411 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1413 void SUPERVGUI_Thread::run()
1415 SUPERV_CNode aNode = NULL;
1416 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1417 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1419 SUPERV_CNode aPrevNode = NULL;
1420 SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1421 SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1426 QPtrList< char * > anEventNodes;
1427 QPtrList< SUPERV::GraphState > aStates;
1429 myMain->startTimer();
1431 myMain->myGUIEventLoopFinished = false;
1434 myMain->getDataflow()->Event(aNode, aEvent, aState);
1436 if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1438 aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1440 aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1442 if (myMain->getEventNodes().count()) {
1443 myMain->removeEventNodes();
1445 if (myMain->getStates().count()) {
1446 myMain->removeStates();
1451 if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1452 aName = aNode->Name();
1455 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
1456 anEventNodes = myMain->getEventNodes();
1457 anEventNodes.append( &aName ) ;
1458 myMain->setEventNodes(anEventNodes);
1460 aStates = myMain->getStates();
1461 aStates.append( &aState ) ;
1462 myMain->setStates(aStates);
1465 if ( aEvent == aPrevEvent && aState == aPrevState) {
1466 QString aNameStr = aName;
1467 QString aPrevNameStr = aPrevName;
1468 if ( aNameStr != aPrevNameStr ) {
1469 anEventNodes = myMain->getEventNodes();
1470 anEventNodes.append( &aName ) ;
1471 myMain->setEventNodes(anEventNodes);
1473 aStates = myMain->getStates();
1474 aStates.append( &aState ) ;
1475 myMain->setStates(aStates);
1479 anEventNodes = myMain->getEventNodes();
1480 anEventNodes.append( &aName ) ;
1481 myMain->setEventNodes(anEventNodes);
1483 aStates = myMain->getStates();
1484 aStates.append( &aState ) ;
1485 myMain->setStates(aStates);
1490 switch (myMain->getDataflow()->State()) {
1491 case SUPERV_Editing :
1492 stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1495 case SUPERV_Suspend :
1496 stopThread(tr("MSG_GRAPH_SUSPENDED"));
1500 stopThread(tr("MSG_GRAPH_FINISHED"));
1504 stopThread(tr("MSG_GRAPH_ABORTED"));
1508 stopThread(tr("MSG_GRAPH_KILLED"));
1514 if ( myMain->getEventNodes().count() ) {
1515 //if list not empty call execute() -> sync()
1516 char * aNodeName = *(myMain->getEventNodes().getFirst());
1517 SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1519 // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1520 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1522 myMain->removeFirstEN();
1523 myMain->removeFirstS();
1527 aPrevEvent = aEvent;
1528 aPrevState = aState;
1530 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
1533 aPrevName = aPrevNode->Name();
1538 // VSR: 04/12/03 ---> update object browser ufter finishing
1540 // myMain->getStudy()->updateObjBrowser();
1542 // VSR: 04/12/03 <---
1544 myMain->myGUIEventLoopFinished = true;
1549 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1553 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1554 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1556 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1557 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1558 setSizeGripEnabled( true );
1561 QGridLayout* TopLayout = new QGridLayout( this );
1562 TopLayout->setSpacing( 6 );
1563 TopLayout->setMargin( 11 );
1565 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1566 TopGroup->setColumnLayout(0, Qt::Vertical );
1567 TopGroup->layout()->setSpacing( 0 );
1568 TopGroup->layout()->setMargin( 0 );
1569 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1570 TopGroupLayout->setAlignment( Qt::AlignTop );
1571 TopGroupLayout->setSpacing( 6 );
1572 TopGroupLayout->setMargin( 11 );
1575 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1576 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1578 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1579 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1580 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1583 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1584 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1586 myTimeOut = new QLineEdit( TopGroup );
1587 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1588 myTimeOut->setValidator( new QIntValidator(this) );
1589 myTimeOut->setMinimumSize( 100, 0 );
1590 myTimeOut->setReadOnly( isReadOnly );
1591 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1594 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1595 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1597 myDataStreamTrace = new QComboBox( TopGroup );
1598 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1599 myDataStreamTrace->insertItem("WithoutTrace");
1600 myDataStreamTrace->insertItem("SummaryTrace");
1601 myDataStreamTrace->insertItem("DetailedTrace");
1602 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1604 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1605 GroupButtons->setColumnLayout(0, Qt::Vertical );
1606 GroupButtons->layout()->setSpacing( 0 );
1607 GroupButtons->layout()->setMargin( 0 );
1608 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1609 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1610 GroupButtonsLayout->setSpacing( 6 );
1611 GroupButtonsLayout->setMargin( 11 );
1613 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1614 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1616 GroupButtonsLayout->addWidget( okB, 0, 0 );
1617 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1618 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1620 TopLayout->addWidget( TopGroup, 0, 0 );
1621 TopLayout->addWidget( GroupButtons, 1, 0 );
1623 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1624 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1632 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1633 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1639 void SUPERVGUI_DSGraphParameters::setData() {
1642 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1644 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1645 if (myGraph->IsStreamGraph()) {
1646 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1647 if (!SUPERV_isNull(aSGraph))
1648 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1651 myDeltaTime->setValue(aDeltaTime);
1652 myTimeOut->setText(QString("%1").arg(aTimeOut));
1653 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1659 void SUPERVGUI_DSGraphParameters::accept() {
1660 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1661 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1662 // myDeltaTime->value());
1663 if (myGraph->IsStreamGraph()) {
1664 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1665 if (!SUPERV_isNull(aSGraph))
1666 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1667 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1668 myDeltaTime->value());