6 #include "GeoPhotoGraphicsItem.h"
8 #include "GeoPainter.h"
9 #include "GeoDataStyle.h"
10 #include "GeoDataIconStyle.h"
11 #include "GeoDataFeature.h"
12 #include "StyleBuilder.h"
20 GeoPhotoGraphicsItem::GeoPhotoGraphicsItem(
const GeoDataFeature *feature )
21 : GeoGraphicsItem( feature )
24 QString const paintLayer = QStringLiteral(
"Photo");
29 void GeoPhotoGraphicsItem::paint(GeoPainter* painter,
const ViewportParams* viewport ,
const QString &layer,
int tileZoomLevel)
32 Q_UNUSED(tileZoomLevel);
39 bool unloadImage =
true;
41 qreal x(0.0), y( 0.0 );
42 viewport->screenCoordinates( m_point.coordinates(), x, y );
44 QRectF position(
QPointF( x, y ), style()->iconStyle().icon().size() );
45 position.moveCenter(
QPointF( x, y ) );
50 if ( m_photo.isNull() ) {
51 m_photo = style()->iconStyle().icon();
54 painter->drawImage( position, m_photo );
62 const GeoDataLatLonAltBox& GeoPhotoGraphicsItem::latLonAltBox()
const
64 return m_point.latLonAltBox();
67 bool GeoPhotoGraphicsItem::contains(
const QPoint &curpos,
const ViewportParams *viewport)
const
69 qreal x(0.0), y( 0.0 );
70 viewport->screenCoordinates(m_point.coordinates(), x, y);
71 auto itemStyle = style();
72 if (itemStyle !=
nullptr && !itemStyle->iconStyle().icon().isNull()) {
73 int halfIconWidth = itemStyle->iconStyle().icon().size().width() / 2;
74 int halfIconHeight = itemStyle->iconStyle().icon().size().height() / 2;
76 if ( x - halfIconWidth < curpos.
x() &&
77 curpos.
x() < x + halfIconWidth &&
78 y - halfIconHeight / 2 < curpos.
y() &&
79 curpos.
y() < y + halfIconHeight / 2 ) {
82 }
else if ( curpos.
x() == x && curpos.
y() == y ) {
89 void GeoPhotoGraphicsItem::setPoint(
const GeoDataPoint &point )
94 GeoDataPoint GeoPhotoGraphicsItem::point()
const