make box, axes, ssao, antialias checkable buttons in image viewer

this reduces the antialias option to just 2x
This commit is contained in:
Axel Kohlmeyer
2023-08-14 21:37:46 -04:00
parent c11c51ba3c
commit e51845776d
10 changed files with 83 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -31,14 +31,14 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
columns = new QComboBox; columns = new QComboBox;
top->addWidget(menu); top->addWidget(menu);
top->addWidget(columns); top->addWidget(columns);
saveAsAct = file->addAction("&Save Graph As...", this, &ChartWindow::saveAs); saveAsAct = file->addAction("&Save Graph As...", this, &ChartWindow::saveAs);
saveAsAct->setIcon(QIcon(":/document-save-as.png")); saveAsAct->setIcon(QIcon(":/document-save-as.png"));
exportCsvAct = file->addAction("&Export data to CSV...", this, &ChartWindow::exportCsv); exportCsvAct = file->addAction("&Export data to CSV...", this, &ChartWindow::exportCsv);
exportCsvAct->setIcon(QIcon(":/application-calc.png")); exportCsvAct->setIcon(QIcon(":/application-calc.png"));
exportDatAct = file->addAction("Export data to &Gnuplot...", this, &ChartWindow::exportDat); exportDatAct = file->addAction("Export data to &Gnuplot...", this, &ChartWindow::exportDat);
exportDatAct->setIcon(QIcon(":/application-plot.png")); exportDatAct->setIcon(QIcon(":/application-plot.png"));
file->addSeparator(); file->addSeparator();
closeAct = file->addAction("&Close", this, &QWidget::close); closeAct = file->addAction("&Close", this, &QWidget::close);
closeAct->setIcon(QIcon(":/window-close.png")); closeAct->setIcon(QIcon(":/window-close.png"));
auto *layout = new QVBoxLayout; auto *layout = new QVBoxLayout;
layout->addLayout(top); layout->addLayout(top);

