Added a feature to draw a box easier

This commit is contained in:
Jaewoo Choi 2017-08-30 02:10:11 +09:00
parent b40edc3ab3
commit dd09ffb497

View File

@ -84,6 +84,8 @@ class Canvas(QWidget):
if not value: # Create if not value: # Create
self.unHighlight() self.unHighlight()
self.deSelectShape() self.deSelectShape()
self.prevPoint = QPointF()
self.repaint()
def unHighlight(self): def unHighlight(self):
if self.hShape: if self.hShape:
@ -117,8 +119,11 @@ class Canvas(QWidget):
self.current.highlightVertex(0, Shape.NEAR_VERTEX) self.current.highlightVertex(0, Shape.NEAR_VERTEX)
self.line[1] = pos self.line[1] = pos
self.line.line_color = color self.line.line_color = color
self.repaint() self.prevPoint = QPointF()
self.current.highlightClear() self.current.highlightClear()
else:
self.prevPoint = pos
self.repaint()
return return
# Polygon copy moving. # Polygon copy moving.
@ -413,6 +418,11 @@ class Canvas(QWidget):
p.setBrush(brush) p.setBrush(brush)
p.drawRect(leftTop.x(), leftTop.y(), rectWidth, rectHeight) p.drawRect(leftTop.x(), leftTop.y(), rectWidth, rectHeight)
if self.drawing() and not self.prevPoint.isNull() and not self.outOfPixmap(self.prevPoint):
p.setPen(QColor(0, 0, 0))
p.drawLine(self.prevPoint.x(), 0, self.prevPoint.x(), self.pixmap.height())
p.drawLine(0, self.prevPoint.y(), self.pixmap.width(), self.prevPoint.y())
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
if self.verified: if self.verified:
pal = self.palette() pal = self.palette()