diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e39d9cb..34511acc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ RELEASING: 14. Create new release in GitHub with tag version and release title of `vX.X.X` --> +# Unreleased + +- Add tooltip hints in processing algorithms ([#196](https://github.com/GIScience/orstools-qgis-plugin/issues/196)) ## [1.7.1] - 2024-01-15 diff --git a/ORStools/proc/base_processing_algorithm.py b/ORStools/proc/base_processing_algorithm.py index 206bc347..0d966eac 100644 --- a/ORStools/proc/base_processing_algorithm.py +++ b/ORStools/proc/base_processing_algorithm.py @@ -26,6 +26,7 @@ * * ***************************************************************************/ """ + from PyQt5.QtCore import QCoreApplication, QSettings from qgis.core import ( QgsProcessing, @@ -116,35 +117,46 @@ def provider_parameter(self) -> QgsProcessingParameterEnum: Parameter definition for provider, used in all child classes """ providers = [provider["name"] for provider in configmanager.read_config()["providers"]] - return QgsProcessingParameterEnum( + parameter = QgsProcessingParameterEnum( self.IN_PROVIDER, self.tr("Provider", "ORSBaseProcessingAlgorithm"), providers, defaultValue=providers[0], ) + self.setToolTip(parameter, self.tr("Select the provider that should be used.")) + + return parameter + def profile_parameter(self) -> QgsProcessingParameterEnum: """ Parameter definition for profile, used in all child classes """ - return QgsProcessingParameterEnum( + parameter = QgsProcessingParameterEnum( self.IN_PROFILE, self.tr("Travel mode", "ORSBaseProcessingAlgorithm"), PROFILES, defaultValue=PROFILES[0], ) + self.setToolTip(parameter, "Select a mode of travel.") + + return parameter + def output_parameter(self) -> QgsProcessingParameterFeatureSink: """ Parameter definition for output, used in all child classes """ - return QgsProcessingParameterFeatureSink( + parameter = QgsProcessingParameterFeatureSink( name=self.OUT, description=self.GROUP, ) + self.setToolTip(parameter, self.tr("Select where the output should be saved.")) + + return parameter def option_parameters(self) -> [QgsProcessingParameterDefinition]: - return [ + parameters = [ QgsProcessingParameterEnum( self.IN_AVOID_FEATS, self.tr("Features to avoid", "ORSBaseProcessingAlgorithm"), @@ -177,6 +189,21 @@ def option_parameters(self) -> [QgsProcessingParameterDefinition]: ), ] + self.setToolTip( + parameters[0], self.tr("Select features that should be avoided by the algorithm.") + ) + self.setToolTip( + parameters[1], self.tr("Select borders that should be avoided by the algorithm.") + ) + self.setToolTip( + parameters[2], self.tr("Select countries that should be avoided by the algorithm.") + ) + self.setToolTip( + parameters[3], self.tr("Select polygons that should be avoided by the algorithm.") + ) + + return parameters + @classmethod def _get_ors_client_from_provider( cls, provider: str, feedback: QgsProcessingFeedback @@ -245,3 +272,7 @@ def initAlgorithm(self, configuration): def tr(self, string, context=None): context = context or self.__class__.__name__ return QCoreApplication.translate(context, string) + + def setToolTip(self, parameter, text): + basic = parameter.toolTip() + parameter.toolTip = lambda: f"{basic}\n{text}" diff --git a/ORStools/proc/directions_lines_proc.py b/ORStools/proc/directions_lines_proc.py index 29e018b8..8f1be72f 100644 --- a/ORStools/proc/directions_lines_proc.py +++ b/ORStools/proc/directions_lines_proc.py @@ -84,6 +84,24 @@ def __init__(self): ), ] + self.setToolTip(self.PARAMETERS[0], "LineString or MultiLineString layer.") + self.setToolTip( + self.PARAMETERS[1], + self.tr( + "Values will transfer to the output layer and can be used to join layers or group features afterwards." + ), + ) + self.setToolTip( + self.PARAMETERS[2], + self.tr("Dictates the cost. For longer routes don't use Shortest Path."), + ) + self.setToolTip( + self.PARAMETERS[3], + self.tr( + "You can optionally perform a Traveling Salesman on the waypoints of each MultiPoint feature. Enabling Traveling Salesman will erase all other advanced configuration and assume the preference to be fastest Advanced Parameters: see the documentation for descriptions." + ), + ) + def processAlgorithm(self, parameters, context, feedback): ors_client = self._get_ors_client_from_provider(parameters[self.IN_PROVIDER], feedback) diff --git a/ORStools/proc/directions_points_layer_proc.py b/ORStools/proc/directions_points_layer_proc.py index 46ed384e..4a3c5f2a 100644 --- a/ORStools/proc/directions_points_layer_proc.py +++ b/ORStools/proc/directions_points_layer_proc.py @@ -92,6 +92,30 @@ def __init__(self): ), ] + self.setToolTip(self.PARAMETERS[0], self.tr("Point or MultiPoint layer.")) + self.setToolTip( + self.PARAMETERS[1], + self.tr( + "Values will transfer to the output layer and can be used to join layers or group features afterwards." + ), + ) + self.setToolTip( + self.PARAMETERS[2], + self.tr( + "Before running the algorithm points are sorted by the values of this field (Be aware of the field type! Text fields will be sorted like 1,13,2,D,a,x)." + ), + ) + self.setToolTip( + self.PARAMETERS[3], + self.tr("Dictates the cost. For longer routes don't use Shortest Path."), + ) + self.setToolTip( + self.PARAMETERS[4], + self.tr( + "You can optionally perform a Traveling Salesman Optimization on the waypoints of each (Multi)Point feature. Enabling Traveling Salesman will erase all other advanced configuration and assume the preference to be fastest." + ), + ) + def processAlgorithm(self, parameters, context, feedback): ors_client = self._get_ors_client_from_provider(parameters[self.IN_PROVIDER], feedback) diff --git a/ORStools/proc/directions_points_layers_proc.py b/ORStools/proc/directions_points_layers_proc.py index b7e00379..49d09367 100644 --- a/ORStools/proc/directions_points_layers_proc.py +++ b/ORStools/proc/directions_points_layers_proc.py @@ -108,6 +108,44 @@ def __init__(self): defaultValue=self.MODE_SELECTION[0], ), ] + self.setToolTip( + self.PARAMETERS[0], self.tr("Only Point layers are allowed, not MultiPoint.") + ) + self.setToolTip( + self.PARAMETERS[1], + self.tr( + "Values will transfer to the output layer and can be used to join layers or group features afterwards." + ), + ) + self.setToolTip( + self.PARAMETERS[2], + self.tr( + "Before running the algorithm points are sorted by the values of this field (Be aware of the field type! Text fields will be sorted like 1,13,2,D,a,x)" + ), + ) + self.setToolTip(self.PARAMETERS[3], "Only Point layers are allowed, not MultiPoint.") + self.setToolTip( + self.PARAMETERS[4], + self.tr( + "Values will transfer to the output layer and can be used to join layers or group features afterwards." + ), + ) + self.setToolTip( + self.PARAMETERS[5], + self.tr( + "Before running the algorithm points are sorted by the values of this field (Be aware of the field type! Text fields will be sorted like 1,13,2,D,a,x)" + ), + ) + self.setToolTip( + self.PARAMETERS[6], + self.tr("Dictates the cost. For longer routes don't use Shortest Path."), + ) + self.setToolTip( + self.PARAMETERS[7], + self.tr( + "Either 'row-by-row' until one layers has no more features or 'all-by-all' for every feature combination" + ), + ) # TODO: preprocess parameters to options the range cleanup below: # https://www.qgis.org/pyqgis/master/core/Processing/QgsProcessingAlgorithm.html#qgis.core.QgsProcessingAlgorithm.preprocessParameters diff --git a/ORStools/proc/isochrones_layer_proc.py b/ORStools/proc/isochrones_layer_proc.py index f0582f33..ca1bb5c4 100644 --- a/ORStools/proc/isochrones_layer_proc.py +++ b/ORStools/proc/isochrones_layer_proc.py @@ -104,6 +104,32 @@ def __init__(self): ), ] + self.setToolTip( + self.PARAMETERS[0], self.tr("Only Point layers are allowed, not MultiPoint.") + ) + self.setToolTip( + self.PARAMETERS[1], + self.tr( + "Values will transfer to the output layer and can be used to join layers or group features afterwards." + ), + ) + self.setToolTip( + self.PARAMETERS[3], + self.tr( + "Parameter needs to be a comma-separated list of integer values, no decimal points." + ), + ) + self.setToolTip( + self.PARAMETERS[4], + self.tr( + "Applies a level of generalisation to the isochrone polygons generated as a smoothing_factor between 0 and 100." + ), + ) + self.setToolTip( + self.PARAMETERS[5], + self.tr("Start treats the location(s) as starting point, destination as goal."), + ) + # Save some important references # TODO bad style, refactor isochrones = isochrones_core.Isochrones() diff --git a/ORStools/proc/isochrones_point_proc.py b/ORStools/proc/isochrones_point_proc.py index 1eb30ddc..ba02eb7e 100644 --- a/ORStools/proc/isochrones_point_proc.py +++ b/ORStools/proc/isochrones_point_proc.py @@ -90,6 +90,24 @@ def __init__(self): ), ] + self.setToolTip(self.PARAMETERS[0], self.tr("Choose a Point from the map.")) + self.setToolTip( + self.PARAMETERS[2], + self.tr( + "Parameter needs to be a comma-separated list of integer values, no decimal points." + ), + ) + self.setToolTip( + self.PARAMETERS[3], + self.tr( + "Applies a level of generalisation to the isochrone polygons generated as a smoothing_factor between 0 and 100." + ), + ) + self.setToolTip( + self.PARAMETERS[4], + self.tr("Start treats the location(s) as starting point, destination as goal."), + ) + # Save some important references # TODO bad style, refactor isochrones = isochrones_core.Isochrones() diff --git a/ORStools/proc/matrix_proc.py b/ORStools/proc/matrix_proc.py index 5a365fb2..96bd5060 100644 --- a/ORStools/proc/matrix_proc.py +++ b/ORStools/proc/matrix_proc.py @@ -82,6 +82,23 @@ def __init__(self): ), ] + self.setToolTip( + self.PARAMETERS[0], self.tr("Only Point layers are allowed, not MultiPoint.") + ) + self.setToolTip( + self.PARAMETERS[1], + self.tr( + "Values will transfer to the output layer and can be used to join layers or group features afterwards." + ), + ) + self.setToolTip(self.PARAMETERS[2], "Only Point layers are allowed, not MultiPoint.") + self.setToolTip( + self.PARAMETERS[3], + self.tr( + "Values will transfer to the output layer and can be used to join layers or group features afterwards." + ), + ) + def processAlgorithm(self, parameters, context, feedback): ors_client = self._get_ors_client_from_provider(parameters[self.IN_PROVIDER], feedback) diff --git a/ORStools/utils/configmanager.py b/ORStools/utils/configmanager.py index 26e4d614..0005e0c4 100644 --- a/ORStools/utils/configmanager.py +++ b/ORStools/utils/configmanager.py @@ -26,6 +26,7 @@ * * ***************************************************************************/ """ + import os import yaml diff --git a/ORStools/utils/processing.py b/ORStools/utils/processing.py index 86c16a97..5d627811 100644 --- a/ORStools/utils/processing.py +++ b/ORStools/utils/processing.py @@ -26,6 +26,7 @@ * * ***************************************************************************/ """ + import os from qgis.core import QgsPointXY