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


C++ setPolygon函数代码示例

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


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

示例1: high_word

void WGraphicsPolygonItem::onContextMenu(Ws::ContextMenuFlag flag)
{
	if (flag == Ws::AddVertex)
	{
		int id = high_word(_select_flag);
		WWorldPolygonF p = data()->polygon;
		p.insert(p.begin()+id+1, _cp[id]);
		setPolygon(p, true, true);
	}
	else if (flag == Ws::DeleteVertex)
	{
		int id = high_word(_select_flag);
		WWorldPolygonF p = data()->polygon;
		p.erase(p.begin() + id);
		if (id == 0)
		{
			p.back() = p.front();
		}
		setPolygon(p, true, true);
	}
	else if (flag == Ws::Copy)
	{
		scene()->setClipboard(this);
	}
}
开发者ID:tecentwenping,项目名称:Controller_Atcsim,代码行数:25,代码来源:wgraphicspolygonitem.cpp

示例2: FSMElementBase

Port::Port(int iInNumber,  FSMElementIfc* poInElementParent )
: FSMElementBase( poInElementParent )
, QGraphicsPolygonItem(poInElementParent ? poInElementParent->getGraphicsItem() : 0 )
, moPolygon()
, miNumber( iInNumber )
{
    // create signal slot connections
    if ( poInElementParent )
    {
      // observer change of id of parent element (node)
      connect(
          poInElementParent->getSignalSlotBase(), SIGNAL( sigChangedId( const FSMElementIfc& ))
          , this, SLOT( slotUpdateId( const FSMElementIfc& ) ) );
    }

    setBrush( QBrush( QColor( Qt::black), Qt::NoBrush ) );
    setPen( QPen( QColor( Qt::black), 2 ) );

    moPolygon << QPointF(0, 0) << QPointF(5, 0)
              << QPointF(5, 5)   << QPointF(0, 5)
              << QPointF(0, 0);

    setPolygon( moPolygon);

    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    // recalculate id
    updateId();

    FSMElementManager::getInstance().addElement( this );
}
开发者ID:kreuzberger,项目名称:FSM-Editor,代码行数:33,代码来源:port.cpp

示例3: setPolygon

void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;

	QPolygonF p;
	p.append(QPointF(hAxis->posAtValue(0), vAxis->posAtValue(0)));
	plot_data *entry = dataModel->data().entry;
	for (int i = 0, count = dataModel->rowCount(); i < count; i++, entry++) {
		if (entry->in_deco && entry->stopdepth) {
			p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(qMin(entry->stopdepth, entry->depth))));
		} else {
			p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0)));
		}
	}
	setPolygon(p);
	QLinearGradient pat(0, p.boundingRect().top(), 0, p.boundingRect().bottom());
	// does the user want the ceiling in "surface color" or in red?
	if (prefs.redceiling) {
		pat.setColorAt(0, getColor(CEILING_SHALLOW));
		pat.setColorAt(1, getColor(CEILING_DEEP));
	} else {
		pat.setColorAt(0, getColor(BACKGROUND_TRANS));
		pat.setColorAt(1, getColor(BACKGROUND_TRANS));
	}
	setPen(QPen(QBrush(Qt::NoBrush), 0));
	setBrush(pat);
}
开发者ID:codesong,项目名称:subsurface,代码行数:28,代码来源:diveprofileitem.cpp

示例4: Q_UNUSED

void MyPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
    //painter->save();
    Q_UNUSED(option);
    QColor color = color_;
    if(isSelected())
        color.setAlpha(125);
    else
        color.setAlpha(50);
    painter->setPen(Qt::NoPen);
    painter->setBrush(color);

    QPolygonF poly = getPoly();
    setPolygon(poly);

    painter->drawPolygon(poly,Qt::WindingFill);

    painter->setPen(Qt::black);
    //qDebug() << pattern_->getName();
    //QRect rect(0,0,200,50);
    //painter->drawText(rect, Qt::AlignCenter, pattern_->getName());
    painter->drawText(poly.boundingRect(), Qt::AlignCenter, pattern_->getName());
    //painter->drawText(QRect(pattern_->getPolygon().at(0).toPoint(),QSize(200,50)), Qt::AlignCenter, pattern_->getName());
    //painter->restore();
}
开发者ID:lbaudouin,项目名称:SewingPattern,代码行数:25,代码来源:mypolygon.cpp

