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


C++ QPainterPath::elementCount方法代码示例

本文整理汇总了C++中QPainterPath::elementCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::elementCount方法的具体用法?C++ QPainterPath::elementCount怎么用?C++ QPainterPath::elementCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPainterPath的用法示例。


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

示例1: AddTrackingVertex

TrackActivities ViewInteractionItemDrawer::AddTrackingVertex(
        const QPointF &src, bool force)
{
    QPainterPath p = _vitem->path();
    QList<QPolygonF> ps = p.toSubpathPolygons();
    Q_ASSERT(ps.size() <= 1);
    Q_ASSERT(_vitem->_feature != nullptr);
    Q_ASSERT(_vitem->_feature->paths().size() == 1);
    _vitem->ClearTempItems();
    TrackActivities ret;
    int n = _vitem->_feature->get_geometry(0).size();
    if (n == 0) {
        ret = TryTrackingMulti(src);
        if (force && ret.is_tracked()) {
            _vitem->add_temp_vertex(ret.closest()._vpos);
        }
    } else {
        Q_ASSERT(p.elementCount() == n || p.elementCount() == n + 1);
        if (p.elementCount() == n) {
            p.lineTo(src);
        } else {
            ret = TryTrackingMulti(src);
            if (force && ret.is_tracked()) {
                p.setElementPositionAt(n, ret.closest()._vpos.x(), ret.closest()._vpos.y());
                _vitem->add_temp_vertex(ret.closest()._vpos);
            } else {
                p.setElementPositionAt(n, src.x(), src.y());
            }
        }
    }
    _vitem->setPath(p);
    return force ? ret : TrackActivities();
}
开发者ID:thecoverofbathtub,项目名称:ginger-app,代码行数:33,代码来源:viewinteractionitemdrawer.cpp

示例2: map

