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
30 #include "QAD_Splitter.h"
31 #include "QAD_LeftFrame.h"
32 #include "QAD_ObjectBrowser.h"
33 #include "QAD_ObjectBrowserItem.h"
34 #include "QAD_PyEditor.h"
35 #include "QAD_Message.h"
36 #include "QAD_FileDlg.h"
37 #include "QAD_Application.h"
38 #include "QAD_RightFrame.h"
39 #include "QAD_SpinBoxDbl.h"
41 #include "NOTIFICATION.hxx"
42 #include "SALOME_Event.hxx"
43 #include "SALOMEGUI_ImportOperation.h"
44 #include "SUPERVGraph_ViewFrame.h"
46 #include "SUPERVGUI.h"
47 #include "SUPERVGUI_Def.h"
48 #include "SUPERVGUI_Main.h"
49 #include "SUPERVGUI_Notification.h"
50 #include "SUPERVGUI_Information.h"
51 #include "SUPERVGUI_CanvasControlNode.h"
53 #include <qvalidator.h>
56 #include <qlineedit.h>
57 #include <qcombobox.h>
60 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, SUPERV_Graph theDataFlow )
61 : SUPERVGraph_View(theParent),
64 myLogFileName( QString::null ),
70 myGUIEventLoopFinished( true )
72 Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
73 theParent->setViewWidget(this);
74 dataflow = theDataFlow;
75 if (SUPERV_isNull(dataflow)) {
76 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY"));
83 void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
84 Trace("SUPERVGUI_Main::init");
85 if (theDesktop) myNService = theDesktop->getNameService();
91 myThread = new SUPERVGUI_Thread();
92 myThread->setMain(this);
94 myCurrentView = CANVAS;
95 myIsFromStudy = false;
97 study = theDesktop->getActiveStudy();
99 SALOMEDS::Study_var studyDoc = study->getStudyDocument();
100 bool aLocked = studyDoc->GetProperties()->IsLocked();
101 SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
102 SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
103 SALOMEDS::GenericAttribute_var anAttr;
104 SALOMEDS::AttributeName_var aName;
105 SALOMEDS::AttributePixMap_var aPixmap;
106 if (father->_is_nil()) {
107 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
109 if (aLocked) studyDoc->GetProperties()->SetLocked(false);
110 father = builder->NewComponent(STUDY_SUPERVISION);
111 anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
112 aName = SALOMEDS::AttributeName::_narrow(anAttr);
113 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
115 anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
116 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
117 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
119 builder->DefineComponentInstance(father, Supervision.getEngine());
120 if (aLocked) studyDoc->GetProperties()->SetLocked(true);
124 objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
126 myArray = new SUPERVGUI_CanvasArray(this);
127 myArrayView = new SUPERVGUI_ArrayView(myArray, this);
129 myCanvas = new SUPERVGUI_Canvas(this);
130 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
132 message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
133 notification = new NOTIFICATION_Consumer();
135 QBoxLayout * layout = new QVBoxLayout(this);
136 layout->setMargin(0);
137 layout->setSpacing(0);
138 layout->addWidget(myCanvasView);
139 layout->addWidget(myArrayView);
141 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
146 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
147 myLogFile = fopen( myLogFileName.latin1(), "a" );
148 if ( myLogFile == NULL )
151 myTimer = new QTimer( this );
152 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
155 SUPERVGUI_Main::~SUPERVGUI_Main() {
156 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
158 // close all opened SubGraphs
159 QMap<QString, QAD_StudyFrame*>::iterator it;
160 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
161 it.data()->removeEventFilter(this);
162 it.data()->disconnect();
165 QAD_Study* aStudy = it.data()->getStudy();
166 aStudy->removeStudyFrame(it.data());
169 mySubGraphMap.clear();
171 QAD_StudyFrame* aSubGraph;
172 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
173 aSubGraph->removeEventFilter(this);
178 if ( myLogFile != NULL) {
183 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
184 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
190 void SUPERVGUI_Main::filterNotification() {
191 Trace("SUPERVGUI_Main::filterNotification");
192 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
193 dlg->setFiltered( myFiltered );
194 dlg->setLogged( myLogged, myLogFileName );
195 dlg->setWarning( myWarning );
196 dlg->setStep( myStep );
197 dlg->setTrace( myTrace );
198 dlg->setVerbose( myVerbose );
199 if ( dlg->exec() == QDialog::Accepted ) {
200 myLogged = dlg->getLogged();
201 myLogFileName = dlg->getLogFile();
202 myFiltered = dlg->getFiltered();
203 myWarning = dlg->getWarning();
204 myStep = dlg->getStep();
205 myTrace = dlg->getTrace();
206 myVerbose = dlg->getVerbose();
208 if ( myLogFile != NULL) {
212 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
213 myLogFile = fopen( myLogFileName.latin1(), "a" );
214 if ( myLogFile == NULL ) {
216 QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
222 void SUPERVGUI_Main::syncAsync() {
223 Trace("SUPERVGUI_Main::syncAsync");
224 QTimer::singleShot(1, this, SLOT(sync()));
229 * Called by thread when dataflow is executing
231 void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) {
232 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
233 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
238 else if (myCurrentView == CANVASTABLE) {
239 SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
240 if (aNode) aNode->sync();
245 void SUPERVGUI_Main::sync() {
246 Trace("SUPERVGUI_Main::sync");
247 if ((SUPERV_isNull(dataflow)))
249 QString t = tr("GRAPH_TITLE");
251 t += dataflow->Name();
254 study->updateObjBrowser();
255 if (myCurrentView == CANVASTABLE) {
264 void SUPERVGUI_Main::showCanvasTable() {
265 if (myCurrentView == CANVASTABLE)
268 if (myArray->create()) {
269 myCanvasView->hide();
271 myCurrentView = CANVASTABLE;
276 void SUPERVGUI_Main::showContolFlow() {
278 if (myCurrentView == CANVASTABLE) {
283 myCurrentView = CONTROLFLOW;
284 myCanvas->setControlView();
287 myCanvasView->show();
291 void SUPERVGUI_Main::showCanvas() {
292 if (myCurrentView == CANVAS)
296 if (myCurrentView == CANVASTABLE) {
301 myCurrentView = CANVAS;
302 myCanvas->setFullView();
305 myCanvasView->show();
309 void SUPERVGUI_Main::insertFile() {
310 Trace("SUPERVGUI_Main::insertFile");
311 if ((SUPERV_isNull(dataflow))) return;
313 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
315 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
318 tr("MSG_GRAPH_INSERT"),
321 if (dataflow->Import(f.latin1())) {
322 if (myCurrentView == CANVASTABLE) {
326 else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
331 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
336 void SUPERVGUI_Main::copy() {
337 Trace("SUPERVGUI_Main::copy");
338 if (dataflow->ThreadsMax() == 0) {
339 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
342 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
343 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
344 (aStudyFrame->getRightFrame()->getViewFrame());
346 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
347 if (dataflow->IsStreamGraph()) {
348 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
349 if (SUPERV_isNull(aSGraph)) {
350 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
353 aNewGraph = aSGraph->StreamCopy();
356 aNewGraph = dataflow->Copy();
358 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
359 aNewName += dataflow->Name();
360 aNewGraph->SetName(aNewName);
361 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
362 Supervision.getDesktop(),
364 study->showFrame(aStudyFrame);
368 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
370 if (theNode->IsMacro()) {
371 // get SubGraph from MacroNode
372 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
374 if (aMacro->IsStreamMacro())
375 aGraph = aMacro->StreamObjRef();
377 aGraph = aMacro->FlowObjRef();
380 if (SUPERV_isNull(aGraph)) {
381 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
385 QString aGraphName = aGraph->Name();
386 QAD_StudyFrame* aStudyFrame;
387 if (mySubGraphs.contains(aGraphName)) {
388 aStudyFrame = mySubGraphs[aGraphName];
389 aStudyFrame->setActiveWindow();
390 aStudyFrame->setFocus();
393 aStudyFrame = Supervision.createGraph();
395 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
396 (aStudyFrame->getRightFrame()->getViewFrame());
398 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
399 Supervision.getDesktop(),
401 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
402 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
403 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
404 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
405 aStudyFrame->installEventFilter(this);
407 mySubGraphs.insert(aGraphName, aStudyFrame);
408 mySubGraphMap.insert(aGraphName, theNode->Name());
413 study->showFrame(aStudyFrame);
414 if (!correct) myLastGraph = aStudyFrame;
419 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
421 // workaround to get close event
422 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
423 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
424 onSubGraphClosed(aFrame);
426 return SUPERVGraph_View::eventFilter(o, e);
429 // workaround to fix PAL6255 -> opened SubGraph is not on top
430 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
433 QAD_StudyFrame* aFrame = myLastGraph;
435 aFrame->setActiveWindow();
440 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
442 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
443 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
444 theStudyFrame->removeEventFilter(this);
445 disconnect(theStudyFrame, 0, this, 0);
447 SUPERVGraph_View* view = supervFrame->getViewWidget();
448 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
450 QString aGraphName = aGraph->getDataflow()->Name();
451 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
452 if (it != mySubGraphMap.end()) {
453 QString aNodeName = it.data();
454 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
455 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
460 mySubGraphMap.remove(it);
462 mySubGraphs.remove(aGraphName);
467 void SUPERVGUI_Main::run() {
468 Trace("SUPERVGUI_Main::run");
469 if ((SUPERV_isNull(dataflow))) return;
471 if (dataflow->IsEditing()) {
472 if (!dataflow->IsValid()) {
473 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
475 else if (!dataflow->IsExecutable()) {
476 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
478 else if (myCanvasView->isAnyLinkCreating()) {
479 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
482 myRunTime = QDateTime::currentDateTime();
483 if ( !dataflow->Run() ) {
484 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
485 if ( dataflow->State() == SUPERV::ErrorState ) {
490 myThread->startThread(tr("MSG_GRAPH_STARTED"));
495 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
501 void SUPERVGUI_Main::startExecute() {
502 Trace("SUPERVGUI_Main::startExecute");
503 if ((SUPERV_isNull(dataflow))) return;
505 if (dataflow->IsEditing()) {
506 if (!dataflow->IsValid()) {
507 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
509 else if (!dataflow->IsExecutable()) {
510 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
512 else if (myCanvasView->isAnyLinkCreating()) {
513 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
516 myRunTime = QDateTime::currentDateTime();
517 if (!dataflow->Start()) {
518 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
521 myThread->startThread(tr("MSG_GRAPH_STARTED"));
526 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
531 void SUPERVGUI_Main::kill() {
532 Trace("SUPERVGUI_Main::kill");
533 if ((SUPERV_isNull(dataflow)))
536 if (dataflow->IsEditing()) {
537 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
539 else if (dataflow->Kill()) {
540 myThread->stopThread(tr("MSG_GRAPH_KILLED"));
544 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
548 void SUPERVGUI_Main::suspendResume() {
549 Trace("SUPERVGUI_Main::suspendResume");
550 if ((SUPERV_isNull(dataflow))) return;
552 if (dataflow->IsEditing()) {
553 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
554 } else if (dataflow->State() == SUPERV_Suspend) {
555 if (dataflow->Resume()) {
556 myThread->startThread(tr("MSG_DF_RESUMED"));
558 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
561 if (dataflow->Suspend()) {
563 myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
565 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
569 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
570 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
571 It also calls deprecated method of Engine: ReStart().
572 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
573 Trace("SUPERVGUI_Main::stopRestart");
574 if ((SUPERV_isNull(dataflow))) return;
576 if (dataflow->IsEditing()) {
577 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
578 } else if (dataflow->State() == SUPERV_Stop) {
579 if (dataflow->ReStart()) {
580 message->setMessage(tr("MSG_DF_RESTARTED"));
583 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
586 if (dataflow->Stop()) {
589 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
594 void SUPERVGUI_Main::addNode() {
595 Trace("SUPERVGUI_Main::addNode");
596 if (SUPERV_isNull(dataflow)) return;
598 if (dataflow->IsExecuting()) {
599 if (QMessageBox::warning(QAD_Application::getDesktop(),
600 tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
601 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
608 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
610 Supervision.getBrowser()->choose();
614 * Add Computation node
616 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
617 switch (myCurrentView) {
625 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
626 aNode->move(theNode->X(), theNode->Y());
627 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
638 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
639 switch (myCurrentView) {
647 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
648 aNode->move(theNode->X(), theNode->Y());
649 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
660 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
661 switch (myCurrentView) {
669 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
670 aStartNode->move(theStartNode->X(), theStartNode->Y());
671 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
673 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
674 aEndNode->move(theEndNode->X(), theEndNode->Y());
675 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
689 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
690 switch (myCurrentView) {
698 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
699 aNode->move(theNode->X(), theNode->Y());
700 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
708 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
709 Trace("SUPERVGUI_Main::getCanvasArray");
713 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
714 Trace("SUPERVGUI_Main::getArrayView");
718 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
719 Trace("SUPERVGUI_Main::getCanvas");
723 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
724 Trace("SUPERVGUI_Main::getCanvasView");
725 return(myCanvasView);
728 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
729 Trace("SUPERVGUI_Main::getDataflow");
733 QAD_Message* SUPERVGUI_Main::getMessage() {
734 Trace("SUPERVGUI_Main::getMessage");
738 QAD_Study* SUPERVGUI_Main::getStudy() {
739 Trace("SUPERVGUI_Main::getStudy");
743 bool SUPERVGUI_Main::isArrayShown() {
744 Trace("SUPERVGUI_Main::isArrayShown");
745 return(myCurrentView == CANVASTABLE);
748 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
749 Trace("SUPERVGUI_Main::showPopup");
750 // To check is Supervision active?
751 if (myIsLocked) return;
752 //if (dataflow->IsExecuting()) return;
754 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
755 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
758 if (e->button() == RightButton) {
759 p->exec(e->globalPos());
765 void SUPERVGUI_Main::changeInformation() {
766 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
772 // returns false, if can't add dataflow into the study
773 bool SUPERVGUI_Main::addStudy() {
774 Trace("SUPERVGUI_Main::addStudy");
775 if (myIsFromStudy) return false;
776 if ((SUPERV_isNull(dataflow))) return false;
778 SALOMEDS::Study_var aStudy = study->getStudyDocument();
779 bool aLocked = aStudy->GetProperties()->IsLocked();
780 // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
785 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
786 SALOMEDS::GenericAttribute_var anAttr;
787 SALOMEDS::AttributeName_var aName;
788 SALOMEDS::AttributeIOR_var anIORAttr;
789 SALOMEDS::AttributePixMap_var aPixmap;
790 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
792 // searching dataflow
793 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
794 if (aSO->_is_nil()) { // create new dataflow SObject
795 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
796 if (aComponent->_is_nil()) { // is supervision component not found, then create it
797 QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
798 anOperation->start();
799 //if (aLocked) aStudy->GetProperties()->SetLocked(false);
800 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
801 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
802 aName = SALOMEDS::AttributeName::_narrow(anAttr);
803 //aName->SetValue(STUDY_SUPERVISION);
804 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
805 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
806 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
807 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
808 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
809 //if (aLocked) aStudy->GetProperties()->SetLocked(true);
810 anOperation->finish();
813 aSO = aBuilder->NewObject(aComponent);
814 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
815 aName = SALOMEDS::AttributeName::_narrow(anAttr);
816 aName->SetValue(dataflow->Name());
817 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
818 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
819 anIORAttr->SetValue(dataflow->getIOR());
821 //if (aLocked) return false;
825 Supervision.unregisterGraph(this);
826 Supervision.registerGraph(dataflow->getIOR(), this);
827 myIsFromStudy = true;
832 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
833 Trace("SUPERVGUI_Main::chooseData");
835 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
837 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
838 SALOMEDS::GenericAttribute_var anAttr;
839 SALOMEDS::AttributeIOR_var anIOR;
840 Standard_CString ior = "";
841 if (object->FindAttribute(anAttr, "AttributeIOR")) {
842 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
843 ior = anIOR->Value();
845 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
846 // should be replaced with some analogious code... selection of IOR was done -
847 // put its value into port.
848 //portIn->setValue(ior);
852 setCursor(Supervision.getCursor());
853 objectBrowser->setCursor(Supervision.getCursor());
854 Supervision.putInfo("");
860 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
861 const SALOMEDS::SObject_var theSO,
863 //QAD_Operation* theOperation,
865 SALOMEDS::SObject_var aResult;
866 SALOMEDS::AttributeName_var aName;
867 SALOMEDS::GenericAttribute_var anAttr;
868 if (!*theStarted) { // optimisation
869 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
870 for (; anIterator->More(); anIterator->Next()) {
871 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
872 aName = SALOMEDS::AttributeName::_narrow(anAttr);
873 if (strcmp(aName->Value(), theName) == 0) {
874 aResult = anIterator->Value();
880 if (!aResult->_is_nil()) return aResult;
882 SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
885 //theOperation->start();
886 aBuilder->NewCommand();
888 aResult = aBuilder->NewObject(theSO);
889 anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
890 aName = SALOMEDS::AttributeName::_narrow(anAttr);
891 aName->SetValue(theName);
895 bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) {
896 Trace("SUPERVGUI_Main::putDataStudy");
898 // static variable to ensure that only one instance (thread) is executing this function
899 static bool isIn = false;
905 SALOMEDS::Study_var aStudy = study->getStudyDocument();
906 bool aLocked = aStudy->GetProperties()->IsLocked();
907 // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
914 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
915 SALOMEDS::GenericAttribute_var anAttr;
916 SALOMEDS::AttributeName_var aName;
917 SALOMEDS::AttributeIOR_var anIORAttr;
918 SALOMEDS::AttributePixMap_var aPixmap;
919 bool aTransaction = false;
921 // searching dataflow
922 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
923 if (aSO->_is_nil()) { // create new dataflow SObject
924 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
925 if (aComponent->_is_nil()) { // is supervision component not found, then create it
926 aBuilder->NewCommand();
927 //if (aLocked) aStudy->GetProperties()->SetLocked(false);
928 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
929 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
930 aName = SALOMEDS::AttributeName::_narrow(anAttr);
931 //aName->SetValue(STUDY_SUPERVISION);
932 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
934 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
935 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
936 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
937 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
938 //if (aLocked) aStudy->GetProperties()->SetLocked(true);
939 aBuilder->CommitCommand();
942 aBuilder->NewCommand();
943 aSO = aBuilder->NewObject(aComponent);
944 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
945 aName = SALOMEDS::AttributeName::_narrow(anAttr);
946 aName->SetValue(dataflow->Name());
947 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
948 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
949 anIORAttr->SetValue(dataflow->getIOR());
952 aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO
953 QString("Run ") + myRunTime.toString(), &aTransaction);
954 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name(), &aTransaction); // get node SO
955 aSO = SearchOrCreateSOWithName(aStudy, aSO, inout, &aTransaction); // get in/out SO
956 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name(), &aTransaction); // get port SO
958 if (aTransaction) aBuilder->CommitCommand();
960 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
961 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
962 if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) {
966 // set object value to the study: if object is external, then put it with
967 // help of the specific component - owner
969 // get according component driver for result object
970 SALOME_LifeCycleCORBA aLCC(myNService);
971 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
972 if (!aFNode->_is_nil()) {
973 Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
974 aFNode->GetComponentName());
975 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
976 if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
977 CORBA::Object_ptr anObject = new CORBA::Object();
978 CORBA::Any* anAny = p->ToAny();
979 (*anAny) >>= anObject;
981 if (aDriver->CanPublishInStudy(anObject)) {
982 SALOMEDS::SObject_var aTmpSO;
986 aBuilder->NewCommand();
988 aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, /*anObject->Name()*/"");
989 aBuilder->Addreference(aSO, aTmpSO);
990 } else { // can't publish object: abort transaction
991 if (aTransaction) aBuilder->AbortCommand();
995 } else { // component has no drivel, but could store IORs (like Calculator)
996 SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR(p->ToString());
997 if (!CORBA::is_nil(anIORSO)) aBuilder->Addreference(aSO, anIORSO);
1001 if (!aTransaction) {
1002 aTransaction = true;
1003 aBuilder->NewCommand();
1005 anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
1009 aBuilder->CommitCommand();
1010 if (!myThread->running())
1011 study->updateObjBrowser();
1017 void SUPERVGUI_Main::ActivatePanning()
1019 if (myCanvasView->isVisible()) {
1020 myCanvasView->ActivatePanning();
1021 } else if (myArrayView->isVisible()) {
1022 myArrayView->ActivatePanning();
1027 void SUPERVGUI_Main::ResetView()
1029 if (myCanvasView->isVisible()) {
1030 myCanvasView->ResetView();
1031 } else if (myArrayView->isVisible()) {
1032 myArrayView->ResetView();
1037 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1038 myIsFromStudy = theToStudy;
1039 myCanvas->setAsFromStudy(theToStudy);
1042 void SUPERVGUI_Main::checkIsInStudy() {
1043 if (!myIsFromStudy) return;
1045 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1046 SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1047 SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1048 SALOMEDS::SObject_var aDataflowLbl;
1049 SALOMEDS::GenericAttribute_var anAttr;
1051 for (; aChildIterator->More(); aChildIterator->Next()) {
1052 aDataflowLbl = aChildIterator->Value();
1053 if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1056 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1057 if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1059 // This Graph considered as in study but in study it is not exists
1060 Supervision.unregisterGraph(this);
1061 setAsFromStudy(false);
1064 void SUPERVGUI_Main::syncNotification() {
1074 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1075 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1077 mess += "NOTIF: "; mess += graph;
1078 mess += " / " ; mess += node;
1079 mess += " / " ; mess += type;
1080 mess += " / " ; mess += message;
1081 getMessage()->setMessage(mess.latin1());
1086 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1087 char* sender, long counter, char* date, long stamp) {
1088 Trace("SUPERVGUI_Main::isFiltered");
1090 if (strcmp(getDataflow()->Name(), graph) == 0) {
1091 SUPERVGUI_CanvasNode* n;
1092 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1093 QObjectListIt i(*nodes);
1094 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1096 if (strcmp(n->name(), node) == 0) {
1097 if (strcmp(type, NOTIF_WARNING) == 0) {
1099 } else if (strcmp(type, NOTIF_STEP) == 0) {
1101 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1103 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1110 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1111 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 );
1112 fflush( myLogFile );
1118 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1123 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1125 myCanvas->setBackgroundColor(color);
1126 myCanvasView->setPaletteBackgroundColor(color.light());
1127 myArray->setBackgroundColor(color);
1128 myArrayView->setPaletteBackgroundColor(color.light());
1130 SUPERVGraph_View::setPaletteBackgroundColor(color);
1133 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1134 return myEventNodes;
1137 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1138 myEventNodes = theEventNodes;
1141 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1145 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1146 myStates = theStates;
1149 int SUPERVGUI_Main::getNodesNumber() {
1150 //create a list of nodes of the graph
1151 SUPERV_Nodes nodes = getDataflow()->Nodes();
1152 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1153 nodes->INodes.length() + nodes->GNodes.length() +
1154 nodes->LNodes.length() + nodes->SNodes.length();
1158 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1162 void SUPERVGUI_Main::startTimer() {
1163 myTimer->start(500);
1166 void SUPERVGUI_Main::executionFinished() {
1167 getStudy()->updateObjBrowser();
1172 void SUPERVGUI_Main::checkExecution() {
1173 if (myThread->finished()) {
1175 executionFinished();
1180 * Editing() is to be called by any operation in GUI before modification of a datamodel
1181 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1182 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1183 * are taken from Executor data model. But when user starts editing the graph - these changes must
1184 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1186 void SUPERVGUI_Main::Editing() {
1187 if ( !SUPERV_isNull( dataflow ) )
1188 dataflow->Editing();
1190 // updata GUI, Nodes' statuses and Ports' values could change.
1194 /******************************* SUPERVGUI_Thread class ****************************************/
1195 SUPERVGUI_Thread::SUPERVGUI_Thread()
1201 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1203 //it is a virtual destructor and needs to be determine here
1206 void SUPERVGUI_Thread::startThread(const char* m)
1212 myMain->getMessage()->setMessage(m);
1217 void SUPERVGUI_Thread::stopThread(const char* m)
1219 myMain->getMessage()->setMessage(m);
1222 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1227 void SUPERVGUI_Thread::KillThread(bool theValue)
1230 myIsActive = !(theValue);
1234 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1236 void SUPERVGUI_Thread::run()
1238 SUPERV_CNode aNode = NULL;
1239 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1240 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1242 SUPERV_CNode aPrevNode = NULL;
1243 SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1244 SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1249 QPtrList< char * > anEventNodes;
1250 QPtrList< SUPERV::GraphState > aStates;
1252 myMain->startTimer();
1254 myMain->myGUIEventLoopFinished = false;
1257 myMain->getDataflow()->Event(aNode, aEvent, aState);
1259 if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1261 aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1263 aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1265 if (myMain->getEventNodes().count()) {
1266 myMain->removeEventNodes();
1268 if (myMain->getStates().count()) {
1269 myMain->removeStates();
1274 if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1275 aName = aNode->Name();
1278 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
1279 anEventNodes = myMain->getEventNodes();
1280 anEventNodes.append( &aName ) ;
1281 myMain->setEventNodes(anEventNodes);
1283 aStates = myMain->getStates();
1284 aStates.append( &aState ) ;
1285 myMain->setStates(aStates);
1288 if ( aEvent == aPrevEvent && aState == aPrevState) {
1289 QString aNameStr = aName;
1290 QString aPrevNameStr = aPrevName;
1291 if ( aNameStr != aPrevNameStr ) {
1292 anEventNodes = myMain->getEventNodes();
1293 anEventNodes.append( &aName ) ;
1294 myMain->setEventNodes(anEventNodes);
1296 aStates = myMain->getStates();
1297 aStates.append( &aState ) ;
1298 myMain->setStates(aStates);
1302 anEventNodes = myMain->getEventNodes();
1303 anEventNodes.append( &aName ) ;
1304 myMain->setEventNodes(anEventNodes);
1306 aStates = myMain->getStates();
1307 aStates.append( &aState ) ;
1308 myMain->setStates(aStates);
1313 switch (myMain->getDataflow()->State()) {
1314 case SUPERV_Editing :
1315 stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1318 case SUPERV_Suspend :
1319 stopThread(tr("MSG_GRAPH_SUSPENDED"));
1323 stopThread(tr("MSG_GRAPH_FINISHED"));
1327 stopThread(tr("MSG_GRAPH_ABORTED"));
1331 stopThread(tr("MSG_GRAPH_KILLED"));
1337 if ( myMain->getEventNodes().count() ) {
1338 //if list not empty call execute() -> sync()
1339 char * aNodeName = *(myMain->getEventNodes().getFirst());
1340 SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1342 // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1343 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1345 myMain->removeFirstEN();
1346 myMain->removeFirstS();
1350 aPrevEvent = aEvent;
1351 aPrevState = aState;
1353 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
1356 aPrevName = aPrevNode->Name();
1361 // VSR: 04/12/03 ---> update object browser ufter finishing
1363 // myMain->getStudy()->updateObjBrowser();
1365 // VSR: 04/12/03 <---
1367 myMain->myGUIEventLoopFinished = true;
1372 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1376 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1377 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1379 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1380 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1381 setSizeGripEnabled( true );
1384 QGridLayout* TopLayout = new QGridLayout( this );
1385 TopLayout->setSpacing( 6 );
1386 TopLayout->setMargin( 11 );
1388 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1389 TopGroup->setColumnLayout(0, Qt::Vertical );
1390 TopGroup->layout()->setSpacing( 0 );
1391 TopGroup->layout()->setMargin( 0 );
1392 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1393 TopGroupLayout->setAlignment( Qt::AlignTop );
1394 TopGroupLayout->setSpacing( 6 );
1395 TopGroupLayout->setMargin( 11 );
1398 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1399 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1401 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1402 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1403 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1406 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1407 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1409 myTimeOut = new QLineEdit( TopGroup );
1410 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1411 myTimeOut->setValidator( new QIntValidator(this) );
1412 myTimeOut->setMinimumSize( 100, 0 );
1413 myTimeOut->setReadOnly( isReadOnly );
1414 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1417 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1418 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1420 myDataStreamTrace = new QComboBox( TopGroup );
1421 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1422 myDataStreamTrace->insertItem("WithoutTrace");
1423 myDataStreamTrace->insertItem("SummaryTrace");
1424 myDataStreamTrace->insertItem("DetailedTrace");
1425 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1427 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1428 GroupButtons->setColumnLayout(0, Qt::Vertical );
1429 GroupButtons->layout()->setSpacing( 0 );
1430 GroupButtons->layout()->setMargin( 0 );
1431 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1432 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1433 GroupButtonsLayout->setSpacing( 6 );
1434 GroupButtonsLayout->setMargin( 11 );
1436 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1437 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1439 GroupButtonsLayout->addWidget( okB, 0, 0 );
1440 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1441 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1443 TopLayout->addWidget( TopGroup, 0, 0 );
1444 TopLayout->addWidget( GroupButtons, 1, 0 );
1446 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1447 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1455 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1456 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1462 void SUPERVGUI_DSGraphParameters::setData() {
1465 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1467 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1468 if (myGraph->IsStreamGraph()) {
1469 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1470 if (!SUPERV_isNull(aSGraph))
1471 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1474 myDeltaTime->setValue(aDeltaTime);
1475 myTimeOut->setText(QString("%1").arg(aTimeOut));
1476 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1482 void SUPERVGUI_DSGraphParameters::accept() {
1483 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1484 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1485 // myDeltaTime->value());
1486 if (myGraph->IsStreamGraph()) {
1487 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1488 if (!SUPERV_isNull(aSGraph))
1489 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1490 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1491 myDeltaTime->value());