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");
240 else if (myCurrentView == CANVASTABLE) {
241 SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
242 if (aNode) aNode->sync();
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");
336 if ((SUPERV_isNull(dataflow))) return;
338 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
340 QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
343 tr("MSG_GRAPH_INSERT"),
346 if (dataflow->Import(f.latin1())) {
347 if (myCurrentView == CANVASTABLE) {
351 else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
356 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
361 void SUPERVGUI_Main::copy() {
362 Trace("SUPERVGUI_Main::copy");
363 if (dataflow->ThreadsMax() == 0) {
364 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
367 QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
368 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
369 (aStudyFrame->getRightFrame()->getViewFrame());
371 SUPERV_Graph aNewGraph; // = dataflow->StreamCopy();
372 if (dataflow->IsStreamGraph()) {
373 SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
374 if (SUPERV_isNull(aSGraph)) {
375 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
378 aNewGraph = aSGraph->StreamCopy();
381 aNewGraph = dataflow->Copy();
383 QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
384 aNewName += dataflow->Name();
385 aNewGraph->SetName(aNewName);
386 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
387 Supervision.getDesktop(),
389 study->showFrame(aStudyFrame);
393 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
395 if (theNode->IsMacro()) {
396 // get SubGraph from MacroNode
397 SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
399 if (aMacro->IsStreamMacro())
400 aGraph = aMacro->StreamObjRef();
402 aGraph = aMacro->FlowObjRef();
405 if (SUPERV_isNull(aGraph)) {
406 QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
410 QString aGraphName = aGraph->Name();
411 QAD_StudyFrame* aStudyFrame;
412 if (mySubGraphs.contains(aGraphName)) {
413 aStudyFrame = mySubGraphs[aGraphName];
414 aStudyFrame->setActiveWindow();
415 aStudyFrame->setFocus();
418 aStudyFrame = Supervision.createGraph();
420 SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
421 (aStudyFrame->getRightFrame()->getViewFrame());
423 /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame,
424 Supervision.getDesktop(),
426 // connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)),
427 // this, SLOT(onSubGraphClosed(QAD_StudyFrame*)));
428 connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)),
429 this, SLOT(onSubGraphActivated(QAD_StudyFrame*)));
430 aStudyFrame->installEventFilter(this);
432 mySubGraphs.insert(aGraphName, aStudyFrame);
433 mySubGraphMap.insert(aGraphName, theNode->Name());
438 study->showFrame(aStudyFrame);
439 if (!correct) myLastGraph = aStudyFrame;
444 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
446 // workaround to get close event
447 if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
448 QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
449 onSubGraphClosed(aFrame);
451 return SUPERVGraph_View::eventFilter(o, e);
454 // workaround to fix PAL6255 -> opened SubGraph is not on top
455 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
458 QAD_StudyFrame* aFrame = myLastGraph;
460 aFrame->setActiveWindow();
465 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
467 QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
468 if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
469 theStudyFrame->removeEventFilter(this);
470 disconnect(theStudyFrame, 0, this, 0);
472 SUPERVGraph_View* view = supervFrame->getViewWidget();
473 SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
475 QString aGraphName = aGraph->getDataflow()->Name();
476 QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
477 if (it != mySubGraphMap.end()) {
478 QString aNodeName = it.data();
479 SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)
480 myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
485 mySubGraphMap.remove(it);
487 mySubGraphs.remove(aGraphName);
492 void SUPERVGUI_Main::run( const bool andSuspend ) {
493 Trace("SUPERVGUI_Main::run");
494 if ( SUPERV_isNull(dataflow) )
497 if ( dataflow->IsEditing() ) { // not currently Executing
499 // asv 31.01.05 : fix for PAL7854, Editing moved from SUPERVGUI.cxx runDataflow(), stepByStep() to here..
500 Editing(); // remove old executor, update GUI (all nodes to "No Status")
502 if ( !dataflow->IsValid() ) {
503 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
505 else if (!dataflow->IsExecutable()) {
506 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
508 else if (myCanvasView->isAnyLinkCreating()) {
509 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
512 myRunTime = QDateTime::currentDateTime();
513 const bool result = andSuspend ? dataflow->Start() : dataflow->Run();
515 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
516 if ( dataflow->State() == SUPERV::ErrorState ) {
521 myExecuted = true; // set to true on first execution. for correct publishing in Study
522 myThread->startThread(tr("MSG_GRAPH_STARTED"));
527 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
532 void SUPERVGUI_Main::kill() {
533 Trace("SUPERVGUI_Main::kill");
534 if ((SUPERV_isNull(dataflow)))
537 if (dataflow->IsEditing()) {
538 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
540 else if (dataflow->Kill()) {
541 myThread->stopThread(tr("MSG_GRAPH_KILLED"));
545 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
549 void SUPERVGUI_Main::suspendResume() {
550 Trace("SUPERVGUI_Main::suspendResume");
551 if ((SUPERV_isNull(dataflow))) return;
553 if (dataflow->IsEditing()) {
554 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
555 } else if (dataflow->State() == SUPERV_Suspend) {
556 if (dataflow->Resume()) {
557 myThread->startThread(tr("MSG_DF_RESUMED"));
559 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
562 if (dataflow->Suspend()) {
564 myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
566 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
570 /* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere,
571 the comment from kloss below may be explaining it, but it's in French and I do not understand it..
572 It also calls deprecated method of Engine: ReStart().
573 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
574 Trace("SUPERVGUI_Main::stopRestart");
575 if ((SUPERV_isNull(dataflow))) return;
577 if (dataflow->IsEditing()) {
578 QMessageBox::warning(0, tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
579 } else if (dataflow->State() == SUPERV_Stop) {
580 if (dataflow->ReStart()) {
581 message->setMessage(tr("MSG_DF_RESTARTED"));
584 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
587 if (dataflow->Stop()) {
590 QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
595 void SUPERVGUI_Main::addNode() {
596 Trace("SUPERVGUI_Main::addNode");
597 bool error = SUPERV_isNull( dataflow );
601 if ( dataflow->IsExecuting() ) {
602 error = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No
603 tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_NO" ), 0, 1, 0 );
604 if ( error ) // user selected NOT to kill dataflow and NOT to add new node
606 else // user selected to kill the dataflow and add new node after that
610 Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
612 Supervision.getBrowser()->choose();
616 * Add Computation node
618 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
619 switch (myCurrentView) {
627 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
628 aNode->move(theNode->X(), theNode->Y());
629 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
640 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
641 switch (myCurrentView) {
649 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
650 aNode->move(theNode->X(), theNode->Y());
651 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
662 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
663 switch (myCurrentView) {
671 SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
672 aStartNode->move(theStartNode->X(), theStartNode->Y());
673 if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
675 SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
676 aEndNode->move(theEndNode->X(), theEndNode->Y());
677 if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
691 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
692 switch (myCurrentView) {
700 SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
701 aNode->move(theNode->X(), theNode->Y());
702 if (myCurrentView == CONTROLFLOW) aNode->hideAll();
710 SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() {
711 Trace("SUPERVGUI_Main::getCanvasArray");
715 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
716 Trace("SUPERVGUI_Main::getArrayView");
720 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
721 Trace("SUPERVGUI_Main::getCanvas");
725 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
726 Trace("SUPERVGUI_Main::getCanvasView");
727 return(myCanvasView);
730 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
731 Trace("SUPERVGUI_Main::getDataflow");
735 QAD_Message* SUPERVGUI_Main::getMessage() {
736 Trace("SUPERVGUI_Main::getMessage");
740 QAD_Study* SUPERVGUI_Main::getStudy() {
741 Trace("SUPERVGUI_Main::getStudy");
745 bool SUPERVGUI_Main::isArrayShown() {
746 Trace("SUPERVGUI_Main::isArrayShown");
747 return(myCurrentView == CANVASTABLE);
750 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
751 Trace("SUPERVGUI_Main::showPopup");
752 // To check is Supervision active?
753 if (myIsLocked) return;
754 //if (dataflow->IsExecuting()) return;
756 //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
757 if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
760 if (e->button() == RightButton) {
761 p->exec(e->globalPos());
767 void SUPERVGUI_Main::changeInformation() {
768 SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
774 // returns false, if can't add dataflow into the study
775 bool SUPERVGUI_Main::addStudy() {
776 Trace("SUPERVGUI_Main::addStudy");
777 if (myIsFromStudy) return false;
778 if ((SUPERV_isNull(dataflow))) return false;
780 SALOMEDS::Study_var aStudy = study->getStudyDocument();
781 bool aLocked = aStudy->GetProperties()->IsLocked();
782 // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
787 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
788 SALOMEDS::GenericAttribute_var anAttr;
789 SALOMEDS::AttributeName_var aName;
790 SALOMEDS::AttributeIOR_var anIORAttr;
791 SALOMEDS::AttributePixMap_var aPixmap;
792 QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
794 // searching dataflow
795 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
796 if (aSO->_is_nil()) { // create new dataflow SObject
797 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
798 if (aComponent->_is_nil()) { // is supervision component not found, then create it
799 QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
800 anOperation->start();
801 //if (aLocked) aStudy->GetProperties()->SetLocked(false);
802 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
803 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
804 aName = SALOMEDS::AttributeName::_narrow(anAttr);
805 //aName->SetValue(STUDY_SUPERVISION);
806 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
807 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
808 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
809 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
810 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
811 //if (aLocked) aStudy->GetProperties()->SetLocked(true);
812 anOperation->finish();
815 aSO = aBuilder->NewObject(aComponent);
816 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
817 aName = SALOMEDS::AttributeName::_narrow(anAttr);
818 aName->SetValue(dataflow->Name());
819 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
820 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
821 anIORAttr->SetValue(dataflow->getIOR());
823 //if (aLocked) return false;
827 Supervision.unregisterGraph(this);
828 Supervision.registerGraph(dataflow->getIOR(), this);
829 myIsFromStudy = true;
834 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
835 Trace("SUPERVGUI_Main::chooseData");
837 QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
839 SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
840 SALOMEDS::GenericAttribute_var anAttr;
841 SALOMEDS::AttributeIOR_var anIOR;
842 Standard_CString ior = "";
843 if (object->FindAttribute(anAttr, "AttributeIOR")) {
844 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
845 ior = anIOR->Value();
847 // asv : 13.12.04 : commented out use of portIn field, but it seems that it
848 // should be replaced with some analogious code... selection of IOR was done -
849 // put its value into port.
850 //portIn->setValue(ior);
854 setCursor(Supervision.getCursor());
855 objectBrowser->setCursor(Supervision.getCursor());
856 Supervision.putInfo("");
862 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
863 const SALOMEDS::StudyBuilder_var theBuilder,
864 const SALOMEDS::SObject_var theSO,
866 bool* theDoneSomething ) {
867 SALOMEDS::SObject_var aResult;
868 SALOMEDS::AttributeName_var aName;
869 SALOMEDS::GenericAttribute_var anAttr;
870 SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
871 for (; anIterator->More(); anIterator->Next()) {
872 if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
873 aName = SALOMEDS::AttributeName::_narrow(anAttr);
874 if (strcmp(aName->Value(), theName) == 0) {
875 aResult = anIterator->Value();
881 // if aResule was found then theDoneSomething=false and we return
882 *theDoneSomething = aResult->_is_nil();
883 if ( !*theDoneSomething )
887 aResult = theBuilder->NewObject( theSO );
888 anAttr = theBuilder->FindOrCreateAttribute(aResult, "AttributeName");
889 aName = SALOMEDS::AttributeName::_narrow(anAttr);
890 aName->SetValue(theName);
894 bool SUPERVGUI_Main::putDataStudy( SUPERV_Port p, const char* inout ) {
895 Trace("SUPERVGUI_Main::putDataStudy");
897 // static variable to ensure that only one instance (thread) is executing this function
898 static bool isIn = false;
899 if (isIn) return true;
902 SALOMEDS::Study_var aStudy = study->getStudyDocument();
903 const bool aLocked = aStudy->GetProperties()->IsLocked();
904 SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
905 SALOMEDS::GenericAttribute_var anAttr;
906 SALOMEDS::AttributeName_var aName;
907 SALOMEDS::AttributeIOR_var anIORAttr;
908 SALOMEDS::AttributePixMap_var aPixmap;
909 bool aDoneSomething = false;
911 // asv 23.11.04 : fix for PAL6852 if the study is locked -- then we can't put anything in it.
913 MESSAGE( "The study is locked and can not be modified!" );
918 // open new command. Commit or Abort it depending on aDoneSomething variable or error
919 aBuilder->NewCommand();
921 // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
922 SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
923 if ( aSO->_is_nil() ) { // dataflow SObject not found in the study
924 aDoneSomething = true;
925 SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
926 if ( aComponent->_is_nil() ) { // is supervision component not found, then create it
927 aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
928 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
929 aName = SALOMEDS::AttributeName::_narrow(anAttr);
930 aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
932 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
933 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
934 aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
935 aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
937 // create dataflow SObject ("aNewDataflow_1")
938 aSO = aBuilder->NewObject(aComponent);
939 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
940 aName = SALOMEDS::AttributeName::_narrow(anAttr);
941 aName->SetValue(dataflow->Name());
942 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
943 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
944 anIORAttr->SetValue(dataflow->getIOR());
947 // Create "Run -> Time and date, etc." SObjects
948 if ( myExecuted ) { // if dataflow was executed at least once
949 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, QString("Run ") + myRunTime.toString(), &aDoneSomething ); // get run time SO
950 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Node()->Name(), &aDoneSomething ); // get node SO
951 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, inout, &aDoneSomething ); // get in/out SO
952 aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Name(), &aDoneSomething ); // get port SO
954 // create IOR attribute for port SObject (usually with "return" name)
955 anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
956 anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
958 // if we have not created anything (all SObject already existed) and we have the same IORAttribute
959 // on the needed SObject -> then don't do anything! it's already there!
960 if ( !aDoneSomething && strcmp(anIORAttr->Value(), p->ToString()) == 0 ) {
961 aBuilder->AbortCommand();
966 aDoneSomething = true; // going to set some value to anIORAttr any way from this point..
968 // set object value to the study: if object is external, then put it with
969 // help of the specific component - owner
971 // get according component driver for result object
972 SALOME_LifeCycleCORBA aLCC( myNService );
973 SUPERV_FNode aFNode = SUPERV::FNode::_narrow( p->Node() );
974 if ( !aFNode->_is_nil() ) {
975 Engines::Component_var aComponent = aLCC.FindOrLoad_Component( aFNode->GetContainer(), aFNode->GetComponentName() );
976 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow( aComponent );
977 if ( !CORBA::is_nil( aDriver ) ) { // if driver was found, publish object
978 CORBA::Object_ptr anObject = new CORBA::Object();
979 CORBA::Any* anAny = p->ToAny();
980 (*anAny) >>= anObject;
982 if ( aDriver->CanPublishInStudy( anObject ) ) {
983 SALOMEDS::SObject_var aTmpSO;// = aSO;
984 aTmpSO = aDriver->PublishInStudy( aStudy, aTmpSO, anObject, "" );
985 aBuilder->Addreference(aSO, aTmpSO);
987 else { // can't publish object: abort transaction
988 MESSAGE( "CanPublishInStudy() returned FALSE. ok, AbortCommand.." );
989 aBuilder->AbortCommand();
994 else { // component has no driver, but could store IORs (like Calculator)
995 SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR( p->ToString() );
996 if ( !CORBA::is_nil( anIORSO ) )
997 aBuilder->Addreference(aSO, anIORSO);
998 else { // Hm... the object (==port value) was not found, so we don't publish it.
999 MESSAGE( "The object (==port value) was not found, so we don't publish it" );
1000 aBuilder->AbortCommand();
1006 else { // FNode is NULL -> bad
1007 MESSAGE( "FNode is NULL. Not good at all. Aborting command." );
1008 aBuilder->AbortCommand();
1014 anIORAttr->SetValue( p->ToString() ); // ior attribute already set for the prevoius condition
1018 if ( aDoneSomething )
1019 aBuilder->CommitCommand();
1021 aBuilder->AbortCommand();
1023 if ( !myThread->running() )
1024 study->updateObjBrowser();
1031 void SUPERVGUI_Main::ActivatePanning()
1033 if (myCanvasView->isVisible()) {
1034 myCanvasView->ActivatePanning();
1035 } else if (myArrayView->isVisible()) {
1036 myArrayView->ActivatePanning();
1041 void SUPERVGUI_Main::ResetView()
1043 if (myCanvasView->isVisible()) {
1044 myCanvasView->ResetView();
1045 } else if (myArrayView->isVisible()) {
1046 myArrayView->ResetView();
1051 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1052 myIsFromStudy = theToStudy;
1053 myCanvas->setAsFromStudy(theToStudy);
1056 void SUPERVGUI_Main::checkIsInStudy() {
1057 if (!myIsFromStudy) return;
1059 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1060 SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1061 SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1062 SALOMEDS::SObject_var aDataflowLbl;
1063 SALOMEDS::GenericAttribute_var anAttr;
1065 for (; aChildIterator->More(); aChildIterator->Next()) {
1066 aDataflowLbl = aChildIterator->Value();
1067 if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1070 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1071 if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1073 // This Graph considered as in study but in study it is not exists
1074 Supervision.unregisterGraph(this);
1075 setAsFromStudy(false);
1078 void SUPERVGUI_Main::syncNotification() {
1088 while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1089 if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1091 mess += "NOTIF: "; mess += graph;
1092 mess += " / " ; mess += node;
1093 mess += " / " ; mess += type;
1094 mess += " / " ; mess += message;
1095 getMessage()->setMessage(mess.latin1());
1100 bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* message,
1101 char* sender, long counter, char* date, long stamp) {
1102 Trace("SUPERVGUI_Main::isFiltered");
1104 if (strcmp(getDataflow()->Name(), graph) == 0) {
1105 SUPERVGUI_CanvasNode* n;
1106 QObjectList* nodes = queryList("SUPERVGUI_CanvasNode");
1107 QObjectListIt i(*nodes);
1108 while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) {
1110 if (strcmp(n->name(), node) == 0) {
1111 if (strcmp(type, NOTIF_WARNING) == 0) {
1113 } else if (strcmp(type, NOTIF_STEP) == 0) {
1115 } else if (strcmp(type, NOTIF_TRACE) == 0) {
1117 } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1124 if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1125 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 );
1126 fflush( myLogFile );
1132 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1137 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) {
1139 myCanvas->setBackgroundColor(color);
1140 myCanvasView->setPaletteBackgroundColor(color.light());
1141 myArray->setBackgroundColor(color);
1142 myArrayView->setPaletteBackgroundColor(color.light());
1144 SUPERVGraph_View::setPaletteBackgroundColor(color);
1147 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1148 return myEventNodes;
1151 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1152 myEventNodes = theEventNodes;
1155 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1159 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1160 myStates = theStates;
1163 int SUPERVGUI_Main::getNodesNumber() {
1164 //create a list of nodes of the graph
1165 SUPERV_Nodes nodes = getDataflow()->Nodes();
1166 int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1167 nodes->INodes.length() + nodes->GNodes.length() +
1168 nodes->LNodes.length() + nodes->SNodes.length();
1172 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1176 void SUPERVGUI_Main::startTimer() {
1177 myTimer->start(500);
1180 void SUPERVGUI_Main::executionFinished() {
1181 getStudy()->updateObjBrowser();
1186 void SUPERVGUI_Main::checkExecution() {
1187 if (myThread->finished()) {
1189 executionFinished();
1194 * Editing() is to be called by any operation in GUI before modification of a datamodel
1195 * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models
1196 * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes
1197 * are taken from Executor data model. But when user starts editing the graph - these changes must
1198 * be applied to Editor data model. This function destroys Executor data model and moves to Editor.
1200 void SUPERVGUI_Main::Editing() {
1201 if ( !SUPERV_isNull( dataflow ) )
1202 dataflow->Editing();
1204 // updata GUI, Nodes' statuses and Ports' values could change.
1208 void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
1210 // mkr: since the deletion of the node allow only in CANVAS view,
1211 // it is necessary to remove the CanvasArray's children, which
1212 // have the same CNode engine as deleting node. This CNode is given
1215 const QObjectList* aChList = myArray->children();
1216 if ( aChList ) { // asv 27.01.05 : fix for 7817
1217 QObjectListIt aItChList(*aChList);
1218 SUPERVGUI_CanvasNode* anObjNode;
1219 while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) {
1221 if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) {
1222 myArray->removeChild(anObjNode);
1226 } // end of if ( ChList )
1230 /******************************* SUPERVGUI_Thread class ****************************************/
1231 SUPERVGUI_Thread::SUPERVGUI_Thread()
1237 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1239 //it is a virtual destructor and needs to be determine here
1242 void SUPERVGUI_Thread::startThread(const char* m)
1248 myMain->getMessage()->setMessage(m);
1253 void SUPERVGUI_Thread::stopThread(const char* m)
1255 myMain->getMessage()->setMessage(m);
1258 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1263 void SUPERVGUI_Thread::KillThread(bool theValue)
1266 myIsActive = !(theValue);
1270 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1272 void SUPERVGUI_Thread::run()
1274 SUPERV_CNode aNode = NULL;
1275 SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1276 SUPERV::GraphState aState = SUPERV::UndefinedState ;
1278 SUPERV_CNode aPrevNode = NULL;
1279 SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1280 SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1285 QPtrList< char * > anEventNodes;
1286 QPtrList< SUPERV::GraphState > aStates;
1288 myMain->startTimer();
1291 myMain->getDataflow()->Event(aNode, aEvent, aState);
1293 if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1295 aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1297 aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1299 if (myMain->getEventNodes().count()) {
1300 myMain->removeEventNodes();
1302 if (myMain->getStates().count()) {
1303 myMain->removeStates();
1308 if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1309 aName = aNode->Name();
1312 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) { //first initialize aPrev... variables
1313 anEventNodes = myMain->getEventNodes();
1314 anEventNodes.append( &aName ) ;
1315 myMain->setEventNodes(anEventNodes);
1317 aStates = myMain->getStates();
1318 aStates.append( &aState ) ;
1319 myMain->setStates(aStates);
1322 if ( aEvent == aPrevEvent && aState == aPrevState) {
1323 QString aNameStr = aName;
1324 QString aPrevNameStr = aPrevName;
1325 if ( aNameStr != aPrevNameStr ) {
1326 anEventNodes = myMain->getEventNodes();
1327 anEventNodes.append( &aName ) ;
1328 myMain->setEventNodes(anEventNodes);
1330 aStates = myMain->getStates();
1331 aStates.append( &aState ) ;
1332 myMain->setStates(aStates);
1336 anEventNodes = myMain->getEventNodes();
1337 anEventNodes.append( &aName ) ;
1338 myMain->setEventNodes(anEventNodes);
1340 aStates = myMain->getStates();
1341 aStates.append( &aState ) ;
1342 myMain->setStates(aStates);
1347 switch (myMain->getDataflow()->State()) {
1348 case SUPERV_Editing :
1349 stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1352 case SUPERV_Suspend :
1353 stopThread(tr("MSG_GRAPH_SUSPENDED"));
1357 stopThread(tr("MSG_GRAPH_FINISHED"));
1361 stopThread(tr("MSG_GRAPH_ABORTED"));
1365 stopThread(tr("MSG_GRAPH_KILLED"));
1371 if ( myMain->getEventNodes().count() ) {
1372 //if list not empty call execute() -> sync()
1373 char * aNodeName = *(myMain->getEventNodes().getFirst());
1374 SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1376 // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1377 ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1379 myMain->removeFirstEN();
1380 myMain->removeFirstS();
1384 aPrevEvent = aEvent;
1385 aPrevState = aState;
1387 if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) )
1390 aPrevName = aPrevNode->Name();
1395 // VSR: 04/12/03 ---> update object browser ufter finishing
1397 // myMain->getStudy()->updateObjBrowser();
1399 // VSR: 04/12/03 <---
1404 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1408 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1409 : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
1411 Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1412 setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1413 setSizeGripEnabled( true );
1416 QGridLayout* TopLayout = new QGridLayout( this );
1417 TopLayout->setSpacing( 6 );
1418 TopLayout->setMargin( 11 );
1420 QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1421 TopGroup->setColumnLayout(0, Qt::Vertical );
1422 TopGroup->layout()->setSpacing( 0 );
1423 TopGroup->layout()->setMargin( 0 );
1424 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1425 TopGroupLayout->setAlignment( Qt::AlignTop );
1426 TopGroupLayout->setSpacing( 6 );
1427 TopGroupLayout->setMargin( 11 );
1430 QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );
1431 TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1433 myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1434 myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1435 TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1438 QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup);
1439 TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1441 myTimeOut = new QLineEdit( TopGroup );
1442 myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1443 myTimeOut->setValidator( new QIntValidator(this) );
1444 myTimeOut->setMinimumSize( 100, 0 );
1445 myTimeOut->setReadOnly( isReadOnly );
1446 TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1449 QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup);
1450 TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1452 myDataStreamTrace = new QComboBox( TopGroup );
1453 myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1454 myDataStreamTrace->insertItem("WithoutTrace");
1455 myDataStreamTrace->insertItem("SummaryTrace");
1456 myDataStreamTrace->insertItem("DetailedTrace");
1457 TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1459 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1460 GroupButtons->setColumnLayout(0, Qt::Vertical );
1461 GroupButtons->layout()->setSpacing( 0 );
1462 GroupButtons->layout()->setMargin( 0 );
1463 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1464 GroupButtonsLayout->setAlignment( Qt::AlignTop );
1465 GroupButtonsLayout->setSpacing( 6 );
1466 GroupButtonsLayout->setMargin( 11 );
1468 QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons );
1469 QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1471 GroupButtonsLayout->addWidget( okB, 0, 0 );
1472 GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1473 GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1475 TopLayout->addWidget( TopGroup, 0, 0 );
1476 TopLayout->addWidget( GroupButtons, 1, 0 );
1478 connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) );
1479 connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1487 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1488 Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1494 void SUPERVGUI_DSGraphParameters::setData() {
1497 SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1499 // myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1500 if (myGraph->IsStreamGraph()) {
1501 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1502 if (!SUPERV_isNull(aSGraph))
1503 aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1506 myDeltaTime->setValue(aDeltaTime);
1507 myTimeOut->setText(QString("%1").arg(aTimeOut));
1508 myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1514 void SUPERVGUI_DSGraphParameters::accept() {
1515 // myGraph->SetStreamParams( myTimeOut->text().toLong(),
1516 // (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1517 // myDeltaTime->value());
1518 if (myGraph->IsStreamGraph()) {
1519 SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1520 if (!SUPERV_isNull(aSGraph))
1521 aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1522 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1523 myDeltaTime->value());