Example #1
0
    def get_fixture_icon(self, fixture):
        """Return an SVG group for a single fixture.

        Search the package data for a symbol for this fixture, then 
        transform as appropriate based on tags and plot scaling.

        Args:
            fixture: the fixture object to create an icon for.

        Returns:
            An ElementTree object representing an SVG 'g' element.
        """
        # Get the base SVG element
        symbol_name = fixture.data['symbol']
        tree = ET.parse(get_data('symbol/'+symbol_name+'.svg'))
        root = tree.getroot()
        svg_ns = {'ns0': 'http://www.w3.org/2000/svg'}
        symbol = root.find('ns0:g', svg_ns)
        # Transform based on scaling and data
        centre = self.get_page_dimensions()[0]/2
        plaster = self.get_plaster_coord()
        scale = float(self.options['scale'])
        plot_pos = lambda dim: (float(fixture.data['pos'+dim])*1000)
        rotation = fixture.get_rotation()
        colour = fixture.get_colour()
        symbol.set('transform', 'scale( '+str(1/scale)+' ) '
                   'translate('+str(centre*scale+plot_pos('X'))+' '+
                   str(plot_pos('Y')+plaster*scale)+') '
                   'rotate('+str(rotation)+')')
        for path in symbol:
            if path.get('class') == 'outer':
                path.set('fill', colour)
                path.set('stroke-width', 
                         str(float(self.options['line-weight-heavy'])*scale))
        return symbol
Example #2
0
 def __init__(self, fixture):
     """Load the fixture symbol file."""
     self.fixture = fixture
     symbol_name = fixture.data['symbol']
     tree = ET.parse(get_data('symbol/'+symbol_name+'.svg'))
     root = tree.getroot()
     self.ns = {'ns0': 'http://www.w3.org/2000/svg'}
     self.image_group = root.find('ns0:g', self.ns)