30 #include "../../core/pattern/mvc/ItemController.h"
31 #include "../../core/AbstractScene.h"
32 #include "../../core/pattern/mvc/Observable.h"
33 #include "../../../color/RGBAColor.h"
34 #include "../../../qt/widgets/Utils.h"
35 #include "../../../geometry/Envelope.h"
36 #include "../../../common/STLUtils.h"
42 #include <QTextDocument>
43 #include <QStyleOptionGraphicsItem>
44 #include <QTextCursor>
45 #include <QAbstractTextDocumentLayout>
46 #include <QGraphicsSceneMouseEvent>
48 #include <QMessageBox>
53 m_nameClass = std::string(this->metaObject()->className());
70 drawBackground(painter);
75 if (option->state & QStyle::State_Selected)
77 drawSelection(painter);
83 QPointF centerBoundRect = boundingRect().center();
84 double xWidth = (boundingRect().width()/2) / 2;
85 double yHeight = (boundingRect().height()/2) / 2;
87 QRectF boundRect(centerBoundRect.x() - xWidth, centerBoundRect.y() - yHeight, boundingRect().width()/2, boundingRect().height()/2);
91 painter->drawRect(boundRect);
93 QPainterPath balloonPath;
95 double arrowWidth = 25.;
96 double arrowHeight = 15;
98 double x = m_endPoint.x();
99 double y = m_endPoint.y();
106 poly.append(QPointF(x, y));
107 poly.append(QPointF(x - arrowWidth / 2, y - arrowHeight));
108 poly.append(QPointF(x + arrowWidth / 2, y - arrowHeight));
109 poly.append(QPointF(x, y));
111 balloonPath.addPolygon(poly);
120 m_initPoint = QPointF(event->pos());
121 QGraphicsItem::mousePressEvent(event);
126 QGraphicsItem::mouseMoveEvent(event);
131 m_endPoint = QPointF(event->pos());
132 QGraphicsItem::mouseReleaseEvent(event);
Abstract class to represent an observable. "Model" part of MVC component.
virtual void drawBalloon(QPainter *painter)
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsItem.
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
Abstract class that represents a graphic item. This object is of type QGraphicsObject.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Reimplemented from QGraphicsItem.
std::string m_nameClass
Class name.
BalloonItem(ItemController *controller, Observable *o)
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsItem.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsItem.