当前位置: 首页>>代码示例>>C++>>正文


C++ QBrush::setTransform方法代码示例

本文整理汇总了C++中QBrush::setTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ QBrush::setTransform方法的具体用法?C++ QBrush::setTransform怎么用?C++ QBrush::setTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QBrush的用法示例。


在下文中一共展示了QBrush::setTransform方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: applyStrokeStyle

void SvgParser::applyStrokeStyle(KoShape *shape)
{
    SvgGraphicsContext *gc = m_context.currentGC();
    if (! gc)
        return;

    if (gc->strokeType == SvgGraphicsContext::None) {
        shape->setStroke(0);
    } else if (gc->strokeType == SvgGraphicsContext::Solid) {
        double lineWidth = gc->stroke.lineWidth();
        QVector<qreal> dashes = gc->stroke.lineDashes();

        KoShapeStroke *stroke = new KoShapeStroke(gc->stroke);

        // apply line width to dashes and dash offset
        if (dashes.count() && lineWidth > 0.0) {
            QVector<qreal> dashes = stroke->lineDashes();
            for (int i = 0; i < dashes.count(); ++i)
                dashes[i] /= lineWidth;
            double dashOffset = stroke->dashOffset();
            stroke->setLineStyle(Qt::CustomDashLine, dashes);
            stroke->setDashOffset(dashOffset / lineWidth);
        } else {
            stroke->setLineStyle(Qt::SolidLine, QVector<qreal>());
        }
        shape->setStroke(stroke);
    } else if (gc->strokeType == SvgGraphicsContext::Complex) {
        // try to find referenced gradient
        SvgGradientHelper *gradient = findGradient(gc->strokeId);
        if (gradient) {
            // great, we have a gradient stroke
            QBrush brush;
            if (gradient->gradientUnits() == SvgGradientHelper::ObjectBoundingBox) {
                brush = *gradient->gradient();
                brush.setTransform(gradient->transform());
            } else {
                QGradient *convertedGradient(SvgGradientHelper::convertGradient(gradient->gradient(), shape->size()));
                brush = *convertedGradient;
                delete convertedGradient;
                brush.setTransform(gradient->transform() * gc->matrix * shape->transformation().inverted());
            }
            KoShapeStroke *stroke = new KoShapeStroke(gc->stroke);
            stroke->setLineBrush(brush);
            stroke->setLineStyle(Qt::SolidLine, QVector<qreal>());
            shape->setStroke(stroke);
        } else {
            // no referenced stroke found, use fallback color
            KoShapeStroke *stroke = new KoShapeStroke(gc->stroke);
            stroke->setLineStyle(Qt::SolidLine, QVector<qreal>());
            shape->setStroke(stroke);
        }
    }
}
开发者ID:loveq369,项目名称:calligra,代码行数:53,代码来源:SvgParser.cpp

示例2: drawPixelWasteDecoration

void TextureViewWidget::drawPixelWasteDecoration(QPainter *p) const
{
    //Draw Warning if more than 30% or 1KB are wasted
    const auto hasTextureWasteProblem =
        (m_pixelWasteInPercent > transparencyWasteLimitInPercent ||
         m_pixelWasteInBytes > transparencyWasteLimitInBytes);
    if (!hasTextureWasteProblem)
        return;

    p->save();
    auto scaleTransform = QTransform::fromScale(zoom(), zoom());
    p->setTransform(scaleTransform, true);

    //Draw Wasted Area
    QPen pen(Qt::red);
    pen.setCosmetic(true);
    p->setPen(pen);
    QBrush brush = QBrush(Qt::red, Qt::FDiagPattern);
    brush.setTransform(scaleTransform.inverted());
    p->setBrush(brush);
    auto outerRect = m_analyzedRect;
    auto wasteArea = QPainterPath();
    wasteArea.addRect(outerRect);
    auto innerRect = QPainterPath();
    auto translatedBoundingRect = m_opaqueBoundingRect.translated(m_analyzedRect.topLeft());
    innerRect.addRect(translatedBoundingRect);
    wasteArea = wasteArea.subtracted(innerRect);
    p->drawPath(wasteArea);
    p->restore();
}
开发者ID:iamsergio,项目名称:GammaRay,代码行数:30,代码来源:textureviewwidget.cpp

示例3: layerToPenBrush

