本文整理汇总了C++中devicePixelRatio函数的典型用法代码示例。如果您正苦于以下问题:C++ devicePixelRatio函数的具体用法?C++ devicePixelRatio怎么用?C++ devicePixelRatio使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了devicePixelRatio函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_ASSERT
void hrRender::setScene(hrScene *s)
{
Q_ASSERT(s);
scene = s;
connect(scene, SIGNAL(sceneChanged()), this, SLOT(onSceneChanged()));
connect(scene, SIGNAL(cursorChaged(int)), this, SLOT(onCursorChanged(int)));
scene->setViewport(width()*devicePixelRatio(), height()*devicePixelRatio());
}
示例2: resizeGL
void NGLScene::resizeGL(int _w , int _h)
{
m_width=_w*devicePixelRatio();
m_height=_h*devicePixelRatio();
ngl::ShaderLib *shader = ngl::ShaderLib::instance();
shader->use("buttonShader");
shader->setRegisteredUniform("resolution", ngl::Vec2(m_width, m_height));
shader->use("progressShader");
shader->setRegisteredUniform("resolution", ngl::Vec2(m_width, m_height));
m_project = ngl::perspective(45.0f, float(m_width)/float(m_height), 0.2f, 20.0f);
}
示例3: resizeEvent
void OpenGLWindow::resizeGL(QResizeEvent *_event)
{
/*
Note: This is merely a convenience function in order to provide an API that is compatible with QOpenGLWidget. Unlike with QOpenGLWidget, derived classes are free to choose to override
resizeEvent() instead of this function.
Note: Avoid issuing OpenGL commands from this function as there may not be
a context current when it is invoked. If it cannot be avoided, call makeCurrent().
*/
m_width=_event->size().width()*devicePixelRatio();
m_height=_event->size().height()*devicePixelRatio();
}
示例4: image
void DisplayImagesWidgetGui::display()
{
QImage image(m_fNames[m_fileIndex]);
cv::Mat img_bw = Util::toCv(image, CV_8UC4);
cv::cvtColor(img_bw, img_bw, CV_BGR2GRAY);
QPixmap pixmap = QPixmap::fromImage(image);
QImage scaledImage = pixmap.toImage().scaled(pixmap.size() * devicePixelRatio(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
scaledImage.setDevicePixelRatio(devicePixelRatio());
QPixmap *newScaledPixmap = new QPixmap(QPixmap::fromImage(scaledImage));
ui->label->setScaledContents(true);
ui->label->setPixmap(*newScaledPixmap);
ui->label->resize(ui->label->pixmap()->size());
}
示例5: devicePixelRatio
// The render function, called when an update is requested
void MainWindow::render()
{
// glViewport is used for specifying the resolution to render
// Uses the window size as the resolution
const qreal retinaScale = devicePixelRatio();
glViewport(0, 0, width() * retinaScale, height() * retinaScale);
// Clear the screen at the start of the rendering.
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// Bind the shaderprogram to use it
m_shaderProgram->bind();
m_shaderProgram->setUniformValue("model", model);
m_shaderProgram->setUniformValue("view", view);
m_shaderProgram->setUniformValue("projection", projection);
m_funcs->glBindVertexArray(VAO);
// Draw cube
m_funcs->glDrawArrays(GL_TRIANGLES, 0, vectorsNumber);
// relases the current shaderprogram (to bind an use another shaderprogram for example)
m_shaderProgram->release();
}
示例6: devicePixelRatio
void OpenGLWidget::paintGL()
{
const qreal retinaScale = devicePixelRatio();
glClear(GL_COLOR_BUFFER_BIT);
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
majorOffset += offset;
fractal.beginRender();
if (fill)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
m_vao.bind();
glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
m_vao.release();
fractal.endRender();
majorOffset -= offset;
if (go)
{
go = anim.nextFrame();
fractal.computeVariables.at(0)->setValue();
fractal.computeVariables.at(1)->setValue();
fractal.computeVariables.at(fractal.computeVariables.size() - 1)->setValue();
rendermodeLR = ALL;
if (anim.checkBox->isChecked())
this->grabFramebuffer().save(anim.file);
}
}
示例7: Q_UNUSED
void QOpenGLTextureBlitWindow::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
m_image = QImage(size() * devicePixelRatio(), QImage::Format_ARGB32_Premultiplied);
m_image.fill(Qt::gray);
QPainter p(&m_image);
QPen pen(Qt::red);
pen.setWidth(5);
p.setPen(pen);
QFont font = p.font();
font.setPixelSize(qMin(m_image.height(), m_image.width()) / 20);
p.setFont(font);
int dx = dWidth() / 5;
int dy = dHeight() / 5;
for (int y = 0; y < 5; y++) {
for (int x = 0; x < 5; x++) {
QRect textRect(x * dx, y*dy, dx,dy);
QString text = QString("[%1,%2]").arg(x).arg(y);
p.drawText(textRect,text);
}
}
p.drawRect(QRectF(2.5,2.5,dWidth() - 5, dHeight() - 5));
m_image_mirrord = m_image.mirrored(false,true);
}
示例8: devicePixelRatio
/**
*Overrides the paintGL method of the base class.
*Dispatches the handling to the active child application.
*/
void ThreeDWidget::paintGL()
{
qreal pixelRatio = 1;
#if QT_VERSION >= 0x050000
pixelRatio = devicePixelRatio();
#endif
setupViewPort(width() * pixelRatio, height() * pixelRatio);
if(m_iView==GLMIAREXVIEW)
{
QMiarex* pMiarex = (QMiarex*)s_pMiarex;
pMiarex->GLDraw3D();
if(pMiarex->m_iView==W3DVIEW) pMiarex->GLRenderView();
}
else if(m_iView == GLBODYVIEW)
{
GL3dBodyDlg *pDlg = (GL3dBodyDlg*)m_pParent;
pDlg->GLDraw3D();
pDlg->GLRenderBody();
}
else if(m_iView == GLWINGVIEW)
{
GL3dWingDlg *pDlg = (GL3dWingDlg*)m_pParent;
pDlg->GLDraw3D();
pDlg->GLRenderView();
}
}
示例9: devicePixelRatio
// The render function, called when an update is requested
void MainWindow::render()
{
// glViewport is used for specifying the resolution to render
// Uses the window size as the resolution
const qreal retinaScale = devicePixelRatio();
glViewport(0, 0, width() * retinaScale, height() * retinaScale);
// Clear the screen at the start of the rendering.
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// Bind the shaderprogram to use it
m_shaderProgram->bind();
object.bind();
// m_shaderProgram->setUniformValue("m", model);
view.setToIdentity();
projection.setToIdentity();
projection.perspective(30.0, 1, 50, 1000);
//view.rotate(-200,-200,-200);
view.translate(-200,-200,-1000);
m_shaderProgram->setUniformValue("v", view);
m_shaderProgram->setUniformValue("p", projection);
renderRaytracerScene();
// relases the current shaderprogram (to bind an use another shaderprogram for example)
m_shaderProgram->release();
}
示例10: switch
QSize TuningLayout::calculateSize(SizeType sizeType) const
{
int _border = 2;
int _width = 0;
int _height = _border;
auto _parent = static_cast<Tuning*>(parent());
for (auto& _item : items_)
{
switch (_item.role_)
{
case Role::PARAMETER:
case Role::TITLE:
_height += 24 / _parent->devicePixelRatio();
break;
case Role::PREVIEW:
if (!tuning()) continue;
/// Increase height by aspect ratio
_height += _parent->width() /
float(tuning()->width()) * tuning()->height();
break;
}
}
_height += _border;
return QSize(_width,_height);
}
示例11: dpiRatio
/**
* @param pos A point in Qt screen coordinates from, for example, a mouse click
* @return A QPointF defining the position in data coordinates
*/
QPointF FigureCanvasQt::toDataCoords(QPoint pos) const {
// There is no isolated method for doing the transform on matplotlib's
// classes. The functionality is bound up inside other methods
// so we are forced to duplicate the behaviour here.
// The following code is derived form what happens in
// matplotlib.backends.backend_qt5.FigureCanvasQT &
// matplotlib.backend_bases.LocationEvent where we transform first to
// matplotlib's coordinate system, (0,0) is bottom left,
// and then to the data coordinates
const int dpiRatio(devicePixelRatio());
const double xPosPhysical = pos.x() * dpiRatio;
GlobalInterpreterLock lock;
// Y=0 is at the bottom
double height = PyFloat_AsDouble(
Python::Object(m_figure.pyobj().attr("bbox").attr("height")).ptr());
const double yPosPhysical =
((height / devicePixelRatio()) - pos.y()) * dpiRatio;
// Transform to data coordinates
QPointF dataCoords;
try {
auto invTransform = gca().pyobj().attr("transData").attr("inverted")();
NDArray transformed = invTransform.attr("transform_point")(
Python::NewRef(Py_BuildValue("(ff)", xPosPhysical, yPosPhysical)));
auto rawData = reinterpret_cast<double *>(transformed.get_data());
dataCoords =
QPointF(static_cast<qreal>(rawData[0]), static_cast<qreal>(rawData[1]));
} catch (Python::ErrorAlreadySet &) {
PyErr_Clear();
// an exception indicates no transform possible. Matplotlib sets this as
// an empty data coordinate so we will do the same
}
return dataCoords;
}
示例12: float
void TuningLayout::setGeometry(QRect const& _rect)
{
if (!tuning()) return;
const int _border = 2;
int _height = _border;
auto _parent = static_cast<Tuning *>(parent());
/// Adjust geometry for each widget
for (auto& _item : items_)
{
auto _widget = _item.widget();
/// Widget height is constant except for preview
int _widgetHeight = _item.role_ == Role::PREVIEW ? _parent->width() /
float(tuning()->width()) * tuning()->height() :
36 / _parent->devicePixelRatio();
_widget->setGeometry(_border, _height,
_parent->width() - _border * 2, _widgetHeight);
_widget->show();
/// Increase height
_height += _widgetHeight;
}
}
示例13: glClear
void FontWindow::render()
{
m_program->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_modelView.setToIdentity();
m_modelView.translate(0.0f, 0.0f, -3.0f);
QVector4D color(1.0f*float(qCos(m_cnt1)),
1.0f*float(qSin(m_cnt2)),
1.0f-0.5f*float(qCos(m_cnt1+m_cnt2)),
1.0f);
m_program->setUniformValue("color", color);
m_program->setUniformValue("mvpMatrix", m_projection * m_modelView);
const qreal retinaScale = devicePixelRatio();
resizeGL(width()*retinaScale, height()*retinaScale);
float sx = 2.0 / width()*retinaScale;
float sy = 2.0 / height()*retinaScale;
FT_Set_Pixel_Sizes(m_ftFace, 0, 48);
float mx = float(cos(m_cnt1));
float my = float(sin(m_cnt2));
QString text = "Active OpenGL Text With NeHe - " + QString::number(m_cnt1, 'f', 2);
renderText(text.toLatin1().data(),
mx - 0.5, my, sx, sy);
m_program->release();
m_cnt1+=0.051f;
m_cnt2+=0.005f;
}
示例14: width
bool IBLWidget::recreateFBO()
{
mSize = width() < height() ? width() : height();
mSize *= devicePixelRatio();
// if the FBO is the right size, no need to create it
if( fbo && fbo->width() == mSize && fbo->height() == mSize )
return false;
if(quad) delete quad;
quad = new Quad(0.f, 0.f, mSize, mSize, 0.f, 0.f, 1.f, 1.f);
if (fbo) delete fbo;
if (comp) delete comp;
fbo = new DGLFrameBuffer( mSize, mSize, "FBO" );
fbo->addColorBuffer( 0, GL_RGBA32F );
fbo->addDepthBuffer();
fbo->checkStatus();
comp = new DGLFrameBuffer( mSize, mSize, "Comp" );
comp->addColorBuffer( 0, GL_RGBA32F );
comp->checkStatus();
glf->glDisable( GL_BLEND );
resetComps();
return true;
}
示例15: p
void QVistaBackButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
QRect r = rect();
HANDLE theme = pOpenThemeData(0, L"Navigation");
//RECT rect;
QPoint origin;
const HDC hdc = QVistaHelper::backingStoreDC(parentWidget(), &origin);
RECT clipRect;
int xoffset = origin.x() + QWidget::mapToParent(r.topLeft()).x() - 1;
int yoffset = origin.y() + QWidget::mapToParent(r.topLeft()).y() - 1;
const int dpr = devicePixelRatio();
const QRect rDp = QRect(r.topLeft() * dpr, r.size() * dpr);
const int xoffsetDp = xoffset * dpr;
const int yoffsetDp = yoffset * dpr;
clipRect.top = rDp.top() + yoffsetDp;
clipRect.bottom = rDp.bottom() + yoffsetDp;
clipRect.left = rDp.left() + xoffsetDp;
clipRect.right = rDp.right() + xoffsetDp;
int state = WIZ_NAV_BB_NORMAL;
if (!isEnabled())
state = WIZ_NAV_BB_DISABLED;
else if (isDown())
state = WIZ_NAV_BB_PRESSED;
else if (underMouse())
state = WIZ_NAV_BB_HOT;
WIZ_NAVIGATIONPARTS buttonType = (layoutDirection() == Qt::LeftToRight
? WIZ_NAV_BACKBUTTON
: WIZ_NAV_FORWARDBUTTON);
pDrawThemeBackground(theme, hdc, buttonType, state, &clipRect, &clipRect);
}