def generateSvg(self,  c_x, c_y, radialLine_x=None, radialLine_y=None, tail_x=None, tail_y=None, angleText='90°',
                    arrowL1=3,arrowL2=1,arrowW=2, strokeWidth=0.5,  lineColor='blue', textRenderer=None):
        self.svg_lineColor = lineColor
        self.svg_strokeWidth = strokeWidth
        XML_body = []
        if radialLine_x <> None and radialLine_y <> None:
            XML_body.append( self.svgLine(radialLine_x, radialLine_y, c_x, c_y) )
            d = directionVector(
                numpy.array([      c_x, c_y]),
                numpy.array([radialLine_x, radialLine_y]),
                )
            XML_body.append( arrowHeadSVG( numpy.array([c_x, c_y]), d, arrowL1, arrowL2, arrowW, lineColor ) )
            if tail_x <> None and tail_y <> None:
                XML_body.append(  self.svgLine( radialLine_x, radialLine_y, tail_x, radialLine_y) )
                #getting scale factor
                svgText = SvgTextParser( textRenderer(0,0,"0") )
                f = svgText.width()
                box_w = f * 1.6
                rect_w = f * 3
                x, y = tail_x, radialLine_y-box_w/2
                #rects
                XML_body.append(  self.svgLine( x,         y, x        , y+box_w)  )
                XML_body.append(  self.svgLine( x + box_w, y, x + box_w, y+box_w)  )
                xe = x + box_w + rect_w
                XML_body.append(  self.svgLine( x,         y, xe, y)  )
                XML_body.append(  self.svgLine( x,         y+box_w, xe, y+box_w)  )
                XML_body.append(  self.svgLine( xe,        y, xe, y+box_w)  )
                #bend symbol
                XML_body.append(  self.svgLine( x + 0.2*box_w, y + 0.8*box_w, x + 0.8*box_w , y + 0.8*box_w,  textRenderer.fill)  )
                XML_body.append(  self.svgLine( x + 0.2*box_w, y + 0.8*box_w, x + 0.8*box_w , y + 0.2*box_w,  textRenderer.fill)  )
                #text
                XML_body.append( textRenderer(x + box_w*1.2, y+box_w*0.8, angleText) )


        return '<g> %s </g> ''' % "\n".join(XML_body)
def ArrowWithTail_SVG(c_x,
                      c_y,
                      radialLine_x=None,
                      radialLine_y=None,
                      tail_x=None,
                      tail_y=None,
                      arrowL1=3,
                      arrowL2=1,
                      arrowW=2,
                      svgTag='g',
                      svgParms='',
                      strokeWidth=0.5,
                      lineColor='blue'):
    XML_body = []
    if radialLine_x <> None and radialLine_y <> None:
        XML_body.append(
            '<line x1="%f" y1="%f" x2="%f" y2="%f" style="stroke:%s;stroke-width:%1.2f" />'
            % (radialLine_x, radialLine_y, c_x, c_y, lineColor, strokeWidth))
        d = directionVector(
            numpy.array([c_x, c_y]),
            numpy.array([radialLine_x, radialLine_y]),
        )
        XML_body.append(
            arrowHeadSVG(numpy.array([c_x, c_y]), d, arrowL1, arrowL2, arrowW,
                         lineColor))
    if tail_x <> None and tail_y <> None:
        XML_body.append(
            '<line x1="%f" y1="%f" x2="%f" y2="%f" style="stroke:%s;stroke-width:%1.2f" />'
            % (radialLine_x, radialLine_y, tail_x, radialLine_y, lineColor,
               strokeWidth))
    return '''<%s  %s >
%s
</%s> ''' % (svgTag, svgParms, "\n".join(XML_body), svgTag)
    def generateSvg(self,
                    c_x,
                    c_y,
                    radialLine_x=None,
                    radialLine_y=None,
                    tail_x=None,
                    tail_y=None,
                    angleText='90°',
                    arrowL1=3,
                    arrowL2=1,
                    arrowW=2,
                    strokeWidth=0.5,
                    lineColor='blue',
                    textRenderer=None):
        self.svg_lineColor = lineColor
        self.svg_strokeWidth = strokeWidth
        XML_body = []
        if radialLine_x <> None and radialLine_y <> None:
            XML_body.append(self.svgLine(radialLine_x, radialLine_y, c_x, c_y))
            d = directionVector(
                numpy.array([c_x, c_y]),
                numpy.array([radialLine_x, radialLine_y]),
            )
            XML_body.append(
                arrowHeadSVG(numpy.array([c_x, c_y]), d, arrowL1, arrowL2,
                             arrowW, lineColor))
            if tail_x <> None and tail_y <> None:
                XML_body.append(
                    self.svgLine(radialLine_x, radialLine_y, tail_x,
                                 radialLine_y))
                #getting scale factor
                svgText = SvgTextParser(textRenderer(0, 0, "0"))
                f = svgText.width()
                box_w = f * 1.6
                rect_w = f * 3
                x, y = tail_x, radialLine_y - box_w / 2
                #rects
                XML_body.append(self.svgLine(x, y, x, y + box_w))
                XML_body.append(
                    self.svgLine(x + box_w, y, x + box_w, y + box_w))
                xe = x + box_w + rect_w
                XML_body.append(self.svgLine(x, y, xe, y))
                XML_body.append(self.svgLine(x, y + box_w, xe, y + box_w))
                XML_body.append(self.svgLine(xe, y, xe, y + box_w))
                #bend symbol
                XML_body.append(
                    self.svgLine(x + 0.2 * box_w, y + 0.8 * box_w,
                                 x + 0.8 * box_w, y + 0.8 * box_w,
                                 textRenderer.fill))
                XML_body.append(
                    self.svgLine(x + 0.2 * box_w, y + 0.8 * box_w,
                                 x + 0.8 * box_w, y + 0.2 * box_w,
                                 textRenderer.fill))
                #text
                XML_body.append(
                    textRenderer(x + box_w * 1.2, y + box_w * 0.8, angleText))

        return '<g> %s </g> ' '' % "\n".join(XML_body)
