Example #1
0
def test_toSvg(project, controller):
    rect = RectangleItem(width=400, height=280, project=project)
    pen = QtGui.QPen(QtCore.Qt.black, 2, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)
    pen.setStyle(QtCore.Qt.DashLine)
    rect.setPen(pen)
    svg = ET.fromstring(rect.toSvg())
    assert float(svg.get("width")) ==  400.0
    assert float(svg.get("height")) ==  280.0

    rect = svg[0]
    assert float(rect.get("width")) ==  400.0
    assert float(rect.get("height")) ==  280.0
    assert rect.get("stroke-width") == "2"
    assert rect.get("stroke") == "#000000"
    assert rect.get("fill", "#ffffff")
    assert rect.get("fill-opacity", "1")

    assert rect.get("stroke-dasharray") == "25, 25"
Example #2
0
def test_toSvg_negative_y(project, controller):
    line = LineItem(dst=QtCore.QPointF(400, -280), project=project)
    pen = QtGui.QPen(QtCore.Qt.black, 2, QtCore.Qt.SolidLine,
                     QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)
    pen.setStyle(QtCore.Qt.DashLine)
    line.setPen(pen)
    svg = ET.fromstring(line.toSvg())
    assert float(svg.get("width")) == 400.0
    assert float(svg.get("height")) == 280.0

    line = svg[0]
    assert float(line.get("x1")) == 0.0
    assert float(line.get("y1")) == 0.0
    assert float(line.get("x2")) == 400.0
    assert float(line.get("y2")) == -280.0
    assert line.get("stroke-width") == "2"
    assert line.get("stroke") == "#000000"
    assert line.get("stroke-dasharray") == "25, 25"