From 07ecaac5989fcd408bcec7dfff17f1f540150bc8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 18 Apr 2020 00:17:17 +0200 Subject: [PATCH] Enhancements. --- src/plugins/tools/view_25d/lay_plugin/layD25View.cc | 3 +-- .../tools/view_25d/lay_plugin/layD25ViewWidget.cc | 9 ++++----- src/plugins/tools/view_25d/view_25d.pro | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index f10ae46ac..94855b6e0 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -39,10 +39,8 @@ D25View::D25View (QWidget *parent) mp_ui = new Ui::D25View (); mp_ui->setupUi (this); - // @@@ should be an event filter? mp_ui->d25_view->setFocusPolicy (Qt::StrongFocus); mp_ui->d25_view->setFocus (); - // @@@ connect (mp_ui->fit_back, SIGNAL (clicked ()), this, SLOT (fit_button_clicked ())); connect (mp_ui->fit_front, SIGNAL (clicked ()), this, SLOT (fit_button_clicked ())); @@ -103,6 +101,7 @@ D25View::exec_dialog (lay::LayoutView *view) mp_ui->d25_view->reset (); mp_ui->d25_view->set_cam_azimuth (0.0); mp_ui->d25_view->set_cam_elevation (initial_elevation); + mp_ui->d25_view->fit (); int ret = QDialog::exec (); diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 01d5afdec..8dbe74798 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -731,7 +731,7 @@ D25ViewWidget::initializeGL () " vec4 p2 = gl_in[2].gl_Position;\n" " vec3 n = cross(p2.xyz - p0.xyz, p1.xyz - p0.xyz);\n" " float dp = dot(normalize(n), illum);\n" - " vertexColor = color * (dp * 0.5 + 0.5) - (min(0.0, dp) * 0.5 * ambient);\n" + " vertexColor = color * (dp * 0.5 + 0.5) - (min(0.0, dp) * ambient);\n" " vertexColor.a = 1.0;\n" " gl_Position = matrix * p0;\n" " EmitVertex();\n" @@ -827,14 +827,13 @@ D25ViewWidget::paintGL () const qreal retinaScale = devicePixelRatio (); glViewport (0, 0, width () * retinaScale, height () * retinaScale); - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - QColor c = mp_view->background_color (); float foreground_rgb = (c.green () > 128 ? 0.0f : 1.0f); - float ambient = (c.green () > 128 ? 1.0f : 0.5f); + float ambient = (c.green () > 128 ? 0.8f : 0.25f); float mist_factor = (c.green () > 128 ? 0.2f : 0.4f); float mist_add = (c.green () > 128 ? 0.8f : 0.2f); glClearColor (float (c.red ()) / 255.0f, float (c.green ()) / 255.0f, float (c.blue ()) / 255.0f, 1.0); + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); QMatrix4x4 scene_trans, scene_trans_wo_y; @@ -858,7 +857,7 @@ D25ViewWidget::paintGL () // NOTE: z axis of illum points towards the scene because we include the z inversion in the scene transformation matrix m_shapes_program->setUniformValue ("illum", QVector3D (-3.0, -4.0, 2.0).normalized ()); - m_shapes_program->setUniformValue ("ambient", QVector4D (ambient, ambient, ambient, 0.5)); + m_shapes_program->setUniformValue ("ambient", QVector4D (ambient, ambient, ambient, 1.0)); m_shapes_program->setUniformValue ("mist_factor", mist_factor); m_shapes_program->setUniformValue ("mist_add", mist_add); diff --git a/src/plugins/tools/view_25d/view_25d.pro b/src/plugins/tools/view_25d/view_25d.pro index 1f10c85ca..30278d0c8 100644 --- a/src/plugins/tools/view_25d/view_25d.pro +++ b/src/plugins/tools/view_25d/view_25d.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -!equals(HAVE_QT, "0") { +equals(HAVE_QT5, "1") { SUBDIRS = lay_plugin unit_tests }