本文整理汇总了C++中QPolygon::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::clear方法的具体用法?C++ QPolygon::clear怎么用?C++ QPolygon::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygon
的用法示例。
在下文中一共展示了QPolygon::clear方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initElement
void EBackGroundFore::initElement()
{
this->clearAllPolygon();
QPolygon polygon;
// switch(GameInfo::gameStatus)
// {
// case MainMenu:
// case ModeSelect:
// case GamePlay:
// case GameOver:
polygon.putPoints(0, 3, 0,0, -884,0, -442,-765);
this->addPolygon(polygon);
polygon.clear();
polygon.putPoints(0, 3, 0,0, 442,-765, 884,0);
this->addPolygon(polygon);
polygon.clear();
polygon.putPoints(0, 3, 0,0, 442,765, -442,765);
this->addPolygon(polygon);
polygon.clear();
// break;
// }
this->pen.setWidth(1);
this->brush.setStyle(Qt::SolidPattern);
}
示例2: testSafeTransformSingleVanishingPoint
void KisTransformMaskTest::testSafeTransformSingleVanishingPoint()
{
// rotation around 0X has a single vanishing point for 0Y axis
QTransform transform(1, 0, 0,
-0.870208, -0.414416, -0.000955222,
132.386, 1082.91, 1.99439);
QTransform R; R.rotateRadians(M_PI / 4.0);
//transform *= R;
QRectF testRect(1536, 1024, 512, 512);
KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());
QPolygonF fwdPoly = t2.mapForward(testRect);
QRectF fwdRect = t2.mapRectForward(testRect);
QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
QRectF bwdRect = t2.mapRectBackward(fwdRect);
/**
* A special weird rect that crosses the vanishing point,
* which is (911.001, 433.84) in this case
*/
QRectF fwdNastyRect(800, 100, 400, 600);
//QRectF fwdNastyRect(100, 400, 1000, 800);
QRectF bwdNastyRect = t2.mapRectBackward(fwdNastyRect);
/*
dbgKrita << ppVar(testRect);
dbgKrita << ppVar(fwdPoly);
dbgKrita << ppVar(fwdRect);
dbgKrita << ppVar(bwdPoly);
dbgKrita << ppVar(bwdRect);
dbgKrita << ppVar(bwdNastyRect);
*/
QPolygon ref;
ref.clear();
ref << QPoint(765,648);
ref << QPoint(1269, 648);
ref << QPoint(1601, 847);
ref << QPoint(629, 847);
ref << QPoint(765, 648);
QCOMPARE(fwdPoly.toPolygon(), ref);
QCOMPARE(fwdRect.toRect(), QRect(629,648,971,199));
ref.clear();
ref << QPoint(1536,1024);
ref << QPoint(2048,1024);
ref << QPoint(2048,1536);
ref << QPoint(1536,1536);
ref << QPoint(1536,1024);
QCOMPARE(bwdPoly.toPolygon(), ref);
QCOMPARE(bwdRect.toRect(), QRect(1398,1024,650,512));
QCOMPARE(bwdNastyRect.toRect(), QRect(1463,0,585,1232));
}
示例3: draw
//.........这里部分代码省略.........
painter->createArc(pa2, view->toGui(arc->getCenter()),
view->toGuiDX(arc->getRadius())
,arc->getAngle1(),arc->getAngle2(),arc->isReversed());
if(pa.size() &&pa2.size()&&(pa.last()-pa2.first()).manhattanLength()<1)
pa2.remove(0,1);
pa<<pa2;
}
break;
case RS2::EntityCircle: {
RS_Circle* circle = static_cast<RS_Circle*>(e);
// QPoint pt1(RS_Math::round(view->toGuiX(circle->getCenter().x+circle->getRadius())),
// RS_Math::round(view->toGuiY(circle->getCenter().y)));
// if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
// jp<<pt1;
// }
RS_Vector c=view->toGui(circle->getCenter());
double r=view->toGuiDX(circle->getRadius());
#if QT_VERSION >= 0x040400
path.addEllipse(QPoint(c.x,c.y),r,r);
#else
path.addEllipse(c.x - r, c.y + r, 2.*r, 2.*r);
// QPolygon pa2;
// painter->createArc(pa2, view->toGui(circle->getCenter()),
// view->toGuiDX(circle->getRadius()),
// 0.0,
// 2*M_PI,
// false);
// pa<<pa2;
#endif
}
break;
case RS2::EntityEllipse:
if(static_cast<RS_Ellipse*>(e)->isArc()) {
QPolygon pa2;
auto ellipse=static_cast<RS_Ellipse*>(e);
painter->createEllipse(pa2,
view->toGui(ellipse->getCenter()),
view->toGuiDX(ellipse->getMajorRadius()),
view->toGuiDX(ellipse->getMinorRadius()),
ellipse->getAngle()
,ellipse->getAngle1(),ellipse->getAngle2(),ellipse->isReversed()
);
// qDebug()<<"ellipse: "<<ellipse->getCenter().x<<","<<ellipse->getCenter().y;
// qDebug()<<"ellipse: pa2.size()="<<pa2.size();
// qDebug()<<"ellipse: pa2="<<pa2;
if(pa.size() && pa2.size()&&(pa.last()-pa2.first()).manhattanLength()<1)
pa2.remove(0,1);
pa<<pa2;
}else{
QPolygon pa2;
auto ellipse=static_cast<RS_Ellipse*>(e);
painter->createEllipse(pa2,
view->toGui(ellipse->getCenter()),
view->toGuiDX(ellipse->getMajorRadius()),
view->toGuiDX(ellipse->getMinorRadius()),
ellipse->getAngle(),
ellipse->getAngle1(), ellipse->getAngle2(),
ellipse->isReversed()
);
path.addPolygon(pa2);
}
break;
default:
break;
}
// qDebug()<<"pa="<<pa;
if( pa.size()>2 && pa.first() == pa.last()) {
paClosed<<pa;
pa.clear();
}
}
}
}
if(pa.size()>2){
pa<<pa.first();
paClosed<<pa;
}
for(auto& p:paClosed){
path.addPolygon(p);
}
//bug#474, restore brush after solid fill
const QBrush brush(painter->brush());
const RS_Pen pen=painter->getPen();
painter->setBrush(pen.getColor());
painter->disablePen();
painter->drawPath(path);
painter->setBrush(brush);
painter->setPen(pen);
}
示例4: QPoint
void
Text::init()
{
_fontSize.setX((qreal)widget()->_inst->font_width);
_fontSize.setY((qreal)widget()->_inst->font_height);
_ldcMap.clear();
QPolygon polygon;
// -
polygon << QPoint(0,_fontSize.y()/2) << QPoint(_fontSize.x(),_fontSize.y()/2);
_ldcMap.insert(lh,polygon);
// |
polygon.clear();
polygon << QPoint(_fontSize.x()/2,0) << QPoint(_fontSize.x()/2,_fontSize.y());
_ldcMap.insert(lv,polygon);
// _
// |
polygon.clear();
polygon << QPoint(_fontSize.x()/2,_fontSize.y()/2) << QPoint(_fontSize.x()/2,_fontSize.y());
polygon << QPoint(_fontSize.x()/2,_fontSize.y()/2) << QPoint(_fontSize.x(),_fontSize.y()/2);
_ldcMap.insert(ldlr,polygon);
// _
// |
polygon.clear();
polygon << QPoint(_fontSize.x()/2,_fontSize.y()/2) << QPoint(_fontSize.x()/2,_fontSize.y());
polygon << QPoint(0,_fontSize.y()/2) << QPoint(_fontSize.x()/2,_fontSize.y()/2);
_ldcMap.insert(ldll,polygon);
// |_
polygon.clear();
polygon << QPoint(_fontSize.x()/2,0) << QPoint(_fontSize.x()/2,_fontSize.y()/2);
polygon << QPoint(_fontSize.x()/2,_fontSize.y()/2) << QPoint(_fontSize.x(),_fontSize.y()/2);
_ldcMap.insert(lulr,polygon);
// _|
polygon.clear();
polygon << QPoint(_fontSize.x()/2,0) << QPoint(_fontSize.x()/2,_fontSize.y()/2);
polygon << QPoint(0,_fontSize.y()/2) << QPoint(_fontSize.x()/2,_fontSize.y()/2);
_ldcMap.insert(lull,polygon);
// |-
polygon.clear();
polygon << QPoint(_fontSize.x()/2,0) << QPoint(_fontSize.x()/2,_fontSize.y());
polygon << QPoint(_fontSize.x()/2,_fontSize.y()/2) << QPoint(_fontSize.x(),_fontSize.y()/2);
_ldcMap.insert(lvlr,polygon);
// -|
polygon.clear();
polygon << QPoint(_fontSize.x()/2,0) << QPoint(_fontSize.x()/2,_fontSize.y());
polygon << QPoint(0,_fontSize.y()/2) << QPoint(_fontSize.x()/2,_fontSize.y()/2);
_ldcMap.insert(lvll,polygon);
// _
// |
polygon.clear();
polygon << QPoint(0,_fontSize.y()/2) << QPoint(_fontSize.x(),_fontSize.y()/2);
polygon << QPoint(_fontSize.x()/2,_fontSize.y()/2) << QPoint(_fontSize.x()/2,_fontSize.y());
_ldcMap.insert(lhld,polygon);
// |
// -
polygon.clear();
polygon << QPoint(0,_fontSize.y()/2) << QPoint(_fontSize.x(),_fontSize.y()/2);
polygon << QPoint(_fontSize.x()/2,0) << QPoint(_fontSize.x()/2,_fontSize.y()/2);
_ldcMap.insert(lhlu,polygon);
// +
polygon.clear();
polygon << QPoint(0,_fontSize.y()/2) << QPoint(_fontSize.x(),_fontSize.y()/2);
polygon << QPoint(_fontSize.x()/2,0) << QPoint(_fontSize.x()/2,_fontSize.y());
_ldcMap.insert(lhlv,polygon);
}
示例5: draw
//.........这里部分代码省略.........
case RS2::EntityArc: {
// QPoint pt1(RS_Math::round(view->toGuiX(e->getStartpoint().x)),
// RS_Math::round(view->toGuiY(e->getStartpoint().y)));
// if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
// jp<<pt1;
// }
QPolygon pa2;
RS_Arc* arc=static_cast<RS_Arc*>(e);
painter->createArc(pa2, view->toGui(arc->getCenter()),
view->toGuiDX(arc->getRadius()),
arc->getAngle1(),
arc->getAngle2(),
arc->isReversed());
pa<<pa2;
}
break;
case RS2::EntityCircle: {
RS_Circle* circle = static_cast<RS_Circle*>(e);
// QPoint pt1(RS_Math::round(view->toGuiX(circle->getCenter().x+circle->getRadius())),
// RS_Math::round(view->toGuiY(circle->getCenter().y)));
// if (! (pa.size()>0 && (pa.last() - pt1).manhattanLength()<=2)) {
// jp<<pt1;
// }
RS_Vector c=view->toGui(circle->getCenter());
double r=view->toGuiDX(circle->getRadius());
#if QT_VERSION >= 0x040400
path.addEllipse(QPoint(c.x,c.y),r,r);
#else
path.addEllipse(c.x - r, c.y + r, 2.*r, 2.*r);
// QPolygon pa2;
// painter->createArc(pa2, view->toGui(circle->getCenter()),
// view->toGuiDX(circle->getRadius()),
// 0.0,
// 2*M_PI,
// false);
// pa<<pa2;
#endif
}
break;
case RS2::EntityEllipse:
if(static_cast<RS_Ellipse*>(e)->isArc()) {
QPolygon pa2;
auto ellipse=static_cast<RS_Ellipse*>(e);
painter->createEllipse(pa2,
view->toGui(ellipse->getCenter()),
view->toGuiDX(ellipse->getMajorRadius()),
view->toGuiDX(ellipse->getMinorRadius()),
ellipse->getAngle(),
ellipse->getAngle1(), ellipse->getAngle2(),
ellipse->isReversed()
);
pa<<pa2;
}else{
QPolygon pa2;
auto ellipse=static_cast<RS_Ellipse*>(e);
painter->createEllipse(pa2,
view->toGui(ellipse->getCenter()),
view->toGuiDX(ellipse->getMajorRadius()),
view->toGuiDX(ellipse->getMinorRadius()),
ellipse->getAngle(),
ellipse->getAngle1(), ellipse->getAngle2(),
ellipse->isReversed()
);
path.addPolygon(pa2);
}
break;
default:
break;
}
if( pa.size()>2 && pa.first() == pa.last()) {
paClosed<<pa;
pa.clear();
}
}
}
}
if(pa.size()>2){
pa<<pa.first();
paClosed<<pa;
}
for(int i=0;i<paClosed.size();i++){
path.addPolygon(paClosed.at(i));
}
painter->setBrush(painter->getPen().getColor());
painter->disablePen();
painter->drawPath(path);
// pa<<jp;
// painter->setBrush(painter->getPen().getColor());
// painter->disablePen();
// painter->drawPolygon(pa);
}
示例6: testSafeTransform
void KisTransformMaskTest::testSafeTransform()
{
QTransform transform(-0.177454, -0.805953, -0.00213713,
-1.9295, -0.371835, -0.00290463,
3075.05, 2252.32, 7.62371);
QRectF testRect(0, 1024, 512, 512);
KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());
QPolygonF fwdPoly = t2.mapForward(testRect);
QRectF fwdRect = t2.mapRectForward(testRect);
QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
QRectF bwdRect = t2.mapRectBackward(fwdRect);
QPolygon ref;
ref.clear();
ref << QPoint(284, 410);
ref << QPoint(10, 613);
ref << QPoint(35, 532);
ref << QPoint(236, 403);
ref << QPoint(284, 410);
QCOMPARE(fwdPoly.toPolygon(), ref);
QCOMPARE(fwdRect.toRect(), QRect(10,403,274,211));
ref.clear();
ref << QPoint(512, 1024);
ref << QPoint(512, 1536);
ref << QPoint(0, 1536);
ref << QPoint(0, 1024);
ref << QPoint(512, 1024);
QCOMPARE(bwdPoly.toPolygon(), ref);
QCOMPARE(bwdRect.toRect(), QRect(0, 994, 1198, 584));
/*
QImage image(2500, 2500, QImage::Format_ARGB32);
QPainter gc(&image);
gc.setPen(Qt::cyan);
gc.setOpacity(0.7);
gc.setBrush(Qt::red);
gc.drawPolygon(t2.srcClipPolygon());
gc.setBrush(Qt::green);
gc.drawPolygon(t2.dstClipPolygon());
dbgKrita << ppVar(testRect);
dbgKrita << ppVar(fwdPoly);
dbgKrita << ppVar(fwdRect);
dbgKrita << ppVar(bwdPoly);
dbgKrita << ppVar(bwdRect);
gc.setBrush(Qt::yellow);
gc.drawPolygon(testRect);
gc.setBrush(Qt::red);
gc.drawPolygon(fwdRect);
gc.setBrush(Qt::blue);
gc.drawPolygon(fwdPoly);
gc.setBrush(Qt::magenta);
gc.drawPolygon(bwdRect);
gc.setBrush(Qt::cyan);
gc.drawPolygon(bwdPoly);
gc.end();
image.save("polygons_safety.png");
*/
}
示例7: color
int
MarkerRetracement::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &, void *m)
{
Marker *ret = (Marker *) m;
Entity *e = ret->settings();
QVariant *date = e->get(QString("date"));
if (! date)
return 0;
QVariant *date2 = e->get(QString("date2"));
if (! date2)
return 0;
QVariant *high = e->get(QString("high"));
if (! high)
return 0;
QVariant *low = e->get(QString("low"));
if (! low)
return 0;
QVariant *tset = e->get(QString("color"));
if (! tset)
return 0;
QColor color(tset->toString());
QVariant *extend = e->get(QString("extend"));
if (! extend)
return 0;
QVariant *l1 = e->get(QString("level1"));
if (! l1)
return 0;
QVariant *l2 = e->get(QString("level2"));
if (! l2)
return 0;
QVariant *l3 = e->get(QString("level3"));
if (! l3)
return 0;
QVariant *l4 = e->get(QString("level4"));
if (! l4)
return 0;
QVariant *l5 = e->get(QString("level5"));
if (! l5)
return 0;
QVariant *l6 = e->get(QString("level6"));
if (! l6)
return 0;
PlotDateScaleDraw *dsd = (PlotDateScaleDraw *) ret->plot()->axisScaleDraw(QwtPlot::xBottom);
int x = xMap.transform(dsd->dateToX(date->toDateTime()));
QDateTime dt = date2->toDateTime();
if (extend->toBool())
{
int s, e;
g_symbol->startEndRange(s, e);
Bar *bar = g_symbol->bar(e);
if (! bar)
return 0;
dt = bar->date();
}
int x2 = xMap.transform(dsd->dateToX(dt));
p->setPen(color);
ret->clearSelectionArea();
QList<double> lineList;
lineList.append(l1->toDouble());
lineList.append(l2->toDouble());
lineList.append(l3->toDouble());
lineList.append(l4->toDouble());
lineList.append(l5->toDouble());
lineList.append(l6->toDouble());
for (int loop = 0; loop < lineList.size(); loop++)
{
double td = lineList.at(loop);
if (td != 0)
{
double range = high->toDouble() - low->toDouble();
double r = 0;
if (td < 0)
r = low->toDouble() + (range * td);
else
{
if (td > 0)
r = low->toDouble() + (range * td);
else
{
if (td < 0)
//.........这里部分代码省略.........
示例8: QGraphicsView
//.........这里部分代码省略.........
painter.drawText(
QPoint(-5, -(WIDGETSIZE/2-CIRCLEPENWIDTH)+28),
QString::number(i));
for(int j=1 ; j<5 ; ++j)
{
painter.rotate(7.2);
painter.drawLine(QPoint(0, -(WIDGETSIZE/2-CIRCLEPENWIDTH)+5),
QPoint(0, -(WIDGETSIZE/2-CIRCLEPENWIDTH)+10));
}
painter.rotate(7.2);
}
painter.restore();
painter.end();
// HAND, FEETS
feetsHand = QPixmap(HANDWIDTH, HANDHEIGHT);
painter.begin(&(this->feetsHand));
painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(feetsHand.rect(), backgroundBrush);
// Hand front
painter.setBrush(handBrushFront);
painter.setPen(handPenFront);
painter.drawRect(QRect(HANDCENTERX-2, CIRCLEPENWIDTH+5, 4, 16));
painter.drawRect(QRect(
QPoint(HANDCENTERX-3, CIRCLEPENWIDTH+5+15),
QPoint(HANDCENTERX+3, HANDCENTERY))
);
// Hand back
painter.setBrush(handBrushBack);
painter.setPen(handPenBack);
painter.drawRect(HANDCENTERX-3, HANDCENTERY, 6, 25);
painter.drawEllipse(QPoint(HANDCENTERX, HANDCENTERY+25), 6, 6);
painter.end();
// Mask
feetsHand.setMask(feetsHand.createMaskFromColor(
backgroundBrush.color(),
Qt::MaskInColor)
);
// HAND, TENTH of FEETS
tenthHand = QPixmap(HANDWIDTH, HANDHEIGHT);
painter.begin(&(this->tenthHand));
painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(tenthHand.rect(), backgroundBrush);
// Hand front
painter.setBrush(handBrushFront);
painter.setPen(handPenFront);
polygon.append(HANDCENTER);
polygon.append(QPoint(HANDCENTERX-10, HANDCENTERY-25));
polygon.append(QPoint(HANDCENTERX, HANDCENTERY-75));
polygon.append(QPoint(HANDCENTERX+10, HANDCENTERY-25));
painter.drawPolygon(polygon);
// Hand back
painter.setBrush(handBrushBack);
painter.setPen(handPenBack);
polygon.clear();
polygon.append(HANDCENTER);
polygon.append(QPoint(HANDCENTERX-10, HANDCENTERY+25));
polygon.append(QPoint(HANDCENTERX+10, HANDCENTERY+25));
painter.drawPolygon(polygon);
painter.end();
// Mask
tenthHand.setMask(tenthHand.createMaskFromColor(
backgroundBrush.color(),
Qt::MaskInColor)
);
// HAND, HUNDREDS of FEETS
hundredsHand = QPixmap(HANDWIDTH, HANDHEIGHT);
painter.begin(&(this->hundredsHand));
painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(hundredsHand.rect(), backgroundBrush);
// Hand front
painter.setBrush(handBrushFront);
painter.setPen(handPenFront);
painter.drawRect(QRect(
HANDCENTERX-2,
CIRCLEPENWIDTH+5,
4,
HANDCENTERY-CIRCLEPENWIDTH-5)
);
polygon.clear();
polygon.append(QPoint(HANDCENTERX-10, CIRCLEPENWIDTH+5));
polygon.append(QPoint(HANDCENTERX+10, CIRCLEPENWIDTH+5));
polygon.append(QPoint(HANDCENTERX, CIRCLEPENWIDTH+5+15));
painter.drawPolygon(polygon);
// Hand back
painter.setBrush(handBrushBack);
painter.setPen(handPenBack);
painter.end();
// Mask
hundredsHand.setMask(hundredsHand.createMaskFromColor(
backgroundBrush.color(),
Qt::MaskInColor)
);
}
示例9: sideBarPaintEvent
void TraceWidget::sideBarPaintEvent(QPaintEvent * event)
{
// don't paint anything if there are no cycles
if (cycle_.first < 0 || cycle_.second < 0)
return;
QPainter painter(cbar_);
QRect rct, first_rct, last_rct;
int first_id = -1, last_id = -1;
for (int i = 0; i < count(); ++i) {
rct = visualItemRect(item(i));
if (rct.top() > event->rect().bottom())
break;
if (rct.bottom() <= event->rect().top())
continue;
if (i >= cycle_.second && i <= cycle_.first) {
if (first_id == -1) {
first_id = i;
first_rct = rct;
}
last_id = i;
last_rct = rct;
}
}
// draw nothing
if (first_id == -1)
return;
QList<QPolygon> lines;
QPolygon line;
// start of the cycle
if (last_id == cycle_.first) {
const int base_off = last_rct.top() + (last_rct.height() - cycleBaseSize) / 2;
const int line_off = last_rct.top() + last_rct.height() / 2;
line.push_back(QPoint(cycleBarWidth - 2, base_off));
line.push_back(QPoint(cycleBarWidth - 2, base_off + cycleBaseSize));
lines.append(line);
line.clear();
line.push_back(QPoint(cycleBarWidth - 2, line_off));
line.push_back(QPoint(cycleLeftOffset, line_off));
} else {
line.push_back(QPoint(cycleLeftOffset, last_rct.bottom()));
}
const int line_off = first_rct.top() + first_rct.height() / 2;
// end
if (first_id == cycle_.second) {
line.push_back(QPoint(cycleLeftOffset, line_off));
line.push_back(QPoint(cycleBarWidth - 2, line_off));
lines.append(line);
// arrow
line.clear();
line.push_back(QPoint(cycleBarWidth - 4, line_off - 2));
line.push_back(QPoint(cycleBarWidth - 2, line_off));
line.push_back(QPoint(cycleBarWidth - 4, line_off + 2));
lines.append(line);
} else {
line.push_back(QPoint(cycleLeftOffset, first_rct.top()));
lines.append(line);
}
QPen pen;
painter.setPen(pen);
foreach(QPolygon itr, lines) {
painter.drawPolyline(itr);
}