Esempio n. 4
0
def ArrowWithTail_SVG( c_x, c_y, radialLine_x=None, radialLine_y=None, tail_x=None, tail_y=None, arrowL1=3,arrowL2=1,arrowW=2, svgTag='g', svgParms='', strokeWidth=0.5,  lineColor='blue'):
    XML_body = []
    if radialLine_x <> None and radialLine_y <> None:
        XML_body.append( '<line x1="%f" y1="%f" x2="%f" y2="%f" style="stroke:%s;stroke-width:%1.2f" />' % (radialLine_x, radialLine_y, c_x, c_y, lineColor, strokeWidth) )
        d = directionVector(
            numpy.array([      c_x, c_y]),
            numpy.array([radialLine_x, radialLine_y]),
            )
        XML_body.append( arrowHeadSVG( numpy.array([c_x, c_y]), d, arrowL1, arrowL2, arrowW, lineColor ) )
    if tail_x <> None and tail_y <> None:
        XML_body.append( '<line x1="%f" y1="%f" x2="%f" y2="%f" style="stroke:%s;stroke-width:%1.2f" />' % (radialLine_x, radialLine_y, tail_x, radialLine_y, lineColor, strokeWidth) )
    return '''<%s  %s >
%s
</%s> ''' % ( svgTag, svgParms, "\n".join(XML_body), svgTag )
    def generateSvg(self,
                    c_x,
                    c_y,
                    radialLine_x=None,
                    radialLine_y=None,
                    tail_x=None,
                    tail_y=None,
                    weldingMarker_x=None,
                    weldingMarker_y=None,
                    arrowL1=3,
                    arrowL2=1,
                    arrowW=2,
                    svgTag='g',
                    svgParms='',
                    strokeWidth=0.5,
                    lineColor='blue',
                    textRenderer=None):
        self.svg_lineColor = lineColor
        self.svg_strokeWidth = strokeWidth
        XML_body = []
        if radialLine_x <> None and radialLine_y <> None:
            XML_body.append(self.svgLine(radialLine_x, radialLine_y, c_x, c_y))
            d = directionVector(
                numpy.array([c_x, c_y]),
                numpy.array([radialLine_x, radialLine_y]),
            )
            XML_body.append(
                arrowHeadSVG(numpy.array([c_x, c_y]), d, arrowL1, arrowL2,
                             arrowW, lineColor))
            if tail_x <> None and tail_y <> None:
                XML_body.append(
                    self.svgLine(radialLine_x, radialLine_y, tail_x,
                                 radialLine_y))
                if weldingMarker_x <> None:
                    self.radialLine_x = radialLine_x  #storing values incase self.weldingMarkerSvg needs them
                    self.radialLine_y = radialLine_y
                    self.tail_x = tail_x
                    self.tail_y = tail_y
                    XML_body.append(
                        self.weldingMarkerSvg(weldingMarker_x, radialLine_y,
                                              lineColor, strokeWidth,
                                              textRenderer))
        return '''<%s  %s >
%s
</%s> ''' % (svgTag, svgParms, "\n".join(XML_body), svgTag)
    def generateSvg(self,  c_x, c_y, radialLine_x=None, radialLine_y=None, tail_x=None, tail_y=None, weldingMarker_x=None, weldingMarker_y=None, 
                    arrowL1=3,arrowL2=1,arrowW=2, svgTag='g', svgParms='', strokeWidth=0.5,  lineColor='blue', textRenderer=None):
        self.svg_lineColor = lineColor
        self.svg_strokeWidth = strokeWidth
        XML_body = []
        if radialLine_x <> None and radialLine_y <> None:
            XML_body.append( self.svgLine(radialLine_x, radialLine_y, c_x, c_y) )
            d = directionVector(
                numpy.array([      c_x, c_y]),
                numpy.array([radialLine_x, radialLine_y]),
                )
            XML_body.append( arrowHeadSVG( numpy.array([c_x, c_y]), d, arrowL1, arrowL2, arrowW, lineColor ) )
            if tail_x <> None and tail_y <> None:
                XML_body.append(  self.svgLine( radialLine_x, radialLine_y, tail_x, radialLine_y) )
                if weldingMarker_x <> None:
                    self.radialLine_x = radialLine_x #storing values incase self.weldingMarkerSvg needs them
                    self.radialLine_y = radialLine_y 
                    self.tail_x = tail_x 
                    self.tail_y = tail_y
                    XML_body.append( self.weldingMarkerSvg( weldingMarker_x, radialLine_y, lineColor, strokeWidth, textRenderer) )
        return '''<%s  %s >
%s
</%s> ''' % ( svgTag, svgParms, "\n".join(XML_body), svgTag )