Пример #1
0
    def Update(self, ShapeObj1, ShapeObj2):
        if ShapeObj1 == None or ShapeObj2 == None:
            return
        if ShapeObj2.isLine():
            tmp = ShapeObj1
            ShapeObj1 = ShapeObj2
            ShapeObj2 = tmp

        if ShapeObj1.isRing() == False:
            self.m_start = Geometry.GetMidPoint(ShapeObj1.m_start,
                                                ShapeObj1.m_end)
        else:
            pathPaint = QPainterPath()
            startPoint = QPoint(
                ShapeObj1.m_start.x() +
                (ShapeObj1.m_end.x() - ShapeObj1.m_start.x()) / 4,
                ShapeObj1.m_start.y())
            end = QPoint(
                ShapeObj1.m_start.x() +
                (ShapeObj1.m_end.x() - ShapeObj1.m_start.x()) / 4 * 3,
                ShapeObj1.m_start.y())
            startPoint += QPoint(
                0.0, (ShapeObj1.m_start.y() - ShapeObj1.m_end.y()) / 2)
            endPoint = startPoint + QPoint(end.x() - startPoint.x(), 0)
            self.m_start = Geometry.GetMidPoint(startPoint, endPoint)

        lMPoint = ShapeObj2.GetConnerPoints()
        nMinLen = 1000000
        nLen = len(lMPoint)
        for i in range(nLen):
            nDis = Geometry.GetDistance(lMPoint[i], self.m_start)
            if nDis < nMinLen:
                nMinLen = nDis
                self.m_end = lMPoint[i]
        return
Пример #2
0
 def IsFinish(self):
     nLen = Geometry.GetDistance(self.m_StartQPointObj, self.m_EndQPointObj)
     if nLen < 5:
         self.m_CallBackFuntion()
         print 'is finish'
         return True
     else:
         return False
Пример #3
0
 def GetInterPoint(self, PointObj):
     lMPoint = self.GetConnerPoints()
     nMinLen = 10000000
     nRet = QPoint()
     for MPointObj in lMPoint:
         nLen = Geometry.GetDistance(MPointObj, PointObj)
         if nMinLen > nLen:
             nMinLen = nLen
             nRet = copy.deepcopy(MPointObj)
     return nRet
Пример #4
0
 def FollowDiamond(self, DiamondObj):
     #跟蹤離他最近的角點
     lMPoint = DiamondObj.GetConnerPoints()
     if DiamondObj.m_nId == self.m_left:
         nLen = len(lMPoint)
         for i in range(nLen):
             nDistance = Geometry.GetDistance(lMPoint[i], self.m_start)
             if nDistance < 10:
                 self.m_start = lMPoint[i]
                 break
     elif DiamondObj.m_nId == self.m_right:
         nLen = len(lMPoint)
         for i in range(nLen):
             nDistance = Geometry.GetDistance(lMPoint[i], self.m_end)
             if nDistance < 10:
                 self.m_end = lMPoint[i]
                 break
     else:
         return