Ejemplo n.º 1
0
 def test_Sublists(self):
     atoms = DXFList([
         DXFList([
             DXFAtom('TAG1'),
             DXFAtom('TAG2'),
             DXFList([
                 DXFAtom('TAG14'),
                 DXFAtom('TAG15'),
                 DXFAtom('TAG16'),
             ]),
             DXFAtom('TAG3'),
         ]),
         DXFList([
             DXFAtom('TAG4'),
             DXFAtom('TAG5'),
             DXFAtom('TAG6'),
             DXFList([
                 DXFAtom('TAG11'),
                 DXFAtom('TAG12'),
                 DXFAtom('TAG13'),
             ]),
         ]),
         DXFAtom('TAG7'),
     ])
     self.assertEqual(dxfstr(atoms), tags2str(atoms))
Ejemplo n.º 2
0
 def _get_body(self):
     """ Return header section content as DXFList.
     """
     varlist = [
         DXFList((DXFAtom(key, 9), value))
         for key, value in self.variables.items()
     ]
     return DXFList((DXFName('HEADER'), DXFList(varlist)))
Ejemplo n.º 3
0
 def test_flat_DXFList(self):
     atoms = DXFList()
     atoms.append(DXFAtom('HEADER'))
     atoms.append(DXFAtom('SECTION', 1))
     self.assertEqual(dxfstr(atoms), '  0\nHEADER\n  1\nSECTION\n')
     result = tags2str(atoms)
     self.assertEqual(dxfstr(atoms), result)
Ejemplo n.º 4
0
    def get_dxf_entity(self, coords, layer):
        """ Create the cell content as MText-object.

        :param coords: tuple of border-coordinates : left, right, top, bottom
        :param layer: layer, which should be used for dxf entities
        """
        if not len(self.text):
            return DXFList()
        left, right, top, bottom = self.get_workspace_coords(coords)
        style = self.style
        halign = style['halign']
        valign = style['valign']
        rotated = self.style['rotation']
        text = self.text
        if style['stacked']:
            rotated = 0.
            text = '\n'.join((char for char in self.text.replace('\n', ' ')))
        xpos = (left, float(left + right) / 2., right)[halign]
        ypos = (bottom, float(bottom + top) / 2., top)[valign - 1]
        return MText(text, (xpos, ypos),
                     linespacing=self.style['linespacing'],
                     style=self.style['textstyle'],
                     height=self.style['textheight'],
                     rotation=rotated,
                     xscale=self.style['xscale'],
                     halign=halign,
                     valign=valign,
                     color=self.style['textcolor'],
                     layer=layer)
Ejemplo n.º 5
0
Archivo: rect.py Proyecto: msarch/py
 def _build_rect(self):
     data = DXFList()
     self._calc_corners()
     if self.color is not None:
         data.append(self._build_polyline())
     if self.bgcolor is not None:
         data.append(self._build_solid())
     return data
Ejemplo n.º 6
0
 def _get_body(self):
     return DXFList( (DXFName('TABLES'),
                       self.linetypes,
                       self.layers,
                       self.styles,
                       self.views,
                       self.appids,
                       self.viewports,
                       self.ucs,
                       ) )
Ejemplo n.º 7
0
 def _build(self):
     data = DXFList()
     self.points = self._calc_points()
     self._transform_points()
     if self.color is not None:
         data.append(self._build_polyline())
     if self.bgcolor is not None:
         #if _calc_points has been run, rmin is already set
         for i in range(self.segments):
             data.append(self._build_solid_triangle(i))
     return data
Ejemplo n.º 8
0
    def _build(self):
        data = DXFList()
        self.transformed_points = self._transform_points(self.points)
        if self.color is not None:
            data.append(self._build_polyline())
        if self.bgcolor is not None:
            if len(self.points) <= 4:
                data.append(self._build_solid())
            elif self.solidFillQuads:
                for i in range(len(self.points) // 2 - 1):
                    data.append(self._build_solid_quad(i))
            else:
                for i in range(len(self.points) - 2):
                    data.append(self._build_solid_triangle(i))

        return data
Ejemplo n.º 9
0
    def _build_dxf_entities(self):
        """ Create the DXF-TEXT entities. 
        """
        dxf_entities = DXFList()
        textlines = self.textlines

        if len(textlines) > 1:
            if self.mirror & dxfwrite.MIRROR_Y:
                textlines.reverse()
            for linenum, text in enumerate(textlines):
                alignpoint = self._get_align_point(linenum)
                params = self._build_text_params(alignpoint)
                dxf_entities.append(Text(text=text, **params))
        elif len(textlines) == 1:
            params = self._build_text_params(self.insert)
            dxf_entities = Text(text=textlines[0], **params).__dxftags__()
        return dxf_entities
Ejemplo n.º 10
0
 def _build(self):
     data = DXFList()
     ralign = self._get_radius_align()
     self.points = self._calc_points(ralign)
     align_vector = self._get_align_vector()
     self._transform_points(align_vector)
     if self.color is not None:
         data.append(self._build_polyline())
     if self.bgcolor is not None:
         #if _calc_points has been run, rmin is already set
         if self.rmin <= 0:
             #if self.angle%(2*math.pi) == math.radians(90): #rounded corner case
             for i in range(self.segments + 1):
                 data.append(self._build_solid_triangle(i))
         else:  #rmin>0, normal operation
             for i in range(self.segments + 1):
                 data.append(self._build_solid_quad(i))
     return data
Ejemplo n.º 11
0
 def __dxftags__(self):
     return DXFList(
         (DXFAtom('SECTION'), DXFList(self._get_body()), DXFAtom('ENDSEC')))
Ejemplo n.º 12
0
 def test_empty_DXFList(self):
     atoms = DXFList()
     self.assertEqual(dxfstr(atoms), '')
     self.assertEqual(dxfstr(atoms), tags2str(atoms))
Ejemplo n.º 13
0
 def _get_body(self):
     return DXFList((DXFName('ENTITIES'), self.entities))
Ejemplo n.º 14
0
 def __init__(self):
     self.entities = DXFList()
Ejemplo n.º 15
0
 def _get_body(self):
     body = DXFList()
     body.append(DXFName('BLOCKS'))
     body.extend(self.blocks.values())
     return body
Ejemplo n.º 16
0
 def _setup(self):
     """ Table generation setup.
     """
     self.data = DXFList()
     self.visibility_map = VisibilityMap(self)
     self.grid = Grid(self)
Ejemplo n.º 17
0
 def get_dxf_entity(self, coords, layer):
     return DXFList()