当前位置: 首页>>代码示例>>C++>>正文


C++ qFuzzyCompare函数代码示例

本文整理汇总了C++中qFuzzyCompare函数的典型用法代码示例。如果您正苦于以下问题:C++ qFuzzyCompare函数的具体用法?C++ qFuzzyCompare怎么用?C++ qFuzzyCompare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qFuzzyCompare函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: snappingOffsetIterator

QList<QLineF> Snapper::findSnappingOffsetLines(const SnapLineMap &snappingOffsetMap,
                                         Qt::Orientation orientation,
                                         double snapLine,
                                         double lowerLimit,
                                         double upperLimit,
                                         QList<QRectF> *boundingRects) const
{
    QList<QLineF> lineList;

    SnapLineMapIterator snappingOffsetIterator(snappingOffsetMap);
    while (snappingOffsetIterator.hasNext()) {
        snappingOffsetIterator.next();

        const QRectF &formEditorItemRect(snappingOffsetIterator.value().first);
        double formEditorItemRectLowerLimit;
        double formEditorItemRectUpperLimit;
        if (orientation == Qt::Horizontal) {
            formEditorItemRectLowerLimit = formEditorItemRect.left();
            formEditorItemRectUpperLimit = formEditorItemRect.right();
        } else {
            formEditorItemRectLowerLimit = formEditorItemRect.top();
            formEditorItemRectUpperLimit = formEditorItemRect.bottom();
        }


        if (qFuzzyCompare(snapLine, snappingOffsetIterator.key()) &&
           !(lowerLimit > formEditorItemRectUpperLimit ||
             upperLimit < formEditorItemRectLowerLimit)) {
            lineList += createSnapLine(orientation,
                                       snapLine,
                                       lowerLimit,
                                       upperLimit,
                                       formEditorItemRect);
            if (boundingRects != 0)
                boundingRects->append(snappingOffsetIterator.value().first);
        }
    }


    return lineList;
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:41,代码来源:snapper.cpp

示例2: loadPixmap

QPixmap loadPixmap(const QString &path)
{
    qreal ratio = 1.0;
    QPixmap pixmap;

    const qreal devicePixelRatio = qApp->devicePixelRatio();

    if (!qFuzzyCompare(ratio, devicePixelRatio)) {
        QImageReader reader;
        reader.setFileName(qt_findAtNxFile(path, devicePixelRatio, &ratio));
        if (reader.canRead()) {
            reader.setScaledSize(reader.size() * (devicePixelRatio / ratio));
            pixmap = QPixmap::fromImage(reader.read());
            pixmap.setDevicePixelRatio(devicePixelRatio);
        }
    } else {
        pixmap.load(path);
    }

    return pixmap;
}
开发者ID:linuxdeepin,项目名称:dde-control-center,代码行数:21,代码来源:basiclistdelegate.cpp

示例3: paint

void WGraphicsArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    const QLineF& line = m_line;

    if (qFuzzyCompare(line.length(), qreal(0.)))
        return;

    // Draw the line itself
    painter->setPen(m_pen);
    painter->drawLine(line);

    // Draw the arrows
    double angle = ::acos(line.dx() / line.length());
    if (line.dy() >= 0)
        angle = TwoPi - angle;

	painter->setBrush(Qt::black);

	QPointF startPos = m_line.p1();
	QPointF endPos = m_line.p2();
	if (!m_uniDirectedArrow) {
		// QPointF startNodeArrowP1 = startPos + QPointF(sin(angle + Pi / 3) * m_arrowSize,
		// 											  cos(angle + Pi / 3) * m_arrowSize);
		// QPointF startNodeArrowP2 = startPos + QPointF(sin(angle + Pi - Pi / 3) * m_arrowSize,
		// 											  cos(angle + Pi - Pi / 3) * m_arrowSize);
		// painter->drawPolygon(QPolygonF() << line.p1() << startNodeArrowP1 << startNodeArrowP2);
		QLineF arrowPoints = Wf::getArrowPoints(endPos, startPos, m_arrowSize);
		painter->drawPolygon(QPolygonF() << line.p1() << arrowPoints.p1() << arrowPoints.p2());
	}

	{
		// QPointF endNodeArrowP1 = endPos + QPointF(sin(angle - Pi / 3) * m_arrowSize,
		// 										  cos(angle - Pi / 3) * m_arrowSize);
		// QPointF endNodeArrowP2 = endPos + QPointF(sin(angle - Pi + Pi / 3) * m_arrowSize,
		// 										  cos(angle - Pi + Pi / 3) * m_arrowSize);
		// painter->drawPolygon(QPolygonF() << line.p2() << endNodeArrowP1 << endNodeArrowP2);
		QLineF arrowPoints = Wf::getArrowPoints(startPos, endPos, m_arrowSize);
		painter->drawPolygon(QPolygonF() << line.p2() << arrowPoints.p1() << arrowPoints.p2());
	}
}
开发者ID:joonhwan,项目名称:Waffle,代码行数:40,代码来源:WGraphicsArrowItem.cpp

