1 #include "qnstgraphicsbind.h"
7 setnstType(Qnst::Condition);
9 setType(Qnst::NoBindType);
18 QnstGraphicsBind::~QnstGraphicsBind()
23 void QnstGraphicsBind::setType(Qnst::BindType type)
31 setnstType(Qnst::Action);
32 this->icon =
":/icon/start";
36 setnstType(Qnst::Action);
37 this->icon =
":/icon/stop";
41 setnstType(Qnst::Action);
42 this->icon =
":/icon/resume";
46 setnstType(Qnst::Action);
47 this->icon =
":/icon/pause";
51 setnstType(Qnst::Action);
52 this->icon =
":/icon/set";
57 setnstType(Qnst::Condition);
58 this->icon =
":/icon/onbegin";
62 setnstType(Qnst::Condition);
63 this->icon =
":/icon/onend";
67 setnstType(Qnst::Condition);
68 this->icon =
":/icon/onresume";
72 setnstType(Qnst::Condition);
73 this->icon =
":/icon/onpause";
76 case Qnst::onSelection:
77 setnstType(Qnst::Condition);
78 this->icon =
":/icon/onselection";
82 if(getnstType() == Qnst::Action)
83 this->icon =
":/icon/noaction";
85 this->icon =
":/icon/nocondition";
90 Qnst::BindType QnstGraphicsBind::getType()
95 QString QnstGraphicsBind::getIcon()
100 void QnstGraphicsBind::adjust()
108 void QnstGraphicsBind::adjust_action()
110 if (getEntityA() != NULL && getEntityB() != NULL)
112 QLineF line = QLineF(QPointF(getEntityA()->getLeft() + getEntityA()->getWidth()/2,
113 getEntityA()->getTop() + getEntityA()->getHeight()/2),
114 QPointF(getEntityB()->getLeft() + getEntityB()->getWidth()/2,
115 getEntityB()->getTop() + getEntityB()->getHeight()/2));
117 if (getEntityA()->getncgType() == Qncg::Interface)
119 line.setP1(getnstGraphicsParent()->mapFromItem(getEntityA()->getnstGraphicsParent(), line.p1()));
122 if (getEntityB()->getncgType() == Qncg::Interface)
124 line.setP2(getnstGraphicsParent()->mapFromItem(getEntityB()->getnstGraphicsParent(), line.p2()));
127 QPointF pointa = line.p1();
128 QPointF pointb = line.p2();
130 aux_adjust(pointa, pointb);
132 getEntityB()->setSelectable(
false);
136 if (pointa != pointb)
142 while(getEntityB()->collidesWithItem(
this))
147 pointb = line.pointAt(index);
149 pointb = arcPointAt(line , index);
151 aux_adjust(pointa, pointb);
159 getEntityB()->setSelectable(
true);
166 void QnstGraphicsBind::adjust_condition()
168 if (getEntityA() != NULL && getEntityB() != NULL)
170 QLineF line = QLineF(QPointF(getEntityA()->getLeft() + getEntityA()->getWidth()/2,
171 getEntityA()->getTop() + getEntityA()->getHeight()/2),
172 QPointF(getEntityB()->getLeft() + getEntityB()->getWidth()/2,
173 getEntityB()->getTop() + getEntityB()->getHeight()/2));
175 if (getEntityA()->getncgType() == Qncg::Interface)
177 line.setP1(getnstGraphicsParent()->mapFromItem(getEntityA()->getnstGraphicsParent(), line.p1()));
180 if (getEntityB()->getncgType() == Qncg::Interface)
182 line.setP2(getnstGraphicsParent()->mapFromItem(getEntityB()->getnstGraphicsParent(), line.p2()));
185 QPointF pointa = line.p1();
186 QPointF pointb = line.p2();
188 aux_adjust(pointa, pointb);
190 getEntityA()->setSelectable(
false);
194 if (pointa != pointb){
200 while(getEntityA()->collidesWithItem(
this))
205 pointa = line.pointAt(index);
207 pointa = arcPointAt(line , index,
false);
209 aux_adjust(pointa, pointb);
216 getEntityA()->setSelectable(
true);
223 void QnstGraphicsBind::aux_adjust(QPointF pointa, QPointF pointb)
225 if (pointa.x() <= pointb.x() && pointa.y() <= pointb.y())
227 setTop(pointa.y()-4);
228 setLeft(pointa.x()-4);
229 setWidth((pointb.x()-4)-(pointa.x()-4) + 8);
230 setHeight((pointb.y()-4)-(pointa.y()-4) + 8);
232 else if (pointa.x() > pointb.x() && pointa.y() < pointb.y())
234 setTop(pointa.y()-4);
235 setLeft(pointb.x()-4);
236 setWidth((pointa.x()-4)-(pointb.x()-4) + 8);
237 setHeight((pointb.y()-4)-(pointa.y()-4) + 8);
239 else if (pointa.x() < pointb.x() && pointa.y() > pointb.y())
241 setTop(pointb.y()-4);
242 setLeft((pointa.x()-4));
243 setWidth((pointb.x()-4)-(pointa.x()-4) + 8);
244 setHeight((pointa.y()-4)-(pointb.y()-4) + 8);
246 else if (pointa.x() > pointb.x() && pointa.y() > pointb.y())
248 setTop(pointb.y()-4);
249 setLeft(pointb.x()-4);
250 setWidth((pointa.x()-4)-(pointb.x()-4) + 8);
251 setHeight((pointa.y()-4)-(pointb.y()-4) + 8);
256 void QnstGraphicsBind::draw(QPainter* painter)
261 draw_action(painter);
264 void QnstGraphicsBind::draw_action(QPainter* painter)
266 if (getEntityA() != NULL && getEntityB() != NULL)
268 painter->setRenderHint(QPainter::Antialiasing,
true);
269 painter->setRenderHint(QPainter::SmoothPixmapTransform,
true);
271 QLineF line = QLineF(QPointF(getEntityA()->getLeft() + getEntityA()->getWidth()/2,
272 getEntityA()->getTop() + getEntityA()->getHeight()/2),
273 QPointF(getEntityB()->getLeft() + getEntityB()->getWidth()/2,
274 getEntityB()->getTop() + getEntityB()->getHeight()/2));
276 if (getEntityA()->getncgType() == Qncg::Interface)
278 line.setP1(getnstGraphicsParent()->mapFromItem(getEntityA()->getnstGraphicsParent(), line.p1()));
281 if (getEntityB()->getncgType() == Qncg::Interface)
283 line.setP2(getnstGraphicsParent()->mapFromItem(getEntityB()->getnstGraphicsParent(), line.p2()));
286 QPointF pointa = line.p1();
287 QPointF pointb = line.p2();
289 if (!isInvalid() && !hasError)
290 painter->setPen(QPen(QBrush(QColor(
"#000000")), 1));
292 painter->setPen(QPen(QBrush(QColor(255,0,0,200)), 1, Qt::DashLine));
294 if (pointa.x() <= pointb.x() && pointa.y() <= pointb.y())
298 qreal drawangle = getAdjAngle();
300 QLineF localline(4+4,4+4, 4+8+getWidth()-16, 4+8+getHeight()-16);
304 drawangle = -drawangle;
307 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
309 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
311 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
312 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
314 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
315 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
317 if (getAdjAngle() < 0)
319 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
320 16*((180-delta-drawangle)+180),16*drawangle);
324 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
325 ,16*(180-delta-drawangle),16*drawangle);
330 painter->drawLine(4+4,4+4, 4+8+getWidth()-16, 4+8+getHeight()-16);
333 painter->setPen(Qt::NoPen);
335 painter->drawPixmap(4+getWidth()-16, 4+getHeight()-16, 16, 16, QPixmap(icon));
337 if (!isInvalid() && !hasError)
339 painter->setBrush(QBrush(QColor(
"#000000")));
343 painter->setBrush(QBrush(QColor(255,0,0,75)));
344 painter->drawEllipse(3+getWidth()-16, 3+getHeight()-16, 18, 18);
347 else if (pointa.x() > pointb.x() && pointa.y() <= pointb.y())
351 qreal drawangle = getAdjAngle();
353 QLineF localline(4+4+getWidth()-8,4+4, 4+8, 4+8+getHeight()-16);
357 drawangle = -drawangle;
360 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
362 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
364 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
365 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
367 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
368 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
370 if (getAdjAngle() < 0)
372 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
373 16*((180-delta-drawangle)+180),16*drawangle);
377 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
378 ,16*(180-delta-drawangle),16*drawangle);
383 painter->drawLine(4+4+getWidth()-8,4+4, 4+8, 4+8+getHeight()-16);
386 painter->setPen(Qt::NoPen);
388 painter->drawPixmap(4, 4+getHeight()-16, 16, 16, QPixmap(icon));
390 if (!isInvalid() && !hasError)
392 painter->setBrush(QBrush(QColor(
"#000000")));
396 painter->setBrush(QBrush(QColor(255,0,0,75)));
397 painter->drawEllipse(3, 3+getHeight()-16, 18, 18);
400 else if (pointa.x() <= pointb.x() && pointa.y() > pointb.y())
404 qreal drawangle = getAdjAngle();
406 QLineF localline(4+4, 4+4+getHeight()-8, 4+8+getWidth()-16, 4+8);
410 drawangle = -drawangle;
413 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
415 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
417 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
418 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
420 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
421 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
423 if (getAdjAngle() < 0)
425 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
426 16*((180-delta-drawangle)+180),16*drawangle);
430 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
431 ,16*(180-delta-drawangle),16*drawangle);
436 painter->drawLine(4+4, 4+4+getHeight()-8, 4+8+getWidth()-16, 4+8);
439 painter->setPen(Qt::NoPen);
441 painter->drawPixmap(4+getWidth()-16,4,16,16, QPixmap(icon));
443 if (!isInvalid() && !hasError)
445 painter->setBrush(QBrush(QColor(
"#000000")));
449 painter->setBrush(QBrush(QColor(255,0,0,75)));
450 painter->drawEllipse(3+getWidth()-16,3,18,18);
453 else if (pointa.x() > pointb.x() && pointa.y() > pointb.y())
455 if (getAngle() != 0){
456 qreal drawangle = getAdjAngle();
458 QLineF localline(4+4+getWidth()-8, 4+4+getHeight()-8, 4+8, 4+8);
462 drawangle = -drawangle;
465 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
467 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
469 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
470 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
472 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
473 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
475 if (getAdjAngle() < 0)
477 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
478 16*((180-delta-drawangle)+180),16*drawangle);
482 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
483 ,16*(180-delta-drawangle),16*drawangle);
488 painter->drawLine(4+4+getWidth()-8, 4+4+getHeight()-8, 4+8, 4+8);
491 painter->setPen(Qt::NoPen);
493 painter->drawPixmap(4,4,16,16, QPixmap(icon));
495 if (!isInvalid() && !hasError)
497 painter->setBrush(QBrush(QColor(
"#000000")));
501 painter->setBrush(QBrush(QColor(255,0,0,75)));
502 painter->drawEllipse(3,3,18,18);
508 void QnstGraphicsBind::draw_condition(QPainter* painter)
510 if (getEntityA() != NULL && getEntityB() != NULL)
512 painter->setRenderHint(QPainter::Antialiasing,
true);
513 painter->setRenderHint(QPainter::SmoothPixmapTransform,
true);
515 QLineF line = QLineF(QPointF(getEntityA()->getLeft() + getEntityA()->getWidth()/2,
516 getEntityA()->getTop() + getEntityA()->getHeight()/2),
517 QPointF(getEntityB()->getLeft() + getEntityB()->getWidth()/2,
518 getEntityB()->getTop() + getEntityB()->getHeight()/2));
520 if (getEntityA()->getncgType() == Qncg::Interface)
522 line.setP1(getnstGraphicsParent()->mapFromItem(getEntityA()->getnstGraphicsParent(), line.p1()));
525 if (getEntityB()->getncgType() == Qncg::Interface)
527 line.setP2(getnstGraphicsParent()->mapFromItem(getEntityB()->getnstGraphicsParent(), line.p2()));
530 QPointF pointa = line.p1();
531 QPointF pointb = line.p2();
533 if (!isInvalid() && !hasError)
534 painter->setPen(QPen(QBrush(QColor(
"#000000")), 1));
536 painter->setPen(QPen(QBrush(QColor(255,0,0,200)), 1, Qt::DashLine));
538 if (pointa.x() <= pointb.x() && pointa.y() <= pointb.y())
542 qreal drawangle = getAdjAngle();
544 QLineF localline(4+8,4+8, 4+getWidth()-4, 4+getHeight()-4);
548 drawangle = -drawangle;
551 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
553 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
555 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
556 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
558 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
559 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
561 if (getAdjAngle() < 0)
563 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
564 16*((180-delta-drawangle)+180),16*drawangle);
568 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
569 ,16*(180-delta-drawangle),16*drawangle);
574 painter->drawLine(4+8,4+8, 4+getWidth()-4, 4+getHeight()-4);
577 painter->setPen(Qt::NoPen);
579 painter->drawPixmap(4,4,16,16, QPixmap(icon));
581 if (!isInvalid() && !hasError)
583 painter->setBrush(QBrush(QColor(
"#000000")));
587 painter->setBrush(QBrush(QColor(255,0,0,75)));
588 painter->drawEllipse(3,3, 18, 18);
591 else if (pointa.x() >= pointb.x() && pointa.y() <= pointb.y())
595 qreal drawangle = getAdjAngle();
597 QLineF localline(4+getWidth()-8,4+8, 4+4, 4+getHeight()-4);
601 drawangle = -drawangle;
604 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
606 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
608 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
609 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
611 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
612 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
614 if (getAdjAngle() < 0)
616 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
617 16*((180-delta-drawangle)+180),16*drawangle);
621 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
622 ,16*(180-delta-drawangle),16*drawangle);
627 painter->drawLine(4+getWidth()-8,4+8, 4+4, 4+getHeight()-4);
630 painter->setPen(Qt::NoPen);
632 painter->drawPixmap(4+getWidth()-16,4,16,16, QPixmap(icon));
634 if (!isInvalid() && !hasError)
636 painter->setBrush(QBrush(QColor(
"#000000")));
640 painter->setBrush(QBrush(QColor(255,0,0,75)));
641 painter->drawEllipse(3+getWidth()-16,3, 18, 18);
644 else if (pointa.x() < pointb.x() && pointa.y() > pointb.y())
648 qreal drawangle = getAdjAngle();
649 QLineF localline(4+8, 4+getHeight()-8, 4+getWidth()-4, 4+4);
653 drawangle = -drawangle;
656 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
658 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
660 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
661 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
663 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
664 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
666 if (getAdjAngle() < 0)
668 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
669 16*((180-delta-drawangle)+180),16*drawangle);
673 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
674 ,16*(180-delta-drawangle),16*drawangle);
679 painter->drawLine(4+8, 4+getHeight()-8, 4+getWidth()-4, 4+4);
682 painter->setPen(Qt::NoPen);
684 painter->drawPixmap(4, 4+getHeight()-16, 16, 16, QPixmap(icon));
686 if (!isInvalid() && !hasError)
688 painter->setBrush(QBrush(QColor(
"#000000")));
692 painter->setBrush(QBrush(QColor(255,0,0,75)));
693 painter->drawEllipse(3, 3+getHeight()-16, 18, 18);
696 else if (pointa.x() > pointb.x() && pointa.y() > pointb.y())
700 qreal drawangle = getAdjAngle();
702 QLineF localline(4+getWidth()-8, 4+getHeight()-8, 4+4, 4+4);
706 drawangle = -drawangle;
709 qreal R = localline.length()/(::sin(((drawangle/2)*PI)/180)*2);
711 qreal delta = (180-drawangle)/2 + (360 - localline.angle());
713 QPointF center_a(localline.p2().x() - ::cos((180-delta-drawangle)*PI/180)*R,
714 localline.p2().y() + ::sin((180-delta-drawangle)*PI/180)*R);
716 QPointF center_b(localline.p1().x() + ::cos((180-delta-drawangle)*PI/180)*R,
717 localline.p1().y() - ::sin((180-delta-drawangle)*PI/180)*R);
719 if (getAdjAngle() < 0)
721 painter->drawArc(center_b.x()-R,center_b.y()-R,2*R,2*R,
722 16*((180-delta-drawangle)+180),16*drawangle);
726 painter->drawArc(center_a.x()-R,center_a.y()-R,2*R,2*R
727 ,16*(180-delta-drawangle),16*drawangle);
732 painter->drawLine(4+getWidth()-8, 4+getHeight()-8, 4+4, 4+4);
735 painter->setPen(Qt::NoPen);
737 painter->drawPixmap(4+getWidth()-16, 4+getHeight()-16, 16, 16, QPixmap(icon));
739 if (!isInvalid() && !hasError)
741 painter->setBrush(QBrush(QColor(
"#000000")));
745 painter->setBrush(QBrush(QColor(255,0,0,75)));
746 painter->drawEllipse(3+getWidth()-16, 3+getHeight()-16, 18, 18);
752 void QnstGraphicsBind::delineate(QPainterPath* painter)
const
757 delineate_action(painter);
760 void QnstGraphicsBind::delineate_action(QPainterPath* painter)
const
762 if (getEntityA() != NULL && getEntityB() != NULL)
764 QLineF line = QLineF(QPointF(getEntityA()->getLeft() + getEntityA()->getWidth()/2,
765 getEntityA()->getTop() + getEntityA()->getHeight()/2),
766 QPointF(getEntityB()->getLeft() + getEntityB()->getWidth()/2,
767 getEntityB()->getTop() + getEntityB()->getHeight()/2));
769 if (getEntityA()->getncgType() == Qncg::Interface)
771 line.setP1(getnstGraphicsParent()->mapFromItem(getEntityA()->getnstGraphicsParent(), line.p1()));
774 if (getEntityB()->getncgType() == Qncg::Interface)
776 line.setP2(getnstGraphicsParent()->mapFromItem(getEntityB()->getnstGraphicsParent(), line.p2()));
779 QPointF pointa = line.p1();
780 QPointF pointb = line.p2();
782 if (pointa.x() <= pointb.x() && pointa.y() <= pointb.y())
784 painter->addEllipse(4+getWidth()-16, 4+getHeight()-16, 16, 16);
786 else if (pointa.x() > pointb.x() && pointa.y() < pointb.y())
788 painter->addEllipse(4, 4+getHeight()-16, 16, 16);
790 else if (pointa.x() < pointb.x() && pointa.y() > pointb.y())
792 painter->addEllipse(4+getWidth()-16,4,16,16);
794 else if (pointa.x() > pointb.x() && pointa.y() > pointb.y())
796 painter->addEllipse(4,4,16,16);
801 void QnstGraphicsBind::delineate_condition(QPainterPath* painter)
const
803 if (getEntityA() != NULL && getEntityB() != NULL)
805 QLineF line = QLineF(QPointF(getEntityA()->getLeft() + getEntityA()->getWidth()/2,
806 getEntityA()->getTop() + getEntityA()->getHeight()/2),
807 QPointF(getEntityB()->getLeft() + getEntityB()->getWidth()/2,
808 getEntityB()->getTop() + getEntityB()->getHeight()/2));
810 if (getEntityA()->getncgType() == Qncg::Interface)
812 line.setP1(getnstGraphicsParent()->mapFromItem(getEntityA()->getnstGraphicsParent(), line.p1()));
815 if (getEntityB()->getncgType() == Qncg::Interface)
817 line.setP2(getnstGraphicsParent()->mapFromItem(getEntityB()->getnstGraphicsParent(), line.p2()));
820 QPointF pointa = line.p1();
821 QPointF pointb = line.p2();
823 if (pointa.x() <= pointb.x() && pointa.y() <= pointb.y())
827 painter->addEllipse(4,4,16,16);
830 else if (pointa.x() > pointb.x() && pointa.y() < pointb.y())
834 painter->addEllipse(4+getWidth()-16,4,16,16);
838 else if (pointa.x() < pointb.x() && pointa.y() > pointb.y())
842 painter->addEllipse(4, 4+getHeight()-16, 16, 16);
845 else if (pointa.x() > pointb.x() && pointa.y() > pointb.y())
849 painter->addEllipse(4+getWidth()-16, 4+getHeight()-16, 16, 16);
854 void QnstGraphicsBind::addParam(QString uid, QString name, QString value)
858 params[name] = value;
859 names_uids[name] = uid;
861 emit bindParamUpdated(getnstUid(), params, names_uids);
865 void QnstGraphicsBind::setParam(QString name, QString value)
869 params[name] = value;
871 emit bindParamUpdated(getnstUid(), params, names_uids);
875 void QnstGraphicsBind::removeUId(QString uid)
877 QString name = names_uids.key(uid);
879 if (params.contains(name))
882 names_uids.remove(name);
884 emit bindParamUpdated(getnstUid(), params, names_uids);
888 void QnstGraphicsBind::removeParam(QString name)
893 names_uids.remove(name);
895 emit bindParamUpdated(getnstUid(), params, names_uids);
904 void QnstGraphicsBind::setParams(QMap<QString, QString> params)
906 this->params = params;
909 void QnstGraphicsBind::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
914 QMap<QString, QString> values;
916 if (params.isEmpty())
920 foreach(QString type, conn->getActions().values())
924 UID = conn->getActions().key(type,
"");
928 QMap<QPair<QString, QString>, QString> parameters = conn->getActionParams();
930 QPair<QString, QString> key;
932 foreach(key , parameters.keys())
934 if (key.first == UID)
936 values[parameters.value(key)] = params.value(parameters.value(key),
"");
943 else if (isCondition())
945 foreach(QString type, conn->getConditions().values())
949 UID = conn->getConditions().key(type,
"");
953 QMap<QPair<QString, QString>, QString> parameters = conn->getConditionParams();
955 QPair<QString, QString> key;
957 foreach(key , parameters.keys())
959 if (key.first == UID)
961 values[parameters.value(key)] = params.value(parameters.value(key),
"");
973 dialog->init(values);
977 params = dialog->getProperties();
979 foreach(QString name, params.keys())
981 QMap<QString, QString> p;
984 p[
"value"] = params[name];
986 if (names_uids[name].isEmpty())
988 names_uids[name] = QUuid::createUuid().toString();
991 emit bindParamAdded(names_uids[name], getnstUid(), p);
994 emit bindParamUpdated(getnstUid(), params, names_uids);
999 qWarning() <<
"[QNST] Connector is NULL. I can not load connectorParams";
1003 bool QnstGraphicsBind::isCondition()
const
1005 return (getnstType() == Qnst::Condition);
1008 bool QnstGraphicsBind::isAction()
const
1010 return !isCondition();
1013 QString QnstGraphicsBind::getRole()
const
1018 void QnstGraphicsBind::setRole(QString role)
1023 QString QnstGraphicsBind::getComponent()
const
1028 void QnstGraphicsBind::setComponent(QString component)
1030 this->component = component;
1033 QString QnstGraphicsBind::getComponentUid()
const
1035 return componentUID;
1038 void QnstGraphicsBind::setComponentUid(QString componentUID)
1040 this->componentUID = componentUID;
1043 QString QnstGraphicsBind::getInterface()
const
1048 void QnstGraphicsBind::setInterface(QString interface)
1050 this->
interface = interface;
1053 QString QnstGraphicsBind::getInterfaceUid()
const
1055 return interfaceUID;
1058 void QnstGraphicsBind::setInterfaceUid(QString interfaceUID)
1060 this->interfaceUID = interfaceUID;
1063 QMap<QString, QString> QnstGraphicsBind::getParams()
1068 QMap<QString, QString> QnstGraphicsBind::getNameUIDs()
1073 void QnstGraphicsBind::setNamesUIDs(QMap<QString, QString> names_uids)
1075 this->names_uids = names_uids;
1096 return getEntityB();
1099 void QnstGraphicsBind::setProperties(
const QMap<QString, QString> &properties)
1101 QnstGraphicsEdge::setProperties(properties);
1103 if(properties.contains(
"role"))
1105 setRole(properties[
"role"]);
1109 if(properties.contains(
"component"))
1110 setComponent(
"component");
1112 if(properties.contains(
"componentUid"))
1113 setComponentUid(properties[
"componentUid"]);
1115 if(properties.contains(
"interface"))
1116 setInterface(properties[
"interface"]);
1118 if(properties.contains(
"interfaceUid"))
1119 setInterfaceUid(properties[
"interfaceUid"]);
1122 void QnstGraphicsBind::getProperties(QMap<QString, QString> &properties)
1124 QnstGraphicsEdge::getProperties(properties);
1126 properties[
"role"] = getRole();
1127 properties[
"component"] = getComponent();
1128 properties[
"componentUid"] = getComponentUid();
1129 properties[
"interface"] = getInterface();
1130 properties[
"interfaceUid"] = getComponentUid();