示例#1
0
void PlacemarkTextAnnotation::paint(GeoPainter *painter, const ViewportParams *viewport, const QString &layer , int tileZoomLevel)
{
    Q_UNUSED(layer);
    Q_UNUSED( painter );
    Q_UNUSED(tileZoomLevel);
    m_viewport = viewport;

    GeoDataStyle::Ptr newStyle(new GeoDataStyle(*placemark()->style()));
    GeoDataLabelStyle labelStyle = newStyle->labelStyle();

    if (labelStyle.color() != QApplication::palette().highlight().color())
        m_labelColor = labelStyle.color();

    if (hasFocus()) {
        labelStyle.setColor(QApplication::palette().highlight().color());
    } else {
        labelStyle.setColor(m_labelColor);
    }

    newStyle->setLabelStyle(labelStyle);
    placemark()->setStyle(newStyle);

    qreal x, y;
    viewport->currentProjection()->screenCoordinates( placemark()->coordinate(), viewport, x, y );
    m_region = QRegion( x - 10 , y - 10 , 20 , 20 );
}