Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpathclipper.cpp File Reference

(f8f23c43feb2fb233a8f047cd1b82259498d9aeb)

#include "qpathclipper_p.h"
#include <private/qbezier_p.h>
#include <private/qdatabuffer_p.h>
#include <private/qnumeric_p.h>
#include <qmath.h>
#include <algorithm>
#include <qdebug.h>
+ Include dependency graph for qpathclipper.cpp:

Go to the source code of this file.

Classes

struct  QIntersection
 
class  QIntersectionFinder
 
class  QKdPointTree
 
struct  QKdPointTree::Node
 
class  QKdPointFinder
 
struct  QCrossingEdge
 

Functions

static QT_BEGIN_NAMESPACE bool fuzzyIsNull (qreal d)
 
static bool comparePoints (const QPointF &a, const QPointF &b)
 
static qreal dot (const QPointF &a, const QPointF &b)
 
static void normalize (double &x, double &y)
 
 Q_DECLARE_TYPEINFO (QIntersection, Q_PRIMITIVE_TYPE)
 
template<typename T >
void qTraverseKdPointTree (QKdPointTree::Node &node, T &t, int depth=0)
 
static qreal component (const QPointF &point, unsigned int i)
 
static bool isLine (const QBezier &bezier)
 
static int commonEdge (const QWingedEdge &list, int a, int b)
 
static double computeAngle (const QPointF &v)
 
static void addLineTo (QPainterPath &path, const QPointF &point)
 