示例4: NewtonRaphsonRootFind

/*
 *  NewtonRaphsonRootFind :
 *  Use Newton-Raphson iteration to find better root.
 */
static qreal NewtonRaphsonRootFind(QPointF *Q, QPointF P, qreal u)
{
    qreal       numerator, denominator;
    QPointF         Q1[3], Q2[2];   /*  Q' and Q''          */
    QPointF     Q_u, Q1_u, Q2_u; /*u evaluated at Q, Q', & Q''  */
    qreal       uPrime;     /*  Improved u          */
    int         i;

    /* Compute Q(u) */
    Q_u = BezierII(3, Q, u);

    /* Generate control vertices for Q' */
    for (i = 0; i <= 2; ++i) {
        Q1[i].setX((Q[i+1].x() - Q[i].x()) * 3.0);
        Q1[i].setY((Q[i+1].y() - Q[i].y()) * 3.0);
    }

    /* Generate control vertices for Q'' */
    for (i = 0; i <= 1; ++i) {
        Q2[i].setX((Q1[i+1].x() - Q1[i].x()) * 2.0);
        Q2[i].setY((Q1[i+1].y() - Q1[i].y()) * 2.0);
    }

    /* Compute Q'(u) and Q''(u) */
    Q1_u = BezierII(2, Q1, u);
    Q2_u = BezierII(1, Q2, u);

    /* Compute f(u)/f'(u) */
    numerator = (Q_u.x() - P.x()) * (Q1_u.x()) + (Q_u.y() - P.y()) * (Q1_u.y());
    denominator = (Q1_u.x()) * (Q1_u.x()) + (Q1_u.y()) * (Q1_u.y()) +
                  (Q_u.x() - P.x()) * (Q2_u.x()) + (Q_u.y() - P.y()) * (Q2_u.y());

    if (qFuzzyCompare(denominator, qreal(0.0))) {
        denominator = Zero;
    }

    /* u = u - f(u)/f'(u) */
    uPrime = u - (numerator / denominator);
    return (uPrime);
}
开发者ID:KDE,项目名称:koffice,代码行数:44,代码来源:ArtworkCurveFit.cpp

示例5: QRadialGradient