示例5: pen

TileOutline::TileOutline(Qt::GlobalColor color, copair xy, QGraphicsItem *parent):QGraphicsPolygonItem(parent)
{
    QPen pen(color,2);
    setPen(pen);

    if((xy.first+xy.second)%2)
        throw(1);

    //set points for hexagon
    QVector<QPointF> points;
    points << QPointF(-1.0/(qSqrt(3)),-1) << QPointF(1.0/(qSqrt(3)),-1) << QPointF(2.0/(qSqrt(3)),0)
           << QPointF(1.0/(qSqrt(3)),1) << QPointF(-1.0/(qSqrt(3)),1) << QPointF(-2.0/(qSqrt(3)),0);

    //scale hexagon
    for(size_t i = 0,n = points.size();i<n;i++)
    {
        points[i]*=HEX_SCALE;
    }

    setPolygon(QPolygonF(points));

    int xb=xy.first,yb=xy.second;//board coordinates
    float xs,ys; //screen coordinates

    xs = HEX_SCALE*qSqrt(3)*xb+xc;
    ys = HEX_SCALE*(-yb)+yc;

    //qDebug()<<"tile created at "<<xs<<","<<ys;

    setPos(xs,ys);
}
开发者ID:Oyinda8,项目名称:Hive-AI,代码行数:31,代码来源:tileoutline.cpp

示例6: GET_PRESSURE

void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	// We don't have enougth data to calculate things, quit.
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;
	int last_index = -1;
	QPolygonF boundingPoly; // This is the "Whole Item", but a pressure can be divided in N Polygons.
	polygons.clear();

	for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
		plot_data *entry = dataModel->data().entry + i;
		int mbar = GET_PRESSURE(entry);

		if (entry->cylinderindex != last_index) {
			polygons.append(QPolygonF()); // this is the polygon that will be actually drawned on screen.
			last_index = entry->cylinderindex;
		}
		if (!mbar) {
			continue;
		}

		QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(mbar));
		boundingPoly.push_back(point);    // The BoundingRect
		polygons.last().push_back(point); // The polygon thta will be plotted.
	}
	setPolygon(boundingPoly);
	qDeleteAll(texts);
	texts.clear();
	int mbar, cyl;
	int seen_cyl[MAX_CYLINDERS] = { false, };
	int last_pressure[MAX_CYLINDERS] = { 0, };
	int last_time[MAX_CYLINDERS] = { 0, };
	struct plot_data *entry;

	cyl = -1;
	for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
		entry = dataModel->data().entry + i;
		mbar = GET_PRESSURE(entry);

		if (!mbar)
			continue;
		if (cyl != entry->cylinderindex) {
			cyl = entry->cylinderindex;
			if (!seen_cyl[cyl]) {
				plotPressureValue(mbar, entry->sec, Qt::AlignRight | Qt::AlignTop);
				plotGasValue(mbar, entry->sec, Qt::AlignRight | Qt::AlignBottom,
					       displayed_dive.cylinder[cyl].gasmix);
				seen_cyl[cyl] = true;
			}
		}
		last_pressure[cyl] = mbar;
		last_time[cyl] = entry->sec;
	}

	for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
		if (last_time[cyl]) {
			plotPressureValue(last_pressure[cyl], last_time[cyl], Qt::AlignLeft | Qt::AlignTop);
		}
	}
}
开发者ID:codesong,项目名称:subsurface,代码行数:60,代码来源:diveprofileitem.cpp

示例7: resizeRect