void EDATool::layerToPenBrush(int layer, QPen &pen, QBrush &brush) {
	struct LayerDefinition {
		LayerDefinition(QString s, QColor c, Qt::BrushStyle bs){
			this->name = s;
			this->color = c;
			this->brushStyle = bs;
		}

		QString name;
		QColor color;
		enum Qt::BrushStyle brushStyle;
		int zorder;
	};
	LayerDefinition *ld[52];

	ld[0] = new LayerDefinition("Undefined", QColor(0,0,0,255), Qt::CrossPattern);
	ld[1] = new LayerDefinition("Top", QColor(255,0,0,127), Qt::SolidPattern);
	ld[16] = new LayerDefinition("Bottom", QColor(0,0,255,127), Qt::SolidPattern);
	ld[21] = new LayerDefinition("tPlace", QColor(255,255,255,127), Qt::SolidPattern);
	ld[29] = new LayerDefinition("tStop", QColor(0,255,0,127), Qt::BDiagPattern);
	ld[31] = new LayerDefinition("tCream", QColor(255,255,255,127), Qt::BDiagPattern);
	ld[51] = new LayerDefinition("tDocu", QColor(200,200,200,127), Qt::SolidPattern);
	if (!ld[layer]) {
		layer = 0; // default style
	}
	brush.setColor(ld[layer]->color);
	brush.setStyle(ld[layer]->brushStyle);
	brush.setTransform(QTransform::fromScale(0.005, 0.005));

	pen.setColor(ld[layer]->color);
	pen.setStyle(Qt::SolidLine);
}
开发者ID:elektronisk,项目名称:edatool,代码行数:32,代码来源:edatool.cpp

示例4: stroke

void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
{
    QPainterState *s = state();

    if (s->bgMode == Qt::OpaqueMode && pen.style() > Qt::SolidLine) {
        QPen bgPen = pen;
        bgPen.setBrush(s->bgBrush);
        bgPen.setStyle(Qt::SolidLine);
        real_engine->stroke(path, bgPen);
    }

    QBrush brush = pen.brush();
    QPen copy = pen;
    Qt::BrushStyle style = qbrush_style(brush);
    if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
        const QGradient *g = brush.gradient();

        if (g->coordinateMode() > QGradient::LogicalMode) {
            if (g->coordinateMode() == QGradient::StretchToDeviceMode) {
                QTransform mat = brush.transform();
                mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height());
                brush.setTransform(mat);
                copy.setBrush(brush);
                real_engine->stroke(path, copy);
                return;
            } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) {
                QTransform mat = brush.transform();
                QRectF r = path.controlPointRect();
                mat.translate(r.x(), r.y());
                mat.scale(r.width(), r.height());
                brush.setTransform(mat);
                copy.setBrush(brush);
                real_engine->stroke(path, copy);
                return;
            }
        }
    }

    real_engine->stroke(path, pen);
}
开发者ID:13W,项目名称:phantomjs,代码行数:40,代码来源:qemulationpaintengine.cpp

示例5: fill

void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
{
    QPainterState *s = state();

    if (s->bgMode == Qt::OpaqueMode) {
        Qt::BrushStyle style = brush.style();
        if (style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern)
            real_engine->fill(path, s->bgBrush);
    }

    Qt::BrushStyle style = qbrush_style(brush);
    if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
        const QGradient *g = brush.gradient();

        if (g->coordinateMode() > QGradient::LogicalMode) {
            if (g->coordinateMode() == QGradient::StretchToDeviceMode) {
                QBrush copy = brush;
                QTransform mat = copy.transform();
                mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height());
                copy.setTransform(mat);
                real_engine->fill(path, copy);
                return;
            } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) {
                QBrush copy = brush;
                QTransform mat = copy.transform();
                QRectF r = path.controlPointRect();
                mat.translate(r.x(), r.y());
                mat.scale(r.width(), r.height());
                copy.setTransform(mat);
                real_engine->fill(path, copy);
                return;
            }
        }
    }

    real_engine->fill(path, brush);
}
开发者ID:13W,项目名称:phantomjs,代码行数:37,代码来源:qemulationpaintengine.cpp

示例6: fillBackground

static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, QRectF gradientRect = QRectF())//copy from QPlainTextEditor from 4.8.1
{
    p->save();
    if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) {
        if (!gradientRect.isNull()) {
            QTransform m = QTransform::fromTranslate(gradientRect.left(), gradientRect.top());
            m.scale(gradientRect.width(), gradientRect.height());
            brush.setTransform(m);
            const_cast<QGradient *>(brush.gradient())->setCoordinateMode(QGradient::LogicalMode);
        }
    } else {
        p->setBrushOrigin(rect.topLeft());
    }
    p->fillRect(rect, brush);
    p->restore();
}
开发者ID:3rdpaw,项目名称:MdCharm,代码行数:16,代码来源:baseeditor.cpp

示例7: renderPolygon

void QgsImageFillSymbolLayer::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }
  p->setPen( QPen( Qt::NoPen ) );
  if ( context.selected() )
  {
    QColor selColor = context.selectionColor();
    // Alister - this doesn't seem to work here
    //if ( ! selectionIsOpaque )
    //  selColor.setAlphaF( context.alpha() );
    p->setBrush( QBrush( selColor ) );
    _renderPolygon( p, points, rings );
  }

  if ( doubleNear( mAngle, 0.0 ) )
  {
    p->setBrush( mBrush );
  }
  else
  {
    QTransform t = mBrush.transform();
    t.rotate( mAngle );
    QBrush rotatedBrush = mBrush;
    rotatedBrush.setTransform( t );
    p->setBrush( rotatedBrush );
  }
  _renderPolygon( p, points, rings );
  if ( mOutline )
  {
    mOutline->renderPolyline( points, context.feature(), context.renderContext(), -1, selectFillBorder && context.selected() );
    if ( rings )
    {
      QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
      for ( ; ringIt != rings->constEnd(); ++ringIt )
      {
        mOutline->renderPolyline( *ringIt, context.feature(), context.renderContext(), -1, selectFillBorder && context.selected() );
      }
    }
  }
}
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:44,代码来源:qgsfillsymbollayerv2.cpp

