예제 #1
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
예제 #2
0
파일: dimlines.py 프로젝트: msarch/py
 def _draw_dimension_text(self):
     insert_point = self._get_insert_point()
     dimtext = self._get_dimtext()
     rotation = degrees(vector2angle(self.target_vector))
     self.data.append(
         Text(text=dimtext,
              insert=insert_point,
              height=self.prop('height'),
              rotation=rotation,
              valign=const.MIDDLE,
              halign=const.RIGHT,
              alignpoint=insert_point,
              layer=self.prop('layer'),
              style=self.prop('style'),
              color=self.prop('textcolor')))
예제 #3
0
파일: dimlines.py 프로젝트: msarch/py
 def _draw_dimension_text(self):
     dimtext = self._get_dimtext()
     insert_point = self._get_text_insert_point()
     rotation = degrees((self.start_angle + self.end_angle) / 2 - pi / 2.)
     self.data.append(
         Text(text=dimtext,
              insert=insert_point,
              height=self.prop('height'),
              rotation=rotation,
              halign=const.CENTER,
              valign=const.MIDDLE,
              layer=self.prop('layer'),
              style=self.prop('style'),
              color=self.prop('textcolor'),
              alignpoint=insert_point))
예제 #4
0
 def test_text_with_attribs(self):
     text = Text(text='Manfred',
                 height=0.7,
                 rotation=30,
                 xscale=2,
                 oblique=75,
                 style='ARIAL',
                 mirror=0,
                 halign=0,
                 valign=0,
                 alignpoint=(0, 0))
     expected = "  0\nTEXT\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n0.0\n 40\n0.7\n  1\nManfred\n" \
              " 50\n30.0\n 41\n2.0\n 51\n75.0\n  7\nARIAL\n 71\n0\n 72\n0\n 73\n0\n" \
              " 11\n0.0\n 21\n0.0\n 31\n0.0\n"
     self.assertEqual(dxfstr(text), expected)
예제 #5
0
파일: dimlines.py 프로젝트: msarch/py
 def _draw_text(self):
     """ build the dimension value text entity """
     for section in range(self.section_count):
         dimvalue_text = self._get_dimvalue_text(section)
         insert_point = self._get_text_insert_point(section)
         self.data.append(
             Text(text=dimvalue_text,
                  insert=insert_point,
                  height=self.prop('height'),
                  color=self.prop('textcolor'),
                  halign=const.CENTER,
                  valign=const.MIDDLE,
                  layer=self.prop('layer'),
                  rotation=self.angle,
                  style=self.prop('style'),
                  alignpoint=insert_point))
예제 #6
0
    def text(text, insert=(0., 0.), height=1.0, **kwargs):
        """ Create a new text entity.

        :param str text: the text to display
        :param insert: insert point (xy- or xyz-tuple), z-axis is 0 by default
        :param float height: text height in drawing-units
        :param float rotation: text rotation in degree, default=0
        :param float xscale: text width factor, default=1
        :param float oblique: text oblique angle in degree, default=0
        :param str style: text style name, default=STANDARD
        :param int mirror: text generation flags, bit-coded, default=0
        :param int halign: horizontal justification type
        :param int valign: vertical justification type
        :param alignpoint: align point (xy- or xyz-tuple), z-axis is 0 by default
            If the justification is anything other than BASELINE/LEFT,
            alignpoint specify the alignment point (or the second alignment
            point for ALIGN or FIT).

        any combination of **valign** (TOP, MIDDLE, BOTTOM) and **halign** (LEFT,
        CENTER, RIGHT) is valid.

        """
        return Text(text=text, insert=insert, height=height, **kwargs)
예제 #7
0
 def test_circle_no_attributes(self):
     text = Text(text='Manfred')
     expected = "  0\nTEXT\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n0.0\n 40\n1.0\n  1\nManfred\n"
     self.assertEqual(dxfstr(text), expected)