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 myArray = new SUPERVGUI_CanvasArray(this);
205 myArrayView = new SUPERVGUI_ArrayView(myArray, this);
207 myCanvas = new SUPERVGUI_Canvas(this);
208 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
210 message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
211 notification = new NOTIFICATION_Consumer();
213 QBoxLayout * layout = new QVBoxLayout(this);
214 layout->setMargin(0);
215 layout->setSpacing(0);
216 layout->addWidget(graph);
217 layout->addWidget(array);
218 layout->addWidget(myCanvasView);
219 layout->addWidget(myArrayView);
221 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
226 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
227 myLogFile = fopen( myLogFileName.latin1(), "a" );
228 if ( myLogFile == NULL )
231 myTimer = new QTimer( this );
232 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
235 SUPERVGUI_Main::~SUPERVGUI_Main() {
236 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
238 // close all opened SubGraphs
239 QMap<QString, QAD_StudyFrame*>::iterator it;
240 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
241 it.data()->removeEventFilter(this);
242 it.data()->disconnect();
245 QAD_Study* aStudy = it.data()->getStudy();
246 aStudy->removeStudyFrame(it.data());
249 mySubGraphMap.clear();
251 QAD_StudyFrame* aSubGraph;
252 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
253 aSubGraph->removeEventFilter(this);
258 if ( myLogFile != NULL) {
261 graph->removeLinks();
263 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
264 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
270 void SUPERVGUI_Main::filterNotification() {
271 Trace("SUPERVGUI_Main::filterNotification");
272 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
273 dlg->setFiltered( myFiltered );
274 dlg->setLogged( myLogged, myLogFileName );
275 dlg->setWarning( myWarning );
276 dlg->setStep( myStep );
277 dlg->setTrace( myTrace );
278 dlg->setVerbose( myVerbose );
279 if ( dlg->exec() == QDialog::Accepted ) {
280 myLogged = dlg->getLogged();
281 myLogFileName = dlg->getLogFile();
282 myFiltered = dlg->getFiltered();
283 myWarning = dlg->getWarning();
284 myStep = dlg->getStep();
285 myTrace = dlg->getTrace();
286 myVerbose = dlg->getVerbose();
288 if ( myLogFile != NULL) {
292 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
293 myLogFile = fopen( myLogFileName.latin1(), "a" );
294 if ( myLogFile == NULL ) {
296 QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
302 void SUPERVGUI_Main::changeDSGraphParameters() {
303 SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly());
309 void SUPERVGUI_Main::syncAsync() {
310 Trace("SUPERVGUI_Main::syncAsync")
311 QTimer::singleShot(1, this, SLOT(sync()));
316 * Called by thread when dataflow is executing
318 void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) {
319 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
320 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
321 if (aNode) aNode->sync();
323 else if (myCurrentView == CANVASTABLE) {
324 SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
325 if (aNode) aNode->sync();
328 SUPERVGUI_Node* aNodePrs;
329 SUPERVGUI_GraphNode* aGraphNodePrs;
330 if (myCurrentView == TABLE) {
331 aNodePrs = (SUPERVGUI_Node*) array->child(theNodeName, "SUPERVGUI_Node");
332 aGraphNodePrs = (SUPERVGUI_GraphNode*) array->child(theNodeName, "SUPERVGUI_GraphNode");
334 aNodePrs = (SUPERVGUI_Node*) graph->child(theNodeName, "SUPERVGUI_Node");
335 aGraphNodePrs = (SUPERVGUI_GraphNode*) graph->child(theNodeName, "SUPERVGUI_GraphNode");
338 aGraphNodePrs->sync();
341 aNodePrs->syncOnEvent(theNodeState);
347 void SUPERVGUI_Main::sync() {
348 Trace("SUPERVGUI_Main::sync")
349 if ((SUPERV_isNull(dataflow))) return;
350 QString t = tr("GRAPH_TITLE");
352 t += dataflow->Name();
355 study->updateObjBrowser();
356 if (myCurrentView == TABLE) {
358 } else if (myCurrentView == CANVASTABLE) {
360 cout<<" --> after myArray->sync() ..."<<endl;
362 } else if (myCurrentView == GRAPH) {
371 void SUPERVGUI_Main::showTable() {
372 if (myCurrentView == TABLE) return;
374 if (array->create()) {
375 if (myCurrentView == GRAPH)
377 else if (myCurrentView == CANVASTABLE) {
382 myCanvasView->hide();
383 myCurrentView = TABLE;
388 void SUPERVGUI_Main::showCanvasTable() {
389 if (myCurrentView == CANVASTABLE) return;
391 if (myArray->create()) {
392 if (myCurrentView == GRAPH)
394 else if (myCurrentView == TABLE)
397 myCanvasView->hide();
400 myCurrentView = CANVASTABLE;
405 void SUPERVGUI_Main::showFullGraph() {
406 if (myCurrentView == TABLE) {
410 else if (myCurrentView == CANVASTABLE) {
415 else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
416 myCanvasView->hide();
419 myCurrentView = GRAPH;
421 graph->setFullView();
425 void SUPERVGUI_Main::showContolFlow() {
427 if (myCurrentView == TABLE) {
431 else if (myCurrentView == GRAPH) {
435 else if (myCurrentView == CANVASTABLE) {
440 myCurrentView = CONTROLFLOW;
441 myCanvas->setControlView();
444 myCanvasView->show();
448 void SUPERVGUI_Main::showCanvas() {
449 if (myCurrentView == CANVAS) return;
452 if (myCurrentView == TABLE) {
456 else if (myCurrentView == CANVASTABLE) {
461 else if (myCurrentView == GRAPH) {
465 myCurrentView = CANVAS;
466 myCanvas->setFullView();
469 myCanvasView->show();
473 void SUPERVGUI_Main::insertFile() {
474 Trace("SUPERVGUI_Main::insertFile")
475 if ((SUPERV_isNull(dataflow))) return;
477 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
480 tr("MSG_GRAPH_INSERT"),
483 if (dataflow->Import(f.latin1())) {
484 if (myCurrentView == TABLE) {
488 else if (myCurrentView == CANVASTABLE) {
492 else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
497 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
502 void SUPERVGUI_Main::copy() {
503 Trace("SUPERVGUI_Main::copy");
504 if (dataflow->ThreadsMax() == 0) {
505 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
508 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
509 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
510 (aStudyFrame->getRightFrame()->getViewFrame());
512 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
513 if (dataflow->IsStreamGraph()) {
514 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
515 if (SUPERV_isNull(aSGraph)) {
516 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
519 aNewGraph = aSGraph->StreamCopy();
522 aNewGraph = dataflow->Copy();
524 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
525 aNewName += dataflow->Name();
526 aNewGraph->SetName(aNewName);
527 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
528 Supervision.getDesktop(),
530 study->showFrame(aStudyFrame);
534 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
536 if (theNode->IsMacro()) {
537 // get SubGraph from MacroNode
538 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
540 if (aMacro->IsStreamMacro())
541 aGraph = aMacro->StreamObjRef();
543 aGraph = aMacro->FlowObjRef();
546 if (SUPERV_isNull(aGraph)) {
547 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
551 QString aGraphName = aGraph->Name();
552 QAD_StudyFrame* aStudyFrame;
553 if (mySubGraphs.contains(aGraphName)) {
554 aStudyFrame = mySubGraphs[aGraphName];
555 aStudyFrame->setActiveWindow();
556 aStudyFrame->setFocus();
559 aStudyFrame = Supervision.createGraph();
561 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
562 (aStudyFrame->getRightFrame()->getViewFrame());
564 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
565 Supervision.getDesktop(),
567 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
568 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
569 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
570 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
571 aStudyFrame->installEventFilter(this);
573 mySubGraphs.insert(aGraphName, aStudyFrame);
574 mySubGraphMap.insert(aGraphName, theNode->Name());
579 study->showFrame(aStudyFrame);
580 if (!correct) myLastGraph = aStudyFrame;
585 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
587 // workaround to get close event
588 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
589 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
590 onSubGraphClosed(aFrame);
592 return SUPERVGraph_View::eventFilter(o, e);
595 // workaround to fix PAL6255 -> opened SubGraph is not on top
596 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
599 QAD_StudyFrame* aFrame = myLastGraph;
601 aFrame->setActiveWindow();
606 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
608 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
609 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
610 theStudyFrame->removeEventFilter(this);
611 disconnect(theStudyFrame, 0, this, 0);
613 SUPERVGraph_View* view = supervFrame->getViewWidget();
614 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
616 QString aGraphName = aGraph->getDataflow()->Name();
617 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
618 if (it != mySubGraphMap.end()) {
619 QString aNodeName = it.data();
620 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
621 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
626 mySubGraphMap.remove(it);
628 mySubGraphs.remove(aGraphName);
633 void SUPERVGUI_Main::run() {
634 Trace("SUPERVGUI_Main::run")
635 if ((SUPERV_isNull(dataflow))) return;
637 if (dataflow->IsEditing()) {
638 if (!dataflow->IsValid()) {
639 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
640 } else if (!dataflow->IsExecutable()) {
641 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
642 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
643 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
645 myRunTime = QDateTime::currentDateTime();
648 if (!dataflow->ReRun()) {
649 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
650 if (dataflow->State() == SUPERV::ErrorState) {
654 myThread->startThread(tr("MSG_GRAPH_STARTED"));
658 if (!dataflow->Run()) {
659 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
660 if (dataflow->State() == SUPERV::ErrorState) {
664 myThread->startThread(tr("MSG_GRAPH_STARTED"));
670 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
676 void SUPERVGUI_Main::startExecute() {
677 Trace("SUPERVGUI_Main::startExecute")
678 if ((SUPERV_isNull(dataflow))) return;
680 if (dataflow->IsEditing()) {
681 if (!dataflow->IsValid()) {
682 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
683 } else if (!dataflow->IsExecutable()) {
684 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
685 } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
686 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
688 myRunTime = QDateTime::currentDateTime();
691 if (!dataflow->ReStart()) {
692 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
694 myThread->startThread(tr("MSG_GRAPH_STARTED"));
698 if (!dataflow->Start()) {
699 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
701 myThread->startThread(tr("MSG_GRAPH_STARTED"));
706 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
711 void SUPERVGUI_Main::kill() {
712 Trace("SUPERVGUI_Main::kill")
713 if ((SUPERV_isNull(dataflow))) return;
715 if (dataflow->IsEditing()) {
716 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
717 } else if (dataflow->Kill()) {
719 myThread->stopThread(tr("MSG_GRAPH_KILLED"));
722 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
726 void SUPERVGUI_Main::suspendResume() {
727 Trace("SUPERVGUI_Main::suspendResume")
728 if ((SUPERV_isNull(dataflow))) return;
730 if (dataflow->IsEditing()) {
731 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
732 } else if (dataflow->State() == SUPERV_Suspend) {
733 if (dataflow->Resume()) {
734 myThread->startThread(tr("MSG_DF_RESUMED"));
736 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
739 if (dataflow->Suspend()) {
741 myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
743 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
748 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
749 Trace("SUPERVGUI_Main::stopRestart")
750 if ((SUPERV_isNull(dataflow))) return;
752 if (dataflow->IsEditing()) {
753 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
754 } else if (dataflow->State() == SUPERV_Stop) {
755 if (dataflow->ReStart()) {
756 message->setMessage(tr("MSG_DF_RESTARTED"));
759 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
762 if (dataflow->Stop()) {
765 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
770 void SUPERVGUI_Main::addNode() {
771 Trace("SUPERVGUI_Main::addNode");
772 if (SUPERV_isNull(dataflow)) return;
774 if (dataflow->IsExecuting()) {
775 if (QMessageBox::warning(QAD_Application::getDesktop(),
776 tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
777 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
783 Supervision.getBrowser()->choose();
787 * Add Computation node
789 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
790 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
791 switch (myCurrentView) {
794 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
795 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
796 graph->addChild(aNode, theNode->X(), theNode->Y());
811 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
812 aNode->move(theNode->X(), theNode->Y());
813 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
824 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
825 switch (myCurrentView) {
828 SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode);
829 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
830 graph->addChild(aNode, theNode->X(), theNode->Y());
845 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
846 aNode->move(theNode->X(), theNode->Y());
847 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
858 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
859 switch (myCurrentView) {
862 SUPERVGUI_StartControlNode* aStartPrs =
863 new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode);
864 SUPERVGUI_EndControlNode* aEndPrs =
865 new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs);
867 graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y());
868 graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y());
869 graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y());
870 graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y());
872 aStartPrs->updateLinksPrs();
873 aEndPrs->updateLinksPrs();
877 graph->repaintContents();
891 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
892 aStartNode->move(theStartNode->X(), theStartNode->Y());
893 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
895 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
896 aEndNode->move(theEndNode->X(), theEndNode->Y());
897 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
911 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
912 //cout<<"### X="<<theNode->X()<<" Y="<<theNode->Y()<<endl;
913 switch (myCurrentView) {
916 SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
917 graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
918 graph->addChild(aNode, theNode->X(), theNode->Y());
933 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
934 aNode->move(theNode->X(), theNode->Y());
935 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
944 SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() {
945 Trace("SUPERVGUI_Main::getGraph")
949 SUPERVGUI_Array* SUPERVGUI_Main::getArray() {
950 Trace("SUPERVGUI_Main::getArray")
954 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
955 Trace("SUPERVGUI_Main::getCanvasArray")
959 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
960 Trace("SUPERVGUI_Main::getArrayView")
964 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
965 Trace("SUPERVGUI_Main::getCanvas")
969 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
970 Trace("SUPERVGUI_Main::getCanvasView")
971 return(myCanvasView);
974 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
975 Trace("SUPERVGUI_Main::getDataflow")
979 QAD_Message* SUPERVGUI_Main::getMessage() {
980 Trace("SUPERVGUI_Main::getMessage")
984 QAD_Study* SUPERVGUI_Main::getStudy() {
985 Trace("SUPERVGUI_Main::getStudy")
989 bool SUPERVGUI_Main::isArrayShown() {
990 Trace("SUPERVGUI_Main::isArrayShown")
991 //return(myCurrentView == TABLE);
992 return(myCurrentView == CANVASTABLE);
995 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
996 Trace("SUPERVGUI_Main::showPopup");
997 // To check is Supervision active?
998 if (myIsLocked) return;
999 //if (dataflow->IsExecuting()) return;
1001 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
1002 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
1005 if (e->button() == RightButton) {
1006 p->exec(e->globalPos());
1012 void SUPERVGUI_Main::changeInformation() {
1013 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
1017 /* Trace("SUPERVGUI_Main::changeInformation")
1018 if (Supervision.information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly())) {
1023 // returns false, if can't add dataflow into the study
1024 bool SUPERVGUI_Main::addStudy() {
1025 Trace("SUPERVGUI_Main::addStudy");
1026 if (myIsFromStudy) return false;
1027 if ((SUPERV_isNull(dataflow))) return false;
1029 SALOMEDS::Study_var aStudy = study->getStudyDocument();
1030 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1031 SALOMEDS::GenericAttribute_var anAttr;
1032 SALOMEDS::AttributeName_var aName;
1033 SALOMEDS::AttributeIOR_var anIORAttr;
1034 SALOMEDS::AttributePixMap_var aPixmap;
1035 bool aLocked = aStudy->GetProperties()->IsLocked();
1036 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
1038 // searching dataflow
1039 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
1040 if (aSO->_is_nil()) { // create new dataflow SObject
1041 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
1042 if (aComponent->_is_nil()) { // is supervision component not found, then create it
1043 QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1044 anOperation->start();
1045 if (aLocked) aStudy->GetProperties()->SetLocked(false);
1046 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
1047 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
1048 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1049 //aName->SetValue(STUDY_SUPERVISION);
1050 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
1051 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
1052 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
1053 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
1054 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
1055 if (aLocked) aStudy->GetProperties()->SetLocked(true);
1056 anOperation->finish();
1059 aSO = aBuilder->NewObject(aComponent);
1060 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1061 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1062 aName->SetValue(dataflow->Name());
1063 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1064 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1065 anIORAttr->SetValue(dataflow->getIOR());
1067 if (aLocked) return false;
1071 Supervision.unregisterGraph(this);
1072 Supervision.registerGraph(dataflow->getIOR(), this);
1073 myIsFromStudy = true;
1078 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
1079 Trace("SUPERVGUI_Main::chooseData")
1081 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
1082 if (!id.isEmpty()) {
1083 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
1084 SALOMEDS::GenericAttribute_var anAttr;
1085 SALOMEDS::AttributeIOR_var anIOR;
1086 Standard_CString ior = "";
1087 if (object->FindAttribute(anAttr, "AttributeIOR")) {
1088 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1089 ior = anIOR->Value();
1090 portIn->setValue(ior);
1094 setCursor(Supervision.getCursor());
1095 objectBrowser->setCursor(Supervision.getCursor());
1096 Supervision.putInfo("");
1102 void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) {
1103 Trace("SUPERVGUI_Main::setData")
1106 setCursor(forbiddenCursor);
1107 objectBrowser->setCursor(pointingHandCursor);
1108 Supervision.putInfo(tr("MSG_CHOOSE_DATA"));
1111 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
1112 const SALOMEDS::SObject_var theSO,
1113 const char* theName,
1114 //QAD_Operation* theOperation,
1116 SALOMEDS::SObject_var aResult;
1117 SALOMEDS::AttributeName_var aName;
1118 SALOMEDS::GenericAttribute_var anAttr;
1119 if (!*theStarted) { // optimisation
1120 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
1121 for (; anIterator->More(); anIterator->Next()) {
1122 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
1123 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1124 if (strcmp(aName->Value(), theName) == 0) {
1125 aResult = anIterator->Value();
1131 if (!aResult->_is_nil()) return aResult;
1133 SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
1136 //theOperation->start();
1137 aBuilder->NewCommand();
1139 aResult = aBuilder->NewObject(theSO);
1140 anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
1141 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1142 aName->SetValue(theName);
1146 bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) {
1147 Trace("SUPERVGUI_Main::putDataStudy");
1149 static bool isIn = false;
1150 if (isIn) return true; else isIn = true;
1152 SALOMEDS::Study_var aStudy = study->getStudyDocument();
1153 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1154 SALOMEDS::GenericAttribute_var anAttr;
1155 SALOMEDS::AttributeName_var aName;
1156 SALOMEDS::AttributeIOR_var anIORAttr;
1157 SALOMEDS::AttributePixMap_var aPixmap;
1158 bool aTransaction = false;
1159 bool aLocked = aStudy->GetProperties()->IsLocked();
1160 // QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
1162 // searching dataflow
1163 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
1164 if (aSO->_is_nil()) { // create new dataflow SObject
1165 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
1166 if (aComponent->_is_nil()) { // is supervision component not found, then create it
1167 //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1168 //anOperation->start();
1169 aBuilder->NewCommand();
1170 if (aLocked) aStudy->GetProperties()->SetLocked(false);
1171 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
1172 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
1173 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1174 //aName->SetValue(STUDY_SUPERVISION);
1175 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
1177 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
1178 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
1179 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
1180 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
1181 if (aLocked) aStudy->GetProperties()->SetLocked(true);
1182 // anOperation->finish();
1183 aBuilder->CommitCommand();
1185 aTransaction = true;
1187 aBuilder->NewCommand();
1188 aSO = aBuilder->NewObject(aComponent);
1189 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1190 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1191 aName->SetValue(dataflow->Name());
1192 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1193 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1194 anIORAttr->SetValue(dataflow->getIOR());
1196 //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1197 aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO
1198 QString("Run ") + myRunTime.toString() /*, anOperation*/, &aTransaction);
1199 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name()/*, anOperation*/, &aTransaction); // get node SO
1200 aSO = SearchOrCreateSOWithName(aStudy, aSO, inout/*, anOperation*/, &aTransaction); // get in/out SO
1201 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name()/*, anOperation*/, &aTransaction); // get port SO
1204 if (aTransaction) aBuilder->CommitCommand();
1210 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1211 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1212 if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) {
1216 // set object value to the study: if object is external, then put it with
1217 // help of the specific component - owner
1219 // get according component driver for result object
1220 SALOME_LifeCycleCORBA aLCC(myNService);
1221 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
1222 if (!aFNode->_is_nil()) {
1223 Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
1224 aFNode->GetComponentName());
1225 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
1226 if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
1227 CORBA::Object_ptr anObject = new CORBA::Object();
1228 CORBA::Any* anAny = p->ToAny();
1229 (*anAny) >>= anObject;
1231 if (aDriver->CanPublishInStudy(anObject)) {
1232 SALOMEDS::SObject_var aTmpSO;
1233 if (!aTransaction) {
1235 aTransaction = true;
1237 aBuilder->NewCommand();
1239 aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, "");
1240 aBuilder->Addreference(aSO, aTmpSO);
1241 } else { // can't publish object: abort transaction
1242 if (aTransaction) aBuilder->AbortCommand();
1247 } else { // component has no drivel, but could store IORs (like Calculator)
1248 SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR(p->ToString());
1249 if (!CORBA::is_nil(anIORSO)) aBuilder->Addreference(aSO, anIORSO);
1253 if (!aTransaction) {
1254 aTransaction = true;
1256 aBuilder->NewCommand();
1258 anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
1263 aBuilder->CommitCommand();
1264 if (!myThread->running())
1265 study->updateObjBrowser();
1271 void SUPERVGUI_Main::ActivatePanning()
1273 if (graph->isVisible()) {
1274 graph->ActivatePanning();
1275 } else if (array->isVisible()) {
1276 array->ActivatePanning();
1277 } else if (myCanvasView->isVisible()) {
1278 myCanvasView->ActivatePanning();
1279 } else if (myArrayView->isVisible()) {
1280 myArrayView->ActivatePanning();
1285 void SUPERVGUI_Main::ResetView()
1287 if (graph->isVisible()) {
1289 } else if (array->isVisible()) {
1291 } else if (myCanvasView->isVisible()) {
1292 myCanvasView->ResetView();
1293 } else if (myArrayView->isVisible()) {
1294 myArrayView->ResetView();
1299 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1300 myIsFromStudy = theToStudy;
1301 graph->setAsFromStudy(theToStudy);
1302 array->setAsFromStudy(theToStudy);
1303 myCanvas->setAsFromStudy(theToStudy);
1306 void SUPERVGUI_Main::checkIsInStudy() {
1307 if (!myIsFromStudy) return;
1309 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1310 SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1311 SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1312 SALOMEDS::SObject_var aDataflowLbl;
1313 SALOMEDS::GenericAttribute_var anAttr;
1315 for (; aChildIterator->More(); aChildIterator->Next()) {
1316 aDataflowLbl = aChildIterator->Value();
1317 if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1320 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1321 if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1323 // This Graph considered as in study but in study it is not exists
1324 Supervision.unregisterGraph(this);
1325 setAsFromStudy(false);
1328 void SUPERVGUI_Main::syncNotification() {
1338 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1339 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1341 mess += "NOTIF: "; mess += graph;
1342 mess += " / " ; mess += node;
1343 mess += " / " ; mess += type;
1344 mess += " / " ; mess += message;
1345 getMessage()->setMessage(mess.latin1());
1350 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1351 char* sender, long counter, char* date, long stamp) {
1352 Trace("SUPERVGUI_Main::isFiltered");
1354 if (strcmp(getDataflow()->Name(), graph) == 0) {
1356 QObjectList* nodes = queryList("SUPERVGUI_Node");
1357 QObjectListIt i(*nodes);
1358 while ((n=(SUPERVGUI_Node*)i.current()) != 0) {
1360 if (strcmp(n->name(), node) == 0) {
1361 if (strcmp(type, NOTIF_WARNING) == 0) {
1363 } else if (strcmp(type, NOTIF_STEP) == 0) {
1365 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1367 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1374 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1375 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 );
1376 fflush( myLogFile );
1382 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1387 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1389 array->setPaletteBackgroundColor(color);
1390 graph->setPaletteBackgroundColor(color);
1391 myCanvas->setBackgroundColor(color);
1392 myCanvasView->setPaletteBackgroundColor(color.light());
1393 myArray->setBackgroundColor(color);
1394 myArrayView->setPaletteBackgroundColor(color.light());
1396 SUPERVGraph_View::setPaletteBackgroundColor(color);
1399 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1400 return myEventNodes;
1403 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1404 myEventNodes = theEventNodes;
1407 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1411 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1412 myStates = theStates;
1415 int SUPERVGUI_Main::getNodesNumber() {
1416 //create a list of nodes of the graph
1417 SUPERV_Nodes nodes = getDataflow()->Nodes();
1418 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1419 nodes->INodes.length() + nodes->GNodes.length() +
1420 nodes->LNodes.length() + nodes->SNodes.length();
1424 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1428 void SUPERVGUI_Main::startTimer() {
1429 myTimer->start(500);
1432 void SUPERVGUI_Main::executionFinished() {
1433 getStudy()->updateObjBrowser();
1438 void SUPERVGUI_Main::checkExecution() {
1439 if (myThread->finished()) {
1441 executionFinished();
1445 /******************************* SUPERVGUI_Thread class ****************************************/
1446 SUPERVGUI_Thread::SUPERVGUI_Thread()
1452 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1454 //it is a virtual destructor and needs to be determine here
1457 void SUPERVGUI_Thread::startThread(const char* m)
1463 myMain->getMessage()->setMessage(m);
1468 void SUPERVGUI_Thread::stopThread(const char* m)
1470 myMain->getMessage()->setMessage(m);
1473 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1478 void SUPERVGUI_Thread::KillThread(bool theValue)
1481 myIsActive = !(theValue);
1485 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1487 void SUPERVGUI_Thread::run()
1489 SUPERV_CNode aNode = NULL;
1490 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1491 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1493 SUPERV_CNode aPrevNode = NULL;
1494 SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1495 SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1500 QPtrList< char * > anEventNodes;
1501 QPtrList< SUPERV::GraphState > aStates;
1503 myMain->startTimer();
1505 myMain->getDataflow()->Event(aNode, aEvent, aState);
1507 if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1509 aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1511 aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1513 if (myMain->getEventNodes().count()) {
1514 myMain->removeEventNodes();
1516 if (myMain->getStates().count()) {
1517 myMain->removeStates();
1522 if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1523 aName = aNode->Name();
1526 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
1527 anEventNodes = myMain->getEventNodes();
1528 anEventNodes.append( &aName ) ;
1529 myMain->setEventNodes(anEventNodes);
1531 aStates = myMain->getStates();
1532 aStates.append( &aState ) ;
1533 myMain->setStates(aStates);
1536 if ( aEvent == aPrevEvent && aState == aPrevState) {
1537 QString aNameStr = aName;
1538 QString aPrevNameStr = aPrevName;
1539 if ( aNameStr != aPrevNameStr ) {
1540 anEventNodes = myMain->getEventNodes();
1541 anEventNodes.append( &aName ) ;
1542 myMain->setEventNodes(anEventNodes);
1544 aStates = myMain->getStates();
1545 aStates.append( &aState ) ;
1546 myMain->setStates(aStates);
1550 anEventNodes = myMain->getEventNodes();
1551 anEventNodes.append( &aName ) ;
1552 myMain->setEventNodes(anEventNodes);
1554 aStates = myMain->getStates();
1555 aStates.append( &aState ) ;
1556 myMain->setStates(aStates);
1561 switch (myMain->getDataflow()->State()) {
1562 case SUPERV_Editing :
1563 stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1566 case SUPERV_Suspend :
1567 stopThread(tr("MSG_GRAPH_SUSPENDED"));
1571 stopThread(tr("MSG_GRAPH_FINISHED"));
1575 stopThread(tr("MSG_GRAPH_ABORTED"));
1579 stopThread(tr("MSG_GRAPH_KILLED"));
1585 if ( myMain->getEventNodes().count() ) {
1586 //if list not empty call execute() -> sync()
1587 char * aNodeName = *(myMain->getEventNodes().getFirst());
1588 SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1590 // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1591 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1593 myMain->removeFirstEN();
1594 myMain->removeFirstS();
1598 aPrevEvent = aEvent;
1599 aPrevState = aState;
1601 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
1604 aPrevName = aPrevNode->Name();
1609 // VSR: 04/12/03 ---> update object browser ufter finishing
1611 // myMain->getStudy()->updateObjBrowser();
1613 // VSR: 04/12/03 <---
1618 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1622 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1623 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1625 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1626 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1627 setSizeGripEnabled( true );
1630 QGridLayout* TopLayout = new QGridLayout( this );
1631 TopLayout->setSpacing( 6 );
1632 TopLayout->setMargin( 11 );
1634 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1635 TopGroup->setColumnLayout(0, Qt::Vertical );
1636 TopGroup->layout()->setSpacing( 0 );
1637 TopGroup->layout()->setMargin( 0 );
1638 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1639 TopGroupLayout->setAlignment( Qt::AlignTop );
1640 TopGroupLayout->setSpacing( 6 );
1641 TopGroupLayout->setMargin( 11 );
1644 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1645 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1647 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1648 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1649 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1652 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1653 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1655 myTimeOut = new QLineEdit( TopGroup );
1656 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1657 myTimeOut->setValidator( new QIntValidator(this) );
1658 myTimeOut->setMinimumSize( 100, 0 );
1659 myTimeOut->setReadOnly( isReadOnly );
1660 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1663 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1664 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1666 myDataStreamTrace = new QComboBox( TopGroup );
1667 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1668 myDataStreamTrace->insertItem("WithoutTrace");
1669 myDataStreamTrace->insertItem("SummaryTrace");
1670 myDataStreamTrace->insertItem("DetailedTrace");
1671 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1673 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1674 GroupButtons->setColumnLayout(0, Qt::Vertical );
1675 GroupButtons->layout()->setSpacing( 0 );
1676 GroupButtons->layout()->setMargin( 0 );
1677 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1678 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1679 GroupButtonsLayout->setSpacing( 6 );
1680 GroupButtonsLayout->setMargin( 11 );
1682 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1683 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1685 GroupButtonsLayout->addWidget( okB, 0, 0 );
1686 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1687 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1689 TopLayout->addWidget( TopGroup, 0, 0 );
1690 TopLayout->addWidget( GroupButtons, 1, 0 );
1692 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1693 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1701 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1702 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1708 void SUPERVGUI_DSGraphParameters::setData() {
1711 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1713 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1714 if (myGraph->IsStreamGraph()) {
1715 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1716 if (!SUPERV_isNull(aSGraph))
1717 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1720 myDeltaTime->setValue(aDeltaTime);
1721 myTimeOut->setText(QString("%1").arg(aTimeOut));
1722 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1728 void SUPERVGUI_DSGraphParameters::accept() {
1729 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1730 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1731 // myDeltaTime->value());
1732 if (myGraph->IsStreamGraph()) {
1733 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1734 if (!SUPERV_isNull(aSGraph))
1735 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1736 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1737 myDeltaTime->value());