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 ),
144 Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
145 theParent->setViewWidget(this);
146 dataflow = theDataFlow;
147 if (SUPERV_isNull(dataflow)) {
148 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY"));
155 void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
156 Trace("SUPERVGUI_Main::init");
157 if (theDesktop) myNService = theDesktop->getNameService();
163 myThread = new SUPERVGUI_Thread();
164 myThread->setMain(this);
167 myCurrentView = CANVAS;
168 myIsFromStudy = false;
170 study = theDesktop->getActiveStudy();
172 SALOMEDS::Study_var studyDoc = study->getStudyDocument();
173 bool aLocked = studyDoc->GetProperties()->IsLocked();
174 SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
175 SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
176 SALOMEDS::GenericAttribute_var anAttr;
177 SALOMEDS::AttributeName_var aName;
178 SALOMEDS::AttributePixMap_var aPixmap;
179 if (father->_is_nil()) {
180 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
182 if (aLocked) studyDoc->GetProperties()->SetLocked(false);
183 father = builder->NewComponent(STUDY_SUPERVISION);
184 anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
185 aName = SALOMEDS::AttributeName::_narrow(anAttr);
186 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
188 anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
189 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
190 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
192 builder->DefineComponentInstance(father, Supervision.getEngine());
193 if (aLocked) studyDoc->GetProperties()->SetLocked(true);
197 objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
200 graph = new SUPERVGUI_Graph(this);
202 array = new SUPERVGUI_Array(this);
204 myCanvas = new SUPERVGUI_Canvas(this);
205 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
207 message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
208 notification = new NOTIFICATION_Consumer();
210 QBoxLayout * layout = new QVBoxLayout(this);
211 layout->setMargin(0);
212 layout->setSpacing(0);
213 layout->addWidget(graph);
214 layout->addWidget(array);
215 layout->addWidget(myCanvasView);
217 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
222 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
223 myLogFile = fopen( myLogFileName.latin1(), "a" );
224 if ( myLogFile == NULL )
227 myTimer = new QTimer( this );
228 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
231 SUPERVGUI_Main::~SUPERVGUI_Main() {
232 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
234 // close all opened SubGraphs
235 QMap<QString, QAD_StudyFrame*>::iterator it;
236 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
237 it.data()->removeEventFilter(this);
238 it.data()->disconnect();
241 QAD_Study* aStudy = it.data()->getStudy();
242 aStudy->removeStudyFrame(it.data());
245 mySubGraphMap.clear();
247 QAD_StudyFrame* aSubGraph;
248 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
249 aSubGraph->removeEventFilter(this);
254 if ( myLogFile != NULL) {
257 graph->removeLinks();
259 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
260 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
265 void SUPERVGUI_Main::filterNotification() {
266 Trace("SUPERVGUI_Main::filterNotification");
267 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
268 dlg->setFiltered( myFiltered );
269 dlg->setLogged( myLogged, myLogFileName );
270 dlg->setWarning( myWarning );
271 dlg->setStep( myStep );
272 dlg->setTrace( myTrace );
273 dlg->setVerbose( myVerbose );
274 if ( dlg->exec() == QDialog::Accepted ) {
275 myLogged = dlg->getLogged();
276 myLogFileName = dlg->getLogFile();
277 myFiltered = dlg->getFiltered();
278 myWarning = dlg->getWarning();
279 myStep = dlg->getStep();
280 myTrace = dlg->getTrace();
281 myVerbose = dlg->getVerbose();
283 if ( myLogFile != NULL) {
287 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
288 myLogFile = fopen( myLogFileName.latin1(), "a" );
289 if ( myLogFile == NULL ) {
291 QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
297 void SUPERVGUI_Main::changeDSGraphParameters() {
298 SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly());
304 void SUPERVGUI_Main::syncAsync() {
305 Trace("SUPERVGUI_Main::syncAsync")
306 QTimer::singleShot(1, this, SLOT(sync()));
311 * Called by thread when dataflow is executing
313 void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) {
314 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
315 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
316 if (aNode) aNode->sync();
319 SUPERVGUI_Node* aNodePrs;
320 SUPERVGUI_GraphNode* aGraphNodePrs;
321 if (myCurrentView == TABLE) {
322 aNodePrs = (SUPERVGUI_Node*) array->child(theNodeName, "SUPERVGUI_Node");
323 aGraphNodePrs = (SUPERVGUI_GraphNode*) array->child(theNodeName, "SUPERVGUI_GraphNode");
325 aNodePrs = (SUPERVGUI_Node*) graph->child(theNodeName, "SUPERVGUI_Node");
326 aGraphNodePrs = (SUPERVGUI_GraphNode*) graph->child(theNodeName, "SUPERVGUI_GraphNode");
329 aGraphNodePrs->sync();
332 aNodePrs->syncOnEvent(theNodeState);
338 void SUPERVGUI_Main::sync() {
339 Trace("SUPERVGUI_Main::sync")
340 if ((SUPERV_isNull(dataflow))) return;
341 QString t = tr("GRAPH_TITLE");
343 t += dataflow->Name();
346 study->updateObjBrowser();
347 if (myCurrentView == TABLE) {
349 } else if (myCurrentView == GRAPH) {
358 void SUPERVGUI_Main::showTable() {
359 if (myCurrentView == TABLE) return;
361 if (array->create()) {
362 if (myCurrentView == GRAPH)
365 myCanvasView->hide();
366 myCurrentView = TABLE;
372 void SUPERVGUI_Main::showFullGraph() {
373 if (myCurrentView == TABLE) {
377 else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
378 myCanvasView->hide();
381 myCurrentView = GRAPH;
383 graph->setFullView();
387 void SUPERVGUI_Main::showContolFlow() {
389 if (myCurrentView == TABLE) {
393 else if (myCurrentView == GRAPH) {
397 myCurrentView = CONTROLFLOW;
398 myCanvas->setControlView();
401 myCanvasView->show();
405 void SUPERVGUI_Main::showCanvas() {
406 if (myCurrentView == CANVAS) return;
409 if (myCurrentView == TABLE) {
413 else if (myCurrentView == GRAPH) {
417 myCurrentView = CANVAS;
418 myCanvas->setFullView();
421 myCanvasView->show();
425 void SUPERVGUI_Main::insertFile() {
426 Trace("SUPERVGUI_Main::insertFile")
427 if ((SUPERV_isNull(dataflow))) return;
429 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
432 tr("MSG_GRAPH_INSERT"),
435 if (dataflow->Import(f.latin1())) {
436 if (myCurrentView == TABLE) {
440 else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
445 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
450 void SUPERVGUI_Main::copy() {
451 Trace("SUPERVGUI_Main::copy");
452 if (dataflow->ThreadsMax() == 0) {
453 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
456 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
457 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
458 (aStudyFrame->getRightFrame()->getViewFrame());
460 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
461 if (dataflow->IsStreamGraph()) {
462 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
463 if (SUPERV_isNull(aSGraph)) {
464 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
467 aNewGraph = aSGraph->StreamCopy();
470 aNewGraph = dataflow->Copy();
472 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
473 aNewName += dataflow->Name();
474 aNewGraph->SetName(aNewName);
475 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
476 Supervision.getDesktop(),
478 study->showFrame(aStudyFrame);
482 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
484 if (theNode->IsMacro()) {
485 // get SubGraph from MacroNode
486 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
488 if (aMacro->IsStreamMacro())
489 aGraph = aMacro->StreamObjRef();
491 aGraph = aMacro->FlowObjRef();
494 if (SUPERV_isNull(aGraph)) {
495 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
499 QString aGraphName = aGraph->Name();
500 QAD_StudyFrame* aStudyFrame;
501 if (mySubGraphs.contains(aGraphName)) {
502 aStudyFrame = mySubGraphs[aGraphName];
503 aStudyFrame->setActiveWindow();
504 aStudyFrame->setFocus();
507 aStudyFrame = Supervision.createGraph();
509 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
510 (aStudyFrame->getRightFrame()->getViewFrame());
512 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
513 Supervision.getDesktop(),
515 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
516 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
517 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
518 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
519 aStudyFrame->installEventFilter(this);
521 mySubGraphs.insert(aGraphName, aStudyFrame);
522 mySubGraphMap.insert(aGraphName, theNode->Name());
527 study->showFrame(aStudyFrame);
528 if (!correct) myLastGraph = aStudyFrame;
533 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
535 // workaround to get close event
536 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
537 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
538 onSubGraphClosed(aFrame);
540 return SUPERVGraph_View::eventFilter(o, e);
543 // workaround to fix PAL6255 -> opened SubGraph is not on top
544 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
547 QAD_StudyFrame* aFrame = myLastGraph;
549 aFrame->setActiveWindow();
554 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
556 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
557 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
558 theStudyFrame->removeEventFilter(this);
559 disconnect(theStudyFrame, 0, this, 0);
561 SUPERVGraph_View* view = supervFrame->getViewWidget();
562 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
564 QString aGraphName = aGraph->getDataflow()->Name();
565 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
566 if (it != mySubGraphMap.end()) {
567 QString aNodeName = it.data();
568 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
569 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
574 mySubGraphMap.remove(it);
576 mySubGraphs.remove(aGraphName);
581 void SUPERVGUI_Main::run() {
582 Trace("SUPERVGUI_Main::run")
583 if ((SUPERV_isNull(dataflow))) return;
585 if (dataflow->IsEditing()) {
586 if (!dataflow->IsValid()) {
587 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
588 } else if (!dataflow->IsExecutable()) {
589 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
590 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
591 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
593 myRunTime = QDateTime::currentDateTime();
596 if (!dataflow->ReRun()) {
597 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
598 if (dataflow->State() == SUPERV::ErrorState) {
602 myThread->startThread(tr("MSG_GRAPH_STARTED"));
606 if (!dataflow->Run()) {
607 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
608 if (dataflow->State() == SUPERV::ErrorState) {
612 myThread->startThread(tr("MSG_GRAPH_STARTED"));
618 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
624 void SUPERVGUI_Main::startExecute() {
625 Trace("SUPERVGUI_Main::startExecute")
626 if ((SUPERV_isNull(dataflow))) return;
628 if (dataflow->IsEditing()) {
629 if (!dataflow->IsValid()) {
630 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
631 } else if (!dataflow->IsExecutable()) {
632 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
633 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
634 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
636 myRunTime = QDateTime::currentDateTime();
639 if (!dataflow->ReStart()) {
640 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
642 myThread->startThread(tr("MSG_GRAPH_STARTED"));
646 if (!dataflow->Start()) {
647 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
649 myThread->startThread(tr("MSG_GRAPH_STARTED"));
654 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
659 void SUPERVGUI_Main::kill() {
660 Trace("SUPERVGUI_Main::kill")
661 if ((SUPERV_isNull(dataflow))) return;
663 if (dataflow->IsEditing()) {
664 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
665 } else if (dataflow->Kill()) {
667 myThread->stopThread(tr("MSG_GRAPH_KILLED"));
670 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
674 void SUPERVGUI_Main::suspendResume() {
675 Trace("SUPERVGUI_Main::suspendResume")
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->State() == SUPERV_Suspend) {
681 if (dataflow->Resume()) {
682 myThread->startThread(tr("MSG_DF_RESUMED"));
684 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
687 if (dataflow->Suspend()) {
689 myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
691 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
696 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
697 Trace("SUPERVGUI_Main::stopRestart")
698 if ((SUPERV_isNull(dataflow))) return;
700 if (dataflow->IsEditing()) {
701 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
702 } else if (dataflow->State() == SUPERV_Stop) {
703 if (dataflow->ReStart()) {
704 message->setMessage(tr("MSG_DF_RESTARTED"));
707 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
710 if (dataflow->Stop()) {
713 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
718 void SUPERVGUI_Main::addNode() {
719 Trace("SUPERVGUI_Main::addNode");
720 if (SUPERV_isNull(dataflow)) return;
722 if (dataflow->IsExecuting()) {
723 if (QMessageBox::warning(QAD_Application::getDesktop(),
724 tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
725 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
731 Supervision.getBrowser()->choose();
735 * Add Computation node
737 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
738 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
739 switch (myCurrentView) {
742 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
743 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
744 graph->addChild(aNode, theNode->X(), theNode->Y());
755 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
756 aNode->move(theNode->X(), theNode->Y());
757 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
768 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
769 switch (myCurrentView) {
772 SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode);
773 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
774 graph->addChild(aNode, theNode->X(), theNode->Y());
785 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
786 aNode->move(theNode->X(), theNode->Y());
787 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
798 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
799 switch (myCurrentView) {
802 SUPERVGUI_StartControlNode* aStartPrs =
803 new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode);
804 SUPERVGUI_EndControlNode* aEndPrs =
805 new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs);
807 graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y());
808 graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y());
809 graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y());
810 graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y());
812 aStartPrs->updateLinksPrs();
813 aEndPrs->updateLinksPrs();
817 graph->repaintContents();
827 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
828 aStartNode->move(theStartNode->X(), theStartNode->Y());
829 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
831 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
832 aEndNode->move(theEndNode->X(), theEndNode->Y());
833 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
847 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
848 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
849 switch (myCurrentView) {
852 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
853 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
854 graph->addChild(aNode, theNode->X(), theNode->Y());
865 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
866 aNode->move(theNode->X(), theNode->Y());
867 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
876 SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() {
877 Trace("SUPERVGUI_Main::getGraph")
881 SUPERVGUI_Array* SUPERVGUI_Main::getArray() {
882 Trace("SUPERVGUI_Main::getArray")
886 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
887 Trace("SUPERVGUI_Main::getCanvas")
891 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
892 Trace("SUPERVGUI_Main::getCanvasView")
893 return(myCanvasView);
896 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
897 Trace("SUPERVGUI_Main::getDataflow")
901 QAD_Message* SUPERVGUI_Main::getMessage() {
902 Trace("SUPERVGUI_Main::getMessage")
906 QAD_Study* SUPERVGUI_Main::getStudy() {
907 Trace("SUPERVGUI_Main::getStudy")
911 bool SUPERVGUI_Main::isArrayShown() {
912 Trace("SUPERVGUI_Main::isArrayShown")
913 return(myCurrentView == TABLE);
916 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
917 Trace("SUPERVGUI_Main::showPopup");
918 // To check is Supervision active?
919 if (myIsLocked) return;
920 //if (dataflow->IsExecuting()) return;
922 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
923 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
926 if (e->button() == RightButton) {
927 p->exec(e->globalPos());
933 void SUPERVGUI_Main::changeInformation() {
934 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
938 /* Trace("SUPERVGUI_Main::changeInformation")
939 if (Supervision.information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly())) {
944 // returns false, if can't add dataflow into the study
945 bool SUPERVGUI_Main::addStudy() {
946 Trace("SUPERVGUI_Main::addStudy");
947 if (myIsFromStudy) return false;
948 if ((SUPERV_isNull(dataflow))) return false;
950 SALOMEDS::Study_var aStudy = study->getStudyDocument();
951 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
952 SALOMEDS::GenericAttribute_var anAttr;
953 SALOMEDS::AttributeName_var aName;
954 SALOMEDS::AttributeIOR_var anIORAttr;
955 SALOMEDS::AttributePixMap_var aPixmap;
956 bool aLocked = aStudy->GetProperties()->IsLocked();
957 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
959 // searching dataflow
960 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
961 if (aSO->_is_nil()) { // create new dataflow SObject
962 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
963 if (aComponent->_is_nil()) { // is supervision component not found, then create it
964 QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
965 anOperation->start();
966 if (aLocked) aStudy->GetProperties()->SetLocked(false);
967 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
968 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
969 aName = SALOMEDS::AttributeName::_narrow(anAttr);
970 //aName->SetValue(STUDY_SUPERVISION);
971 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
972 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
973 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
974 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
975 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
976 if (aLocked) aStudy->GetProperties()->SetLocked(true);
977 anOperation->finish();
980 aSO = aBuilder->NewObject(aComponent);
981 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
982 aName = SALOMEDS::AttributeName::_narrow(anAttr);
983 aName->SetValue(dataflow->Name());
984 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
985 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
986 anIORAttr->SetValue(dataflow->getIOR());
988 if (aLocked) return false;
992 Supervision.unregisterGraph(this);
993 Supervision.registerGraph(dataflow->getIOR(), this);
994 myIsFromStudy = true;
999 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
1000 Trace("SUPERVGUI_Main::chooseData")
1002 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
1003 if (!id.isEmpty()) {
1004 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
1005 SALOMEDS::GenericAttribute_var anAttr;
1006 SALOMEDS::AttributeIOR_var anIOR;
1007 Standard_CString ior = "";
1008 if (object->FindAttribute(anAttr, "AttributeIOR")) {
1009 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1010 ior = anIOR->Value();
1011 portIn->setValue(ior);
1015 setCursor(Supervision.getCursor());
1016 objectBrowser->setCursor(Supervision.getCursor());
1017 Supervision.putInfo("");
1023 void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) {
1024 Trace("SUPERVGUI_Main::setData")
1027 setCursor(forbiddenCursor);
1028 objectBrowser->setCursor(pointingHandCursor);
1029 Supervision.putInfo(tr("MSG_CHOOSE_DATA"));
1032 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
1033 const SALOMEDS::SObject_var theSO,
1034 const char* theName,
1035 //QAD_Operation* theOperation,
1037 SALOMEDS::SObject_var aResult;
1038 SALOMEDS::AttributeName_var aName;
1039 SALOMEDS::GenericAttribute_var anAttr;
1040 if (!*theStarted) { // optimisation
1041 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
1042 for (; anIterator->More(); anIterator->Next()) {
1043 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
1044 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1045 if (strcmp(aName->Value(), theName) == 0) {
1046 aResult = anIterator->Value();
1052 if (!aResult->_is_nil()) return aResult;
1054 SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
1057 //theOperation->start();
1058 aBuilder->NewCommand();
1060 aResult = aBuilder->NewObject(theSO);
1061 anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
1062 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1063 aName->SetValue(theName);
1067 bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) {
1068 Trace("SUPERVGUI_Main::putDataStudy");
1070 static bool isIn = false;
1071 if (isIn) return true; else isIn = true;
1073 SALOMEDS::Study_var aStudy = study->getStudyDocument();
1074 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1075 SALOMEDS::GenericAttribute_var anAttr;
1076 SALOMEDS::AttributeName_var aName;
1077 SALOMEDS::AttributeIOR_var anIORAttr;
1078 SALOMEDS::AttributePixMap_var aPixmap;
1079 bool aTransaction = false;
1080 bool aLocked = aStudy->GetProperties()->IsLocked();
1081 // QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
1083 // searching dataflow
1084 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
1085 if (aSO->_is_nil()) { // create new dataflow SObject
1086 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
1087 if (aComponent->_is_nil()) { // is supervision component not found, then create it
1088 //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1089 //anOperation->start();
1090 aBuilder->NewCommand();
1091 if (aLocked) aStudy->GetProperties()->SetLocked(false);
1092 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
1093 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
1094 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1095 //aName->SetValue(STUDY_SUPERVISION);
1096 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
1098 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
1099 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
1100 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
1101 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
1102 if (aLocked) aStudy->GetProperties()->SetLocked(true);
1103 // anOperation->finish();
1104 aBuilder->CommitCommand();
1106 aTransaction = true;
1108 aBuilder->NewCommand();
1109 aSO = aBuilder->NewObject(aComponent);
1110 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1111 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1112 aName->SetValue(dataflow->Name());
1113 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1114 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1115 anIORAttr->SetValue(dataflow->getIOR());
1117 //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1118 aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO
1119 QString("Run ") + myRunTime.toString() /*, anOperation*/, &aTransaction);
1120 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name()/*, anOperation*/, &aTransaction); // get node SO
1121 aSO = SearchOrCreateSOWithName(aStudy, aSO, inout/*, anOperation*/, &aTransaction); // get in/out SO
1122 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name()/*, anOperation*/, &aTransaction); // get port SO
1125 if (aTransaction) aBuilder->CommitCommand();
1131 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1132 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1133 if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) {
1137 // set object value to the study: if object is external, then put it with
1138 // help of the specific component - owner
1140 // get according component driver for result object
1141 SALOME_LifeCycleCORBA aLCC(myNService);
1142 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
1143 if (!aFNode->_is_nil()) {
1144 Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
1145 aFNode->GetComponentName());
1146 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
1147 if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
1148 CORBA::Object_ptr anObject = new CORBA::Object();
1149 CORBA::Any* anAny = p->ToAny();
1150 (*anAny) >>= anObject;
1152 if (aDriver->CanPublishInStudy(anObject)) {
1153 SALOMEDS::SObject_var aTmpSO;
1154 if (!aTransaction) {
1156 aTransaction = true;
1158 aBuilder->NewCommand();
1160 aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, "");
1161 aBuilder->Addreference(aSO, aTmpSO);
1162 } else { // can't publish object: abort transaction
1163 if (aTransaction) aBuilder->AbortCommand();
1168 } else { // component has no drivel, but could store IORs (like Calculator)
1169 SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR(p->ToString());
1170 if (!CORBA::is_nil(anIORSO)) aBuilder->Addreference(aSO, anIORSO);
1174 if (!aTransaction) {
1175 aTransaction = true;
1177 aBuilder->NewCommand();
1179 anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
1184 aBuilder->CommitCommand();
1185 if (!myThread->running())
1186 study->updateObjBrowser();
1192 void SUPERVGUI_Main::ActivatePanning()
1194 if (graph->isVisible()) {
1195 graph->ActivatePanning();
1196 } else if (array->isVisible()) {
1197 array->ActivatePanning();
1198 } else if (myCanvasView->isVisible()) {
1199 myCanvasView->ActivatePanning();
1204 void SUPERVGUI_Main::ResetView()
1206 if (graph->isVisible()) {
1208 } else if (array->isVisible()) {
1210 } else if (myCanvasView->isVisible()) {
1211 myCanvasView->ResetView();
1216 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1217 myIsFromStudy = theToStudy;
1218 graph->setAsFromStudy(theToStudy);
1219 array->setAsFromStudy(theToStudy);
1220 myCanvas->setAsFromStudy(theToStudy);
1223 void SUPERVGUI_Main::checkIsInStudy() {
1224 if (!myIsFromStudy) return;
1226 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1227 SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1228 SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1229 SALOMEDS::SObject_var aDataflowLbl;
1230 SALOMEDS::GenericAttribute_var anAttr;
1232 for (; aChildIterator->More(); aChildIterator->Next()) {
1233 aDataflowLbl = aChildIterator->Value();
1234 if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1237 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1238 if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1240 // This Graph considered as in study but in study it is not exists
1241 Supervision.unregisterGraph(this);
1242 setAsFromStudy(false);
1245 void SUPERVGUI_Main::syncNotification() {
1255 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1256 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1258 mess += "NOTIF: "; mess += graph;
1259 mess += " / " ; mess += node;
1260 mess += " / " ; mess += type;
1261 mess += " / " ; mess += message;
1262 getMessage()->setMessage(mess.latin1());
1267 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1268 char* sender, long counter, char* date, long stamp) {
1269 Trace("SUPERVGUI_Main::isFiltered");
1271 if (strcmp(getDataflow()->Name(), graph) == 0) {
1273 QObjectList* nodes = queryList("SUPERVGUI_Node");
1274 QObjectListIt i(*nodes);
1275 while ((n=(SUPERVGUI_Node*)i.current()) != 0) {
1277 if (strcmp(n->name(), node) == 0) {
1278 if (strcmp(type, NOTIF_WARNING) == 0) {
1280 } else if (strcmp(type, NOTIF_STEP) == 0) {
1282 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1284 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1291 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1292 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 );
1293 fflush( myLogFile );
1299 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1304 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1306 array->setPaletteBackgroundColor(color);
1307 graph->setPaletteBackgroundColor(color);
1308 myCanvas->setBackgroundColor(color);
1309 myCanvasView->setPaletteBackgroundColor(color.light());
1311 SUPERVGraph_View::setPaletteBackgroundColor(color);
1314 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1315 return myEventNodes;
1318 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1319 myEventNodes = theEventNodes;
1322 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1326 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1327 myStates = theStates;
1330 int SUPERVGUI_Main::getNodesNumber() {
1331 //create a list of nodes of the graph
1332 SUPERV_Nodes nodes = getDataflow()->Nodes();
1333 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1334 nodes->INodes.length() + nodes->GNodes.length() +
1335 nodes->LNodes.length() + nodes->SNodes.length();
1339 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1343 void SUPERVGUI_Main::startTimer() {
1344 myTimer->start(500);
1347 void SUPERVGUI_Main::executionFinished() {
1348 getStudy()->updateObjBrowser();
1352 void SUPERVGUI_Main::checkExecution() {
1353 if (myThread->finished()) {
1355 executionFinished();
1359 /******************************* SUPERVGUI_Thread class ****************************************/
1360 SUPERVGUI_Thread::SUPERVGUI_Thread()
1366 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1368 //it is a virtual destructor and needs to be determine here
1371 void SUPERVGUI_Thread::startThread(const char* m)
1377 myMain->getMessage()->setMessage(m);
1382 void SUPERVGUI_Thread::stopThread(const char* m)
1384 myMain->getMessage()->setMessage(m);
1387 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1392 void SUPERVGUI_Thread::KillThread(bool theValue)
1395 myIsActive = !(theValue);
1399 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1401 void SUPERVGUI_Thread::run()
1403 SUPERV_CNode aNode = NULL;
1404 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1405 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1407 SUPERV_CNode aPrevNode = NULL;
1408 SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1409 SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1414 QPtrList< char * > anEventNodes;
1415 QPtrList< SUPERV::GraphState > aStates;
1417 myMain->startTimer();
1419 myMain->getDataflow()->Event(aNode, aEvent, aState);
1421 if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1423 aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1425 aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1427 if (myMain->getEventNodes().count()) {
1428 myMain->removeEventNodes();
1430 if (myMain->getStates().count()) {
1431 myMain->removeStates();
1436 if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1437 aName = aNode->Name();
1440 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
1441 anEventNodes = myMain->getEventNodes();
1442 anEventNodes.append( &aName ) ;
1443 myMain->setEventNodes(anEventNodes);
1445 aStates = myMain->getStates();
1446 aStates.append( &aState ) ;
1447 myMain->setStates(aStates);
1450 if ( aEvent == aPrevEvent && aState == aPrevState) {
1451 QString aNameStr = aName;
1452 QString aPrevNameStr = aPrevName;
1453 if ( aNameStr != aPrevNameStr ) {
1454 anEventNodes = myMain->getEventNodes();
1455 anEventNodes.append( &aName ) ;
1456 myMain->setEventNodes(anEventNodes);
1458 aStates = myMain->getStates();
1459 aStates.append( &aState ) ;
1460 myMain->setStates(aStates);
1464 anEventNodes = myMain->getEventNodes();
1465 anEventNodes.append( &aName ) ;
1466 myMain->setEventNodes(anEventNodes);
1468 aStates = myMain->getStates();
1469 aStates.append( &aState ) ;
1470 myMain->setStates(aStates);
1475 switch (myMain->getDataflow()->State()) {
1476 case SUPERV_Editing :
1477 stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1480 case SUPERV_Suspend :
1481 stopThread(tr("MSG_GRAPH_SUSPENDED"));
1485 stopThread(tr("MSG_GRAPH_FINISHED"));
1489 stopThread(tr("MSG_GRAPH_ABORTED"));
1493 stopThread(tr("MSG_GRAPH_KILLED"));
1499 if ( myMain->getEventNodes().count() ) {
1500 //if list not empty call execute() -> sync()
1501 char * aNodeName = *(myMain->getEventNodes().getFirst());
1502 SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1504 // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1505 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1507 myMain->removeFirstEN();
1508 myMain->removeFirstS();
1512 aPrevEvent = aEvent;
1513 aPrevState = aState;
1515 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
1518 aPrevName = aPrevNode->Name();
1523 // VSR: 04/12/03 ---> update object browser ufter finishing
1525 // myMain->getStudy()->updateObjBrowser();
1527 // VSR: 04/12/03 <---
1532 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1536 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1537 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1539 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1540 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1541 setSizeGripEnabled( true );
1544 QGridLayout* TopLayout = new QGridLayout( this );
1545 TopLayout->setSpacing( 6 );
1546 TopLayout->setMargin( 11 );
1548 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1549 TopGroup->setColumnLayout(0, Qt::Vertical );
1550 TopGroup->layout()->setSpacing( 0 );
1551 TopGroup->layout()->setMargin( 0 );
1552 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1553 TopGroupLayout->setAlignment( Qt::AlignTop );
1554 TopGroupLayout->setSpacing( 6 );
1555 TopGroupLayout->setMargin( 11 );
1558 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1559 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1561 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1562 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1563 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1566 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1567 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1569 myTimeOut = new QLineEdit( TopGroup );
1570 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1571 myTimeOut->setValidator( new QIntValidator(this) );
1572 myTimeOut->setMinimumSize( 100, 0 );
1573 myTimeOut->setReadOnly( isReadOnly );
1574 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1577 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1578 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1580 myDataStreamTrace = new QComboBox( TopGroup );
1581 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1582 myDataStreamTrace->insertItem("WithoutTrace");
1583 myDataStreamTrace->insertItem("SummaryTrace");
1584 myDataStreamTrace->insertItem("DetailedTrace");
1585 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1587 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1588 GroupButtons->setColumnLayout(0, Qt::Vertical );
1589 GroupButtons->layout()->setSpacing( 0 );
1590 GroupButtons->layout()->setMargin( 0 );
1591 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1592 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1593 GroupButtonsLayout->setSpacing( 6 );
1594 GroupButtonsLayout->setMargin( 11 );
1596 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1597 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1599 GroupButtonsLayout->addWidget( okB, 0, 0 );
1600 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1601 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1603 TopLayout->addWidget( TopGroup, 0, 0 );
1604 TopLayout->addWidget( GroupButtons, 1, 0 );
1606 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1607 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1615 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1616 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1622 void SUPERVGUI_DSGraphParameters::setData() {
1625 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1627 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1628 if (myGraph->IsStreamGraph()) {
1629 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1630 if (!SUPERV_isNull(aSGraph))
1631 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1634 myDeltaTime->setValue(aDeltaTime);
1635 myTimeOut->setText(QString("%1").arg(aTimeOut));
1636 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1642 void SUPERVGUI_DSGraphParameters::accept() {
1643 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1644 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1645 // myDeltaTime->value());
1646 if (myGraph->IsStreamGraph()) {
1647 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1648 if (!SUPERV_isNull(aSGraph))
1649 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1650 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1651 myDeltaTime->value());