mirror of
https://github.com/wassname/sloth.git
synced 2026-06-27 19:32:40 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user