本文整理汇总了C++中QPainterPath::arcMoveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::arcMoveTo方法的具体用法?C++ QPainterPath::arcMoveTo怎么用?C++ QPainterPath::arcMoveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPath
的用法示例。
在下文中一共展示了QPainterPath::arcMoveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ri
//------------------------------------------------------------------------------
void
Canvas::DrawAnnulus(int x, int y,
unsigned inner_r, unsigned outer_r,
Angle start, Angle end)
{
QPainterPath p;
QRectF ri(x - inner_r, y - inner_r, 2 * inner_r, 2 * inner_r);
QRectF ro(x - outer_r, y - outer_r, 2 * outer_r, 2 * outer_r);
// Draw the inner radius of the annulus.
p.arcMoveTo(ri, start.Degrees());
p.arcTo(ri, start.Degrees(), end.Degrees() - start.Degrees());
if (start != end)
{ // Only draw the end caps when needed.
// The currentPosition() will be at the end of the inner circle. Draw
// one side of the annulus.
// \todo This doesn't work because Angle(360) != Angle(0)!
double xx = (outer_r - inner_r) * cos(end.Radians()) +
p.currentPosition().rx();
double yy = (outer_r - inner_r) * -sin(end.Radians()) +
p.currentPosition().ry();
p.lineTo(xx, yy);
}
else
p.arcMoveTo(ro, end.Degrees()); // Set up for the outer circle.
// The currentPosition() will be at the 'end' of the outer circle. Draw the
// outer to the start.
p.arcTo(ro, end.Degrees(), start.Degrees() - end.Degrees());
if (start != end)
{// And close it off to finish up.
p.closeSubpath();
}
this->pushObject(p, this->pen(), this->brush());
}
示例2: paintEvent
void SearchButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainterPath myPath;
int radius = (height() / 5) * 2;
QRect circle(height() / 3 - 1, height() / 4, radius, radius);
myPath.addEllipse(circle);
myPath.arcMoveTo(circle, 300);
QPointF c = myPath.currentPosition();
int diff = height() / 7;
myPath.lineTo(qMin(width() - 2, (int)c.x() + diff), c.y() + diff);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::darkGray, 2));
painter.drawPath(myPath);
if (m_menu) {
QPainterPath dropPath;
dropPath.arcMoveTo(circle, 320);
QPointF c = dropPath.currentPosition();
c = QPointF(c.x() + 3.5, c.y() + 0.5);
dropPath.moveTo(c);
dropPath.lineTo(c.x() + 4, c.y());
dropPath.lineTo(c.x() + 2, c.y() + 2);
dropPath.closeSubpath();
painter.setPen(Qt::darkGray);
painter.setBrush(Qt::darkGray);
painter.setRenderHint(QPainter::Antialiasing, false);
painter.drawPath(dropPath);
}
painter.end();
}
示例3: arcWinding_data
void tst_QPainterPath::arcWinding_data()
{
QTest::addColumn<QPainterPath>("path");
QTest::addColumn<QPointF>("point");
QTest::addColumn<bool>("inside");
QPainterPath a;
a.addEllipse(0, 0, 100, 100);
a.addRect(50, 50, 100, 100);
QTest::newRow("Case A (oddeven)") << a << QPointF(55, 55) << false;
a.setFillRule(Qt::WindingFill);
QTest::newRow("Case A (winding)") << a << QPointF(55, 55) << true;
QPainterPath b;
b.arcMoveTo(0, 0, 100, 100, 10);
b.arcTo(0, 0, 100, 100, 10, 360);
b.addRect(50, 50, 100, 100);
QTest::newRow("Case B (oddeven)") << b << QPointF(55, 55) << false;
b.setFillRule(Qt::WindingFill);
QTest::newRow("Case B (winding)") << b << QPointF(55, 55) << false;
QPainterPath c;
c.arcMoveTo(0, 0, 100, 100, 0);
c.arcTo(0, 0, 100, 100, 0, 360);
c.addRect(50, 50, 100, 100);
QTest::newRow("Case C (oddeven)") << c << QPointF(55, 55) << false;
c.setFillRule(Qt::WindingFill);
QTest::newRow("Case C (winding)") << c << QPointF(55, 55) << false;
QPainterPath d;
d.arcMoveTo(0, 0, 100, 100, 10);
d.arcTo(0, 0, 100, 100, 10, -360);
d.addRect(50, 50, 100, 100);
QTest::newRow("Case D (oddeven)") << d << QPointF(55, 55) << false;
d.setFillRule(Qt::WindingFill);
QTest::newRow("Case D (winding)") << d << QPointF(55, 55) << true;
QPainterPath e;
e.arcMoveTo(0, 0, 100, 100, 0);
e.arcTo(0, 0, 100, 100, 0, -360);
e.addRect(50, 50, 100, 100);
QTest::newRow("Case E (oddeven)") << e << QPointF(55, 55) << false;
e.setFillRule(Qt::WindingFill);
QTest::newRow("Case E (winding)") << e << QPointF(55, 55) << true;
}
示例4: redBrush
dialogSmithChart::dialogSmithChart(QWidget *parent) :
QDialog(parent),
ui(new Ui::dialogSmithChart)
{
ui->setupUi(this);
resize(430,400);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
QBrush redBrush(Qt::red);
QBrush blueBrush(Qt::blue);
QPen blackPen(Qt::black);
//ell = scene->addEllipse(10,10,100,100,blackPen,redBrush);
QPainterPath* path = new QPainterPath();
path->arcMoveTo(0,0,50,50,20);
path->arcTo(0,0,50,50,20, 90);
scene->addPath(*path);
//ui->graphicsView->sc
//h = 430; w = 400
// centerX = 195;
// CenterY = 191;
}
示例5: drawRobot
void Robotcl::drawRobot(QPainter *painter)
{
painter->save();
painter->translate(px,py);
QPen pen;
QBrush brush;
if(team() == Blue)
{
if(Field::SelectedRobotID == ID)
pen.setColor(Qt::white);
else
pen.setColor(Qt::blue);
brush = QBrush(QColor("blue"));
}
else if(team()==Yellow)
{
if(Field::SelectedRobotID == ID)
pen.setColor(Qt::white);
else
pen.setColor(Qt::yellow);
brush = QBrush(QColor("Yellow"));
}
QPainterPath robotPath;
robotPath.moveTo(-diagonal/2.0,-diagonal/2.0);
robotPath.arcMoveTo(-diagonal/2.0,-diagonal/2.0,diagonal,diagonal,0);
robotPath.arcTo(-diagonal/2.0,-diagonal/2.0,diagonal,diagonal,0,290.0);
pen.setWidth(10);
painter->setPen(pen);
qreal rotateAngle = 35.0;
painter->rotate(orientation()-rotateAngle);
painter->fillPath(robotPath,brush);
painter->rotate(-(orientation()-rotateAngle));
QRectF rect;
pen.setWidth(20);
if(Field::SelectedRobotID == ID)
pen.setColor(Qt::white);
else
pen.setColor(Qt::black);
painter->setPen(pen);
painter->setBrush(Qt::NoBrush);
painter->setFont(QFont("Tahoma",100));
rect = painter->boundingRect(rect,QString::number(ID));
painter->scale(1,-1);
painter->drawText(0,0 ,rect.width() ,rect.height() ,0 ,QString::number(ID));
painter->restore();
}
示例6: 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));
}
示例7: thickPen
QGraphicsItem *addSmiley() {
QPen thickPen(Qt::black);
thickPen.setWidth(2);
// add face
QGraphicsEllipseItem *face = new QGraphicsEllipseItem(QRect(-50, -50, 100, 100));
face->setPen(Qt::NoPen);
face->setBrush(Qt::yellow);
// add eyes
QGraphicsEllipseItem *leftEye = new QGraphicsEllipseItem(QRectF(-6, -12, 12, 24), face);
leftEye->setPen(thickPen);
leftEye->setBrush(Qt::white);
leftEye->setPos(-15, -25);
QGraphicsEllipseItem *rightEye = new QGraphicsEllipseItem(QRectF(-6, -12, 12, 24), face);
rightEye->setPen(thickPen);
rightEye->setBrush(Qt::white);
rightEye->setPos(15, -25);
// add smile
QPainterPath smileArc;
QRect rect(-33, -15, 66, 50);
smileArc.arcMoveTo(rect, 0);
smileArc.arcTo(rect, 0, -180);
QGraphicsPathItem *smile = new QGraphicsPathItem(smileArc, face);
smile->setPen(thickPen);
return face;
}
示例8: updatePath
void EllipseObject::updatePath()
{
QPainterPath path;
QRectF r = rect();
path.arcMoveTo(r, 0);
path.arcTo(r, 0, 360);
//NOTE: Reverse the path so that the inside area isn't considered part of the ellipse
path.arcTo(r, 0, -360);
setObjectPath(path);
}
示例9: updatePath
void CircleObject::updatePath()
{
QPainterPath path;
QRectF r = rect();
//Add the center point
path.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002);
//Add the circle
path.arcMoveTo(r, 0);
path.arcTo(r, 0, 360);
//NOTE: Reverse the path so that the inside area isn't considered part of the circle
path.arcTo(r, 0, -360);
setObjectPath(path);
}
示例10: objectSavePath
QPainterPath CircleObject::objectSavePath() const
{
QPainterPath path;
QRectF r = rect();
path.arcMoveTo(r, 0);
path.arcTo(r, 0, 360);
qreal s = scale();
QTransform trans;
trans.rotate(rotation());
trans.scale(s,s);
return trans.map(path);
}
示例11: r
//------------------------------------------------------------------------------
void
Canvas::DrawSegment(int x,
int y,
unsigned radius,
Angle start,
Angle end,
bool horizon)
{
QPainterPath p;
QRectF r(x - radius, y - radius, 2 * radius, 2 * radius);
p.arcMoveTo(r, start.Degrees());
p.arcTo(r, start.Degrees(), end.Degrees() - start.Degrees());
this->pushObject(p, this->pen(), this->brush());
}
示例12: paint
void Arc::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
QPen paintpen;
painter->setRenderHint(QPainter::Antialiasing);
paintpen.setCosmetic(true);
paintpen.setWidth(1);
// Draw arc
if (option->state & QStyle::State_Selected)
{
// sets brush for end points
painter->setBrush(Qt::SolidPattern);
paintpen.setColor(Qt::red);
painter->setPen(paintpen);
painter->drawEllipse(p1, 2, 2);
painter->drawEllipse(p2, 2, 2);
painter->drawEllipse(p3, 2, 2);
// sets pen for arc path
paintpen.setStyle(Qt::DashLine);
paintpen.setColor(Qt::black);
painter->setPen(paintpen);
}
else
{
painter->setBrush(Qt::SolidPattern);
paintpen.setColor(Qt::black);
painter->setPen(paintpen);
painter->drawEllipse(p1, 2, 2);
painter->drawEllipse(p2, 2, 2);
painter->drawEllipse(p3, 2, 2);
}
QPainterPath path;
path.arcMoveTo(circle, startAngle);
path.arcTo(circle, startAngle, spanAngle);
painter->setBrush(Qt::NoBrush);
painter->drawPath(path);
}
示例13: paintEvent
void CircularIndicatorMeterWidget::paintEvent(QPaintEvent* paintevent)
{
MeterWidget::paintEvent(paintevent);
m_MainBrush = QBrush(m_MainColor);
m_OutlinePen = QPen(m_OutlineColor);
m_OutlinePen.setWidth(1);
m_OutlinePen.setStyle(Qt::SolidLine);
//painter
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
// define scale and location
painter.translate(m_Width / 2, m_Height / 2);
painter.scale(m_Width / 200.0, m_Height / 200.0);
// Draw circular indicator
// Define coordinates:
static const QPoint CP_pt1(0, -70);
static const QPoint CP_pt2(0, -90);
static const QRectF CP_extRect(-90,-90,180,180);
static const QRectF CP_intRect(-70,-70,140,140);
// rotate painter
painter.save();
painter.rotate(-m_Angle/2);
double CPAngle = qBound((float) -1.0, (Value-m_RangeMin) / (m_RangeMax-m_RangeMin), (float) 1.0) * m_Angle;
QPainterPath CPEmptyPath;
CPEmptyPath.moveTo(CP_pt1);
CPEmptyPath.arcMoveTo(CP_intRect, 90 - CPAngle);
QPainterPath CPIndicatorPath;
CPIndicatorPath.moveTo(CP_pt1);
CPIndicatorPath.lineTo(CP_pt2);
CPIndicatorPath.arcTo(CP_extRect, 90, -1 * CPAngle);
CPIndicatorPath.lineTo(CPEmptyPath.currentPosition());
CPIndicatorPath.arcTo(CP_intRect, 90 - CPAngle, CPAngle);
painter.setBrush(IndicatorGradient);
painter.setPen(Qt::NoPen);
painter.drawPath(CPIndicatorPath);
painter.restore();
}
示例14: visitPath
void ShapePaintVisitor::visitPath(const PathShape *shapePath)
{
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, true);
QPainterPath path;
foreach (const PathShape::Element &element, shapePath->elements()) {
switch (element.m_elementType) {
case PathShape::TypeNone:
// nothing to do
break;
case PathShape::TypeMoveto:
path.moveTo(element.m_position.mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size));
break;
case PathShape::TypeLineto:
path.lineTo(element.m_position.mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size));
break;
case PathShape::TypeArcmoveto:
{
QSizeF radius = element.m_size.mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
path.arcMoveTo(QRectF(element.m_position.mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size) - QPointF(radius.width(), radius.height()),
radius * 2.0),
element.m_angle1);
break;
}
case PathShape::TypeArcto:
{
QSizeF radius = element.m_size.mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
path.arcTo(QRectF(element.m_position.mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size) - QPointF(radius.width(), radius.height()),
radius * 2.0),
element.m_angle1, element.m_angle2);
break;
}
case PathShape::TypeClose:
path.closeSubpath();
break;
}
}
m_painter->drawPath(path);
m_painter->restore();
}
示例15: fabs
//------------------------------------------------------------------------------
void
Canvas::DrawKeyhole(int x, int y,
unsigned inner_r, unsigned outer_r,
Angle start, Angle end)
{
// Make sure that the 'left' angle is first.
QPainterPath path;
path.setFillRule(Qt::WindingFill);
Angle startN = this->normalize(start);
Angle endN = this->normalize(end);
Angle a[4];
a[2] = (startN > endN) ? startN : endN;
a[3] = (startN > endN) ? endN : startN;
a[0] = this->geo2Screen(a[3]);
a[1] = this->geo2Screen(a[2]);
#ifndef NDEBUG
std::cerr << __LINE__ << ": "
<< a[0].Degrees() << ", " << a[1].Degrees() << ", "
<< a[2].Degrees() << ", " << a[3].Degrees() << std::endl;
#endif
// Draw the inner with a segment left out for the cone.
path.arcMoveTo(this->boundingBox(x, y, inner_r), a[0].Degrees());
path.arcTo(this->boundingBox(x, y, inner_r),
a[0].Degrees(), 360.0 - fabs(a[1].Degrees() - a[0].Degrees()));
// The currentPosition() will be at the end of the inner circle. Draw
// one side of the cone.
double xx = (outer_r - inner_r) * cos(a[1].Radians()) +
path.currentPosition().rx();
double yy = (outer_r - inner_r) * -sin(a[1].Radians()) +
path.currentPosition().ry();
path.lineTo(xx, yy);
// Draw the outer arc of the cone.
path.arcTo(this->boundingBox(x, y, outer_r),
a[1].Degrees(), fabs(a[1].Degrees() - a[0].Degrees()));
// This will draw the other side of the cone to finish the keyhole.
path.closeSubpath();
this->pushObject(path, this->pen(), this->brush());
}