]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_Graph.cxx
Salome HOME
Stream Graph parameters dialog box
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Graph.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_Graph.cxx
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 using namespace std;
29 #include "SUPERVGUI_Def.h"
30 #include "SUPERVGUI_Graph.h"
31 #include "SUPERVGUI_Main.h"
32 #include "SUPERVGUI_ComputeNode.h"
33 #include "SUPERVGUI_ControlNode.h"
34 #include "SUPERVGUI.h"
35
36 #include <qapplication.h>
37 #include <qlabel.h>
38 #include <qgroupbox.h>
39 #include <qlayout.h>
40 #include <qvalidator.h>
41
42 //#define CHECKTIME
43
44 #ifdef CHECKTIME
45 #include <sys/timeb.h>
46 #endif
47
48
49 #define UPDATECONTROLNODES(NodesName)  \
50     n = nodes->NodesName.length(); \
51     for (int i=0; i<n; i++) { \
52       SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[i]); \
53       SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[i]->Coupled()); \
54       ihmNode = (SUPERVGUI_Node *)child(aCNode->Name(), "SUPERVGUI_Node"); \
55       if (ihmNode == NULL) { \
56         main->addControlNode(aCNode, aCNodeEnd, false); \
57       } else { \
58         ResizeGraph(ihmNode, aCNode->X(), aCNode->Y()); \
59         moveChild(ihmNode, aCNode->X(), aCNode->Y());  \
60         ihmList->removeRef(ihmNode); \
61         ihmNode->sync(); \
62         aEndNodePrs = (SUPERVGUI_EndControlNode*)child(aCNodeEnd->Name(), "SUPERVGUI_EndControlNode"); \
63         ResizeGraph(aEndNodePrs, aCNodeEnd->X(), aCNodeEnd->Y()); \
64         moveChild(aEndNodePrs, aCNodeEnd->X(), aCNodeEnd->Y());  \
65         ihmList->removeRef(aEndNodePrs); \
66         aEndNodePrs->sync(); \
67       } \
68     }
69
70
71 #define UPDATENODES(NodesName, FuncName)   \
72     n = nodes->NodesName.length(); \
73     for (int i=0; i<n; i++) { \
74       SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[i]); \
75       ihmNode = (SUPERVGUI_Node *)child(aCNode->Name(), "SUPERVGUI_Node"); \
76       if (ihmNode == NULL) { \
77           main->FuncName(aCNode); \
78       } else { \
79         ResizeGraph(ihmNode, aCNode->X(), aCNode->Y()); \
80         moveChild(ihmNode, aCNode->X(), aCNode->Y()); \
81         ihmList->removeRef(ihmNode); \
82         ihmNode->sync(); \
83       } \
84     }
85
86
87 SUPERVGUI_Graph::SUPERVGUI_Graph(SUPERVGUI_Main* m):
88     SUPERVGUI_View(m),
89     myNewLink(0)
90 {
91   Trace("SUPERVGUI_Graph::SUPERVGUI_Graph");
92   myIsControlView = false;
93   myLinksList.setAutoDelete(true);
94   viewport()->setMouseTracking(true);
95
96   resizeContents(GRAPH_WIDTH, GRAPH_HEIGHT);
97   
98   if (SUPERV_isNull(main->getDataflow())) return;
99   
100  
101   //create sketching popup menu
102   mySketchPopup = new QPopupMenu(viewport());
103   if (!mySketchPopup->isCheckable())
104     mySketchPopup->setCheckable(true);
105   myDelPntItem = mySketchPopup->insertItem(tr("MSG_DEL_LAST_PNT"), this, SLOT(delLastPnt()));
106   mySketchPopup->insertItem(tr("MSG_DEL_LINK"), this, SLOT(delCreatingLink()));
107   myOrtoItem = mySketchPopup->insertItem(tr("MSG_ORTHO_LINE"), this, SLOT(setOrtho()));
108
109   //create link popup menu
110   myLinkPopup = new QPopupMenu(viewport());
111   myDelLinkItem = myLinkPopup->insertItem(tr("MSG_DELLINK"), this, SLOT(deleteLink()));
112   myAddLinkPntItem = myLinkPopup->insertItem(tr("MSG_ADD_POINT"), this, SLOT(addPoint()));
113   myDelLinkPntItem = myLinkPopup->insertItem(tr("MSG_DEL_POINT"), this, SLOT(deletePoint()));
114 }
115
116
117
118 SUPERVGUI_Graph::~SUPERVGUI_Graph() {
119 }
120
121 /** 
122  * Synchronizes Graph presentation with internal graph structure
123  */
124 void SUPERVGUI_Graph::sync() {
125     if (SUPERV_isNull(main->getDataflow())) return;
126       
127     myLinksList.clear();
128
129     SUPERVGUI_Node* ihmNode;
130     QObjectList* ihmList = queryList("SUPERVGUI_Node");
131     SUPERV_Nodes nodes = main->getDataflow()->Nodes();
132
133     MESSAGE("CNodes="<<nodes->CNodes.length());
134     MESSAGE("FNodes="<<nodes->FNodes.length());
135     MESSAGE("INodes="<<nodes->INodes.length());
136     MESSAGE("GNodes="<<nodes->GNodes.length());
137     MESSAGE("LNodes="<<nodes->LNodes.length());
138     MESSAGE("SNodes="<<nodes->SNodes.length());
139
140     int n;
141     UPDATENODES(CNodes, addComputeNode);
142     UPDATENODES(FNodes, addComputeNode);
143     UPDATENODES(INodes, addComputeNode);
144     UPDATENODES(GNodes, addGOTONode);
145
146     SUPERVGUI_EndControlNode* aEndNodePrs;
147     UPDATECONTROLNODES(LNodes);    
148     UPDATECONTROLNODES(SNodes);
149
150     QObjectListIt i(*ihmList);
151     while ((ihmNode=(SUPERVGUI_Node*)i.current()) != 0) {
152       ++i;
153       ihmNode->close(true);
154     }
155     delete ihmList;
156
157     ihmList = queryList("SUPERVGUI_GraphNode");
158     i=(*ihmList);
159     SUPERVGUI_GraphNode* aGraphNode;
160     while ((aGraphNode=(SUPERVGUI_GraphNode*)i.current()) != 0) {
161       ++i;
162       aGraphNode->updateLinksPrs();
163     }
164     delete ihmList;
165
166     draw();
167 }
168
169
170 /**
171  * Reimplemented for repainting links
172  */
173 bool SUPERVGUI_Graph::eventFilter(QObject* object, QEvent* event) {
174   if (event->type() == QEvent::Paint) {
175     draw();
176     return true;
177   }
178   return QScrollView::eventFilter(object, event);
179 }
180
181
182 /**
183  * Clears content of Graph (links)
184  */
185 void SUPERVGUI_Graph::clearView() {
186   QPainter aPainter(viewport());
187   aPainter.eraseRect(viewport()->rect());    
188 }
189
190
191 /**
192  * Draws links using off screen buffer
193  */
194 void SUPERVGUI_Graph::draw() {
195 #ifdef CHECKTIME
196   struct timeb aTm1;
197   ftime(&aTm1);
198 #endif
199   if (myLinksList.count() == 0) {
200     return;
201   }
202   int aWidth = viewport()->width();
203   int aHeight = viewport()->height();
204   QPixmap aPixmap(aWidth, aHeight);
205   aPixmap.setOptimization(QPixmap::BestOptim);
206   aPixmap.fill(viewport()->paletteBackgroundColor());
207   
208   QPainter aPainter(&aPixmap);
209   QPoint aPos = viewportToContents(viewport()->pos());
210
211   if (myIsControlView) {
212     SUPERVGUI_CtrlLink* aLink;
213     QMap<QString, SUPERVGUI_CtrlLink>::Iterator it;    
214     for ( it = myCtrlLinks.begin(); it != myCtrlLinks.end(); ++it ) {
215       it.data().paint(&aPainter, false);
216     }
217   } else {
218     SUPERVGUI_Link* aLink;
219     for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) {
220       aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight);
221       if (aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight)) {
222         aLink->paint(&aPainter, false);
223       }
224     }    
225   }
226   bitBlt(viewport(), 0, 0, 
227              &aPixmap, 0, 0, aWidth, aHeight, 
228              Qt::CopyROP, true);
229   
230   if (myNewLink) {
231     myNewLink->repaintSketch();
232   }
233 #ifdef CHECKTIME
234   struct timeb aTm2;
235   ftime(&aTm2);
236   ulong aTm = 1000*(aTm2.time-aTm1.time)+(aTm2.millitm-aTm1.millitm);
237   cout<<"### Time="<<aTm<<endl;
238 #endif
239 }
240
241
242 void SUPERVGUI_Graph::contentsMousePressEvent(QMouseEvent* e) {
243   Trace("SUPERVGUI_Graph::contentsMousePressEvent");
244   if ( e->button() == Qt::RightButton) {
245     if (myNewLink) {
246       main->showPopup(mySketchPopup, e);
247     } else {
248       SUPERVGUI_Link* aLink = SUPERVGUI_Link::getSelectedLink();
249       if (aLink && main->isEditable()) {
250         myLinkPopup->setItemEnabled(myAddLinkPntItem, 
251                                     !aLink->haveSelectedPoint());
252         myLinkPopup->setItemEnabled(myDelLinkPntItem, 
253                                     aLink->haveSelectedPoint());
254
255
256         if (!aLink->isESInputPort()) {
257           SUPERV::KindOfPort aOutType = aLink->getOutputPort()->getPort()->Kind();
258           SUPERV::KindOfPort aInType = aLink->getInputPort()->getPort()->Kind();
259           myLinkPopup->setItemEnabled(myDelLinkItem,
260                                       ((aOutType != SUPERV::LoopParameter) 
261                                        && 
262                                        (aInType != SUPERV::LoopParameter)));
263         }
264         
265         myMousePos = e->pos();
266         mySelectedLink = aLink;
267         mySelectedPoint = mySelectedLink->getSelectedPoint();
268         main->showPopup(myLinkPopup, e);
269       } else {
270         mySelectedLink = 0;
271         addDSPopupItem();
272         main->showPopup(myPopup, e);
273       }
274     }
275   } 
276   emit mousePressed(e);
277     
278   SUPERVGUI_View::contentsMousePressEvent(e);  
279 }
280
281
282 void SUPERVGUI_Graph::contentsMouseReleaseEvent(QMouseEvent* e) {
283   Trace("SUPERVGUI_Graph::contentsMouseReleaseEvent");
284   if (myNewLink && (e->button() == Qt::LeftButton)) {
285     myNewLink->addTmpPoint(e->pos());
286     mySketchPopup->setItemEnabled(myDelPntItem, true);      
287   } 
288   emit mouseReleased(e);
289   SUPERVGUI_View::contentsMouseReleaseEvent(e);
290 }
291
292
293 void SUPERVGUI_Graph::contentsMouseMoveEvent(QMouseEvent* e) {
294   Trace("SUPERVGUI_Graph::contentsMouseMoveEvent");
295   if (myNewLink) {
296     myNewLink->drawTo(e->pos());
297   } 
298   emit mouseMoved(e);
299   SUPERVGUI_View::contentsMouseMoveEvent(e);
300 }
301
302
303 void SUPERVGUI_Graph::addPoint() {
304   mySelectedLink->addPoint(myMousePos.x(), myMousePos.y());
305 }
306
307
308 void SUPERVGUI_Graph::deletePoint() {
309   mySelectedLink->removePoint(mySelectedPoint);
310 }
311
312
313 void SUPERVGUI_Graph::deleteLink() {
314   QString aName;
315   if (mySelectedLink->isESInputPort())
316     aName = mySelectedLink->getInputPortES()->getPort()->Name();
317   else
318     aName = mySelectedLink->getInputPort()->getPort()->Name();
319
320   if (aName != "Default") {
321     deleteLink(mySelectedLink);
322     mySelectedLink = 0;
323     repaintContents();
324   }
325 }
326
327
328 void SUPERVGUI_Graph::deleteLink(SUPERVGUI_Link* theLink) {
329   //update values of input ports of theLink if theLink is deleted
330   if ( theLink->getInputPort() ) {
331     //input port exist
332     SUPERVGUI_PortIn* aInPort = theLink->getInputPort();
333     if (aInPort->getPort()->IsParam() || aInPort->getPort()->IsInLine()) {
334       QString aPortValue = QString(aInPort->getPort()->ToString()); 
335       if (!aPortValue.isNull()) {
336         //gives a value to an input port
337         theLink->destroyEngine();
338         aInPort->getPort()->Input( Supervision.getEngine()->StringValue( aPortValue ) );
339         aInPort->sync();
340       }
341     }
342   }
343   else 
344     theLink->destroyEngine();
345
346   myLinksList.removeRef(theLink);
347   if (myLinksList.count() == 0) clearView();
348 }
349
350
351 void SUPERVGUI_Graph::setAsFromStudy(bool theToStudy) {
352   SUPERVGUI_View::setAsFromStudy(theToStudy);
353   if (theToStudy) return;
354
355   SUPERVGUI_PortOut* aPortOut;
356   QObjectList* aPortsList = queryList("SUPERVGUI_PortOut");
357   QObjectListIt aPortIt(*aPortsList);
358   while ((aPortOut=(SUPERVGUI_PortOut*)aPortIt.current()) != 0) {
359     ++aPortIt;
360     if (aPortOut->isInStudy()) {
361       aPortOut->setStudyState(false);
362       aPortOut->sync();
363     }
364   }
365   delete aPortsList;
366 }
367
368
369 /**
370  * Begins Link sketching
371  */
372 void SUPERVGUI_Graph::sketchBegin(SUPERVGUI_Port* thePort) {
373   if (thePort == 0) return;
374
375   SUPERV_Port aPort = thePort->getPort();
376   myNewLink = new SUPERVGUI_Link(this);
377   mySketchPopup->setItemEnabled(myDelPntItem, false);      
378   mySketchPopup->setItemChecked(myOrtoItem, myNewLink->isOrthoMode());
379
380   myNewLink->setBeginPort(thePort);
381
382   if (aPort->IsInput()) {
383     if (aPort->Kind() == SUPERV::EndSwitchParameter
384         ||
385         aPort->Node()->Kind() == SUPERV::EndSwitchNode) {
386       myNewLink->setInputPortES(dynamic_cast<SUPERVGUI_PortInESNode*>(thePort));
387     }
388     else
389       myNewLink->setInputPort(dynamic_cast<SUPERVGUI_PortIn*>(thePort));
390   }
391   else
392     myNewLink->setOutputPort(dynamic_cast<SUPERVGUI_PortOut*>(thePort));    
393 }
394
395
396 void SUPERVGUI_Graph::sketchEnd(SUPERVGUI_Port* thePort) {
397   if (!myNewLink) return;
398
399   bool aIsInput = myNewLink->getBeginPort()->getPort()->IsInput();
400   if (aIsInput && thePort->getPort()->IsInput()
401       ||
402       !aIsInput && !thePort->getPort()->IsInput()) {
403     return;
404   }
405   
406
407   SUPERV_Port aPort = thePort->getPort();
408   if (aPort->IsInput()) {
409
410     int aKind = myNewLink->getOutputPort()->getPort()->Kind();
411
412     if ((aPort->Kind() == SUPERV::EndSwitchParameter
413          ||
414          aPort->Node()->Kind() == SUPERV::EndSwitchNode)
415         &&
416         (aKind == SUPERV::InLineParameter || aKind == SUPERV::ServiceParameter))
417       {
418         QString aName(aPort->Name());
419         if (aName != "Default")
420           myNewLink->setInputPortES(dynamic_cast<SUPERVGUI_PortInESNode*>(thePort));
421       }
422     else if (aPort->Kind() == SUPERV::DataStreamParameter){
423       myNewLink->setInputPort(dynamic_cast<SUPERVGUI_StreamPortIn*>(thePort));
424     } else { 
425       if (aPort->IsLinked()) return;
426     
427       if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) {
428         if (aKind != aPort->Kind() && aKind != SUPERV::InLineParameter 
429             && aPort->Kind() != SUPERV::InLineParameter) {
430           return;
431         }
432         else { //connection like Gate <--> Gate
433           myNewLink->setInputPort(dynamic_cast<SUPERVGUI_PortIn*>(thePort));
434         }
435       } else {
436         myNewLink->setInputPort(dynamic_cast<SUPERVGUI_PortIn*>(thePort));
437       }
438     }
439
440   } else {
441     if (myNewLink->isESInputPort()) {
442       if(aPort->Kind() == SUPERV::InLineParameter || aPort->Kind() == SUPERV::ServiceParameter)
443         {
444           myNewLink->setOutputPort(dynamic_cast<SUPERVGUI_PortOut*>(thePort));
445         }
446       else
447         return;
448     } else {
449       int aKind = myNewLink->getInputPort()->getPort()->Kind();
450
451       if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) {
452         if (aKind != aPort->Kind() && 
453             aKind != SUPERV::InLineParameter && 
454             aPort->Kind() != SUPERV::InLineParameter) {
455           return;
456         } else  //connection like Gate <--> Gate
457           myNewLink->setOutputPort(dynamic_cast<SUPERVGUI_PortOut*>(thePort));
458       } else if (aPort->Kind() == SUPERV::DataStreamParameter){
459         myNewLink->setOutputPort(dynamic_cast<SUPERVGUI_StreamPortOut*>(thePort));
460       } else
461         myNewLink->setOutputPort(dynamic_cast<SUPERVGUI_PortOut*>(thePort));    
462     }
463   }
464   
465   if (myNewLink->isCreationComplete()) {  // if everything is defined
466     if (myNewLink->createEngine()) {
467       myLinksList.append(myNewLink);
468       myNewLink = 0;
469     } else {
470       QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_LINK")); 
471       delete myNewLink;
472     }
473   }
474 }
475
476
477 /**
478  * Returns true if presentation of link exists
479  */
480 bool SUPERVGUI_Graph::isLinkPrsExists(SUPERV_Link theLink) {
481   SUPERVGUI_Link* aTmpLink;
482   for (aTmpLink = myLinksList.first(); aTmpLink; aTmpLink = myLinksList.next()) {
483     SUPERVGUI_PortOut* aOutPort = aTmpLink->getOutputPort();
484     if (strcmp(aOutPort->getPort()->Node()->Name(), 
485                theLink->OutPort()->Node()->Name()) == 0) {
486       QString aName(theLink->OutPort()->Name());
487       aName += "Output";
488       if (aOutPort->name() == aName) {
489         return true;
490       }
491     }
492   }
493   return false;
494 }
495
496
497 /**
498  * Creates link presentation from link engine
499  * Returns false if fails
500  */
501 bool SUPERVGUI_Graph::createLinkPrs(SUPERV_Link theLink) {
502   SUPERVGUI_Link* aNewLink = new SUPERVGUI_Link(this, theLink);
503   
504   // Find output node
505   SUPERVGUI_Node* aOutNode = (SUPERVGUI_Node*) 
506     child(theLink->OutPort()->Node()->Name(), "SUPERVGUI_Node");
507   if (aOutNode) {
508     QString aName(theLink->OutPort()->Name());
509     aName += "Output";
510     SUPERVGUI_PortOut* aOutPort = (SUPERVGUI_PortOut*)
511       aOutNode->child(aName, "SUPERVGUI_PortOut");
512     if (aOutPort)
513       aNewLink->setOutputPort(aOutPort);
514     else {
515       delete aNewLink;
516       return false;
517     }
518   } else {
519     delete aNewLink;
520     return false;
521   }
522   // Find input node
523   SUPERVGUI_Node* aInNode = (SUPERVGUI_Node*)
524     child(theLink->InPort()->Node()->Name(), "SUPERVGUI_Node");
525   if (aInNode) {
526     QString aName(theLink->InPort()->Name());
527     aName += "Input";
528     if (theLink->InPort()->Kind() == SUPERV::EndSwitchParameter) {
529       //If input port is EndSwitchParameter
530       SUPERVGUI_PortInESNode* aInPortES =(SUPERVGUI_PortInESNode*)
531         aInNode->child(aName, "SUPERVGUI_PortInESNode");        //returns null
532       if (aInPortES)
533         aNewLink->setInputPortES(aInPortES);
534       else {
535         delete aNewLink;
536         return false;
537       }
538     } else {
539       SUPERVGUI_PortIn* aInPort =(SUPERVGUI_PortIn*)
540         aInNode->child(aName, "SUPERVGUI_PortIn");
541       if (aInPort) 
542         aNewLink->setInputPort(aInPort);
543       else {
544         delete aNewLink;
545         return false;
546       }
547     }
548   } else {
549     delete aNewLink;
550     return false;
551   }
552   aNewLink->setVisible(!myIsControlView);
553   myLinksList.append(aNewLink);
554   return true;
555 }
556
557
558 void SUPERVGUI_Graph::delLastPnt() {
559   if (myNewLink) { 
560     myNewLink->delLastTmpPoint();
561   }
562 }
563
564 void SUPERVGUI_Graph::delCreatingLink() {
565   myNewLink->abortCreation();
566   delete myNewLink;
567   myNewLink=0;
568   repaintContents();
569 }
570
571 void SUPERVGUI_Graph::setOrtho() {
572   if (myNewLink) { 
573     bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem);
574     myNewLink->setOrthoMode(aIsOrtho);
575     mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho);
576   }
577 }
578
579
580
581 void SUPERVGUI_Graph::setFullView() {
582   QObjectList* aNodeList = queryList("SUPERVGUI_Node");
583   QObjectListIt aIt(*aNodeList);
584   SUPERVGUI_Node* aNode;
585   while ((aNode=(SUPERVGUI_Node*)aIt.current()) != 0) {
586     ++aIt;
587     aNode->showAll();
588   }
589   delete aNodeList;
590
591   myCtrlLinks.clear();
592   SUPERVGUI_Link* aLink;
593   for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) {
594     aLink->setVisible(true);
595   }
596   draw();
597   myIsControlView = false;
598 }
599
600
601 void SUPERVGUI_Graph::setControlView() {
602   QObjectList* aNodeList = queryList("SUPERVGUI_Node");
603   QObjectListIt aIt(*aNodeList);
604   SUPERVGUI_Node* aNode;
605   while ((aNode=(SUPERVGUI_Node*)aIt.current()) != 0) {
606     ++aIt;
607     aNode->hideAll();
608   }
609   delete aNodeList;
610   myCtrlLinks.clear();
611   SUPERVGUI_Link* aLink;
612   for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) {
613     aLink->setVisible(false);
614
615     QString aOutName(aLink->getEngineLink()->OutPort()->Node()->Name());
616     QString aInName(aLink->getEngineLink()->InPort()->Node()->Name());
617     QString aKey = aOutName + aInName;
618
619     if (!myCtrlLinks.contains(aKey)) {
620       SUPERVGUI_GraphNode* aOutNode = (SUPERVGUI_GraphNode*)
621         child(aOutName, "SUPERVGUI_GraphNode");
622       if (!aOutNode) continue;
623       SUPERVGUI_GraphNode* aInNode = (SUPERVGUI_GraphNode*)
624         child(aInName, "SUPERVGUI_GraphNode");
625       if (!aInNode) continue;
626
627       myCtrlLinks[aKey] = SUPERVGUI_CtrlLink(this, aOutNode, aInNode);
628     }
629   }
630   draw();
631   myIsControlView = true;
632 }
633
634
635 void SUPERVGUI_Graph::deleteNode(SUPERVGUI_Node* theNode) { 
636   theNode->close(true); 
637   draw(); 
638 }
639
640 /*!
641   Constructor
642 */
643 SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly)
644      : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) 
645 {
646   Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters");
647   setCaption( tr( "TLT_DSGRAPHPARAMS" ) );
648   setSizeGripEnabled( true );
649   myGraph = theGraph;
650
651   QGridLayout* TopLayout = new QGridLayout( this );
652   TopLayout->setSpacing( 6 );
653   TopLayout->setMargin( 11 );
654     
655   QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
656   TopGroup->setColumnLayout(0, Qt::Vertical );
657   TopGroup->layout()->setSpacing( 0 );
658   TopGroup->layout()->setMargin( 0 );
659   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
660   TopGroupLayout->setAlignment( Qt::AlignTop );
661   TopGroupLayout->setSpacing( 6 );
662   TopGroupLayout->setMargin( 11 );
663
664   // DeltaTime
665   QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup );  
666   TopGroupLayout->addWidget( DeltaTimeL, 0, 0 );
667   
668   myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1);
669   myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
670   TopGroupLayout->addWidget( myDeltaTime, 0, 1 );
671
672   // TimeOut
673   QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup); 
674   TopGroupLayout->addWidget( TimeOutL, 1, 0 );
675
676   myTimeOut = new QLineEdit( TopGroup );
677   myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
678   myTimeOut->setValidator( new QIntValidator(this) );
679   myTimeOut->setMinimumSize( 100, 0 );
680   myTimeOut->setReadOnly( isReadOnly );
681   TopGroupLayout->addWidget( myTimeOut, 1, 1 );
682
683   // DataStreamTrace
684   QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup); 
685   TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 );
686
687   myDataStreamTrace = new QComboBox( TopGroup );
688   myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
689   myDataStreamTrace->insertItem("WithoutTrace");
690   myDataStreamTrace->insertItem("SummaryTrace");
691   myDataStreamTrace->insertItem("DetailedTrace");
692   TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 );
693
694   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
695   GroupButtons->setColumnLayout(0, Qt::Vertical );
696   GroupButtons->layout()->setSpacing( 0 );
697   GroupButtons->layout()->setMargin( 0 );
698   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
699   GroupButtonsLayout->setAlignment( Qt::AlignTop );
700   GroupButtonsLayout->setSpacing( 6 );
701   GroupButtonsLayout->setMargin( 11 );
702   
703   QPushButton* okB     = new QPushButton( tr( "BUT_OK" ),     GroupButtons );
704   QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons );
705
706   GroupButtonsLayout->addWidget( okB, 0, 0 );
707   GroupButtonsLayout->addItem  ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
708   GroupButtonsLayout->addWidget( cancelB, 0, 2 );
709
710   TopLayout->addWidget( TopGroup,     0, 0 );
711   TopLayout->addWidget( GroupButtons, 1, 0 );
712
713   connect( okB,     SIGNAL( clicked() ), this, SLOT( accept() ) );
714   connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) );
715
716   setData();
717 }
718
719 /*!
720   Destructor
721 */
722 SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() {
723   Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters");
724 }
725
726 /*!
727   Sets data function
728 */
729 void SUPERVGUI_DSGraphParameters::setData() {
730   double aDeltaTime;
731   long aTimeOut;
732   SUPERV::KindOfDataStreamTrace aDataStreamTrace;
733
734   myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime);
735
736   myDeltaTime->setValue(aDeltaTime);
737   myTimeOut->setText(QString("%1").arg(aTimeOut));
738   myDataStreamTrace->setCurrentItem((int)aDataStreamTrace);
739 }
740
741 /*!
742   <OK> button slot
743 */
744 void SUPERVGUI_DSGraphParameters::accept() {
745   myGraph->SetStreamParams( myTimeOut->text().toLong(),
746                             (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(),
747                             myDeltaTime->value());
748   QDialog::accept();
749 }