QGradient* Gradient::platformGradient()
{
    if (m_gradient)
        return m_gradient;

    if (m_radial)
        m_gradient = new QRadialGradient(m_p1.x(), m_p1.y(), m_r1, m_p0.x(), m_p0.y());
    else
        m_gradient = new QLinearGradient(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y());

    QColor stopColor;
    Vector<ColorStop>::iterator stopIterator = m_stops.begin();
    qreal lastStop(0.0);
    const qreal lastStopDiff = 0.0000001;
    while (stopIterator != m_stops.end()) {
        stopColor.setRgbF(stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha);
        if (qFuzzyCompare(lastStop, qreal(stopIterator->stop)))
            lastStop = stopIterator->stop + lastStopDiff;
        else
            lastStop = stopIterator->stop;
        if (m_radial && m_r0)
            lastStop = m_r0 / m_r1 + lastStop * (1.0f - m_r0 / m_r1);
        m_gradient->setColorAt(lastStop, stopColor);
        ++stopIterator;
    }

    switch(m_spreadMethod) {
    case SpreadMethodPad:
        m_gradient->setSpread(QGradient::PadSpread);
        break;
    case SpreadMethodReflect:
        m_gradient->setSpread(QGradient::ReflectSpread);
        break;
    case SpreadMethodRepeat:
        m_gradient->setSpread(QGradient::RepeatSpread);
        break;
    }

    return m_gradient;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:40,代码来源:GradientQt.cpp

示例6: lineIntersectPlane

bool glc::lineIntersectPlane(const GLC_Line3d& line, const GLC_Plane& plane, GLC_Point3d* pPoint)
{
	const GLC_Vector3d n= plane.normal();
	const GLC_Point3d p= line.startingPoint();
	const GLC_Vector3d d= line.direction();

	const double denominator= d * n;
	if (qFuzzyCompare(fabs(denominator), 0.0))
	{
		qDebug() << " glc::lineIntersectPlane : Line parallel to the plane";
		// The line is parallel to the plane
		return false;
	}
	else
	{
		// The line intersect the plane by one point
		const double t= -((n * p) + plane.coefD()) / denominator;
		(*pPoint)= p + (t * d);

		return true;
	}
}
开发者ID:AlessioMorale,项目名称:GLC_lib,代码行数:22,代码来源:glc_geomtools.cpp

示例7: QIODevice

VoiceAnalyzer::VoiceAnalyzer(const QAudioFormat &format, QObject *parent):
    QIODevice(parent),
    m_format(format),
    m_frequency(0),
    m_position(0),
    m_fftHelper(new FastFourierTransformer(this))
{
    Q_ASSERT(qFuzzyCompare(M_SAMPLE_COUNT_MULTIPLIER,
                           float(2)/(M_TWELTH_ROOT_OF_2 -1.0)));
    m_totalSampleCount = qRound(qreal(PrecisionPerNote)
                                *TargetFrequencyParameter
                                *M_SAMPLE_COUNT_MULTIPLIER);
    m_samples.reserve(m_totalSampleCount);
    int i = 2;
    int j = 1;
    for (; i < TargetFrequencyParameter; i *= 2) {
        j++;
    }
    m_maximumVoiceDifference = j*12;

    setCutOffPercentage(CutOffScaler);
}
开发者ID:RobertoMalatesta,项目名称:emscripten-qt,代码行数:22,代码来源:voiceanalyzer.cpp

示例8: it

void CSceneWidget::onHideBoxsTriggerd(bool triggerd)
{
    QListIterator<QGraphicsItem*> it(scene()->items());
    while(it.hasNext())
    {
        CGraphicsItem *gi = qgraphicsitem_cast<CGraphicsItem*>(it.next());
        if(!qFuzzyCompare(gi->zValue(), qreal(0.0)))
        {
            gi->setEditMode(!triggerd);
            gi->setVisible(!triggerd);
        }
    }

    if(QAction *action = qobject_cast<QAction*>(sender()))
    {
        if(triggerd)
            action->setText(tr("Show boxs"));
        else
            action->setText(tr("Hide boxs"));
    }
    update();
}
开发者ID:slima4,项目名称:zgui-qt,代码行数:22,代码来源:scenewidget.cpp

示例9: drawHighlightRect

    /*!
     * \brief Draw an hightlight rectangle arround an item
     *
     * \param painter painter where the item is highlighted
     * \param rect    The rectangular area to be drawn
     * \param pw      Pen width of highlight rectangle drawn.
     * \param option  The style option which contains palette and other information.
     */
    void drawHighlightRect(QPainter *painter, QRectF rect, qreal pw,
            const QStyleOptionGraphicsItem *option)
    {
        const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
        if(qFuzzyCompare(qMax(murect.width(), murect.height()), qreal(0.0))) {
            return;
        }

        const QPen savePen = painter->pen();
        const QBrush saveBrush = painter->brush();

        const QRectF mbrect = painter->transform().mapRect(rect);
        if(qMin(mbrect.width(), mbrect.height()) < qreal(1.0)) {
            return;
        }

        qreal itemStrokeWidth = pw;
        const qreal pad = itemStrokeWidth / 2;
        const qreal strokeWidth = 0; // cosmetic pen

        const QColor fgcolor = option->palette.windowText().color();
        const QColor bgcolor( // ensure good contrast against fgcolor
                fgcolor.red()   > 127 ? 0 : 255,
                fgcolor.green() > 127 ? 0 : 255,
                fgcolor.blue()  > 127 ? 0 : 255);

        rect.adjust(pad, pad, -pad, -pad);

        painter->setPen(QPen(bgcolor, strokeWidth, Qt::SolidLine));
        painter->setBrush(Qt::NoBrush);
        painter->drawRect(rect);

        painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));
        painter->setBrush(Qt::NoBrush);
        painter->drawRect(rect);

        painter->setPen(savePen);
        painter->setBrush(saveBrush);
    }