void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
{
    QGraphicsItem *prevItem = m_currentItem;
    m_currentItem = item;

    if (!m_currentItem)
        return;

    QRect viewRect = m_inspector->declarativeView()->rect();
    viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect();

    QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
    itemRect = item->mapRectToScene(itemRect);

    // if updating the same item as before, resize the rectangle only bigger, not smaller.
    if (prevItem == item && prevItem != 0) {
        m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect);
    } else {
        m_itemPolyRect = itemRect;
    }
    QRectF borderRect = m_itemPolyRect;
    borderRect.adjust(-1, -1, 1, 1);
    m_borderRect->setRect(borderRect);

    const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect());
    setPolygon(regionToPolygon(externalRegion));
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:27,代码来源:subcomponentmasklayeritem.cpp

示例8: prepareGeometryChange

void DiagramDrawItem::setDimension(QPointF newPos)
{
	prepareGeometryChange();
	myPos2=newPos;
	myPolygon=createPath();
	setPolygon(myPolygon);
}
开发者ID:autoscatto,项目名称:retroshare,代码行数:7,代码来源:diagramdrawitem.cpp

示例9: polygon

void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	// We don't have enougth data to calculate things, quit.
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;
	AbstractProfilePolygonItem::modelDataChanged(topLeft, bottomRight);
	// Add 2 points to close the polygon.
	QPolygonF poly = polygon();
	if (poly.isEmpty())
		return;
	QPointF p1 = poly.first();
	QPointF p2 = poly.last();

	poly.prepend(QPointF(p1.x(), vAxis->posAtValue(0)));
	poly.append(QPointF(p2.x(), vAxis->posAtValue(0)));
	setPolygon(poly);

	QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
	pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
	pat.setColorAt(1, getColor(CALC_CEILING_DEEP));
	setPen(QPen(QBrush(Qt::NoBrush), 0));
	setBrush(pat);

	gradientFactor->setX(poly.boundingRect().width() / 2 + poly.boundingRect().x());
	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
	if (plannerModel->isPlanner()) {
		struct diveplan &diveplan = plannerModel->getDiveplan();
		gradientFactor->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh));
	} else {
		gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
	}
}
开发者ID:codesong,项目名称:subsurface,代码行数:32,代码来源:diveprofileitem.cpp

示例10: QPointF

void SMDItem::createItem(QGraphicsItemGroup* inOutItem, bool inIsMainNotGround)
{
    auto main = new QGraphicsPolygonItem;
    QPolygonF poly;
    for (auto point : mComponent->rect().points)
    {
        poly << QPointF(point.x, - point.y);
    }
    poly << poly.first();
    main->setPolygon(poly);

    QColor color = inIsMainNotGround ?
        gSettings().layerColor(mComponent->layer())
        : gSettings().backgroundColor();
    QBrush br(color);
    main->setBrush(br);
    QPen p(color);
    if (!inIsMainNotGround)
    {
        p.setColor(color);
        p.setWidthF(mComponent->groundPlaneDistance() * 2);
        p.setJoinStyle(Qt::MiterJoin);
    }
    main->setPen(p);
    inOutItem->addToGroup(main);
}
开发者ID:constrictor,项目名称:Layoutie,代码行数:26,代码来源:SMDItem.cpp

示例11: point

void PartialPressureGasItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
	//AbstractProfilePolygonItem::modelDataChanged();
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;

	plot_data *entry = dataModel->data().entry;
	QPolygonF poly;
	alertPoly.clear();
	QSettings s;
	s.beginGroup("TecDetails");
	double threshould = s.value(threshouldKey).toDouble();
	for(int i = 0;  i < dataModel->rowCount(); i++, entry++){
		double value = dataModel->index(i, vDataColumn).data().toDouble();
		int time = dataModel->index(i, hDataColumn).data().toInt();
		QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
		poly.push_back( point );
		if (value >= threshould)
			alertPoly.push_back(point);
	}
	setPolygon(poly);
	/*
	createPPLegend(trUtf8("pN" UTF8_SUBSCRIPT_2),getColor(PN2), legendPos);
	*/
}
开发者ID:danilocesar,项目名称:subsurface,代码行数:25,代码来源:diveprofileitem.cpp

