GraphicCommons.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:beremiz 作者: nucleron 项目源码 文件源码
def TestSegment(self, pt, all=False):
        for i in xrange(len(self.Segments)):
            # If wire is not in a Ladder Diagram, first and last segments are excluded
            if all or 0 < i < len(self.Segments) - 1:
                x1, y1 = self.Points[i].x, self.Points[i].y
                x2, y2 = self.Points[i + 1].x, self.Points[i + 1].y
                # Calculate a rectangle around the segment
                rect = wx.Rect(min(x1, x2) - ANCHOR_DISTANCE, min(y1, y2) - ANCHOR_DISTANCE,
                               abs(x1 - x2) + 2 * ANCHOR_DISTANCE, abs(y1 - y2) + 2 * ANCHOR_DISTANCE)
                if rect.InsideXY(pt.x, pt.y):
                    return i, self.Segments[i]
        return None

    # Define the wire points
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号