コード例 #1
0
 def setUp(self):
     blankSVGpath = './blank.svg'
     svgTree = etree.parse(blankSVGpath)
     svgRoot = svgTree.getroot()
     self.svgFile = svg.SVG()
     self.svgFile.setSvg(svgRoot)
     self.linac = Linac()
コード例 #2
0
    def testFoundElement(self):
        linac = Linac()
        linac.addSection("TEST-abc")
        linac.updateSvg()
        zoomNode = self.svgFile.getZoom2Background()
        sectionRectNode = self.svgFile.getElementById("section1bottomRect",
                                                      zoomNode)

        self.assertEqual(sectionRectNode.attrib["id"], "section1bottomRect")
        self.assertEqual(sectionRectNode.attrib["width"], "630")
コード例 #3
0
    def testAssigningSvgCoordinate(self):
        device = Device("abc/testDevice", None, None)
        self.assertEqual(device.svgCoordinateX, None)

        linac = Linac()
        linac.addSection("abc")
        linac.addDevice(device)
        device.assignSvgCoordinatesForLinacDevice()
        testSection = linac.getSection("abc")
        sectionStartCoordinate = testSection.startCoordinate
        distanceBetweenDevices = testSection.getDistanceBetweenDevices()

        self.assertEqual(device.svgCoordinateX,
                         sectionStartCoordinate + distanceBetweenDevices)
コード例 #4
0
    def testDrawDevice(self):
        icon = Icon("symbol-quadrupole.svg")
        device = Device("I-K01/VAC/I-K01CAB05-VAC-IPCU1", icon, (113, 122))
        linac = Linac()
        linac.addSection("I-K01")
        linac.addDevice(device)

        blankSVGpath = 'blank.svg'
        svgTree = etree.parse(blankSVGpath)
        svgRoot = svgTree.getroot()
        svgFile = svg.SVG()
        svgFile.setSvg(svgRoot)

        device.updateSvg()
        vacNode = svgFile.getSubsystemZoomNode("VAC")
        deviceNode = svgFile.getElementById("ik01vacik01cab05vacipcu1",
                                            vacNode)
        self.assertEqual(
            deviceNode.attrib["{http://www.w3.org/1999/xlink}href"],
            "#symbol-quadrupole")
        descriptionNode = svgFile.getElementById(
            "ik01vacik01cab05vacipcu1Desc", deviceNode)
        self.assertEqual(descriptionNode.text,
                         "device=I-K01/VAC/I-K01CAB05-VAC-IPCU1")
コード例 #5
0
#!/usr/bin/python

import src.svg as svg
from src.Linac import Linac
from lxml import etree
from src.TangoDeviceManager import TangoDeviceManager

blankSVGpath = './src/blank.svg'

svgTree = etree.parse(blankSVGpath)
svgRoot = svgTree.getroot()

svgFile = svg.SVG()
svgFile.setSvg(svgRoot)

print "SVG file loaded "

L = Linac()
L.addSection("AB-01")
L.addSection("BB02")
L.addSection("CC03")
L.addLastLongSection()
L.updateSvg()

svgRoot = svgFile.getSvg()
toWrite = etree.tostring(svgRoot, pretty_print=True)
fd = open("new.svg", 'w')
fd.write(toWrite)