开发者ID:damiansimanuk,项目名称:qucs-qt4,代码行数:47,代码来源:item.cpp

示例10: qt_graphicsItem_highlightSelected

void GraphicsUtils::qt_graphicsItem_highlightSelected(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRectF & boundingRect, const QPainterPath & path)
{	
    const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
    if (qFuzzyCompare(qMax(murect.width(), murect.height()) + 1, 1))
        return;

    const QRectF mbrect = painter->transform().mapRect(boundingRect);
    if (qMin(mbrect.width(), mbrect.height()) < double(1.0))
        return;

    double itemPenWidth = 1.0;
	const double pad = itemPenWidth / 2;
    const double penWidth = 0; // cosmetic pen

    const QColor fgcolor = option->palette.windowText().color();
    const QColor bgcolor( // ensure good contrast against fgcolor
        fgcolor.red()   > 127 ? 0 : 255,
        fgcolor.green() > 127 ? 0 : 255,
        fgcolor.blue()  > 127 ? 0 : 255);

    painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));
    painter->setBrush(Qt::NoBrush);
	if (path.isEmpty()) {
		painter->drawRect(boundingRect.adjusted(pad, pad, -pad, -pad));
	}
	else {
		painter->drawPath(path);
	}

	painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));
    painter->setBrush(Qt::NoBrush);
	if (path.isEmpty()) {
		painter->drawRect(boundingRect.adjusted(pad, pad, -pad, -pad));
	}
	else {
		painter->drawPath(path);
	} 
}
开发者ID:DHaylock,项目名称:fritzing-app,代码行数:38,代码来源:graphicsutils.cpp

示例11: p1

void TestQgsDistanceArea::basic()
{
    QgsPoint p1( 1.0, 3.0 ), p2( -2.0, -1.0 );
    QgsDistanceArea daA;
    double resultA, resultB, resultC;

    daA.setEllipsoid( GEO_NONE );
    resultA = daA.measureLine( p1, p2 );
    QCOMPARE( resultA, 5.0 );

    // Now, on an ellipsoid. Always less?
    daA.setSourceCrs( 3006 );
    daA.setEllipsoid( "WGS84" );
    daA.setEllipsoidalMode( true );
    resultA = daA.measureLine( p1, p2 );
    QVERIFY( resultA < 5.0 );

    // Test copy constructor
    QgsDistanceArea daB( daA );
    resultB = daB.measureLine( p1, p2 );
    QCOMPARE( resultA, resultB );

    // Different Ellipsoid
    daB.setEllipsoid( "WGS72" );
    resultB = daB.measureLine( p1, p2 );
    QVERIFY( ! qFuzzyCompare( resultA, resultB ) );

    // Test assignment
    QSharedPointer<QgsDistanceArea> daC( new QgsDistanceArea );
    *daC = daB;
    resultC = daC->measureLine( p1, p2 );
    QCOMPARE( resultB, resultC );

    // Use parameter setting of ellipsoid radii (from WGS72 )
    daA.setEllipsoid( 6378135.0, 6378135.0 - ( 6378135.0 / 298.26 ) );
    resultA = daA.measureLine( p1, p2 );
    QCOMPARE( resultA, resultB );
}
开发者ID:avautour,项目名称:QGIS,代码行数:38,代码来源:testqgsdistancearea.cpp

示例12: glReadPixels

