def _paint_grid(self): area = self.scene_area # Fixme: if area is None: return xinf, xsup = area.x.inf, area.x.sup yinf, ysup = area.y.inf, area.y.sup length = min(area.x.length, area.y.length) color = QColor('black') brush = QBrush(color) pen = QPen(brush, .75) self._painter.setPen(pen) self._painter.setBrush(Qt.NoBrush) step = max(10**int(math.log10(length)), 10) small_step = step // 10 self._logger.info('Grid of {}/{} for {:.1f} mm'.format( step, small_step, length)) self._paint_axis_grid(xinf, xsup, yinf, ysup, True, step) self._paint_axis_grid(yinf, ysup, xinf, xsup, False, step) color = QColor('black') brush = QBrush(color) pen = QPen(brush, .25) self._painter.setPen(pen) self._painter.setBrush(Qt.NoBrush) self._paint_axis_grid(xinf, xsup, yinf, ysup, True, small_step) self._paint_axis_grid(yinf, ysup, xinf, xsup, False, small_step)
def _paint_cubic(self, item, vertices): pen = self._set_pen(item) path = QPainterPath() path.moveTo(vertices[0]) path.cubicTo(*vertices[1:]) self._painter.drawPath(path) path_style = item.path_style # if path_style.show_control: if getattr(path_style, 'show_control', False): color = QColor(str(path_style.control_color)) brush = QBrush(color) pen = QPen(brush, 1) # Fixme self._painter.setPen(pen) self._painter.setBrush(Qt.NoBrush) path = QPainterPath() path.moveTo(vertices[0]) for vertex in vertices[1:]: path.lineTo(vertex) self._painter.drawPath(path) # Fixme: radius = 3 self._painter.setBrush(brush) for vertex in vertices: self._painter.drawEllipse(vertex, radius, radius) self._painter.setBrush(Qt.NoBrush) # Fixme:
def _set_pen(self, item): path_syle = item.path_style # print('_set_pen', item, path_syle) if item.selected: color = QColor('red') # Fixme: style else: color = path_syle.stroke_color if color is not None: color = QColor(str(color)) color.setAlphaF(path_syle.stroke_alpha) else: color = None line_style = self.__STROKE_STYLE__[path_syle.stroke_style] line_width = path_syle.line_width_as_float # Fixme: selection style if item.selected: line_width *= 4 fill_color = path_syle.fill_color if fill_color is not None: color = QColor(str(fill_color)) color.setAlphaF(path_syle.fill_alpha) self._painter.setBrush(color) # return None else: self._painter.setBrush(Qt.NoBrush) # print(item, color, line_style) if color is None or line_style is StrokeStyle.NoPen: # invisible item pen = QPen(Qt.NoPen) # print('Warning Pen:', item, item.user_data, color, line_style) return None else: pen = QPen( QBrush(color), line_width, line_style, self.__CAP_STYLE__[path_syle.cap_style], self.__JOIN_STYLE__[path_syle.join_style], ) self._painter.setPen(pen) return pen