Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72998

QPainterpath return null in operator subtraced

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.9.3, 5.11.2
    • GUI: Painting
    • None
    • Debian9 Qt5.9.3
    • Linux/X11

       
      I have a problem in qpainterpaht calculation.

      Here are the two QPainterPath:

      The two path: subjectpath, clippath. One edge is overlapping in math, but maybe not in computer data

       the path data and the schematic diagram

      Accordint to qpainterpath doc, the result of (subjectpath - clippath) should be subjectpath. But the result in my code is null.

      Would someone give me some advise?

      Thank you!

       

      here is the code:
       
      double dy_x = -0.8609277780573142;

      double dy_y = -179.18974019701932;

      double dx_x = -100.56567051873533;

      double dx_y = 0.48317375299134985;

      double p1_x = 174.49572649572647;

      double p1_y = 239.04273504273505;

      double p2_x = 297.57264957264954;

      double p2_y = 238.4957264957265;

      QPainterPath p1;

      p1.moveTo(p1_x, p1_y);

      p1.lineTo(p1_x - dy_x + dx_x, p1_y - dy_y + dx_y);

      p1.lineTo(p2_x - dy_x - dx_x, p2_y - dy_y - dx_y);

      p1.lineTo(p2_x, p2_y);

      p1.lineTo(p1_x, p1_y);

      QPainterPath p2;

      p2.moveTo(p1_x, p1_y);

      p2.lineTo(p1_x + dy_x + dx_x, p1_y + dy_y + dx_y);

      p2.lineTo(p2_x + dy_x - dx_x, p2_y + dy_y - dx_y);

      p2.lineTo(p2_x, p2_y);

      p2.lineTo(p1_x, p1_y);

      double r1_x = 201.2991452991453;double r1_y = 199.11111111111106;double r2_x = 225.36752136752136;double r2_y = 259.8290598290598;double r3_x = 248.3418803418803;double r3_y = 198.01709401709397;QPainterPath p3;

      p3.moveTo(r1_x, r1_y);

      p3.lineTo(r2_x, r2_y);

      p3.lineTo(r3_x, r3_y);

      p3.lineTo(r1_x, r1_y);

      QPainterPath result = (p3 & p1) - p2;

      if (result.isEmpty()) {

      {{ qDebug()<<"Result is empty";}}

      }

      else {

      {{ qDebug()<<"Result is not empty";}}

      }

      the code diagram, the result should be the orange part!

      if r2_y = 252.8290598290598, the result should be right.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            vgt Eirik Aavitsland
            guojunjie4sd Alex Guo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes