summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-06 10:46:48 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-06 10:46:48 (GMT)
commit934dfd760ce613d3cdabe78b944f70982f1c98a9 (patch)
tree7964fe35bf2a0b61b4af427778e26d4ac80ebdbe
parent8955569d0b65bd63bc367c31a8f5d97b2f0a8471 (diff)
Add a debug mode for placemark layer
- toggle with key 'O' (Marble needs to be run with --debug-info) - red rectangles are hidden placemarks - blue rectangles are bounding boxes of visible placemarks - green rectangles are symbol and label bounding boxes of visible placemarks - green text is placemarks' popularity (sort key used to decide which ones to show/hide on collisions) Some red rectangles seem to get stuck. This is not a bug in the debug painting, but the viewport cache not working properly and keeping many orphane placemarks around forever. Needs to be fixed in a follow-up commit. CCMAIL: tackat@kde.org
-rw-r--r--src/apps/marble-maps/DeveloperDialog.qml5
-rw-r--r--src/lib/marble/MarbleMap.cpp13
-rw-r--r--src/lib/marble/MarbleMap.h9
-rw-r--r--src/lib/marble/MarbleWidget.cpp10
-rw-r--r--src/lib/marble/MarbleWidget.h9
-rw-r--r--src/lib/marble/MarbleWidgetInputHandler.cpp3
-rw-r--r--src/lib/marble/PlacemarkLayout.cpp5
-rw-r--r--src/lib/marble/PlacemarkLayout.h2
-rw-r--r--src/lib/marble/declarative/MarbleQuickItem.cpp6
-rw-r--r--src/lib/marble/declarative/MarbleQuickItem.h1
-rw-r--r--src/lib/marble/layers/PlacemarkLayer.cpp48
-rw-r--r--src/lib/marble/layers/PlacemarkLayer.h5
12 files changed, 114 insertions, 2 deletions
diff --git a/src/apps/marble-maps/DeveloperDialog.qml b/src/apps/marble-maps/DeveloperDialog.qml
index 80e1975..9fb4fdc 100644
--- a/src/apps/marble-maps/DeveloperDialog.qml
+++ b/src/apps/marble-maps/DeveloperDialog.qml
@@ -79,7 +79,10 @@ Item {
id: debugPolygons
text: "Render in Debug Mode"
checked: settings.value("Developer", "debugPolygons") === "true"
- onCheckedChanged: marbleMaps.setShowDebugPolygons(checked)
+ onCheckedChanged: {
+ marbleMaps.setShowDebugPlacemarks(checked)
+ marbleMaps.setShowDebugPolygons(checked)
+ }
}
}
}
diff --git a/src/lib/marble/MarbleMap.cpp b/src/lib/marble/MarbleMap.cpp
index a2e15e6..92afd82 100644
--- a/src/lib/marble/MarbleMap.cpp
+++ b/src/lib/marble/MarbleMap.cpp
@@ -1253,6 +1253,19 @@ bool MarbleMap::showDebugPolygons() const
return d->m_showDebugPolygons;
}
+void MarbleMap::setShowDebugPlacemarks( bool visible)
+{
+ if (visible != d->m_placemarkLayer.isDebugModeEnabled()) {
+ d->m_placemarkLayer.setDebugModeEnabled(visible);
+ emit repaintNeeded();
+ }
+}
+
+bool MarbleMap::showDebugPlacemarks() const
+{
+ return d->m_placemarkLayer.isDebugModeEnabled();
+}
+
void MarbleMap::setShowBackground( bool visible )
{
d->m_layerManager.setShowBackground( visible );
diff --git a/src/lib/marble/MarbleMap.h b/src/lib/marble/MarbleMap.h
index 91526f9..c9500cd 100644
--- a/src/lib/marble/MarbleMap.h
+++ b/src/lib/marble/MarbleMap.h
@@ -649,6 +649,15 @@ class MARBLE_EXPORT MarbleMap : public QObject
bool showDebugPolygons() const;
+ /**
+ * @brief Set whether to enter the debug mode for
+ * placemark drawing
+ * @param visible visibility of the node debug mode
+ */
+ void setShowDebugPlacemarks(bool visible);
+
+ bool showDebugPlacemarks() const;
+
void setShowBackground( bool visible );
/**
diff --git a/src/lib/marble/MarbleWidget.cpp b/src/lib/marble/MarbleWidget.cpp
index 9f6523a..a48539b 100644
--- a/src/lib/marble/MarbleWidget.cpp
+++ b/src/lib/marble/MarbleWidget.cpp
@@ -930,6 +930,16 @@ bool MarbleWidget::showDebugPolygons() const
return d->m_map.showDebugPolygons();
}
+void MarbleWidget::setShowDebugPlacemarks( bool visible)
+{
+ d->m_map.setShowDebugPlacemarks( visible );
+}
+
+bool MarbleWidget::showDebugPlacemarks() const
+{
+ return d->m_map.showDebugPlacemarks();
+}
+
void MarbleWidget::setShowTileId( bool visible )
{
d->m_map.setShowTileId( visible );
diff --git a/src/lib/marble/MarbleWidget.h b/src/lib/marble/MarbleWidget.h
index acce763..66db8d5 100644
--- a/src/lib/marble/MarbleWidget.h
+++ b/src/lib/marble/MarbleWidget.h
@@ -948,6 +948,15 @@ class MARBLE_EXPORT MarbleWidget : public QWidget
bool showDebugPolygons() const;
/**
+ * @brief Set whether to enter the debug mode for
+ * placemark drawing
+ * @param visible visibility of the node debug mode
+ */
+ void setShowDebugPlacemarks(bool visible);
+
+ bool showDebugPlacemarks() const;
+
+ /**
* @brief Set the map quality for the specified view context.
*
* @param quality map quality for the specified view context
diff --git a/src/lib/marble/MarbleWidgetInputHandler.cpp b/src/lib/marble/MarbleWidgetInputHandler.cpp
index c2ab1e4..908c0cc 100644
--- a/src/lib/marble/MarbleWidgetInputHandler.cpp
+++ b/src/lib/marble/MarbleWidgetInputHandler.cpp
@@ -113,6 +113,9 @@ bool MarbleWidgetInputHandler::handleKeyPress(QKeyEvent *event)
case Qt::Key_R:
d->m_marbleWidget->setShowRuntimeTrace(!d->m_marbleWidget->showRuntimeTrace());
break;
+ case Qt::Key_O:
+ d->m_marbleWidget->setShowDebugPlacemarks(!d->m_marbleWidget->showDebugPlacemarks());
+ break;
case Qt::Key_P:
d->m_marbleWidget->setShowDebugPolygons(!d->m_marbleWidget->showDebugPolygons());
break;
diff --git a/src/lib/marble/PlacemarkLayout.cpp b/src/lib/marble/PlacemarkLayout.cpp
index 1c6ace1..2e7a53b 100644
--- a/src/lib/marble/PlacemarkLayout.cpp
+++ b/src/lib/marble/PlacemarkLayout.cpp
@@ -498,6 +498,11 @@ QString PlacemarkLayout::runtimeTrace() const
return m_runtimeTrace;
}
+QList<VisiblePlacemark *> PlacemarkLayout::visiblePlacemarks() const
+{
+ return m_visiblePlacemarks.values();
+}
+
bool PlacemarkLayout::layoutPlacemark( const GeoDataPlacemark *placemark, qreal x, qreal y, bool selected )
{
// Find the corresponding visible placemark
diff --git a/src/lib/marble/PlacemarkLayout.h b/src/lib/marble/PlacemarkLayout.h
index 5035a2f..f53ddc3 100644
--- a/src/lib/marble/PlacemarkLayout.h
+++ b/src/lib/marble/PlacemarkLayout.h
@@ -81,6 +81,8 @@ class PlacemarkLayout : public QObject
QString runtimeTrace() const;
+ QList<VisiblePlacemark *> visiblePlacemarks() const;
+
public Q_SLOTS:
// earth
void setShowPlaces( bool show );
diff --git a/src/lib/marble/declarative/MarbleQuickItem.cpp b/src/lib/marble/declarative/MarbleQuickItem.cpp
index ee1e151..7d09383 100644
--- a/src/lib/marble/declarative/MarbleQuickItem.cpp
+++ b/src/lib/marble/declarative/MarbleQuickItem.cpp
@@ -894,6 +894,12 @@ namespace Marble
update();
}
+ void MarbleQuickItem::setShowDebugPlacemarks(bool showDebugPlacemarks)
+ {
+ d->m_map.setShowDebugPlacemarks(showDebugPlacemarks);
+ update();
+ }
+
void MarbleQuickItem::setPlacemarkDelegate(QQmlComponent *placemarkDelegate)
{
if (d->m_placemarkDelegate == placemarkDelegate) {
diff --git a/src/lib/marble/declarative/MarbleQuickItem.h b/src/lib/marble/declarative/MarbleQuickItem.h
index 151bc39..d7246a8 100644
--- a/src/lib/marble/declarative/MarbleQuickItem.h
+++ b/src/lib/marble/declarative/MarbleQuickItem.h
@@ -128,6 +128,7 @@ namespace Marble
Q_INVOKABLE void setShowRuntimeTrace(bool showRuntimeTrace);
Q_INVOKABLE void setShowDebugPolygons(bool showDebugPolygons);
+ Q_INVOKABLE void setShowDebugPlacemarks(bool showDebugPlacemarks);
void setPlacemarkDelegate(QQmlComponent* placemarkDelegate);
diff --git a/src/lib/marble/layers/PlacemarkLayer.cpp b/src/lib/marble/layers/PlacemarkLayer.cpp
index 9a4164b..a06890a 100644
--- a/src/lib/marble/layers/PlacemarkLayer.cpp
+++ b/src/lib/marble/layers/PlacemarkLayer.cpp
@@ -33,7 +33,8 @@ PlacemarkLayer::PlacemarkLayer(QAbstractItemModel *placemarkModel,
MarbleClock *clock, const StyleBuilder *styleBuilder,
QObject *parent ) :
QObject( parent ),
- m_layout( placemarkModel, selectionModel, clock, styleBuilder )
+ m_layout( placemarkModel, selectionModel, clock, styleBuilder ),
+ m_debugModeEnabled(false)
{
m_useXWorkaround = testXBug();
mDebug() << "Use workaround: " << ( m_useXWorkaround ? "1" : "0" );
@@ -97,6 +98,10 @@ bool PlacemarkLayer::render( GeoPainter *geoPainter, ViewportParams *viewport,
}
}
+ if (m_debugModeEnabled) {
+ renderDebug(geoPainter, viewport, visiblePlacemarks);
+ }
+
return true;
}
@@ -115,6 +120,16 @@ QVector<const GeoDataFeature *> PlacemarkLayer::whichPlacemarkAt( const QPoint &
return m_layout.whichPlacemarkAt( pos );
}
+bool PlacemarkLayer::isDebugModeEnabled() const
+{
+ return m_debugModeEnabled;
+}
+
+void PlacemarkLayer::setDebugModeEnabled(bool enabled)
+{
+ m_debugModeEnabled = enabled;
+}
+
void PlacemarkLayer::setShowPlaces( bool show )
{
m_layout.setShowPlaces( show );
@@ -192,5 +207,36 @@ bool PlacemarkLayer::testXBug()
return true;
}
+void PlacemarkLayer::renderDebug(GeoPainter *painter, ViewportParams *viewport, const QVector<VisiblePlacemark *> &placemarks)
+{
+ Q_UNUSED(viewport);
+ painter->save();
+ painter->setBrush(QBrush(Qt::NoBrush));
+
+ typedef QSet<VisiblePlacemark*> Placemarks;
+ Placemarks const hidden = Placemarks::fromList(m_layout.visiblePlacemarks()).subtract(Placemarks::fromList(placemarks.toList()));
+
+ painter->setPen(QPen(QColor(Qt::red)));
+ for (auto placemark: hidden) {
+ painter->drawRect(placemark->boundingBox());
+ }
+
+ painter->setPen(QPen(QColor(Qt::blue)));
+ for (auto placemark: placemarks) {
+ painter->drawRect(placemark->boundingBox());
+ }
+
+ painter->setPen(QPen(QColor(Qt::green)));
+ for (auto placemark: placemarks) {
+ painter->drawRect(placemark->labelRect());
+ painter->drawRect(placemark->symbolRect());
+ QString const popularity = QString::number(placemark->placemark()->popularity());
+ painter->drawText(placemark->symbolRect().bottomLeft(), popularity);
+ }
+
+
+ painter->restore();
+}
+
#include "moc_PlacemarkLayer.cpp"
diff --git a/src/lib/marble/layers/PlacemarkLayer.h b/src/lib/marble/layers/PlacemarkLayer.h
index 47333c1..f90ea73 100644
--- a/src/lib/marble/layers/PlacemarkLayer.h
+++ b/src/lib/marble/layers/PlacemarkLayer.h
@@ -76,6 +76,9 @@ class PlacemarkLayer : public QObject, public LayerInterface
*/
QVector<const GeoDataFeature *> whichPlacemarkAt( const QPoint &pos );
+ bool isDebugModeEnabled() const;
+ void setDebugModeEnabled(bool enabled);
+
static bool m_useXWorkaround; // Indicates need for an X windows workaround.
public Q_SLOTS:
// earth
@@ -95,9 +98,11 @@ class PlacemarkLayer : public QObject, public LayerInterface
void repaintNeeded();
private:
+ void renderDebug(GeoPainter *painter, ViewportParams *viewport, const QVector<VisiblePlacemark*> & placemarks);
static bool testXBug();
PlacemarkLayout m_layout;
+ bool m_debugModeEnabled;
};
}