Skip to content

Commit

Permalink
notes implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroalberti committed Sep 25, 2016
1 parent 96b65d1 commit 9d7fff3
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 38 deletions.
25 changes: 16 additions & 9 deletions beePen_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def setup_pencil_eraser(self):

def createFeature(self, geom):

if geom is None:
return

layer = self.canvas.currentLayer()
if layer is None:
del geom
Expand All @@ -174,14 +177,12 @@ def createFeature(self, geom):
"The current active layer is not an annotation layer")
return

#self.beePen_pencil_QAction.triggered.disconnect(self.freehandediting)

# open note window for reading the note text
noteDialog = NoteDialog()
if noteDialog.exec_():
pass
else:
return
# open note window for inputting the note text
note = ''
if self.beePen_QWidget.note_QCheckBox.isChecked():
noteDialog = NoteDialog()
if noteDialog.exec_():
note = noteDialog.note_plainTextEdit.toPlainText()

layer.startEditing()

Expand All @@ -205,19 +206,25 @@ def createFeature(self, geom):
layerCRSSrsid))
s = geom.simplify(tolerance)
del geom

f.setGeometry(s)

# add attribute fields to feature
fields = layer.pendingFields()
f.initAttributes(fields.count())
record_values = [self.beePen_QWidget.pencil_width,
self.beePen_QWidget.color_name]
self.beePen_QWidget.color_name,
note]
for ndx, value in enumerate(record_values):
f.setAttribute(ndx, value)
layer.addFeature(f)
layer.commitChanges()

def deleteFeatures(self, geom):

if geom is None:
return

