def _paint_arc(self, item, center, radius_x, radius_y): if item.is_closed: self._painter.drawEllipse(center, radius_x, radius_y) else: # drawArc cannot be filled ! rectangle = QRectF( center + QPointF(-radius_x, radius_y), center + QPointF(radius_x, -radius_y), ) start_angle, stop_angle = [ int(angle * 16) for angle in (item.start_angle, item.stop_angle) ] span_angle = stop_angle - start_angle if span_angle < 0: span_angle = 5760 + span_angle self._painter.drawArc(rectangle, start_angle, span_angle)
def _update_viewport_area(self): offset = self._viewport_size / 2 * self.scale_mm_by_px x, y = self._center dx, dy = offset self._area = Interval2D( (x - dx, x + dx), (y - dy, y + dy), ) # Fixme: QPointF ??? self._translation = -QPointF(self._area.x.inf, self._area.y.sup)
def scene_to_viewport(self, position): point = QPointF(position.x, position.y) point += self._translation point *= self._scale point = QPointF(point.x(), -point.y()) return point
def viewport_to_scene(self, position): point = QPointF(position.x(), -position.y()) point /= self._scale point -= self._translation return self._point_to_np(point)
def scene_to_viewport(self, position): return QPointF(position.x * self._scale, position.y * self._scale)