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