Merge pull request #85 from neingeist/feature/polygon-enumerator-plugin

Add a plugin to enumerate the corners of polygon items
This commit is contained in:
baeuml
2014-10-08 16:47:29 +02:00
+24
View File
@@ -85,3 +85,27 @@ class CopyAnnotationsPlugin(QObject):
def action(self):
return self._sc
class PolygonEnumeratorPlugin(QObject):
"""Enumerate the corners of polygons."""
def __init__(self, labeltool):
QObject.__init__(self)
# Decorate the paint() method with our enumerating paint:
from sloth.items import PolygonItem
oldpaint = PolygonItem.paint
def paint(self, painter, option, widget=None):
oldpaint(self, painter, option, widget)
for i, p in enumerate(self._polygon):
painter.drawText(p, str(i))
import functools
functools.update_wrapper(paint, oldpaint)
PolygonItem.paint = paint
def action(self):
return None