Skip to content

Commit a380360

Browse files
author
cfarmer
committedJan 29, 2009
fix error in adding output to mapcanvas & ability to create grid
coverage of current zoom level git-svn-id: http://svn.osgeo.org/qgis/trunk@10044 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a091be0 commit a380360

File tree

3 files changed

+45
-59
lines changed

3 files changed

+45
-59
lines changed
 

‎python/plugins/ftools/tools/doVectorGrid.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def __init__(self, iface):
4343
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
4444
QObject.connect(self.spnX, SIGNAL("valueChanged(double)"), self.offset)
4545
#QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateInput)
46-
QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateInput)
46+
QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateLayer)
47+
QObject.connect(self.btnCanvas, SIGNAL("clicked()"), self.updateCanvas)
4748
self.setWindowTitle("Vector grid")
4849
self.xMin.setValidator(QDoubleValidator(self.xMin))
4950
self.xMax.setValidator(QDoubleValidator(self.xMax))
@@ -58,13 +59,17 @@ def offset(self, value):
5859
if self.chkLock.isChecked():
5960
self.spnY.setValue(value)
6061

61-
def updateInput( self ):
62+
def updateLayer( self ):
6263
mLayerName = self.inShape.currentText()
6364
if not mLayerName == "":
6465
mLayer = self.getMapLayerByName( unicode( mLayerName ) )
65-
self.inLayer = mLayer
6666
boundBox = mLayer.extent()
6767
self.updateExtents( boundBox )
68+
69+
def updateCanvas( self ):
70+
canvas = self.iface.mapCanvas()
71+
boundBox = canvas.extent()
72+
self.updateExtents( boundBox )
6873

