Skip to content

Commit 9d7fff3

Browse files
committed
notes implemented
1 parent 96b65d1 commit 9d7fff3

File tree

7 files changed

+51
-38
lines changed

7 files changed

+51
-38
lines changed

beePen_gui.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ def setup_pencil_eraser(self):
162162

163163
def createFeature(self, geom):
164164

165+
if geom is None:
166+
return
167+
165168
layer = self.canvas.currentLayer()
166169
if layer is None:
167170
del geom
@@ -174,14 +177,12 @@ def createFeature(self, geom):
174177
"The current active layer is not an annotation layer")
175178
return
176179

177-
#self.beePen_pencil_QAction.triggered.disconnect(self.freehandediting)
178-
179-
# open note window for reading the note text
180-
noteDialog = NoteDialog()
181-
if noteDialog.exec_():
182-
pass
183-
else:
184-
return
180+
# open note window for inputting the note text
181+
note = ''
182+
if self.beePen_QWidget.note_QCheckBox.isChecked():
183+
noteDialog = NoteDialog()
184+
if noteDialog.exec_():
185+
note = noteDialog.note_plainTextEdit.toPlainText()
185186

186187
layer.startEditing()
187188

@@ -205,19 +206,25 @@ def createFeature(self, geom):
205206
layerCRSSrsid))
206207
s = geom.simplify(tolerance)
207208
del geom
209+
208210
f.setGeometry(s)
211+
209212
# add attribute fields to feature
210213
fields = layer.pendingFields()
211214
f.initAttributes(fields.count())
212215
record_values = [self.beePen_QWidget.pencil_width,
213-
self.beePen_QWidget.color_name]
216+
self.beePen_QWidget.color_name,
217+
note]
214218
for ndx, value in enumerate(record_values):
215219
f.setAttribute(ndx, value)
216220
layer.addFeature(f)
217221
layer.commitChanges()
218222

219223
def deleteFeatures(self, geom):
220224

225+
if geom is None:
226+
return
227+
221228
layer = self.canvas.currentLayer()
222229
if layer is None:
223230
del geom

