diff --git a/tools/lammps-gui/imageviewer.cpp b/tools/lammps-gui/imageviewer.cpp index af7e22128a..4841d651d0 100644 --- a/tools/lammps-gui/imageviewer.cpp +++ b/tools/lammps-gui/imageviewer.cpp @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -150,9 +152,11 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge QSettings settings; - vdwfactor = 0.5; - auto pix = QPixmap(":/icons/emblem-photos.png"); + vdwfactor = 0.5; + shinyfactor = 0.6; + auto pix = QPixmap(":/icons/emblem-photos.png"); xcenter = ycenter = zcenter = 0.5; + auto bsize = QFontMetrics(QApplication::font()).size(Qt::TextSingleLine, "Height: 200"); auto *renderstatus = new QLabel(QString()); renderstatus->setPixmap(pix.scaled(22, 22, Qt::KeepAspectRatio)); @@ -166,19 +170,23 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge xval->setValue(settings.value("xsize", "800").toInt()); xval->setObjectName("xsize"); xval->setToolTip("Set rendered image width"); + xval->setMinimumSize(bsize); auto *yval = new QSpinBox; yval->setRange(100, 10000); yval->setStepType(QAbstractSpinBox::AdaptiveDecimalStepType); yval->setValue(settings.value("ysize", "600").toInt()); yval->setObjectName("ysize"); yval->setToolTip("Set rendered image height"); + yval->setMinimumSize(bsize); settings.endGroup(); connect(xval, &QAbstractSpinBox::editingFinished, this, &ImageViewer::edit_size); connect(yval, &QAbstractSpinBox::editingFinished, this, &ImageViewer::edit_size); // workaround for incorrect highlight bug on macOS - auto *dummy = new QPushButton(QIcon(), ""); - dummy->hide(); + auto *dummy1 = new QPushButton(QIcon(), ""); + dummy1->hide(); + auto *dummy2 = new QPushButton(QIcon(), ""); + dummy2->hide(); auto *dossao = new QPushButton(QIcon(":/icons/hd-img.png"), ""); dossao->setCheckable(true); @@ -188,6 +196,10 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge doanti->setCheckable(true); doanti->setToolTip("Toggle anti-aliasing"); doanti->setObjectName("antialias"); + auto *doshiny = new QPushButton(QIcon(":/icons/image-shiny.png"), ""); + doshiny->setCheckable(true); + doshiny->setToolTip("Toggle shininess"); + doshiny->setObjectName("shiny"); auto *dovdw = new QPushButton(QIcon(":/icons/vdw-style.png"), ""); dovdw->setCheckable(true); dovdw->setToolTip("Toggle VDW style representation"); @@ -229,32 +241,41 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge combo->addItem(gname); } - auto *menuLayout = new QHBoxLayout; + auto *menuLayout = new QHBoxLayout; + auto *buttonLayout = new QHBoxLayout; + auto *topLayout = new QVBoxLayout; + topLayout->addLayout(menuLayout); + topLayout->addLayout(buttonLayout); + menuLayout->addWidget(menuBar); menuLayout->addWidget(renderstatus); menuLayout->addWidget(new QLabel(" Width: ")); menuLayout->addWidget(xval); menuLayout->addWidget(new QLabel(" Height: ")); menuLayout->addWidget(yval); - menuLayout->addWidget(dummy); - menuLayout->addWidget(dossao); - menuLayout->addWidget(doanti); - menuLayout->addWidget(dovdw); - menuLayout->addWidget(dobox); - menuLayout->addWidget(doaxes); - menuLayout->addWidget(zoomin); - menuLayout->addWidget(zoomout); - menuLayout->addWidget(rotleft); - menuLayout->addWidget(rotright); - menuLayout->addWidget(rotup); - menuLayout->addWidget(rotdown); - menuLayout->addWidget(recenter); - menuLayout->addWidget(reset); + menuLayout->addWidget(dummy1); menuLayout->addWidget(new QLabel(" Group: ")); menuLayout->addWidget(combo); + buttonLayout->addWidget(dummy2); + buttonLayout->addWidget(dossao); + buttonLayout->addWidget(doanti); + buttonLayout->addWidget(doshiny); + buttonLayout->addWidget(dovdw); + buttonLayout->addWidget(dobox); + buttonLayout->addWidget(doaxes); + buttonLayout->addWidget(zoomin); + buttonLayout->addWidget(zoomout); + buttonLayout->addWidget(rotleft); + buttonLayout->addWidget(rotright); + buttonLayout->addWidget(rotup); + buttonLayout->addWidget(rotdown); + buttonLayout->addWidget(recenter); + buttonLayout->addWidget(reset); + buttonLayout->addStretch(1); connect(dossao, &QPushButton::released, this, &ImageViewer::toggle_ssao); connect(doanti, &QPushButton::released, this, &ImageViewer::toggle_anti); + connect(doshiny, &QPushButton::released, this, &ImageViewer::toggle_shiny); connect(dovdw, &QPushButton::released, this, &ImageViewer::toggle_vdw); connect(dobox, &QPushButton::released, this, &ImageViewer::toggle_box); connect(doaxes, &QPushButton::released, this, &ImageViewer::toggle_axes); @@ -268,7 +289,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge connect(reset, &QPushButton::released, this, &ImageViewer::reset_view); connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(change_group(int))); - mainLayout->addLayout(menuLayout); + mainLayout->addLayout(topLayout); mainLayout->addWidget(scrollArea); setWindowIcon(QIcon(":/icons/lammps-icon-128x128.png")); setWindowTitle(QString("LAMMPS-GUI - Image Viewer - ") + QFileInfo(fileName).fileName()); @@ -278,6 +299,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge // layout has not yet be established, so we need to fix up some pushbutton // properties directly since lookup in reset_view() will have failed dobox->setChecked(showbox); + doshiny->setChecked(shinyfactor > 0.4); dovdw->setChecked(vdwfactor > 1.0); dovdw->setEnabled(useelements || usediameter || usesigma); doaxes->setChecked(showaxes); @@ -296,16 +318,17 @@ void ImageViewer::reset_view() { QSettings settings; settings.beginGroup("snapshot"); - xsize = settings.value("xsize", "800").toInt(); - ysize = settings.value("ysize", "600").toInt(); - zoom = settings.value("zoom", 1.0).toDouble(); - hrot = settings.value("hrot", 60).toInt(); - vrot = settings.value("vrot", 30).toInt(); - vdwfactor = settings.value("vdwstyle", false).toBool() ? 1.6 : 0.5; - showbox = settings.value("box", true).toBool(); - showaxes = settings.value("axes", false).toBool(); - usessao = settings.value("ssao", false).toBool(); - antialias = settings.value("antialias", false).toBool(); + xsize = settings.value("xsize", "800").toInt(); + ysize = settings.value("ysize", "600").toInt(); + zoom = settings.value("zoom", 1.0).toDouble(); + hrot = settings.value("hrot", 60).toInt(); + vrot = settings.value("vrot", 30).toInt(); + shinyfactor = settings.value("shinystyle", true).toBool() ? 0.6 : 0.2; + vdwfactor = settings.value("vdwstyle", false).toBool() ? 1.6 : 0.5; + showbox = settings.value("box", true).toBool(); + showaxes = settings.value("axes", false).toBool(); + usessao = settings.value("ssao", false).toBool(); + antialias = settings.value("antialias", false).toBool(); xcenter = ycenter = zcenter = 0.5; settings.endGroup(); @@ -320,6 +343,8 @@ void ImageViewer::reset_view() if (button) button->setChecked(usessao); button = findChild("antialias"); if (button) button->setChecked(antialias); + button = findChild("shiny"); + if (button) button->setChecked(shinyfactor > 0.4); button = findChild("vdw"); if (button) button->setChecked(vdwfactor > 1.0); button = findChild("box"); @@ -358,6 +383,17 @@ void ImageViewer::toggle_anti() createImage(); } +void ImageViewer::toggle_shiny() +{ + auto *button = qobject_cast(sender()); + if (shinyfactor > 0.4) + shinyfactor = 0.2; + else + shinyfactor = 0.6; + button->setChecked(shinyfactor > 0.4); + createImage(); +} + void ImageViewer::toggle_vdw() { auto *button = qobject_cast(sender()); @@ -541,7 +577,7 @@ void ImageViewer::createImage() dumpcmd += blank + settings.value("diameter", "type").toString(); dumpcmd += QString(" size %1 %2").arg(xsize).arg(ysize); dumpcmd += QString(" zoom %1").arg(zoom); - dumpcmd += " shiny 0.5 "; + dumpcmd += QString(" shiny %1 ").arg(shinyfactor); dumpcmd += QString(" fsaa %1").arg(antialias ? "yes" : "no"); if (nbondtypes > 0) { if (vdwfactor > 1.0) diff --git a/tools/lammps-gui/imageviewer.h b/tools/lammps-gui/imageviewer.h index f9b935640e..94632bde89 100644 --- a/tools/lammps-gui/imageviewer.h +++ b/tools/lammps-gui/imageviewer.h @@ -46,6 +46,7 @@ private slots: void reset_view(); void toggle_ssao(); void toggle_anti(); + void toggle_shiny(); void toggle_vdw(); void toggle_box(); void toggle_axes(); @@ -90,7 +91,7 @@ private: QString last_dump_cmd; int xsize, ysize; int hrot, vrot; - double zoom, vdwfactor; + double zoom, vdwfactor, shinyfactor; double xcenter, ycenter, zcenter; bool showbox, showaxes, antialias, usessao, useelements, usediameter, usesigma; }; diff --git a/tools/lammps-gui/lammpsgui.qrc b/tools/lammps-gui/lammpsgui.qrc index eb7c1fbc19..510d86689f 100644 --- a/tools/lammps-gui/lammpsgui.qrc +++ b/tools/lammps-gui/lammpsgui.qrc @@ -42,6 +42,7 @@ icons/help-browser.png icons/help-faq.png icons/help-tutorial.png + icons/image-shiny.png icons/image-x-generic.png icons/media-playback-start-2.png icons/media-playlist-repeat.png