本文整理汇总了C++中QPainterPath::setFillRule方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::setFillRule方法的具体用法?C++ QPainterPath::setFillRule怎么用?C++ QPainterPath::setFillRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPath
的用法示例。
在下文中一共展示了QPainterPath::setFillRule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
/**
* \brief Draw the palette
* @param event as the paint event
*/
void UBDockPalette::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush);
if(mOrientation == eUBDockOrientation_Left)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(0.0, 0.0, width()-border(), height());
path.addRoundedRect(width()-2*border(), border(), 2*border(), TABSIZE, radius(), radius());
painter.drawPath(path);
painter.drawPixmap(width() - border() + 1, border() + 1 , border() - 4, TABSIZE - 2, mIcon);
}
else if(mOrientation == eUBDockOrientation_Right)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(border(), 0.0, width()-border(), height());
path.addRoundedRect(0.0, border(), 2*border(), TABSIZE, radius(), radius());
painter.drawPath(path);
painter.drawPixmap(2, border() + 1, border() - 3, TABSIZE - 2, mIcon);
}
else
{
painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius());
}
}
示例2: paintEvent
void DropShadowWidget::paintEvent(QPaintEvent *event)
{
int margins = 10;
if(this->isMaximized()){
margins = 0;
}
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(margins, margins, this->width()-2*margins, this->height()-2*margins);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.fillPath(path, QBrush(Qt::white));
QColor color(0, 0, 0, 50);
for(int i=0; i<margins; i++)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(margins-i, margins-i, this->width()-(margins-i)*2, this->height()-(margins-i)*2);
color.setAlpha(150 - qSqrt(i)*50);
painter.setPen(color);
painter.drawPath(path);
}
}
示例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: drawFace
QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx)
{
std::vector<TechDrawGeometry::Wire *> fWires = f->wires;
QPainterPath facePath;
for(std::vector<TechDrawGeometry::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
QPainterPath wirePath;
for(std::vector<TechDrawGeometry::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
//Save the start Position
QPainterPath edgePath = drawPainterPath(*edge);
// If the current end point matches the shape end point the new edge path needs reversing
QPointF shapePos = (wirePath.currentPosition()- edgePath.currentPosition());
if(sqrt(shapePos.x() * shapePos.x() + shapePos.y()*shapePos.y()) < 0.05) { //magic tolerance
edgePath = edgePath.toReversed();
}
wirePath.connectPath(edgePath);
}
//dumpPath("wirePath:",wirePath);
facePath.addPath(wirePath);
}
facePath.setFillRule(Qt::OddEvenFill);
QGIFace* gFace = new QGIFace(idx);
addToGroup(gFace);
gFace->setPos(0.0,0.0);
gFace->setPath(facePath);
//debug a path
//std::stringstream faceId;
//faceId << "facePath " << idx;
//dumpPath(faceId.str().c_str(),facePath);
return gFace;
}
示例5: paint
void UBGraphicsCache::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->setBrush(mMaskColor);
painter->setPen(mMaskColor);
// Draw the hole
QPainterPath path;
path.addRect(rect());
if(mDrawMask)
{
if(eMaskShape_Circle == mMaskShape)
{
path.addEllipse(mShapePos, mShapeWidth, mShapeWidth);
}
else if(eMaskShap_Rectangle == mMaskShape)
{
path.addRect(mShapePos.x() - mShapeWidth, mShapePos.y() - mShapeWidth, 2*mShapeWidth, 2*mShapeWidth);
}
path.setFillRule(Qt::OddEvenFill);
}
painter->drawPath(path);
}
示例6: drawValue
void QRoundProgressBar::drawValue(QPainter &p, const QRectF &baseRect, double value, double arcLength)
{
// nothing to draw
if (value == m_min)
return;
// for Line style
if (m_barStyle == StyleLine)
{
p.setPen(QPen(palette().highlight().color(), m_dataPenWidth));
p.setBrush(Qt::NoBrush);
p.drawArc(baseRect.adjusted(m_outlinePenWidth/2, m_outlinePenWidth/2, -m_outlinePenWidth/2, -m_outlinePenWidth/2),
m_nullPosition * 16,
-arcLength * 16);
return;
}
// for Pie and Donut styles
QPainterPath dataPath;
dataPath.setFillRule(Qt::WindingFill);
// pie segment outer
dataPath.moveTo(baseRect.center());
dataPath.arcTo(baseRect, m_nullPosition, -arcLength);
dataPath.lineTo(baseRect.center());
p.setBrush(palette().highlight());
p.setPen(QPen(palette().shadow().color(), m_dataPenWidth));
p.drawPath(dataPath);
}
示例7: toQPainterPathPx
QPainterPath BI_Via::toQPainterPathPx(const Length& expansion) const noexcept {
QPainterPath p = getOutline(expansion).toQPainterPathPx();
p.setFillRule(Qt::OddEvenFill); // important to subtract the hole!
p.addEllipse(QPointF(0, 0), mDrillDiameter->toPx() / 2,
mDrillDiameter->toPx() / 2);
return p;
}
示例8: intersects_QRectF_data
void tst_QPainterPath::intersects_QRectF_data()
{
QTest::addColumn<QPainterPath>("path");
QTest::addColumn<QRectF>("rect");
QTest::addColumn<bool>("intersects");
QPainterPath path;
path.addRect(0, 0, 100, 100);
QTest::newRow("same rect") << path << QRectF(0.1, 0.1, 99, 99) << true; // ###
QTest::newRow("outside") << path << QRectF(-1, -1, 100, 100) << true;
QTest::newRow("covers") << path << QRectF(-1, -1, 102, 102) << true;
QTest::newRow("left") << path << QRectF(-10, 50, 5, 5) << false;
QTest::newRow("top") << path << QRectF(50, -10, 5, 5) << false;
QTest::newRow("right") << path << QRectF(110, 50, 5, 5) << false;
QTest::newRow("bottom") << path << QRectF(50, 110, 5, 5) << false;
path.addRect(50, 50, 100, 100);
QTest::newRow("r1 top") << path << QRectF(0.1, 0.1, 99, 49) << true;
QTest::newRow("r1 left") << path << QRectF(0.1, 0.1, 49, 99) << true;
QTest::newRow("r2 right") << path << QRectF(100.01, 50.1, 49, 99) << true;
QTest::newRow("r2 bottom") << path << QRectF(50.1, 100.1, 99, 49) << true;
QTest::newRow("inside 2 rects") << path << QRectF(51, 51, 48, 48) << false;
path.setFillRule(Qt::WindingFill);
QTest::newRow("inside 2 rects (winding)") << path << QRectF(51, 51, 48, 48) << true;
path.addEllipse(0, 0, 150, 150);
QTest::newRow("topRight 2 rects") << path << QRectF(100, 25, 24, 24) << true;
QTest::newRow("bottomLeft 2 rects") << path << QRectF(25, 100, 24, 24) << true;
QTest::newRow("horizontal line") << linePath(0, 0, 10, 0) << QRectF(1, -1, 2, 2) << true;
QTest::newRow("vertical line") << linePath(0, 0, 0, 10) << QRectF(-1, 1, 2, 2) << true;
}
示例9: RefreshGeometry
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolSpline::RefreshGeometry()
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
QPainterPath path;
path.addPath(spl->GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
QPointF splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP1().id())->toQPointF();
QPointF controlPoint = spl->GetP2();
emit RefreshLine(1, SplinePointPosition::FirstPoint, controlPoint, splinePoint);
splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP4().id())->toQPointF();
controlPoint = spl->GetP3();
emit RefreshLine(1, SplinePointPosition::LastPoint, controlPoint, splinePoint);
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
controlPoints[0]->setPos(spl->GetP2());
controlPoints[1]->setPos(spl->GetP3());
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
}
示例10: paintEvent
void TClickableLabel::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
if (m_isEnter) {
painter.save();
QRect r = rect();
double h = r.height();
double h2 = r.height() / 2.0;
QPainterPath path;
path.addRect(r.x() + h2, r.y() + 0, r.width() - h2 * 2, r.height());
path.addEllipse(r.x(), r.y(), h, h);
path.addEllipse(r.x() + r.width() - h, r.y(), h, h);
path.setFillRule(Qt::WindingFill);
painter.setPen(Qt::NoPen);
painter.setBrush( palette().brush(QPalette::Highlight) );
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(path);
painter.restore();
}
QRect r = rect();
r.setX((int) (r.x() + m_text->textWidth())/2);
m_text->drawContents(&painter, r);
painter.end();
QWidget::paintEvent(e);
}
示例11: paintEvent
/**
* \brief Draw the palette
* @param event as the paint event
*/
void UBDockPalette::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush);
QPainterPath path;
path.setFillRule(Qt::WindingFill);
int nbTabs = mTabWidgets.size();
if(0 < nbTabs)
{
// First draw the BIG RECTANGLE (I write it big because the rectangle is big...)
if(mOrientation == eUBDockOrientation_Left)
{
path.addRect(0.0, 0.0, width(), height());
}
else if(mOrientation == eUBDockOrientation_Right)
{
path.addRect(0.0, 0.0, width(), height());
}
painter.drawPath(path);
}
}
示例12: shape
QPainterPath IsometricRenderer::shape(const MapObject *object) const
{
QPainterPath path;
if (!object->cell().isEmpty()) {
path.addRect(boundingRect(object));
} else {
switch (object->shape()) {
case MapObject::Ellipse:
case MapObject::Rectangle:
path.addPolygon(pixelRectToScreenPolygon(object->bounds()));
break;
case MapObject::Polygon:
case MapObject::Polyline: {
const QPointF &pos = object->position();
const QPolygonF polygon = object->polygon().translated(pos);
const QPolygonF screenPolygon = pixelToScreenCoords(polygon);
if (object->shape() == MapObject::Polygon) {
path.addPolygon(screenPolygon);
} else {
for (int i = 1; i < screenPolygon.size(); ++i) {
path.addPolygon(lineToPolygon(screenPolygon[i - 1],
screenPolygon[i]));
}
path.setFillRule(Qt::WindingFill);
}
break;
}
}
}
return path;
}
示例13: paint
void ZLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.moveTo(m_BRect.x(), m_BRect.y());
path.lineTo(m_BRect.x()+m_BRect.width()/2, m_BRect.y());
QRectF rect = m_BRect;
rect.setX(rect.x()+rect.width()/2);
path.arcTo(rect, 90, -180);
path.lineTo(m_BRect.x(), m_BRect.y()+m_BRect.height());
painter->setPen(QPen(Qt::black, 0) );
painter->drawPath(path);
if(option->state & QStyle::State_Selected) {
painter->setPen(Qt::NoPen);
QColor lightGray(192, 192, 192, 128);
painter->setBrush(lightGray);
painter->drawPath(path);
}
else {
painter->setPen(Qt::NoPen);
QColor lightGray(128, 128, 128, 128);
painter->setBrush(lightGray);
painter->drawPath(path);
}
QFont font; font.setPixelSize(18);
painter->setPen(QPen(Qt::black, 0));
painter->setFont(font);
painter->drawText(m_BRect, Qt::AlignCenter, QString::number(m_iZLayer) );
}
示例14:
QPainterPath
rce::gui::RGraphicsFlagItem::
generateFlagPath(const QRectF &flagArea)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.moveTo(0,0);
if((flagArea.width() > 0) &&
(flagArea.height() > 0))
{
QRectF adjustedArea = flagArea.adjusted(-RCE_EMPHASED_LINE_WIDTH,
-RCE_EMPHASED_LINE_WIDTH,
RCE_EMPHASED_LINE_WIDTH,
RCE_EMPHASED_LINE_WIDTH); // TODO: Make this automaticly scale with font size
path.lineTo(adjustedArea.bottomLeft());
path.addRect(adjustedArea);
}
path.moveTo(0,0);
path.addEllipse(QPointF(0,0),
1.0, 1.0);
return path;
}
示例15: painterPath
QPainterPath TextSymbol::painterPath(void)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
QString filename = ctx.loader->absPath("fonts/" + m_font);
FontDataStore* ds = CachedFontParser::parse(filename);
QMatrix mat(m_xsize / ds->xsize(), 0, 0, m_ysize / ds->ysize(), 0, 0);
for (int i = 0; i < m_text.length(); ++i) {
CharRecord* rec = ds->charRecord(m_text[i].toAscii());
if (rec) {
QPainterPath p = mat.map(rec->painterPath(m_width_factor));
path.addPath(p);
}
mat.translate(ds->xsize() + ds->offset(), 0);
}
QRectF b = path.boundingRect();
QMatrix mat2;
mat2.translate(-b.x(), -(b.y() + b.height()));
path = mat2.map(path);
return path;
}