mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-26 00:02:43 -04:00
Add CrsWidgetWrapper
This commit is contained in:
parent
bb0938a5fe
commit
6158e9b340
@ -162,12 +162,16 @@ class ParameterBoolean(Parameter):
|
|||||||
|
|
||||||
class ParameterCrs(Parameter):
|
class ParameterCrs(Parameter):
|
||||||
|
|
||||||
def __init__(self, name='', description='', default=None, optional=False):
|
default_metadata = {
|
||||||
|
'widget_wrapper': 'processing.gui.wrappers.CrsWidgetWrapper'
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, name='', description='', default=None, optional=False, metadata={}):
|
||||||
'''The value is a string that uniquely identifies the
|
'''The value is a string that uniquely identifies the
|
||||||
coordinate reference system. Typically it is the auth id of the CRS
|
coordinate reference system. Typically it is the auth id of the CRS
|
||||||
(if the authority is EPSG) or proj4 string of the CRS (in case
|
(if the authority is EPSG) or proj4 string of the CRS (in case
|
||||||
of other authorities or user defined projections).'''
|
of other authorities or user defined projections).'''
|
||||||
Parameter.__init__(self, name, description, default, optional)
|
Parameter.__init__(self, name, description, default, optional, metadata)
|
||||||
|
|
||||||
def setValue(self, value):
|
def setValue(self, value):
|
||||||
if value is None or value.strip() == '':
|
if value is None or value.strip() == '':
|
||||||
|
@ -55,7 +55,6 @@ from processing.core.parameters import ParameterMultipleInput
|
|||||||
from processing.core.parameters import ParameterString
|
from processing.core.parameters import ParameterString
|
||||||
from processing.core.parameters import ParameterNumber
|
from processing.core.parameters import ParameterNumber
|
||||||
from processing.core.parameters import ParameterFile
|
from processing.core.parameters import ParameterFile
|
||||||
from processing.core.parameters import ParameterCrs
|
|
||||||
from processing.core.parameters import ParameterPoint
|
from processing.core.parameters import ParameterPoint
|
||||||
from processing.core.parameters import ParameterGeometryPredicate
|
from processing.core.parameters import ParameterGeometryPredicate
|
||||||
|
|
||||||
@ -172,7 +171,7 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
|||||||
else:
|
else:
|
||||||
options = dataobjects.getVectorLayers([param.datatype], sorting=False)
|
options = dataobjects.getVectorLayers([param.datatype], sorting=False)
|
||||||
return param.setValue([options[i] for i in widget.selectedoptions])
|
return param.setValue([options[i] for i in widget.selectedoptions])
|
||||||
elif isinstance(param, (ParameterNumber, ParameterFile, ParameterCrs,
|
elif isinstance(param, (ParameterNumber, ParameterFile,
|
||||||
ParameterExtent, ParameterPoint)):
|
ParameterExtent, ParameterPoint)):
|
||||||
return param.setValue(widget.getValue())
|
return param.setValue(widget.getValue())
|
||||||
elif isinstance(param, ParameterString):
|
elif isinstance(param, ParameterString):
|
||||||
|
@ -39,14 +39,16 @@ WIDGET, BASE = uic.loadUiType(
|
|||||||
|
|
||||||
class CrsSelectionPanel(BASE, WIDGET):
|
class CrsSelectionPanel(BASE, WIDGET):
|
||||||
|
|
||||||
def __init__(self, default):
|
def __init__(self, default='EPSG:4326'):
|
||||||
super(CrsSelectionPanel, self).__init__(None)
|
super(CrsSelectionPanel, self).__init__(None)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.leText.setEnabled(False)
|
self.leText.setEnabled(False)
|
||||||
|
|
||||||
self.btnSelect.clicked.connect(self.browseCRS)
|
self.btnSelect.clicked.connect(self.browseCRS)
|
||||||
self.crs = QgsCoordinateReferenceSystem(default).authid()
|
|
||||||
|
# TODO: Default should be removed
|
||||||
|
self.crs = default
|
||||||
self.updateText()
|
self.updateText()
|
||||||
|
|
||||||
def setAuthId(self, authid):
|
def setAuthId(self, authid):
|
||||||
|
@ -411,8 +411,6 @@ class ParametersPanel(BASE, WIDGET):
|
|||||||
item = ExtentSelectionPanel(self.parent, self.alg, param.default)
|
item = ExtentSelectionPanel(self.parent, self.alg, param.default)
|
||||||
elif isinstance(param, ParameterPoint):
|
elif isinstance(param, ParameterPoint):
|
||||||
item = PointSelectionPanel(self.parent, param.default)
|
item = PointSelectionPanel(self.parent, param.default)
|
||||||
elif isinstance(param, ParameterCrs):
|
|
||||||
item = CrsSelectionPanel(param.default)
|
|
||||||
elif isinstance(param, ParameterString):
|
elif isinstance(param, ParameterString):
|
||||||
if param.multiline:
|
if param.multiline:
|
||||||
verticalLayout = QVBoxLayout()
|
verticalLayout = QVBoxLayout()
|
||||||
|
@ -28,11 +28,14 @@ __revision__ = '$Format:%H$'
|
|||||||
|
|
||||||
from inspect import isclass
|
from inspect import isclass
|
||||||
|
|
||||||
|
from qgis.core import QgsCoordinateReferenceSystem
|
||||||
from qgis.PyQt.QtWidgets import (
|
from qgis.PyQt.QtWidgets import (
|
||||||
QCheckBox,
|
QCheckBox,
|
||||||
QComboBox,
|
QComboBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from processing.gui.CrsSelectionPanel import CrsSelectionPanel
|
||||||
|
|
||||||
DIALOG_STANDARD = 'standard'
|
DIALOG_STANDARD = 'standard'
|
||||||
DIALOG_BATCH = 'batch'
|
DIALOG_BATCH = 'batch'
|
||||||
DIALOG_MODELER = 'modeler'
|
DIALOG_MODELER = 'modeler'
|
||||||
@ -115,3 +118,19 @@ class BooleanWidgetWrapper(WidgetWrapper):
|
|||||||
|
|
||||||
if self.dialog in (DIALOG_BATCH, DIALOG_MODELER):
|
if self.dialog in (DIALOG_BATCH, DIALOG_MODELER):
|
||||||
return self.widget.itemData(self.widget.currentIndex())
|
return self.widget.itemData(self.widget.currentIndex())
|
||||||
|
|
||||||
|
|
||||||
|
class CrsWidgetWrapper(WidgetWrapper):
|
||||||
|
|
||||||
|
def createWidget(self, extra_values=[]):
|
||||||
|
return CrsSelectionPanel()
|
||||||
|
|
||||||
|
def setValue(self, value):
|
||||||
|
if isinstance(value, basestring): # authId
|
||||||
|
self.widget.crs = value
|
||||||
|
else:
|
||||||
|
self.widget.crs = QgsCoordinateReferenceSystem(value).authid()
|
||||||
|
self.widget.updateText()
|
||||||
|
|
||||||
|
def value(self):
|
||||||
|
return self.widget.getValue()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user