39 using namespace YACS::ENGINE;
40 using namespace YACS::HMI;
45 QString label,
Subject *subject)
60 _path = QPainterPath();
79 return _path.boundingRect();
91 _path = QPainterPath();
92 _path.setFillRule(Qt::WindingFill);
93 QPointF pfrom =
start();
107 double d = std::sqrt((pto.x() - pfrom.x())*(pto.x() - pfrom.x()) + (pto.y() - pfrom.y())*(pto.y() - pfrom.y()));
108 double sina = (pto.y() - pfrom.y())/d;
109 double cosa = (pto.x() - pfrom.x())/d;
111 _path.moveTo(pfrom.x() -ep*sina, pfrom.y() +ep*cosa);
112 _path.lineTo(pto.x() -ep*sina, pto.y() +ep*cosa);
113 _path.lineTo(pto.x() +ep*sina, pto.y() -ep*cosa);
114 _path.lineTo(pfrom.x() +ep*sina, pfrom.y() -ep*cosa);
115 _path.lineTo(pfrom.x() -ep*sina, pfrom.y() -ep*cosa);
117 double x=(pto.x() + pfrom.x())/2.;
118 double y=(pto.y() + pfrom.y())/2.;
121 _path.moveTo(x+l*cosa,y+l*sina);
122 _path.lineTo(x+e*sina,y-e*cosa);
123 _path.lineTo(x-e*sina,y+e*cosa);
124 _path.lineTo(x+l*cosa,y+l*sina);
133 qreal x, y, width, height, length;
141 height = 2*ep + pto.y() -pfrom.y();
147 width = 2*ep + pto.x() -pfrom.x();
155 height = 2*ep + pfrom.y() -pto.y();
161 width = 2*ep + pfrom.x() -pto.x();
166 _path.addRect(x, y, width, height);
170 int e=5*ep, h1=4*ep, h2=8*ep;
175 y = (pto.y() + pfrom.y())/2 +h1;
177 _path.lineTo(x+e, y-h2);
178 _path.lineTo(x, y-h1);
179 _path.lineTo(x-e, y-h2);
183 x = (pto.x() + pfrom.x())/2 +h1;
186 _path.lineTo(x-h2, y+e);
187 _path.lineTo(x-h1, y );
188 _path.lineTo(x-h2, y-e);
193 y = (pto.y() + pfrom.y())/2 -h1;
195 _path.lineTo(x+e, y+h2);
196 _path.lineTo(x, y+h1);
197 _path.lineTo(x-e, y+h2);
201 x = (pto.x() + pfrom.x())/2 -h1;
204 _path.lineTo(x+h2, y+e);
205 _path.lineTo(x+h1, y );
206 _path.lineTo(x+h2, y-e);
214 const QStyleOptionGraphicsItem *option,
222 painter->setPen(pen);
224 painter->drawPath(
_path);
234 DEBTRACE(
"SceneObserverItem::update EMPHASIZE " << type);
249 QGraphicsItem::update();
252 DEBTRACE(
"SceneObserverItem::update SWITCHSHAPE");
254 QGraphicsItem::update();
269 DEBTRACE(
"SceneLinkItem::setPath " << lp.size());
271 prepareGeometryChange();
275 std::list<linkPoint>::const_iterator it = lp.begin();
281 for (; it != lp.end(); ++it)
283 QPointF
p = mapFromScene(QPointF((*it).x, (*it).y));
284 DEBTRACE(
"p(" << p.x() <<
"," << p.y() <<
")");
294 bool changeDir =
true;
295 if (dirx && (p.y() == prevy))
297 _lp[k-1].setX(p.x());
300 if (diry && (p.x() == prevx))
302 _lp[k-1].setY(p.y());
344 if(
_lp[k].y() == prevy)
356 DEBTRACE(
"_lp[" << k <<
"](" <<
_lp[k].x() <<
"," <<
_lp[k].y() <<
")");
367 vector<QPointF> newlp;
368 vector<Direction> newdir;
372 bool modified =
true;
399 qreal xtop, ytop, width, height;
400 if (
_lp[k].x() <
_lp[k+2].x())
403 width =
_lp[k+2].x() -
_lp[k].x();
408 width =
_lp[k].x() -
_lp[k+2].x();
410 if (
_lp[k].y() <
_lp[k+2].y())
413 height =
_lp[k+2].y() -
_lp[k].y();
418 height =
_lp[k].y() -
_lp[k+2].y();
420 QRectF aRect(mapToScene(QPointF(xtop, ytop)),
421 mapToScene(QPointF(xtop + width, ytop + height)));
422 QList<QGraphicsItem*> itemList = scene()->items(aRect);
423 for (
int kk=0; kk<itemList.size(); kk++)
426 if ((dynamic_cast<SceneElementaryNodeItem*>(item)) ||
436 _lp[k+1] = QPointF(tryx, tryy);
446 newlp[newk].setX(
_lp[k].x());
448 newlp[newk].setY(
_lp[k].y());
453 newlp[newk] =
_lp[k];
460 DEBTRACE(
"modified : _nbPoints=" << _nbPoints <<
" newk=" << newk+1);
487 DEBTRACE(
"_nbPoints " << _nbPoints);
500 vector<QPointF> newlp;
501 vector<Direction> newdir;
508 newlp[0].setY(a.y());
509 newlp[1].setY(b.y());
532 DEBTRACE(
"localFrom(" << localFrom.x() <<
"," << localFrom.y() <<
")");
533 return mapFromItem(dpif, localFrom);
540 DEBTRACE(
"localTo(" << localTo.x() <<
"," << localTo.y() <<
")");
541 return mapFromItem(dpit, localTo);
546 prepareGeometryChange();
550 QPointF pfrom =
start();
551 QPointF pto =
goal();
552 _lp[0].setY(pfrom.y());