]> SALOME platform Git repositories - modules/superv.git/blob - src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx
Salome HOME
70a1e3826177ac2069ffe8aa2cf4cadb4b4e874f
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasLink.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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SUPERVGUI_GanvasNodePrs.cxx
23 //  Author : Natalia KOPNOVA
24 //  Module : SUPERV
25
26 #include "SUPERVGUI_CanvasLink.h"
27 #include "SUPERVGUI_Canvas.h"
28 #include "SUPERVGUI_CanvasPort.h"
29 #include "SUPERVGUI_Main.h"
30
31 //#define CHECKTIME
32
33 #ifdef CHECKTIME
34 #include <sys/timeb.h>
35 #endif
36
37 #define DRAW_COLOR Qt::black
38 #define SELECT_COLOR Qt::magenta
39 #define SKETCH_COLOR Qt::darkGreen
40 #define STREAM_COLOR Qt::darkRed // QColor(0, 64, 128) // Qt::blue
41
42 #define LINE_WIDTH 1
43
44
45 SUPERVGUI_CanvasLink::SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Link_ptr theLink):
46   QObject(theParent),
47   myMain(theMain),
48   myLink(0),
49   myInputPort(0),
50   myOutputPort(0),
51   myHilighted(false),
52   mySelectedItem(0)
53 {
54   if (theLink && !SUPERV_isNull(theLink)) {
55     myLink = SUPERV::Link::_duplicate(theLink);
56
57     SUPERVGUI_Canvas* aCanvas = myMain->getCanvas();
58     setName(aCanvas->getLinkName(theLink));
59
60     myInputPort = aCanvas->getPort(myLink->InPort());
61     if (myInputPort) myInputPort->addLink(this);
62
63     myOutputPort = aCanvas->getPort(myLink->OutPort());
64     if (myOutputPort) myOutputPort->addLink(this);
65
66     if (myInputPort->isStream())
67       myColor = STREAM_COLOR;
68     else
69       myColor = DRAW_COLOR;
70   }
71
72   // mkr : PAL8237
73   connect(this, SIGNAL(objectCreatedDeleted()), myMain, SLOT(onObjectCreatedDeleted()));
74 }
75
76 SUPERVGUI_CanvasLink::~SUPERVGUI_CanvasLink()
77 {
78   for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) {
79     (*it)->hide();
80     delete *it;
81   }
82   if (myInputPort) myInputPort->removeLink(this);
83   if (myOutputPort) myOutputPort->removeLink(this);
84 }
85
86 void SUPERVGUI_CanvasLink::createPrs()
87 {
88   if (myLink && !SUPERV_isNull(myLink)) {
89     if (myInputPort) {
90       addPoint(myInputPort->getConnectionPoint());
91     }
92     if (!myMain->getCanvas()->isControlView()) {
93       CORBA::Long x, y;
94       for (CORBA::Long i = 0; i < myLink->CoordsSize(); i++) {
95         myLink->Coords(i+1, x, y);
96         addPoint(QPoint(x, y), i+1);
97       }
98     }
99     if (myOutputPort) {
100       addPoint(myOutputPort->getConnectionPoint());
101     }
102   }
103   setColor(myHilighted ? SELECT_COLOR : myColor);
104 }
105
106 void SUPERVGUI_CanvasLink::addPoint(const QPoint& thePoint, const int& theIndex)
107 {
108   SUPERVGUI_CanvasPointPrs* aPoint;
109   if (myPrs.empty()) {
110     aPoint = new SUPERVGUI_CanvasPointPrs(myMain->getCanvas(), this, theIndex);
111     aPoint->setColor(myColor);
112     aPoint->move(thePoint.x(), thePoint.y());
113   }
114   else {
115     SUPERVGUI_CanvasPointPrs* aPrev = (SUPERVGUI_CanvasPointPrs*) myPrs.last();
116
117     SUPERVGUI_CanvasEdgePrs* anEdge = new SUPERVGUI_CanvasEdgePrs(myMain->getCanvas(), this);
118     anEdge->setColor(myColor);
119     myPrs.append(anEdge);
120
121     aPoint = new SUPERVGUI_CanvasPointPrs(myMain->getCanvas(), this, theIndex);
122     aPoint->setColor(myColor);
123     aPoint->move(thePoint.x(), thePoint.y());
124
125     aPrev->setOutEdge(anEdge);
126     aPoint->setInEdge(anEdge);
127   }
128   myPrs.append(aPoint);
129 }
130
131 void SUPERVGUI_CanvasLink::setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint)
132 {
133   mySelectedItem = theItem;
134   mySelectedPoint = thePoint;
135 }
136
137 QPopupMenu* SUPERVGUI_CanvasLink::getPopupMenu(QWidget* theParent) 
138 {
139   QPopupMenu* popup = new QPopupMenu(theParent);
140   int anItem;
141   anItem = popup->insertItem(tr("MSG_DELLINK"), this, SLOT(remove()));
142   if (myInputPort && 
143       (myInputPort->getEngine()->Kind() != SUPERV::EndSwitchParameter ||
144        myInputPort->getEngine()->Node()->Kind() != SUPERV::EndSwitchNode))
145     if (myInputPort->getEngine()->Kind() == SUPERV::LoopParameter ||
146         myOutputPort && myOutputPort->getEngine()->Kind() == SUPERV::LoopParameter)
147       popup->setItemEnabled(anItem, false);
148
149   popup->insertSeparator();
150   if (mySelectedItem) {
151     anItem = popup->insertItem(tr("MSG_ADD_POINT"), this, SLOT(addPoint()));
152     if (mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint)
153       popup->setItemEnabled(anItem, false);
154
155     anItem = popup->insertItem(tr("MSG_DEL_POINT"), this, SLOT(removePoint()));
156     if (mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge)
157       popup->setItemEnabled(anItem, false);
158   }
159   return popup;
160 }
161
162 void SUPERVGUI_CanvasLink::show()
163 {
164   if (myPrs.isEmpty()) createPrs();
165
166   for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) {
167     (*it)->show();
168   }
169 }
170
171 void SUPERVGUI_CanvasLink::merge()
172 {
173   // remove old presentation
174   for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) {
175     delete *it;
176   }
177   myPrs.clear();
178
179   // display a new one
180   show();
181 }
182
183 void SUPERVGUI_CanvasLink::setHilighted(bool state)
184 {
185   myHilighted = state;
186   setColor(myHilighted ? SELECT_COLOR : myColor);
187   if (!myPrs.isEmpty()) {
188     bool disp = myPrs.first()->isVisible();
189     if (disp) {
190       for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) {
191         (*it)->hide(); (*it)->show();
192       }
193       myMain->getCanvas()->update();
194     }
195   }
196 }
197
198 void SUPERVGUI_CanvasLink::moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy)
199 {
200   if (myInputPort && myInputPort == thePort) {
201     myPrs.first()->moveBy(dx, dy);
202     return;
203   }
204   if (myOutputPort && myOutputPort == thePort) {
205     myPrs.last()->moveBy(dx, dy);
206     return;
207   }
208 }
209
210 void SUPERVGUI_CanvasLink::moveByPort(SUPERVGUI_CanvasPort* thePort)
211 {
212   QPoint p = thePort->getConnectionPoint();
213   if (myInputPort && myInputPort == thePort) {
214     myPrs.first()->move(p.x(), p.y());
215     return;
216   }
217   if (myOutputPort && myOutputPort == thePort) {
218     myPrs.last()->move(p.x(), p.y());
219     return;
220   }
221 }
222
223 void SUPERVGUI_CanvasLink::setColor(const QColor& theColor)
224 {
225   for (QCanvasItemList::Iterator it = myPrs.begin(); it != myPrs.end(); ++it) {
226     if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
227       ((SUPERVGUI_CanvasPointPrs*)(*it))->setColor(theColor);
228     }
229     else if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
230       ((SUPERVGUI_CanvasEdgePrs*)(*it))->setColor(theColor);
231     }
232   }
233 }
234
235 void SUPERVGUI_CanvasLink::remove() {
236   // IPAL9369 : check the dataflow readiness to modify
237   if ( !myMain->ReadyToModify() ) // null dataflow or executing, ..
238     return;
239
240   myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
241
242   QString aValue;
243   SUPERVGUI_CanvasPortIn* aPort = 0;
244   SUPERVGUI_Canvas* aCanvas = myMain->getCanvas();
245   if (myLink && !SUPERV_isNull(myLink)) {
246     if (myInputPort) {
247       if (myInputPort->getEngine()->IsParam() || myInputPort->getEngine()->IsInLine()) {
248         aValue = QString(myInputPort->getEngine()->ToString());
249         aPort = (SUPERVGUI_CanvasPortIn*) myInputPort;
250       }
251     }
252     myLink->destroy();
253
254     emit objectCreatedDeleted(); // mkr : PAL8237
255   }
256
257   delete this;
258   if (aPort && !aValue.isEmpty() && myMain->getDataflow()->GraphLevel() == 0) {
259     aPort->setValue(aValue);
260   }
261   aCanvas->update();
262 }
263
264 void SUPERVGUI_CanvasLink::addPoint() {
265   if (mySelectedItem && mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) {
266     SUPERVGUI_CanvasEdgePrs* anEdge = (SUPERVGUI_CanvasEdgePrs*) mySelectedItem;
267
268     int anIndex = 1;
269     QCanvasItemList::Iterator it;
270     for (it = myPrs.begin(); it != myPrs.end(); ++it) {
271       if ((*it) == anEdge) break;
272     }
273     if (it != myPrs.begin()) {
274       --it;
275       SUPERVGUI_CanvasPointPrs* aPoint = (SUPERVGUI_CanvasPointPrs*) (*it);
276       anIndex = aPoint->getIndex()+1;
277       if (anIndex < 1) anIndex = 1;
278     }
279     if (myLink && !SUPERV_isNull(myLink)) {
280       myLink->AddCoord(anIndex, mySelectedPoint.x(), mySelectedPoint.y());
281       emit objectCreatedDeleted(); // mkr : PAL8237
282     }
283     merge();
284     myMain->getCanvas()->update();
285   }
286 }
287
288 void SUPERVGUI_CanvasLink::removePoint() {
289   if (mySelectedItem && mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
290     SUPERVGUI_CanvasPointPrs* aPoint = (SUPERVGUI_CanvasPointPrs*) mySelectedItem;
291     if (myLink && !SUPERV_isNull(myLink)) {
292       myLink->RemoveCoord(aPoint->getIndex());
293       emit objectCreatedDeleted(); // mkr : PAL8237
294     }
295     merge();
296     myMain->getCanvas()->update();
297   }
298 }
299
300 QString SUPERVGUI_CanvasLink::getToolTipText() const {
301   QString aTTT;
302   if (myInputPort && myOutputPort)
303     aTTT = myOutputPort->getEngine()->Node()->Name() + QString(" : ") + 
304       myOutputPort->getEngine()->Name() + QString(" => ") +
305       myInputPort->getEngine()->Node()->Name() + QString(" : ") + 
306       myInputPort->getEngine()->Name();
307   return aTTT;
308 }
309
310 /*
311 //===============================================================================
312 //  SUPERVGUI_CanvasStreamLink: new link to be created
313 //===============================================================================
314 SUPERVGUI_CanvasStreamLink::SUPERVGUI_CanvasStreamLink(QObject* theParent, SUPERVGUI_Main* theMain, 
315                                                        SUPERV::StreamLink_ptr theLink):
316   SUPERVGUI_CanvasLink(theParent, theMain, theLink)
317 {
318   if (theLink && !SUPERV_isNull(theLink)) {
319     myStreamLink = SUPERV::StreamLink::_duplicate(theLink);
320   }
321 }
322
323
324 void SUPERVGUI_CanvasStreamLink::remove() {
325   QString aValue;
326   SUPERVGUI_CanvasPortIn* aPort = 0;
327   SUPERVGUI_Canvas* aCanvas = getMain()->getCanvas();
328   if (myStreamLink && !SUPERV_isNull(myStreamLink)) {
329     if (getInputPort()) {
330       if (getInputPort()->getEngine()->IsParam() || getInputPort()->getEngine()->IsInLine()) {
331         aPort = (SUPERVGUI_CanvasPortIn*) getInputPort();
332         aValue = QString(aPort->getEngine()->ToString());
333       }
334     }
335     myStreamLink->destroy();
336   }
337   delete this;
338   if (aPort && !aValue.isEmpty()) {
339     aPort->setValue(aValue);
340   }
341   aCanvas->update();
342 }
343 */
344
345 //===============================================================================
346 //  SUPERVGUI_CanvasLinkBuilder: new link to be created
347 //===============================================================================
348 SUPERVGUI_CanvasLinkBuilder::SUPERVGUI_CanvasLinkBuilder(QObject* theParent, SUPERVGUI_Main* theMain, 
349                                                          SUPERVGUI_CanvasPort* thePort):
350   SUPERVGUI_CanvasLink(theParent, theMain),
351   myPort(thePort),
352   myFloatingEdge(0)
353 {
354   if (myPort) {
355     myPort->addLink(this);
356     addPoint(myPort->getConnectionPoint());
357   }
358   myColor = SKETCH_COLOR;
359 }
360
361 SUPERVGUI_CanvasLinkBuilder::~SUPERVGUI_CanvasLinkBuilder()
362 {
363   if (myFloatingEdge) delete myFloatingEdge;
364   if (myPort) myPort->removeLink(this);
365 }
366
367 bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort)
368 {
369   if (thePort && myPort) {
370     SUPERVGUI_CanvasPort* aInPort;
371     SUPERVGUI_CanvasPort* aOutPort;
372
373     // check if ports are couple of input and output
374     if (myPort->getEngine()->IsInput()) {
375       aInPort = myPort;
376       if (thePort->getEngine()->IsInput())
377         return false;
378       aOutPort = thePort;
379     }
380     else {
381       aOutPort = myPort;
382       if (!thePort->getEngine()->IsInput())
383         return false;
384       aInPort = thePort;
385     }
386
387     // control if nodes are different, not the same node
388     QString aInNode(aInPort->getEngine()->Node()->Name());
389     QString aOutNode(aOutPort->getEngine()->Node()->Name());
390     if (aInNode.compare(aOutNode) == 0) // linking outport and inport of the same node
391       return false;
392
393     // control types of ports
394     int aInKind = aInPort->getEngine()->Kind();
395     int aOutKind = aOutPort->getEngine()->Kind();
396
397     // connect stream port with stream port only
398     if ((aInKind == SUPERV::DataStreamParameter && aOutKind != SUPERV::DataStreamParameter) ||
399         (aOutKind == SUPERV::DataStreamParameter && aInKind != SUPERV::DataStreamParameter))
400       return false;
401
402     // asv : 15.12.04 : NOT allow to connect Gate-to-InLine --> it does not make sence!
403     // Out Gate port can be connected only to In Gate port 
404     if ( aOutKind == SUPERV::GateParameter && aInKind != SUPERV::GateParameter )
405       return false;
406
407     // In Gate can be connected to (receive links from) Gate port and InLine ports (important for Switch nodes)
408     if ( aInKind == SUPERV::GateParameter && aOutKind != SUPERV::GateParameter && aOutKind != SUPERV::InLineParameter )
409         return false;
410
411     // asv : 15.12.04 : PAL7374, p.2.2 "Bugs and Improvements": multiple links into Gate port 
412     //                  for InGate it's OK to accept more than 1 link
413     // THESE NEEDS REVISION, ALSO DON'T ALLOW MANY LINKS TO "DEFAULT" PORT OF EndSwitch
414     //if ( aInPort->getEngine()->IsLinked() && aInKind != SUPERV::GateParameter ) 
415     
416     // control if port is already linked except for input inline ports of end switch node (check for EndSwitchParameter)
417     // and "Default" port of Switch node (check for aNode->isEndSwitch()).  "Default" port is linked by default, but we
418     // let it to be "re-linked" to another port. 
419     const bool isEndSwitch = ( aInKind == SUPERV::EndSwitchParameter || aInPort->getEngine()->Node()->IsEndSwitch() );
420     if ( !isEndSwitch && aInPort->getEngine()->IsLinked() ) 
421       return false;
422     
423     return true;
424   }
425   return false;
426 }
427
428 void SUPERVGUI_CanvasLinkBuilder::setCoords(SUPERV::Link_ptr theLink)
429 {
430   if (theLink) {
431     QCanvasItemList::Iterator it;
432     int anIndex = 1;
433     if (myPort->getEngine()->IsInput()) {
434       it = myPrs.begin(); ++it; // ignore the first point
435       for (; it != myPrs.end(); ++it) {
436         if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
437           theLink->AddCoord(anIndex++, (int)(*it)->x(), (int)(*it)->y());
438         }
439       }
440     }
441     else {
442       it = myPrs.end(); --it;
443       for (; it != myPrs.begin(); --it) {
444         if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
445           theLink->AddCoord(anIndex++, (int)(*it)->x(), (int)(*it)->y());
446         }
447       }
448     }
449   }
450 }
451
452 void SUPERVGUI_CanvasLinkBuilder::addNextPoint(const QPoint& thePoint, bool theOrtho)
453 {
454   if (myFloatingEdge) myFloatingEdge->hide();
455
456   if (!theOrtho || myPrs.empty()) {
457     addPoint(thePoint);
458   }
459   else {
460     SUPERVGUI_CanvasPointPrs* aPrev = (SUPERVGUI_CanvasPointPrs*) myPrs.last();
461     int x = (int)aPrev->x(); int y = (int)aPrev->y();
462     if (thePoint.x() != x && thePoint.y() != y) {
463       addPoint(QPoint(thePoint.x(), y), -2);
464     }
465     addPoint(thePoint);
466   }
467   show();
468 }
469
470 void SUPERVGUI_CanvasLinkBuilder::setFloatPoint(const QPoint& thePoint)
471 {
472   if (!myFloatingEdge) {
473     myFloatingEdge = new QCanvasLine(getMain()->getCanvas());
474     myFloatingEdge->setPen(QPen(myColor, LINE_WIDTH));
475   }
476   if (!myPrs.empty()) {
477     myFloatingEdge->setPoints((int)myPrs.last()->x(), (int)myPrs.last()->y(), 
478                               thePoint.x(), thePoint.y());
479     myFloatingEdge->show();
480   }
481 }
482
483 void SUPERVGUI_CanvasLinkBuilder::removeLastPoint()
484 {
485   if (myPrs.count() > 1) {
486     QPoint aLast((int)myPrs.last()->x(), (int)myPrs.last()->y());
487     QCanvasItemList::Iterator it = myPrs.end();
488     bool removed = false;
489     --it;
490     for (; it != myPrs.begin(); --it) {
491       if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
492         SUPERVGUI_CanvasPointPrs* aPoint = (SUPERVGUI_CanvasPointPrs*) (*it);
493         if (aPoint->getIndex() == -1 && removed) break;
494       }
495       QCanvasItem* anItem = (*it);
496       it = myPrs.remove(it);
497       delete anItem;
498       removed = true;
499     }
500     if (removed) {
501       if (myFloatingEdge) {
502         QPoint aPoint = myFloatingEdge->endPoint();
503         myFloatingEdge->setPoints((int)myPrs.last()->x(), (int)myPrs.last()->y(),
504                                   aPoint.x(), aPoint.y());
505       }
506       else
507         setFloatPoint(aLast);
508     }
509   }
510 }
511
512 void SUPERVGUI_CanvasLinkBuilder::moveByPort(SUPERVGUI_CanvasPort* thePort, int dx, int dy)
513 {
514   if (myPort && myPort == thePort) {
515     myPrs.first()->moveBy(dx, dy);
516     return;
517   }
518 }
519
520 void SUPERVGUI_CanvasLinkBuilder::moveByPort(SUPERVGUI_CanvasPort* thePort)
521 {
522   QPoint p = thePort->getConnectionPoint();
523   if (myPort && myPort == thePort) {
524     myPrs.first()->move(p.x(), p.y());
525     return;
526   }
527 }
528
529
530 //===============================================================================
531 //  SUPERVGUI_CanvasPointPrs: link point presentation
532 //===============================================================================
533 SUPERVGUI_CanvasPointPrs::SUPERVGUI_CanvasPointPrs(QCanvas* theCanvas, 
534                                                    SUPERVGUI_CanvasLink* theLink,
535                                                    const int& theIndex):
536   QCanvasEllipse(theCanvas),
537   myLink(theLink), myIndex(theIndex),
538   myInEdge(0), myOutEdge(0), myMoving(false)
539 {
540   setSize(POINT_SIZE, POINT_SIZE);
541   setZ(-1);
542 }
543
544 int SUPERVGUI_CanvasPointPrs::rtti() const
545 {
546   return SUPERVGUI_Canvas::Rtti_LinkPoint;
547 }
548
549 void SUPERVGUI_CanvasPointPrs::setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge)
550 {
551   myInEdge = theEdge;
552   theEdge->setFromPoint(this);
553 }
554
555 void SUPERVGUI_CanvasPointPrs::setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge)
556 {
557   myOutEdge = theEdge;
558   theEdge->setToPoint(this); 
559 }
560
561 void SUPERVGUI_CanvasPointPrs::moveBy(double dx, double dy)
562 {
563   QCanvasEllipse::moveBy(dx, dy);
564   if (myInEdge) myInEdge->setFromPoint(this);
565   if (myOutEdge) myOutEdge->setToPoint(this);
566   //resize canvas view if mouse is outside
567   int w = (int)(x()+dx) + width() + GRAPH_MARGIN;
568   int h = (int)(y()+dy) + height() + GRAPH_MARGIN;
569   if (canvas()->width() > w) w = canvas()->width();
570   if (canvas()->height() > h) h = canvas()->height();
571   if (canvas()->width() < w || canvas()->height() < h) canvas()->resize(w, h);
572   if (myIndex > 0 && isMoving()) {
573     myLink->getEngine()->ChangeCoord(myIndex, (int)x(), (int)y());
574   }
575 }
576
577 void SUPERVGUI_CanvasPointPrs::setColor(const QColor& theColor)
578 {
579   setBrush(theColor);
580 }
581
582 //===============================================================================
583 //  SUPERVGUI_CanvasEdgePrs: link edge presentation
584 //===============================================================================
585 SUPERVGUI_CanvasEdgePrs::SUPERVGUI_CanvasEdgePrs(QCanvas* theCanvas, 
586                                                  SUPERVGUI_CanvasLink* theLink):
587   QCanvasLine(theCanvas),
588   myLink(theLink)
589 {
590   setZ(-2);
591 }
592
593 int SUPERVGUI_CanvasEdgePrs::rtti() const
594 {
595   return SUPERVGUI_Canvas::Rtti_LinkEdge;
596 }
597
598 void SUPERVGUI_CanvasEdgePrs::setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint)
599 {
600   myStartPoint = thePoint;
601   setPoints((int)(thePoint->x()), (int)(thePoint->y()), endPoint().x(), endPoint().y());
602 }
603
604 void SUPERVGUI_CanvasEdgePrs::setToPoint(SUPERVGUI_CanvasPointPrs* thePoint)
605 {
606   myEndPoint = thePoint;
607   setPoints(startPoint().x(), startPoint().y(), (int)(thePoint->x()), (int)(thePoint->y()));
608 }
609
610 void SUPERVGUI_CanvasEdgePrs::setColor(const QColor& theColor)
611 {
612   setPen(QPen(theColor, LINE_WIDTH));
613 }
614
615 void SUPERVGUI_CanvasEdgePrs::moveBy(double dx, double dy)
616 {
617   //mkr: for moving segment of link
618   if (myStartPoint && myEndPoint) {
619     myStartPoint->setMoving(true);
620     myStartPoint->moveBy(dx, dy);
621     
622     myEndPoint->setMoving(true);
623     myEndPoint->moveBy(dx,dy);
624   }
625 }
626