Show label text at the top-left of the rect
This commit is contained in:
parent
c1954b3244
commit
deb8b844f9
@ -10,6 +10,7 @@ except ImportError:
|
|||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
|
|
||||||
from libs.lib import distance
|
from libs.lib import distance
|
||||||
|
import sys
|
||||||
|
|
||||||
DEFAULT_LINE_COLOR = QColor(0, 255, 0, 128)
|
DEFAULT_LINE_COLOR = QColor(0, 255, 0, 128)
|
||||||
DEFAULT_FILL_COLOR = QColor(255, 0, 0, 128)
|
DEFAULT_FILL_COLOR = QColor(255, 0, 0, 128)
|
||||||
@ -107,6 +108,20 @@ class Shape(object):
|
|||||||
painter.drawPath(line_path)
|
painter.drawPath(line_path)
|
||||||
painter.drawPath(vrtx_path)
|
painter.drawPath(vrtx_path)
|
||||||
painter.fillPath(vrtx_path, self.vertex_fill_color)
|
painter.fillPath(vrtx_path, self.vertex_fill_color)
|
||||||
|
|
||||||
|
# Draw text at the top-left
|
||||||
|
min_x = sys.maxsize
|
||||||
|
min_y = sys.maxsize
|
||||||
|
for point in self.points:
|
||||||
|
min_x = min(min_x, point.x())
|
||||||
|
min_y = min(min_y, point.y())
|
||||||
|
if min_x != sys.maxsize and min_y != sys.maxsize:
|
||||||
|
font = QFont()
|
||||||
|
font.setPointSize(8)
|
||||||
|
font.setBold(True)
|
||||||
|
painter.setFont(font)
|
||||||
|
painter.drawText(min_x, min_y, self.label)
|
||||||
|
|
||||||
if self.fill:
|
if self.fill:
|
||||||
color = self.select_fill_color if self.selected else self.fill_color
|
color = self.select_fill_color if self.selected else self.fill_color
|
||||||
painter.fillPath(line_path, color)
|
painter.fillPath(line_path, color)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user