本文整理汇总了C++中QPainterPath::closeSubpath方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::closeSubpath方法的具体用法?C++ QPainterPath::closeSubpath怎么用?C++ QPainterPath::closeSubpath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPath
的用法示例。
在下文中一共展示了QPainterPath::closeSubpath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updatePath
void PolygonObject::updatePath(const QPainterPath& p)
{
normalPath = p;
QPainterPath closedPath = normalPath;
closedPath.closeSubpath();
QPainterPath reversePath = closedPath.toReversed();
reversePath.connectPath(closedPath);
setObjectPath(reversePath);
}
示例2: needleShape
QPainterPath UBGraphicsCompass::needleShape() const
{
QPainterPath path;
path.moveTo(rect().left(), rect().center().y());
path.lineTo(rect().left() + sNeedleLength, rect().center().y() - 2);
path.lineTo(rect().left() + sNeedleLength, rect().center().y() + 2);
path.closeSubpath();
return path;
}
示例3: 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);
}
示例4: objectSavePath
QPainterPath PolygonObject::objectSavePath() const
{
QPainterPath closedPath = normalPath;
closedPath.closeSubpath();
qreal s = scale();
QTransform trans;
trans.rotate(rotation());
trans.scale(s,s);
return trans.map(closedPath);
}
示例5: paintBackground
void UIGDetailsElement::paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
{
/* Save painter: */
pPainter->save();
/* Prepare variables: */
int iMargin = data(ElementData_Margin).toInt();
int iHeaderHeight = 2 * iMargin + m_iMinimumHeaderHeight;
QRect optionRect = pOption->rect;
QRect fullRect = !m_fAnimationRunning ? optionRect :
QRect(optionRect.topLeft(), QSize(optionRect.width(), iHeaderHeight + m_iAdditionalHeight));
int iFullHeight = fullRect.height();
/* Prepare color: */
QPalette pal = palette();
QColor headerColor = pal.color(QPalette::Active, QPalette::Button);
QColor strokeColor = pal.color(QPalette::Active, QPalette::Mid);
QColor bodyColor = pal.color(QPalette::Active, QPalette::Base);
/* Add clipping: */
QPainterPath path;
path.moveTo(m_iCornerRadius, 0);
path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, 0), 90, 90);
path.lineTo(path.currentPosition().x(), iFullHeight - m_iCornerRadius);
path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(0, -m_iCornerRadius), 180, 90);
path.lineTo(fullRect.width() - m_iCornerRadius, path.currentPosition().y());
path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, -2 * m_iCornerRadius), 270, 90);
path.lineTo(path.currentPosition().x(), m_iCornerRadius);
path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-2 * m_iCornerRadius, -m_iCornerRadius), 0, 90);
path.closeSubpath();
pPainter->setClipPath(path);
/* Calculate top rectangle: */
QRect tRect = fullRect;
tRect.setBottom(tRect.top() + iHeaderHeight);
/* Calculate bottom rectangle: */
QRect bRect = fullRect;
bRect.setTop(tRect.bottom());
/* Prepare top gradient: */
QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft());
tGradient.setColorAt(0, headerColor.darker(110));
tGradient.setColorAt(1, headerColor.darker(animationDarkness()));
/* Paint all the stuff: */
pPainter->fillRect(tRect, tGradient);
pPainter->fillRect(bRect, bodyColor);
/* Stroke path: */
pPainter->setClipping(false);
pPainter->strokePath(path, strokeColor);
/* Restore painter: */
pPainter->restore();
}
示例6:
QPainterPath Paths::triangle2()
{
QPainterPath path;
path.moveTo(0, 120);
path.lineTo(60, 120);
path.lineTo(60, 60);
path.closeSubpath();
return path;
}
示例7: visitTriangle
void ShapeSizeVisitor::visitTriangle(const TriangleShape *shapeTriangle)
{
QPainterPath path;
QPointF center = shapeTriangle->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
QSizeF size = shapeTriangle->size().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
path.moveTo(center + QPointF(size.width() / 2.0, size.height() / 2.0));
path.lineTo(center + QPointF(-size.width() / 2.0, size.height() / 2.0));
path.lineTo(center + QPointF(0.0, -size.height() / 2.0));
path.closeSubpath();
m_boundingRect |= path.boundingRect();
}
示例8: draw
void Stem::draw(QPainter* painter) const
{
Staff* st = staff();
bool useTab = st && st->isTabStaff();
if (useTab && st->staffType()->slashStyle())
return;
qreal lw = lineWidth();
painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
painter->drawLine(line);
if (!useTab)
return;
// TODO: adjust bounding rectangle in layout() for dots and for slash
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType());
qreal sp = spatium();
// slashed half note stem
if (chord() && chord()->durationType().type() == TDuration::V_HALF
&& stt->minimStyle() == TAB_MINIM_SLASHED) {
qreal wdt = sp * STAFFTYPE_TAB_SLASH_WIDTH;
qreal sln = sp * STAFFTYPE_TAB_SLASH_SLANTY;
qreal thk = sp * STAFFTYPE_TAB_SLASH_THICK;
qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL;
QPainterPath path;
qreal y = stt->stemsDown() ?
_len - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp :
-_len + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp;
for (int i = 0; i < 2; ++i) {
path.moveTo( wdt*0.5-lw, y); // top-right corner
path.lineTo( wdt*0.5-lw, y+thk); // bottom-right corner
path.lineTo(-wdt*0.5, y+thk+sln);// bottom-left corner
path.lineTo(-wdt*0.5, y+sln); // top-left corner
path.closeSubpath();
y += displ;
}
// setbbox(path.boundingRect());
painter->setBrush(QBrush(curColor()));
painter->setPen(Qt::NoPen);
painter->drawPath(path);
}
// dots
// NOT THE BEST PLACE FOR THIS?
// with tablatures, dots are not drawn near 'notes', but near stems
int nDots = chord()->dots();
if (nDots > 0) {
qreal y = stemLen() - (stt->stemsDown() ?
(STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 );
symbols[score()->symIdx()][dotSym].draw(painter, magS(),
QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots);
}
}
示例9: singleShape
// w=width, h=height, indent=degree of indentation of pertubring glyph sides
QPainterPath PerturbingEPN::singleShape(int w, int h, int indent) const
{
QPainterPath p;
p.moveTo( -w/2, -h/2 );
p.lineTo( -w/2+indent, 0);
p.lineTo( -w/2, h/2);
p.lineTo( w/2, h/2 );
p.lineTo( w/2-indent, 0 );
p.lineTo( w/2, -h/2 );
p.closeSubpath();
return p;
}
示例10: pencilShape
QPainterPath UBGraphicsCompass::pencilShape() const
{
int penWidthIndex = UBSettings::settings()->penWidthIndex();
int logicalCompassPencilWidth = penWidthIndex > 1 ? 8 : (penWidthIndex > 0 ? 4 : 2);
QPainterPath path;
path.moveTo(rect().right() - sPencilLength, rect().center().y() - logicalCompassPencilWidth / 2);
path.lineTo(rect().right() - logicalCompassPencilWidth / 2, rect().center().y() - logicalCompassPencilWidth / 2);
QRectF tipRect(rect().right() - logicalCompassPencilWidth, rect().center().y() - logicalCompassPencilWidth / 2, logicalCompassPencilWidth, logicalCompassPencilWidth);
path.arcTo(tipRect, 90, -180);
path.lineTo(rect().right() - sPencilLength, rect().center().y() + logicalCompassPencilWidth / 2);
path.closeSubpath();
return path;
}
示例11: painterPath
QPainterPath HalfOvalSymbol::painterPath(void)
{
QPainterPath path;
if (m_w > m_h) {
qreal rad = m_h / 2;
path.moveTo(rad, -rad);
path.arcTo(0, -m_h/2, m_h, m_h, 90, -180);
path.lineTo(m_h - m_w, m_h/2);
path.lineTo(m_h - m_w, -m_h/2);
path.closeSubpath();
} else {
qreal rad = m_w / 2;
path.moveTo(rad, -rad);
path.arcTo(-m_w/2, -m_w, m_w, m_w, 0, 180);
path.lineTo(-m_w/2, m_h - m_w);
path.lineTo(m_w/2, m_h - m_w);
path.closeSubpath();
}
return path;
}
示例12: shapeInternal
QPainterPath QSysMLAction::shapeInternal() const
{
QPainterPath p;
if (property("actionType") == "default"){
p.addRoundedRect(0, 50, geometry().width(), geometry().height() - 100, 40, 40);
} else if (property("actionType") == "event"){
p.moveTo(0, 50);
p.lineTo(geometry().width(), 50);
p.lineTo(geometry().width(), geometry().height() - 50);
p.lineTo(0, geometry().height() - 50);
p.lineTo((geometry().height() - 100) / 2, geometry().height() / 2);
p.closeSubpath();
} else if (property("actionType") == "sendSignal"){
p.moveTo(0, 50);
p.lineTo(geometry().width() - (geometry().height() - 100) / 2, 50);
p.lineTo(geometry().width(), geometry().height() / 2);
p.lineTo(geometry().width() - (geometry().height() - 100) / 2, geometry().height() - 50);
p.lineTo(0, geometry().height() - 50);
p.closeSubpath();
}
return p;
}
示例13: painterPath
QPainterPath TriangleSymbol::painterPath(void)
{
QPainterPath path;
//The co-ordinates of y needs to be flipped
//due to it is screen co-ordination ( increase from top to down )
path.moveTo(0, - m_h / 2);
path.lineTo(- m_base / 2, m_h / 2);
path.lineTo(m_base / 2, m_h / 2);
path.closeSubpath();
return path;
}
示例14: painter
void Smb4KToolTip::paintEvent(QPaintEvent *e)
{
// Copied from Dolphin's meta data tool tips.
Q_UNUSED(e);
QPainter painter(this);
QColor toColor = palette().brush(QPalette::ToolTipBase).color();
QColor fromColor = KColorScheme::shade(toColor, KColorScheme::LightShade, 0.2);
const bool haveAlphaChannel = KWindowSystem::compositingActive();
if (haveAlphaChannel)
{
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(0.5, 0.5);
toColor.setAlpha(220);
fromColor.setAlpha(220);
}
else
{
// Do nothing
}
QLinearGradient gradient(QPointF(0.0, 0.0), QPointF(0.0, height()));
gradient.setColorAt(0.0, fromColor);
gradient.setColorAt(1.0, toColor);
painter.setPen(Qt::NoPen);
painter.setBrush(gradient);
const QRect rect(0, 0, width(), height());
if (haveAlphaChannel)
{
const qreal radius = 5.0;
QPainterPath path;
path.moveTo(rect.left(), rect.top() + radius);
arc(path, rect.left() + radius, rect.top() + radius, radius, 180, -90);
arc(path, rect.right() - radius, rect.top() + radius, radius, 90, -90);
arc(path, rect.right() - radius, rect.bottom() - radius, radius, 0, -90);
arc(path, rect.left() + radius, rect.bottom() - radius, radius, 270, -90);
path.closeSubpath();
painter.drawPath(path);
}
else
{
painter.drawRect(rect);
}
}
示例15: rebuildShape
void UIMiniToolBar::rebuildShape()
{
#ifdef VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR
/* Rebuild shape: */
QPainterPath shape;
switch (m_alignment)
{
case Qt::AlignTop:
{
shape.moveTo(0, 0);
shape.lineTo(shape.currentPosition().x(), height() - 10);
shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(0, -10), 180, 90);
shape.lineTo(width() - 10, shape.currentPosition().y());
shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(-10, -20), 270, 90);
shape.lineTo(shape.currentPosition().x(), 0);
shape.closeSubpath();
break;
}
case Qt::AlignBottom:
{
shape.moveTo(0, height());
shape.lineTo(shape.currentPosition().x(), 10);
shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(0, -10), 180, -90);
shape.lineTo(width() - 10, shape.currentPosition().y());
shape.arcTo(QRectF(shape.currentPosition(), QSizeF(20, 20)).translated(-10, 0), 90, -90);
shape.lineTo(shape.currentPosition().x(), height());
shape.closeSubpath();
break;
}
default:
break;
}
m_shape = shape;
/* Update: */
update();
#endif /* VBOX_RUNTIME_UI_WITH_SHAPED_MINI_TOOLBAR */
}