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


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

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


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

示例1:

void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings )
{
  if ( !p )
  {
    return;
  }

  if ( rings == NULL )
  {
    // simple polygon without holes
    p->drawPolygon( points );
  }
  else
  {
    // polygon with holes must be drawn using painter path
    QPainterPath path;
    QPolygonF outerRing = points;
    path.addPolygon( outerRing );

    QList<QPolygonF>::const_iterator it = rings->constBegin();
    for ( ; it != rings->constEnd(); ++it )
    {
      QPolygonF ring = *it;
      path.addPolygon( ring );
    }

    p->drawPath( path );
  }
}
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:29,代码来源:qgssymbollayerv2.cpp

示例2:

QPainterPath Fidelity::GUI::ComponentLinkItem::shape() const
{
	// Reshape our line to include the arrow's head
	QPainterPath path = QGraphicsLineItem::shape();
	path.addPolygon(m_StartArrowHead);
	path.addPolygon(m_EndArrowHead);

	return(path);
}
开发者ID:brevilo,项目名称:fidelity,代码行数:9,代码来源:ComponentLinkItem.cpp

示例3: shape

QPainterPath CopyFilterGUIConnectionItem::shape() const
{
	QLineF l = line();

	QPainterPath path;
	path.setFillRule(Qt::WindingFill);
	double length = line().length();
	if (length > 0)
	{
		double offset = min(length, maxArrowSize);
		QLineF unit = l.unitVector();
		QLineF normal = l.normalVector().unitVector();
		QPointF v(unit.dx(), unit.dy());
		QPointF n(normal.dx(), normal.dy());
		QPointF p2 = l.p2();

		QPointF p3 = p2 - v * offset + 0.5 * n * offset;
		QPointF p4 = p2 - v * offset - 0.5 * n * offset;
		QPolygonF polygon;
		polygon.append(p4);
		polygon.append(p3);
		polygon.append(p2);
		path.addPolygon(polygon);

		QPolygonF polygon2;
		QPointF p1 = l.p1();
		polygon2.append(p2 + 3 * n);
		polygon2.append(p2 - 2 * n);
		polygon2.append(p1 - 2 * n);
		polygon2.append(p1 + 3 * n);
		path.addPolygon(polygon2);

		if (factor != 1.0 || isDecibel)
		{
			QFont font;
			font.setPixelSize(10);
			QPointF center = (l.p1() + l.p2()) / 2;
			QString text = QString("%1").arg(factor);
			if (isDecibel)
				text += " dB";

			QFontMetrics fontMetrics(font);
			QSizeF size = fontMetrics.size(0, text);
			size += QSizeF(2, 0);
			QRectF rect;
			rect.setSize(size);
			rect.moveCenter(center);
			path.addRoundedRect(rect.adjusted(-0.5, 0.5, 0.5, 0.5), 3, 3);
		}
	}

	return path;
}
开发者ID:Noiled,项目名称:equalizerapo,代码行数:53,代码来源:CopyFilterGUIConnectionItem.cpp

示例4: shape

QPainterPath OrthogonalRenderer::shape(const MapObject *object) const
{
    QPainterPath path;

    if (!object->cell().isEmpty()) {
        path.addRect(boundingRect(object));
    } else {
        switch (object->shape()) {
        case MapObject::Rectangle: {
            const QRectF bounds = object->bounds();
            const QRectF rect(tileToPixelCoords(bounds.topLeft()),
                              tileToPixelCoords(bounds.bottomRight()));

            if (rect.isNull()) {
                path.addEllipse(rect.topLeft(), 20, 20);
            } else {
                path.addRoundedRect(rect, 10, 10);
            }
            break;
        }
        case MapObject::Polygon:
        case MapObject::Polyline: {
            const QPointF &pos = object->position();
            const QPolygonF polygon = object->polygon().translated(pos);
            const QPolygonF screenPolygon = tileToPixelCoords(polygon);
            if (object->shape() == MapObject::Polygon) {
                path.addPolygon(screenPolygon);
            } else {
                for (int i = 1; i < screenPolygon.size(); ++i) {
                    path.addPolygon(lineToPolygon(screenPolygon[i - 1],
                                                  screenPolygon[i]));
                }
                path.setFillRule(Qt::WindingFill);
            }
            break;
        }
        case MapObject::Ellipse: {
            const QRectF bounds = object->bounds();
            const QRectF rect(tileToPixelCoords(bounds.topLeft()),
                              tileToPixelCoords(bounds.bottomRight()));

            if (rect.isNull()) {
                path.addEllipse(rect.topLeft(), 20, 20);
            } else {
                path.addEllipse(rect);
            }
            break;
        }
        }
    }

    return path;
}
开发者ID:ErwanLeroux,项目名称:CatchChallenger,代码行数:53,代码来源:tiled_orthogonalrenderer.cpp

