From 1d1e8564808ee0cf79b15b93b9339ffecae64958 Mon Sep 17 00:00:00 2001 From: Till Frankenbach <81414045+Merydian@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:16:29 +0100 Subject: [PATCH] feat: style output layers of plugin GUI (#188) Style was chosen to follow the ors maps client. Style is only overwritten on GUI usage, not for anything else. See discussion in the PR. Fixes #149 Co-authored-by: Jakob Schnell --- CHANGELOG.md | 1 + ORStools/gui/ORStoolsDialog.py | 16 +- ORStools/gui/img/svg/endpoint_marker.svg | 9 + ORStools/gui/img/svg/startpoint_marker.svg | 9 + ORStools/gui/linestyle.qml | 615 +++++++++++++++++++++ 5 files changed, 649 insertions(+), 1 deletion(-) create mode 100644 ORStools/gui/img/svg/endpoint_marker.svg create mode 100644 ORStools/gui/img/svg/startpoint_marker.svg create mode 100644 ORStools/gui/linestyle.qml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f068fb0..6abf4e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ RELEASING: - Additional parameter for the "smoothing factor" to isochrones processing algorithms ([#172](https://github.com/GIScience/orstools-qgis-plugin/issues/172)) - Mention omission of configuration options when using traveling salesman - option to set location type for isochrones ([#191](https://github.com/GIScience/orstools-qgis-plugin/pull/191)) +- Add styling of routing output in main plugin ([#149](https://github.com/GIScience/orstools-qgis-plugin/issues/149)) - make items in centroid list drag and droppable ([#144](https://github.com/GIScience/orstools-qgis-plugin/issues/144)) - Add save button for vertices ([#144](https://github.com/GIScience/orstools-qgis-plugin/issues/144)) diff --git a/ORStools/gui/ORStoolsDialog.py b/ORStools/gui/ORStoolsDialog.py index f6959fa1..dbeb53f2 100644 --- a/ORStools/gui/ORStoolsDialog.py +++ b/ORStools/gui/ORStoolsDialog.py @@ -45,7 +45,7 @@ ) from qgis.gui import QgsMapCanvasAnnotationItem -from PyQt5.QtCore import QSizeF, QPointF, QCoreApplication +from PyQt5.QtCore import QSizeF, QPointF, QCoreApplication, QSettings from PyQt5.QtGui import QIcon, QTextDocument from PyQt5.QtWidgets import QAction, QDialog, QApplication, QMenu, QMessageBox, QDialogButtonBox @@ -243,6 +243,20 @@ def run_gui_control(self): layer_out.dataProvider().addAttributes(directions_core.get_fields()) layer_out.updateFields() + basepath = os.path.dirname(__file__) + + # add ors svg path + my_new_path = os.path.join(basepath, "img/svg") + svg_paths = QSettings().value("svg/searchPathsForSVG") + if my_new_path not in svg_paths: + svg_paths.append(my_new_path) + QSettings().setValue("svg/searchPathsForSVG", svg_paths) + + # style output layer + qml_path = os.path.join(basepath, "linestyle.qml") + layer_out.loadNamedStyle(qml_path, True) + layer_out.triggerRepaint() + # Associate annotations with map layer, so they get deleted when layer is deleted for annotation in self.dlg.annotations: # Has the potential to be pretty cool: instead of deleting, associate with mapLayer diff --git a/ORStools/gui/img/svg/endpoint_marker.svg b/ORStools/gui/img/svg/endpoint_marker.svg new file mode 100644 index 00000000..6755de40 --- /dev/null +++ b/ORStools/gui/img/svg/endpoint_marker.svg @@ -0,0 +1,9 @@ + + + + + + 2 + + + diff --git a/ORStools/gui/img/svg/startpoint_marker.svg b/ORStools/gui/img/svg/startpoint_marker.svg new file mode 100644 index 00000000..edbd0a60 --- /dev/null +++ b/ORStools/gui/img/svg/startpoint_marker.svg @@ -0,0 +1,9 @@ + + + + + + 1 + + + diff --git a/ORStools/gui/linestyle.qml b/ORStools/gui/linestyle.qml new file mode 100644 index 00000000..34454262 --- /dev/null +++ b/ORStools/gui/linestyle.qml @@ -0,0 +1,615 @@ + + + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "new_field_name" + + 1 +