7#include "GeoGraphicsItem.h"
8#include "GeoGraphicsItem_p.h"
10#include "GeoDataPlacemark.h"
13#include "MarbleDebug.h"
20 : d(new GeoGraphicsItemPrivate(feature))
22 setFlag(ItemIsVisible,
true);
25GeoGraphicsItem::~GeoGraphicsItem()
30bool GeoGraphicsItem::visible()
const
32 return d->m_flags & ItemIsVisible;
35void GeoGraphicsItem::setVisible(
bool visible)
37 setFlag(ItemIsVisible, visible);
45void GeoGraphicsItem::setFlag(GeoGraphicsItemFlag flag,
bool enabled)
48 d->m_flags = d->m_flags | flag;
50 d->m_flags = d->m_flags & ~flag;
54void GeoGraphicsItem::setFlags(GeoGraphicsItemFlags flags)
70 d->m_highlightStyle = highlightStyle;
79 if (d->m_highlighted && d->m_highlightStyle) {
80 return d->m_highlightStyle;
85 auto styling = StyleParameters(placemark, d->m_renderContext.tileLevel());
86 for (
auto relation : std::as_const(d->m_relations)) {
87 if (relation->isVisible()) {
88 styling.relation = relation;
92 d->m_style = d->m_styleBuilder->createStyle(styling);
94 d->m_style = d->m_feature->style();
101void GeoGraphicsItem::setStyleBuilder(
const StyleBuilder *styleBuilder)
103 d->m_styleBuilder = styleBuilder;
106void GeoGraphicsItem::resetStyle()
109 handleRelationUpdate(d->m_relations);
112qreal GeoGraphicsItem::zValue()
const
117void GeoGraphicsItem::setZValue(qreal z)
122void GeoGraphicsItem::setHighlighted(
bool highlight)
124 d->m_highlighted = highlight;
127bool GeoGraphicsItem::isHighlighted()
const
129 return d->m_highlighted;
134 return d->m_paintLayers;
137void GeoGraphicsItem::setPaintLayers(
const QStringList &paintLayers)
139 d->m_paintLayers = paintLayers;
142void GeoGraphicsItem::setRenderContext(
const RenderContext &renderContext)
144 if (renderContext != d->m_renderContext) {
145 d->m_renderContext = renderContext;
157 d->m_relations.clear();
158 std::copy(relations.
begin(), relations.
end(), std::back_inserter(d->m_relations));
159 std::sort(d->m_relations.begin(), d->m_relations.end(), [](
const GeoDataRelation *a,
const GeoDataRelation *b) {
164 handleRelationUpdate(d->m_relations);
172int GeoGraphicsItem::minZoomLevel()
const
174 return d->m_minZoomLevel;
177void GeoGraphicsItem::setMinZoomLevel(
int zoomLevel)
179 d->m_minZoomLevel = zoomLevel;
182bool GeoGraphicsItem::zValueLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two)
184 return one->d->m_zValue < two->d->m_zValue;
187bool GeoGraphicsItem::styleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two)
189 return reinterpret_cast<quint64
>(one->d->m_style.data()) <
reinterpret_cast<quint64
>(two->d->m_style.data());
192bool GeoGraphicsItem::zValueAndStyleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two)
194 if (one->d->m_zValue == two->d->m_zValue) {
195 return reinterpret_cast<quint64
>(one->d->m_style.data()) <
reinterpret_cast<quint64
>(two->d->m_style.data());
198 return one->d->m_zValue < two->d->m_zValue;
201bool RenderContext::operator==(
const RenderContext &other)
const
203 return m_tileLevel == other.m_tileLevel;
206bool RenderContext::operator!=(
const RenderContext &other)
const
208 return !operator==(other);
211int RenderContext::tileLevel()
const
216RenderContext::RenderContext(
int tileLevel)
217 : m_tileLevel(tileLevel)
A base class for all geodata features.
A public class that controls what is visible in the viewport of a Marble map.
Binds a QML item to a specific geodetic location in screen coordinates.
T * geodata_cast(GeoDataObject *node)
Returns the given node cast to type T if the node was instantiated as type T; otherwise returns 0.