YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
arrow.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
10/****************************************************************************
11**
12** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
13** Contact: http://www.qt-project.org/legal
14**
15** This file is part of the examples of the Qt Toolkit.
16**
17** $QT_BEGIN_LICENSE:BSD$
18** You may use this file under the terms of the BSD license as follows:
19**
20** "Redistribution and use in source and binary forms, with or without
21** modification, are permitted provided that the following conditions are
22** met:
23** * Redistributions of source code must retain the above copyright
24** notice, this list of conditions and the following disclaimer.
25** * Redistributions in binary form must reproduce the above copyright
26** notice, this list of conditions and the following disclaimer in
27** the documentation and/or other materials provided with the
28** distribution.
29** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
30** of its contributors may be used to endorse or promote products derived
31** from this software without specific prior written permission.
32**
33**
34** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
45**
46** $QT_END_LICENSE$
47**
48****************************************************************************/
49
50
51#include "arrow.h"
52#include "destinationportitem.h"
53#include "sourceportitem.h"
54
55#include <cmath>
56
57#include <QPen>
58#include <QPainter>
59#include <QGraphicsDropShadowEffect>
60#include <QStyleOptionGraphicsItem>
61#include <QDebug>
62
63#define AUTOSNIPE_MARGINE 5
64
65const qreal Pi = 3.14;
66
67
68
69Arrow::Arrow(BuilderItem *startItem, BuilderItem *endItem,int id, Manager *safeManager,
70 bool isInApp,bool editingMode, BuilderItem *parent) :
71 BuilderItem(parent),
72 manager(safeManager),
73 externalSelection(false),
74 editingMode(editingMode),
75 connected(false),
76 myStartItem(startItem),
77 myEndItem(endItem),
78 myColor(Qt::black),
79 textLbl("",this),
80 textWidth(0),
81 id(id)
82{
84 nestedInApp = isInApp;
86 setFlag(ItemIsSelectable,true);
87 setFlag(ItemClipsToShape,false);
88 setToolTip(QString("%1 --> %2").arg(myStartItem->itemName).arg(myEndItem->itemName));
89 textLbl.setFlag(ItemIsMovable,!nestedInApp);
90 textLbl.setFlag(ItemSendsGeometryChanges,!nestedInApp);
91}
92
94{
95 hide();
96 setToolTip("");
97 startItem()->removeArrow(this);
98 endItem()->removeArrow(this);
99 handleList.clear();
100
101 if(editingMode && manager){
102 Application* mainApplication = manager->getKnowledgeBase()->getApplication();
103 manager->getKnowledgeBase()->removeConnectionFromApplication(mainApplication, connection);
104 }
105}
106
108{
109 return &model;
110}
111
113{
114 connection = conn;
115 QString label = connection.carrier();
116 if(!label.isEmpty()){
117 textLbl.setText(label);
118 }
119 QFontMetrics fontMetric(font);
120#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
121 textWidth = fontMetric.horizontalAdvance(label);
122#else
123 textWidth = fontMetric.width(label);
124#endif
125
126 GraphicModel mod = connection.getModelBase();
127 if(mod.points.size() > 0){
128 GyPoint p = mod.points[0];
129 if(p.x >= 0 && p.y >= 0){
130 textLbl.setHasMoved(true);
131 textLbl.setPos(p.x,p.y);
132 }
133 if(mod.points.size() > 3){
134 // Handles
135 startP = mapFromItem(myStartItem,myStartItem->connectionPoint());
136 endP = mapFromItem(myEndItem,myEndItem->connectionPoint());
137 polyline.clear();
138 polyline.prepend(startP);
139
140 for(unsigned int i=2; i<mod.points.size() - 1;i++){
141 GyPoint p = mod.points[i];
142 QPointF point(p.x,p.y);
143 auto* handle = new LineHandle(point,this);
144 handleList.append(handle);
145 polyline.append(point);
146 qDebug() << "APPENDING " << handle;
147 }
148 polyline.append(endP);
149 boundingPolyline = polyline;
150 }
151 }
152
153 update();
154}
155
156void Arrow::updateCarrier(QString carrier)
157{
158 if(!editingMode){
159 return;
160 }
161 Application* mainApplication = nullptr;
162 mainApplication = manager->getKnowledgeBase()->getApplication();
163 manager->getKnowledgeBase()->removeConnectionFromApplication(mainApplication, connection);
164
165 connection.setCarrier(carrier.toLatin1().data());
166
167 connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
168 emit sigHandler->modified();
169}
170
172{
173 if(!editingMode){
174 return;
175 }
176 Application* mainApplication = nullptr;
177 mainApplication = manager->getKnowledgeBase()->getApplication();
178 Connection updatedCon = connection;
179 updatedCon.setFrom(from.toLatin1().data());
180
181 if(manager->getKnowledgeBase()->updateConnectionOfApplication(mainApplication, connection,updatedCon)){
182 connection = updatedCon;
183 }
184
185// connection.setFrom(from.toLatin1().data());
186
187// connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
188 emit sigHandler->modified();
189}
190
192{
193 if(!editingMode){
194 return;
195 }
196 Application* mainApplication = nullptr;
197 mainApplication = manager->getKnowledgeBase()->getApplication();
198 Connection updatedCon = connection;
199 updatedCon.setTo(to.toLatin1().data());
200
201 if(manager->getKnowledgeBase()->updateConnectionOfApplication(mainApplication, connection,updatedCon)){
202 connection = updatedCon;
203 }
204
205// connection.setTo(to.toLatin1().data());
206// connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
207 emit sigHandler->modified();
208}
209
211{
212 GyPoint startPoint;
213 GyPoint endPoint;
214 GyPoint labelPoint;
215
216 if(!textLbl.hasBeenMoved()){
217 labelPoint.x = -1;
218 labelPoint.y = -1;
219 }else{
220 QPointF p = textLbl.pos();
221 labelPoint.x = p.x();
222 labelPoint.y = p.y();
223 }
224 startPoint.x = (myStartItem->pos()).x();
225 startPoint.y = (myStartItem->pos()).y();
226 endPoint.x = (myEndItem->pos()).x();
227 endPoint.y = (myEndItem->pos()).y();
228
229 Application* mainApplication = nullptr;
230 mainApplication = manager->getKnowledgeBase()->getApplication();
231 manager->getKnowledgeBase()->removeConnectionFromApplication(mainApplication, connection);
232
233 model.points.clear();
234 model.points.push_back(labelPoint);
235 model.points.push_back(startPoint);
236
237 foreach (LineHandle *handle, handleList) {
238 GyPoint point;
239 point.x = handle->handlePoint().x();
240 point.y = handle->handlePoint().y();
241 model.points.push_back(point);
242 }
243
244 model.points.push_back(endPoint);
245 connection.setModel(&model);
246 connection.setModelBase(model);
247
248 connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
249
250}
251
253{
254 if(!editingMode || nestedInApp){
255 return;
256 }
257
260
261 emit sigHandler->modified();
262 emit signalHandler()->moved();
263}
264
266{
267 externalSelection = true;
268 setSelected(selected);
269}
270
272{
273 QPointF startIngPoint;
274
275 return startIngPoint;
276}
277
279{
280 return QString("%1").arg(connection.from());
281}
282
284{
285 return QString("%1").arg(connection.to());
286}
287
288void Arrow::setConnected(bool connected)
289{
290 this->connected = connected;
291 update();
292}
293
295{
296 return id;
297}
298
300{
301 qreal extra = (/*pen().width()*/2 + 30) / 2.0;
302
303 QRectF bRect = QRectF(boundingPolyline.boundingRect())
304 .normalized()
305 .adjusted(-extra, -extra, extra, extra);
306
307 return bRect.united(textLbl.boundingRect());
308}
309
310QPainterPath Arrow::shape() const
311{
312 QPainterPath path;// = QGraphicsItem::shape();
313 QPainterPathStroker pathStroke;
314 pathStroke.setWidth(8);
315 for(int i=0;i<boundingPolyline.count();i++){
316 QPointF p = boundingPolyline.at(i);
317 if(i==0){
318 path.moveTo(p);
319 continue;
320 }
321 path.lineTo(p.x(),p.y());
322 }
323
324 //path.addPolygon(arrowHead);
325 QPainterPath ret = pathStroke.createStroke(path);
326 return ret;
327}
328
330{
331
332 if(boundingPolyline.isEmpty()){
333 boundingPolyline.prepend(mapFromItem(myStartItem,myStartItem->connectionPoint()));
334 boundingPolyline.append( mapFromItem(myEndItem,myEndItem->connectionPoint()));
335 }
336 update();
337}
338
339void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
340 QWidget *)
341{
342 qreal arrowSize = 10;
343
344 /************** Polyline *********************/
345 startP = mapFromItem(myStartItem,myStartItem->connectionPoint());
346 endP = mapFromItem(myEndItem,myEndItem->connectionPoint());
347 polyline.clear();
348
349 polyline.prepend(startP);
350 foreach (LineHandle *handle, handleList) {
351 QPointF handlePoint = handle->handlePoint();
352 polyline.append(handlePoint);
353 if(isSelected() && !isNestedInApp()){
354 handle->show();
355 }else{
356 handle->hide();
357 }
358
359 }
360 polyline.append(endP);
361 boundingPolyline = polyline;
362 /************** Polyline *********************/
363
364
365 QLineF lastLine(polyline.at(polyline.count()-2),
366 polyline.last());
367 QPointF p1 = lastLine.p1();
368 QPointF p2 = lastLine.p2();
369
370 QLineF line = QLineF(p2,p1);
371
372 double angle = ::acos(line.dx() / line.length());
373 if (line.dy() >= 0){
374 angle = (Pi * 2) - angle;
375 }
376
377 QPointF arrowP1 = line.p1() + QPointF(sin(angle + Pi / 3) * arrowSize,
378 cos(angle + Pi / 3) * arrowSize);
379 QPointF arrowP2 = line.p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
380 cos(angle + Pi - Pi / 3) * arrowSize);
381
382 arrowHead.clear();
383 arrowHead << line.p1() << arrowP1 << arrowP2;
384 if (isSelected()) {
385 painter->setPen(QPen(Qt::blue, 1, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin));
386 }else{
387 if(connected){
388 painter->setPen(QPen(Qt::green, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
389 }else{
390 painter->setPen(QPen(Qt::red, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
391 }
392
393
394 }
395 if(connected){
396 painter->setBrush(Qt::green);
397 }else{
398 painter->setBrush(Qt::red);
399 }
400 painter->drawPolyline(polyline);
401 painter->drawPolygon(arrowHead);
402
403
404 if(!textLbl.hasBeenMoved()){
405 QPointF centerP = QPointF((p1.x() + p2.x())/2 - textWidth/2,((p1.y() + p2.y())/2) - 5);
406 textLbl.setPos(centerP);
407
408
409 }
410
411
412
413}
414
415void Arrow::mousePressEvent(QGraphicsSceneMouseEvent *event)
416{
417 pressed = true;
418 if(!nestedInApp){
419 setFlag(ItemIsMovable,true);
420 }
421 BuilderItem::mousePressEvent(event);
422
423}
424
425
426void Arrow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
427{
428
429 pressed = false;
430 if(!nestedInApp){
431 setFlag(ItemIsMovable,false);
432 }
433 BuilderItem::mouseReleaseEvent(event);
434}
435void Arrow::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
436{
437
438 moved = true;
439 if(!nestedInApp){
440 setFlag(ItemIsMovable,false);
441 }
442 BuilderItem::mouseMoveEvent(event);
443}
444
445
446
447void Arrow::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
448{
449 if(!nestedInApp){
450 QPointF clickPos = event->pos();
451 addHandle(clickPos);
452
454 }
455
456 QGraphicsItem::mouseDoubleClickEvent(event);
457}
458
459void Arrow::addHandle(QPointF clickPos)
460{
461 auto* handle = new LineHandle(clickPos,this);
462 handle->setSelected(true);
463 if(handleList.isEmpty()){
464 handleList.append(handle);
465 }else{
466 bool inserted = false;
467 for(int i=0;i<handleList.count();i++){
468 LineHandle *hndl = handleList.at(i);
469 if(hndl->x() > clickPos.x()){
470 handleList.insert(i,handle);
471 inserted = true;
472 break;
473 }
474 }
475 if(!inserted){
476 handleList.append(handle);
477 }
478 }
479 updateModel();
480}
481
483{
484 handleList.removeOne(handle);
485 updateModel();
486}
487QList <LineHandle*> Arrow::handles()
488{
489 return handleList;
490}
491
492QVariant Arrow::itemChange(GraphicsItemChange change, const QVariant &value)
493{
494 if (change == QGraphicsItem::ItemPositionChange) {
495 if(pressed){
496 setFlag(ItemIsMovable,false);
497 }
498 }
499 if (change == QGraphicsItem::ItemSelectedHasChanged) {
500 if(!externalSelection){
502 }
503 externalSelection = false;
504 }
505
506 return value;
507}
508
510{
511 for(int i=0;i<handleList.count();i++) {
512 LineHandle *h = handleList.at(i);
513 if(h == handle){
514 return i;
515 }
516 }
517
518 return -1;
519}
520
522{
523 if(index >= 0 && index <= handleList.count() - 1){
524 return handleList.at(index);
525 }
526 return nullptr;
527}
528
529/******************************************************************/
530
531LineHandle::LineHandle(QPointF center, Arrow *parent) : QGraphicsRectItem(parent)
532{
533 this->parent = parent;
534 setFlag(ItemIsSelectable,true);
535 setFlag(ItemIsMovable,true);
536 setFlag(ItemSendsGeometryChanges,true);
537
538 rectSize = 8;
539 setRect( - rectSize/2, -rectSize/2, rectSize,rectSize);
540 setPos(center);
541 setPen(QPen(QColor(Qt::black),1));
542 setBrush(QBrush(QColor(Qt::red)));
543
544
545 offset = QPointF(0,0);
546 pressed = false;
547 ctrlPressed = false;
548 this->center = center;
549 qDebug() << "CENTER CREATED IN " << center;
550}
551
552LineHandle::~LineHandle() = default;
553
554QPointF LineHandle::computeTopLeftGridPoint(const QPointF &pointP){
555 int gridSize = 16;
556 qreal xV = gridSize/2 + floor(pointP.x()/gridSize)*gridSize;
557 qreal yV = gridSize/2 + floor(pointP.y()/gridSize)*gridSize;
558 return {xV, yV};
559}
560
561
563{
564 return pos();
565}
566
567void LineHandle::mousePressEvent(QGraphicsSceneMouseEvent *event)
568{
569 pressed = true;
570 QPainterPath newPath;
571
572 if(event->modifiers() == Qt::ControlModifier){
573 ctrlPressed = true;
574 }else{
575 ctrlPressed = false;
576 }
577
578 newPath.addRect(pos().x() + rect().x() - 2,
579 pos().y() + rect().y() - 2 ,
580 rect().width() + 4,
581 rect().height()+4);
582
583 scene()->setSelectionArea(newPath);
584 parent->update();
585 QGraphicsRectItem::mousePressEvent(event);
586}
587
588void LineHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
589{
590 if(pressed){
591
592 if(event->modifiers() == Qt::ControlModifier){
593 ctrlPressed = true;
594 }else{
595 ctrlPressed = false;
596 }
597
598 parent->updatePosition();
599 }
600
601 QGraphicsRectItem::mouseMoveEvent(event);
602}
603
604void LineHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
605{
606 pressed = false;
607 ctrlPressed = false;
608 parent->setSelected(true);
609 parent->updateModel();
610 QGraphicsRectItem::mouseReleaseEvent(event);
611}
612
613QVariant LineHandle::itemChange(GraphicsItemChange change, const QVariant &value)
614{
615 QVariant val = value;
616 if (change == QGraphicsItem::ItemPositionChange && pressed) {
617 if(parent->snap){
618 QPointF newPos = parent->mapToScene(value.toPointF());
619 QPointF closestPoint = computeTopLeftGridPoint(newPos);
620 QPointF ret = parent->mapFromScene(closestPoint);
621
622 val = ret;
623 }
624 if(ctrlPressed){
625 int index = parent->getHandleIndex(this);
626 if( index >= 0){
627 QPointF current_point, base_point;
628 float dist;
629 bool modified = false;
630
631 current_point = mapToItem(parent,val.toPointF());
632 // adjusting to the previous point
633 LineHandle *h = parent->getLineHandle(index-1);
634 if(h){
635 base_point = mapToItem(parent,h->pos());
636 }else{
637 base_point = mapToItem(parent,parent->mapFromItem(parent->startItem(),parent->startItem()->connectionPoint()));
638 }
639
640 dist = current_point.y() - base_point.y();
641
642 if (::fabs(dist) <= AUTOSNIPE_MARGINE) {
643 modified = true;
644 current_point = QPointF(current_point.x(), current_point.y() -dist);
645 }
646 dist = current_point.x() - base_point.x();
647 if (::fabs(dist) <= AUTOSNIPE_MARGINE) {
648 modified = true;
649 //moveBy(-dist, 0);
650 current_point = QPointF(current_point.x()-dist, current_point.y());
651 }
652
653
654
655 // adjusting to the next point
656 h = parent->getLineHandle(index+1);
657 if(h){
658 base_point = mapToItem(parent,h->pos());
659 }else{
660 base_point = mapToItem(parent,parent->mapFromItem(parent->endItem(),parent->endItem()->connectionPoint()));
661 }
662 dist = current_point.y() - base_point.y();
663 if (::fabs(dist) <= AUTOSNIPE_MARGINE) {
664 modified = true;
665 current_point = QPointF(current_point.x(), current_point.y() -dist);
666 }
667 dist = current_point.x() - base_point.x();
668 if (::fabs(dist) <= AUTOSNIPE_MARGINE) {
669 modified = true;
670 //moveBy(-dist, 0);
671 current_point = QPointF(current_point.x()-dist, current_point.y());
672 }
673
674
675
676
677 if(modified){
678 val = mapFromItem(parent,current_point);
679 }
680 }
681 }
682 }
683
684 return val;
685}
686
687void LineHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
688 QWidget *)
689{
690 QRectF myRect = rect();
691
692 if(isSelected()){
693 painter->setPen(QPen(QColor(Qt::black),1,Qt::DashLine));
694 painter->setBrush(QBrush(QColor(Qt::blue)));
695 }else{
696 painter->setPen(QPen(QColor(Qt::black),1));
697 painter->setBrush(QBrush(QColor(Qt::red)));
698 }
699
700
701 painter->drawRect(myRect);
702}
703
704
705/**********************************************************************/
706
707Label::Label(QString label, QGraphicsItem *parent) : QGraphicsTextItem(label,parent)
708{
709
710 sigHandler = new ItemSignalHandler((QGraphicsItem*)this,ArrowLabelItemType,nullptr);
711 comboWidget = new QGraphicsProxyWidget(this);
712 auto* combo = new QComboBox();
713 combo->setEditable(true);
714 parentArrow = (Arrow*)parent;
715 QObject::connect(combo,SIGNAL(activated(QString)),
716 sigHandler,SLOT(onConnectionComboChanged(QString)));
717
718 combo->addItem("tcp");
719 combo->addItem("udp");
720
721 comboWidget->setWidget(combo);
722 comboWidget->setVisible(false);
723
724 setFlag(ItemIsMovable,!parentArrow->nestedInApp);
725 setFlag(ItemIsSelectable,true);
726 setFlag(ItemSendsGeometryChanges,!parentArrow->nestedInApp);
727
728
729 pressed = false;
730 moved = false;
731 hasMoved = false;
732 offset = QPointF(0,0);
733
734 setText(label);
735
736 parentArrow->update();
737
738}
739
740Label::~Label() = default;
741
742void Label::setHasMoved(bool moved)
743{
744 hasMoved = moved;
745}
746
748{
749 return hasMoved;
750}
751
753{
754 return text;
755}
756void Label::setText(QString label)
757{
758 this->text = label;
759 setPlainText(label);
760 if(((QComboBox*)comboWidget->widget())->findText(label) == -1){
761 ((QComboBox*)comboWidget->widget())->addItem(label);
762 }
763
764}
765
767 setPlainText(text);
768 comboWidget->setVisible(false);
770}
771void Label::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event){
772 if(!parentArrow->editingMode || parentArrow->nestedInApp){
773 return;
774 }
775 if(comboWidget->isVisible()){
776 comboWidget->setVisible(false);
777 }else{
778 comboWidget->setVisible(true);
779 }
780 QGraphicsTextItem::mouseDoubleClickEvent(event);
781}
782
783void Label::mousePressEvent(QGraphicsSceneMouseEvent *event)
784{
785 pressed = true;
786 parentArrow->setSelected(true);
787 QGraphicsItem::mousePressEvent(event);
788}
789void Label::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
790{
791
792 if(moved){
794 }
795 parentArrow->setSelected(true);
796 pressed = false;
797 moved = false;
798
799
800 QGraphicsItem::mouseReleaseEvent(event);
801}
802
803void Label::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
804{
805 if(pressed){
806 moved = true;
807 hasMoved = true;
808
809 }
810 QGraphicsItem::mouseMoveEvent(event);
811}
812
813QVariant Label::itemChange(GraphicsItemChange change, const QVariant &value)
814{
815
816 if (change == QGraphicsItem::ItemPositionChange) {
817 if(parentArrow->snap && hasMoved){
818 QPointF newPos = value.toPointF();
819 QPointF closestPoint = computeTopLeftGridPoint(newPos);
820
821 return closestPoint+=offset;
822 }
823
824 }
825 if (change == QGraphicsItem::ItemSelectedHasChanged) {
826 bool selected = isSelected();
828
829 if(!selected){
830 comboWidget->setVisible(false);
831 }
832 }
833
834 return value;
835}
836
837
838QPointF Label::computeTopLeftGridPoint(const QPointF &pointP){
839 int gridSize = 16;
840 qreal xV = gridSize/2 + floor(pointP.x()/gridSize)*gridSize;
841 qreal yV = gridSize/2 + floor(pointP.y()/gridSize)*gridSize;
842 return {xV, yV};
843}
bool ret
int SIGNAL(int pid, int signum)
#define AUTOSNIPE_MARGINE
Original license follows:
Definition arrow.cpp:63
const qreal Pi
Definition arrow.cpp:65
Definition arrow.h:106
void updateModel()
Definition arrow.cpp:252
void updateConnectionTo(QString to)
Definition arrow.cpp:191
QPointF connectionPoint() override
Definition arrow.cpp:271
void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override
Definition arrow.cpp:435
void setConnectionSelected(bool selected)
Definition arrow.cpp:265
void updateCarrier(QString carrier)
Definition arrow.cpp:156
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override
Definition arrow.cpp:426
void updatePosition()
Definition arrow.cpp:329
int getHandleIndex(LineHandle *handle)
Definition arrow.cpp:509
void addHandle(QPointF clickPos)
Definition arrow.cpp:459
~Arrow()
Definition arrow.cpp:93
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Definition arrow.cpp:492
GraphicModel * getModel()
Definition arrow.cpp:107
QPainterPath shape() const override
Definition arrow.cpp:310
BuilderItem * startItem() const
Definition arrow.h:132
QString getFrom()
Definition arrow.cpp:278
LineHandle * getLineHandle(int index)
Definition arrow.cpp:521
friend class LineHandle
Definition arrow.h:109
QString getTo()
Definition arrow.cpp:283
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) override
Definition arrow.cpp:339
void removeHandle(LineHandle *)
Definition arrow.cpp:482
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:447
void updateConnectionFrom(QString from)
Definition arrow.cpp:171
QList< LineHandle * > handles()
Definition arrow.cpp:487
void mousePressEvent(QGraphicsSceneMouseEvent *e) override
Definition arrow.cpp:415
BuilderItem * endItem() const
Definition arrow.h:133
int getId()
Definition arrow.cpp:294
void updateGraphicModel()
Definition arrow.cpp:210
QRectF boundingRect() const override
Definition arrow.cpp:299
void setConnection(const Connection &conn)
Definition arrow.cpp:112
void setConnected(bool)
Definition arrow.cpp:288
ItemSignalHandler * sigHandler
Definition builderitem.h:90
void removeArrow(Arrow *arrow)
QString itemName
Definition builderitem.h:75
friend class Arrow
Definition builderitem.h:31
bool nestedInApp
Definition builderitem.h:88
ItemSignalHandler * signalHandler()
virtual QPointF connectionPoint()=0
bool isNestedInApp()
ItemType itemType
Definition builderitem.h:74
void connectctionSelected(QGraphicsItem *it)
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Definition arrow.cpp:813
void currentComboTextChanged(QString text)
Definition arrow.cpp:766
bool pressed
Definition arrow.h:99
QString text
Definition arrow.h:95
bool moved
Definition arrow.h:97
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:783
void setText(QString)
Definition arrow.cpp:756
Arrow * parentArrow
Definition arrow.h:100
bool hasMoved
Definition arrow.h:98
void setHasMoved(bool)
Definition arrow.cpp:742
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:789
QPointF computeTopLeftGridPoint(const QPointF &pointP)
Definition arrow.cpp:838
QString labelText()
Definition arrow.cpp:752
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:771
bool hasBeenMoved()
Definition arrow.cpp:747
ItemSignalHandler * sigHandler
Definition arrow.h:96
Label(QString label, QGraphicsItem *parent=0)
Definition arrow.cpp:707
QGraphicsProxyWidget * comboWidget
Definition arrow.h:94
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:803
QPointF offset
Definition arrow.h:101
QPointF computeTopLeftGridPoint(const QPointF &pointP)
Definition arrow.cpp:554
QPointF handlePoint()
Definition arrow.cpp:562
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:588
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:604
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Definition arrow.cpp:613
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) override
Definition arrow.cpp:687
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Definition arrow.cpp:567
LineHandle(QPointF center, Arrow *parent=0)
Definition arrow.cpp:531
Class Application.
Class Connection.
Definition application.h:56
void setTo(const char *szTo)
Definition application.h:81
void setCarrier(const char *szCr)
Definition application.h:82
GraphicModel & getModelBase()
void setModelBase(GraphicModel &mdl)
void setFrom(const char *szFrom)
Definition application.h:80
void setModel(GraphicModel *mdl)
std::vector< GyPoint > points
Definition node.h:29
bool updateConnectionOfApplication(Application *application, Connection &prev, Connection &con)
Definition kbase.cpp:598
bool removeConnectionFromApplication(Application *application, Connection &cnn)
Definition kbase.cpp:634
Connection & addConnectionToApplication(Application *application, Connection &cnn)
Definition kbase.cpp:562
Application * getApplication()
Definition kbase.h:84
Class Manager.
Definition manager.h:20
KnowledgeBase * getKnowledgeBase()
Definition manager.h:103
@ ConnectionItemType
Definition commons.h:17
@ ArrowLabelItemType
Definition commons.h:17