/*!
    \overload

    Creates and returns a QPainterPath object that is a copy of the
    given \a path, mapped into the coordinate system defined by this
    matrix.
*/
QPainterPath QMatrix::map(const QPainterPath &path) const
{
    if (path.isEmpty())
        return QPainterPath();

    QPainterPath copy = path;

    // Translate or identity
    if (_m11 == 1.0 && _m22 == 1.0 && _m12 == 0.0 && _m21 == 0.0) {

        // Translate
        if (_dx != 0.0 || _dy != 0.0) {
            copy.detach();
            for (int i=0; i<path.elementCount(); ++i) {
                QPainterPath::Element &e = copy.d_ptr->elements[i];
                e.x += _dx;
                e.y += _dy;
            }
        }

    // Full xform
    } else {
        copy.detach();
        for (int i=0; i<path.elementCount(); ++i) {
            QPainterPath::Element &e = copy.d_ptr->elements[i];
            qreal fx = e.x, fy = e.y;
            e.x = _m11*fx + _m21*fy + _dx;
            e.y =  _m12*fx + _m22*fy + _dy;
        }
    }

    return copy;
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:40,代码来源:qmatrix.cpp

示例3: addPoint

void UBEditableGraphicsPolygonItem::addPoint(const QPointF & point)
{
    QPainterPath painterPath = path();

    if (painterPath.elementCount() == 0)
    {
        painterPath.moveTo(point); // For the first point added, we must use moveTo().
        setPath(painterPath);

        mStartEndPoint[0] = point;
    }
    else
    {
        // If clic on first point, close the polygon
        // TODO à terme : utiliser la surface de la première poignée.
        QPointF pointDepart(painterPath.elementAt(0).x, painterPath.elementAt(0).y);
        QPointF pointFin(painterPath.elementAt(painterPath.elementCount()-1).x, painterPath.elementAt(painterPath.elementCount()-1).y);


        QGraphicsEllipseItem poigneeDepart(pointDepart.x()-10, pointDepart.y()-10, 20, 20);
        QGraphicsEllipseItem poigneeFin(pointFin.x()-10, pointFin.y()-10, 20, 20);

        if (poigneeDepart.contains(point))
        {
            setClosed(true);
        }
        else
        {
            if(poigneeFin.contains(point)){
                mIsInCreationMode = false;
                mOpened = true;
            }else{
                painterPath.lineTo(point);
                setPath(painterPath);
            }
        }

        mStartEndPoint[1] = point;
    }

    if(!mClosed && !mOpened){
        UBFreeHandle *handle = new UBFreeHandle();

        addHandle(handle);

        handle->setParentItem(this);
        handle->setEditableObject(this);
        handle->setPos(point);
        handle->setId(path().elementCount()-1);
        handle->hide();
    }
}
开发者ID:hethi,项目名称:Sankore-3.1,代码行数:52,代码来源:UBEditableGraphicsPolygonItem.cpp

示例4: updateHandle

void UBGraphicsPathItem::updateHandle(UBAbstractHandle *handle)
{

    setSelected(true);
    Delegate()->showFrame(false);

    int id = handle->getId();

    QPainterPath oldPath = path();

    QPainterPath newPath;

    if(mClosed && id == 0){
        newPath.moveTo(handle->pos());
        for(int i = 1; i < oldPath.elementCount()-1; i++){
            newPath.lineTo(oldPath.elementAt(i).x, oldPath.elementAt(i).y);
        }
        newPath.lineTo(handle->pos());
    }else{
        for(int i = 0; i < oldPath.elementCount(); i++){
            if(i == 0){
                if(i == id){
                    newPath.moveTo(handle->pos());
                }else{
                    newPath.moveTo(oldPath.elementAt(i).x, oldPath.elementAt(i).y);
                }
            }else{
                if(i == id){
                    newPath.lineTo(handle->pos());
                }else{
                    newPath.lineTo(oldPath.elementAt(i).x, oldPath.elementAt(i).y);
                }
            }
        }
    }


    setPath(newPath);

    if(fillingProperty()->gradient()){
        QLinearGradient g(path().boundingRect().topLeft(), path().boundingRect().topRight());

        g.setColorAt(0, fillingProperty()->gradient()->stops().at(0).second);
        g.setColorAt(1, fillingProperty()->gradient()->stops().at(1).second);

        setFillingProperty(new UBFillProperty(g));
    }
}
开发者ID:fincom,项目名称:Sankore-3.1,代码行数:48,代码来源:UBGraphicsPathItem.cpp

示例5: drawPath

void QgsDxfPaintEngine::drawPath( const QPainterPath& path )
{
  int pathLength = path.elementCount();
  for ( int i = 0; i < pathLength; ++i )
  {
    const QPainterPath::Element& pathElem = path.elementAt( i );
    if ( pathElem.type == QPainterPath::MoveToElement )
    {
      moveTo( pathElem.x, pathElem.y );
    }
    else if ( pathElem.type == QPainterPath::LineToElement )
    {
      lineTo( pathElem.x, pathElem.y );
    }
    else if ( pathElem.type == QPainterPath::CurveToElement )
    {
      curveTo( pathElem.x, pathElem.y );
    }
    else if ( pathElem.type == QPainterPath::CurveToDataElement )
    {
      mCurrentCurve.append( QPointF( pathElem.x, pathElem.y ) );
    }
  }
  endCurve();
  endPolygon();
}
开发者ID:ACorradini,项目名称:QGIS,代码行数:26,代码来源:qgsdxfpaintengine.cpp

示例6: pathToSvg

QString PolaroidBorderDrawer::pathToSvg(const QPainterPath & path) const
{
    int count = path.elementCount();
    QString str_path_d;
    for (int i = 0; i < count; ++i)
    {
        QPainterPath::Element e = path.elementAt(i);
        switch (e.type)
        {
        case QPainterPath::LineToElement:
            str_path_d.append("L " + QString::number(e.x) + ' ' + QString::number(e.y) + ' ');
            break;
        case QPainterPath::MoveToElement:
            str_path_d.append("M " + QString::number(e.x) + ' ' + QString::number(e.y) + ' ');
            break;
        case QPainterPath::CurveToElement:
            str_path_d.append("C " + QString::number(e.x) + ' ' + QString::number(e.y) + ' ');
            break;
        case QPainterPath::CurveToDataElement:
            str_path_d.append(QString::number(e.x) + ' ' + QString::number(e.y) + ' ');
            break;
        }
    }
    str_path_d.append("z");
    return str_path_d;
}
开发者ID:NathanDM,项目名称:kipi-plugins,代码行数:26,代码来源:PolaroidBorderDrawer.cpp

示例7:

//=============================================================================
int sstQt01PathStoreViewCls::AppendPathSymbol(int          iKey,
                                      QPainterPath oTmpPath,
                                      sstQt01ShapeType_enum eTmpPathType,
                                      QColor       oTmpColor,
                                      QPen         oTmpPen)
{

  //-----------------------------------------------------------------------------
  if ( iKey != 0) return -1;

  int iEleNum = oTmpPath.elementCount();
  for (int ii =1; ii <= iEleNum; ii++)
  {
    sstQt01PathElementCsv3Cls oShapeItemCsv;
    QPainterPath::Element oElement;
    oElement = oTmpPath.elementAt(ii-1);
    oShapeItemCsv.setAll(oElement.type,oElement.x,oElement.y, oTmpColor);
    if (oElement.type == 0)
    {
      oShapeItemCsv.setIPenStyle(oTmpPen.style());
      oShapeItemCsv.setIPenWidth(oTmpPen.width());
      oShapeItemCsv.setShapeType(eTmpPathType);
    }
  }

  return 0;
}
开发者ID:UliRehr15,项目名称:sstQt01Lib,代码行数:28,代码来源:sstQt01PathStoreView.cpp

示例8: sstSgnlBeginInsertRows

//=============================================================================
void sstQt01PathPaintWidgetCls::createShapeItem(const QPainterPath &path,
                                                // const QString &toolTip,
                                                const QPoint &pos,
                                                const QColor &color,
                                                const QPen &oPen,
                                                const sstQt01ShapeType_enum eShapeType)
{
  sstQt01ShapeItem shapeItem;
  shapeItem.setPath(path);
  // shapeItem.setToolTip(toolTip);
  shapeItem.setPosition(pos);
  shapeItem.setColor(color);
  shapeItem.setPen(oPen);
  shapeItem.setShapeType(eShapeType);

  // Generate tooltip (Type and row number)
  std::string oTooltipStr;
  sstQt01ShapeTypeCls oShapeType;
  oShapeType.Enm2Str( 0, eShapeType, &oTooltipStr);
  sstStr01Cls oStrCnvt;
  oStrCnvt.Csv_UInt4_2String(0,this->oPathStorage->RecordCount()+1,&oTooltipStr);
  QString oQTooltipStr;
  oQTooltipStr.append(oTooltipStr.c_str());
  shapeItem.setToolTip(oQTooltipStr);

  int iBegin=0;
  int iEnd=0;
  // Insert rows at end of table
  iBegin = (int) this->oPathStorage->RecordCount() +1;
  iEnd = iBegin + (int) path.elementCount() -1;
  emit sstSgnlBeginInsertRows(iBegin,iEnd);
  this->oPathStorage->appendShapeItem(shapeItem);
  emit sstSgnlEndInsertRows();
  update();
}
开发者ID:UliRehr15,项目名称:sstQt01Lib,代码行数:36,代码来源:sstQt01PathPaintWidget.cpp

示例9: testArcMoveTo

void tst_QPainterPath::testArcMoveTo()
{
    QFETCH(QRectF, rect);
    QFETCH(qreal, angle);

    QPainterPath path;
    path.arcMoveTo(rect, angle);
    path.arcTo(rect, angle, 30);
    path.arcTo(rect, angle + 30, 30);

    QPointF pos = path.elementAt(0);

    QVERIFY((path.elementCount()-1) % 3 == 0);

    qreal x_radius = rect.width() / 2.0;
    qreal y_radius = rect.height() / 2.0;

    QPointF shouldBe = rect.center()
                       + QPointF(x_radius * cos(ANGLE(angle)), -y_radius * sin(ANGLE(angle)));

    qreal iw = 1 / rect.width();
    qreal ih = 1 / rect.height();

    QVERIFY(pathFuzzyCompare(pos.x() * iw, shouldBe.x() * iw));
    QVERIFY(pathFuzzyCompare(pos.y() * ih, shouldBe.y() * ih));
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:26,代码来源:tst_qpainterpath.cpp

示例10: drawPath

void QJsonPaintEngine::drawPath(const QPainterPath &path)
{
	Q_D(QJsonPaintEngine);
#ifdef QT_PICTURE_DEBUG
	qDebug() << " -> drawPath():" << path.boundingRect();
#endif
	QString command;
	d->s << QString("\t{\"p\": \r\n\t\t[\r\n");
	 for(int i=0; i< path.elementCount(); i++)
	 {
		 QPainterPath::Element e = path.elementAt(i);
		 switch (e.type)
		 {
		 case QPainterPath::MoveToElement:
			 command = QString("\t\t{\"m\": {\"x\": %1, \"y\":%2}},\r\n").arg(e.x).arg(e.y); break;
		 case QPainterPath::LineToElement:
			 command = QString("\t\t{\"l\": {\"x\": %1, \"y\":%2}},\r\n").arg(e.x).arg(e.y); break;
		 case QPainterPath::CurveToElement:
			 command = QString("\t\t{\"a\": (\"x1\": %1, \"y1\": %2, \"x2\": %3, \"y2\": %4}},\r\n").arg(d->pos.x()).arg(d->pos.y()).arg(e.x).arg(e.y); break;
		 case QPainterPath::CurveToDataElement:
			 command = QString("\t\t{\"ax\": (\"x1\": %1, \"y2\": %2, \"x2\": %3, \"y2\": %4}},\r\n").arg(d->pos.x()).arg(d->pos.y()).arg(e.x).arg(e.y); break;
		 default: break;
		 }

		  d->s << command;
		  d->pos.setX(e.x);
		  d->pos.setX(e.y);
	 }
	 d->s << QString("\t\t]\r\n\t},\r\n");
}
开发者ID:jhihn,项目名称:Vaudeville,代码行数:30,代码来源:qpaintengine_json.cpp

示例11: assert

//=============================================================================
int sstQt01PathStoreViewCls::appendItemSymbol(sstQt01ShapeItem oItem)
{
  // Append to element table
  QPainterPath oPath = oItem.getPath();
  int iStat = this->AppendPathSymbol(0,oPath,oItem.getShapeType(), oItem.getColor(),oItem.getPen());
  assert(iStat >= 0);

  // Append to main table
  sstQt01PathMainRecCls oMainRec;
  oMainRec.setQCol(oItem.getColor());
  oMainRec.setPosition(oItem.getPosition());
  int iNumElements = oPath.elementCount();
  dREC04RECNUMTYP dLastRecNo = 0;
  oMainRec.setStartElementRecNo(dLastRecNo-iNumElements+1);
  oMainRec.setNumElements(iNumElements);
  oMainRec.setShapeType(oItem.getShapeType());
  QString oToolTipStr = oItem.getToolTip();
  oMainRec.setTooltip(oToolTipStr.toStdString());

  // Store Extern Id for example dxf in sstPathStorage
  dREC04RECNUMTYP dExternId = oItem.getExternId();
  oMainRec.setExternId(dExternId);

  dREC04RECNUMTYP dRecNo = 0;

  // move position from main table to element table
  this->addPositionSym(dRecNo);

  return iStat;
}
开发者ID:UliRehr15,项目名称:sstQt01Lib,代码行数:31,代码来源:sstQt01PathStoreView.cpp

示例12: lensDeform

QPainterPath PathDeformRenderer::lensDeform(const QPainterPath &source, const QPointF &offset)
{
    QPainterPath path;
    path.addPath(source);

    qreal flip = m_intensity / qreal(100);

    for (int i=0; i<path.elementCount(); ++i) {
        const QPainterPath::Element &e = path.elementAt(i);

        qreal x = e.x + offset.x();
        qreal y = e.y + offset.y();

        qreal dx = x - m_pos.x();
        qreal dy = y - m_pos.y();
        qreal len = m_radius - qSqrt(dx * dx + dy * dy);

        if (len > 0) {
            path.setElementPositionAt(i,
                                      x + flip * dx * len / m_radius,
                                      y + flip * dy * len / m_radius);
        } else {
            path.setElementPositionAt(i, x, y);
        }

    }

    return path;
}
开发者ID:Kwangsub,项目名称:qt-openwebos,代码行数:29,代码来源:pathdeform.cpp

示例13: currentLine

QList<QPointF> Geometry::intersection(QLineF const &line, QPainterPath const &path, qreal eps)
{
	QList<QPointF> result;
	QPointF startPoint;
	QPointF endPoint;

	for (int i = 0; i < path.elementCount(); ++i) {
		QPainterPath::Element const element = path.elementAt(i);

		// Checking that element belongs to the wall path
		if (element.isMoveTo()) {
			endPoint = QPointF(element.x, element.y);
			continue;
		}

		startPoint = endPoint;
		endPoint = QPointF(element.x, element.y);
		QLineF currentLine(startPoint, endPoint);
		QPointF intersectionPoint;
		// TODO: consider curve cases
		if (line.intersect(currentLine, &intersectionPoint) != QLineF::NoIntersection
				&& belongs(intersectionPoint, currentLine, eps))
		{
			result << intersectionPoint;
		}
	}

	return result;
}
开发者ID:ASabina,项目名称:qreal,代码行数:29,代码来源:geometry.cpp

示例14: moved

bool Editor::moved( const QPoint& pos )
{
    if ( plot() == NULL )
        return false;

    const QwtScaleMap xMap = plot()->canvasMap( d_editedItem->xAxis() );
    const QwtScaleMap yMap = plot()->canvasMap( d_editedItem->yAxis() );

    const QPointF p1 = QwtScaleMap::invTransform( xMap, yMap, d_currentPos );
    const QPointF p2 = QwtScaleMap::invTransform( xMap, yMap, pos );

#if QT_VERSION >= 0x040600
    const QPainterPath shape = d_editedItem->shape().translated( p2 - p1 );
#else
    const double dx = p2.x() - p1.x();
    const double dy = p2.y() - p1.y();

    QPainterPath shape = d_editedItem->shape();
    for ( int i = 0; i < shape.elementCount(); i++ )
    {
        const QPainterPath::Element &el = shape.elementAt( i );
        shape.setElementPositionAt( i, el.x + dx, el.y + dy );
    }
#endif

    d_editedItem->setShape( shape );
    d_currentPos = pos;

    return true;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:30,代码来源:editor.cpp

示例15: qwtTransformPath

static QPainterPath qwtTransformPath( const QwtScaleMap &xMap,
        const QwtScaleMap &yMap, const QPainterPath &path, bool doAlign )
{
    QPainterPath shape;
    shape.setFillRule( path.fillRule() );

    for ( int i = 0; i < path.elementCount(); i++ )
    {
        const QPainterPath::Element &element = path.elementAt( i );

        double x = xMap.transform( element.x );
        double y = yMap.transform( element.y );

        switch( element.type )
        {
            case QPainterPath::MoveToElement:
            {
                if ( doAlign )
                {
                    x = qRound( x );
                    y = qRound( y );
                }

                shape.moveTo( x, y );
                break;
            }
            case QPainterPath::LineToElement:
            {
                if ( doAlign )
                {
                    x = qRound( x );
                    y = qRound( y );
                }

                shape.lineTo( x, y );
                break;
            }
            case QPainterPath::CurveToElement:
            {
                const QPainterPath::Element& element1 = path.elementAt( ++i );
                const double x1 = xMap.transform( element1.x );
                const double y1 = yMap.transform( element1.y );

                const QPainterPath::Element& element2 = path.elementAt( ++i );
                const double x2 = xMap.transform( element2.x );
                const double y2 = yMap.transform( element2.y );

                shape.cubicTo( x, y, x1, y1, x2, y2 );
                break;
            }
            case QPainterPath::CurveToDataElement:
            {
                break;
            }
        }
    }

    return shape;
}
开发者ID:OpenModelica,项目名称:OMPlot,代码行数:59,代码来源:qwt_plot_shapeitem.cpp


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