本文整理汇总了C++中QPainterPath::quadTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::quadTo方法的具体用法?C++ QPainterPath::quadTo怎么用?C++ QPainterPath::quadTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPath
的用法示例。
在下文中一共展示了QPainterPath::quadTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawLineHead
/**
* Paint arrow
*/
void drawLineHead (QPainter * painter, QPointF end, double angle, double size, bool figure)
{
QPointF lineP1 = end + QPointF( sin( angle + Pi / 3) * size, cos( angle + Pi / 3) * size);
QPointF lineP2 = end + QPointF( sin( angle + Pi - Pi / 3) * size, cos( angle + Pi - Pi / 3) * size);
QPointF centre = (lineP1 + lineP2 + end)/3;
if (figure)
{
QPainterPath arrow;
arrow.moveTo (end);
arrow.quadTo (centre, lineP1);
arrow.lineTo (lineP2);
arrow.quadTo (centre, end);
painter->drawPath (arrow);
}
else
{
QPolygonF lineHead;
lineHead.clear();
lineHead << end << lineP1 << lineP2;
painter->drawPolygon (lineHead);
}
}
示例2: paintPriorityHeader
void TaskItemDelegate::paintPriorityHeader(QPainter* painter, const QRectF& rect, const QModelIndex &index) const
{
painter->save();
//Draw colored gradient as priority background
QLinearGradient gradient(rect.topLeft(), rect.bottomRight());
gradient.setColorAt(0, itemPriorityColor(index));
gradient.setColorAt(1, Qt::transparent);
int h = QApplication::fontMetrics().height();
QPainterPath path;
path.moveTo(rect.bottomLeft());
path.quadTo(rect.bottomLeft()+QPointF(0, -h), rect.bottomLeft()+QPointF(2, -h));
path.lineTo(rect.bottomRight()-QPointF(2, h));
path.quadTo(rect.bottomRight()+QPointF(0, -h), rect.bottomRight());
painter->setBrush(Qt::NoBrush);
QPen thickPen(itemPriorityColor(index));
thickPen.setWidth(2);
painter->setPen(thickPen);
painter->drawPath(path);
// Draw priority text
QString priority = index.data(Qt::DisplayRole).toString();
painter->setPen(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
painter->setBrush(Qt::NoBrush);
painter->drawText(rect.bottomLeft()+QPoint(MARGIN, -2*MARGIN) ,priority);
painter->restore();
}
示例3: adjustX
QPainterPath
TriggerPoint::shape() const
{
QPainterPath path;
float line = BasicBox::LINE_WIDTH / 2;
QPointF adjustX(-line, 0);
QPointF adjustY(0, -line);
QRectF rect = boundingRect();
switch (_abstract->boxExtremity()) {
case BOX_START:
path.moveTo(rect.topLeft() + adjustX);
path.lineTo(rect.bottomLeft() + adjustX + adjustY);
path.lineTo(rect.bottomRight() + adjustY);
path.lineTo(rect.bottomRight() + adjustY - QPointF(0, rect.height() / 5.));
path.quadTo(rect.topRight(), rect.topLeft() + adjustX);
break;
case BOX_END:
path.moveTo(rect.topRight());
path.lineTo(rect.bottomRight() + adjustY);
path.lineTo(rect.bottomLeft() + adjustY);
path.lineTo(rect.bottomLeft() + adjustY - QPointF(0, rect.height() / 5.));
path.quadTo(rect.topLeft(), rect.topRight());
break;
default:
break;
}
return path;
}
示例4: paintEdges
void EditorArea::paintEdges(QPainter &painter)
{
bool firstTime = true;
QVector<int> edgesIds = workspace->getEdgesIds();
for (int i=0; i < edgesIds.size(); i++) {
QPoint nodesOfEdge = workspace->getNodesOfEdge(edgesIds[i]);
QPointF screenXYFirst = graph2screen(workspace->getNodePosition(nodesOfEdge.x()));
QPointF screenXYSecond = graph2screen(workspace->getNodePosition(nodesOfEdge.y()));
QPointF screenMidPoint = graph2screen(workspace->getThirdPointPos(edgesIds[i]));
QPainterPath path;
path.moveTo(screenXYFirst);
path.quadTo(screenMidPoint, screenXYSecond);
path.quadTo(screenMidPoint, screenXYFirst);
painter.drawPath(path);
QVector<QPointF> pointsOnBezier;
QVector<float> sOnEdge;
for (int k = 0; k < edgeDiscretization + 1; k++) {
float t = float(k) / edgeDiscretization;
QPointF coord = (1 - t) * (1 - t) * screenXYFirst + 2 * (1 - t) * t * screenMidPoint + t * t * screenXYSecond;
pointsOnBezier << coord;
}
for (int k = 0; k < pointsOnBezier.size(); k++) {
if (k == 0) {
sOnEdge << 0.0;
} else {
float sJesima = workspace->distance(pointsOnBezier[k], pointsOnBezier[k - 1]);
sOnEdge << sJesima;
}
}
for (int k = 1; k < pointsOnBezier.size(); k++) {
sOnEdge[k] = sOnEdge[k] + sOnEdge[k - 1];
}
float length = sOnEdge.last();
for (int k = 0; k < sOnEdge.size(); k++) {
sOnEdge[k] = sOnEdge[k] / length;
}
sOnBezier.insert(edgesIds[i], sOnEdge);
if (path.intersects(QRectF(mouseCurrentPos.x() - 7, mouseCurrentPos.y() - 7, 14, 14))) {
if (firstTime) {
firstTime = false;
hitElements.clear();
}
QPoint temp(2, edgesIds[i]);
hitElements.append(temp);
}
}
}
示例5: standardPadding
void
CurrentTrack::drawStatsBackground( QPainter *const p, const QRect &rect )
{
// draw the complete outline. lots of little steps :) at each corner, leave
// a 6x6 box. draw a quad bezier curve from the two ends of the lines,
// through the original corner
const qreal leftEdge = m_ratingWidget->boundingRect().right() + standardPadding();
const qreal rightEdge = rect.right() - standardPadding() / 2;
const qreal ratingWidgetX = m_ratingWidget->pos().x();
const qreal ratingWidgetY = m_ratingWidget->pos().y();
const qreal ratingWidgetH = m_ratingWidget->boundingRect().height();
QColor topColor = The::paletteHandler()->palette().color( QPalette::Base );
QColor bottomColor = topColor;
topColor.setAlpha( 200 );
bottomColor.setAlpha( 100 );
QPainterPath statsPath;
statsPath.moveTo( leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 ); // top left position of the rect, right below the album
statsPath.lineTo( rightEdge - 6, ratingWidgetY - ratingWidgetH + 8 ); // go right to margin
statsPath.quadTo( rightEdge, ratingWidgetY - ratingWidgetH + 8,
rightEdge, ratingWidgetY - ratingWidgetH + 8 + 6 );
statsPath.lineTo( rightEdge, ratingWidgetY + ratingWidgetH - 6 ); // go down to bottom right corner
statsPath.quadTo( rightEdge, ratingWidgetY + ratingWidgetH,
rightEdge - 6, ratingWidgetY + ratingWidgetH );
statsPath.lineTo( ratingWidgetX + 6, ratingWidgetY + ratingWidgetH ); // way bottom left corner
statsPath.quadTo( ratingWidgetX, ratingWidgetY + ratingWidgetH,
ratingWidgetX, ratingWidgetY + ratingWidgetH - 6 );
statsPath.lineTo( ratingWidgetX, ratingWidgetY + 6 ); // top left of rating widget
statsPath.quadTo( ratingWidgetX, ratingWidgetY,
ratingWidgetX + 6, ratingWidgetY );
statsPath.lineTo( leftEdge - 6, ratingWidgetY ); // joining of two rects
statsPath.quadTo( leftEdge, ratingWidgetY,
leftEdge, ratingWidgetY - 6 );
statsPath.lineTo( leftEdge, ratingWidgetY - ratingWidgetH + 8 + 6 ); // back to start
statsPath.quadTo( leftEdge, ratingWidgetY - ratingWidgetH + 8,
leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 );
// draw just the overlay which is the "header" row, to emphasize that we have 2 rows here
QPainterPath headerPath;
headerPath.moveTo( leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 ); // top left position of the rect, right below the album
headerPath.lineTo( rightEdge - 6, ratingWidgetY - ratingWidgetH + 8 ); // go right to margin
headerPath.quadTo( rightEdge, ratingWidgetY - ratingWidgetH + 8,
rightEdge, ratingWidgetY - ratingWidgetH + 8 + 6 );
headerPath.lineTo( rightEdge, ratingWidgetY ); // middle of the right side
headerPath.lineTo( leftEdge - 6, ratingWidgetY ); // join spot, before quad curve
headerPath.quadTo( leftEdge, ratingWidgetY,
leftEdge, ratingWidgetY - 6 );
headerPath.lineTo( leftEdge, ratingWidgetY - ratingWidgetH + 8 + 6 ); // curve back through start
headerPath.quadTo( leftEdge, ratingWidgetY - ratingWidgetH + 8,
leftEdge + 6, ratingWidgetY - ratingWidgetH + 8 );
p->save();
p->setRenderHint( QPainter::Antialiasing );
p->fillPath( statsPath, bottomColor );
p->fillPath( headerPath, topColor );
p->restore();
}
示例6: createBezierCurve
/**
* Returns a Bézier path from given points.
* @param points points which define the Bézier curve
* @return cubic Bézier spline
*/
QPainterPath AssociationLine::createBezierCurve(QVector<QPointF> points)
{
QPainterPath path;
if (points.size() > 3) { // cubic Bezier curve(s)
path.moveTo(points.at(0));
int i = 1;
while (i + 2 < points.size()) {
path.cubicTo(points.at(i), points.at(i+1), points.at(i+2));
i += 3;
}
while (i < points.size()) { // draw a line if points are not modulo 3
path.lineTo(points.at(i));
++i;
}
}
else {
if (points.size() == 3) { // quadratic Bezier curve
path.moveTo(points.at(0));
path.quadTo(points.at(1), points.at(2));
}
else { // should not be reached
QPolygonF polygon(points);
path.addPolygon(polygon);
}
}
return path;
}
示例7: if
void Kompton::Particle::rebuildRepresentation() {
//prepare a new path
QPainterPath path;
path.moveTo(m_line.p1());
//draw on the path according to the style
if (m_style == Kompton::PlainStyle) {
path.lineTo(m_line.p2());
}
else if (m_style == Kompton::WigglyStyle) {
const QPointF start = m_line.p1();
const QPointF diff = m_line.p2() - start;
//some constants of the representation
static const qreal amplitude = 10.0; //maximum wave elongation
static const qreal wavelength = 20.0;
//parameters for this wave
const qreal waveCount = floor(sqrt(diff.x() * diff.x() + diff.y() * diff.y()) / wavelength);
const QPointF waveDiff = diff / waveCount;
const qreal slope = atan2(diff.y(), diff.x());
const QPointF waveElongationVector(amplitude * -sin(slope), amplitude * cos(slope));
//draw waves
for (qreal i = 0.0; i < waveCount; ++i) {
path.quadTo(start + waveDiff * (i + 0.25) + waveElongationVector, start + waveDiff * (i + 0.5));
path.quadTo(start + waveDiff * (i + 0.75) - waveElongationVector, start + waveDiff * (i + 1.0));
}
}
//make new path active
setPath(path);
}
示例8: add_to
void Quad_Curve::add_to(bool move, QPainterPath &ppth) const
{
if ( move )
ppth.moveTo(begin);
ppth.quadTo(control,end);
}
示例9: paintHighlightingEdge
void EditorArea::paintHighlightingEdge(QPainter& painter)
{
QMap<QString, int> supportEdges(workspace->getSupportEdges());
QPoint nodesOfEdge = workspace->getNodesOfEdge(supportEdges.value("highlightingEdge"));
QPointF screenXYFirst = graph2screen(workspace->getNodePosition(nodesOfEdge.x()));
QPointF screenXYSecond = graph2screen(workspace->getNodePosition(nodesOfEdge.y()));
QPointF screenMidPoint = graph2screen(workspace->getThirdPointPos(supportEdges.value("highlightingEdge")));
QPainterPath path;
path.moveTo(screenXYFirst);
path.quadTo(screenMidPoint, screenXYSecond);
path.quadTo(screenMidPoint, screenXYFirst);
path.closeSubpath();
painter.drawPath(path);
}
示例10: QPoint
void
drawRoundedButton( QPainter* painter, const QRect& btnRect, const QColor& color, const QColor &gradient1bottom, const QColor& gradient2top, const QColor& gradient2bottom )
{
QPainterPath btnPath;
const int radius = 3;
// draw top half gradient
const int btnCenter = btnRect.bottom() - ( btnRect.height() / 2 );
btnPath.moveTo( btnRect.left(), btnCenter );
btnPath.lineTo( btnRect.left(), btnRect.top() + radius );
btnPath.quadTo( QPoint( btnRect.topLeft() ), QPoint( btnRect.left() + radius, btnRect.top() ) );
btnPath.lineTo( btnRect.right() - radius, btnRect.top() );
btnPath.quadTo( QPoint( btnRect.topRight() ), QPoint( btnRect.right(), btnRect.top() + radius ) );
btnPath.lineTo( btnRect.right(),btnCenter );
btnPath.lineTo( btnRect.left(), btnCenter );
QLinearGradient g;
if ( gradient1bottom.isValid() )
{
g.setColorAt( 0, color );
g.setColorAt( 0.5, gradient1bottom );
painter->fillPath( btnPath, g );
}
else
painter->fillPath( btnPath, color );
//painter->setPen( bg.darker() );
//painter->drawPath( btnPath );
btnPath = QPainterPath();
btnPath.moveTo( btnRect.left(), btnCenter );
btnPath.lineTo( btnRect.left(), btnRect.bottom() - radius );
btnPath.quadTo( QPoint( btnRect.bottomLeft() ), QPoint( btnRect.left() + radius, btnRect.bottom() ) );
btnPath.lineTo( btnRect.right() - radius, btnRect.bottom() );
btnPath.quadTo( QPoint( btnRect.bottomRight() ), QPoint( btnRect.right(), btnRect.bottom() - radius ) );
btnPath.lineTo( btnRect.right(), btnCenter );
btnPath.lineTo( btnRect.left(), btnCenter );
if ( gradient2top.isValid() && gradient2bottom.isValid() )
{
g.setColorAt( 0, gradient2top );
g.setColorAt( 0.5, gradient2bottom );
painter->fillPath( btnPath, g );
}
else
painter->fillPath( btnPath, color );
}
示例11:
void EditorArea::paintSupportEdges4selecting(QPainter& painter)
{
QVector<int> supportEdges4selecting(workspace->getSupportEdges4selecting());
for (int i = 0; i < supportEdges4selecting.size(); i++) {
QPoint nodesOfEdge = workspace->getNodesOfEdge(supportEdges4selecting[i]);
QPointF screenXYFirst = graph2screen(workspace->getNodePosition(nodesOfEdge.x()));
QPointF screenXYSecond = graph2screen(workspace->getNodePosition(nodesOfEdge.y()));
QPointF screenMidPoint = graph2screen(workspace->getThirdPointPos(supportEdges4selecting[i]));
QPainterPath path;
path.moveTo(screenXYFirst);
path.quadTo(screenMidPoint, screenXYSecond);
path.quadTo(screenMidPoint, screenXYFirst);
painter.drawPath(path);
}
}
示例12: dialogPath
QPainterPath dialogPath( const QRect & rct , int padding ) const
{
QPainterPath path;
path.setFillRule( Qt::WindingFill );
path.moveTo( rct.width()/2 , padding );
path.lineTo( rct.width()-padding-ROUNDED_PIXEL , padding );
path.quadTo( rct.width()-padding , padding , rct.width()-padding , padding+ROUNDED_PIXEL );
path.lineTo( rct.width()-padding , rct.height()-padding-ROUNDED_PIXEL );
path.quadTo( rct.width()-padding , rct.height()-padding , rct.width()-padding-ROUNDED_PIXEL , rct.height()-padding );
path.lineTo( padding+ROUNDED_PIXEL , rct.height()-padding );
path.quadTo( padding , rct.height()-padding , padding , rct.height()-padding-ROUNDED_PIXEL );
path.lineTo( padding , padding+ROUNDED_PIXEL );
path.quadTo( padding , padding , padding+ROUNDED_PIXEL , padding );
path.lineTo( rct.width()/2 , padding );
return path;
}
示例13: drawChecker
void StylePainterMobile::drawChecker(QPainter* painter, const QRect& rect, const QColor& color) const
{
painter->setRenderHint(QPainter::Antialiasing, true);
QPen pen(Qt::darkGray);
pen.setCosmetic(true);
painter->setPen(pen);
painter->scale(rect.width(), rect.height());
QPainterPath path;
path.moveTo(0.18, 0.47);
path.lineTo(0.25, 0.4);
path.lineTo(0.4, 0.55);
path.quadTo(0.64, 0.29, 0.78, 0.2);
path.lineTo(0.8, 0.25);
path.quadTo(0.53, 0.55, 0.45, 0.75);
path.closeSubpath();
painter->setBrush(color);
painter->drawPath(path);
}
示例14: pq
void
CQGroupBox::
drawArcShape(QPainter *painter, double xc, double yc, double r, double startAngle, int sides) const
{
auto Deg2Rad = [](double d) -> double { return M_PI*d/180.0; };
//auto Rad2Deg = [](double r) -> double { return 180.0*r/M_PI; };
double x1 = xc - r;
double y1 = yc - r;
double x2 = xc + r;
double y2 = yc + r;
double xm = (x1 + x2)/2;
double ym = (y1 + y2)/2;
double da = 360.0/sides;
double dc = 360.0/40;
QPainterPath path;
for (int i = 0; i < sides; ++i) {
double angle = startAngle + i*da;
double a1 = Deg2Rad(angle - dc);
double a2 = Deg2Rad(angle + dc);
double c1 = cos(a1), s1 = sin(a1);
double c2 = cos(a2), s2 = sin(a2);
QPointF p1(xm + r*c1, ym + r*s1);
QPointF p2(xm + r*c2, ym + r*s2);
if (i == 0)
path.moveTo(p1);
else
path.lineTo(p1);
//---
QPointF p12 = (p1 + p2)/2;
double ar = 2*hypot(p1.x() - p12.x(), p1.y() - p12.y())/sides;
double a = Deg2Rad(angle);
double c = cos(a), s = sin(a);
QPointF pq(xm + (r + ar)*c, ym + (r + ar)*s);
path.quadTo(pq, p2);
}
path.closeSubpath();
painter->drawPath(path);
}
示例15: strokeToPainterPath
QPainterPath strokeToPainterPath(TStroke *stroke) {
QPainterPath path;
int i, chunkSize = stroke->getChunkCount();
for (i = 0; i < chunkSize; i++) {
const TThickQuadratic *q = stroke->getChunk(i);
if (i == 0) path.moveTo(toQPointF(q->getThickP0()));
path.quadTo(toQPointF(q->getThickP1()), toQPointF(q->getThickP2()));
}
return path;
}