Skip to content

QGraphicsEllipseItem gives wrong shape #1095

@neumann-nico

Description

@neumann-nico

I'm trying to combine multiple QGraphicsEllipseItem to one QPainterPath. To archive this I use the shape() function and simplify the QPainterPath.
When I set the span angle to 360 degrees I get the right output. But when I use a lower degree (e. g. 359 or 180) I get strange shape.
Red is what I want and blue is what I get.

Short description

QGraphicsEllipseItem gives strange shape when the span angle is below 360 degrees.

screenshot

Expected behavior

The red shape

Real behavior

The blue shape

Code to reproduce

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui


app = QtGui.QApplication([])

pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')

win = pg.GraphicsWindow()
canvas1 = win.addPlot()
canvas2 = win.addPlot()

canvas1.setAspectLocked(True)
canvas2.setAspectLocked(True)

ellipse1 = QtGui.QGraphicsEllipseItem(0, 0, 20, 20)
ellipse1.setStartAngle(0 * 16)
ellipse1.setSpanAngle(180 * 16)
ellipse1.setPen(pg.mkPen(0, 0, 0, 255))
ellipse1.setBrush(pg.mkBrush(255, 0, 0, 255))
canvas1.addItem(ellipse1)

ellipse2 = QtGui.QGraphicsEllipseItem(0, 20, 20, 20)
ellipse2.setStartAngle(0 * 16)
ellipse2.setSpanAngle(360 * 16)
ellipse2.setPen(pg.mkPen(0, 0, 0, 255))
ellipse2.setBrush(pg.mkBrush(255, 0, 0, 255))
canvas1.addItem(ellipse2)

painter_path1 = ellipse1.shape().simplified()
painter_path2 = ellipse2.shape().simplified()

painter_path = QtGui.QPainterPath()
for p in [painter_path1, painter_path2]:
    painter_path += p
#painter_path.closeSubpath()

area = QtGui.QGraphicsPathItem(painter_path)
area.setPen(pg.mkPen(0, 0, 0, 255))
area.setBrush(pg.mkBrush(0, 0, 255, 255))
canvas2.addItem(area)
win.showMaximized()


if __name__ == '__main__':
    QtGui.QApplication.instance().exec_()

Tested environment(s)

  • PyQtGraph version: 0.10.0 (also tried with development version 0.11.0)
  • Qt Python binding: PyQt5 5.13.2 Qt 5.13.2
  • Python version: 3.5.2 and 3.7.5
  • Operating system: Ubuntu 16.04
  • Installation method: pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    need upstream fixFor issues that require an issue in a pyqtgraph dependeny

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions