Esempio n. 1
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)
Esempio n. 2
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)
         ]