示例5: paint

//! [4]
void mafNodeConnectionGraphicWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w)
{
	Q_UNUSED(option);
    Q_UNUSED(w);

	painter->setRenderHint(QPainter::Antialiasing);

	if (mStartConnector == NULL || mEndConnector == NULL || mStartConnector->collidesWithItem(mEndConnector))
        return;

	QPointF controlPoint1;
	QPointF controlPoint2;
	recreatePath(controlPoint1, controlPoint2);
	
    if (static_cast<mafDiagramScene*>(scene())->isDebugDraw()) {
		QPen origPen = painter->pen();
		QBrush origBrush = painter->brush();
		debugPaint(painter, controlPoint1, controlPoint2);
		painter->setPen(origPen);
	    painter->setBrush(origBrush);
	}

    QPen mPen = pen();
    mPen.setColor(mColor);
    painter->setPen(mPen);
	//line
    //painter->setBrush(mColor);
	painter->setBrush(Qt::NoBrush);

	if (isSelected())
		painter->setPen(QPen(mColor, 1, Qt::DashLine));


    QPainterPath p = this->path();
	painter->drawPath(p);

	//fill
	painter->setBrush(mColor);

    QPolygonF arrowHeadEnd = createArrowPoly(p, mEndConnector);
	if (bidirectional()) {
		QPolygonF arrowHeadStart = createArrowPoly(p, mStartConnector);
		p.addPolygon(arrowHeadStart);
		painter->drawPolygon(arrowHeadStart);
	}
    p.addPolygon(arrowHeadEnd);
	painter->drawPolygon(arrowHeadEnd);
	
}
开发者ID:b3c,项目名称:MAF3,代码行数:50,代码来源:mafNodeConnectionGraphicWidget.cpp

示例6: shape

QPainterPath UBGraphicsTriangle::shape() const
{
    QPainterPath tShape;
    QPolygonF tPolygon;

    tPolygon << A1 << B1 << C1;
    tShape.addPolygon(tPolygon);
    tPolygon.clear();

    tPolygon << A2 << B2 << C2;
    tShape.addPolygon(tPolygon);
    tPolygon.clear();

    return tShape;
}
开发者ID:Tonicminds,项目名称:Sankore-3.1,代码行数:15,代码来源:UBGraphicsTriangle.cpp

示例7: shape

QPainterPath Building::shape() const
{
    QPainterPath painterPath;
    painterPath.addPolygon(_building.toPolygonF());

    return painterPath;
}
开发者ID:ufoproger,项目名称:reveler,代码行数:7,代码来源:building.cpp

示例8: shape

//!
//! Returns the shape of the item as QPainterPath.
//!
//! \param The shape of the item as QPainterPath.
//!
QPainterPath ConnectionGraphicsItem::shape () const
{
    QPainterPath result;
    result.addPath(m_mainPath);
    result.addPolygon(m_arrowHeadPolygon);
    return result;
}
开发者ID:banduladh,项目名称:levelfour,代码行数:12,代码来源:ConnectionGraphicsItem.cpp

示例9: shape

QPainterPath SCgNode::shape() const
{
    QPainterPath path;
    QRectF boundRect = boundingRect();

    if (mContentVisible)
    {
        path.addRect(boundRect);
    }else
    {
        QMatrix matrix;
        switch (mConstType)
        {
        case SCgAlphabet::Const:
            path.addEllipse(boundRect);
            break;

        case SCgAlphabet::Var:
            path.addRect(boundRect);
            break;

        case SCgAlphabet::Meta:
            path.addPolygon(matrix.rotate(45.f).mapToPolygon(boundRect.toRect()));
            break;

        default:
            break;
        }
    }

    return path;
}
开发者ID:DavidBermuda,项目名称:kbe,代码行数:32,代码来源:scgnode.cpp

示例10: shape