示例12: QPointF

Hex::Hex(QGraphicsItem *parent){
    // draw the polygon

    // points needed to draw hexagon: (1,0), (2,0), (3,1), (2,2), (1,2), (0,1)
    QVector<QPointF> hexPoints;
    hexPoints << QPointF(1,0) << QPointF(2,0) << QPointF(3,1) << QPointF(2,2)
              << QPointF(1,2) << QPointF(0,1);

    // scale the points
    int SCALE_BY = 40;
    for (size_t i = 0, n = hexPoints.size(); i < n; ++i){
        hexPoints[i] = hexPoints[i] * SCALE_BY;
    }

    // create a polygon with the scaled points
    QPolygonF hexagon(hexPoints);

    // draw the poly
    setPolygon(hexagon);

    // initialize
    isPlaced = false;

    // initialize side attacks to 0
    side0Attack = 0;
    side1Attack = 0;
    side2Attack = 0;
    side3Attack = 0;
    side4Attack = 0;
    side5Attack = 0;

    // create QGraphicsTextItems to represent visually each side's attack
    QGraphicsTextItem* text0 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text1 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text2 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text3 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text4 = new QGraphicsTextItem(QString::number(0),this);
    QGraphicsTextItem* text5 = new QGraphicsTextItem(QString::number(0),this);

    attackTexts.append(text0);
    attackTexts.append(text1);
    attackTexts.append(text2);
    attackTexts.append(text3);
    attackTexts.append(text4);
    attackTexts.append(text5);

    // set the correct position of the attack texts
    text0->setPos(50,0);
    text1->setPos(20,15);
    text2->setPos(20,40);
    text3->setPos(50,55);
    text4->setPos(80,40);
    text5->setPos(80,15);

    // make all attack texts invisible
    for (size_t i = 0, n = attackTexts.size(); i < n; i++){
        attackTexts[i]->setVisible(false);
    }
}
开发者ID:Fader1997,项目名称:QtGameTutorial,代码行数:59,代码来源:Hex.cpp

示例13: QPointF

/*!
	\brief Create the hexagon by setting a QPolygonF
*/
void HexagonItem::createHexagon()
{
	QPolygonF hexagonPolygon;
	hexagonPolygon << QPointF(-HEXAGON_EDGE_ITEM, 0.0) << QPointF(-HEXAGON_EDGE_ITEM/2, HEXAGON_EDGE_ITEM/2*sqrt(3.0))
					<< QPointF(HEXAGON_EDGE_ITEM/2, HEXAGON_EDGE_ITEM/2*sqrt(3.0)) << QPointF(HEXAGON_EDGE_ITEM, 0.0)
					<< QPointF(HEXAGON_EDGE_ITEM/2, -HEXAGON_EDGE_ITEM/2*sqrt(3.0)) << QPointF(-HEXAGON_EDGE_ITEM/2, -HEXAGON_EDGE_ITEM/2*sqrt(3.0));
	setPolygon(hexagonPolygon);
}
开发者ID:pqpqpqpqpq,项目名称:Graph,代码行数:11,代码来源:hexagonitem.cpp

示例14: QGraphicsPolygonItem

HexagonItem::HexagonItem(const QPolygonF &polygon, QGraphicsItem *parent)
	: QGraphicsPolygonItem(parent),
	  edgeWidth(1)
{
	setPolygon(polygon);
	createHexagon();
	setZValue(3);
}
开发者ID:pqpqpqpqpq,项目名称:Graph,代码行数:8,代码来源:hexagonitem.cpp

示例15: QGraphicsPolygonItem

Terrain::Terrain (const QPolygonF & polygon, QGraphicsItem *parent) : QGraphicsPolygonItem(parent)/*, m_polygon(polygon)*/ {
    setPolygon( polygon );
    setType( kWoods );
    setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges );

    foreach ( const QPointF & pos, polygon ) {
        createDot( pos );
    }
开发者ID:D-Pointer,项目名称:imperium-editor,代码行数:8,代码来源:Terrain.cpp


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