BIN
tools/lammps-gui/hd-img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -58,6 +58,14 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
auto *dossao = new QPushButton(QIcon(":/hd-img.png"), "");
dossao->setCheckable(true);
auto *doanti = new QPushButton(QIcon(":/antialias.png"), "");
doanti->setCheckable(true);
auto *dobox = new QPushButton(QIcon(":/system-box.png"), "");
dobox->setCheckable(true);
auto *doaxes = new QPushButton(QIcon(":/axes-img.png"), "");
doaxes->setCheckable(true);
auto *zoomin = new QPushButton(QIcon(":/gtk-zoom-in.png"), ""); auto *zoomin = new QPushButton(QIcon(":/gtk-zoom-in.png"), "");
auto *zoomout = new QPushButton(QIcon(":/gtk-zoom-out.png"), ""); auto *zoomout = new QPushButton(QIcon(":/gtk-zoom-out.png"), "");
auto *rotleft = new QPushButton(QIcon(":/object-rotate-left.png"), ""); auto *rotleft = new QPushButton(QIcon(":/object-rotate-left.png"), "");
@ -75,6 +83,10 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
QHBoxLayout *menuLayout = new QHBoxLayout; QHBoxLayout *menuLayout = new QHBoxLayout;
menuLayout->addWidget(menuBar); menuLayout->addWidget(menuBar);
menuLayout->addWidget(dossao);
menuLayout->addWidget(doanti);
menuLayout->addWidget(dobox);
menuLayout->addWidget(doaxes);
menuLayout->addWidget(zoomin); menuLayout->addWidget(zoomin);
menuLayout->addWidget(zoomout); menuLayout->addWidget(zoomout);
menuLayout->addWidget(rotleft); menuLayout->addWidget(rotleft);
@ -84,6 +96,10 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
menuLayout->addWidget(new QLabel(" Group: ")); menuLayout->addWidget(new QLabel(" Group: "));
menuLayout->addWidget(combo); menuLayout->addWidget(combo);
connect(dossao, &QPushButton::released, this, &ImageViewer::toggle_ssao);
connect(doanti, &QPushButton::released, this, &ImageViewer::toggle_anti);
connect(dobox, &QPushButton::released, this, &ImageViewer::toggle_box);
connect(doaxes, &QPushButton::released, this, &ImageViewer::toggle_axes);
connect(zoomin, &QPushButton::released, this, &ImageViewer::do_zoom_in); connect(zoomin, &QPushButton::released, this, &ImageViewer::do_zoom_in);
connect(zoomout, &QPushButton::released, this, &ImageViewer::do_zoom_out); connect(zoomout, &QPushButton::released, this, &ImageViewer::do_zoom_out);
connect(rotleft, &QPushButton::released, this, &ImageViewer::do_rot_left); connect(rotleft, &QPushButton::released, this, &ImageViewer::do_rot_left);
@ -99,9 +115,13 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
QSettings settings; QSettings settings;
settings.beginGroup("snapshot"); settings.beginGroup("snapshot");
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();
showbox = settings.value("box", true).toBool();
dobox->setChecked(showbox);
showaxes = settings.value("axes", false).toBool();
doaxes->setChecked(showaxes);
settings.endGroup(); settings.endGroup();
createActions(); createActions();
@ -117,6 +137,38 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
setLayout(mainLayout); setLayout(mainLayout);
} }
void ImageViewer::toggle_ssao()
{
QPushButton *button = qobject_cast<QPushButton *>(sender());
usessao = !usessao;
button->setChecked(usessao);
createImage();
}
void ImageViewer::toggle_anti()
{
QPushButton *button = qobject_cast<QPushButton *>(sender());
antialias = !antialias;
button->setChecked(antialias);
createImage();
}
void ImageViewer::toggle_box()
{
QPushButton *button = qobject_cast<QPushButton *>(sender());
showbox = !showbox;
button->setChecked(showbox);
createImage();
}
void ImageViewer::toggle_axes()
{
QPushButton *button = qobject_cast<QPushButton *>(sender());
showaxes = !showaxes;
button->setChecked(showaxes);
createImage();
}
void ImageViewer::do_zoom_in() void ImageViewer::do_zoom_in()
{ {
zoom = zoom * 1.1; zoom = zoom * 1.1;
@ -175,7 +227,7 @@ void ImageViewer::createImage()
dumpcmd += dumpfile.fileName(); dumpcmd += dumpfile.fileName();
settings.beginGroup("snapshot"); settings.beginGroup("snapshot");
int aa = settings.value("antialias", 0).toInt() + 1; int aa = antialias ? 2 : 1;
int xsize = settings.value("xsize", 800).toInt() * aa; int xsize = settings.value("xsize", 800).toInt() * aa;
int ysize = settings.value("ysize", 600).toInt() * aa; int ysize = settings.value("ysize", 600).toInt() * aa;
int hhrot = (hrot > 180) ? 360 - hrot : hrot; int hhrot = (hrot > 180) ? 360 - hrot : hrot;
@ -188,16 +240,18 @@ void ImageViewer::createImage()
if (lammps->extract_setting("dimension") == 3) { if (lammps->extract_setting("dimension") == 3) {
dumpcmd += QString(" view ") + QString::number(hhrot) + blank + QString::number(vrot); dumpcmd += QString(" view ") + QString::number(hhrot) + blank + QString::number(vrot);
} }
if (settings.value("ssao", false).toBool()) dumpcmd += QString(" ssao yes 453983 0.6"); if (usessao) dumpcmd += QString(" ssao yes 453983 0.75");
if (settings.value("box", true).toBool()) if (showbox)
dumpcmd += QString(" box yes 0.02"); dumpcmd += QString(" box yes 0.025");
else else
dumpcmd += QString(" box no 0.0"); dumpcmd += QString(" box no 0.0");
if (settings.value("axes", true).toBool())
dumpcmd += QString(" axes yes 0.2 0.02"); if (showaxes)
dumpcmd += QString(" axes yes 0.2 0.025");
else else
dumpcmd += QString(" axes no 0.0 0.0"); dumpcmd += QString(" axes no 0.0 0.0");
dumpcmd += " modify boxcolor silver";
settings.endGroup(); settings.endGroup();
lammps->command(dumpcmd.toLocal8Bit()); lammps->command(dumpcmd.toLocal8Bit());

View File

@ -45,6 +45,10 @@ private slots:
void normalSize(); void normalSize();
void fitToWindow(); void fitToWindow();
void toggle_ssao();
void toggle_anti();
void toggle_box();
void toggle_axes();
void do_zoom_in(); void do_zoom_in();
void do_zoom_out(); void do_zoom_out();
void do_rot_left(); void do_rot_left();
@ -83,6 +87,7 @@ private:
QString filename; QString filename;
int hrot, vrot; int hrot, vrot;
double zoom; double zoom;
bool showbox, showaxes, antialias, usessao;
}; };
#endif #endif

View File

