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"
40 #include "QAD_MessageBox.h"
42 #include "NOTIFICATION.hxx"
43 #include "SALOME_Event.hxx"
44 #include "SALOMEGUI_ImportOperation.h"
45 #include "SUPERVGraph_ViewFrame.h"
47 #include "SUPERVGUI.h"
48 #include "SUPERVGUI_Def.h"
49 #include "SUPERVGUI_Main.h"
50 #include "SUPERVGUI_Notification.h"
51 #include "SUPERVGUI_Information.h"
52 #include "SUPERVGUI_CanvasControlNode.h"
53 #include "SUPERVGUI_CanvasPort.h"
55 #include <qvalidator.h>
58 #include <qlineedit.h>
59 #include <qcombobox.h>
62 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, SUPERV_Graph theDataFlow )
63 : SUPERVGraph_View(theParent),
66 myLogFileName( QString::null ),
74 Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
75 theParent->setViewWidget(this);
76 dataflow = theDataFlow;
77 if (SUPERV_isNull(dataflow)) {
78 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY"));
85 void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
86 Trace("SUPERVGUI_Main::init");
87 if (theDesktop) myNService = theDesktop->getNameService();
93 myThread = new SUPERVGUI_Thread();
94 myThread->setMain(this);
96 myCurrentView = CANVAS;
97 myIsFromStudy = false;
99 study = theDesktop->getActiveStudy();
101 SALOMEDS::Study_var studyDoc = study->getStudyDocument();
102 bool aLocked = studyDoc->GetProperties()->IsLocked();
103 SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
104 SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
105 SALOMEDS::GenericAttribute_var anAttr;
106 SALOMEDS::AttributeName_var aName;
107 SALOMEDS::AttributePixMap_var aPixmap;
108 if (father->_is_nil()) {
109 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
111 if (aLocked) studyDoc->GetProperties()->SetLocked(false);
112 father = builder->NewComponent(STUDY_SUPERVISION);
113 anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
114 aName = SALOMEDS::AttributeName::_narrow(anAttr);
115 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
117 anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
118 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
119 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
121 builder->DefineComponentInstance(father, Supervision.getEngine());
122 if (aLocked) studyDoc->GetProperties()->SetLocked(true);
126 objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
128 myArray = new SUPERVGUI_CanvasArray(this);
129 myArrayView = new SUPERVGUI_ArrayView(myArray, this);
131 myCanvas = new SUPERVGUI_Canvas(this);
132 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
134 message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
135 notification = new NOTIFICATION_Consumer();
137 QBoxLayout * layout = new QVBoxLayout(this);
138 layout->setMargin(0);
139 layout->setSpacing(0);
140 layout->addWidget(myCanvasView);
141 layout->addWidget(myArrayView);
143 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
149 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
150 myLogFile = fopen( myLogFileName.latin1(), "a" );
151 if ( myLogFile == NULL )
154 myTimer = new QTimer( this );
155 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
158 SUPERVGUI_Main::~SUPERVGUI_Main() {
159 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
161 // close all opened SubGraphs
162 QMap<QString, QAD_StudyFrame*>::iterator it;
163 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
164 it.data()->removeEventFilter(this);
165 it.data()->disconnect();
168 QAD_Study* aStudy = it.data()->getStudy();
169 aStudy->removeStudyFrame(it.data());
172 mySubGraphMap.clear();
174 QAD_StudyFrame* aSubGraph;
175 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
176 aSubGraph->removeEventFilter(this);
181 if ( myLogFile != NULL) {
185 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
186 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
192 void SUPERVGUI_Main::filterNotification() {
193 Trace("SUPERVGUI_Main::filterNotification");
194 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
195 dlg->setFiltered( myFiltered );
196 dlg->setLogged( myLogged, myLogFileName );
197 dlg->setWarning( myWarning );
198 dlg->setStep( myStep );
199 dlg->setTrace( myTrace );
200 dlg->setVerbose( myVerbose );
201 if ( dlg->exec() == QDialog::Accepted ) {
202 myLogged = dlg->getLogged();
203 myLogFileName = dlg->getLogFile();
204 myFiltered = dlg->getFiltered();
205 myWarning = dlg->getWarning();
206 myStep = dlg->getStep();
207 myTrace = dlg->getTrace();
208 myVerbose = dlg->getVerbose();
210 if ( myLogFile != NULL) {
214 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
215 myLogFile = fopen( myLogFileName.latin1(), "a" );
216 if ( myLogFile == NULL ) {
218 QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
224 void SUPERVGUI_Main::syncAsync() {
225 Trace("SUPERVGUI_Main::syncAsync");
226 QTimer::singleShot(1, this, SLOT(sync()));
231 * Called by thread when dataflow is executing
233 void SUPERVGUI_Main::execute( char * theNodeName, SUPERV::GraphState theNodeState ) {
234 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
235 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
239 else if (myCurrentView == CANVASTABLE) {
240 SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
245 // asv : 26.01.05 : Bug PAL7164 : puting out-value to study if the "put_to_Study" flag is set on a
246 // CanvasPort the functionality was moved from SUPERVGUI_CanvasPortOut::sync() method please, see
247 // comment in that method for details.
248 if ( theNodeState == SUPERV::DoneState ) {
249 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
251 //cout << " *** theNode " << theNodeName << " received DONE_STATE *** " << endl;
252 SUPERVGUI_CanvasPortOut* aPortOut;
253 QObjectList* aPortList = aNode->queryList("SUPERVGUI_CanvasPortOut");
254 QObjectListIt aPortIt(*aPortList);
255 while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) {
257 if ( aPortOut->isInStudy() && aPortOut->getEngine()->State() == SUPERV::ReadyState ) {
258 //cout << " *** " << theNodeName << "[" << aPortOut->name() << "]--> goes into study *** " << endl;
259 putDataStudy( aPortOut->getEngine(), STUDY_PORT_OUT );
264 //else //normal case if Node is not found is when node is a graph! it can receive DoneState as well!
265 // MESSAGE( "ERROR in SUPERVGUI_Main::execute() : CanvasNode \"" << theNodeName << "\" NOT FOUND in myCanvas" );
270 void SUPERVGUI_Main::sync() {
271 Trace("SUPERVGUI_Main::sync");
272 if ((SUPERV_isNull(dataflow)))
274 QString t = tr("GRAPH_TITLE");
276 t += dataflow->Name();
279 study->updateObjBrowser();
280 if (myCurrentView == CANVASTABLE) {
289 void SUPERVGUI_Main::showCanvasTable() {
290 if (myCurrentView == CANVASTABLE)
293 if (myArray->create()) {
294 myCanvasView->hide();
296 myCurrentView = CANVASTABLE;
301 void SUPERVGUI_Main::showContolFlow() {
303 if (myCurrentView == CANVASTABLE) {
308 myCurrentView = CONTROLFLOW;
309 myCanvas->setControlView();
312 myCanvasView->show();
316 void SUPERVGUI_Main::showCanvas() {
317 if (myCurrentView == CANVAS)
321 if (myCurrentView == CANVASTABLE) {
326 myCurrentView = CANVAS;
327 myCanvas->setFullView();
330 myCanvasView->show();
334 void SUPERVGUI_Main::insertFile() {
335 Trace("SUPERVGUI_Main::insertFile");
337 if ( !ReadyToModify() ) // null dataflow or executing, ..
340 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
343 tr("MSG_GRAPH_INSERT"),
345 if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name
347 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960
349 if (dataflow->Import(f.latin1())) {
350 if (myCurrentView == CANVASTABLE) {
354 else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
359 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
364 void SUPERVGUI_Main::copy() {
365 Trace("SUPERVGUI_Main::copy");
366 if (dataflow->ThreadsMax() == 0) {
367 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
370 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
371 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
372 (aStudyFrame->getRightFrame()->getViewFrame());
374 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
375 if (dataflow->IsStreamGraph()) {
376 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
377 if (SUPERV_isNull(aSGraph)) {
378 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
381 aNewGraph = aSGraph->StreamCopy();
384 aNewGraph = dataflow->Copy();
386 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
387 aNewName += dataflow->Name();
388 aNewGraph->SetName(aNewName);
389 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
390 Supervision.getDesktop(),
392 study->showFrame(aStudyFrame);
396 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
398 if (theNode->IsMacro()) {
399 // get SubGraph from MacroNode
400 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
402 if (aMacro->IsStreamMacro())
403 aGraph = aMacro->StreamObjRef();
405 aGraph = aMacro->FlowObjRef();
408 if (SUPERV_isNull(aGraph)) {
409 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
413 QString aGraphName = aGraph->Name();
414 QAD_StudyFrame* aStudyFrame;
415 if (mySubGraphs.contains(aGraphName)) {
416 aStudyFrame = mySubGraphs[aGraphName];
417 aStudyFrame->setActiveWindow();
418 aStudyFrame->setFocus();
421 aStudyFrame = Supervision.createGraph();
423 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
424 (aStudyFrame->getRightFrame()->getViewFrame());
426 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
427 Supervision.getDesktop(),
429 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
430 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
431 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
432 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
433 aStudyFrame->installEventFilter(this);
435 mySubGraphs.insert(aGraphName, aStudyFrame);
436 mySubGraphMap.insert(aGraphName, theNode->Name());
441 study->showFrame(aStudyFrame);
442 if (!correct) myLastGraph = aStudyFrame;
447 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
449 // workaround to get close event
450 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
451 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
452 onSubGraphClosed(aFrame);
454 return SUPERVGraph_View::eventFilter(o, e);
457 // workaround to fix PAL6255 -> opened SubGraph is not on top
458 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
461 QAD_StudyFrame* aFrame = myLastGraph;
463 aFrame->setActiveWindow();
468 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
470 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
471 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
472 theStudyFrame->removeEventFilter(this);
473 disconnect(theStudyFrame, 0, this, 0);
475 SUPERVGraph_View* view = supervFrame->getViewWidget();
476 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
478 QString aGraphName = aGraph->getDataflow()->Name();
479 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
480 if (it != mySubGraphMap.end()) {
481 QString aNodeName = it.data();
482 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
483 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
488 mySubGraphMap.remove(it);
490 mySubGraphs.remove(aGraphName);
495 void SUPERVGUI_Main::run( const bool andSuspend ) {
496 Trace("SUPERVGUI_Main::run");
497 if ( SUPERV_isNull(dataflow) )
500 if ( dataflow->IsEditing() ) { // not currently Executing
502 // asv 31.01.05 : fix for PAL7854, Editing moved from SUPERVGUI.cxx runDataflow(), stepByStep() to here..
503 Editing(); // remove old executor, update GUI (all nodes to "No Status")
505 if ( !dataflow->IsValid() ) {
506 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
508 else if (!dataflow->IsExecutable()) {
509 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
511 else if (myCanvasView->isAnyLinkCreating()) {
512 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
515 myRunTime = QDateTime::currentDateTime();
516 const bool result = andSuspend ? dataflow->Start() : dataflow->Run();
518 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
519 if ( dataflow->State() == SUPERV::ErrorState ) {
524 //myExecuted = true; // set to true on first execution. for correct publishing in Study
525 myThread->startThread(tr("MSG_GRAPH_STARTED"));
530 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
535 void SUPERVGUI_Main::kill() {
536 Trace("SUPERVGUI_Main::kill");
537 if ((SUPERV_isNull(dataflow)))
540 if (dataflow->IsEditing()) {
541 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
543 else if (dataflow->Kill()) {
544 getMessage()->setMessage( tr("MSG_GRAPH_KILLED") );
548 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
552 void SUPERVGUI_Main::suspendResume() {
553 Trace("SUPERVGUI_Main::suspendResume");
554 if ((SUPERV_isNull(dataflow))) return;
556 if (dataflow->IsEditing()) {
557 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
558 } else if (dataflow->State() == SUPERV_Suspend) {
559 if (dataflow->Resume()) {
560 myThread->startThread(tr("MSG_DF_RESUMED"));
562 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
565 if (dataflow->Suspend()) {
567 getMessage()->setMessage( tr("MSG_GRAPH_SUSPENDED") );
569 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
573 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
574 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
575 It also calls deprecated method of Engine: ReStart().
576 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
577 Trace("SUPERVGUI_Main::stopRestart");
578 if ((SUPERV_isNull(dataflow))) return;
580 if (dataflow->IsEditing()) {
581 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
582 } else if (dataflow->State() == SUPERV_Stop) {
583 if (dataflow->ReStart()) {
584 message->setMessage(tr("MSG_DF_RESTARTED"));
587 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
590 if (dataflow->Stop()) {
593 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
598 void SUPERVGUI_Main::addNode() {
599 Trace("SUPERVGUI_Main::addNode");
601 if ( !ReadyToModify() ) // null dataflow or executing, ..
604 //Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, commented: PAL7960
605 Supervision.getBrowser()->choose();
609 * Add Computation node
611 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
612 switch (myCurrentView) {
620 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
621 aNode->move(theNode->X(), theNode->Y());
622 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
633 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
634 switch (myCurrentView) {
642 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
643 aNode->move(theNode->X(), theNode->Y());
644 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
655 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
656 switch (myCurrentView) {
664 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
665 aStartNode->move(theStartNode->X(), theStartNode->Y());
666 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
668 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
669 aEndNode->move(theEndNode->X(), theEndNode->Y());
670 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
684 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
685 switch (myCurrentView) {
693 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
694 aNode->move(theNode->X(), theNode->Y());
695 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
703 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
704 Trace("SUPERVGUI_Main::getCanvasArray");
708 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
709 Trace("SUPERVGUI_Main::getArrayView");
713 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
714 Trace("SUPERVGUI_Main::getCanvas");
718 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
719 Trace("SUPERVGUI_Main::getCanvasView");
720 return(myCanvasView);
723 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
724 Trace("SUPERVGUI_Main::getDataflow");
728 QAD_Message* SUPERVGUI_Main::getMessage() {
729 Trace("SUPERVGUI_Main::getMessage");
733 QAD_Study* SUPERVGUI_Main::getStudy() {
734 Trace("SUPERVGUI_Main::getStudy");
738 bool SUPERVGUI_Main::isArrayShown() {
739 Trace("SUPERVGUI_Main::isArrayShown");
740 return(myCurrentView == CANVASTABLE);
743 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
744 Trace("SUPERVGUI_Main::showPopup");
745 // To check is Supervision active?
746 if (myIsLocked) return;
747 //if (dataflow->IsExecuting()) return;
749 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
750 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
752 if (e->button() == RightButton) {
753 p->exec(e->globalPos());
757 void SUPERVGUI_Main::changeInformation() {
758 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
764 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
765 Trace("SUPERVGUI_Main::chooseData");
767 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
769 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
770 SALOMEDS::GenericAttribute_var anAttr;
771 SALOMEDS::AttributeIOR_var anIOR;
772 Standard_CString ior = "";
773 if (object->FindAttribute(anAttr, "AttributeIOR")) {
774 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
775 ior = anIOR->Value();
777 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
778 // should be replaced with some analogious code... selection of IOR was done -
779 // put its value into port.
780 //portIn->setValue(ior);
784 setCursor(Supervision.getCursor());
785 objectBrowser->setCursor(Supervision.getCursor());
786 Supervision.putInfo("");
792 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
793 const SALOMEDS::StudyBuilder_var theBuilder,
794 const SALOMEDS::SObject_var theSO,
796 bool* theDoneSomething ) {
797 SALOMEDS::SObject_var aResult;
798 SALOMEDS::AttributeName_var aName;
799 SALOMEDS::GenericAttribute_var anAttr;
800 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
801 for (; anIterator->More(); anIterator->Next()) {
802 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
803 aName = SALOMEDS::AttributeName::_narrow(anAttr);
804 if (strcmp(aName->Value(), theName) == 0) {
805 aResult = anIterator->Value();
811 // if aResule was found then theDoneSomething=false and we return
812 *theDoneSomething = aResult->_is_nil();
813 if ( !*theDoneSomething )
817 aResult = theBuilder->NewObject( theSO );
818 anAttr = theBuilder->FindOrCreateAttribute(aResult, "AttributeName");
819 aName = SALOMEDS::AttributeName::_narrow(anAttr);
820 aName->SetValue(theName);
825 * Return true if dataflow is already in the study
827 bool SUPERVGUI_Main::isDataflowInStudy() const {
828 SALOMEDS::Study_var aStudy = study->getStudyDocument();
829 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
830 return ( !CORBA::is_nil( aSO ) );
834 * Create a "Supervision" object in the Study and a "dataflow" object under it
835 * aDoneSomething will be true if "Supervision" or "dataflow" object were created (not found).
837 SALOMEDS::SObject_var createDataflowSObj( QAD_Study* study,
838 SUPERV::Graph_var dataflow,
839 SALOMEDS::StudyBuilder_var aBuilder,
840 bool& aDoneSomething ) {
841 SALOMEDS::Study_var aStudy = study->getStudyDocument();
842 SALOMEDS::GenericAttribute_var anAttr;
843 SALOMEDS::AttributeName_var aName;
844 SALOMEDS::AttributeIOR_var anIORAttr;
845 SALOMEDS::AttributePixMap_var aPixmap;
847 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
848 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
849 if ( aSO->_is_nil() ) { // dataflow SObject not found in the study
850 aDoneSomething = true;
851 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
852 if ( aComponent->_is_nil() ) { // is supervision component not found, then create it
853 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
854 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
855 aName = SALOMEDS::AttributeName::_narrow(anAttr);
856 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
858 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
859 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
860 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
861 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
863 // create dataflow SObject ("aNewDataflow_1")
864 aSO = aBuilder->NewObject(aComponent);
865 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
866 aName = SALOMEDS::AttributeName::_narrow(anAttr);
867 aName->SetValue(dataflow->Name());
868 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
869 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
870 anIORAttr->SetValue(dataflow->getIOR());
876 void SUPERVGUI_Main::addDataflowToStudy() {
878 SALOMEDS::StudyBuilder_var aBuilder = study->getStudyDocument()->NewBuilder();
879 aBuilder->NewCommand();
880 SALOMEDS::SObject_var aDF = createDataflowSObj( study, dataflow, aBuilder, isCreated );
881 if ( !CORBA::is_nil( aDF ) ) {
882 aBuilder->CommitCommand();
883 // what is this register/unregister?? don't know..
884 Supervision.unregisterGraph(this);
885 Supervision.registerGraph(dataflow->getIOR(), this);
887 if ( !myThread->running() )
888 study->updateObjBrowser();
891 MESSAGE( "ERROR: failed to find or create dataflow SObject" );
892 aBuilder->AbortCommand();
896 bool SUPERVGUI_Main::putDataStudy( SUPERV_Port p, const char* inout ) {
897 Trace("SUPERVGUI_Main::putDataStudy");
899 // static variable to ensure that only one instance (thread) is executing this function
900 static bool isIn = false;
901 if (isIn) return true;
904 SALOMEDS::Study_var aStudy = study->getStudyDocument();
905 const bool aLocked = aStudy->GetProperties()->IsLocked();
906 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
907 SALOMEDS::GenericAttribute_var anAttr;
908 SALOMEDS::AttributeIOR_var anIORAttr;
909 SALOMEDS::AttributePixMap_var aPixmap;
910 bool aDoneSomething = false;
912 // asv 23.11.04 : fix for PAL6852 if the study is locked -- then we can't put anything in it.
914 MESSAGE( "The study is locked and can not be modified!" );
919 // check if the port and its node are good
920 if ( CORBA::is_nil( p ) || CORBA::is_nil( p->Node() ) ) {
921 MESSAGE( "putInStudy ERROR: port or node are NULL!" );
926 // open new command. Commit or Abort it depending on aDoneSomething variable or error
927 aBuilder->NewCommand();
929 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
930 SALOMEDS::SObject_var aSO = createDataflowSObj( study, dataflow, aBuilder, aDoneSomething );
932 if ( CORBA::is_nil( aSO ) ) {
933 MESSAGE( "ERROR: putDataStudy() could not find or create dataflow SObject" );
934 aBuilder->AbortCommand();
939 // Create "Run -> Time and date, etc." SObjects
940 if ( p->State() == SUPERV::ReadyState ) { // if port contains valid computed value
942 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, QString("Run ") + myRunTime.toString(), &aDoneSomething ); // get run time SO
943 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Node()->Name(), &aDoneSomething ); // get node SO
944 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, inout, &aDoneSomething ); // get in/out SO
945 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Name(), &aDoneSomething ); // get port SO
947 // create IOR attribute for port SObject (usually with "return" name)
948 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
949 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
951 // if we have not created anything (all SObject already existed) and we have the same IORAttribute
952 // on the needed SObject -> then don't do anything! it's already there!
953 if ( !aDoneSomething && strcmp(anIORAttr->Value(), p->ToString()) == 0 ) {
954 aBuilder->AbortCommand();
959 aDoneSomething = true; // going to set some value to anIORAttr any way from this point..
961 // set object value to the study: if object is external, then put it with
962 // help of the specific component - owner
964 // get according component driver for result object
965 SALOME_LifeCycleCORBA aLCC( myNService );
966 SUPERV_FNode aFNode = SUPERV::FNode::_narrow( p->Node() );
967 if ( !aFNode->_is_nil() ) {
968 Engines::Component_var aComponent = aLCC.FindOrLoad_Component( aFNode->GetContainer(), aFNode->GetComponentName() );
969 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow( aComponent );
970 if ( !CORBA::is_nil( aDriver ) ) { // if driver was found, publish object
971 CORBA::Object_ptr anObject = new CORBA::Object();
972 CORBA::Any* anAny = p->ToAny();
973 (*anAny) >>= anObject;
975 if ( aDriver->CanPublishInStudy( anObject ) ) {
976 SALOMEDS::SObject_var aTmpSO;// = aSO;
977 aTmpSO = aDriver->PublishInStudy( aStudy, aTmpSO, anObject, "" );
978 aBuilder->Addreference(aSO, aTmpSO);
980 else { // can't publish object: abort transaction
981 MESSAGE( "CanPublishInStudy() returned FALSE. ok, AbortCommand.." );
982 aBuilder->AbortCommand();
987 else { // component has no driver, but could store IORs (like Calculator)
988 SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR( p->ToString() );
989 if ( !CORBA::is_nil( anIORSO ) )
990 aBuilder->Addreference(aSO, anIORSO);
991 else { // Hm... the object (==port value) was not found, so we don't publish it.
992 MESSAGE( "The object (==port value) was not found, so we don't publish it" );
993 aBuilder->AbortCommand();
999 else { // FNode is NULL -> bad
1000 MESSAGE( "FNode is NULL. Not good at all. Aborting command." );
1001 aBuilder->AbortCommand();
1007 anIORAttr->SetValue( p->ToString() ); // ior attribute already set for the prevoius condition
1011 if ( aDoneSomething )
1012 aBuilder->CommitCommand();
1014 aBuilder->AbortCommand();
1016 if ( !myThread->running() )
1017 study->updateObjBrowser();
1024 void SUPERVGUI_Main::ActivatePanning()
1026 if (myCanvasView->isVisible()) {
1027 myCanvasView->ActivatePanning();
1028 } else if (myArrayView->isVisible()) {
1029 myArrayView->ActivatePanning();
1034 void SUPERVGUI_Main::ResetView()
1036 if (myCanvasView->isVisible()) {
1037 myCanvasView->ResetView();
1038 } else if (myArrayView->isVisible()) {
1039 myArrayView->ResetView();
1043 void SUPERVGUI_Main::syncNotification() {
1053 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1054 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1056 mess += "NOTIF: "; mess += graph;
1057 mess += " / " ; mess += node;
1058 mess += " / " ; mess += type;
1059 mess += " / " ; mess += message;
1060 getMessage()->setMessage(mess.latin1());
1065 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1066 char* sender, long counter, char* date, long stamp) {
1067 Trace("SUPERVGUI_Main::isFiltered");
1069 if (strcmp(getDataflow()->Name(), graph) == 0) {
1070 SUPERVGUI_CanvasNode* n;
1071 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1072 QObjectListIt i(*nodes);
1073 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1075 if (strcmp(n->name(), node) == 0) {
1076 if (strcmp(type, NOTIF_WARNING) == 0) {
1078 } else if (strcmp(type, NOTIF_STEP) == 0) {
1080 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1082 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1089 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1090 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 );
1091 fflush( myLogFile );
1097 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1102 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1104 myCanvas->setBackgroundColor(color);
1105 myCanvasView->setPaletteBackgroundColor(color.light());
1106 myArray->setBackgroundColor(color);
1107 myArrayView->setPaletteBackgroundColor(color.light());
1109 SUPERVGraph_View::setPaletteBackgroundColor(color);
1112 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1113 return myEventNodes;
1116 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1117 myEventNodes = theEventNodes;
1120 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1124 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1125 myStates = theStates;
1128 int SUPERVGUI_Main::getNodesNumber() {
1129 //create a list of nodes of the graph
1130 SUPERV_Nodes nodes = getDataflow()->Nodes();
1131 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1132 nodes->INodes.length() + nodes->GNodes.length() +
1133 nodes->LNodes.length() + nodes->SNodes.length();
1137 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1141 void SUPERVGUI_Main::startTimer() {
1142 myTimer->start(500);
1145 void SUPERVGUI_Main::executionFinished() {
1146 getStudy()->updateObjBrowser();
1151 void SUPERVGUI_Main::checkExecution() {
1152 if (myThread->finished()) {
1154 executionFinished();
1159 * Editing() is to be called by any operation in GUI before modification of a datamodel
1160 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1161 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1162 * are taken from Executor data model. But when user starts editing the graph - these changes must
1163 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1165 void SUPERVGUI_Main::Editing() {
1166 if ( !SUPERV_isNull( dataflow ) )
1167 dataflow->Editing();
1169 // updata GUI, Nodes' statuses and Ports' values could change.
1173 void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
1175 // mkr: since the deletion of the node allow only in CANVAS view,
1176 // it is necessary to remove the CanvasArray's children, which
1177 // have the same CNode engine as deleting node. This CNode is given
1180 const QObjectList* aChList = myArray->children();
1181 if ( aChList ) { // asv 27.01.05 : fix for 7817
1182 QObjectListIt aItChList(*aChList);
1183 SUPERVGUI_CanvasNode* anObjNode;
1184 while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
1186 if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
1187 myArray->removeChild(anObjNode);
1191 } // end of if ( ChList )
1196 * ReadyToModify() must be called before any modification
1197 * operation - asks to kill execution of dataflow. If returns false -
1198 * modification (==Editing() ) is not allowed.
1200 bool SUPERVGUI_Main::ReadyToModify() {
1201 if ( CORBA::is_nil( dataflow ) )
1203 if ( dataflow->IsExecuting() ) {
1204 bool quit = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No
1205 tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 );
1206 if ( quit ) // user selected NOT to kill dataflow and NOT to add new node
1208 else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that
1209 kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up
1214 /******************************* SUPERVGUI_Thread class ****************************************/
1215 SUPERVGUI_Thread::SUPERVGUI_Thread()
1221 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1223 //it is a virtual destructor and needs to be determine here
1226 void SUPERVGUI_Thread::startThread(const char* m)
1231 myMain->getMessage()->setMessage(m);
1236 void SUPERVGUI_Thread::setMain( SUPERVGUI_Main* theMain )
1241 void SUPERVGUI_Thread::KillThread( bool theValue )
1244 myIsActive = !(theValue);
1248 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1250 void SUPERVGUI_Thread::run()
1252 myMain->startTimer();
1254 // GUI cycle to handle events coming for Engine
1255 while ( myIsActive ) {
1257 SUPERV_CNode aNode = NULL;
1258 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1259 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1261 // blocking function of Engine. Return from there only after anEvent happens on node aNode
1262 myMain->getDataflow()->Event(aNode, aEvent, aState);
1264 // "kill" or undefined event came
1265 if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
1266 ( aEvent == SUPERV::NoEvent && aState == SUPERV::NoState ) ||
1267 ( aEvent == SUPERV::KillEvent && aState == SUPERV::KillState )) {
1271 else { // a "normal" execution event came
1273 if ( aNode != NULL && !CORBA::is_nil( aNode ) )
1274 aName = aNode->Name();
1276 // this function is asynchronious. The call does NOT wait when SUPERVGUI_Main::execute finishes
1277 // handling the event. So: SUPERVGUI_Main::execute must be fast, in order we don't get here again
1278 // on the next loop iteration, BEFORE previous SUPERVGUI_Main::execute finished.
1279 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aName, aState ) );
1282 // execution is finished. just set a "finished" message(s)
1283 if ( !myIsActive ) {
1284 switch ( myMain->getDataflow()->State() ) {
1285 case SUPERV_Editing :
1286 myMain->getMessage()->setMessage( myMain->getDataflow()->IsReadOnly()?
1287 tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING") );
1289 case SUPERV_Suspend :
1290 myMain->getMessage()->setMessage( tr("MSG_GRAPH_SUSPENDED") );
1293 myMain->getMessage()->setMessage( tr("MSG_GRAPH_FINISHED") );
1296 myMain->getMessage()->setMessage( tr("MSG_GRAPH_ABORTED") );
1299 myMain->getMessage()->setMessage( tr("MSG_GRAPH_KILLED") );
1303 // asv 03.02.05 : fix for PAL6859, not very good, but works..
1305 } // end of if !myIsActive
1306 } // end of while( myIsActive )
1311 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1315 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1316 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1318 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1319 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1320 setSizeGripEnabled( true );
1323 QGridLayout* TopLayout = new QGridLayout( this );
1324 TopLayout->setSpacing( 6 );
1325 TopLayout->setMargin( 11 );
1327 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1328 TopGroup->setColumnLayout(0, Qt::Vertical );
1329 TopGroup->layout()->setSpacing( 0 );
1330 TopGroup->layout()->setMargin( 0 );
1331 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1332 TopGroupLayout->setAlignment( Qt::AlignTop );
1333 TopGroupLayout->setSpacing( 6 );
1334 TopGroupLayout->setMargin( 11 );
1337 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1338 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1340 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1341 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1342 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1345 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1346 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1348 myTimeOut = new QLineEdit( TopGroup );
1349 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1350 myTimeOut->setValidator( new QIntValidator(this) );
1351 myTimeOut->setMinimumSize( 100, 0 );
1352 myTimeOut->setReadOnly( isReadOnly );
1353 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1356 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1357 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1359 myDataStreamTrace = new QComboBox( TopGroup );
1360 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1361 myDataStreamTrace->insertItem("WithoutTrace");
1362 myDataStreamTrace->insertItem("SummaryTrace");
1363 myDataStreamTrace->insertItem("DetailedTrace");
1364 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1366 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1367 GroupButtons->setColumnLayout(0, Qt::Vertical );
1368 GroupButtons->layout()->setSpacing( 0 );
1369 GroupButtons->layout()->setMargin( 0 );
1370 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1371 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1372 GroupButtonsLayout->setSpacing( 6 );
1373 GroupButtonsLayout->setMargin( 11 );
1375 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1376 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1378 GroupButtonsLayout->addWidget( okB, 0, 0 );
1379 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1380 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1382 TopLayout->addWidget( TopGroup, 0, 0 );
1383 TopLayout->addWidget( GroupButtons, 1, 0 );
1385 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1386 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1394 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1395 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1401 void SUPERVGUI_DSGraphParameters::setData() {
1404 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1406 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1407 if (myGraph->IsStreamGraph()) {
1408 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1409 if (!SUPERV_isNull(aSGraph))
1410 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1413 myDeltaTime->setValue(aDeltaTime);
1414 myTimeOut->setText(QString("%1").arg(aTimeOut));
1415 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1421 void SUPERVGUI_DSGraphParameters::accept() {
1422 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1423 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1424 // myDeltaTime->value());
1425 if (myGraph->IsStreamGraph()) {
1426 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1427 if (!SUPERV_isNull(aSGraph))
1428 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1429 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1430 myDeltaTime->value());