Esempio n. 1
0
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());
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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();

}
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());
}
// 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();

}
Esempio n. 6
0
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);
    }
}
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);
}
Esempio n. 8
0
/**
*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();
	}
}
Esempio n. 9
0
// 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();
}
Esempio n. 10
0
void AvatarService::fetchImageFromServer(const QString& email)
{
    if (get_avatar_req_) {
        if (email == get_avatar_req_->email()) {
            return;
        }
        queue_->enqueue(email);
        return;
    }

    if (!seafApplet->accountManager()->hasAccount())
        return;
    const Account& account = seafApplet->accountManager()->accounts().front();
    qint64 mtime = 0;

    if (autoupdate_db_) {
        char *zql = sqlite3_mprintf("SELECT timestamp FROM Avatar "
                                    "WHERE filename = %Q",
                                    avatarPathForEmail(account, email).toUtf8().data());
        sqlite_foreach_selected_row(autoupdate_db_, zql, loadTimeStampCB, &mtime);
        sqlite3_free(zql);
    }

    get_avatar_req_ = new GetAvatarRequest(account, email, mtime, devicePixelRatio() * kAvatarSize);

    connect(get_avatar_req_, SIGNAL(success(const QImage&)),
            this, SLOT(onGetAvatarSuccess(const QImage&)));
    connect(get_avatar_req_, SIGNAL(failed(const ApiError&)),
            this, SLOT(onGetAvatarFailed(const ApiError&)));

    get_avatar_req_->send();
}
Esempio n. 11
0
      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);
      }
Esempio n. 12
0
/**
 * @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;
}
Esempio n. 13
0
      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;
        }
      }
Esempio n. 14
0
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;
}
Esempio n. 15
0
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;
}
Esempio n. 16
0
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);
}
void RasterWindow::paintEvent(QPaintEvent * event)
{
    QRect r = event->rect();
    QPainter p(this);

    QColor fillColor(0, 102, 153);
    QColor fillColor2(0, 85, 123);

    int tileSize = 40;
    for (int i = -tileSize * 2; i < r.width() + tileSize * 2; i += tileSize) {
        for (int j = -tileSize * 2; j < r.height() + tileSize * 2; j += tileSize) {
            QRect rect(i + (m_offset.x() % tileSize * 2), j + (m_offset.y() % tileSize * 2), tileSize, tileSize);
            int colorIndex = abs((i/tileSize - j/tileSize) % 2);
            p.fillRect(rect, colorIndex == 0 ? fillColor : fillColor2);
        }
    }

    QRect g = geometry();
    QRect sg = this->screen()->geometry();
    QString text;
    text += QString("Window Geometry: %1 %2 %3 %4\n").arg(g.x()).arg(g.y()).arg(g.width()).arg(g.height());
    text += QString("Window devicePixelRatio: %1\n").arg(devicePixelRatio());
    text += QString("Screen Geometry: %1 %2 %3 %4\n").arg(sg.x()).arg(sg.y()).arg(sg.width()).arg(sg.height());
    text += QString("Received Event Count: %1\n").arg(m_eventCount);

    p.drawText(QRectF(0, 0, width(), height()), Qt::AlignCenter, text);
}
Esempio n. 18
0
double View3D::getDevicePixelRatio()
{
#ifdef DISPLAZ_USE_QT4
    return 1.0;
#else
    return devicePixelRatio();
#endif
}
Esempio n. 19
0
qreal MapWindow::pixelRatio() {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
    return devicePixelRatioF();
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    return devicePixelRatio();
#else
    return 1;
#endif
}
Esempio n. 20
0
const ezObjectPickingResult& ezQtEngineViewWidget::PickObject(ezUInt16 uiScreenPosX, ezUInt16 uiScreenPosY) const
{
  if (!ezEditorEngineProcessConnection::GetSingleton()->IsEngineSetup())
  {
    m_LastPickingResult.Reset();
  }
  else
  {
    ezViewPickingMsgToEngine msg;
    msg.m_uiViewID = GetViewID();
    msg.m_uiPickPosX = uiScreenPosX * devicePixelRatio();
    msg.m_uiPickPosY = uiScreenPosY * devicePixelRatio();

    GetDocumentWindow()->GetDocument()->SendMessageToEngine(&msg);
  }

  return m_LastPickingResult;
}
Esempio n. 21
0
qreal MapWindow::pixelRatio() {
#if QT_VERSION >= 0x050600
    return devicePixelRatioF();
#elif QT_VERSION >= 0x050000
    return devicePixelRatio();
#else
    return 1;
#endif
}
Esempio n. 22
0
void QTestWindow::draw() {
    if (!isVisible()) {
        return;
    }

    makeCurrent();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());

    _context.swapBuffers(this);
    glFinish();

    fps.increment();
    if (fps.elapsed() >= 2.0f) {
        qDebug() << "FPS: " << fps.rate();
        fps.reset();
    }
}
Esempio n. 23
0
void RenderWidget::PassEventToImGui(const QEvent* event)
{
  if (!Core::IsRunningAndStarted())
    return;

  switch (event->type())
  {
  case QEvent::KeyPress:
  case QEvent::KeyRelease:
  {
    // As the imgui KeysDown array is only 512 elements wide, and some Qt keys which
    // we need to track (e.g. alt) are above this value, we mask the lower 9 bits.
    // Even masked, the key codes are still unique, so conflicts aren't an issue.
    // The actual text input goes through AddInputCharactersUTF8().
    const QKeyEvent* key_event = static_cast<const QKeyEvent*>(event);
    const bool is_down = event->type() == QEvent::KeyPress;
    const u32 key = static_cast<u32>(key_event->key() & 0x1FF);
    auto lock = g_renderer->GetImGuiLock();
    if (key < ArraySize(ImGui::GetIO().KeysDown))
      ImGui::GetIO().KeysDown[key] = is_down;

    if (is_down)
    {
      auto utf8 = key_event->text().toUtf8();
      ImGui::GetIO().AddInputCharactersUTF8(utf8.constData());
    }
  }
  break;

  case QEvent::MouseMove:
  {
    auto lock = g_renderer->GetImGuiLock();

    // Qt multiplies all coordinates by the scaling factor in highdpi mode, giving us "scaled" mouse
    // coordinates (as if the screen was standard dpi). We need to update the mouse position in
    // native coordinates, as the UI (and game) is rendered at native resolution.
    const float scale = devicePixelRatio();
    ImGui::GetIO().MousePos.x = static_cast<const QMouseEvent*>(event)->x() * scale;
    ImGui::GetIO().MousePos.y = static_cast<const QMouseEvent*>(event)->y() * scale;
  }
  break;

  case QEvent::MouseButtonPress:
  case QEvent::MouseButtonRelease:
  {
    auto lock = g_renderer->GetImGuiLock();
    const u32 button_mask = static_cast<u32>(static_cast<const QMouseEvent*>(event)->buttons());
    for (size_t i = 0; i < ArraySize(ImGui::GetIO().MouseDown); i++)
      ImGui::GetIO().MouseDown[i] = (button_mask & (1u << i)) != 0;
  }
  break;

  default:
    break;
  }
}
void GameWindow::render(){
    const qreal retinaScale = devicePixelRatio();
    glViewport(0, 0, width() * retinaScale, height() * retinaScale);

    glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);

    glClearColor(0.1, 0.1, 0.1, 1.0);

}
Esempio n. 25
0
void LitSphereWidget::paintGL()
{
    if( !isShowing() || !isExposed())
        return;

    glcontext->makeCurrent(this);

    float useTheta = inTheta;
    if( doubleTheta )
        useTheta *= 2.0;

    incidentVector[0] = sin(useTheta) * cos(inPhi);
    incidentVector[1] = sin(useTheta) * sin(inPhi);
    incidentVector[2] = cos(useTheta);

    glf->glClearColor( 0.25, 0.25, 0.25, 1 );
    glf->glEnable(GL_DEPTH_TEST);
    glf->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    float fWidth = float(width()*devicePixelRatio());
    float fHeight = float(height()*devicePixelRatio());

    glf->glViewport(0, 0, fWidth, fHeight);

    if( width() > height() )
    {
        float aspect = fWidth / fHeight;
        projectionMatrix = glm::ortho( -aspect * sphereMargin, aspect * sphereMargin, -sphereMargin, sphereMargin, NEAR_PLANE, FAR_PLANE );
    }
    else
    {
        float invAspect = fHeight / fWidth;
        projectionMatrix = glm::ortho( -sphereMargin, sphereMargin, -invAspect * sphereMargin, invAspect * sphereMargin, NEAR_PLANE, FAR_PLANE );
    }

    modelViewMatrix = glm::lookAt( glm::vec3(0, 0, 2.75), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));

    if( brdfs.size() )
        drawSphere( 1.0, 100, 100 );

    glcontext->swapBuffers(this);
}
Esempio n. 26
0
void QMLProfile::paint(QPainter *painter)
{
	// let's look at the intended size of the content and scale our scene accordingly
	QRect painterRect = painter->viewport();
	QRect profileRect = m_profileWidget->viewport()->rect();
	// qDebug() << "profile viewport and painter viewport" << profileRect << painterRect;
	qreal sceneSize = 104; // that should give us 2% margin all around (100x100 scene)
	qreal dprComp =  devicePixelRatio() * painterRect.width() / profileRect.width();
	qreal sx = painterRect.width() / sceneSize / dprComp;
	qreal sy = painterRect.height() / sceneSize / dprComp;

	// next figure out the weird magic by which we need to shift the painter so the profile is shown
	int dpr = rint(devicePixelRatio());
	qreal magicShiftFactor = (dpr == 2 ? 0.25 : (dpr == 3 ? 0.33 : 0.0));

	// now set up the transformations scale the profile and
	// shift the painter (taking its existing transformation into account)
	QTransform profileTransform = QTransform();
	profileTransform.scale(sx, sy);
	QTransform painterTransform = painter->transform();
	painterTransform.translate(-painterRect.width() * magicShiftFactor ,-painterRect.height() * magicShiftFactor);

#if PROFILE_SCALING_DEBUG
	// some debugging messages to help adjust this in case the magic above is insufficient
	QMLManager::instance()->appendTextToLog(QString("dpr %1 profile viewport %2 %3 painter viewport %4 %5").arg(dpr).arg(profileRect.width()).arg(profileRect.height())
						.arg(painterRect.width()).arg(painterRect.height()));
	QMLManager::instance()->appendTextToLog(QString("profile matrix %1 %2 %3 %4 %5 %6 %7 %8 %9").arg(profileTransform.m11()).arg(profileTransform.m12()).arg(profileTransform.m13())
						.arg(profileTransform.m21()).arg(profileTransform.m22()).arg(profileTransform.m23())
						.arg(profileTransform.m31()).arg(profileTransform.m32()).arg(profileTransform.m33()));
	QMLManager::instance()->appendTextToLog(QString("painter matrix %1 %2 %3 %4 %5 %6 %7 %8 %9").arg(painterTransform.m11()).arg(painterTransform.m12()).arg(painterTransform.m13())
						.arg(painterTransform.m21()).arg(painterTransform.m22()).arg(painterTransform.m23())
						.arg(painterTransform.m31()).arg(painterTransform.m32()).arg(painterTransform.m33()));
	qDebug() << "profile scaled by" << profileTransform.m11() << profileTransform.m22() << "and translated by" << profileTransform.m31() << profileTransform.m32();
	qDebug() << "exist profile transform" << m_profileWidget->transform() << "painter transform" << painter->transform();
#endif
	// apply the transformation
	painter->setTransform(painterTransform);
	m_profileWidget->setTransform(profileTransform);

	// finally, render the profile
	m_profileWidget->render(painter);
}
Esempio n. 27
0
void PlotCartesianWidget::paintGL()
{
    if( !isShowing() || !isExposed())
        return;

    glcontext->makeCurrent(this);

    glf->glClearColor(1,1,1,1);
    glf->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glf->glDisable(GL_DEPTH_TEST);

    float currentFWidth = float(width()*devicePixelRatio());
    float currentFHeight = float(height()*devicePixelRatio());
    if(currentFWidth != fWidth || currentFHeight != fHeight)
    {
        fWidth = currentFWidth;
        fHeight = currentFHeight;
        mAspect = fWidth / fHeight;
        updateInputDataLineVAO();
        updateProjectionMatrix();
    }

    glf->glViewport(0, 0, fWidth, fHeight);
    glf->glEnable(GL_MULTISAMPLE);

    drawAxis();
    drawLabels();

    glf->glBindVertexArray(dataLineVAO);
    for( int i = 0; i < (int)brdfs.size(); i++ )
    {
        DGLShader* shader = updateShader( brdfs[i] );
        glf->glDrawArrays(GL_LINE_STRIP_ADJACENCY, 0,  dataLineNPoints);
        shader->disable();
    }
    glf->glBindVertexArray(0);

    glf->glDisable(GL_BLEND);
    glf->glEnable(GL_DEPTH_TEST);

    glcontext->swapBuffers(this);
}
Esempio n. 28
0
void BaseGuiApp::initSubsystems(SubsystemInitFlags flags)
{
    GuiApp::initSubsystems(flags);

#ifdef DENG2_QT_5_0_OR_NEWER
    // The device pixel ratio.
    scriptSystem().nativeModule("DisplayMode").set("DPI_FACTOR", devicePixelRatio());
#endif

    d->uiState.reset(new PersistentState("UIState"));
}
Esempio n. 29
0
void GLWidget::paintEvent(QPaintEvent *event)
{
    makeCurrent();
//! [4]
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
//! [4]

//! [6]
    qglClearColor(qtPurple.dark());
    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_MULTISAMPLE);
    static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

    qreal pixelRatio = devicePixelRatio();
    setupViewport(width() * pixelRatio, height() * pixelRatio);
//! [6]

//! [7]
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -10.0);
    glRotatef(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotatef(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotatef(zRot / 16.0, 0.0, 0.0, 1.0);

    logo->draw();
//! [7]

//! [8]
    glShadeModel(GL_FLAT);
    glDisable(GL_CULL_FACE);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);

    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
//! [8]

//! [10]
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    foreach (Bubble *bubble, bubbles) {
        if (bubble->rect().intersects(event->rect()))
            bubble->drawBubble(&painter);
    }
    drawInstructions(&painter);
    painter.end();
}
Esempio n. 30
0
void BrowserWindow::render()
{
    const qreal retinaScale = devicePixelRatio();
    glViewport(0, 0, width() * retinaScale, height() * retinaScale);

    glClear(GL_COLOR_BUFFER_BIT);
    if (m_timer.isActive()) {
        qDebug() << "* rendering";
        m_mozView.RenderToCurrentContext();
    }
}