Commit 80f452ca authored by Mohammed Nafees's avatar Mohammed Nafees

Add a debug mode that filters level tag values

Differential Revision: https://phabricator.kde.org/D884
parent c983b201
......@@ -333,6 +333,8 @@ int main ( int argc, char *argv[] )
QCommandLineOption debugOption( "debug-info", i18n( "Enable debug output" ) );
parser.addOption( debugOption );
QCommandLineOption levelOption( "debug-levels", i18n( "Display OSM placemarks according to the level selected" ) );
parser.addOption( levelOption );
QCommandLineOption timeOption( "timedemo", i18n( "Make a time measurement to check performance" ) );
parser.addOption( timeOption );
QCommandLineOption fpsOption( "fps", i18n( "Show frame rate" ) );
......@@ -399,6 +401,10 @@ int main ( int argc, char *argv[] )
window->marbleControl()->marbleWidget()->setShowFrameRate( true );
}
if (parser.isSet(levelOption)) {
window->marbleWidget()->setDebugLevelTags(true);
}
if ( parser.isSet( tileOption ) ) {
window->marbleControl()->marbleWidget()->setShowTileId( true );
}
......
......@@ -158,7 +158,8 @@ int main(int argc, char *argv[])
qWarning() << " --runtimeTrace.............. Show the time spent and other debug info of each layer";
qWarning() << " --tile-id................... Write the identifier of texture tiles on top of them";
qWarning() << " --timedemo ................. Measure the paint performance while moving the map and quit";
qWarning() << " --debug-polygons .............Display the polygon nodes and their index for debugging";
qWarning() << " --debug-polygons ........... Display the polygon nodes and their index for debugging";
qWarning() << " --debug-levels ............. Display OSM placemarks according to the level selected";
qWarning();
qWarning() << "profile options (note that marble should automatically detect which profile to use. Override that with the options below):";
qWarning() << " --highresolution ........... Enforce the profile for devices with high resolution (e.g. desktop computers)";
......@@ -278,7 +279,8 @@ int main(int argc, char *argv[])
marbleTest.timeDemo();
return 0;
}
else if (arg == QLatin1String("--fps")) {
if (arg == QLatin1String("--fps")) {
window->marbleControl()->marbleWidget()->setShowFrameRate( true );
}
else if (arg == QLatin1String("--tile-id")) {
......@@ -290,12 +292,17 @@ int main(int argc, char *argv[])
else if (arg == QLatin1String("--debug-polygons")) {
window->marbleControl()->marbleWidget()->setShowDebugPolygons( true );
}
else if ( i != dataPathIndex && QFile::exists( arg ) )
window->addGeoDataFile( arg );
else if ( i != dataPathIndex && QFile::exists( arg ) ) {
window->addGeoDataFile(arg);
}
else if (arg == QLatin1String("--debug-levels")) {
window->marbleWidget()->setDebugLevelTags(true);
}
}
auto const marbleWidget = window->marbleControl()->marbleWidget();
bool const debugModeEnabled = marbleWidget->showRuntimeTrace() || marbleWidget->showDebugPolygons() || MarbleDebug::isEnabled();
bool const debugModeEnabled = marbleWidget->showRuntimeTrace() || marbleWidget->showDebugPolygons() ||
marbleWidget->debugLevelTags() || MarbleDebug::isEnabled();
marbleWidget->inputHandler()->setDebugModeEnabled(debugModeEnabled);
return app.exec();
......
......@@ -941,10 +941,14 @@ bool MarbleDefaultInputHandler::handleKeyPress(QKeyEvent* event)
marblePresenter->moveByStep(0, 1);
break;
case Qt::Key_Plus:
marblePresenter->zoomIn();
if (event->modifiers() != Qt::ControlModifier) {
marblePresenter->zoomIn();
}
break;
case Qt::Key_Minus:
marblePresenter->zoomOut();
if (event->modifiers() != Qt::ControlModifier) {
marblePresenter->zoomOut();
}
break;
case Qt::Key_Home:
marblePresenter->goHome();
......
......@@ -1302,6 +1302,29 @@ bool MarbleMap::showDebugPlacemarks() const
return d->m_placemarkLayer.isDebugModeEnabled();
}
void MarbleMap::setLevelTagDebugModeEnabled(bool visible)
{
if (visible != d->m_geometryLayer.levelTagDebugModeEnabled()) {
d->m_geometryLayer.setLevelTagDebugModeEnabled(visible);
emit repaintNeeded();
}
}
bool MarbleMap::levelTagDebugModeEnabled() const
{
return d->m_geometryLayer.levelTagDebugModeEnabled();
}
void MarbleMap::setDebugLevelTag(int level)
{
d->m_geometryLayer.setDebugLevelTag(level);
}
int MarbleMap::debugLevelTag() const
{
return d->m_geometryLayer.debugLevelTag();
}
void MarbleMap::setShowBackground( bool visible )
{
d->m_layerManager.setShowBackground( visible );
......
......@@ -675,6 +675,21 @@ class MARBLE_EXPORT MarbleMap : public QObject
bool showDebugPlacemarks() const;
/**
* @brief Set whether to enter the debug mode for
* level tags
* @param visible visibility according to OSM level tags
*/
void setLevelTagDebugModeEnabled(bool visible);
bool levelTagDebugModeEnabled() const;
void setDebugLevelTag(int level);
int debugLevelTag() const;
void setShowBackground( bool visible );
void setVisibleRelationTypes(GeoDataRelation::RelationTypes relationTypes);
......
......@@ -950,6 +950,16 @@ bool MarbleWidget::showDebugPlacemarks() const
return d->m_map.showDebugPlacemarks();
}
void MarbleWidget::setDebugLevelTags(bool visible)
{
d->m_map.setLevelTagDebugModeEnabled(visible);
}
bool MarbleWidget::debugLevelTags() const
{
return d->m_map.levelTagDebugModeEnabled();
}
void MarbleWidget::setShowTileId( bool visible )
{
d->m_map.setShowTileId( visible );
......@@ -1227,6 +1237,16 @@ qreal MarbleWidget::heading() const
return d->m_map.heading();
}
void MarbleWidget::setLevelToDebug(int level)
{
d->m_map.setDebugLevelTag(level);
}
int MarbleWidget::levelToDebug() const
{
return d->m_map.debugLevelTag();
}
}
#include "moc_MarbleWidget.cpp"
......@@ -970,6 +970,22 @@ class MARBLE_EXPORT MarbleWidget : public QWidget
bool showDebugPlacemarks() const;
/**
* @brief Set whether to render according to OSM indoor level tags
* @param visible visibility of entities (placemarks, buildings etc.) level-wise
*/
void setDebugLevelTags(bool visible);
bool debugLevelTags() const;
/**
* @brief Set the level to debug
* @param level the level to debug
*/
void setLevelToDebug(int level);
int levelToDebug() const;
/**
* @brief Set the map quality for the specified view context.
*
* @param quality map quality for the specified view context
......@@ -1150,7 +1166,7 @@ class MARBLE_EXPORT MarbleWidget : public QWidget
friend class CustomPaintLayer;
friend class MarbleWidgetDefaultInputHandler;
};
};
}
......
......@@ -106,22 +106,66 @@ void MarbleWidgetInputHandler::setCursor(const QCursor &cursor)
bool MarbleWidgetInputHandler::handleKeyPress(QKeyEvent *event)
{
if (d->m_debugModeEnabled) {
switch(event->key()) {
case Qt::Key_I:
MarbleDebug::setEnabled(!MarbleDebug::isEnabled());
break;
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;
case Qt::Key_B:
d->m_marbleWidget->setShowDebugBatchRender(!d->m_marbleWidget->showDebugBatchRender());
break;
if (event->modifiers() == Qt::ControlModifier && d->m_marbleWidget->debugLevelTags()) {
switch(event->key()) {
case Qt::Key_0:
d->m_marbleWidget->setLevelToDebug(0);
break;
case Qt::Key_1:
d->m_marbleWidget->setLevelToDebug(1);
break;
case Qt::Key_2:
d->m_marbleWidget->setLevelToDebug(2);
break;
case Qt::Key_3:
d->m_marbleWidget->setLevelToDebug(3);
break;
case Qt::Key_4:
d->m_marbleWidget->setLevelToDebug(4);
break;
case Qt::Key_5:
d->m_marbleWidget->setLevelToDebug(5);
break;
case Qt::Key_6:
d->m_marbleWidget->setLevelToDebug(6);
break;
case Qt::Key_7:
d->m_marbleWidget->setLevelToDebug(7);
break;
case Qt::Key_8:
d->m_marbleWidget->setLevelToDebug(8);
break;
case Qt::Key_9:
d->m_marbleWidget->setLevelToDebug(9);
break;
case Qt::Key_Plus:
d->m_marbleWidget->setLevelToDebug(d->m_marbleWidget->levelToDebug() + 1);
break;
case Qt::Key_Minus:
d->m_marbleWidget->setLevelToDebug(d->m_marbleWidget->levelToDebug() - 1);
break;
}
} else {
switch(event->key()) {
case Qt::Key_I:
MarbleDebug::setEnabled(!MarbleDebug::isEnabled());
break;
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;
case Qt::Key_B:
d->m_marbleWidget->setShowDebugBatchRender(!d->m_marbleWidget->showDebugBatchRender());
break;
case Qt::Key_L:
d->m_marbleWidget->setDebugLevelTags(!d->m_marbleWidget->debugLevelTags());
break;
}
}
}
return MarbleDefaultInputHandler::handleKeyPress(event);
......
......@@ -110,6 +110,8 @@ public:
GeoDataLatLonBox m_cachedLatLonBox;
QSet<qint64> m_highlightedRouteRelations;
GeoDataRelation::RelationTypes m_visibleRelationTypes;
bool m_levelTagDebugModeEnabled;
int m_levelToDebug;
};
GeometryLayerPrivate::GeometryLayerPrivate(const QAbstractItemModel *model, const StyleBuilder *styleBuilder) :
......@@ -119,7 +121,9 @@ GeometryLayerPrivate::GeometryLayerPrivate(const QAbstractItemModel *model, cons
m_lastFeatureAt(nullptr),
m_dirty(true),
m_cachedItemCount(0),
m_visibleRelationTypes(GeoDataRelation::RouteFerry)
m_visibleRelationTypes(GeoDataRelation::RouteFerry),
m_levelTagDebugModeEnabled(false),
m_levelToDebug(0)
{
}
......@@ -248,6 +252,21 @@ bool GeometryLayer::render(GeoPainter *painter, ViewportParams *viewport,
AbstractGeoPolygonGraphicsItem::s_previousStyle = 0;
GeoLineStringGraphicsItem::s_previousStyle = 0;
for (auto item: layerItems) {
if (d->m_levelTagDebugModeEnabled) {
if (const auto placemark = geodata_cast<GeoDataPlacemark>(item->feature())) {
if (!placemark->hasOsmData()) {
continue;
}
QHash<QString, QString>::const_iterator tagIter = placemark->osmData().findTag(QStringLiteral("level"));
if (tagIter == placemark->osmData().tagsEnd()) {
continue;
}
const int val = tagIter.value().toInt();
if (val != d->m_levelToDebug) {
continue;
}
}
}
item->paint(painter, viewport, layer, d->m_tileLevel);
}
}
......@@ -667,6 +686,32 @@ void GeometryLayer::handleHighlight(qreal lon, qreal lat, GeoDataCoordinates::Un
emit highlightedPlacemarksChanged(selectedPlacemarks);
}
void GeometryLayer::setLevelTagDebugModeEnabled(bool enabled)
{
if (d->m_levelTagDebugModeEnabled != enabled) {
d->m_levelTagDebugModeEnabled = enabled;
emit repaintNeeded();
}
}
bool GeometryLayer::levelTagDebugModeEnabled() const
{
return d->m_levelTagDebugModeEnabled;
}
void GeometryLayer::setDebugLevelTag(int level)
{
if (d->m_levelToDebug != level) {
d->m_levelToDebug = level;
emit repaintNeeded();
}
}
int GeometryLayer::debugLevelTag() const
{
return d->m_levelToDebug;
}
}
#include "moc_GeometryLayer.cpp"
......@@ -58,6 +58,14 @@ public:
void setVisibleRelationTypes(GeoDataRelation::RelationTypes relationTypes);
void setLevelTagDebugModeEnabled(bool enabled);
bool levelTagDebugModeEnabled() const;
void setDebugLevelTag(int level);
int debugLevelTag() const;
public Q_SLOTS:
void addPlacemarks( const QModelIndex& index, int first, int last );
void removePlacemarks( const QModelIndex& index, int first, int last );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment