Salome HOME
Add functionality for Table view based on QCanvas.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Main.cxx
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SUPERVGUI_Main.cxx
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 using namespace std;
29 #include "QAD_Splitter.h"
30 #include "QAD_LeftFrame.h"
31 #include "QAD_ObjectBrowser.h"
32 #include "QAD_ObjectBrowserItem.h"
33 #include "QAD_PyEditor.h"
34 #include "QAD_Message.h"
35 #include "QAD_FileDlg.h"
36 #include "QAD_Application.h"
37 #include "SUPERVGUI_Def.h"
38 #include "QAD_RightFrame.h"
39 #include "SALOME_Event.hxx"
40 #include "SUPERVGraph_ViewFrame.h"
41 #include <qlayout.h>
42 #include <qfile.h>
43 #include "SUPERVGUI_Main.h"
44 #include "SUPERVGUI.h"
45 #include "SUPERVGUI_ComputeNode.h"
46 #include "SUPERVGUI_ControlNode.h"
47 #include "NOTIFICATION.hxx"
48 #include "SUPERVGUI_Notification.h"
49 #include "SALOMEGUI_ImportOperation.h"
50 #include "SUPERVGUI_Information.h"
51 #include "SUPERVGUI_CanvasControlNode.h"
52 #include <qvalidator.h>
53
54 /*
55 asv 20.10.04: removed 2 SUPERVGUI_Main constructors.  there is only ONE way 
56 to create a Main object now: with a non-null DataFlow as a 3d parameter
57 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool fromIOR)
58      : SUPERVGraph_View(theParent), 
59        myLogged( false ),
60        myFiltered( false ),
61        myLogFileName( QString::null ),
62        myLogFile( NULL ),
63        myWarning( false ),
64        myStep( false ),
65        myTrace( false ),
66        myVerbose( false )
67 {
68   Trace("SUPERVGUI_Main::SUPERVGUI_Main (new)");
69   theParent->setViewWidget(this); 
70   if (fromIOR) {
71     //SUPERVGUI_Main* am = Supervision.getMain();
72     QAD_ObjectBrowser* ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser();
73     //        if (am == 0) {
74     //  ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser();
75     //} else {
76     //ob = am->objectBrowser;
77     //}; 
78     QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)(ob->getListView()->currentItem());
79     SALOMEDS::SObject_var obj = theDesktop->getActiveStudy()->getStudyDocument()->FindObjectID(item->getEntry().latin1());
80     SALOMEDS::GenericAttribute_var anAttr;
81     if (obj->FindAttribute(anAttr, "AttributeIOR")) {
82       SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
83       Standard_CString ior = anIOR->Value();
84       dataflow = Supervision.getEngine()->getStreamGraph(ior);
85       if (SUPERV_isNull(dataflow)) {
86         QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
87         close();
88       } else {
89         init(theDesktop);
90       }
91     } else {
92       QMessageBox::warning(0, tr("ERROR"), tr("MSG_NOACCESS_BY_IOR"));
93       close();
94     }
95   } else {
96     dataflow = Supervision.getEngine()->StreamGraph(MAIN_NEW);
97     if (SUPERV_isNull(dataflow)) {
98       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_DF"));
99       close();
100     } else {
101       init(theDesktop);
102     }
103   }
104 }
105
106 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool isModify, const char* f)
107      : SUPERVGraph_View(theParent),
108        myLogged( false ),
109        myFiltered( false ),
110        myLogFileName( QString::null ),
111        myLogFile( NULL ),
112        myWarning( false ),
113        myStep( false ),
114        myTrace( false ),
115        myVerbose( false )
116 {
117   Trace("SUPERVGUI_Main::SUPERVGUI_Main (file)")
118     theParent->setViewWidget(this);  
119   if (isModify) {
120     dataflow = Supervision.getEngine()->StreamGraph(f);
121   } else {
122     dataflow = Supervision.getEngine()->StreamGraphE(f);
123   }
124   if (SUPERV_isNull(dataflow)) {
125     QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
126     close();
127   } else {
128     init(theDesktop);
129   }
130 }
131 */
132
133 SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, SUPERV_Graph theDataFlow )
134      : SUPERVGraph_View(theParent),
135        myLogged( false ),
136        myFiltered( false ),
137        myLogFileName( QString::null ),
138        myLogFile( NULL ),
139        myWarning( false ),
140        myStep( false ),
141        myTrace( false ),
142        myVerbose( false )
143 {
144   Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)");
145   theParent->setViewWidget(this);  
146   dataflow = theDataFlow;
147   if (SUPERV_isNull(dataflow)) {
148     QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_COPY"));
149     close();
150   } else {
151     init(theDesktop);
152   }
153 }
154
155 void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) {
156   Trace("SUPERVGUI_Main::init");
157   if (theDesktop) myNService = theDesktop->getNameService();
158   myHashCode = "New";
159   myCopyNum = 0;
160   choosing  = false;
161   myIsLocked = false;
162
163   myThread = new SUPERVGUI_Thread();
164   myThread->setMain(this);
165
166   myIsKilled = false;
167   myCurrentView = CANVAS;
168   myIsFromStudy = false;
169   myLastGraph = 0;
170   study     = theDesktop->getActiveStudy();
171   
172   SALOMEDS::Study_var studyDoc = study->getStudyDocument();
173   bool aLocked = studyDoc->GetProperties()->IsLocked();
174   SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
175   SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
176   SALOMEDS::GenericAttribute_var anAttr;
177   SALOMEDS::AttributeName_var    aName;
178   SALOMEDS::AttributePixMap_var  aPixmap;
179   if (father->_is_nil()) {
180     QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
181     op->start();
182     if (aLocked) studyDoc->GetProperties()->SetLocked(false);
183     father = builder->NewComponent(STUDY_SUPERVISION);
184     anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
185     aName = SALOMEDS::AttributeName::_narrow(anAttr);
186     aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
187     
188     anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
189     aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
190     aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
191     
192     builder->DefineComponentInstance(father, Supervision.getEngine());
193     if (aLocked) studyDoc->GetProperties()->SetLocked(true);
194     op->finish();
195   };
196
197   objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
198     
199
200   graph = new SUPERVGUI_Graph(this);
201   graph->hide();
202   array = new SUPERVGUI_Array(this);
203
204   myArray = new SUPERVGUI_CanvasArray(this);
205   myArrayView = new SUPERVGUI_ArrayView(myArray, this);
206
207   myCanvas = new SUPERVGUI_Canvas(this);
208   myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
209   
210   message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
211   notification = new NOTIFICATION_Consumer();
212
213   QBoxLayout * layout = new QVBoxLayout(this);
214   layout->setMargin(0);
215   layout->setSpacing(0);
216   layout->addWidget(graph);
217   layout->addWidget(array);
218   layout->addWidget(myCanvasView);
219   layout->addWidget(myArrayView);
220
221   if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
222     myCanvas->merge();
223   }
224   sync();
225   show();
226   if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
227     myLogFile = fopen( myLogFileName.latin1(), "a" );
228     if (  myLogFile == NULL )
229       myLogged = false;
230   }
231   myTimer = new QTimer( this );
232   connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
233 }
234
235 SUPERVGUI_Main::~SUPERVGUI_Main() {
236   Trace("SUPERVGUI_Main::~SUPERVGUI_Main");
237
238   // close all opened SubGraphs 
239   QMap<QString, QAD_StudyFrame*>::iterator it;
240   for (it = mySubGraphs.begin(); it != mySubGraphs.end(); ++it) {
241     it.data()->removeEventFilter(this);
242     it.data()->disconnect();
243     it.data()->close();
244
245     QAD_Study* aStudy = it.data()->getStudy();
246     aStudy->removeStudyFrame(it.data());
247   }
248   mySubGraphs.clear();
249   mySubGraphMap.clear();
250   /*
251   QAD_StudyFrame* aSubGraph;
252   for (aSubGraph = mySubGraphs.first(); aSubGraph; aSubGraph = mySubGraphs.next()) {
253     aSubGraph->removeEventFilter(this);
254     aSubGraph->close();
255   }
256   */
257
258   if ( myLogFile != NULL) {
259     fclose( myLogFile );
260   }
261   graph->removeLinks();
262   //delete myCanvas;
263   //  delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
264   notification->_remove_ref();  // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit
265
266   delete myCanvas;
267   delete myArray;
268 }
269
270 void SUPERVGUI_Main::filterNotification() {
271   Trace("SUPERVGUI_Main::filterNotification");
272   SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
273   dlg->setFiltered( myFiltered );
274   dlg->setLogged( myLogged, myLogFileName );
275   dlg->setWarning( myWarning );
276   dlg->setStep( myStep );
277   dlg->setTrace( myTrace );
278   dlg->setVerbose( myVerbose );
279   if ( dlg->exec() == QDialog::Accepted ) {
280     myLogged      = dlg->getLogged();
281     myLogFileName = dlg->getLogFile();
282     myFiltered    = dlg->getFiltered();
283     myWarning     = dlg->getWarning();
284     myStep        = dlg->getStep();
285     myTrace       = dlg->getTrace();
286     myVerbose     = dlg->getVerbose();
287     delete dlg;
288     if ( myLogFile != NULL) {
289       fclose( myLogFile );
290     }
291     myLogFile = NULL;
292     if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
293       myLogFile = fopen( myLogFileName.latin1(), "a" );
294       if (  myLogFile == NULL ) {
295         myLogged = false;
296         QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr( "ERR_CANT_OPEN_LOG_FILE" ) );
297       }
298     }
299   }
300 }
301
302 void SUPERVGUI_Main::changeDSGraphParameters() {
303   SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly());
304   if (aDlg->exec() )
305     sync();
306   delete aDlg;
307 }
308
309 void SUPERVGUI_Main::syncAsync() {
310     Trace("SUPERVGUI_Main::syncAsync")
311     QTimer::singleShot(1, this, SLOT(sync()));
312 }
313
314
315 /**
316  * Called by thread when dataflow is executing
317  */
318 void SUPERVGUI_Main::execute(char *  theNodeName, SUPERV::GraphState theNodeState) {
319   if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
320     SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode");
321     if (aNode) aNode->sync();
322   }
323   else if (myCurrentView == CANVASTABLE) {
324     SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode");
325     if (aNode) aNode->sync();
326   }
327   else {
328     SUPERVGUI_Node* aNodePrs; 
329     SUPERVGUI_GraphNode* aGraphNodePrs;
330     if (myCurrentView == TABLE) {
331       aNodePrs = (SUPERVGUI_Node*) array->child(theNodeName, "SUPERVGUI_Node");
332       aGraphNodePrs = (SUPERVGUI_GraphNode*) array->child(theNodeName, "SUPERVGUI_GraphNode");
333     } else {
334       aNodePrs = (SUPERVGUI_Node*) graph->child(theNodeName, "SUPERVGUI_Node");
335       aGraphNodePrs = (SUPERVGUI_GraphNode*) graph->child(theNodeName, "SUPERVGUI_GraphNode");
336     }
337     if (aGraphNodePrs) {
338       aGraphNodePrs->sync();
339     }
340     else if (aNodePrs) {
341       aNodePrs->syncOnEvent(theNodeState);
342     }
343   }
344 }
345
346
347 void SUPERVGUI_Main::sync() {
348     Trace("SUPERVGUI_Main::sync")
349     if ((SUPERV_isNull(dataflow))) return;
350     QString t = tr("GRAPH_TITLE");
351     
352     t += dataflow->Name();
353     setCaption(t);
354
355     study->updateObjBrowser();
356     if (myCurrentView == TABLE) {
357       array->sync();
358     } else if (myCurrentView == CANVASTABLE) {
359       myArray->sync();
360       cout<<" --> after myArray->sync() ..."<<endl;
361       myArray->update();
362     } else if (myCurrentView == GRAPH) {
363       graph->sync();
364     } else {
365       myCanvas->sync();
366       myCanvas->update();
367     }
368 }
369
370
371 void SUPERVGUI_Main::showTable() {
372   if (myCurrentView == TABLE) return;
373
374   if (array->create()) {
375     if (myCurrentView == GRAPH)
376       graph->hide();
377     else if (myCurrentView == CANVASTABLE) {
378       myArrayView->hide();
379       myArray->destroy();
380     }
381     else
382       myCanvasView->hide();
383     myCurrentView = TABLE;
384   }
385   sync();
386 }
387
388 void SUPERVGUI_Main::showCanvasTable() {
389   if (myCurrentView == CANVASTABLE) return;
390
391   if (myArray->create()) {
392     if (myCurrentView == GRAPH)
393       graph->hide();
394     else if (myCurrentView == TABLE)
395       array->destroy();
396     else
397       myCanvasView->hide();
398
399     myArrayView->show();
400     myCurrentView = CANVASTABLE;
401   }
402   sync();
403 }
404
405 void SUPERVGUI_Main::showFullGraph() {
406   if (myCurrentView == TABLE) {
407     array->destroy();
408     graph->show();    
409   }
410   else if (myCurrentView == CANVASTABLE) {
411     myArrayView->hide();
412     myArray->destroy();
413     graph->show();    
414   }
415   else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) {
416     myCanvasView->hide();
417     graph->show();
418   }
419   myCurrentView = GRAPH;
420   graph->sync();
421   graph->setFullView();
422 }
423
424
425 void SUPERVGUI_Main::showContolFlow() {
426   bool merge = false;
427   if (myCurrentView == TABLE) {
428     array->destroy();
429     merge = true;
430   }
431   else if (myCurrentView == GRAPH) {
432     graph->hide();
433     merge = true;
434   }
435   else if (myCurrentView == CANVASTABLE) {
436     myArrayView->hide();
437     myArray->destroy();
438     merge = true;
439   }
440   myCurrentView = CONTROLFLOW;
441   myCanvas->setControlView();
442   if (merge) {
443     myCanvas->merge();
444     myCanvasView->show();
445   }
446 }
447
448 void SUPERVGUI_Main::showCanvas() {
449   if (myCurrentView == CANVAS) return;
450
451   bool merge = false;
452   if (myCurrentView == TABLE) {
453     array->destroy();
454     merge = true;
455   }
456   else if (myCurrentView == CANVASTABLE) {
457     myArrayView->hide();
458     myArray->destroy();
459     merge = true;
460   }
461   else if (myCurrentView == GRAPH) {
462     graph->hide();
463     merge = true;
464   }
465   myCurrentView = CANVAS;
466   myCanvas->setFullView();
467   if (merge) {
468     myCanvas->merge();
469     myCanvasView->show();
470   }
471 }
472
473 void SUPERVGUI_Main::insertFile() {
474     Trace("SUPERVGUI_Main::insertFile")
475     if ((SUPERV_isNull(dataflow))) return;
476
477     QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
478                                          "",
479                                          "*.xml",
480                                          tr("MSG_GRAPH_INSERT"),
481                                          true);
482     if (!f.isEmpty()) {
483         if (dataflow->Import(f.latin1())) {
484           if (myCurrentView == TABLE) {
485             array->destroy();
486             array->create();
487           }
488           else if (myCurrentView == CANVASTABLE) {
489             myArray->destroy();
490             myArray->create();
491           }
492           else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) {
493             myCanvas->merge();
494           }
495           sync();
496         } else {
497             QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f));
498         };
499     };
500 }
501
502 void SUPERVGUI_Main::copy() {
503   Trace("SUPERVGUI_Main::copy");
504   if (dataflow->ThreadsMax() == 0) {
505     QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOTHING_COPY"));
506     return;
507   }
508   QAD_StudyFrame* aStudyFrame = Supervision.createGraph();
509   SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
510     (aStudyFrame->getRightFrame()->getViewFrame());
511   if(aViewFrame){
512     SUPERV_Graph aNewGraph; //  = dataflow->StreamCopy();
513     if (dataflow->IsStreamGraph()) {
514       SUPERV_StreamGraph aSGraph = dataflow->ToStreamGraph();
515       if (SUPERV_isNull(aSGraph)) {
516         QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_CANT_COPY"));
517         return;
518       }
519       aNewGraph = aSGraph->StreamCopy();
520     }
521     else {
522       aNewGraph = dataflow->Copy();
523     }
524     QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum));
525     aNewName += dataflow->Name();
526     aNewGraph->SetName(aNewName);
527     /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame, 
528                                            Supervision.getDesktop(), 
529                                            aNewGraph);
530     study->showFrame(aStudyFrame);
531   }
532 }
533
534 void SUPERVGUI_Main::openSubGraph(SUPERV_CNode theNode, bool correct)
535 {
536   if (theNode->IsMacro()) {
537     // get SubGraph from MacroNode
538     SUPERV_Graph aMacro = SUPERV::Graph::_narrow(theNode);
539     SUPERV_Graph aGraph;
540     if (aMacro->IsStreamMacro())
541       aGraph = aMacro->StreamObjRef();
542     else
543       aGraph = aMacro->FlowObjRef();
544
545     // display SubGraph
546     if (SUPERV_isNull(aGraph)) {
547       QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOACCESS"));
548       return;
549     }
550     else {
551       QString aGraphName = aGraph->Name();
552       QAD_StudyFrame* aStudyFrame;
553       if (mySubGraphs.contains(aGraphName)) {
554         aStudyFrame = mySubGraphs[aGraphName];
555         aStudyFrame->setActiveWindow();
556         aStudyFrame->setFocus();
557       }
558       else {
559         aStudyFrame = Supervision.createGraph();
560         if (aStudyFrame) {
561           SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>
562             (aStudyFrame->getRightFrame()->getViewFrame());
563           if(aViewFrame) {
564             /*SUPERVGUI_Main* m = */new SUPERVGUI_Main(aViewFrame, 
565                                                    Supervision.getDesktop(), 
566                                                    aGraph);
567             //    connect(aStudyFrame, SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)), 
568             //            this,  SLOT(onSubGraphClosed(QAD_StudyFrame*)));
569             connect(aStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)), 
570                     this,  SLOT(onSubGraphActivated(QAD_StudyFrame*)));
571             aStudyFrame->installEventFilter(this);
572
573             mySubGraphs.insert(aGraphName, aStudyFrame);
574             mySubGraphMap.insert(aGraphName, theNode->Name());
575
576           }
577         }
578       }
579       study->showFrame(aStudyFrame);
580       if (!correct) myLastGraph = aStudyFrame;
581     }
582   }
583 }
584
585 bool SUPERVGUI_Main::eventFilter( QObject* o, QEvent* e)
586 {
587   // workaround to get close event
588   if (o->inherits("QAD_StudyFrame") && e->type() == QEvent::Close) {
589     QAD_StudyFrame* aFrame = (QAD_StudyFrame*) o;
590     onSubGraphClosed(aFrame);
591   }
592   return SUPERVGraph_View::eventFilter(o, e);
593 }
594
595 // workaround to fix PAL6255 -> opened SubGraph is not on top
596 void SUPERVGUI_Main::onSubGraphActivated(QAD_StudyFrame* theStudyFrame)
597 {
598   if (myLastGraph) {
599     QAD_StudyFrame* aFrame = myLastGraph;
600     myLastGraph = 0;
601     aFrame->setActiveWindow();
602     aFrame->setFocus();
603   }
604 }
605
606 void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame)
607 {
608   QAD_ViewFrame* viewFrame = theStudyFrame->getRightFrame()->getViewFrame();
609   if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(viewFrame)){
610     theStudyFrame->removeEventFilter(this);
611     disconnect(theStudyFrame, 0, this, 0);
612
613     SUPERVGraph_View* view = supervFrame->getViewWidget();
614     SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
615     if (aGraph) {
616       QString aGraphName = aGraph->getDataflow()->Name();
617       QMap<QString, QString>::iterator it = mySubGraphMap.find(aGraphName);
618       if (it != mySubGraphMap.end()) {
619         QString aNodeName = it.data();
620         SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) 
621           myCanvas->child(aNodeName, "SUPERVGUI_CanvasNode");
622         if (aNode) {
623           aNode->merge();
624           myCanvas->update();
625         }
626         mySubGraphMap.remove(it);
627       }
628       mySubGraphs.remove(aGraphName);
629     }
630   }
631 }
632
633 void SUPERVGUI_Main::run() {
634   Trace("SUPERVGUI_Main::run")
635     if ((SUPERV_isNull(dataflow))) return;
636   
637   if (dataflow->IsEditing()) {
638     if (!dataflow->IsValid()) {
639       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
640     } else if (!dataflow->IsExecutable()) {
641       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
642     } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
643       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
644     } else {
645       myRunTime = QDateTime::currentDateTime();
646       if (myIsKilled) {
647       //if (myIsRunned) {
648         if (!dataflow->ReRun()) {
649           QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
650           if (dataflow->State() == SUPERV::ErrorState) {
651             kill();
652           }
653         } else {
654           myThread->startThread(tr("MSG_GRAPH_STARTED"));
655           sync();
656         }
657       } else {
658         if (!dataflow->Run()) {
659           QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
660           if (dataflow->State() == SUPERV::ErrorState) {
661             kill();
662           }
663         } else {
664           myThread->startThread(tr("MSG_GRAPH_STARTED"));
665           sync();
666         }
667       }
668     }
669   } else {
670     QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
671   }
672 }
673
674
675
676 void SUPERVGUI_Main::startExecute() {
677   Trace("SUPERVGUI_Main::startExecute")
678   if ((SUPERV_isNull(dataflow))) return;
679   
680   if (dataflow->IsEditing()) {
681     if (!dataflow->IsValid()) {
682       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID"));
683     } else if (!dataflow->IsExecutable()) {
684       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE"));
685     } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) {
686       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE"));
687     } else {
688       myRunTime = QDateTime::currentDateTime();
689       if (myIsKilled) {
690       //if (myIsRunned) {
691         if (!dataflow->ReStart()) {
692           QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
693         } else {
694           myThread->startThread(tr("MSG_GRAPH_STARTED"));
695         }
696       }
697       else {
698         if (!dataflow->Start()) {
699           QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
700         } else {
701           myThread->startThread(tr("MSG_GRAPH_STARTED"));
702         }
703       }
704     }
705   } else {
706     QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING"));
707   }
708 }
709
710
711 void SUPERVGUI_Main::kill() {
712     Trace("SUPERVGUI_Main::kill")
713     if ((SUPERV_isNull(dataflow))) return;
714
715     if (dataflow->IsEditing()) {
716       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
717     } else if (dataflow->Kill()) {
718       myIsKilled = true;
719       myThread->stopThread(tr("MSG_GRAPH_KILLED"));
720       sync();
721     } else {
722       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
723     }
724 }
725
726 void SUPERVGUI_Main::suspendResume() {
727     Trace("SUPERVGUI_Main::suspendResume")
728     if ((SUPERV_isNull(dataflow))) return;
729
730     if (dataflow->IsEditing()) {
731         QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
732     } else if (dataflow->State() == SUPERV_Suspend) {
733       if (dataflow->Resume()) {
734         myThread->startThread(tr("MSG_DF_RESUMED"));
735       } else {
736         QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
737       }
738     } else {
739       if (dataflow->Suspend()) {
740         sync();
741         myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
742       } else {
743         QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
744       }
745     }
746 }
747
748 void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton)
749     Trace("SUPERVGUI_Main::stopRestart")
750     if ((SUPERV_isNull(dataflow))) return;
751
752     if (dataflow->IsEditing()) {
753         QMessageBox::warning(0, tr("ERROR"),  tr("MSG_DF_NOTRUNNING"));
754     } else if (dataflow->State() == SUPERV_Stop) {
755         if (dataflow->ReStart()) {
756             message->setMessage(tr("MSG_DF_RESTARTED"));
757             sync();
758         } else {
759             QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTART"));
760         };
761     } else {
762         if (dataflow->Stop()) {
763             sync();
764         } else {
765             QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOP"));
766         };
767     };
768 }
769
770 void SUPERVGUI_Main::addNode() {
771   Trace("SUPERVGUI_Main::addNode");
772   if (SUPERV_isNull(dataflow)) return;
773
774   if (dataflow->IsExecuting()) {
775     if (QMessageBox::warning(QAD_Application::getDesktop(), 
776                              tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
777                              QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
778       return;        
779     } else {
780       kill();
781     }
782   }
783   Supervision.getBrowser()->choose();
784 }
785
786 /**
787  * Add Computation node
788  */
789 void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
790   //cout<<"### X="<<theNode->X()<<"  Y="<<theNode->Y()<<endl;
791   switch (myCurrentView) {
792   case GRAPH:
793     {
794       SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
795       graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
796       graph->addChild(aNode, theNode->X(), theNode->Y());
797       aNode->sync();
798     }
799     break;
800   case TABLE:
801     array->destroy();
802     array->create();
803     break;
804   case CANVASTABLE:
805     myArray->destroy();
806     myArray->create();
807     break;  
808   case CANVAS:
809   case CONTROLFLOW: 
810     {
811       SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode(myCanvas, this, theNode);
812       aNode->move(theNode->X(), theNode->Y());
813       if (myCurrentView == CONTROLFLOW) aNode->hideAll();
814       aNode->show();
815       myCanvas->update();
816     }
817     break;
818   }
819 }
820
821 /**
822  * Add GOTO node
823  */
824 void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
825   switch (myCurrentView) {
826   case GRAPH:
827     {
828       SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode);
829       graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
830       graph->addChild(aNode, theNode->X(), theNode->Y());
831       aNode->sync();
832     }
833     break;
834   case TABLE:
835     array->destroy();
836     array->create();
837     break;
838   case CANVASTABLE:
839     myArray->destroy();
840     myArray->create();
841     break;
842   case CANVAS:
843   case CONTROLFLOW: 
844     {
845       SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode(myCanvas, this, theNode);
846       aNode->move(theNode->X(), theNode->Y());
847       if (myCurrentView == CONTROLFLOW) aNode->hideAll();
848       aNode->show();
849       myCanvas->update();
850     }
851     break;
852   }
853 }
854
855 /**
856  * Add Control node
857  */
858 void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
859   switch (myCurrentView) {
860   case GRAPH:
861     {
862       SUPERVGUI_StartControlNode* aStartPrs = 
863         new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode);
864       SUPERVGUI_EndControlNode* aEndPrs = 
865         new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs);
866
867       graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y());            
868       graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y());
869       graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y());
870       graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y());
871       if (Update) {
872         aStartPrs->updateLinksPrs();
873         aEndPrs->updateLinksPrs();
874       }
875       aStartPrs->sync();
876       aEndPrs->sync();
877       graph->repaintContents();
878     }
879     break;
880   case TABLE:
881     array->destroy();
882     array->create();
883     break;
884   case CANVASTABLE:
885     myArray->destroy();
886     myArray->create();
887     break;
888   case CANVAS:
889   case CONTROLFLOW: 
890     {
891       SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode(myCanvas, this, theStartNode);
892       aStartNode->move(theStartNode->X(), theStartNode->Y());
893       if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
894
895       SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode(myCanvas, this, theEndNode, aStartNode);
896       aEndNode->move(theEndNode->X(), theEndNode->Y());
897       if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
898
899       aStartNode->show();
900       aEndNode->show();
901       myCanvas->update();
902     }
903     break;
904   }
905 }
906
907
908 /**
909  * Add Macro node
910  */
911 void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
912   //cout<<"### X="<<theNode->X()<<"  Y="<<theNode->Y()<<endl;
913   switch (myCurrentView) {
914   case GRAPH:
915     {
916       SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode(graph->viewport(), this, theNode);
917       graph->ResizeGraph(aNode, theNode->X(), theNode->Y());
918       graph->addChild(aNode, theNode->X(), theNode->Y());
919       aNode->sync();
920     }
921     break;
922   case TABLE:
923     array->destroy();
924     array->create();
925     break;
926   case CANVASTABLE:
927     myArray->destroy();
928     myArray->create();
929     break;
930   case CANVAS:
931   case CONTROLFLOW: 
932     {
933       SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode(myCanvas, this, theNode);
934       aNode->move(theNode->X(), theNode->Y());
935       if (myCurrentView == CONTROLFLOW) aNode->hideAll();
936       aNode->show();
937       myCanvas->update();
938     }
939     break;
940   }
941 }
942
943
944 SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() {
945     Trace("SUPERVGUI_Main::getGraph")
946     return(graph);
947 }
948
949 SUPERVGUI_Array* SUPERVGUI_Main::getArray() {
950     Trace("SUPERVGUI_Main::getArray")
951     return(array);
952 }
953
954 SUPERVGUI_CanvasArray*  SUPERVGUI_Main::getCanvasArray() {
955     Trace("SUPERVGUI_Main::getCanvasArray")
956     return(myArray);
957 }
958
959 SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() {
960     Trace("SUPERVGUI_Main::getArrayView")
961       return(myArrayView);
962 }
963
964 SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() {
965     Trace("SUPERVGUI_Main::getCanvas")
966     return(myCanvas);
967 }
968
969 SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() {
970     Trace("SUPERVGUI_Main::getCanvasView")
971       return(myCanvasView);
972 }
973
974 SUPERV_Graph SUPERVGUI_Main::getDataflow() {
975     Trace("SUPERVGUI_Main::getDataflow")
976     return(dataflow);
977 }
978
979 QAD_Message* SUPERVGUI_Main::getMessage() {
980     Trace("SUPERVGUI_Main::getMessage")
981     return(message);
982 }
983
984 QAD_Study* SUPERVGUI_Main::getStudy() {
985     Trace("SUPERVGUI_Main::getStudy")
986     return(study);
987 }
988
989 bool SUPERVGUI_Main::isArrayShown() {
990     Trace("SUPERVGUI_Main::isArrayShown")
991       //return(myCurrentView == TABLE);
992     return(myCurrentView == CANVASTABLE);  
993 }
994
995 void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) {
996   Trace("SUPERVGUI_Main::showPopup");
997   // To check is Supervision active?
998   if (myIsLocked) return;
999   //if (dataflow->IsExecuting()) return;
1000
1001   //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
1002   if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
1003
1004   checkIsInStudy();
1005   if (e->button() == RightButton) {
1006     p->exec(e->globalPos());
1007   }
1008 }
1009
1010
1011
1012 void SUPERVGUI_Main::changeInformation() {
1013   SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly());
1014   if (aDlg->exec() )
1015     sync();
1016   delete aDlg;
1017   /*    Trace("SUPERVGUI_Main::changeInformation")
1018     if (Supervision.information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly())) {
1019       sync();
1020       }*/
1021 }
1022
1023 // returns false, if can't add dataflow into the study
1024 bool SUPERVGUI_Main::addStudy() {
1025   Trace("SUPERVGUI_Main::addStudy");
1026   if (myIsFromStudy) return false;
1027   if ((SUPERV_isNull(dataflow))) return false;
1028   
1029   SALOMEDS::Study_var            aStudy = study->getStudyDocument();
1030   SALOMEDS::StudyBuilder_var     aBuilder  = aStudy->NewBuilder();
1031   SALOMEDS::GenericAttribute_var anAttr;
1032   SALOMEDS::AttributeName_var    aName;
1033   SALOMEDS::AttributeIOR_var     anIORAttr;
1034   SALOMEDS::AttributePixMap_var  aPixmap;
1035   bool                           aLocked = aStudy->GetProperties()->IsLocked();
1036   QAD_Operation*                 op = new SALOMEGUI_ImportOperation( study );
1037   
1038   // searching dataflow
1039   SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
1040   if (aSO->_is_nil()) { // create new dataflow SObject
1041     SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
1042     if (aComponent->_is_nil()) { // is supervision component not found, then create it
1043       QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1044       anOperation->start();
1045       if (aLocked) aStudy->GetProperties()->SetLocked(false);
1046       aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
1047       anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
1048       aName = SALOMEDS::AttributeName::_narrow(anAttr);
1049       //aName->SetValue(STUDY_SUPERVISION);
1050       aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
1051       anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
1052       aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
1053       aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
1054       aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
1055       if (aLocked) aStudy->GetProperties()->SetLocked(true);
1056       anOperation->finish();
1057     }
1058     op->start();
1059     aSO = aBuilder->NewObject(aComponent);
1060     anAttr =  aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1061     aName = SALOMEDS::AttributeName::_narrow(anAttr);
1062     aName->SetValue(dataflow->Name());
1063     anAttr =  aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1064     anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1065     anIORAttr->SetValue(dataflow->getIOR());
1066     op->finish();
1067     if (aLocked) return false;
1068   }
1069
1070   sync();
1071   Supervision.unregisterGraph(this);
1072   Supervision.registerGraph(dataflow->getIOR(), this);
1073   myIsFromStudy = true;
1074   return true;
1075 }
1076
1077
1078 void SUPERVGUI_Main::chooseData(QListViewItem* item) {
1079     Trace("SUPERVGUI_Main::chooseData")
1080     if (choosing) {
1081         QString id = ((QAD_ObjectBrowserItem*)item)->getEntry();
1082         if (!id.isEmpty()) {
1083             SALOMEDS::SObject_var object = study->getStudyDocument()->FindObjectID(id.latin1());
1084             SALOMEDS::GenericAttribute_var anAttr;
1085             SALOMEDS::AttributeIOR_var     anIOR;
1086             Standard_CString      ior    = "";
1087             if (object->FindAttribute(anAttr, "AttributeIOR")) {
1088               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1089               ior = anIOR->Value();
1090               portIn->setValue(ior);
1091
1092               // stop selection
1093               choosing = false;
1094               setCursor(Supervision.getCursor());
1095               objectBrowser->setCursor(Supervision.getCursor());
1096               Supervision.putInfo("");
1097             }
1098         }
1099     }
1100 }
1101
1102 void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) {
1103     Trace("SUPERVGUI_Main::setData")
1104     portIn   = p;
1105     choosing = true;
1106     setCursor(forbiddenCursor);
1107     objectBrowser->setCursor(pointingHandCursor);
1108     Supervision.putInfo(tr("MSG_CHOOSE_DATA"));
1109 }
1110
1111 SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
1112                                                const SALOMEDS::SObject_var theSO,
1113                                                const char* theName,
1114                                                //QAD_Operation* theOperation,
1115                                                bool* theStarted) {
1116   SALOMEDS::SObject_var aResult;
1117   SALOMEDS::AttributeName_var aName;
1118   SALOMEDS::GenericAttribute_var anAttr;
1119   if (!*theStarted) { // optimisation
1120     SALOMEDS::ChildIterator_var anIterator = theStudy->NewChildIterator(theSO);
1121     for (; anIterator->More(); anIterator->Next()) {
1122       if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
1123         aName = SALOMEDS::AttributeName::_narrow(anAttr);
1124         if (strcmp(aName->Value(), theName) == 0) {
1125           aResult = anIterator->Value();
1126           break;
1127         }
1128       }
1129     }
1130   }
1131   if (!aResult->_is_nil()) return aResult;
1132   // add new SObject
1133   SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
1134   if (!*theStarted) {
1135     *theStarted = true;
1136     //theOperation->start();
1137     aBuilder->NewCommand();
1138   }
1139   aResult = aBuilder->NewObject(theSO);
1140   anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
1141   aName = SALOMEDS::AttributeName::_narrow(anAttr);
1142   aName->SetValue(theName);
1143   return aResult;
1144 }
1145
1146 bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) {
1147   Trace("SUPERVGUI_Main::putDataStudy");
1148
1149   static bool isIn = false;
1150   if (isIn) return true; else isIn = true;
1151
1152   SALOMEDS::Study_var            aStudy = study->getStudyDocument();
1153   SALOMEDS::StudyBuilder_var     aBuilder  = aStudy->NewBuilder();
1154   SALOMEDS::GenericAttribute_var anAttr;
1155   SALOMEDS::AttributeName_var    aName;
1156   SALOMEDS::AttributeIOR_var     anIORAttr;
1157   SALOMEDS::AttributePixMap_var  aPixmap;
1158   bool                           aTransaction = false;
1159   bool                           aLocked = aStudy->GetProperties()->IsLocked();
1160   //  QAD_Operation*                 op = new SALOMEGUI_ImportOperation( study );
1161   
1162   // searching dataflow
1163   SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
1164   if (aSO->_is_nil()) { // create new dataflow SObject
1165     SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
1166     if (aComponent->_is_nil()) { // is supervision component not found, then create it
1167       //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1168       //anOperation->start();
1169       aBuilder->NewCommand();
1170       if (aLocked) aStudy->GetProperties()->SetLocked(false);
1171       aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
1172       anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
1173       aName = SALOMEDS::AttributeName::_narrow(anAttr);
1174       //aName->SetValue(STUDY_SUPERVISION);
1175       aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
1176         
1177       anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
1178       aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
1179       aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
1180       aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
1181       if (aLocked) aStudy->GetProperties()->SetLocked(true);
1182       //      anOperation->finish();
1183       aBuilder->CommitCommand();
1184     }
1185     aTransaction = true;
1186     //op->start();
1187     aBuilder->NewCommand();
1188     aSO = aBuilder->NewObject(aComponent);
1189     anAttr =  aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
1190     aName = SALOMEDS::AttributeName::_narrow(anAttr);
1191     aName->SetValue(dataflow->Name());
1192     anAttr =  aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1193     anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
1194     anIORAttr->SetValue(dataflow->getIOR());
1195   }
1196   //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
1197   aSO = SearchOrCreateSOWithName(aStudy, aSO,  // get run time SO
1198                                  QString("Run ") + myRunTime.toString() /*, anOperation*/, &aTransaction);
1199   aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name()/*, anOperation*/, &aTransaction); // get node SO
1200   aSO = SearchOrCreateSOWithName(aStudy, aSO, inout/*, anOperation*/, &aTransaction); // get in/out SO
1201   aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name()/*, anOperation*/, &aTransaction); // get port SO
1202
1203   if (aLocked) {
1204     if (aTransaction) aBuilder->CommitCommand();
1205       //op->finish();
1206     isIn = false;
1207     return false;
1208   }
1209
1210   anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
1211   anIORAttr  = SALOMEDS::AttributeIOR::_narrow(anAttr);
1212   if (!aTransaction && strcmp(anIORAttr->Value(), p->ToString()) == 0) {
1213     isIn = false;
1214     return true;
1215   }
1216   // set object value to the study: if object is external, then put it with
1217   //                                 help of the specific component - owner
1218   if (p->IsIOR()) {
1219     // get according component driver for result object
1220     SALOME_LifeCycleCORBA aLCC(myNService);
1221     SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
1222     if (!aFNode->_is_nil()) {
1223       Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
1224                                                                     aFNode->GetComponentName());
1225       SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
1226       if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
1227         CORBA::Object_ptr anObject = new CORBA::Object();
1228         CORBA::Any* anAny = p->ToAny();
1229         (*anAny) >>= anObject;
1230         
1231         if (aDriver->CanPublishInStudy(anObject)) {
1232           SALOMEDS::SObject_var aTmpSO;
1233           if (!aTransaction) {
1234             aTmpSO = aSO;
1235             aTransaction = true;
1236             //op->start();
1237             aBuilder->NewCommand();
1238           }
1239           aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, "");
1240           aBuilder->Addreference(aSO, aTmpSO);
1241         } else { // can't publish object: abort transaction
1242           if (aTransaction) aBuilder->AbortCommand();
1243           //op->abort();
1244           isIn = false;
1245           return false;
1246         }
1247       } else { // component has no drivel, but could store IORs (like Calculator)
1248         SALOMEDS::SObject_var anIORSO = aStudy->FindObjectIOR(p->ToString());
1249         if (!CORBA::is_nil(anIORSO)) aBuilder->Addreference(aSO, anIORSO);
1250       }
1251     }
1252   } else {
1253     if (!aTransaction) {
1254       aTransaction = true;
1255       //      op->start();
1256       aBuilder->NewCommand();
1257     }
1258     anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
1259   }
1260   
1261   if (aTransaction) 
1262     //op->finish();
1263     aBuilder->CommitCommand();
1264   if (!myThread->running())
1265     study->updateObjBrowser();
1266   isIn = false;
1267   return true;
1268 }
1269
1270
1271 void SUPERVGUI_Main::ActivatePanning()
1272 {
1273   if (graph->isVisible()) {
1274     graph->ActivatePanning();
1275   } else if (array->isVisible()) {
1276     array->ActivatePanning();
1277   } else if (myCanvasView->isVisible()) {
1278     myCanvasView->ActivatePanning();
1279   } else if (myArrayView->isVisible()) {
1280     myArrayView->ActivatePanning();
1281   }
1282 }
1283
1284
1285 void SUPERVGUI_Main::ResetView()
1286 {
1287   if (graph->isVisible()) {
1288     graph->ResetView();
1289   } else if (array->isVisible()) {
1290     array->ResetView();
1291   } else if (myCanvasView->isVisible()) {
1292     myCanvasView->ResetView();
1293   } else if (myArrayView->isVisible()) {
1294     myArrayView->ResetView();
1295   }
1296 }
1297
1298
1299 void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) {
1300   myIsFromStudy = theToStudy;
1301   graph->setAsFromStudy(theToStudy);
1302   array->setAsFromStudy(theToStudy);
1303   myCanvas->setAsFromStudy(theToStudy);
1304 }
1305
1306 void SUPERVGUI_Main::checkIsInStudy() {
1307   if (!myIsFromStudy) return;
1308
1309   SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
1310   SALOMEDS::SComponent_var aFatherLbl = aStudyDoc->FindComponent(STUDY_SUPERVISION);
1311   SALOMEDS::ChildIterator_var aChildIterator = aStudyDoc->NewChildIterator(aFatherLbl);
1312   SALOMEDS::SObject_var aDataflowLbl;
1313   SALOMEDS::GenericAttribute_var anAttr;
1314
1315   for (; aChildIterator->More(); aChildIterator->Next()) {
1316     aDataflowLbl = aChildIterator->Value();
1317     if (!aDataflowLbl->FindAttribute(anAttr, "AttributeIOR"))
1318       continue;
1319
1320     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1321     if (strcmp(anIOR->Value(), dataflow->getIOR()) == 0) return;
1322   }
1323   // This Graph considered as in study but in study it is not exists
1324   Supervision.unregisterGraph(this);
1325   setAsFromStudy(false);
1326 }
1327
1328 void SUPERVGUI_Main::syncNotification() {
1329   char* graph;
1330   char* node;
1331   char* type;
1332   char* message;
1333   char* sender;
1334   long  counter;
1335   char* date;
1336   long  stamp;
1337   
1338   while (notification->Receive(&graph, &node, &type, &message, &sender, &counter, &date, &stamp)) {
1339     if (isFiltered(graph, node, type, message, sender, counter, date, stamp)) {
1340       QString mess("");
1341       mess += "NOTIF: "; mess += graph;
1342       mess += " / "    ; mess += node;
1343       mess += " / "    ; mess += type;
1344       mess += " / "    ; mess += message;
1345       getMessage()->setMessage(mess.latin1());
1346     };
1347   };
1348 }
1349   
1350 bool SUPERVGUI_Main::isFiltered(char* graph,  char* node,   char* type, char* message, 
1351                                 char* sender, long counter, char* date, long stamp) {
1352   Trace("SUPERVGUI_Main::isFiltered");
1353   bool b = false;
1354   if (strcmp(getDataflow()->Name(), graph) == 0) {
1355     SUPERVGUI_Node* n;
1356     QObjectList* nodes = queryList("SUPERVGUI_Node");
1357     QObjectListIt i(*nodes);
1358     while ((n=(SUPERVGUI_Node*)i.current()) != 0) {
1359       ++i;
1360       if (strcmp(n->name(), node) == 0) {
1361         if (strcmp(type, NOTIF_WARNING) == 0) {
1362           b = n->isWarning();
1363         } else if (strcmp(type, NOTIF_STEP) == 0) {
1364           b = n->isStep();
1365         } else if (strcmp(type, NOTIF_TRACE) == 0) {
1366           b = n->isTrace();
1367         } else if (strcmp(type, NOTIF_VERBOSE) == 0) {
1368           b = n->isVerbose();
1369         };
1370         break;
1371       };
1372     };
1373     delete nodes;
1374     if ( myLogged && myLogFile && ( ( !myFiltered ) || b ) ) {
1375       fprintf( myLogFile, "NOTIF %ld\t%s\t%s\t%ld\t%s\t%s\t%s\t%s\n", stamp, date, sender, counter, graph, node, type, message );
1376       fflush( myLogFile );
1377     };
1378   };
1379   return( b );
1380 }
1381
1382 void SUPERVGUI_Main::closeEvent(QCloseEvent* e) {
1383   e->accept();
1384 }
1385
1386
1387 void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) { 
1388
1389   array->setPaletteBackgroundColor(color);
1390   graph->setPaletteBackgroundColor(color);
1391   myCanvas->setBackgroundColor(color);
1392   myCanvasView->setPaletteBackgroundColor(color.light());
1393   myArray->setBackgroundColor(color);
1394   myArrayView->setPaletteBackgroundColor(color.light());
1395   
1396   SUPERVGraph_View::setPaletteBackgroundColor(color); 
1397 }
1398
1399 QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
1400   return myEventNodes;
1401 }
1402
1403 void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
1404   myEventNodes = theEventNodes;
1405 }
1406
1407 QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
1408   return myStates;
1409 }
1410
1411 void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
1412   myStates = theStates;
1413 }
1414
1415 int SUPERVGUI_Main::getNodesNumber() {
1416   //create a list of nodes of the graph
1417   SUPERV_Nodes nodes = getDataflow()->Nodes();
1418   int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
1419                nodes->INodes.length() + nodes->GNodes.length() +
1420                nodes->LNodes.length() + nodes->SNodes.length();
1421   return RetVal;
1422 }
1423
1424 SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
1425   return myThread;
1426 }
1427
1428 void SUPERVGUI_Main::startTimer() {
1429   myTimer->start(500);
1430 }
1431
1432 void SUPERVGUI_Main::executionFinished() {
1433   getStudy()->updateObjBrowser();
1434   myCanvas->update();
1435   myArray->update();
1436 }
1437
1438 void SUPERVGUI_Main::checkExecution() {
1439   if (myThread->finished()) {
1440     myTimer->stop();
1441     executionFinished();
1442   }
1443 }
1444
1445 /******************************* SUPERVGUI_Thread class ****************************************/
1446 SUPERVGUI_Thread::SUPERVGUI_Thread()
1447      :QThread()
1448 {
1449   myIsActive = false;
1450 }
1451
1452 SUPERVGUI_Thread::~SUPERVGUI_Thread()
1453 {
1454   //it is a virtual destructor and needs to be determine here
1455 }
1456
1457 void SUPERVGUI_Thread::startThread(const char* m)
1458 {
1459   if (!myIsActive) {
1460     myIsActive = true;
1461     //QThread::start();
1462     this->start();
1463     myMain->getMessage()->setMessage(m); 
1464     myMain->sync();
1465   }
1466 }
1467
1468 void SUPERVGUI_Thread::stopThread(const char* m)
1469 {
1470   myMain->getMessage()->setMessage(m);
1471 }
1472
1473 void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
1474 {
1475   myMain = theMain;
1476 }
1477
1478 void SUPERVGUI_Thread::KillThread(bool theValue)
1479 {
1480   myMutex.lock();
1481   myIsActive = !(theValue);
1482   myMutex.unlock();
1483 }
1484
1485 typedef TVoidMemFun2ArgEvent<SUPERVGUI_Main, char*, SUPERV::GraphState> TNodeSyncEvent;
1486
1487 void SUPERVGUI_Thread::run()
1488 {
1489   SUPERV_CNode aNode = NULL;
1490   SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
1491   SUPERV::GraphState aState = SUPERV::UndefinedState ;
1492
1493   SUPERV_CNode aPrevNode = NULL;
1494   SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
1495   SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
1496
1497   char * aName;
1498   char * aPrevName;
1499
1500   QPtrList< char * > anEventNodes;
1501   QPtrList< SUPERV::GraphState > aStates;
1502
1503   myMain->startTimer();
1504   while(myIsActive) {
1505     myMain->getDataflow()->Event(aNode, aEvent, aState);
1506     
1507     if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
1508         ||
1509         aEvent == SUPERV::NoEvent && aState == SUPERV::NoState
1510         ||
1511         aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) {
1512
1513       if (myMain->getEventNodes().count()) {
1514         myMain->removeEventNodes();
1515       }    
1516       if (myMain->getStates().count()) {
1517         myMain->removeStates();
1518       }    
1519       myIsActive = false;
1520     }
1521     else {    
1522       if ( aNode != NULL && !CORBA::is_nil( aNode ) ) {
1523         aName = aNode->Name();
1524       }
1525
1526       if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) {  //first initialize aPrev... variables
1527         anEventNodes = myMain->getEventNodes();
1528         anEventNodes.append( &aName ) ;
1529         myMain->setEventNodes(anEventNodes);
1530         
1531         aStates = myMain->getStates();
1532         aStates.append( &aState ) ;
1533         myMain->setStates(aStates);
1534       }
1535       else {
1536         if ( aEvent == aPrevEvent && aState == aPrevState) {
1537           QString aNameStr = aName;
1538           QString aPrevNameStr = aPrevName;
1539           if ( aNameStr != aPrevNameStr ) {
1540             anEventNodes = myMain->getEventNodes();
1541             anEventNodes.append( &aName ) ;
1542             myMain->setEventNodes(anEventNodes);
1543             
1544             aStates = myMain->getStates();
1545             aStates.append( &aState ) ;
1546             myMain->setStates(aStates);
1547           }
1548         }
1549         else {
1550           anEventNodes = myMain->getEventNodes();
1551           anEventNodes.append( &aName ) ;
1552           myMain->setEventNodes(anEventNodes);
1553           
1554           aStates = myMain->getStates();
1555           aStates.append( &aState ) ;
1556           myMain->setStates(aStates);
1557         }
1558       }
1559     }      
1560     if (!myIsActive) {
1561       switch (myMain->getDataflow()->State()) {
1562       case SUPERV_Editing :     
1563         stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
1564         break;
1565         
1566       case SUPERV_Suspend : 
1567         stopThread(tr("MSG_GRAPH_SUSPENDED"));
1568         break;
1569  
1570       case SUPERV_Done : 
1571         stopThread(tr("MSG_GRAPH_FINISHED"));
1572         break;
1573         
1574       case SUPERV_Error :
1575         stopThread(tr("MSG_GRAPH_ABORTED"));
1576         break;
1577         
1578       case SUPERV_Kill:
1579         stopThread(tr("MSG_GRAPH_KILLED"));
1580         break;
1581       }
1582
1583       break;
1584     }
1585     if ( myMain->getEventNodes().count() ) {    
1586       //if list not empty call execute() -> sync()
1587       char * aNodeName = *(myMain->getEventNodes().getFirst());
1588       SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
1589
1590       // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here
1591       ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) );
1592
1593       myMain->removeFirstEN();
1594       myMain->removeFirstS();
1595     }
1596
1597     aPrevNode = aNode;
1598     aPrevEvent = aEvent;
1599     aPrevState = aState;
1600
1601     if ( aPrevNode == NULL || CORBA::is_nil( aPrevNode ) ) 
1602       aPrevName = "";
1603     else 
1604       aPrevName = aPrevNode->Name();
1605     
1606     //usleep(10);
1607     //msleep(5);
1608   }
1609   // VSR: 04/12/03 ---> update object browser ufter finishing
1610 //   qApp->lock();
1611 //   myMain->getStudy()->updateObjBrowser();
1612 //   qApp->unlock();
1613   // VSR: 04/12/03 <---    
1614
1615   QThread::exit();
1616 }
1617
1618 /******************************* SUPERVGUI_DSGraphParameters class ****************************************/
1619 /*!
1620   Constructor
1621 */
1622 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
1623      : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) 
1624 {
1625   Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
1626   setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
1627   setSizeGripEnabled( true );
1628   myGraph = theGraph;
1629
1630   QGridLayout* TopLayout = new QGridLayout( this );
1631   TopLayout->setSpacing( 6 );
1632   TopLayout->setMargin( 11 );
1633     
1634   QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
1635   TopGroup->setColumnLayout(0, Qt::Vertical );
1636   TopGroup->layout()->setSpacing( 0 );
1637   TopGroup->layout()->setMargin( 0 );
1638   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
1639   TopGroupLayout->setAlignment( Qt::AlignTop );
1640   TopGroupLayout->setSpacing( 6 );
1641   TopGroupLayout->setMargin( 11 );
1642
1643   // DeltaTime
1644   QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );  
1645   TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
1646   
1647   myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
1648   myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1649   TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
1650
1651   // TimeOut
1652   QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup); 
1653   TopGroupLayout->addWidget( TimeOutL, 1, 0 );
1654
1655   myTimeOut = new QLineEdit( TopGroup );
1656   myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1657   myTimeOut->setValidator( new QIntValidator(this) );
1658   myTimeOut->setMinimumSize( 100, 0 );
1659   myTimeOut->setReadOnly( isReadOnly );
1660   TopGroupLayout->addWidget( myTimeOut, 1, 1 );
1661
1662   // DataStreamTrace
1663   QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup); 
1664   TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
1665
1666   myDataStreamTrace = new QComboBox( TopGroup );
1667   myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
1668   myDataStreamTrace->insertItem("WithoutTrace");
1669   myDataStreamTrace->insertItem("SummaryTrace");
1670   myDataStreamTrace->insertItem("DetailedTrace");
1671   TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
1672
1673   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
1674   GroupButtons->setColumnLayout(0, Qt::Vertical );
1675   GroupButtons->layout()->setSpacing( 0 );
1676   GroupButtons->layout()->setMargin( 0 );
1677   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
1678   GroupButtonsLayout->setAlignment( Qt::AlignTop );
1679   GroupButtonsLayout->setSpacing( 6 );
1680   GroupButtonsLayout->setMargin( 11 );
1681   
1682   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
1683   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
1684
1685   GroupButtonsLayout->addWidget( okB, 0, 0 );
1686   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
1687   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
1688
1689   TopLayout->addWidget( TopGroup,     0, 0 );
1690   TopLayout->addWidget( GroupButtons, 1, 0 );
1691
1692   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
1693   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
1694
1695   setData();
1696 }
1697
1698 /*!
1699   Destructor
1700 */
1701 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
1702   Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
1703 }
1704
1705 /*!
1706   Sets data function
1707 */
1708 void SUPERVGUI_DSGraphParameters::setData() {
1709   double aDeltaTime;
1710   long aTimeOut;
1711   SUPERV::KindOfDataStreamTrace aDataStreamTrace;
1712
1713 //  myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1714   if (myGraph->IsStreamGraph()) {
1715     SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1716     if (!SUPERV_isNull(aSGraph)) 
1717       aSGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
1718   }
1719
1720   myDeltaTime->setValue(aDeltaTime);
1721   myTimeOut->setText(QString("%1").arg(aTimeOut));
1722   myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
1723 }
1724
1725 /*!
1726   <OK> button slot
1727 */
1728 void SUPERVGUI_DSGraphParameters::accept() {
1729 //   myGraph->SetStreamParams( myTimeOut->text().toLong(),
1730 //                          (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1731 //                          myDeltaTime->value());
1732   if (myGraph->IsStreamGraph()) {
1733     SUPERV_StreamGraph aSGraph = myGraph->ToStreamGraph();
1734     if (!SUPERV_isNull(aSGraph)) 
1735       aSGraph->SetStreamParams( myTimeOut->text().toLong(),
1736                                 (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
1737                                 myDeltaTime->value());
1738   }
1739   QDialog::accept();
1740 }