layer = self.canvas.currentLayer()
if layer is None:
del geom
Expand Down
27 changes: 14 additions & 13 deletions beePen_style.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
<property key="labeling/dist" value="0"/>
<property key="labeling/distInMapUnits" value="false"/>
<property key="labeling/distMapUnitScale" value="0,0,0,0,0,0"/>
<property key="labeling/drawLabels" value="false"/>
<property key="labeling/enabled" value="false"/>
<property key="labeling/fieldName" value=""/>
<property key="labeling/drawLabels" value="true"/>
<property key="labeling/enabled" value="true"/>
<property key="labeling/fieldName" value="note"/>
<property key="labeling/fitInPolygonOnly" value="false"/>
<property key="labeling/fontCapitals" value="0"/>
<property key="labeling/fontFamily" value="Noto Sans"/>
Expand All @@ -89,7 +89,7 @@
<property key="labeling/fontWeight" value="50"/>
<property key="labeling/fontWordSpacing" value="0"/>
<property key="labeling/formatNumbers" value="false"/>
<property key="labeling/isExpression" value="true"/>
<property key="labeling/isExpression" value="false"/>
<property key="labeling/labelOffsetInMapUnits" value="true"/>
<property key="labeling/labelOffsetMapUnitScale" value="0,0,0,0,0,0"/>
<property key="labeling/labelPerPart" value="false"/>
Expand All @@ -108,7 +108,7 @@
<property key="labeling/obstacleType" value="0"/>
<property key="labeling/offsetType" value="0"/>
<property key="labeling/placeDirectionSymbol" value="0"/>
<property key="labeling/placement" value="2"/>
<property key="labeling/placement" value="4"/>
<property key="labeling/placementFlags" value="10"/>
<property key="labeling/plussign" value="false"/>
<property key="labeling/predefinedPositionOrder" value="TR,TL,BR,BL,R,L,TSR,BSR"/>
Expand Down Expand Up @@ -149,11 +149,11 @@
<property key="labeling/shapeBorderWidth" value="0"/>
<property key="labeling/shapeBorderWidthMapUnitScale" value="0,0,0,0,0,0"/>
<property key="labeling/shapeBorderWidthUnits" value="1"/>
<property key="labeling/shapeDraw" value="false"/>
<property key="labeling/shapeDraw" value="true"/>
<property key="labeling/shapeFillColorA" value="255"/>
<property key="labeling/shapeFillColorB" value="255"/>
<property key="labeling/shapeFillColorG" value="255"/>
<property key="labeling/shapeFillColorR" value="255"/>
<property key="labeling/shapeFillColorB" value="106"/>
<property key="labeling/shapeFillColorG" value="245"/>
<property key="labeling/shapeFillColorR" value="236"/>
<property key="labeling/shapeJoinStyle" value="64"/>
<property key="labeling/shapeOffsetMapUnitScale" value="0,0,0,0,0,0"/>
<property key="labeling/shapeOffsetUnits" value="1"/>
Expand Down Expand Up @@ -189,7 +189,7 @@
<blendMode>0</blendMode>
<featureBlendMode>0</featureBlendMode>
<layerTransparency>0</layerTransparency>
<displayfield>width</displayfield>
<displayfield>[% "note" %]</displayfield>
<label>0</label>
<labelattributes>
<label fieldname="" text="Label"/>
Expand All @@ -214,6 +214,7 @@
<SingleCategoryDiagramRenderer diagramType="Histogram" sizeLegend="0" attributeLegend="1">
<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">
<fontProperties description="Noto Sans,9,-1,5,50,0,0,0,0,0" style=""/>
<attribute field="" color="#000000" label=""/>
</DiagramCategory>
<symbol alpha="1" clip_to_extent="1" type="marker" name="sizeSymbol">
<layer pass="0" class="SimpleMarker" locked="0">
Expand All @@ -239,7 +240,7 @@
</symbol>
</SingleCategoryDiagramRenderer>
<DiagramLayerSettings yPosColumn="-1" showColumn="-1" linePlacementFlags="10" placement="2" dist="0" xPosColumn="-1" priority="0" obstacle="0" zIndex="0" showAll="1"/>
<annotationform></annotationform>
<annotationform>.</annotationform>
<excludeAttributesWMS/>
<excludeAttributesWFS/>
<attributeactions default="-1"/>
Expand All @@ -251,10 +252,10 @@
<column width="-1" hidden="1" type="actions"/>
</columns>
</attributetableconfig>
<editform></editform>
<editform>.</editform>
<editforminit/>
<editforminitcodesource>0</editforminitcodesource>
<editforminitfilepath></editforminitfilepath>
<editforminitfilepath>.</editforminitfilepath>
<editforminitcode><![CDATA[# -*- coding: utf-8 -*-
"""
QGIS forms can have a Python function that is called when the form is
Expand Down
9 changes: 7 additions & 2 deletions freehandeditingtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ def canvasReleaseEvent(self, event):

if self.rubberband.numberOfVertices() > 2:
geom = self.rubberband.asGeometry()
self.rbFinished.emit(geom)
else:
geom = None

# reset rubberband and refresh the canvas
self.rubberband.reset()
self.rubberband = None
self.canvas.refresh()

self.rbFinished.emit(geom)

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

if self.rb.numberOfVertices() > 2:
geom = self.rb.asGeometry()
self.rbFinished.emit(geom)
else:
geom = None

# reset rubberband and refresh the canvas
self.rb.reset()
self.rb = None
self.canvas.refresh()

self.rbFinished.emit(geom)


def setIgnoreClick(self, ignore):
"""Used to keep the tool from registering clicks during modal dialogs"""
Expand Down
26 changes: 13 additions & 13 deletions help/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
<head>
<title>beePen help</title>
</head>

<body>

<h1>beePen help</h1>

beePen is a Python plugin for drawing freeand annotations and sketches in an ad-hoc layer in QGis.
It is inspired by the corresponding tool in <a href="http://www.beegis.org/" target="_blank">BeeGIS</a>
and re-use the code by Pavol Kapusta in his Frehand Editing plugin.<br />
<br />

The plugin window is started by the "beePen" command (Fig. 1).<br /><br />

and re-use the code by Pavol Kapusta in his Frehand Editing plugin. The plugin window is started by the "beePen" command (Fig. 1).
<br /><br />
<img src="ims/beepen_icon.png">
<br/>Fig. 1.
<br /><br /><br />
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.
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;
3) the optional note to be associated with each element.
These value are automatically inserted based on the user choice in the plugin window (Fig. 2).<br />
<br />
<img src="ims/beepen_window.png">
<br/>Fig. 2.
<br /><br /><br />
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
(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
more annotations by drwaing a line above them with the eraser tool (rightmost command in Fig. 3).<br />
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
with the "Style selected layers" command), and then draw annotations by selecting the pen tool (command with pencil icon in Fig. 3).
You can delete one or more annotations by drawing a line above them with the eraser tool (rightmost command in Fig. 3).<br />
<br />
<img src="ims/beepen_commands.png">
<br/>Fig. 3.
<br /><br /><br />
<br />
<div>
<br /><br />
The conception of beePen is by Mauro Dedonatis (Urbino Univ., Italy), while the implementation is by Mauro Alberti.</div>
<br /><br /><br />
<br />
<div style="font-style: italic; font-size:90%">Milan, September 2016, by Mauro Alberti</div>



</body>
Expand Down
Binary file modified help/ims/beepen_commands.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified help/ims/beepen_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ changelog=
0.0.8 : - removed bug appearing when multiple clicks on pencil tool; added eraser tool
0.0.9 : - added sub-unit pencil widths
0.1.0 : - removed possibility to save annotation shapefile on an existing one
0.1.1 : - removed prior layer editing requirement
0.1.1 : - removed prior layer editing requirement; added color choice; added notes

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

0 comments on commit 9d7fff3

Please sign in to comment.