// Initialized the mover
void GLC_SetTargetMover::init(const GLC_UserInput& userInput)
{
	// Z Buffer component of selected point between 0 and 1
	GLfloat Depth;
	// read selected point
	glReadPixels(userInput.x(), m_pViewport->viewVSize() - userInput.y() , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &Depth);

	// Test if there is geometry under picking point
	if (!qFuzzyCompare(Depth, 1.0f))
	{	// Geometry find -> Update camera's target position
		const GLC_Point3d target(m_pViewport->unProject(userInput.x(), userInput.y()));
		m_pViewport->cameraHandle()->setTargetCam(target);
	}
	else
	{	// Geometry not find -> panning

		const GLC_Point3d curPos(m_pViewport->mapPosMouse(userInput.x(), userInput.y()));
		const GLC_Point3d prevPos(m_pViewport->mapPosMouse(m_pViewport->viewHSize() / 2, m_pViewport->viewVSize() / 2));
		const GLC_Vector3d VectPan(curPos - prevPos);	// panning vector
		// pan camera
		m_pViewport->cameraHandle()->pan(VectPan);
	}
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:24,代码来源:glc_settargetmover.cpp

示例13: goodGainOffsetTest

bool VariableDesc::goodGainOffsetTest(const VariableDesc& var)
{
    DEBUG_FUNC_NAME

    const QString conversionType = var.conversionType();
    qreal aValue = var.aValue();
    qreal bValue = var.bValue();

    // zero-full scale
    if (conversionType == getVARIABLE_CONVERSION_TYPE_STRING_0())
    {
        return !qFuzzyCompare(aValue, bValue);
    }
    // gain-offset
    else if (conversionType == getVARIABLE_CONVERSION_TYPE_STRING_1())
    {
        return (aValue != 0.0);
    }
    else
    {
        return true;
    }
}
开发者ID:jiaoy06,项目名称:eddypro-gui,代码行数:23,代码来源:variable_desc.cpp

示例14: NormaliseWidths

void StretchHeaderView::NormaliseWidths(const QList<int>& sections) {
  if (!stretch_enabled_)
    return;

  const ColumnWidthType total_sum =
      std::accumulate(column_widths_.begin(), column_widths_.end(), 0.0);
  ColumnWidthType selected_sum = total_sum;

  if (!sections.isEmpty()) {
    selected_sum = 0.0;
    for (int i=0 ; i<count() ; ++i)
      if (sections.contains(i))
        selected_sum += column_widths_[i];
  }

  if (total_sum != 0.0 && !qFuzzyCompare(total_sum, 1.0)) {
    const ColumnWidthType mult = (selected_sum + (1.0 - total_sum)) / selected_sum;
    for (int i=0 ; i<column_widths_.count() ; ++i) {
      if (sections.isEmpty() || sections.contains(i))
        column_widths_[i] *= mult;
    }
  }
}
开发者ID:Civil,项目名称:cantata,代码行数:23,代码来源:stretchheaderview.cpp

示例15: iteratorOf

bool OsmAnd::CoreResourcesEmbeddedBundle_P::containsResource(const QString& name, const float displayDensityFactor) const
{
    const auto citResourceEntry = _resources.constFind(name);
    if (citResourceEntry == _resources.cend())
        return false;
    const auto& resourceEntry = *citResourceEntry;

    auto itByDisplayDensityFactor = iteratorOf(constOf(resourceEntry.variantsByDisplayDensityFactor));
    while (itByDisplayDensityFactor.hasNext())
    {
        const auto byDisplayDensityFactorEntry = itByDisplayDensityFactor.next();
        const auto& testDisplayDensityFactor = byDisplayDensityFactorEntry.key();

        if (qFuzzyCompare(displayDensityFactor, testDisplayDensityFactor) ||
            testDisplayDensityFactor >= displayDensityFactor ||
            !itByDisplayDensityFactor.hasNext())
        {
            return true;
        }
    }

    return false;
}
开发者ID:Zahnstocher,项目名称:OsmAnd-core,代码行数:23,代码来源:CoreResourcesEmbeddedBundle_P.cpp


注:本文中的qFuzzyCompare函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。