def test_dash_dot_2x_render_issue():
    # DASHDOTX2 (0, 0) -> (20, 0)
    ltr = LineTypeRenderer(dashes=(2.0, 0.2, 0.1, 0.2))
    result = list(ltr.line_segment((0, 0), (20, 0)))
    last_segment = result[-1]
    # Last segment is very very short:
    assert last_segment[0].isclose(last_segment[1])
Exemplo n.º 2
0
 def draw_path(self, path, properties: Properties, z: float):
     pattern = self.pattern(properties)
     lineweight = self.lineweight(properties)
     color = properties.color
     if len(pattern) < 2:
         vertices, codes = _get_path_patch_data(path)
         patch = PathPatch(
             Path(vertices, codes),
             linewidth=lineweight,
             color=color,
             fill=False,
             zorder=z,
         )
         self.ax.add_patch(patch)
     else:
         renderer = EzdxfLineTypeRenderer(pattern)
         segments = renderer.line_segments(
             path.flattening(self._config.max_flattening_distance,
                             segments=16))
         lines = LineCollection(
             [((s.x, s.y), (e.x, e.y)) for s, e in segments],
             linewidths=lineweight,
             color=color,
             zorder=z,
         )
         lines.set_capstyle("butt")
         self.ax.add_collection(lines)
def test_dashed_line_4():
    ltr = LineTypeRenderer(dashes=(1, 1))
    result = list(ltr.line_segment((0, 0), (4, 0)))
    assert len(result) == 2
    assert result[0] == ((0, 0), (1, 0))
    # 1,0 -> 2,0 is a gap
    assert result[1] == ((2, 0), (3, 0))
Exemplo n.º 4
0
 def draw_line(self, start: Vec3, end: Vec3, properties: Properties,
               z: float):
     pattern = self.pattern(properties)
     lineweight = self.lineweight(properties)
     color = properties.color
     if len(pattern) < 2:
         self.ax.add_line(
             Line2D(
                 (start.x, end.x),
                 (start.y, end.y),
                 linewidth=lineweight,
                 color=color,
                 zorder=z,
             ))
     else:
         renderer = EzdxfLineTypeRenderer(pattern)
         lines = LineCollection(
             [((s.x, s.y), (e.x, e.y))
              for s, e in renderer.line_segment(start, end)],
             linewidths=lineweight,
             color=color,
             zorder=z,
         )
         lines.set_capstyle("butt")
         self.ax.add_collection(lines)
Exemplo n.º 5
0
 def draw_line(self, start: Vec3, end: Vec3, properties: Properties, z=0):
     pattern = self.pattern(properties)
     pen = self.get_pen(properties)
     if len(pattern) < 2:
         return self.scene.addLine(start.x, start.y, end.x, end.y, pen)
     else:
         add_line = self.scene.addLine
         renderer = EzdxfLineTypeRenderer(pattern)
         return [
             add_line(s.x, s.y, e.x, e.y, pen)
             for s, e in renderer.line_segment(start, end)
             # PyQt has problems with very short lines:
             if not s.isclose(e)
         ]
Exemplo n.º 6
0
 def draw_path(self, path, properties: Properties, z=0):
     pattern = self.pattern(properties)
     pen = self.get_pen(properties)
     render_linetypes = bool(self.linetype_scaling)
     if len(pattern) < 2 or not render_linetypes:
         qt_path = qg.QPainterPath()
         _extend_qt_path(qt_path, path)
         return self.scene.addPath(qt_path, pen, self.no_fill)
     else:
         add_line = self.scene.addLine
         renderer = EzdxfLineTypeRenderer(pattern)
         segments = renderer.line_segments(
             path.flattening(self.max_flattening_distance, segments=16))
         return [
             add_line(s.x, s.y, e.x, e.y, pen) for s, e in segments
             # PyQt has problems with very short lines:
             if not s.isclose(e)
         ]
def test_line_type_solid():
    ltr = LineTypeRenderer(dashes=tuple())
    assert ltr.is_solid is True
    assert list(ltr.line_segment((0, 0), (5, 0))) == [((0, 0), (5, 0))]
def test_dashed_line_2():
    ltr = LineTypeRenderer(dashes=(1, 1))
    result = list(ltr.line_segment((0, 0), (2, 0)))
    assert len(result) == 1
    assert result[0] == ((0, 0), (1, 0))
def test_line_start_is_end():
    ltr = LineTypeRenderer(dashes=tuple())
    assert list(ltr.line_segment((0, 0), (0, 0))) == [((0, 0), (0, 0))]