|
@@ -1,40 +1,39 @@
|
|
#!/usr/bin/python
|
|
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-import sys, random
|
|
|
|
from PyQt4.QtGui import *
|
|
from PyQt4.QtGui import *
|
|
from PyQt4.QtCore import *
|
|
from PyQt4.QtCore import *
|
|
|
|
|
|
class shape(object):
|
|
class shape(object):
|
|
-
|
|
|
|
|
|
+
|
|
def __init__(self ,label,color):
|
|
def __init__(self ,label,color):
|
|
- self.label=label
|
|
|
|
- self.points=[]
|
|
|
|
- self.color=color
|
|
|
|
- self.fill=False
|
|
|
|
|
|
+ self.label=label
|
|
|
|
+ self.points=[]
|
|
|
|
+ self.color=color
|
|
|
|
+ self.fill=False
|
|
|
|
+
|
|
def getLabel(self):
|
|
def getLabel(self):
|
|
- return label
|
|
|
|
-
|
|
|
|
|
|
+ return label
|
|
|
|
+
|
|
def setLabel(self,label):
|
|
def setLabel(self,label):
|
|
- self.label=label
|
|
|
|
-
|
|
|
|
|
|
+ self.label=label
|
|
|
|
+
|
|
def setFill(self,fillB):
|
|
def setFill(self,fillB):
|
|
- self.fill=fillB
|
|
|
|
|
|
+ self.fill=fillB
|
|
|
|
+
|
|
def addPoint(self,point):
|
|
def addPoint(self,point):
|
|
- self.points.append(point)
|
|
|
|
-
|
|
|
|
|
|
+ self.points.append(point)
|
|
|
|
+
|
|
def drawShape(self,painter):
|
|
def drawShape(self,painter):
|
|
-
|
|
|
|
- if len(self.points) >0 :
|
|
|
|
- pen=QPen(self.color)
|
|
|
|
- painter.setPen(pen)
|
|
|
|
- prePoint=self.points[0]
|
|
|
|
- path=QPainterPath()
|
|
|
|
- path.moveTo(prePoint.x(),prePoint.y())
|
|
|
|
- for point in self.points:
|
|
|
|
- path.lineTo(point.x(),point.y())
|
|
|
|
- painter.drawPath(path)
|
|
|
|
- if self.fill:
|
|
|
|
- painter.fillPath(path,Qt.red)
|
|
|
|
|
|
+
|
|
|
|
+ if len(self.points) >0 :
|
|
|
|
+ pen=QPen(self.color)
|
|
|
|
+ painter.setPen(pen)
|
|
|
|
+ prePoint=self.points[0]
|
|
|
|
+ path=QPainterPath()
|
|
|
|
+ path.moveTo(prePoint.x(),prePoint.y())
|
|
|
|
+ for point in self.points:
|
|
|
|
+ path.lineTo(point.x(),point.y())
|
|
|
|
+ painter.drawPath(path)
|
|
|
|
+ if self.fill:
|
|
|
|
+ painter.fillPath(path,Qt.red)
|