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();
426 bool SUPERVGUI_Main::exportDataflow(QString theFile) {
427 Trace("SUPERVGUI_Main::exportDataflow");
428 if ((SUPERV_isNull(dataflow))) return false;
430 if (!theFile.isEmpty()) {
431 if (!dataflow->Export(theFile.latin1())) {
432 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING"));
439 void SUPERVGUI_Main::insertFile() {
440 Trace("SUPERVGUI_Main::insertFile")
441 if ((SUPERV_isNull(dataflow))) return;
443 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
446 tr("MSG_GRAPH_INSERT"),
449 if (dataflow->Import(f.latin1())) {
450 if (myCurrentView == TABLE) {
454 else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
459 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
464 void SUPERVGUI_Main::copy() {
465 Trace("SUPERVGUI_Main::copy");
466 if (dataflow->ThreadsMax() == 0) {
467 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
470 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
471 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
472 (aStudyFrame->getRightFrame()->getViewFrame());
474 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
475 if (dataflow->IsStreamGraph()) {
476 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
477 if (SUPERV_isNull(aSGraph)) {
478 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
481 aNewGraph = aSGraph->StreamCopy();
484 aNewGraph = dataflow->Copy();
486 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
487 aNewName += dataflow->Name();
488 aNewGraph->SetName(aNewName);
489 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
490 Supervision.getDesktop(),
492 study->showFrame(aStudyFrame);
496 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
498 if (theNode->IsMacro()) {
499 // get SubGraph from MacroNode
500 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
502 if (aMacro->IsStreamMacro())
503 aGraph = aMacro->StreamObjRef();
505 aGraph = aMacro->FlowObjRef();
508 if (SUPERV_isNull(aGraph)) {
509 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
513 QString aGraphName = aGraph->Name();
514 QAD_StudyFrame* aStudyFrame;
515 if (mySubGraphs.contains(aGraphName)) {
516 aStudyFrame = mySubGraphs[aGraphName];
517 aStudyFrame->setActiveWindow();
518 aStudyFrame->setFocus();
521 aStudyFrame = Supervision.createGraph();
523 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
524 (aStudyFrame->getRightFrame()->getViewFrame());
526 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
527 Supervision.getDesktop(),
529 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
530 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
531 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
532 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
533 aStudyFrame->installEventFilter(this);
535 mySubGraphs.insert(aGraphName, aStudyFrame);
536 mySubGraphMap.insert(aGraphName, theNode->Name());
541 study->showFrame(aStudyFrame);
542 if (!correct) myLastGraph = aStudyFrame;
547 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
549 // workaround to get close event
550 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
551 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
552 onSubGraphClosed(aFrame);
554 return SUPERVGraph_View::eventFilter(o, e);
557 // workaround to fix PAL6255 -> opened SubGraph is not on top
558 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
561 QAD_StudyFrame* aFrame = myLastGraph;
563 aFrame->setActiveWindow();
568 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
570 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
571 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
572 theStudyFrame->removeEventFilter(this);
573 disconnect(theStudyFrame, 0, this, 0);
575 SUPERVGraph_View* view = supervFrame->getViewWidget();
576 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
578 QString aGraphName = aGraph->getDataflow()->Name();
579 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
580 if (it != mySubGraphMap.end()) {
581 QString aNodeName = it.data();
582 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
583 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
588 mySubGraphMap.remove(it);
590 mySubGraphs.remove(aGraphName);
595 void SUPERVGUI_Main::run() {
596 Trace("SUPERVGUI_Main::run")
597 if ((SUPERV_isNull(dataflow))) return;
599 if (dataflow->IsEditing()) {
600 if (!dataflow->IsValid()) {
601 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
602 } else if (!dataflow->IsExecutable()) {
603 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
604 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
605 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
607 myRunTime = QDateTime::currentDateTime();
610 if (!dataflow->ReRun()) {
611 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
612 if (dataflow->State() == SUPERV::ErrorState) {
616 myThread->startThread(tr("MSG_GRAPH_STARTED"));
620 if (!dataflow->Run()) {
621 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
622 if (dataflow->State() == SUPERV::ErrorState) {
626 myThread->startThread(tr("MSG_GRAPH_STARTED"));
632 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
638 void SUPERVGUI_Main::startExecute() {
639 Trace("SUPERVGUI_Main::startExecute")
640 if ((SUPERV_isNull(dataflow))) return;
642 if (dataflow->IsEditing()) {
643 if (!dataflow->IsValid()) {
644 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
645 } else if (!dataflow->IsExecutable()) {
646 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
647 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
648 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
650 myRunTime = QDateTime::currentDateTime();
653 if (!dataflow->ReStart()) {
654 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
656 myThread->startThread(tr("MSG_GRAPH_STARTED"));
660 if (!dataflow->Start()) {
661 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
663 myThread->startThread(tr("MSG_GRAPH_STARTED"));
668 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
673 void SUPERVGUI_Main::kill() {
674 Trace("SUPERVGUI_Main::kill")
675 if ((SUPERV_isNull(dataflow))) return;
677 if (dataflow->IsEditing()) {
678 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
679 } else if (dataflow->Kill()) {
681 myThread->stopThread(tr("MSG_GRAPH_KILLED"));
684 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
688 void SUPERVGUI_Main::suspendResume() {
689 Trace("SUPERVGUI_Main::suspendResume")
690 if ((SUPERV_isNull(dataflow))) return;
692 if (dataflow->IsEditing()) {
693 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
694 } else if (dataflow->State() == SUPERV_Suspend) {
695 if (dataflow->Resume()) {
696 myThread->startThread(tr("MSG_DF_RESUMED"));
698 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
701 if (dataflow->Suspend()) {
703 myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
705 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
710 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
711 Trace("SUPERVGUI_Main::stopRestart")
712 if ((SUPERV_isNull(dataflow))) return;
714 if (dataflow->IsEditing()) {
715 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
716 } else if (dataflow->State() == SUPERV_Stop) {
717 if (dataflow->ReStart()) {
718 message->setMessage(tr("MSG_DF_RESTARTED"));
721 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
724 if (dataflow->Stop()) {
727 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
732 void SUPERVGUI_Main::addNode() {
733 Trace("SUPERVGUI_Main::addNode");
734 if (SUPERV_isNull(dataflow)) return;
736 if (dataflow->IsExecuting()) {
737 if (QMessageBox::warning(QAD_Application::getDesktop(),
738 tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
739 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
745 Supervision.getBrowser()->choose();
749 * Add Computation node
751 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
752 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
753 switch (myCurrentView) {
756 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
757 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
758 graph->addChild(aNode, theNode->X(), theNode->Y());
769 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
770 aNode->move(theNode->X(), theNode->Y());
771 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
782 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
783 switch (myCurrentView) {
786 SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode);
787 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
788 graph->addChild(aNode, theNode->X(), theNode->Y());
799 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
800 aNode->move(theNode->X(), theNode->Y());
801 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
812 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
813 switch (myCurrentView) {
816 SUPERVGUI_StartControlNode* aStartPrs =
817 new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode);
818 SUPERVGUI_EndControlNode* aEndPrs =
819 new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs);
821 graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y());
822 graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y());
823 graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y());
824 graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y());
826 aStartPrs->updateLinksPrs();
827 aEndPrs->updateLinksPrs();
831 graph->repaintContents();
841 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
842 aStartNode->move(theStartNode->X(), theStartNode->Y());
843 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
845 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
846 aEndNode->move(theEndNode->X(), theEndNode->Y());
847 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
861 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
862 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
863 switch (myCurrentView) {
866 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
867 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
868 graph->addChild(aNode, theNode->X(), theNode->Y());
879 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
880 aNode->move(theNode->X(), theNode->Y());
881 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
890 SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() {
891 Trace("SUPERVGUI_Main::getGraph")
895 SUPERVGUI_Array* SUPERVGUI_Main::getArray() {
896 Trace("SUPERVGUI_Main::getArray")
900 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
901 Trace("SUPERVGUI_Main::getCanvas")
905 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
906 Trace("SUPERVGUI_Main::getCanvasView")
907 return(myCanvasView);
910 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
911 Trace("SUPERVGUI_Main::getDataflow")
915 QAD_Message* SUPERVGUI_Main::getMessage() {
916 Trace("SUPERVGUI_Main::getMessage")
920 QAD_Study* SUPERVGUI_Main::getStudy() {
921 Trace("SUPERVGUI_Main::getStudy")
925 bool SUPERVGUI_Main::isArrayShown() {
926 Trace("SUPERVGUI_Main::isArrayShown")
927 return(myCurrentView == TABLE);
930 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
931 Trace("SUPERVGUI_Main::showPopup");
932 // To check is Supervision active?
933 if (myIsLocked) return;
934 //if (dataflow->IsExecuting()) return;
936 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
937 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
940 if (e->button() == RightButton) {
941 p->exec(e->globalPos());
947 void SUPERVGUI_Main::changeInformation() {
948 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
952 /* Trace("SUPERVGUI_Main::changeInformation")
953 if (Supervision.information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly())) {
958 // returns false, if can't add dataflow into the study
959 bool SUPERVGUI_Main::addStudy() {
960 Trace("SUPERVGUI_Main::addStudy");
961 if (myIsFromStudy) return false;
962 if ((SUPERV_isNull(dataflow))) return false;
964 SALOMEDS::Study_var aStudy = study->getStudyDocument();
965 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
966 SALOMEDS::GenericAttribute_var anAttr;
967 SALOMEDS::AttributeName_var aName;
968 SALOMEDS::AttributeIOR_var anIORAttr;
969 SALOMEDS::AttributePixMap_var aPixmap;
970 bool aLocked = aStudy->GetProperties()->IsLocked();
971 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
973 // searching dataflow
974 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
975 if (aSO->_is_nil()) { // create new dataflow SObject
976 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
977 if (aComponent->_is_nil()) { // is supervision component not found, then create it
978 QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
979 anOperation->start();
980 if (aLocked) aStudy->GetProperties()->SetLocked(false);
981 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
982 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
983 aName = SALOMEDS::AttributeName::_narrow(anAttr);
984 //aName->SetValue(STUDY_SUPERVISION);
985 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
986 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
987 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
988 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
989 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
990 if (aLocked) aStudy->GetProperties()->SetLocked(true);
991 anOperation->finish();
994 aSO = aBuilder->NewObject(aComponent);
995 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
996 aName = SALOMEDS::AttributeName::_narrow(anAttr);
997 aName->SetValue(dataflow->Name());
998 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
999 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1000 anIORAttr->SetValue(dataflow->getIOR());
1002 if (aLocked) return false;
1006 Supervision.unregisterGraph(this);
1007 Supervision.registerGraph(dataflow->getIOR(), this);
1008 myIsFromStudy = true;
1013 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
1014 Trace("SUPERVGUI_Main::chooseData")
1016 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
1017 if (!id.isEmpty()) {
1018 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
1019 SALOMEDS::GenericAttribute_var anAttr;
1020 SALOMEDS::AttributeIOR_var anIOR;
1021 Standard_CString ior = "";
1022 if (object->FindAttribute(anAttr, "AttributeIOR")) {
1023 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1024 ior = anIOR->Value();
1025 portIn->setValue(ior);
1029 setCursor(Supervision.getCursor());
1030 objectBrowser->setCursor(Supervision.getCursor());
1031 Supervision.putInfo("");
1037 void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) {
1038 Trace("SUPERVGUI_Main::setData")
1041 setCursor(forbiddenCursor);
1042 objectBrowser->setCursor(pointingHandCursor);
1043 Supervision.putInfo(tr("MSG_CHOOSE_DATA"));
1046 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
1047 const SALOMEDS::SObject_var theSO,
1048 const char* theName,
1049 //QAD_Operation* theOperation,
1051 SALOMEDS::SObject_var aResult;
1052 SALOMEDS::AttributeName_var aName;
1053 SALOMEDS::GenericAttribute_var anAttr;
1054 if (!*theStarted) { // optimisation
1055 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
1056 for (; anIterator->More(); anIterator->Next()) {
1057 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
1058 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1059 if (strcmp(aName->Value(), theName) == 0) {
1060 aResult = anIterator->Value();
1066 if (!aResult->_is_nil()) return aResult;
1068 SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
1071 //theOperation->start();
1072 aBuilder->NewCommand();
1074 aResult = aBuilder->NewObject(theSO);
1075 anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
1076 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1077 aName->SetValue(theName);
1081 bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) {
1082 Trace("SUPERVGUI_Main::putDataStudy");
1084 static bool isIn = false;
1085 if (isIn) return true; else isIn = true;
1087 SALOMEDS::Study_var aStudy = study->getStudyDocument();
1088 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1089 SALOMEDS::GenericAttribute_var anAttr;
1090 SALOMEDS::AttributeName_var aName;
1091 SALOMEDS::AttributeIOR_var anIORAttr;
1092 SALOMEDS::AttributePixMap_var aPixmap;
1093 bool aTransaction = false;
1094 bool aLocked = aStudy->GetProperties()->IsLocked();
1095 // QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
1097 // searching dataflow
1098 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
1099 if (aSO->_is_nil()) { // create new dataflow SObject
1100 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
1101 if (aComponent->_is_nil()) { // is supervision component not found, then create it
1102 //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1103 //anOperation->start();
1104 aBuilder->NewCommand();
1105 if (aLocked) aStudy->GetProperties()->SetLocked(false);
1106 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
1107 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
1108 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1109 //aName->SetValue(STUDY_SUPERVISION);
1110 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
1112 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
1113 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
1114 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
1115 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
1116 if (aLocked) aStudy->GetProperties()->SetLocked(true);
1117 // anOperation->finish();
1118 aBuilder->CommitCommand();
1120 aTransaction = true;
1122 aBuilder->NewCommand();
1123 aSO = aBuilder->NewObject(aComponent);
1124 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1125 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1126 aName->SetValue(dataflow->Name());
1127 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1128 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1129 anIORAttr->SetValue(dataflow->getIOR());
1131 //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1132 aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO
1133 QString("Run ") + myRunTime.toString() /*, anOperation*/, &aTransaction);
1134 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name()/*, anOperation*/, &aTransaction); // get node SO
1135 aSO = SearchOrCreateSOWithName(aStudy, aSO, inout/*, anOperation*/, &aTransaction); // get in/out SO
1136 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name()/*, anOperation*/, &aTransaction); // get port SO
1139 if (aTransaction) aBuilder->CommitCommand();
1145 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1146 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1147 if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) {
1151 // set object value to the study: if object is external, then put it with
1152 // help of the specific component - owner
1154 // get according component driver for result object
1155 SALOME_LifeCycleCORBA aLCC(myNService);
1156 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
1157 if (!aFNode->_is_nil()) {
1158 Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
1159 aFNode->GetComponentName());
1160 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
1161 if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
1162 CORBA::Object_ptr anObject = new CORBA::Object();
1163 CORBA::Any* anAny = p->ToAny();
1164 (*anAny) >>= anObject;
1166 if (aDriver->CanPublishInStudy(anObject)) {
1167 SALOMEDS::SObject_var aTmpSO;
1168 if (!aTransaction) {
1170 aTransaction = true;
1172 aBuilder->NewCommand();
1174 aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, "");
1175 aBuilder->Addreference(aSO, aTmpSO);
1176 } else { // can't publish object: abort transaction
1177 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;
1191 aBuilder->NewCommand();
1193 anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
1198 aBuilder->CommitCommand();
1199 if (!myThread->running())
1200 study->updateObjBrowser();
1206 void SUPERVGUI_Main::ActivatePanning()
1208 if (graph->isVisible()) {
1209 graph->ActivatePanning();
1210 } else if (array->isVisible()) {
1211 array->ActivatePanning();
1212 } else if (myCanvasView->isVisible()) {
1213 myCanvasView->ActivatePanning();
1218 void SUPERVGUI_Main::ResetView()
1220 if (graph->isVisible()) {
1222 } else if (array->isVisible()) {
1224 } else if (myCanvasView->isVisible()) {
1225 myCanvasView->ResetView();
1230 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1231 myIsFromStudy = theToStudy;
1232 graph->setAsFromStudy(theToStudy);
1233 array->setAsFromStudy(theToStudy);
1234 myCanvas->setAsFromStudy(theToStudy);
1237 void SUPERVGUI_Main::checkIsInStudy() {
1238 if (!myIsFromStudy) return;
1240 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1241 SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1242 SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1243 SALOMEDS::SObject_var aDataflowLbl;
1244 SALOMEDS::GenericAttribute_var anAttr;
1246 for (; aChildIterator->More(); aChildIterator->Next()) {
1247 aDataflowLbl = aChildIterator->Value();
1248 if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1251 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1252 if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1254 // This Graph considered as in study but in study it is not exists
1255 Supervision.unregisterGraph(this);
1256 setAsFromStudy(false);
1259 void SUPERVGUI_Main::syncNotification() {
1269 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1270 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1272 mess += "NOTIF: "; mess += graph;
1273 mess += " / " ; mess += node;
1274 mess += " / " ; mess += type;
1275 mess += " / " ; mess += message;
1276 getMessage()->setMessage(mess.latin1());
1281 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1282 char* sender, long counter, char* date, long stamp) {
1283 Trace("SUPERVGUI_Main::isFiltered");
1285 if (strcmp(getDataflow()->Name(), graph) == 0) {
1287 QObjectList* nodes = queryList("SUPERVGUI_Node");
1288 QObjectListIt i(*nodes);
1289 while ((n=(SUPERVGUI_Node*)i.current()) != 0) {
1291 if (strcmp(n->name(), node) == 0) {
1292 if (strcmp(type, NOTIF_WARNING) == 0) {
1294 } else if (strcmp(type, NOTIF_STEP) == 0) {
1296 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1298 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1305 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1306 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 );
1307 fflush( myLogFile );
1313 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1318 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1320 array->setPaletteBackgroundColor(color);
1321 graph->setPaletteBackgroundColor(color);
1322 myCanvas->setBackgroundColor(color);
1323 myCanvasView->setPaletteBackgroundColor(color.light());
1325 SUPERVGraph_View::setPaletteBackgroundColor(color);
1328 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1329 return myEventNodes;
1332 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1333 myEventNodes = theEventNodes;
1336 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1340 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1341 myStates = theStates;
1344 int SUPERVGUI_Main::getNodesNumber() {
1345 //create a list of nodes of the graph
1346 SUPERV_Nodes nodes = getDataflow()->Nodes();
1347 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1348 nodes->INodes.length() + nodes->GNodes.length() +
1349 nodes->LNodes.length() + nodes->SNodes.length();
1353 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1357 void SUPERVGUI_Main::startTimer() {
1358 myTimer->start(500);
1361 void SUPERVGUI_Main::executionFinished() {
1362 getStudy()->updateObjBrowser();
1366 void SUPERVGUI_Main::checkExecution() {
1367 if (myThread->finished()) {
1369 executionFinished();
1373 /******************************* SUPERVGUI_Thread class ****************************************/
1374 SUPERVGUI_Thread::SUPERVGUI_Thread()
1380 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1382 //it is a virtual destructor and needs to be determine here
1385 void SUPERVGUI_Thread::startThread(const char* m)
1391 myMain->getMessage()->setMessage(m);
1396 void SUPERVGUI_Thread::stopThread(const char* m)
1398 myMain->getMessage()->setMessage(m);
1401 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1406 void SUPERVGUI_Thread::KillThread(bool theValue)
1409 myIsActive = !(theValue);
1413 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1415 void SUPERVGUI_Thread::run()
1417 SUPERV_CNode aNode = NULL;
1418 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1419 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1421 SUPERV_CNode aPrevNode = NULL;
1422 SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1423 SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1428 QPtrList< char * > anEventNodes;
1429 QPtrList< SUPERV::GraphState > aStates;
1431 myMain->startTimer();
1433 myMain->getDataflow()->Event(aNode, aEvent, aState);
1435 if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1437 aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1439 aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1441 if (myMain->getEventNodes().count()) {
1442 myMain->removeEventNodes();
1444 if (myMain->getStates().count()) {
1445 myMain->removeStates();
1450 if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1451 aName = aNode->Name();
1454 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
1455 anEventNodes = myMain->getEventNodes();
1456 anEventNodes.append( &aName ) ;
1457 myMain->setEventNodes(anEventNodes);
1459 aStates = myMain->getStates();
1460 aStates.append( &aState ) ;
1461 myMain->setStates(aStates);
1464 if ( aEvent == aPrevEvent && aState == aPrevState) {
1465 QString aNameStr = aName;
1466 QString aPrevNameStr = aPrevName;
1467 if ( aNameStr != aPrevNameStr ) {
1468 anEventNodes = myMain->getEventNodes();
1469 anEventNodes.append( &aName ) ;
1470 myMain->setEventNodes(anEventNodes);
1472 aStates = myMain->getStates();
1473 aStates.append( &aState ) ;
1474 myMain->setStates(aStates);
1478 anEventNodes = myMain->getEventNodes();
1479 anEventNodes.append( &aName ) ;
1480 myMain->setEventNodes(anEventNodes);
1482 aStates = myMain->getStates();
1483 aStates.append( &aState ) ;
1484 myMain->setStates(aStates);
1489 switch (myMain->getDataflow()->State()) {
1490 case SUPERV_Editing :
1491 stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1494 case SUPERV_Suspend :
1495 stopThread(tr("MSG_GRAPH_SUSPENDED"));
1499 stopThread(tr("MSG_GRAPH_FINISHED"));
1503 stopThread(tr("MSG_GRAPH_ABORTED"));
1507 stopThread(tr("MSG_GRAPH_KILLED"));
1513 if ( myMain->getEventNodes().count() ) {
1514 //if list not empty call execute() -> sync()
1515 char * aNodeName = *(myMain->getEventNodes().getFirst());
1516 SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1518 // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1519 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1521 myMain->removeFirstEN();
1522 myMain->removeFirstS();
1526 aPrevEvent = aEvent;
1527 aPrevState = aState;
1529 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
1532 aPrevName = aPrevNode->Name();
1537 // VSR: 04/12/03 ---> update object browser ufter finishing
1539 // myMain->getStudy()->updateObjBrowser();
1541 // VSR: 04/12/03 <---
1546 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1550 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1551 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1553 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1554 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1555 setSizeGripEnabled( true );
1558 QGridLayout* TopLayout = new QGridLayout( this );
1559 TopLayout->setSpacing( 6 );
1560 TopLayout->setMargin( 11 );
1562 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1563 TopGroup->setColumnLayout(0, Qt::Vertical );
1564 TopGroup->layout()->setSpacing( 0 );
1565 TopGroup->layout()->setMargin( 0 );
1566 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1567 TopGroupLayout->setAlignment( Qt::AlignTop );
1568 TopGroupLayout->setSpacing( 6 );
1569 TopGroupLayout->setMargin( 11 );
1572 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1573 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1575 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1576 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1577 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1580 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1581 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1583 myTimeOut = new QLineEdit( TopGroup );
1584 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1585 myTimeOut->setValidator( new QIntValidator(this) );
1586 myTimeOut->setMinimumSize( 100, 0 );
1587 myTimeOut->setReadOnly( isReadOnly );
1588 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1591 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1592 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1594 myDataStreamTrace = new QComboBox( TopGroup );
1595 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1596 myDataStreamTrace->insertItem("WithoutTrace");
1597 myDataStreamTrace->insertItem("SummaryTrace");
1598 myDataStreamTrace->insertItem("DetailedTrace");
1599 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1601 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1602 GroupButtons->setColumnLayout(0, Qt::Vertical );
1603 GroupButtons->layout()->setSpacing( 0 );
1604 GroupButtons->layout()->setMargin( 0 );
1605 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1606 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1607 GroupButtonsLayout->setSpacing( 6 );
1608 GroupButtonsLayout->setMargin( 11 );
1610 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1611 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1613 GroupButtonsLayout->addWidget( okB, 0, 0 );
1614 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1615 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1617 TopLayout->addWidget( TopGroup, 0, 0 );
1618 TopLayout->addWidget( GroupButtons, 1, 0 );
1620 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1621 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1629 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1630 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1636 void SUPERVGUI_DSGraphParameters::setData() {
1639 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1641 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1642 if (myGraph->IsStreamGraph()) {
1643 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1644 if (!SUPERV_isNull(aSGraph))
1645 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1648 myDeltaTime->setValue(aDeltaTime);
1649 myTimeOut->setText(QString("%1").arg(aTimeOut));
1650 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1656 void SUPERVGUI_DSGraphParameters::accept() {
1657 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1658 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1659 // myDeltaTime->value());
1660 if (myGraph->IsStreamGraph()) {
1661 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1662 if (!SUPERV_isNull(aSGraph))
1663 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1664 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1665 myDeltaTime->value());