示例8: drawBorderImageCutouts

void TextureViewWidget::drawBorderImageCutouts(QPainter *p) const
{
    p->save();
    auto scaleTransform = QTransform::fromScale(zoom(), zoom());
    p->setTransform(scaleTransform, true);

    QPen pen(Qt::white);
    pen.setCosmetic(true);
    p->setPen(pen);
    QBrush brush = QBrush(Qt::white, Qt::FDiagPattern);
    brush.setTransform(scaleTransform.inverted());
    p->setBrush(brush);
    if (m_horizontalBorderImageSavingsInPercent > minimumBorderImageSavingsPercent) {
        auto horizontalCutout = m_horizontalBorderRectMidCut.translated(m_analyzedRect.topLeft());
        p->drawRect(horizontalCutout);
    }
    if (m_verticalBorderImageSavings > minimumBorderImageSavingsPercent) {
        auto verticalCutout = m_verticalBorderRectMidCut.translated(m_analyzedRect.topLeft());
        p->drawRect(verticalCutout);
    }
    p->restore();
}
开发者ID:iamsergio,项目名称:GammaRay,代码行数:22,代码来源:textureviewwidget.cpp

示例9: stroke


//.........这里部分代码省略.........
                d->activeStroker->lineTo(path.points()[0], path.points()[1]);

        } else {
            d->activeStroker->moveTo(points[0], points[1]);
            points += 2;
            while (points < lastPoint) {
                d->activeStroker->lineTo(points[0], points[1]);
                points += 2;
            }
            if (path.hasImplicitClose())
                d->activeStroker->lineTo(path.points()[0], path.points()[1]);
        }
        d->activeStroker->end();

        if (!d->strokeHandler->types.size()) // an empty path...
            return;

        QVectorPath strokePath(d->strokeHandler->pts.data(),
                               d->strokeHandler->types.size(),
                               d->strokeHandler->types.data(),
                               flags);
        fill(strokePath, pen.brush());
    } else {
        // For cosmetic pens we need a bit of trickery... We to process xform the input points
        if (state()->matrix.type() >= QTransform::TxProject) {
            QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
            d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
        } else {
            d->activeStroker->setCurveThresholdFromTransform(QTransform());
            d->activeStroker->begin(d->strokeHandler);
            if (types) {
                while (points < lastPoint) {
                    switch (*types) {
                    case QPainterPath::MoveToElement: {
                        QPointF pt = (*(QPointF *) points) * state()->matrix;
                        d->activeStroker->moveTo(pt.x(), pt.y());
                        points += 2;
                        ++types;
                        break;
                    }
                    case QPainterPath::LineToElement: {
                        QPointF pt = (*(QPointF *) points) * state()->matrix;
                        d->activeStroker->lineTo(pt.x(), pt.y());
                        points += 2;
                        ++types;
                        break;
                    }
                    case QPainterPath::CurveToElement: {
                        QPointF c1 = ((QPointF *) points)[0] * state()->matrix;
                        QPointF c2 = ((QPointF *) points)[1] * state()->matrix;
                        QPointF e =  ((QPointF *) points)[2] * state()->matrix;
                        d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
                        points += 6;
                        types += 3;
                        flags |= QVectorPath::CurvedShapeMask;
                        break;
                    }
                    default:
                        break;
                    }
                }
                if (path.hasImplicitClose()) {
                    QPointF pt = * ((QPointF *) path.points()) * state()->matrix;
                    d->activeStroker->lineTo(pt.x(), pt.y());
                }

            } else {
                QPointF p = ((QPointF *)points)[0] * state()->matrix;
                d->activeStroker->moveTo(p.x(), p.y());
                points += 2;
                while (points < lastPoint) {
                    QPointF p = ((QPointF *)points)[0] * state()->matrix;
                    d->activeStroker->lineTo(p.x(), p.y());
                    points += 2;
                }
                if (path.hasImplicitClose())
                    d->activeStroker->lineTo(p.x(), p.y());
            }
            d->activeStroker->end();
        }

        QVectorPath strokePath(d->strokeHandler->pts.data(),
                               d->strokeHandler->types.size(),
                               d->strokeHandler->types.data(),
                               flags);

        QTransform xform = state()->matrix;
        state()->matrix = QTransform();
        transformChanged();

        QBrush brush = pen.brush();
        if (qbrush_style(brush) != Qt::SolidPattern)
            brush.setTransform(brush.transform() * xform);

        fill(strokePath, brush);

        state()->matrix = xform;
        transformChanged();
    }
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:101,代码来源:qpaintengineex.cpp


注:本文中的QBrush::setTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。