+ if (gp == NULL)
+ return NULL;
+
+ if (path != NULL)
+ delete path;
+
+ path = new QPainterPath();
+// path->setFillRule(Qt::OddEvenFill);
+ path->setFillRule(Qt::WindingFill);
+
+ // Draw curve formed by points
+
+ for(int poly=0; poly<gp->GetNumPolys(); poly++)
+ {
+ if (gp->GetNumPoints(poly) < 3)
+ continue;
+
+ // Initial move: If our start point is on curve, then go to it.
+ // Otherwise, check previous point. If it's on curve, go to it
+ // otherwise go the midpoint between start point and previous (since
+ // it's between two curve control points).
+ IPoint pt = (gp->GetOnCurve(poly, 0)
+ ? gp->GetPoint(poly, 0) : (gp->GetPrevOnCurve(poly, 0)
+ ? gp->GetPrevPoint(poly, 0) : gp->GetMidpointToPrev(poly, 0)));
+ path->moveTo(pt.x, pt.y);
+
+ for(int i=0; i<gp->GetNumPoints(poly); i++)
+ {
+ // If this point and then next are both on curve, we have a line...
+ if (gp->GetOnCurve(poly, i) && gp->GetNextOnCurve(poly, i))
+ path->lineTo(gp->GetNextX(poly, i), gp->GetNextY(poly, i));
+ else
+ {
+ // Skip point if it's on curve (start of curve--it's already
+ // been plotted so we don't need to handle it...)
+ if (gp->GetOnCurve(poly, i))
+ continue;
+
+ // We are now guaranteed that we are sitting on a curve control
+ // point (off curve). Figure the extent of the curve: If the
+ // following is a curve control point, then use the midpoint to
+ // it otherwise go to the next point since it's on curve.
+ IPoint pt = (gp->GetNextOnCurve(poly, i)
+ ? gp->GetNextPoint(poly, i) : gp->GetMidpointToNext(poly, i));
+
+ path->quadTo(gp->GetX(poly, i), gp->GetY(poly, i), pt.x, pt.y);
+ }
+ }
+
+ path->closeSubpath();
+ }
+
+ return path;