34 #include "../../../color/RGBAColor.h"
35 #include "../../../../qt/widgets/Utils.h"
36 #include "../../../../geometry/Envelope.h"
37 #include "../../../../common/STLUtils.h"
42 #include <QGraphicsSceneMouseEvent>
43 #include <QStyleOptionGraphicsItem>
46 QGraphicsItemGroup(0, 0),
49 this->setFlags(QGraphicsItem::ItemIsMovable
50 | QGraphicsItem::ItemIsSelectable
51 | QGraphicsItem::ItemSendsGeometryChanges);
53 QGraphicsItem* item =
this;
57 setAcceptHoverEvents(
true);
94 pixmp.fill(Qt::transparent);
95 pixmp = QPixmap::fromImage(*img);
113 QPointF posF = scenePos();
114 qreal valuex = posF.x();
115 qreal valuey = posF.y();
118 coordinate.
x = valuex;
119 coordinate.
y = valuey;
126 QGraphicsItemGroup::addToGroup(item);
128 QRectF chRect = childrenBoundingRect();
132 chRect.y() + childrenBoundingRect().height()));
137 QGraphicsItem::mouseMoveEvent(event);
142 QGraphicsItem::mousePressEvent(event);
146 QList<QGraphicsItem*> graphicsItems = childItems();
147 foreach( QGraphicsItem *item, graphicsItems)
151 if(item->contains(event->scenePos()))
161 QGraphicsItem::mouseReleaseEvent(event);
178 drawBackground( painter );
182 boundRect = boundingRect();
186 painter->translate( -boundRect.width() / 2.0, -boundRect.height() / 2.0 );
187 painter->drawPixmap(boundRect, m_pixmap, QRectF( 0, 0, m_pixmap.width(), m_pixmap.height() ));
191 if (option->state & QStyle::State_Selected)
193 drawSelection(painter);
204 painter->setPen( Qt::NoPen );
205 painter->setRenderHint( QPainter::Antialiasing,
true );
217 qreal penWidth = painter->pen().widthF();
219 const qreal adj = penWidth / 2;
220 const QColor fgcolor(255,255,255);
221 const QColor backgroundColor(0,0,0);
224 painter->setBrush(Qt::NoBrush);
225 painter->drawRect(boundingRect().adjusted(adj, adj, -adj, -adj));
228 painter->setBrush(Qt::NoBrush);
229 painter->drawRect(boundingRect().adjusted(adj, adj, -adj, -adj));
241 QGraphicsItem::setZValue(z);
247 return QGraphicsItem::zValue();
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
double getWidth() const
It returns the envelope width.
ItemGroup(ItemController *controller, Observable *o)
An utility struct for representing 2D coordinates.
virtual int getZValueItem()
virtual void updateObserver(ContextItem context)
te::color::RGBAColor ** getPixmap()
void drawBackground(QPainter *painter)
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
An Envelope defines a 2D rectangular region.
virtual void insertItem(ItemObserver *item)=0
void drawSelection(QPainter *painter)
virtual te::gm::Envelope viewportBox(te::gm::Envelope box)
virtual void addToGroup(QGraphicsItem *item)
virtual void setPosition(const double &x, const double &y)
void setPixmap(const QPixmap &pixmap)
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
AbstractScene * getScene()
virtual te::gm::Envelope getBox()
virtual bool contains(const QPointF &point) const
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
static Context * getInstance()
This function is called to create an instance of the class.
virtual bool contains(const te::gm::Coord2D &coord) const
virtual void setBox(te::gm::Envelope box)
double getHeight() const
It returns the envelope height.
bool isValid() const
It tells if the rectangle is valid or not.
virtual te::gm::Coord2D getPosition()