GraphicCommons.py 文件源码

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

项目:beremiz 作者: nucleron 项目源码 文件源码
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        # If user trying to connect wire with wrong input, highlight will become red.
        if self.ErrHighlight and not (self.EndConnected):
            highlightcolor = wx.RED
        else:
            highlightcolor = HIGHLIGHTCOLOR
        dc.SetPen(MiterPen(highlightcolor, (2 * scalex + 5)))
        dc.SetBrush(wx.Brush(highlightcolor))
        dc.SetLogicalFunction(wx.AND)
        # Draw the start and end points if they are not connected or the mouse is over them
        if len(self.Points) > 0 and (not self.StartConnected or self.OverStart):
            dc.DrawCircle(round(self.Points[0].x * scalex),
                          round(self.Points[0].y * scaley),
                          (POINT_RADIUS + 1) * scalex + 2)
        if len(self.Points) > 1 and (not self.EndConnected or self.OverEnd):
            dc.DrawCircle(self.Points[-1].x * scalex, self.Points[-1].y * scaley, (POINT_RADIUS + 1) * scalex + 2)
        # Draw the wire lines and the last point (it seems that DrawLines stop before the last point)
        if len(self.Points) > 1:
            points = [wx.Point(round((self.Points[0].x - self.Segments[0][0]) * scalex),
                               round((self.Points[0].y - self.Segments[0][1]) * scaley))]
            points.extend([wx.Point(round(point.x * scalex), round(point.y * scaley)) for point in self.Points[1:-1]])
            points.append(wx.Point(round((self.Points[-1].x + self.Segments[-1][0]) * scalex),
                                   round((self.Points[-1].y + self.Segments[-1][1]) * scaley)))
        else:
            points = []
        dc.DrawLines(points)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

        if self.StartConnected is not None:
            self.StartConnected.DrawHighlightment(dc)
            self.StartConnected.Draw(dc)
        if self.EndConnected is not None:
            self.EndConnected.DrawHighlightment(dc)
            self.EndConnected.Draw(dc)

    # Draws the wire lines and points
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号