static void add (QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
 
static void clear (QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
 
template<typename InputIterator >
InputIterator qFuzzyFind (InputIterator first, InputIterator last, qreal val)
 
static bool fuzzyCompare (qreal a, qreal b)
 
static void traverse (QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
 
 Q_DECLARE_TYPEINFO (QCrossingEdge, Q_PRIMITIVE_TYPE)
 
static bool bool_op (bool a, bool b, QPathClipper::Operation op)
 
static QList< QCrossingEdgefindCrossings (const QWingedEdge &list, qreal y)
 

Function Documentation

◆ add()

static void add ( QPainterPath & path,
const QWingedEdge & list,
int edge,
QPathEdge::Traversal traversal )
static

◆ addLineTo()

static void addLineTo ( QPainterPath & path,
const QPointF & point )
static

Definition at line 1252 of file qpathclipper.cpp.

References d1, d2, dot(), QPainterPath::LineToElement, qFuzzyIsNull(), QPainterPath::Element::type, QPointF::x(), and QPointF::y().

Referenced by add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bool_op()

static bool bool_op ( bool a,
bool b,
QPathClipper::Operation op )
static

◆ clear()

◆ commonEdge()

static int commonEdge ( const QWingedEdge & list,
int a,
int b )
static

Definition at line 1091 of file qpathclipper.cpp.

References QWingedEdge::TraversalStatus::direction, QWingedEdge::TraversalStatus::edge, QPathEdge::first, QWingedEdge::TraversalStatus::flip(), list, Q_ASSERT, QPathEdge::RightTraversal, QPathEdge::second, and QWingedEdge::TraversalStatus::traversal.

Referenced by QWingedEdge::addEdge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ comparePoints()

static bool comparePoints ( const QPointF & a,
const QPointF & b )
inlinestatic

Definition at line 40 of file qpathclipper.cpp.

References fuzzyIsNull().

Referenced by QPathSegments::addPath(), and isLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ component()

static qreal component ( const QPointF & point,
unsigned int i )
inlinestatic

Definition at line 626 of file qpathclipper.cpp.

References i, Q_ASSERT, QPointF::x(), and QPointF::y().

Referenced by QQuickVisualTestUtils::QQuickApplicationHelper::QQuickApplicationHelper(), TestCaseCollector::TestCaseCollector(), QQmlJS::Dom::QmlFile::addComponent(), QQmlPropertyCacheAliasCreator< ObjectContainer >::appendAliasesToPropertyCache(), appendComponentIfPresent(), QKdPointTree::build(), QQmlDataTest::canImportModule(), QQuickControlsTestUtils::ComponentCreator::createComponent(), QQuickDesignerSupportItems::createComponent(), QQmlObjectCreator::createComponent(), QQuickItemViewPrivate::createComponentItem(), QQuickSwipePrivate::createDelegateItem(), QQuickFolderBreadcrumbBarPrivate::createDelegateItem(), createDimmer(), createDummyWindow(), QQuickMacFocusFrame::createFocusFrame(), QQuickWindowsFocusFrame::createFocusFrame(), QQuickPopupPrivate::createOverlay(), QtObject::createQmlObject(), QCoreGraphicsPaintEngine::drawTiledPixmap(), QQmlJS::Dom::QQmlDomAstCreator::endVisit(), QQmlJSImportVisitor::endVisit(), Expectations::expectFive(), Expectations::expectFour(), Expectations::expectOne(), Expectations::expectThree(), Expectations::expectTwo(), QQmlIncubatorPrivate::incubate(), QQmlIncubatorPrivate::incubateCppBasedComponent(), QQmlComponentPrivate::incubateObject(), QQuickToolTipAttachedPrivate::instance(), QOpenXRSpaceExtension::isComponentSupported(), QQmlJS::AST::UiInlineComponent::lastSourceLocation(), main(), objectForId(), operator<<(), QQmlJS::Dom::MutableDomItem::operator[](), QQmlJS::Dom::DomItem::operator[](), QQmlJS::Dom::MutableDomItem::operator[](), QQmlJS::Dom::MutableDomItem::operator[](), QAbstractTextDocumentLayout::registerHandler(), QQmlComponentAndAliasResolver< ObjectContainer >::resolve(), QQmlLSUtils::resolveExpressionType(), QQuickView::setContent(), QQuickWidget::setContent(), QQmlComponent::setInitialProperties(), QGraphicsLayoutItemPrivate::setSizeComponent(), QOpenGLTexture::setSwizzleMask(), QQmlEnginePrivate::singletonInstance(), statusChanged(), QOpenGLTexture::swizzleMask(), QAbstractTextDocumentLayout::unregisterHandler(), QQuickControlsTestUtils::QQuickStyleHelper::updateStyle(), QQmlJSImportVisitor::visit(), withComponent(), and QQmlJSStreamWriter::writeStartObject().

+ Here is the call graph for this function:

◆ computeAngle()

static double computeAngle ( const QPointF & v)
static

Definition at line 1121 of file qpathclipper.cpp.

References normalize(), Q_PI, and qAtan2().

Referenced by QWingedEdge::addEdge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dot()

◆ findCrossings()

static QList< QCrossingEdge > findCrossings ( const QWingedEdge & list,
qreal y )
static

Definition at line 1747 of file qpathclipper.cpp.

References QPathEdge::first, i, list, and QPathEdge::second.

◆ fuzzyCompare()

static bool fuzzyCompare ( qreal a,
qreal b )
static

Definition at line 1452 of file qpathclipper.cpp.

References qFuzzyCompare().

+ Here is the call graph for this function:

◆ fuzzyIsNull()

static QT_BEGIN_NAMESPACE bool fuzzyIsNull ( qreal d)
inlinestatic

The algorithm is as follows:

  1. Find all intersections between the two paths (including self-intersections), and build a winged edge structure of non-intersecting parts.
  2. While there are more unhandled edges:
    1. Pick a y-coordinate from an unhandled edge.
    2. Intersect the horizontal line at y-coordinate with all edges.
    3. Traverse intersections left to right deciding whether each subpath should be added or not.
    4. If the subpath should be added, traverse the winged-edge structure and add the edges to a separate winged edge structure.
    5. Mark all edges in subpaths crossing the horizontal line as handled.

(Optional) Simplify the resulting winged edge structure by merging shared edges.

  1. Convert the resulting winged edge structure to a painter path.

Definition at line 32 of file qpathclipper.cpp.

References d, and qAbs().

Referenced by comparePoints(), and QKdPointFinder::operator()().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLine()

static bool isLine ( const QBezier & bezier)
static

Definition at line 855 of file qpathclipper.cpp.

References comparePoints(), QBezier::pt1(), QBezier::pt2(), QBezier::pt3(), and QBezier::pt4().

Referenced by QSGRhiInternalTextNode::addDecorationNode(), QPathSegments::addPath(), QQuadPath::Element::extent(), QQuadPath::Element::midPoint(), QSGCurveGlyphAtlas::populate(), QSGCurveProcessor::processFill(), QQuadPath::Element::referencePoint(), QQuadPath::Element::segmentFromTo(), and QQuadPath::Element::tangentAtFraction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalize()

static void normalize ( double & x,
double & y )
static

Definition at line 52 of file qpathclipper.cpp.

References qSqrt().

Referenced by computeAngle(), and QRhiGles2::executeCommandBuffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Q_DECLARE_TYPEINFO() [1/2]

Q_DECLARE_TYPEINFO ( QCrossingEdge ,
Q_PRIMITIVE_TYPE  )

◆ Q_DECLARE_TYPEINFO() [2/2]

Q_DECLARE_TYPEINFO ( QIntersection ,
Q_PRIMITIVE_TYPE  )

◆ qFuzzyFind()

template<typename InputIterator >
InputIterator qFuzzyFind ( InputIterator first,
InputIterator last,
qreal val )

Definition at line 1445 of file qpathclipper.cpp.

References qFuzzyCompare().

+ Here is the call graph for this function:

◆ qTraverseKdPointTree()

template<typename T >
void qTraverseKdPointTree ( QKdPointTree::Node & node,
T & t,
int depth = 0 )

◆ traverse()