本文整理汇总了C++中QRectF::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::isEmpty方法的具体用法?C++ QRectF::isEmpty怎么用?C++ QRectF::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPixmap
void QPdfEngine::drawPixmap (const QRectF &rectangle, const QPixmap &pixmap, const QRectF &sr)
{
if (sr.isEmpty() || rectangle.isEmpty() || pixmap.isNull())
return;
Q_D(QPdfEngine);
QBrush b = d->brush;
QRect sourceRect = sr.toRect();
QPixmap pm = sourceRect != pixmap.rect() ? pixmap.copy(sourceRect) : pixmap;
QImage image = pm.toImage();
bool bitmap = true;
const int object = d->addImage(image, &bitmap, pm.cacheKey());
if (object < 0)
return;
*d->currentPage << "q\n/GSa gs\n";
*d->currentPage
<< QPdf::generateMatrix(QTransform(rectangle.width() / sr.width(), 0, 0, rectangle.height() / sr.height(),
rectangle.x(), rectangle.y()) * (d->simplePen ? QTransform() : d->stroker.matrix));
if (bitmap) {
// set current pen as d->brush
d->brush = d->pen.brush();
}
setBrush();
d->currentPage->streamImage(image.width(), image.height(), object);
*d->currentPage << "Q\n";
d->brush = b;
}
示例2: drawPlainText
void X11FilterContext::drawPlainText(const QRectF &rect, int flags, const QString &text)
{
if (text.isEmpty())
return;
if (rect.isEmpty()) {
drawPlainText(rect.topLeft(), text);
return;
}
if (test_img.size() != rect.size().toSize()) {
test_img = QImage(rect.size().toSize(), QImage::Format_ARGB32); //TODO: create once
}
painter->begin(&test_img);
prepare();
QRectF br = painter->boundingRect(rect, flags, text);
painter->end();
if (br.isEmpty())
return;
if (text == this->text && plain && mask_pix) {
renderTextImageX11(0, br.topLeft());
return;
}
this->text = text;
this->plain = true;
text_q = QImage(br.size().toSize(), QImage::Format_ARGB32);
text_q.fill(QColor(0, 0, 0, 0));
painter->begin(&text_q);
prepare();
painter->drawText(0, 0, br.width(), br.height(), Qt::AlignCenter, text);
painter->end();
renderTextImageX11(&text_q, br.topLeft());
}
示例3: be
/*!
\brief Render the plot to a QSvgGenerator
If the generator has a view box, the plot will be rendered into it.
If it has no viewBox but a valid size the target coordinates
will be (0, 0, generator.width(), generator.height()). Otherwise
the target rectangle will be QRectF(0, 0, 800, 600);
\param plot Plot to be rendered
\param generator SVG generator
*/
void QwtPolarRenderer::renderTo(
QwtPolarPlot *plot, QSvgGenerator &generator ) const
{
QRectF rect = generator.viewBoxF();
if ( rect.isEmpty() )
rect.setRect( 0, 0, generator.width(), generator.height() );
if ( rect.isEmpty() )
rect.setRect( 0, 0, 800, 600 ); // something
QPainter p( &generator );
render( plot, &p, rect );
}
示例4: compose
QImage QwtPlotRasterItem::compose(
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &imageArea, const QRectF &paintRect,
const QSize &imageSize, bool doCache) const
{
QImage image;
if ( imageArea.isEmpty() || paintRect.isEmpty() || imageSize.isEmpty() )
return image;
if ( doCache )
{
if ( !d_data->cache.image.isNull()
&& d_data->cache.area == imageArea
&& d_data->cache.size == paintRect.size() )
{
image = d_data->cache.image;
}
}
if ( image.isNull() )
{
double dx = 0.0;
if ( paintRect.toRect().width() > imageSize.width() )
dx = imageArea.width() / imageSize.width();
const QwtScaleMap xxMap =
imageMap(Qt::Horizontal, xMap, imageArea, imageSize, dx);
double dy = 0.0;
if ( paintRect.toRect().height() > imageSize.height() )
dy = imageArea.height() / imageSize.height();
const QwtScaleMap yyMap =
imageMap(Qt::Vertical, yMap, imageArea, imageSize, dy);
image = renderImage( xxMap, yyMap, imageArea, imageSize );
if ( doCache )
{
d_data->cache.area = imageArea;
d_data->cache.size = paintRect.size();
d_data->cache.image = image;
}
}
if ( d_data->alpha >= 0 && d_data->alpha < 255 )
image = toRgba( image, d_data->alpha );
return image;
}
示例5: doData
QVariant ComplexControlModel::doData(int row, int column, int role) const
{
if (role == Qt::DecorationRole) {
QPixmap pixmap(m_interface->cellSizeHint());
QPainter painter(&pixmap);
Util::drawTransparencyPattern(&painter, pixmap.rect());
painter.scale(m_interface->cellZoom(), m_interface->cellZoom());
QScopedPointer<QStyleOptionComplex> opt(
qstyleoption_cast<QStyleOptionComplex*>(complexControlElements[row].styleOptionFactory()));
Q_ASSERT(opt);
fillStyleOption(opt.data(), column);
m_style->drawComplexControl(complexControlElements[row].control, opt.data(), &painter);
int colorIndex = 7;
for (int i = 0; i < 32; ++i) {
QStyle::SubControl sc = static_cast<QStyle::SubControl>(1 << i);
if (sc & complexControlElements[row].subControls) {
QRectF scRect =
m_style->subControlRect(complexControlElements[row].control, opt.data(), sc);
scRect.adjust(0, 0, -1.0 / m_interface->cellZoom(), -1.0 / m_interface->cellZoom());
if (scRect.isValid() && !scRect.isEmpty()) {
// HACK: add some real color mapping
painter.setPen(static_cast<Qt::GlobalColor>(colorIndex++));
painter.drawRect(scRect);
}
}
}
return pixmap;
}
return AbstractStyleElementStateTable::doData(row, column, role);
}
示例6: qwtDrawSvgSymbols
static inline void qwtDrawSvgSymbols( QPainter *painter,
const QPointF *points, int numPoints,
QSvgRenderer *renderer, const QwtSymbol &symbol )
{
if ( renderer == NULL || !renderer->isValid() )
return;
const QRectF viewBox = renderer->viewBoxF();
if ( viewBox.isEmpty() )
return;
QSizeF sz = symbol.size();
if ( !sz.isValid() )
sz = viewBox.size();
const double sx = sz.width() / viewBox.width();
const double sy = sz.height() / viewBox.height();
QPointF pinPoint = viewBox.center();
if ( symbol.isPinPointEnabled() )
pinPoint = symbol.pinPoint();
const double dx = sx * ( pinPoint.x() - viewBox.left() );
const double dy = sy * ( pinPoint.y() - viewBox.top() );
for ( int i = 0; i < numPoints; i++ )
{
const double x = points[i].x() - dx;
const double y = points[i].y() - dy;
renderer->render( painter,
QRectF( x, y, sz.width(), sz.height() ) );
}
}
示例7: clipAndDrawPixmap
void QBlitterPaintEnginePrivate::clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr, bool opacity)
{
Q_Q(QBlitterPaintEngine);
QRectF intersectedRect = clip.intersected(target);
if (intersectedRect.isEmpty())
return;
QRectF source = sr;
if (intersectedRect.size() != target.size()) {
if (sr.size() == target.size()) {
// no resize
qreal deltaTop = target.top() - intersectedRect.top();
qreal deltaLeft = target.left() - intersectedRect.left();
qreal deltaBottom = target.bottom() - intersectedRect.bottom();
qreal deltaRight = target.right() - intersectedRect.right();
source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
} else {
// resize case
qreal hFactor = sr.size().width() / target.size().width();
qreal vFactor = sr.size().height() / target.size().height();
qreal deltaTop = (target.top() - intersectedRect.top()) * vFactor;
qreal deltaLeft = (target.left() - intersectedRect.left()) * hFactor;
qreal deltaBottom = (target.bottom() - intersectedRect.bottom()) * vFactor;
qreal deltaRight = (target.right() - intersectedRect.right()) * hFactor;
source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
}
}
pmData->unmarkRasterOverlay(intersectedRect);
if (opacity)
pmData->blittable()->drawPixmapOpacity(intersectedRect, pm, source, q->state()->compositionMode(), q->state()->opacity);
else
pmData->blittable()->drawPixmap(intersectedRect, pm, source);
}
示例8: runPartialDst
void KisPerspectiveTransformWorker::runPartialDst(KisPaintDeviceSP srcDev,
KisPaintDeviceSP dstDev,
const QRect &dstRect)
{
if (m_isIdentity) {
KisPainter::copyAreaOptimizedOldData(dstRect.topLeft(), srcDev, dstDev, dstRect);
return;
}
QRectF srcClipRect = srcDev->exactBounds();
if (srcClipRect.isEmpty()) return;
KisProgressUpdateHelper progressHelper(m_progressUpdater, 100, dstRect.height());
KisRandomSubAccessorSP srcAcc = srcDev->createRandomSubAccessor();
KisRandomAccessorSP accessor = dstDev->createRandomAccessorNG(dstRect.x(), dstRect.y());
for (int y = dstRect.y(); y < dstRect.y() + dstRect.height(); ++y) {
for (int x = dstRect.x(); x < dstRect.x() + dstRect.width(); ++x) {
QPointF dstPoint(x, y);
QPointF srcPoint = m_backwardTransform.map(dstPoint);
if (srcClipRect.contains(srcPoint)) {
accessor->moveTo(dstPoint.x(), dstPoint.y());
srcAcc->moveTo(srcPoint.x(), srcPoint.y());
srcAcc->sampledOldRawData(accessor->rawData());
}
}
progressHelper.step();
}
}
示例9: applyViewboxTransformation
void KPathShapePrivate::applyViewboxTransformation(const KXmlElement &element)
{
Q_Q(KPathShape);
// apply viewbox transformation
QRectF viewBox = q->loadOdfViewbox(element);
if (! viewBox.isEmpty()) {
// load the desired size
QSizeF size;
size.setWidth(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "width", QString())));
size.setHeight(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "height", QString())));
// load the desired position
QPointF pos;
pos.setX(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "x", QString())));
pos.setY(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "y", QString())));
// create matrix to transform original path data into desired size and position
QTransform viewMatrix;
viewMatrix.translate(-viewBox.left(), -viewBox.top());
viewMatrix.scale(size.width() / viewBox.width(), size.height() / viewBox.height());
viewMatrix.translate(pos.x(), pos.y());
// transform the path data
map(viewMatrix);
}
}
示例10: toTikzPath
QString QTikzPicturePrivate::toTikzPath(const QRectF & rect) const
{
if (rect.isEmpty()) return QString();
const QString path = toCoord(rect.topLeft()) + " rectangle "
+ toCoord(rect.bottomRight());
return path;
}
示例11: computeVisibleSet
Indices PixelStreamUpdater::computeVisibleSet(const QRectF& visibleTilesArea,
const uint lod,
const uint channel) const
{
Q_UNUSED(lod);
if (!_frameLeftOrMono || visibleTilesArea.isEmpty())
return Indices{};
return _processorLeft->computeVisibleSet(visibleTilesArea, channel);
}
示例12: select
void Canvas::select(QRectF & rect)
{
if (rect.isEmpty()) {
m_found = m_rtree.contains(rect.topLeft());
} else {
m_found = m_rtree.intersects(rect);
}
update();
}
示例13: draw
// Drawing Routines
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
{
QRectF normalizedDst = dst.normalized();
QRectF normalizedSrc = src.normalized();
startAnimation();
if (normalizedSrc.isEmpty() || normalizedDst.isEmpty())
return;
QPixmap* image = nativeImageForCurrentFrame();
if (!image)
return;
if (mayFillWithSolidColor()) {
fillWithSolidColor(ctxt, normalizedDst, solidColor(), styleColorSpace, op);
return;
}
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
normalizedSrc = adjustSourceRectForDownSampling(normalizedSrc, image->size());
#endif
CompositeOperator previousOperator = ctxt->compositeOperation();
ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
if (ctxt->hasShadow()) {
ShadowBlur* shadow = ctxt->shadowBlur();
GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
shadow->endShadowLayer(ctxt);
}
}
ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);
ctxt->setCompositeOperation(previousOperator);
if (imageObserver())
imageObserver()->didDraw(this);
}
示例14: drawTileSelection
void OrthogonalRenderer::drawTileSelection(QPainter *painter,
const QRegion ®ion,
const QColor &color,
const QRectF &exposed) const
{
foreach (const QRect &r, region.rects()) {
const QRectF toFill = QRectF(boundingRect(r)).intersected(exposed);
if (!toFill.isEmpty())
painter->fillRect(toFill, color);
}
}
示例15: drawBackground
void MPlainWindow::drawBackground(QPainter *painter, const QRectF &rect)
{
if (not host || rect.isEmpty()) {
return;
}
const QPixmap bg(host->background());
if (not bg.isNull()) {
painter->drawPixmap(rect, bg, rect);
}
}