@@ -97,17 +97,23 @@ def __init__(self, dialog, param):
97
97
98
98
def selectExtent (self ):
99
99
popupmenu = QMenu ()
100
+ useCanvasExtentAction = QAction (
101
+ QCoreApplication .translate ("ExtentSelectionPanel" , 'Use Canvas Extent' ),
102
+ self .btnSelect )
100
103
useLayerExtentAction = QAction (
101
- QCoreApplication .translate ("ExtentSelectionPanel" , 'Use Layer/Canvas Extent…' ),
104
+ QCoreApplication .translate ("ExtentSelectionPanel" , 'Use Layer Extent…' ),
102
105
self .btnSelect )
103
106
selectOnCanvasAction = QAction (
104
107
self .tr ('Select Extent on Canvas' ), self .btnSelect )
105
108
106
- popupmenu .addAction (useLayerExtentAction )
109
+ popupmenu .addAction (useCanvasExtentAction )
107
110
popupmenu .addAction (selectOnCanvasAction )
111
+ popupmenu .addSeparator ()
112
+ popupmenu .addAction (useLayerExtentAction )
108
113
109
114
selectOnCanvasAction .triggered .connect (self .selectOnCanvas )
110
115
useLayerExtentAction .triggered .connect (self .useLayerExtent )
116
+ useCanvasExtentAction .triggered .connect (self .useCanvasExtent )
111
117
112
118
if self .param .flags () & QgsProcessingParameterDefinition .FlagOptional :
113
119
useMincoveringExtentAction = QAction (
@@ -123,11 +129,8 @@ def useMinCoveringExtent(self):
123
129
self .leText .setText ('' )
124
130
125
131
def useLayerExtent (self ):
126
- CANVAS_KEY = 'Canvas Extent'
127
132
extentsDict = {}
128
- extentsDict [CANVAS_KEY ] = {"extent" : iface .mapCanvas ().extent (),
129
- "authid" : iface .mapCanvas ().mapSettings ().destinationCrs ().authid ()}
130
- extents = [CANVAS_KEY ]
133
+ extents = []
131
134
layers = QgsProcessingUtils .compatibleLayers (QgsProject .instance ())
132
135
for layer in layers :
133
136
authid = layer .crs ().authid ()
@@ -143,6 +146,10 @@ def useLayerExtent(self):
143
146
if ok :
144
147
self .setValueFromRect (QgsReferencedRectangle (extentsDict [item ]["extent" ], QgsCoordinateReferenceSystem (extentsDict [item ]["authid" ])))
145
148
149
+ def useCanvasExtent (self ):
150
+ self .setValueFromRect (QgsReferencedRectangle (iface .mapCanvas ().extent (),
151
+ iface .mapCanvas ().mapSettings ().destinationCrs ()))
152
+
146
153
def selectOnCanvas (self ):
147
154
canvas = iface .mapCanvas ()
148
155
canvas .setMapTool (self .tool )
0 commit comments