Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
4.8.6, 5.12.4
-
None
-
windows7 64bit with Qt5.12.4 msvc2017 32bit
Description
a line QPainterPath with -1.0 slope intersected other QPainterPath return null path!
following is the example code...
#define TOLERANCE 1.0e-3 int main(int argc, char *argv[]) { QApplication a(argc, argv); QGraphicsView view; QGraphicsScene *scene = new QGraphicsScene; view.setScene(scene); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // line 1 QPointF p1( 0.0, 0.0 ); QPointF p2( 200.0, 0.0 ); QPainterPath smallRectPath1; smallRectPath1.addRect( QRectF( p1.x() - TOLERANCE, p1.y() - TOLERANCE, 2 * TOLERANCE, 2 * TOLERANCE ) ); QPainterPath path1; path1.addPolygon( QPolygonF() << p1 << p2 ); path1.connectPath( smallRectPath1 ); // construce a closed trajectory with small rectangle // line 2 QPointF p3( 0.0, -100.0 ); QPointF p4( 200.0, 100.0 ); QPainterPath smallRectPath2; smallRectPath2.addRect( QRectF( p3.x() - TOLERANCE, p3.y() - TOLERANCE, 2 * TOLERANCE, 2 * TOLERANCE ) ); QPainterPath path2; path2.addPolygon( QPolygonF() << p3 << p4 ); // slope is -1.0 path2.connectPath( smallRectPath2 ); // construce a closed trajectory with small rectangle // path1 intersected path2 is null path qDebug() << path1.intersected( path2 ); // line 3 QPointF p5( 200.0, 200.0 ); QPainterPath path3; path3.addPolygon( QPolygonF() << p3 << p5 ); // slope is not -1.0 path3.connectPath( smallRectPath2 ); // construce a closed trajectory with small rectangle // path1 intersected path3 is not null path qDebug() << path1.intersected( path3 ); scene->addPath( path1 ); scene->addPath( path2 ); scene->addPath( path3 ); view.show(); return a.exec(); }
following is output...
===============================================
QPainterPath: Element count=0
QPainterPath: Element count=5
-> MoveTo(x=66.6664, y=0)
-> LineTo(x=66.6667, y=0)
-> LineTo(x=66.6662, y=-0.000666666)
-> LineTo(x=66.666, y=-0.000666667)
-> LineTo(x=66.6664, y=0)