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 );
25 GeoGraphicsItem::~GeoGraphicsItem()
30 bool GeoGraphicsItem::visible()
const
32 return d->m_flags & ItemIsVisible;
35 void GeoGraphicsItem::setVisible(
bool visible )
37 setFlag( ItemIsVisible, visible );
45 void GeoGraphicsItem::setFlag( GeoGraphicsItemFlag flag,
bool enabled )
48 d->m_flags = d->m_flags | flag;
50 d->m_flags = d->m_flags & ~flag;
54 void GeoGraphicsItem::setFlags( GeoGraphicsItemFlags flags )
70 d->m_highlightStyle = highlightStyle;
79 if ( d->m_highlighted && d->m_highlightStyle ) {
80 return d->m_highlightStyle;
84 if (
const GeoDataPlacemark *placemark = geodata_cast<GeoDataPlacemark>(d->m_feature)) {
85 auto styling = StyleParameters(placemark, d->m_renderContext.tileLevel());
86 for (
auto relation: 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();
101 void GeoGraphicsItem::setStyleBuilder(
const StyleBuilder *styleBuilder)
103 d->m_styleBuilder = styleBuilder;
106 void GeoGraphicsItem::resetStyle()
109 handleRelationUpdate(d->m_relations);
112 qreal GeoGraphicsItem::zValue()
const
117 void GeoGraphicsItem::setZValue( qreal z )
122 void GeoGraphicsItem::setHighlighted(
bool highlight )
124 d->m_highlighted = highlight;
127 bool GeoGraphicsItem::isHighlighted()
const
129 return d->m_highlighted;
134 return d->m_paintLayers;
137 void GeoGraphicsItem::setPaintLayers(
const QStringList &paintLayers)
139 d->m_paintLayers = paintLayers;
142 void 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(),
160 [](
const GeoDataRelation * a,
const GeoDataRelation * b) {
165 handleRelationUpdate(d->m_relations);
173 int GeoGraphicsItem::minZoomLevel()
const
175 return d->m_minZoomLevel;
178 void GeoGraphicsItem::setMinZoomLevel(
int zoomLevel)
180 d->m_minZoomLevel = zoomLevel;
183 bool GeoGraphicsItem::zValueLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two)
185 return one->d->m_zValue < two->d->m_zValue;
188 bool GeoGraphicsItem::styleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two)
190 return reinterpret_cast<quint64
>(one->d->m_style.data()) <
reinterpret_cast<quint64
>(two->d->m_style.data());
193 bool GeoGraphicsItem::zValueAndStyleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two)
195 if (one->d->m_zValue == two->d->m_zValue) {
196 return reinterpret_cast<quint64
>(one->d->m_style.data()) <
reinterpret_cast<quint64
>(two->d->m_style.data());
199 return one->d->m_zValue < two->d->m_zValue;
203 bool RenderContext::operator==(
const RenderContext &other)
const
205 return m_tileLevel == other.m_tileLevel;
208 bool RenderContext::operator!=(
const RenderContext &other)
const
213 int RenderContext::tileLevel()
const
218 RenderContext::RenderContext(
int tileLevel) :
219 m_tileLevel(tileLevel)