6974
def updateExtents( self, boundBox ):
7075
self.xMin.setText( unicode( boundBox.xMinimum() ) )
@@ -93,7 +98,7 @@ def accept(self):
9398
self.outShape.clear()
9499
self.compute( boundBox, xSpace, ySpace, polygon )
95100
addToTOC = QMessageBox.question(self,
96-
"Generate Vector Grid", "Created output Shapefile:\n" + outPath
101+
"Generate Vector Grid", "Created output Shapefile:\n" + self.shapefileName
97102
+ "\nNote: Layer has no associated coordinate system, please use "
98103
+ "the Projection Management Tool to specify spatial reference system."
99104
+ "\n\nWould you like to add the new layer to the TOC?",

‎python/plugins/ftools/tools/frmVectorGrid.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'frmVectorGrid.ui'
44
#
5-
# Created: Tue Jan 27 23:10:42 2009
5+
# Created: Thu Jan 29 18:39:47 2009
66
# by: PyQt4 UI code generator 4.3.3
77
#
88
# WARNING! All changes made in this file will be lost!
@@ -25,16 +25,19 @@ def setupUi(self, Dialog):
2525
self.gridlayout1 = QtGui.QGridLayout(self.groupBox)
2626
self.gridlayout1.setObjectName("gridlayout1")
2727

28-
spacerItem = QtGui.QSpacerItem(80,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
29-
self.gridlayout1.addItem(spacerItem,1,0,1,1)
28+
self.inShape = QtGui.QComboBox(self.groupBox)
29+
self.inShape.setObjectName("inShape")
30+
self.gridlayout1.addWidget(self.inShape,0,0,1,2)
3031

3132
self.btnUpdate = QtGui.QToolButton(self.groupBox)
3233
self.btnUpdate.setMinimumSize(QtCore.QSize(0,30))
3334
self.btnUpdate.setObjectName("btnUpdate")
34-
self.gridlayout1.addWidget(self.btnUpdate,1,1,1,2)
35+
self.gridlayout1.addWidget(self.btnUpdate,1,0,1,1)
3536

36-
spacerItem1 = QtGui.QSpacerItem(79,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
37-
self.gridlayout1.addItem(spacerItem1,1,3,1,1)
37+
self.btnCanvas = QtGui.QToolButton(self.groupBox)
38+
self.btnCanvas.setMinimumSize(QtCore.QSize(0,30))
39+
self.btnCanvas.setObjectName("btnCanvas")
40+
self.gridlayout1.addWidget(self.btnCanvas,1,1,1,1)
3841

3942
self.hboxlayout = QtGui.QHBoxLayout()
4043
self.hboxlayout.setObjectName("hboxlayout")
@@ -48,7 +51,7 @@ def setupUi(self, Dialog):
4851
self.xMin.setEnabled(True)
4952
self.xMin.setObjectName("xMin")
5053
self.hboxlayout.addWidget(self.xMin)
51-
self.gridlayout1.addLayout(self.hboxlayout,2,0,1,2)
54+
self.gridlayout1.addLayout(self.hboxlayout,2,0,1,1)
5255

5356
self.hboxlayout1 = QtGui.QHBoxLayout()
5457
self.hboxlayout1.setObjectName("hboxlayout1")
@@ -62,7 +65,7 @@ def setupUi(self, Dialog):
6265
self.yMin.setEnabled(True)
6366
self.yMin.setObjectName("yMin")
6467
self.hboxlayout1.addWidget(self.yMin)
65-
self.gridlayout1.addLayout(self.hboxlayout1,2,2,1,2)
68+
self.gridlayout1.addLayout(self.hboxlayout1,2,1,1,1)
6669

6770
self.hboxlayout2 = QtGui.QHBoxLayout()
6871
self.hboxlayout2.setObjectName("hboxlayout2")
@@ -76,7 +79,7 @@ def setupUi(self, Dialog):
7679
self.xMax.setEnabled(True)
7780
self.xMax.setObjectName("xMax")
7881
self.hboxlayout2.addWidget(self.xMax)
79-
self.gridlayout1.addLayout(self.hboxlayout2,3,0,1,2)
82+
self.gridlayout1.addLayout(self.hboxlayout2,3,0,1,1)
8083

8184
self.hboxlayout3 = QtGui.QHBoxLayout()
8285
self.hboxlayout3.setObjectName("hboxlayout3")
@@ -90,11 +93,7 @@ def setupUi(self, Dialog):
9093
self.yMax.setEnabled(True)
9194
self.yMax.setObjectName("yMax")
9295
self.hboxlayout3.addWidget(self.yMax)
93-
self.gridlayout1.addLayout(self.hboxlayout3,3,2,1,2)
94-
95-
self.inShape = QtGui.QComboBox(self.groupBox)
96-
self.inShape.setObjectName("inShape")
97-
self.gridlayout1.addWidget(self.inShape,0,0,1,4)
96+
self.gridlayout1.addLayout(self.hboxlayout3,3,1,1,1)
9897
self.gridlayout.addWidget(self.groupBox,0,0,1,2)
9998

10099
self.gridBox = QtGui.QGroupBox(Dialog)
@@ -103,8 +102,8 @@ def setupUi(self, Dialog):
103102
self.gridlayout2 = QtGui.QGridLayout(self.gridBox)
104103
self.gridlayout2.setObjectName("gridlayout2")
105104

106-
spacerItem2 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
107-
self.gridlayout2.addItem(spacerItem2,0,0,1,1)
105+
spacerItem = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
106+
self.gridlayout2.addItem(spacerItem,0,0,1,1)
108107

109108
self.label_7 = QtGui.QLabel(self.gridBox)
110109
self.label_7.setObjectName("label_7")
@@ -123,11 +122,11 @@ def setupUi(self, Dialog):
123122
self.chkLock.setObjectName("chkLock")
124123
self.gridlayout2.addWidget(self.chkLock,0,3,2,1)
125124

126-
spacerItem3 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
127-
self.gridlayout2.addItem(spacerItem3,0,4,1,1)
125+
spacerItem1 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
126+
self.gridlayout2.addItem(spacerItem1,0,4,1,1)
128127

129-
spacerItem4 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
130-
self.gridlayout2.addItem(spacerItem4,1,0,1,1)
128+
spacerItem2 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
129+
self.gridlayout2.addItem(spacerItem2,1,0,1,1)
131130

132131
self.label_8 = QtGui.QLabel(self.gridBox)
133132
self.label_8.setEnabled(False)
@@ -200,6 +199,7 @@ def retranslateUi(self, Dialog):
200199
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Generate Regular Points", None, QtGui.QApplication.UnicodeUTF8))
201200
self.groupBox.setTitle(QtGui.QApplication.translate("Dialog", "Grid extent", None, QtGui.QApplication.UnicodeUTF8))
202201
self.btnUpdate.setText(QtGui.QApplication.translate("Dialog", "Update extents from layer", None, QtGui.QApplication.UnicodeUTF8))
202+
self.btnCanvas.setText(QtGui.QApplication.translate("Dialog", "Update extents from canvas", None, QtGui.QApplication.UnicodeUTF8))
203203
self.label.setText(QtGui.QApplication.translate("Dialog", "X Min", None, QtGui.QApplication.UnicodeUTF8))
204204
self.label_4.setText(QtGui.QApplication.translate("Dialog", "Y Min", None, QtGui.QApplication.UnicodeUTF8))
205205
self.label_3.setText(QtGui.QApplication.translate("Dialog", "X Max", None, QtGui.QApplication.UnicodeUTF8))

‎python/plugins/ftools/tools/frmVectorGrid.ui

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,10 @@
2525
<string>Grid extent</string>
2626
</property>
2727
<layout class="QGridLayout" name="gridLayout" >
28-
<item row="1" column="0" >
29-
<spacer name="horizontalSpacer" >
30-
<property name="orientation" >
31-
<enum>Qt::Horizontal</enum>
32-
</property>
33-
<property name="sizeHint" stdset="0" >
34-
<size>
35-
<width>80</width>
36-
<height>20</height>
37-
</size>
38-
</property>
39-
</spacer>
28+
<item row="0" column="0" colspan="2" >
29+
<widget class="QComboBox" name="inShape" />
4030
</item>
41-
<item row="1" column="1" colspan="2" >
31+
<item row="1" column="0" >
4232
<widget class="QToolButton" name="btnUpdate" >
4333
<property name="minimumSize" >
4434
<size>
@@ -51,20 +41,20 @@
5141
</property>
5242
</widget>
5343
</item>
54-
<item row="1" column="3" >
55-
<spacer name="horizontalSpacer_2" >
56-
<property name="orientation" >
57-
<enum>Qt::Horizontal</enum>
58-
</property>
59-
<property name="sizeHint" stdset="0" >
44+
<item row="1" column="1" >
45+
<widget class="QToolButton" name="btnCanvas" >
46+
<property name="minimumSize" >
6047
<size>
61-
<width>79</width>
62-
<height>20</height>
48+
<width>0</width>
49+
<height>30</height>
6350
</size>
6451
</property>
65-
</spacer>
52+
<property name="text" >
53+
<string>Update extents from canvas</string>
54+
</property>
55+
</widget>
6656
</item>
67-
<item row="2" column="0" colspan="2" >
57+
<item row="2" column="0" >
6858
<layout class="QHBoxLayout" >
6959
<item>
7060
<widget class="QLabel" name="label" >
@@ -91,7 +81,7 @@
9181
</item>
9282
</layout>
9383
</item>
94-
<item row="2" column="2" colspan="2" >
84+
<item row="2" column="1" >
9585
<layout class="QHBoxLayout" >
9686
<item>
9787
<widget class="QLabel" name="label_4" >
@@ -118,7 +108,7 @@
118108
</item>
119109
</layout>
120110
</item>
121-
<item row="3" column="0" colspan="2" >
111+
<item row="3" column="0" >
122112
<layout class="QHBoxLayout" >
123113
<item>
124114
<widget class="QLabel" name="label_3" >
@@ -145,7 +135,7 @@
145135
</item>
146136
</layout>
147137
</item>
148-
<item row="3" column="2" colspan="2" >
138+
<item row="3" column="1" >
149139
<layout class="QHBoxLayout" >
150140
<item>
151141
<widget class="QLabel" name="label_5" >
@@ -172,9 +162,6 @@
172162
</item>
173163
</layout>
174164
</item>
175-
<item row="0" column="0" colspan="4" >
176-
<widget class="QComboBox" name="inShape" />
177-
</item>
178165
</layout>
179166
</widget>
180167
</item>
@@ -360,12 +347,6 @@
360347
</widget>
361348
</item>
362349
</layout>
363-
<zorder>groupBox</zorder>
364-
<zorder>gridBox</zorder>
365-
<zorder>label_2</zorder>
366-
<zorder>progressBar</zorder>
367-
<zorder>buttonBox_2</zorder>
368-
<zorder>inShape</zorder>
369350
</widget>
370351
<resources/>
371352
<connections>

0 commit comments

Comments
 (0)
Please sign in to comment.