Example #1
0
 def _get_pen(self, properties: Properties) -> qg.QPen:
     """Returns a cosmetic pen with applied lineweight but without line type
     support.
     """
     px = (
         properties.lineweight
         / 0.3527
         * self.config.lineweight_scaling
         * self._extra_lineweight_scaling
     )
     pen = qg.QPen(self._get_color(properties.color), px)
     # Use constant width in pixel:
     pen.setCosmetic(True)
     pen.setJoinStyle(qc.Qt.RoundJoin)
     return pen
Example #2
0
    def __init__(
        self,
        scene: Optional[qw.QGraphicsScene] = None,
        *,
        use_text_cache: bool = True,
        debug_draw_rect: bool = False,
        extra_lineweight_scaling: float = 2.0,
    ):
        """
        Args:
            extra_lineweight_scaling: compared to other backends,
                PyQt draws lines which appear thinner
        """
        super().__init__()
        self._scene = scene or qw.QGraphicsScene()  # avoids many type errors
        self._color_cache: Dict[Color, qg.QColor] = {}
        self._pattern_cache: Dict[PatternKey, int] = {}
        self._no_line = qg.QPen(qc.Qt.NoPen)
        self._no_fill = qg.QBrush(qc.Qt.NoBrush)

        self._text_renderer = TextRenderer(qg.QFont(), use_text_cache)
        self._line_renderer: PyQtLineRenderer
        self._extra_lineweight_scaling = extra_lineweight_scaling
        self._debug_draw_rect = debug_draw_rect
Example #3
0
 def __init__(self, x: float, y: float, brush: qg.QBrush):
     super().__init__()
     self.location = qc.QPointF(x, y)
     self.radius = 1.0
     self.setPen(qg.QPen(qc.Qt.NoPen))
     self.setBrush(brush)