@ -179,8 +179,8 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
#endif #endif
lammpsstatus = new QLabel(QString()); lammpsstatus = new QLabel(QString());
auto pix = QPixmap(":/lammps-icon-128x128.png"); auto pix = QPixmap(":/lammps-icon-128x128.png");
lammpsstatus->setPixmap(pix.scaled(22,22,Qt::KeepAspectRatio)); lammpsstatus->setPixmap(pix.scaled(22, 22, Qt::KeepAspectRatio));
ui->statusbar->addWidget(lammpsstatus); ui->statusbar->addWidget(lammpsstatus);
lammpsstatus->hide(); lammpsstatus->hide();
status = new QLabel("Ready."); status = new QLabel("Ready.");
@ -935,9 +935,10 @@ void LammpsGui::preferences()
if ((oldaccel != settings.value("accelerator", AcceleratorTab::None).toInt()) || if ((oldaccel != settings.value("accelerator", AcceleratorTab::None).toInt()) ||
(oldthreads != settings.value("nthreads", 1).toInt()) || (oldthreads != settings.value("nthreads", 1).toInt()) ||
(oldecho != settings.value("echo", 0).toInt()) || (oldecho != settings.value("echo", 0).toInt()) ||
(oldcite != settings.value("cite", 0).toInt())) (oldcite != settings.value("cite", 0).toInt())) {
lammps.close(); lammps.close();
lammpsstatus->hide(); lammpsstatus->hide();
}
if (imagewindow) imagewindow->createImage(); if (imagewindow) imagewindow->createImage();
} }
} }

View File

@ -37,5 +37,9 @@
<file>window-close.png</file> <file>window-close.png</file>
<file>application-plot.png</file> <file>application-plot.png</file>
<file>application-calc.png</file> <file>application-calc.png</file>
<file>system-box.png</file>
<file>axes-img.png</file>
<file>hd-img.png</file>
<file>antialias.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -112,9 +112,9 @@ void Preferences::accept()
field = tabWidget->findChild<QLineEdit *>("zoom"); field = tabWidget->findChild<QLineEdit *>("zoom");
if (field) if (field)
if (field->hasAcceptableInput()) settings->setValue("zoom", field->text()); if (field->hasAcceptableInput()) settings->setValue("zoom", field->text());
QComboBox *combo = tabWidget->findChild<QComboBox *>("anti"); QCheckBox *box = tabWidget->findChild<QCheckBox *>("anti");
if (combo) settings->setValue("antialias", combo->currentIndex()); if (box) settings->setValue("antialias", box->isChecked());
QCheckBox *box = tabWidget->findChild<QCheckBox *>("ssao"); box = tabWidget->findChild<QCheckBox *>("ssao");
if (box) settings->setValue("ssao", box->isChecked()); if (box) settings->setValue("ssao", box->isChecked());
box = tabWidget->findChild<QCheckBox *>("box"); box = tabWidget->findChild<QCheckBox *>("box");
if (box) settings->setValue("box", box->isChecked()); if (box) settings->setValue("box", box->isChecked());
@ -371,17 +371,13 @@ SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) :
auto *xval = new QLineEdit(settings->value("xsize", "800").toString()); auto *xval = new QLineEdit(settings->value("xsize", "800").toString());
auto *yval = new QLineEdit(settings->value("ysize", "600").toString()); auto *yval = new QLineEdit(settings->value("ysize", "600").toString());
auto *zval = new QLineEdit(settings->value("zoom", "1.0").toString()); auto *zval = new QLineEdit(settings->value("zoom", "1.0").toString());
auto *aval = new QComboBox; auto *aval = new QCheckBox;
auto *sval = new QCheckBox; auto *sval = new QCheckBox;
auto *bval = new QCheckBox; auto *bval = new QCheckBox;
auto *eval = new QCheckBox; auto *eval = new QCheckBox;
sval->setCheckState(settings->value("ssao", false).toBool() ? Qt::Checked : Qt::Unchecked); sval->setCheckState(settings->value("ssao", false).toBool() ? Qt::Checked : Qt::Unchecked);
sval->setObjectName("ssao"); sval->setObjectName("ssao");
aval->addItem("1x", 1); aval->setCheckState(settings->value("antialias", false).toBool() ? Qt::Checked : Qt::Unchecked);
aval->addItem("2x", 2);
aval->addItem("3x", 3);
aval->addItem("4x", 4);
aval->setCurrentIndex(settings->value("antialias", "0").toInt());
aval->setObjectName("anti"); aval->setObjectName("anti");
bval->setCheckState(settings->value("box", true).toBool() ? Qt::Checked : Qt::Unchecked); bval->setCheckState(settings->value("box", true).toBool() ? Qt::Checked : Qt::Unchecked);
bval->setObjectName("box"); bval->setObjectName("box");

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB