Эх сурвалжийг харах

in shape ,small square around each point
small change in canvas

Hussein 13 жил өмнө
parent
commit
14f3c199ce
2 өөрчлөгдсөн 13 нэмэгдсэн , 2 устгасан
  1. 1 1
      canvas.py
  2. 12 1
      shape.py

+ 1 - 1
canvas.py

@@ -43,7 +43,7 @@ class Canvas(QLabel):
 
     def mouseDoubleClickEvent(self, ev):
         if self.current:
-            self.current.addPoint(self.current[0])
+            #self.current.addPoint(self.current[0]) , you don't need this code ,point0 is already there (duplicate the same point)
             self.finalise()
 
     def paintEvent(self, event):

+ 12 - 1
shape.py

@@ -13,7 +13,7 @@ class Shape(object):
         self.label = label
         self.line_color = line_color
         self.fill_color = fill_color
-
+	self.pointSize=8 # draw square around each point , with length and width =8 pixels
         self.points = []
         self.fill = False
 
@@ -33,14 +33,25 @@ class Shape(object):
             pen = QPen(self.line_color)
             painter.setPen(pen)
             path = QPainterPath()
+            pathRect = QPainterPath()
+
             path.moveTo(self.points[0].x(), self.points[0].y())
+            pathRect.addRect( self.points[0].x()-self.pointSize/2, self.points[0].y()-self.pointSize/2, self.pointSize,self.pointSize)
+
             for p in self.points[1:]:
                 path.lineTo(p.x(), p.y())
+		pathRect.addRect(p.x()-self.pointSize/2. ,p.y()-self.pointSize/2,self.pointSize,self.pointSize)
             painter.drawPath(path)
+            #painter.drawPath(pathRect)
+
 
             if self.fill:
                 painter.fillPath(path, self.fill_color)
 
+	painter.fillPath(pathRect, self.line_color)
+
+
+
     def __len__(self):
         return len(self.points)