Exemple #1
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)
Exemple #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)
Exemple #3
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)
         ]
Exemple #4
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)
         ]