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"
52 #include "SUPERVGUI_CanvasPort.h"
54 #include <qvalidator.h>
57 #include <qlineedit.h>
58 #include <qcombobox.h>
61 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, SUPERV_Graph theDataFlow )
62 : SUPERVGraph_View(theParent),
65 myLogFileName( QString::null ),
71 myGUIEventLoopFinished( true )
73 Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
74 theParent->setViewWidget(this);
75 dataflow = theDataFlow;
76 if (SUPERV_isNull(dataflow)) {
77 QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY"));
84 void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
85 Trace("SUPERVGUI_Main::init");
86 if (theDesktop) myNService = theDesktop->getNameService();
92 myThread = new SUPERVGUI_Thread();
93 myThread->setMain(this);
95 myCurrentView = CANVAS;
96 myIsFromStudy = false;
98 study = theDesktop->getActiveStudy();
100 SALOMEDS::Study_var studyDoc = study->getStudyDocument();
101 bool aLocked = studyDoc->GetProperties()->IsLocked();
102 SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
103 SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
104 SALOMEDS::GenericAttribute_var anAttr;
105 SALOMEDS::AttributeName_var aName;
106 SALOMEDS::AttributePixMap_var aPixmap;
107 if (father->_is_nil()) {
108 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
110 if (aLocked) studyDoc->GetProperties()->SetLocked(false);
111 father = builder->NewComponent(STUDY_SUPERVISION);
112 anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
113 aName = SALOMEDS::AttributeName::_narrow(anAttr);
114 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
116 anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
117 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
118 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
120 builder->DefineComponentInstance(father, Supervision.getEngine());
121 if (aLocked) studyDoc->GetProperties()->SetLocked(true);
125 objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
127 myArray = new SUPERVGUI_CanvasArray(this);
128 myArrayView = new SUPERVGUI_ArrayView(myArray, this);
130 myCanvas = new SUPERVGUI_Canvas(this);
131 myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
133 message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
134 notification = new NOTIFICATION_Consumer();
136 QBoxLayout * layout = new QVBoxLayout(this);
137 layout->setMargin(0);
138 layout->setSpacing(0);
139 layout->addWidget(myCanvasView);
140 layout->addWidget(myArrayView);
142 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
148 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
149 myLogFile = fopen( myLogFileName.latin1(), "a" );
150 if ( myLogFile == NULL )
153 myTimer = new QTimer( this );
154 connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
157 SUPERVGUI_Main::~SUPERVGUI_Main() {
158 Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
160 // close all opened SubGraphs
161 QMap<QString, QAD_StudyFrame*>::iterator it;
162 for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
163 it.data()->removeEventFilter(this);
164 it.data()->disconnect();
167 QAD_Study* aStudy = it.data()->getStudy();
168 aStudy->removeStudyFrame(it.data());
171 mySubGraphMap.clear();
173 QAD_StudyFrame* aSubGraph;
174 for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
175 aSubGraph->removeEventFilter(this);
180 if ( myLogFile != NULL) {
184 // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
185 notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
191 void SUPERVGUI_Main::filterNotification() {
192 Trace("SUPERVGUI_Main::filterNotification");
193 SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
194 dlg->setFiltered( myFiltered );
195 dlg->setLogged( myLogged, myLogFileName );
196 dlg->setWarning( myWarning );
197 dlg->setStep( myStep );
198 dlg->setTrace( myTrace );
199 dlg->setVerbose( myVerbose );
200 if ( dlg->exec() == QDialog::Accepted ) {
201 myLogged = dlg->getLogged();
202 myLogFileName = dlg->getLogFile();
203 myFiltered = dlg->getFiltered();
204 myWarning = dlg->getWarning();
205 myStep = dlg->getStep();
206 myTrace = dlg->getTrace();
207 myVerbose = dlg->getVerbose();
209 if ( myLogFile != NULL) {
213 if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
214 myLogFile = fopen( myLogFileName.latin1(), "a" );
215 if ( myLogFile == NULL ) {
217 QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
223 void SUPERVGUI_Main::syncAsync() {
224 Trace("SUPERVGUI_Main::syncAsync");
225 QTimer::singleShot(1, this, SLOT(sync()));
230 * Called by thread when dataflow is executing
232 void SUPERVGUI_Main::execute( char * theNodeName, SUPERV::GraphState theNodeState ) {
233 if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
234 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");
241 if (aNode) aNode->sync();
244 // asv : 26.01.05 : Bug PAL7164 : puting out-value to study if the "put_to_Study" flag is set on a
245 // CanvasPort the functionality was moved from SUPERVGUI_CanvasPortOut::sync() method please, see
246 // comment in that method for details.
247 if ( theNodeState == SUPERV::DoneState ) {
248 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
250 //cout << " *** theNode " << theNodeName << " received DONE_STATE *** " << endl;
251 SUPERVGUI_CanvasPortOut* aPortOut;
252 QObjectList* aPortList = aNode->queryList("SUPERVGUI_CanvasPortOut");
253 QObjectListIt aPortIt(*aPortList);
254 while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) {
256 if ( aPortOut->isInStudy() && aPortOut->getEngine()->State() == SUPERV::ReadyState ) {
257 //cout << " *** " << theNodeName << "[" << aPortOut->name() << "]--> goes into study *** " << endl;
258 putDataStudy( aPortOut->getEngine(), STUDY_PORT_OUT );
263 //else //normal case if Node is not found is when node is a graph! it can receive DoneState as well!
264 // MESSAGE( "ERROR in SUPERVGUI_Main::execute() : CanvasNode \"" << theNodeName << "\" NOT FOUND in myCanvas" );
269 void SUPERVGUI_Main::sync() {
270 Trace("SUPERVGUI_Main::sync");
271 if ((SUPERV_isNull(dataflow)))
273 QString t = tr("GRAPH_TITLE");
275 t += dataflow->Name();
278 study->updateObjBrowser();
279 if (myCurrentView == CANVASTABLE) {
288 void SUPERVGUI_Main::showCanvasTable() {
289 if (myCurrentView == CANVASTABLE)
292 if (myArray->create()) {
293 myCanvasView->hide();
295 myCurrentView = CANVASTABLE;
300 void SUPERVGUI_Main::showContolFlow() {
302 if (myCurrentView == CANVASTABLE) {
307 myCurrentView = CONTROLFLOW;
308 myCanvas->setControlView();
311 myCanvasView->show();
315 void SUPERVGUI_Main::showCanvas() {
316 if (myCurrentView == CANVAS)
320 if (myCurrentView == CANVASTABLE) {
325 myCurrentView = CANVAS;
326 myCanvas->setFullView();
329 myCanvasView->show();
333 void SUPERVGUI_Main::insertFile() {
334 Trace("SUPERVGUI_Main::insertFile");
335 if ((SUPERV_isNull(dataflow))) return;
337 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
339 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
342 tr("MSG_GRAPH_INSERT"),
345 if (dataflow->Import(f.latin1())) {
346 if (myCurrentView == CANVASTABLE) {
350 else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
355 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
360 void SUPERVGUI_Main::copy() {
361 Trace("SUPERVGUI_Main::copy");
362 if (dataflow->ThreadsMax() == 0) {
363 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
366 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
367 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
368 (aStudyFrame->getRightFrame()->getViewFrame());
370 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
371 if (dataflow->IsStreamGraph()) {
372 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
373 if (SUPERV_isNull(aSGraph)) {
374 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
377 aNewGraph = aSGraph->StreamCopy();
380 aNewGraph = dataflow->Copy();
382 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
383 aNewName += dataflow->Name();
384 aNewGraph->SetName(aNewName);
385 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
386 Supervision.getDesktop(),
388 study->showFrame(aStudyFrame);
392 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
394 if (theNode->IsMacro()) {
395 // get SubGraph from MacroNode
396 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
398 if (aMacro->IsStreamMacro())
399 aGraph = aMacro->StreamObjRef();
401 aGraph = aMacro->FlowObjRef();
404 if (SUPERV_isNull(aGraph)) {
405 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
409 QString aGraphName = aGraph->Name();
410 QAD_StudyFrame* aStudyFrame;
411 if (mySubGraphs.contains(aGraphName)) {
412 aStudyFrame = mySubGraphs[aGraphName];
413 aStudyFrame->setActiveWindow();
414 aStudyFrame->setFocus();
417 aStudyFrame = Supervision.createGraph();
419 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
420 (aStudyFrame->getRightFrame()->getViewFrame());
422 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
423 Supervision.getDesktop(),
425 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
426 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
427 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
428 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
429 aStudyFrame->installEventFilter(this);
431 mySubGraphs.insert(aGraphName, aStudyFrame);
432 mySubGraphMap.insert(aGraphName, theNode->Name());
437 study->showFrame(aStudyFrame);
438 if (!correct) myLastGraph = aStudyFrame;
443 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
445 // workaround to get close event
446 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
447 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
448 onSubGraphClosed(aFrame);
450 return SUPERVGraph_View::eventFilter(o, e);
453 // workaround to fix PAL6255 -> opened SubGraph is not on top
454 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
457 QAD_StudyFrame* aFrame = myLastGraph;
459 aFrame->setActiveWindow();
464 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
466 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
467 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
468 theStudyFrame->removeEventFilter(this);
469 disconnect(theStudyFrame, 0, this, 0);
471 SUPERVGraph_View* view = supervFrame->getViewWidget();
472 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
474 QString aGraphName = aGraph->getDataflow()->Name();
475 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
476 if (it != mySubGraphMap.end()) {
477 QString aNodeName = it.data();
478 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
479 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
484 mySubGraphMap.remove(it);
486 mySubGraphs.remove(aGraphName);
491 void SUPERVGUI_Main::run() {
492 Trace("SUPERVGUI_Main::run");
493 if ((SUPERV_isNull(dataflow))) return;
495 if (dataflow->IsEditing()) {
496 if (!dataflow->IsValid()) {
497 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
499 else if (!dataflow->IsExecutable()) {
500 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
502 else if (myCanvasView->isAnyLinkCreating()) {
503 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
506 myRunTime = QDateTime::currentDateTime();
507 if ( !dataflow->Run() ) {
508 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
509 if ( dataflow->State() == SUPERV::ErrorState ) {
514 myThread->startThread(tr("MSG_GRAPH_STARTED"));
519 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
525 void SUPERVGUI_Main::startExecute() {
526 Trace("SUPERVGUI_Main::startExecute");
527 if ((SUPERV_isNull(dataflow))) return;
529 if (dataflow->IsEditing()) {
530 if (!dataflow->IsValid()) {
531 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
533 else if (!dataflow->IsExecutable()) {
534 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
536 else if (myCanvasView->isAnyLinkCreating()) {
537 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
540 myRunTime = QDateTime::currentDateTime();
541 if (!dataflow->Start()) {
542 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
545 myThread->startThread(tr("MSG_GRAPH_STARTED"));
550 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
555 void SUPERVGUI_Main::kill() {
556 Trace("SUPERVGUI_Main::kill");
557 if ((SUPERV_isNull(dataflow)))
560 if (dataflow->IsEditing()) {
561 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
563 else if (dataflow->Kill()) {
564 myThread->stopThread(tr("MSG_GRAPH_KILLED"));
568 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
572 void SUPERVGUI_Main::suspendResume() {
573 Trace("SUPERVGUI_Main::suspendResume");
574 if ((SUPERV_isNull(dataflow))) return;
576 if (dataflow->IsEditing()) {
577 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
578 } else if (dataflow->State() == SUPERV_Suspend) {
579 if (dataflow->Resume()) {
580 myThread->startThread(tr("MSG_DF_RESUMED"));
582 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
585 if (dataflow->Suspend()) {
587 myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
589 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
593 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
594 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
595 It also calls deprecated method of Engine: ReStart().
596 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
597 Trace("SUPERVGUI_Main::stopRestart");
598 if ((SUPERV_isNull(dataflow))) return;
600 if (dataflow->IsEditing()) {
601 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
602 } else if (dataflow->State() == SUPERV_Stop) {
603 if (dataflow->ReStart()) {
604 message->setMessage(tr("MSG_DF_RESTARTED"));
607 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
610 if (dataflow->Stop()) {
613 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
618 void SUPERVGUI_Main::addNode() {
619 Trace("SUPERVGUI_Main::addNode");
620 if (SUPERV_isNull(dataflow)) return;
622 if (dataflow->IsExecuting()) {
623 if (QMessageBox::warning(QAD_Application::getDesktop(),
624 tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
625 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
632 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
634 Supervision.getBrowser()->choose();
638 * Add Computation node
640 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
641 switch (myCurrentView) {
649 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
650 aNode->move(theNode->X(), theNode->Y());
651 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
662 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
663 switch (myCurrentView) {
671 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
672 aNode->move(theNode->X(), theNode->Y());
673 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
684 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
685 switch (myCurrentView) {
693 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
694 aStartNode->move(theStartNode->X(), theStartNode->Y());
695 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
697 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
698 aEndNode->move(theEndNode->X(), theEndNode->Y());
699 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
713 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
714 switch (myCurrentView) {
722 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
723 aNode->move(theNode->X(), theNode->Y());
724 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
732 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
733 Trace("SUPERVGUI_Main::getCanvasArray");
737 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
738 Trace("SUPERVGUI_Main::getArrayView");
742 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
743 Trace("SUPERVGUI_Main::getCanvas");
747 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
748 Trace("SUPERVGUI_Main::getCanvasView");
749 return(myCanvasView);
752 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
753 Trace("SUPERVGUI_Main::getDataflow");
757 QAD_Message* SUPERVGUI_Main::getMessage() {
758 Trace("SUPERVGUI_Main::getMessage");
762 QAD_Study* SUPERVGUI_Main::getStudy() {
763 Trace("SUPERVGUI_Main::getStudy");
767 bool SUPERVGUI_Main::isArrayShown() {
768 Trace("SUPERVGUI_Main::isArrayShown");
769 return(myCurrentView == CANVASTABLE);
772 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
773 Trace("SUPERVGUI_Main::showPopup");
774 // To check is Supervision active?
775 if (myIsLocked) return;
776 //if (dataflow->IsExecuting()) return;
778 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
779 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
782 if (e->button() == RightButton) {
783 p->exec(e->globalPos());
789 void SUPERVGUI_Main::changeInformation() {
790 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
796 // returns false, if can't add dataflow into the study
797 bool SUPERVGUI_Main::addStudy() {
798 Trace("SUPERVGUI_Main::addStudy");
799 if (myIsFromStudy) return false;
800 if ((SUPERV_isNull(dataflow))) return false;
802 SALOMEDS::Study_var aStudy = study->getStudyDocument();
803 bool aLocked = aStudy->GetProperties()->IsLocked();
804 // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
809 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
810 SALOMEDS::GenericAttribute_var anAttr;
811 SALOMEDS::AttributeName_var aName;
812 SALOMEDS::AttributeIOR_var anIORAttr;
813 SALOMEDS::AttributePixMap_var aPixmap;
814 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
816 // searching dataflow
817 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
818 if (aSO->_is_nil()) { // create new dataflow SObject
819 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
820 if (aComponent->_is_nil()) { // is supervision component not found, then create it
821 QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
822 anOperation->start();
823 //if (aLocked) aStudy->GetProperties()->SetLocked(false);
824 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
825 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
826 aName = SALOMEDS::AttributeName::_narrow(anAttr);
827 //aName->SetValue(STUDY_SUPERVISION);
828 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
829 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
830 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
831 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
832 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
833 //if (aLocked) aStudy->GetProperties()->SetLocked(true);
834 anOperation->finish();
837 aSO = aBuilder->NewObject(aComponent);
838 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
839 aName = SALOMEDS::AttributeName::_narrow(anAttr);
840 aName->SetValue(dataflow->Name());
841 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
842 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
843 anIORAttr->SetValue(dataflow->getIOR());
845 //if (aLocked) return false;
849 Supervision.unregisterGraph(this);
850 Supervision.registerGraph(dataflow->getIOR(), this);
851 myIsFromStudy = true;
856 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
857 Trace("SUPERVGUI_Main::chooseData");
859 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
861 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
862 SALOMEDS::GenericAttribute_var anAttr;
863 SALOMEDS::AttributeIOR_var anIOR;
864 Standard_CString ior = "";
865 if (object->FindAttribute(anAttr, "AttributeIOR")) {
866 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
867 ior = anIOR->Value();
869 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
870 // should be replaced with some analogious code... selection of IOR was done -
871 // put its value into port.
872 //portIn->setValue(ior);
876 setCursor(Supervision.getCursor());
877 objectBrowser->setCursor(Supervision.getCursor());
878 Supervision.putInfo("");
884 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
885 const SALOMEDS::SObject_var theSO,
887 //QAD_Operation* theOperation,
889 SALOMEDS::SObject_var aResult;
890 SALOMEDS::AttributeName_var aName;
891 SALOMEDS::GenericAttribute_var anAttr;
892 if (!*theStarted) { // optimisation
893 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
894 for (; anIterator->More(); anIterator->Next()) {
895 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
896 aName = SALOMEDS::AttributeName::_narrow(anAttr);
897 if (strcmp(aName->Value(), theName) == 0) {
898 aResult = anIterator->Value();
904 if (!aResult->_is_nil()) return aResult;
906 SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
909 //theOperation->start();
910 aBuilder->NewCommand();
912 aResult = aBuilder->NewObject(theSO);
913 anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
914 aName = SALOMEDS::AttributeName::_narrow(anAttr);
915 aName->SetValue(theName);
919 bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) {
920 Trace("SUPERVGUI_Main::putDataStudy");
922 // static variable to ensure that only one instance (thread) is executing this function
923 static bool isIn = false;
929 SALOMEDS::Study_var aStudy = study->getStudyDocument();
930 bool aLocked = aStudy->GetProperties()->IsLocked();
931 // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
938 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
939 SALOMEDS::GenericAttribute_var anAttr;
940 SALOMEDS::AttributeName_var aName;
941 SALOMEDS::AttributeIOR_var anIORAttr;
942 SALOMEDS::AttributePixMap_var aPixmap;
943 bool aTransaction = false;
945 // searching dataflow
946 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
947 if (aSO->_is_nil()) { // create new dataflow SObject
948 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
949 if (aComponent->_is_nil()) { // is supervision component not found, then create it
950 aBuilder->NewCommand();
951 //if (aLocked) aStudy->GetProperties()->SetLocked(false);
952 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
953 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
954 aName = SALOMEDS::AttributeName::_narrow(anAttr);
955 //aName->SetValue(STUDY_SUPERVISION);
956 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
958 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
959 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
960 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
961 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
962 //if (aLocked) aStudy->GetProperties()->SetLocked(true);
963 aBuilder->CommitCommand();
966 aBuilder->NewCommand();
967 aSO = aBuilder->NewObject(aComponent);
968 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
969 aName = SALOMEDS::AttributeName::_narrow(anAttr);
970 aName->SetValue(dataflow->Name());
971 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
972 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
973 anIORAttr->SetValue(dataflow->getIOR());
976 aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO
977 QString("Run ") + myRunTime.toString(), &aTransaction);
978 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name(), &aTransaction); // get node SO
979 aSO = SearchOrCreateSOWithName(aStudy, aSO, inout, &aTransaction); // get in/out SO
980 aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name(), &aTransaction); // get port SO
982 if (aTransaction) aBuilder->CommitCommand();
984 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
985 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
986 if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) {
990 // set object value to the study: if object is external, then put it with
991 // help of the specific component - owner
993 // get according component driver for result object
994 SALOME_LifeCycleCORBA aLCC(myNService);
995 SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
996 if (!aFNode->_is_nil()) {
997 Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
998 aFNode->GetComponentName());
999 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
1000 if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
1001 CORBA::Object_ptr anObject = new CORBA::Object();
1002 CORBA::Any* anAny = p->ToAny();
1003 (*anAny) >>= anObject;
1005 if (aDriver->CanPublishInStudy(anObject)) {
1006 SALOMEDS::SObject_var aTmpSO;
1007 if (!aTransaction) {
1009 aTransaction = true;
1010 aBuilder->NewCommand();
1012 aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, /*anObject->Name()*/"");
1013 aBuilder->Addreference(aSO, aTmpSO);
1014 } else { // can't publish object: abort transaction
1015 if (aTransaction) aBuilder->AbortCommand();
1019 } else { // component has no drivel, but could store IORs (like Calculator)
1020 SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR(p->ToString());
1021 if (!CORBA::is_nil(anIORSO)) aBuilder->Addreference(aSO, anIORSO);
1025 if (!aTransaction) {
1026 aTransaction = true;
1027 aBuilder->NewCommand();
1029 anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
1033 aBuilder->CommitCommand();
1034 if (!myThread->running())
1035 study->updateObjBrowser();
1041 void SUPERVGUI_Main::ActivatePanning()
1043 if (myCanvasView->isVisible()) {
1044 myCanvasView->ActivatePanning();
1045 } else if (myArrayView->isVisible()) {
1046 myArrayView->ActivatePanning();
1051 void SUPERVGUI_Main::ResetView()
1053 if (myCanvasView->isVisible()) {
1054 myCanvasView->ResetView();
1055 } else if (myArrayView->isVisible()) {
1056 myArrayView->ResetView();
1061 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1062 myIsFromStudy = theToStudy;
1063 myCanvas->setAsFromStudy(theToStudy);
1066 void SUPERVGUI_Main::checkIsInStudy() {
1067 if (!myIsFromStudy) return;
1069 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1070 SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1071 SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1072 SALOMEDS::SObject_var aDataflowLbl;
1073 SALOMEDS::GenericAttribute_var anAttr;
1075 for (; aChildIterator->More(); aChildIterator->Next()) {
1076 aDataflowLbl = aChildIterator->Value();
1077 if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1080 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1081 if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1083 // This Graph considered as in study but in study it is not exists
1084 Supervision.unregisterGraph(this);
1085 setAsFromStudy(false);
1088 void SUPERVGUI_Main::syncNotification() {
1098 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1099 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1101 mess += "NOTIF: "; mess += graph;
1102 mess += " / " ; mess += node;
1103 mess += " / " ; mess += type;
1104 mess += " / " ; mess += message;
1105 getMessage()->setMessage(mess.latin1());
1110 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1111 char* sender, long counter, char* date, long stamp) {
1112 Trace("SUPERVGUI_Main::isFiltered");
1114 if (strcmp(getDataflow()->Name(), graph) == 0) {
1115 SUPERVGUI_CanvasNode* n;
1116 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1117 QObjectListIt i(*nodes);
1118 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1120 if (strcmp(n->name(), node) == 0) {
1121 if (strcmp(type, NOTIF_WARNING) == 0) {
1123 } else if (strcmp(type, NOTIF_STEP) == 0) {
1125 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1127 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1134 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1135 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 );
1136 fflush( myLogFile );
1142 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1147 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1149 myCanvas->setBackgroundColor(color);
1150 myCanvasView->setPaletteBackgroundColor(color.light());
1151 myArray->setBackgroundColor(color);
1152 myArrayView->setPaletteBackgroundColor(color.light());
1154 SUPERVGraph_View::setPaletteBackgroundColor(color);
1157 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1158 return myEventNodes;
1161 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1162 myEventNodes = theEventNodes;
1165 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1169 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1170 myStates = theStates;
1173 int SUPERVGUI_Main::getNodesNumber() {
1174 //create a list of nodes of the graph
1175 SUPERV_Nodes nodes = getDataflow()->Nodes();
1176 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1177 nodes->INodes.length() + nodes->GNodes.length() +
1178 nodes->LNodes.length() + nodes->SNodes.length();
1182 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1186 void SUPERVGUI_Main::startTimer() {
1187 myTimer->start(500);
1190 void SUPERVGUI_Main::executionFinished() {
1191 getStudy()->updateObjBrowser();
1196 void SUPERVGUI_Main::checkExecution() {
1197 if (myThread->finished()) {
1199 executionFinished();
1204 * Editing() is to be called by any operation in GUI before modification of a datamodel
1205 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1206 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1207 * are taken from Executor data model. But when user starts editing the graph - these changes must
1208 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1210 void SUPERVGUI_Main::Editing() {
1211 if ( !SUPERV_isNull( dataflow ) )
1212 dataflow->Editing();
1214 // updata GUI, Nodes' statuses and Ports' values could change.
1218 void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
1220 // mkr: since the deletion of the node allow only in CANVAS view,
1221 // it is necessary to remove the CanvasArray's children, which
1222 // have the same CNode engine as deleting node. This CNode is given
1225 const QObjectList* aChList = myArray->children();
1226 QObjectListIt aItChList(*aChList);
1227 SUPERVGUI_CanvasNode* anObjNode;
1228 while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
1230 if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
1231 myArray->removeChild(anObjNode);
1238 /******************************* SUPERVGUI_Thread class ****************************************/
1239 SUPERVGUI_Thread::SUPERVGUI_Thread()
1245 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1247 //it is a virtual destructor and needs to be determine here
1250 void SUPERVGUI_Thread::startThread(const char* m)
1256 myMain->getMessage()->setMessage(m);
1261 void SUPERVGUI_Thread::stopThread(const char* m)
1263 myMain->getMessage()->setMessage(m);
1266 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1271 void SUPERVGUI_Thread::KillThread(bool theValue)
1274 myIsActive = !(theValue);
1278 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1280 void SUPERVGUI_Thread::run()
1282 SUPERV_CNode aNode = NULL;
1283 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1284 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1286 SUPERV_CNode aPrevNode = NULL;
1287 SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1288 SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1293 QPtrList< char * > anEventNodes;
1294 QPtrList< SUPERV::GraphState > aStates;
1296 myMain->startTimer();
1298 myMain->myGUIEventLoopFinished = false;
1301 myMain->getDataflow()->Event(aNode, aEvent, aState);
1303 if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1305 aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1307 aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1309 if (myMain->getEventNodes().count()) {
1310 myMain->removeEventNodes();
1312 if (myMain->getStates().count()) {
1313 myMain->removeStates();
1318 if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1319 aName = aNode->Name();
1322 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
1323 anEventNodes = myMain->getEventNodes();
1324 anEventNodes.append( &aName ) ;
1325 myMain->setEventNodes(anEventNodes);
1327 aStates = myMain->getStates();
1328 aStates.append( &aState ) ;
1329 myMain->setStates(aStates);
1332 if ( aEvent == aPrevEvent && aState == aPrevState) {
1333 QString aNameStr = aName;
1334 QString aPrevNameStr = aPrevName;
1335 if ( aNameStr != aPrevNameStr ) {
1336 anEventNodes = myMain->getEventNodes();
1337 anEventNodes.append( &aName ) ;
1338 myMain->setEventNodes(anEventNodes);
1340 aStates = myMain->getStates();
1341 aStates.append( &aState ) ;
1342 myMain->setStates(aStates);
1346 anEventNodes = myMain->getEventNodes();
1347 anEventNodes.append( &aName ) ;
1348 myMain->setEventNodes(anEventNodes);
1350 aStates = myMain->getStates();
1351 aStates.append( &aState ) ;
1352 myMain->setStates(aStates);
1357 switch (myMain->getDataflow()->State()) {
1358 case SUPERV_Editing :
1359 stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1362 case SUPERV_Suspend :
1363 stopThread(tr("MSG_GRAPH_SUSPENDED"));
1367 stopThread(tr("MSG_GRAPH_FINISHED"));
1371 stopThread(tr("MSG_GRAPH_ABORTED"));
1375 stopThread(tr("MSG_GRAPH_KILLED"));
1381 if ( myMain->getEventNodes().count() ) {
1382 //if list not empty call execute() -> sync()
1383 char * aNodeName = *(myMain->getEventNodes().getFirst());
1384 SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1386 // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1387 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1389 myMain->removeFirstEN();
1390 myMain->removeFirstS();
1394 aPrevEvent = aEvent;
1395 aPrevState = aState;
1397 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
1400 aPrevName = aPrevNode->Name();
1405 // VSR: 04/12/03 ---> update object browser ufter finishing
1407 // myMain->getStudy()->updateObjBrowser();
1409 // VSR: 04/12/03 <---
1411 myMain->myGUIEventLoopFinished = true;
1416 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1420 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1421 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1423 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1424 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1425 setSizeGripEnabled( true );
1428 QGridLayout* TopLayout = new QGridLayout( this );
1429 TopLayout->setSpacing( 6 );
1430 TopLayout->setMargin( 11 );
1432 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1433 TopGroup->setColumnLayout(0, Qt::Vertical );
1434 TopGroup->layout()->setSpacing( 0 );
1435 TopGroup->layout()->setMargin( 0 );
1436 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1437 TopGroupLayout->setAlignment( Qt::AlignTop );
1438 TopGroupLayout->setSpacing( 6 );
1439 TopGroupLayout->setMargin( 11 );
1442 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1443 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1445 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1446 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1447 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1450 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1451 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1453 myTimeOut = new QLineEdit( TopGroup );
1454 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1455 myTimeOut->setValidator( new QIntValidator(this) );
1456 myTimeOut->setMinimumSize( 100, 0 );
1457 myTimeOut->setReadOnly( isReadOnly );
1458 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1461 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1462 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1464 myDataStreamTrace = new QComboBox( TopGroup );
1465 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1466 myDataStreamTrace->insertItem("WithoutTrace");
1467 myDataStreamTrace->insertItem("SummaryTrace");
1468 myDataStreamTrace->insertItem("DetailedTrace");
1469 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1471 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1472 GroupButtons->setColumnLayout(0, Qt::Vertical );
1473 GroupButtons->layout()->setSpacing( 0 );
1474 GroupButtons->layout()->setMargin( 0 );
1475 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1476 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1477 GroupButtonsLayout->setSpacing( 6 );
1478 GroupButtonsLayout->setMargin( 11 );
1480 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1481 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1483 GroupButtonsLayout->addWidget( okB, 0, 0 );
1484 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1485 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1487 TopLayout->addWidget( TopGroup, 0, 0 );
1488 TopLayout->addWidget( GroupButtons, 1, 0 );
1490 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1491 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1499 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1500 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1506 void SUPERVGUI_DSGraphParameters::setData() {
1509 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1511 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1512 if (myGraph->IsStreamGraph()) {
1513 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1514 if (!SUPERV_isNull(aSGraph))
1515 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1518 myDeltaTime->setValue(aDeltaTime);
1519 myTimeOut->setText(QString("%1").arg(aTimeOut));
1520 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1526 void SUPERVGUI_DSGraphParameters::accept() {
1527 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1528 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1529 // myDeltaTime->value());
1530 if (myGraph->IsStreamGraph()) {
1531 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1532 if (!SUPERV_isNull(aSGraph))
1533 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1534 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1535 myDeltaTime->value());