beePen_style.qml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
<property key="labeling/dist" value="0"/>
7171
<property key="labeling/distInMapUnits" value="false"/>
7272
<property key="labeling/distMapUnitScale" value="0,0,0,0,0,0"/>
73-
<property key="labeling/drawLabels" value="false"/>
74-
<property key="labeling/enabled" value="false"/>
75-
<property key="labeling/fieldName" value=""/>
73+
<property key="labeling/drawLabels" value="true"/>
74+
<property key="labeling/enabled" value="true"/>
75+
<property key="labeling/fieldName" value="note"/>
7676
<property key="labeling/fitInPolygonOnly" value="false"/>
7777
<property key="labeling/fontCapitals" value="0"/>
7878
<property key="labeling/fontFamily" value="Noto Sans"/>
@@ -89,7 +89,7 @@
8989
<property key="labeling/fontWeight" value="50"/>
9090
<property key="labeling/fontWordSpacing" value="0"/>
9191
<property key="labeling/formatNumbers" value="false"/>
92-
<property key="labeling/isExpression" value="true"/>
92+
<property key="labeling/isExpression" value="false"/>
9393
<property key="labeling/labelOffsetInMapUnits" value="true"/>
9494
<property key="labeling/labelOffsetMapUnitScale" value="0,0,0,0,0,0"/>
9595
<property key="labeling/labelPerPart" value="false"/>
@@ -108,7 +108,7 @@
108108
<property key="labeling/obstacleType" value="0"/>
109109
<property key="labeling/offsetType" value="0"/>
110110
<property key="labeling/placeDirectionSymbol" value="0"/>
111-
<property key="labeling/placement" value="2"/>
111+
<property key="labeling/placement" value="4"/>
112112
<property key="labeling/placementFlags" value="10"/>
113113
<property key="labeling/plussign" value="false"/>
114114
<property key="labeling/predefinedPositionOrder" value="TR,TL,BR,BL,R,L,TSR,BSR"/>
@@ -149,11 +149,11 @@
149149
<property key="labeling/shapeBorderWidth" value="0"/>
150150
<property key="labeling/shapeBorderWidthMapUnitScale" value="0,0,0,0,0,0"/>
151151
<property key="labeling/shapeBorderWidthUnits" value="1"/>
152-
<property key="labeling/shapeDraw" value="false"/>
152+
<property key="labeling/shapeDraw" value="true"/>
153153
<property key="labeling/shapeFillColorA" value="255"/>
154-
<property key="labeling/shapeFillColorB" value="255"/>
155-
<property key="labeling/shapeFillColorG" value="255"/>
156-
<property key="labeling/shapeFillColorR" value="255"/>
154+
<property key="labeling/shapeFillColorB" value="106"/>
155+
<property key="labeling/shapeFillColorG" value="245"/>
156+
<property key="labeling/shapeFillColorR" value="236"/>
157157
<property key="labeling/shapeJoinStyle" value="64"/>
158158
<property key="labeling/shapeOffsetMapUnitScale" value="0,0,0,0,0,0"/>
159159
<property key="labeling/shapeOffsetUnits" value="1"/>
@@ -189,7 +189,7 @@
189189
<blendMode>0</blendMode>
190190
<featureBlendMode>0</featureBlendMode>
191191
<layerTransparency>0</layerTransparency>
192-
<displayfield>width</displayfield>
192+
<displayfield>[% "note" %]</displayfield>
193193
<label>0</label>
194194
<labelattributes>
195195
<label fieldname="" text="Label"/>
@@ -214,6 +214,7 @@
214214
<SingleCategoryDiagramRenderer diagramType="Histogram" sizeLegend="0" attributeLegend="1">
215215
<DiagramCategory penColor="#000000" labelPlacementMethod="XHeight" penWidth="0" diagramOrientation="Up" sizeScale="0,0,0,0,0,0" minimumSize="0" barWidth="5" penAlpha="255" maxScaleDenominator="1e+08" backgroundColor="#ffffff" transparency="0" width="15" scaleDependency="Area" backgroundAlpha="255" angleOffset="1440" scaleBasedVisibility="0" enabled="0" height="15" lineSizeScale="0,0,0,0,0,0" sizeType="MM" lineSizeType="MM" minScaleDenominator="100000">
216216
<fontProperties description="Noto Sans,9,-1,5,50,0,0,0,0,0" style=""/>
217+
<attribute field="" color="#000000" label=""/>
217218
</DiagramCategory>
218219
<symbol alpha="1" clip_to_extent="1" type="marker" name="sizeSymbol">
219220
<layer pass="0" class="SimpleMarker" locked="0">
@@ -239,7 +240,7 @@
239240
</symbol>
240241
</SingleCategoryDiagramRenderer>
241242
<DiagramLayerSettings yPosColumn="-1" showColumn="-1" linePlacementFlags="10" placement="2" dist="0" xPosColumn="-1" priority="0" obstacle="0" zIndex="0" showAll="1"/>
242-
<annotationform></annotationform>
243+
<annotationform>.</annotationform>
243244
<excludeAttributesWMS/>
244245
<excludeAttributesWFS/>
245246
<attributeactions default="-1"/>
@@ -251,10 +252,10 @@
251252
<column width="-1" hidden="1" type="actions"/>
252253
</columns>
253254
</attributetableconfig>
254-
<editform></editform>
255+
<editform>.</editform>
255256
<editforminit/>
256257
<editforminitcodesource>0</editforminitcodesource>
257-
<editforminitfilepath></editforminitfilepath>
258+
<editforminitfilepath>.</editforminitfilepath>
258259
<editforminitcode><![CDATA[# -*- coding: utf-8 -*-
259260
"""
260261
QGIS forms can have a Python function that is called when the form is

freehandeditingtool.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ def canvasReleaseEvent(self, event):
119119

120120
if self.rubberband.numberOfVertices() > 2:
121121
geom = self.rubberband.asGeometry()
122-
self.rbFinished.emit(geom)
122+
else:
123+
geom = None
123124

124125
# reset rubberband and refresh the canvas
125126
self.rubberband.reset()
126127
self.rubberband = None
127128
self.canvas.refresh()
128129

130+
self.rbFinished.emit(geom)
129131

130132
def setIgnoreClick(self, ignore):
131133
"""Used to keep the tool from registering clicks during modal dialogs"""
@@ -267,13 +269,16 @@ def canvasReleaseEvent(self, event):
267269

268270
if self.rb.numberOfVertices() > 2:
269271
geom = self.rb.asGeometry()
270-
self.rbFinished.emit(geom)
272+
else:
273+
geom = None
271274

272275
# reset rubberband and refresh the canvas
273276
self.rb.reset()
274277
self.rb = None
275278
self.canvas.refresh()
276279

280+
self.rbFinished.emit(geom)
281+
277282

278283
def setIgnoreClick(self, ignore):
279284
"""Used to keep the tool from registering clicks during modal dialogs"""

help/help.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
<head>
44
<title>beePen help</title>
55
</head>
6-
7-
<body>
6+
87
<h1>beePen help</h1>
98

109
beePen is a Python plugin for drawing freeand annotations and sketches in an ad-hoc layer in QGis.
1110
It is inspired by the corresponding tool in <a href="http://www.beegis.org/" target="_blank">BeeGIS</a>
12-
and re-use the code by Pavol Kapusta in his Frehand Editing plugin.<br />
13-
<br />
14-
15-
The plugin window is started by the "beePen" command (Fig. 1).<br /><br />
16-
11+
and re-use the code by Pavol Kapusta in his Frehand Editing plugin. The plugin window is started by the "beePen" command (Fig. 1).
12+
<br /><br />
1713
<img src="ims/beepen_icon.png">
1814
<br/>Fig. 1.
1915
<br /><br /><br />
20-
beePen allows to create an annotation layer, that is characterized by three fields, storing the user-defined width (in map units), color and transparency of the pen.
16+
beePen allows to create an annotation layer, that is characterized by three fields, storing: 1) the user-defined width (in map units); 2) the color and transparency of the pen;
17+
3) the optional note to be associated with each element.
2118
These value are automatically inserted based on the user choice in the plugin window (Fig. 2).<br />
2219
<br />
2320
<img src="ims/beepen_window.png">
2421
<br/>Fig. 2.
2522
<br /><br /><br />
26-
To draw annotations, create a new annotation layer from the beePen window (see Fig. 2) or load a previous one, put in edit mode using the standard tool of QGis
27-
(command at the left in Fig. 3) and then draw after selecting the pen tool (command with pencil icon at the right in Fig. 3). You can delete one or
28-
more annotations by drwaing a line above them with the eraser tool (rightmost command in Fig. 3).<br />
23+
To draw annotations, create a new annotation layer from the beePen window (see Fig. 2) or load an existing one with QGIS (and style it if necessary
24+
with the "Style selected layers" command), and then draw annotations by selecting the pen tool (command with pencil icon in Fig. 3).
25+
You can delete one or more annotations by drawing a line above them with the eraser tool (rightmost command in Fig. 3).<br />
2926
<br />
3027
<img src="ims/beepen_commands.png">
3128
<br/>Fig. 3.
32-
<br /><br /><br />
29+
<br />
3330
<div>
31+
<br /><br />
3432
The conception of beePen is by Mauro Dedonatis (Urbino Univ., Italy), while the implementation is by Mauro Alberti.</div>
35-
<br /><br /><br />
33+
<br />
34+
<div style="font-style: italic; font-size:90%">Milan, September 2016, by Mauro Alberti</div>
35+
3636

3737

3838
</body>

help/ims/beepen_commands.png

-5.73 KB
Loading

help/ims/beepen_window.png

8.43 KB
Loading

metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ changelog=
2323
0.0.8 : - removed bug appearing when multiple clicks on pencil tool; added eraser tool
2424
0.0.9 : - added sub-unit pencil widths
2525
0.1.0 : - removed possibility to save annotation shapefile on an existing one
26-
0.1.1 : - removed prior layer editing requirement
26+
0.1.1 : - removed prior layer editing requirement; added color choice; added notes
2727

2828
; tags are in comma separated value format, spaces are allowed
2929
tags = annotation, field work, geology, mapping

0 commit comments

Comments
 (0)