void FrameItem::setEmuView(QObject *emuView) { qDebug("Setting emuView."); m_emuView = qobject_cast<EmuView *>(emuView); connect(m_emuView, SIGNAL(videoFrameChanged(QImage)), this, SLOT(handleNewFrame(QImage))); m_emuView->hostInput()->touchInputDevice()->setHeight((int) contentsBoundingRect().height()); m_emuView->hostInput()->touchInputDevice()->setWidth((int) contentsBoundingRect().width()); }
/*! Schedules a redraw of the area covered by \a rect in this item. You can call this function whenever your item needs to be redrawn, such as if it changes appearance or size. This function does not cause an immediate paint; instead it schedules a paint request that is processed by the QML Scene Graph when the next frame is rendered. The item will only be redrawn if it is visible. Note that calling this function will trigger a repaint of the whole scene. \sa paint() */ void QQuickPaintedItem::update(const QRect &rect) { Q_D(QQuickPaintedItem); if (rect.isNull() && !d->dirtyRect.isNull()) d->dirtyRect = contentsBoundingRect().toAlignedRect(); else d->dirtyRect |= (contentsBoundingRect() & rect).toAlignedRect(); QQuickItem::update(); }
void LaserSurface::paint(QPainter *painter) { if (laserPainter) { laserPainter->paint(painter, contentsBoundingRect()); } else { #ifdef DEBUG // In debug builds, we warn about an unset laser painter by turning the screen magenta. painter->fillRect(contentsBoundingRect(), Qt::magenta); #else painter->fillRect(contentsBoundingRect(), Qt::black); #endif } }
/*! \reimp */ QSGNode *QQuickPaintedItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { Q_UNUSED(data); Q_D(QQuickPaintedItem); if (width() <= 0 || height() <= 0) { delete oldNode; return 0; } QSGPainterNode *node = static_cast<QSGPainterNode *>(oldNode); if (!node) node = new QSGPainterNode(this); QRectF br = contentsBoundingRect(); node->setPreferredRenderTarget(d->renderTarget); node->setFastFBOResizing(d->performanceHints & FastFBOResizing); node->setSize(QSize(qRound(br.width()), qRound(br.height()))); node->setSmoothPainting(d->antialiasing); node->setLinearFiltering(d->smooth); node->setMipmapping(d->mipmap); node->setOpaquePainting(d->opaquePainting); node->setFillColor(d->fillColor); node->setContentsScale(d->contentsScale); node->setDirty(d->dirtyRect); node->update(); d->dirtyRect = QRect(); return node; }
void MapWidget::paint(QPainter *painter) { RenderMapRequest request; QRectF boundingBox=contentsBoundingRect(); request.lat=center.GetLat(); request.lon=center.GetLon(); request.angle=angle; request.magnification=magnification; request.width=boundingBox.width(); request.height=boundingBox.height(); if(quickZooming) //just zoom the already rendered Qimage and repaint { DBThread *dbThread=DBThread::GetInstance(); dbThread->RenderMapQuick(*painter, quickMoveX, quickMoveY, quickZoomFactor, request); } else { DBThread *dbThread=DBThread::GetInstance(); if (!dbThread->RenderMap(*painter,request) && requestNewMap) { TriggerMapRendering(); } requestNewMap=true; } }
void FrameItem::paint(QPainter *painter) { if (! m_currentFrame.isNull()) { painter->drawImage(contentsBoundingRect(), m_currentFrame); m_emuView->hostInput()->paint(painter); paintFps(painter); } }
void QmlWebViewWidget::updateGeometry() { QPointF newPos(0, 0); newPos = mapToItem(0, newPos); qDebug() << "QmlWebViewWidget::updateGeometry, top left mapped to window: " << newPos; if(this->window()){ newPos += this->window()->position(); qDebug() << "QmlWebViewWidget::updateGeometry, top left mapped to screen: " << newPos; } QRectF absRect(newPos, contentsBoundingRect().size()); m_widget->setGeometry(absRect.toRect()); }
void RubberBand::paint(QPainter *painter) { if (!qApp || !qApp->style()) { return; } QStyleOptionRubberBand opt; opt.state = QStyle::State_None; opt.direction = qApp->layoutDirection(); opt.fontMetrics = qApp->fontMetrics(); opt.styleObject = this; opt.palette = qApp->palette(); opt.shape = QRubberBand::Rectangle; opt.opaque = false; opt.rect = contentsBoundingRect().toRect(); qApp->style()->drawControl(QStyle::CE_RubberBand, &opt, painter); }
void MapWidget::paint(QPainter *painter) { RenderMapRequest request; DBThread *dbThread=DBThread::GetInstance(); QRectF boundingBox=contentsBoundingRect(); request.lat=center.GetLat(); request.lon=center.GetLon(); request.magnification=magnification; request.width=boundingBox.width(); request.height=boundingBox.height(); if (!dbThread->RenderMap(*painter,request) && requestNewMap) { TriggerMapRendering(); } requestNewMap=true; }
void PlotItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget*) { const auto& rect = option->rect; #else void PlotItem::paint (QPainter *painter) { const auto& rect = contentsBoundingRect ().toRect (); #endif QwtPlot plot; plot.setFrameShape (QFrame::NoFrame); plot.enableAxis (QwtPlot::yLeft, LeftAxisEnabled_); plot.enableAxis (QwtPlot::xBottom, BottomAxisEnabled_); plot.setAxisTitle (QwtPlot::yLeft, LeftAxisTitle_); plot.setAxisTitle (QwtPlot::xBottom, BottomAxisTitle_); plot.resize (rect.size ()); auto setPaletteColor = [&plot] (const QColor& color, QPalette::ColorRole role) -> void { if (!color.isValid ()) return; auto pal = plot.palette (); pal.setColor (role, { color }); plot.setPalette (pal); }; setPaletteColor (BackgroundColor_, QPalette::Window); setPaletteColor (TextColor_, QPalette::WindowText); setPaletteColor (TextColor_, QPalette::Text); if (!PlotTitle_.isEmpty ()) plot.setTitle (QwtText { PlotTitle_ }); if (MinYValue_ < MaxYValue_) { plot.setAxisAutoScale (QwtPlot::yLeft, false); plot.setAxisScale (QwtPlot::yLeft, MinYValue_, MaxYValue_); } plot.setAutoFillBackground (false); plot.setCanvasBackground (Qt::transparent); if (YGridEnabled_) { auto grid = new QwtPlotGrid; grid->enableYMin (YMinorGridEnabled_); grid->enableX (false); #if QWT_VERSION >= 0x060100 grid->setMajorPen (QPen (GridLinesColor_, 1, Qt::SolidLine)); grid->setMinorPen (QPen (GridLinesColor_, 1, Qt::DashLine)); #else grid->setMajPen (QPen (GridLinesColor_, 1, Qt::SolidLine)); grid->setMinPen (QPen (GridLinesColor_, 1, Qt::DashLine)); #endif grid->attach (&plot); } auto items = Multipoints_; if (items.isEmpty ()) items.push_back ({ Color_, Points_ }); if (MinXValue_ < MaxXValue_) plot.setAxisScale (QwtPlot::xBottom, MinXValue_, MaxXValue_); else if (const auto ptsCount = items.first ().Points_.size ()) plot.setAxisScale (QwtPlot::xBottom, 0, ptsCount - 1); std::vector<std::unique_ptr<QwtPlotCurve>> curves; for (const auto& item : items) { curves.emplace_back (new QwtPlotCurve); const auto curve = curves.back ().get (); curve->setPen (QPen (item.Color_)); auto transpColor = item.Color_; transpColor.setAlphaF (Alpha_); curve->setBrush (transpColor); curve->setRenderHint (QwtPlotItem::RenderAntialiased); curve->attach (&plot); curve->setSamples (item.Points_.toVector ()); } plot.replot (); QwtPlotRenderer {}.render (&plot, painter, rect); const auto xExtent = CalcXExtent (plot); const auto yExtent = CalcYExtent (plot); if (xExtent != XExtent_ || yExtent != YExtent_) { XExtent_ = xExtent; YExtent_ = yExtent; emit extentsChanged (); } }
void CalcScreen::paint(QPainter *painter) { QRectF target = contentsBoundingRect(); QRectF source(0.0, 0.0, m_lcdW, m_lcdH); painter->drawImage(target,m_screen,source); }
/*! \reimp */ QSGNode *QQuickPaintedItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { Q_UNUSED(data); Q_D(QQuickPaintedItem); if (width() <= 0 || height() <= 0) { delete oldNode; if (d->textureProvider) { d->textureProvider->node = 0; d->textureProvider->fireTextureChanged(); } return 0; } QSGPainterNode *node = static_cast<QSGPainterNode *>(oldNode); if (!node) { node = d->sceneGraphContext()->createPainterNode(this); d->node = node; } bool hasTextureSize = d->textureSize.width() > 0 && d->textureSize.height() > 0; // Use the compat mode if any of the compat things are set and // textureSize is 0x0. if (!hasTextureSize && (d->contentsScale != 1 || (d->contentsSize.width() > 0 && d->contentsSize.height() > 0))) { QRectF br = contentsBoundingRect(); node->setContentsScale(d->contentsScale); QSize size = QSize(qRound(br.width()), qRound(br.height())); node->setSize(size); node->setTextureSize(size); } else { // The default, use textureSize or item's size * device pixel ratio node->setContentsScale(1); QSize itemSize(qRound(width()), qRound(height())); node->setSize(itemSize); QSize textureSize = (hasTextureSize ? d->textureSize : itemSize) * window()->effectiveDevicePixelRatio(); node->setTextureSize(textureSize); } node->setPreferredRenderTarget(d->renderTarget); node->setFastFBOResizing(d->performanceHints & FastFBOResizing); node->setSmoothPainting(d->antialiasing); node->setLinearFiltering(d->smooth); node->setMipmapping(d->mipmap); node->setOpaquePainting(d->opaquePainting); node->setFillColor(d->fillColor); node->setDirty(d->dirtyRect); node->update(); d->dirtyRect = QRect(); if (d->textureProvider) { d->textureProvider->node = node; d->textureProvider->fireTextureChanged(); } return node; }