SFC_Objects.py 文件源码

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

项目:beremiz 作者: nucleron 项目源码 文件源码
def Draw(self, dc):
        Graphic_Element.Draw(self, dc)
        if self.Value:
            dc.SetPen(MiterPen(wx.GREEN))
        else:
            dc.SetPen(MiterPen(wx.BLACK))
        dc.SetBrush(wx.WHITE_BRUSH)
        colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
        # Draw plain rectangle for representing the action block
        dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
        dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y,
                    self.Pos.x + colsize[0], self.Pos.y + self.Size[1])
        dc.DrawLine(self.Pos.x + colsize[0] + colsize[1], self.Pos.y,
                    self.Pos.x + colsize[0] + colsize[1], self.Pos.y + self.Size[1])
        line_size = self.GetLineSize()
        for i, action in enumerate(self.Actions):
            if i != 0:
                dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size,
                            self.Pos.x + self.Size[0], self.Pos.y + i * line_size)
            qualifier_size = dc.GetTextExtent(action.qualifier)
            if action.duration != "":
                qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
                                 self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1])
                duration_size = dc.GetTextExtent(action.duration)
                duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2,
                                self.Pos.y + i * line_size + line_size / 2)
                dc.DrawText(action.duration, duration_pos[0], duration_pos[1])
            else:
                qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
                                 self.Pos.y + i * line_size + (line_size - qualifier_size[1]) / 2)
            dc.DrawText(action.qualifier, qualifier_pos[0], qualifier_pos[1])
            content_size = dc.GetTextExtent(action.value)
            content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2,
                           self.Pos.y + i * line_size + (line_size - content_size[1]) / 2)
            dc.DrawText(action.value, content_pos[0], content_pos[1])
            if action.indicator != "":
                indicator_size = dc.GetTextExtent(action.indicator)
                indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2,
                                 self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2)
                dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1])

            if not getattr(dc, "printing", False):
                action_highlights = self.Highlights.get(i, {})
                for name, attribute_highlights in action_highlights.iteritems():
                    if name == "qualifier":
                        DrawHighlightedText(dc, action.qualifier, attribute_highlights, qualifier_pos[0], qualifier_pos[1])
                    elif name == "duration":
                        DrawHighlightedText(dc, action.duration, attribute_highlights, duration_pos[0], duration_pos[1])
                    elif name in ["reference", "inline"]:
                        DrawHighlightedText(dc, action.value, attribute_highlights, content_pos[0], content_pos[1])
                    elif name == "indicator":
                        DrawHighlightedText(dc, action.indicator, attribute_highlights, indicator_pos[0], indicator_pos[1])

        # Draw input connector
        self.Input.Draw(dc)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号