Пример #1
0
 def GetAt(self):
     if self.Attribute(0) == '':
         at = Canvas.Position()
     else:
         at = Canvas.Position(float(self.Attribute(0)),
                              float(self.Attribute(1)))
         if self.Attribute(2) != '':
             at.angle = float(self.Attribute(2))
     return at
Пример #2
0
    def Render(self, canvas, obj):
        if len(self.attributes) < 6:
            return

        width = 2
        length = canvas.mm2px(float(self.Attribute(4)))
        if self.Attribute(5) == 'U':
            angle = 3 * math.pi / 2
            text_angle = angle
            text_dx = -10
            text_dy = -length / 2
        elif self.Attribute(5) == 'D':
            angle = math.pi / 2
            text_angle = 3 * math.pi / 2
            text_dx = -10
            text_dy = length / 2
        elif self.Attribute(5) == 'R':
            angle = 0
            text_angle = 0
            text_dx = length / 2
            text_dy = -10
        else:
            angle = math.pi
            text_angle = 0
            text_dx = -length / 2
            text_dy = -10

        start = Canvas.Point(canvas.xmm2px(float(self.Attribute(2))),
                             canvas.ymm2px(-float(self.Attribute(3))))
        end = Canvas.Point(canvas.xmm2px(start.x + length * math.cos(angle)),
                           canvas.ymm2px(start.y + length * math.sin(angle)))
        line = Canvas.Line(start, end, width)
        canvas.Draw(line, ["Drawing"])

        font = Canvas.Font(
            Canvas.Point(canvas.xmm2px(float(self.Attribute(6))),
                         canvas.ymm2px(float(self.Attribute(7)))), 2)
        text = Canvas.Text(self.Attribute(1))
        text.anchor_x = 'center'
        text.anchor_y = ''
        text.at = Canvas.Position(canvas.xmm2px(start.x + text_dx),
                                  canvas.ymm2px(start.y + text_dy), text_angle)
        canvas.SetFont(font)
        canvas.Draw(text, ["Label"])

        circle = Canvas.Circle(
            start,
            Canvas.Point(canvas.xmm2px(start.x + 10), canvas.ymm2px(start.y)),
            1, False)
        canvas.Draw(circle, ["Label"])
Пример #3
0
 def Render(self, canvas, obj):
     if len(self.attributes) < 4:
         return
     font = Canvas.Font(
         Canvas.Point(canvas.xmm2px(float(self.Attribute(3))),
                      canvas.ymm2px(float(self.Attribute(3)))), 2)
     text = Canvas.Text(self.Attribute(7))
     if int(self.Attribute(0)) > 0:
         angle = 3 * math.pi / 2
     else:
         angle = 0
     text.anchor_x = 'center'
     text.anchor_y = 'center'
     text.at = Canvas.Position(canvas.xmm2px(float(self.Attribute(1))),
                               canvas.ymm2px(-float(self.Attribute(2))),
                               angle)
     canvas.SetFont(font)
     canvas.Draw(text, ["Label"])