QPainterPath ItemPhysEnv::shape() const
{
    QPainterPath path;
    QPolygonF lineBoarder;
    QVector<qreal> points = {0.0,
                             0.0,
                             this->data(ITEM_WIDTH).toReal(),
                             this->data(ITEM_HEIGHT).toReal()};
#define PLEFT   0
#define PTOP    1
#define PRIGHT  2
#define PBOTTOM 3
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PTOP]));
    lineBoarder.push_back(QPointF(points[PRIGHT],    points[PTOP]));
    lineBoarder.push_back(QPointF(points[PRIGHT],    points[PBOTTOM]));
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PBOTTOM]));
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PTOP]));

    lineBoarder.push_back(QPointF(points[PLEFT] + 4, points[PTOP]));
    lineBoarder.push_back(QPointF(points[PLEFT] + 4, points[PBOTTOM] - 4));
    lineBoarder.push_back(QPointF(points[PRIGHT] - 4,points[PBOTTOM] - 4));
    lineBoarder.push_back(QPointF(points[PRIGHT] - 4,points[PTOP] + 4));
    lineBoarder.push_back(QPointF(points[PLEFT],     points[PTOP] + 4));
#undef PLEFT
#undef PTOP
#undef PRIGHT
#undef PBOTTOM

    path.addPolygon(lineBoarder);
    return path;
}
开发者ID:Wohlhabend-Networks,项目名称:PGE-Project,代码行数:31,代码来源:item_water.cpp

示例11: shape

/**
 * @brief Hex::shape	Zwraca dokładne ograniczenie hexa, sześciąkąt foremny, który zawiera hex.
 * @return		QPainterPath z ograniczeniem hexa.
 */
QPainterPath Tile::shape() const
{
    QPainterPath result;
    result.addPolygon(QPolygonF(tileVertices(1)));
    result.closeSubpath();
    return result;
}
开发者ID:squadack,项目名称:KronikiAndarii,代码行数:11,代码来源:Tile.cpp

示例12: cutCircle

void QChain::cutCircle(Circle circle) {
  if (m_vertices.size() == 0) return;
  circle.setCenter(circle.pos());

  QPainterPath cr;
  cr.addEllipse(circle.x - circle.r, circle.y - circle.r, 2 * circle.r,
                2 * circle.r);

  QPolygonF polygon;
  for (QPointF p : m_vertices) polygon.append(p);
  QPainterPath chain;
  chain.addPolygon(polygon);

  if (!chain.intersects(cr)) return;

  chain = chain.subtracted(cr);

  for (const QPolygonF &poly : chain.toSubpathPolygons()) {
    std::vector<Vector2d> pts(poly.begin(), poly.end() - 1);

    if (std::fabs(Geometry::area(pts.begin(), pts.end())) > 5.f) {
      auto chain = std::make_unique<QChain>(world());
      chain->setVertices(std::vector<QPointF>(pts.begin(), pts.end()));
      chain->initializeLater(world());

      world()->itemSet()->addBody(std::move(chain));
    }
  }

  m_vertices.clear();
  destroyLater();
}
开发者ID:Hakiko,项目名称:GameEngine,代码行数:32,代码来源:QChain.cpp

示例13: addPolygon

int PainterPath::addPolygon(lua_State * L) // ( const QPolygonF & polygon )
{
	QPainterPath* lhs = ValueInstaller2<QPainterPath>::check( L, 1 );
	QPolygonF* polygon = ValueInstaller2<QPolygonF>::check( L, 2 );
	lhs->addPolygon( *polygon );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlPainterPath.cpp

示例14: shape

//----------------------------------------------------------------------------------------------
QPainterPath GraphEdgeView::shape() const
{
    QPainterPath path;// = QGraphicsLineItem::shape();

    QLineF normal = this->line().unitVector().normalVector();
    qreal dx = normal.dx();
    qreal dy = normal.dy();

    QLineF myLine;

    myLine = this->line();
    myLine.translate(dx * 4, dy * 4);
    path.lineTo(myLine.p1());
    path.lineTo(myLine.p2());

    myLine = this->line();
    myLine.translate(-dx * 4,-dy * 4);
    path.lineTo(myLine.p2());
    path.lineTo(myLine.p1());
    path.closeSubpath();

    path.addPolygon(m_arrowHead);

    return path;
}
开发者ID:mabdelmonemali,项目名称:IStrategizer,代码行数:26,代码来源:GraphEdgeView.cpp

示例15: setPolygon

/*!
  \brief Set a path built from a polygon

  \param polygon Polygon
  \sa setShape(), setRect(), shape()
 */
void QwtPlotShapeItem::setPolygon( const QPolygonF &polygon )
{
    QPainterPath shape;
    shape.addPolygon( polygon );

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


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