add option to toggle between VDW style representation and licorice style
This commit is contained in:
@ -78,6 +78,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
|
vdwfactor = 0.4;
|
||||||
auto *renderstatus = new QLabel(QString());
|
auto *renderstatus = new QLabel(QString());
|
||||||
auto pix = QPixmap(":/emblem-photos.png");
|
auto pix = QPixmap(":/emblem-photos.png");
|
||||||
renderstatus->setPixmap(pix.scaled(22, 22, Qt::KeepAspectRatio));
|
renderstatus->setPixmap(pix.scaled(22, 22, Qt::KeepAspectRatio));
|
||||||
@ -106,6 +107,9 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
auto *doanti = new QPushButton(QIcon(":/antialias.png"), "");
|
auto *doanti = new QPushButton(QIcon(":/antialias.png"), "");
|
||||||
doanti->setCheckable(true);
|
doanti->setCheckable(true);
|
||||||
doanti->setToolTip("Toggle anti-aliasing");
|
doanti->setToolTip("Toggle anti-aliasing");
|
||||||
|
auto *dovdw = new QPushButton(QIcon(":/vdw-style.png"), "");
|
||||||
|
dovdw->setCheckable(true);
|
||||||
|
dovdw->setToolTip("Toggle VDW style representation");
|
||||||
auto *dobox = new QPushButton(QIcon(":/system-box.png"), "");
|
auto *dobox = new QPushButton(QIcon(":/system-box.png"), "");
|
||||||
dobox->setCheckable(true);
|
dobox->setCheckable(true);
|
||||||
dobox->setToolTip("Toggle displaying box");
|
dobox->setToolTip("Toggle displaying box");
|
||||||
@ -145,6 +149,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
menuLayout->addWidget(yval);
|
menuLayout->addWidget(yval);
|
||||||
menuLayout->addWidget(dossao);
|
menuLayout->addWidget(dossao);
|
||||||
menuLayout->addWidget(doanti);
|
menuLayout->addWidget(doanti);
|
||||||
|
menuLayout->addWidget(dovdw);
|
||||||
menuLayout->addWidget(dobox);
|
menuLayout->addWidget(dobox);
|
||||||
menuLayout->addWidget(doaxes);
|
menuLayout->addWidget(doaxes);
|
||||||
menuLayout->addWidget(zoomin);
|
menuLayout->addWidget(zoomin);
|
||||||
@ -159,6 +164,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
|
|
||||||
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(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);
|
||||||
connect(zoomin, &QPushButton::released, this, &ImageViewer::do_zoom_in);
|
connect(zoomin, &QPushButton::released, this, &ImageViewer::do_zoom_in);
|
||||||
@ -178,6 +184,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
|
|
||||||
reset_view();
|
reset_view();
|
||||||
dobox->setChecked(showbox);
|
dobox->setChecked(showbox);
|
||||||
|
dovdw->setChecked(vdwfactor > 1.0);
|
||||||
doaxes->setChecked(showaxes);
|
doaxes->setChecked(showaxes);
|
||||||
dossao->setChecked(usessao);
|
dossao->setChecked(usessao);
|
||||||
doanti->setChecked(antialias);
|
doanti->setChecked(antialias);
|
||||||
@ -201,6 +208,7 @@ void ImageViewer::reset_view()
|
|||||||
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;
|
||||||
showbox = settings.value("box", true).toBool();
|
showbox = settings.value("box", true).toBool();
|
||||||
showaxes = settings.value("axes", false).toBool();
|
showaxes = settings.value("axes", false).toBool();
|
||||||
usessao = settings.value("ssao", false).toBool();
|
usessao = settings.value("ssao", false).toBool();
|
||||||
@ -223,8 +231,10 @@ void ImageViewer::reset_view()
|
|||||||
button = qobject_cast<QPushButton *>(lo->itemAt(7)->widget());
|
button = qobject_cast<QPushButton *>(lo->itemAt(7)->widget());
|
||||||
button->setChecked(antialias);
|
button->setChecked(antialias);
|
||||||
button = qobject_cast<QPushButton *>(lo->itemAt(8)->widget());
|
button = qobject_cast<QPushButton *>(lo->itemAt(8)->widget());
|
||||||
button->setChecked(showbox);
|
button->setChecked(vdwfactor > 1.0);
|
||||||
button = qobject_cast<QPushButton *>(lo->itemAt(9)->widget());
|
button = qobject_cast<QPushButton *>(lo->itemAt(9)->widget());
|
||||||
|
button->setChecked(showbox);
|
||||||
|
button = qobject_cast<QPushButton *>(lo->itemAt(10)->widget());
|
||||||
button->setChecked(showaxes);
|
button->setChecked(showaxes);
|
||||||
// grab the last entry -> group selector
|
// grab the last entry -> group selector
|
||||||
auto *cb = qobject_cast<QComboBox *>(lo->itemAt(lo->count() - 1)->widget());
|
auto *cb = qobject_cast<QComboBox *>(lo->itemAt(lo->count() - 1)->widget());
|
||||||
@ -261,6 +271,17 @@ void ImageViewer::toggle_anti()
|
|||||||
createImage();
|
createImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageViewer::toggle_vdw()
|
||||||
|
{
|
||||||
|
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
||||||
|
if (vdwfactor > 1.0)
|
||||||
|
vdwfactor = 0.4;
|
||||||
|
else
|
||||||
|
vdwfactor = 1.6;
|
||||||
|
button->setChecked(vdwfactor > 1.0);
|
||||||
|
createImage();
|
||||||
|
}
|
||||||
|
|
||||||
void ImageViewer::toggle_box()
|
void ImageViewer::toggle_box()
|
||||||
{
|
{
|
||||||
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
||||||
@ -333,19 +354,6 @@ void ImageViewer::createImage()
|
|||||||
if (lo) qobject_cast<QLabel *>(lo->itemAt(1)->widget())->setEnabled(true);
|
if (lo) qobject_cast<QLabel *>(lo->itemAt(1)->widget())->setEnabled(true);
|
||||||
this->repaint();
|
this->repaint();
|
||||||
|
|
||||||
int ntypes = lammps->extract_setting("ntypes");
|
|
||||||
double *masses = (double *)lammps->extract_atom("mass");
|
|
||||||
QString units = (const char *)lammps->extract_global("units");
|
|
||||||
QString elements = "element ";
|
|
||||||
QString adiams;
|
|
||||||
if ((units == "real") || (units == "metal")) {
|
|
||||||
for (int i = 1; i <= ntypes; ++i) {
|
|
||||||
int idx = get_pte_from_mass(masses[i]);
|
|
||||||
elements += QString(pte_label[idx]) + blank;
|
|
||||||
adiams += QString("adiam %1 %2 ").arg(i).arg(pte_vdw_radius[idx]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString dumpcmd = QString("write_dump ") + group + " image ";
|
QString dumpcmd = QString("write_dump ") + group + " image ";
|
||||||
QDir dumpdir(QDir::tempPath());
|
QDir dumpdir(QDir::tempPath());
|
||||||
@ -358,6 +366,20 @@ void ImageViewer::createImage()
|
|||||||
int tmpysize = ysize * aa;
|
int tmpysize = ysize * aa;
|
||||||
int hhrot = (hrot > 180) ? 360 - hrot : hrot;
|
int hhrot = (hrot > 180) ? 360 - hrot : hrot;
|
||||||
|
|
||||||
|
// determine elements from masses and set their covalent radii
|
||||||
|
int ntypes = lammps->extract_setting("ntypes");
|
||||||
|
double *masses = (double *)lammps->extract_atom("mass");
|
||||||
|
QString units = (const char *)lammps->extract_global("units");
|
||||||
|
QString elements = "element ";
|
||||||
|
QString adiams;
|
||||||
|
if ((units == "real") || (units == "metal")) {
|
||||||
|
for (int i = 1; i <= ntypes; ++i) {
|
||||||
|
int idx = get_pte_from_mass(masses[i]);
|
||||||
|
elements += QString(pte_label[idx]) + blank;
|
||||||
|
adiams += QString("adiam %1 %2 ").arg(i).arg(vdwfactor * pte_vdw_radius[idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!adiams.isEmpty())
|
if (!adiams.isEmpty())
|
||||||
dumpcmd += blank + "element";
|
dumpcmd += blank + "element";
|
||||||
else
|
else
|
||||||
@ -365,7 +387,7 @@ void ImageViewer::createImage()
|
|||||||
dumpcmd += blank + settings.value("diameter", "type").toString();
|
dumpcmd += blank + settings.value("diameter", "type").toString();
|
||||||
dumpcmd += QString(" size ") + QString::number(tmpxsize) + blank + QString::number(tmpysize);
|
dumpcmd += QString(" size ") + QString::number(tmpxsize) + blank + QString::number(tmpysize);
|
||||||
dumpcmd += QString(" zoom ") + QString::number(zoom);
|
dumpcmd += QString(" zoom ") + QString::number(zoom);
|
||||||
dumpcmd += " shiny 0.5 ";
|
dumpcmd += " shiny 0.5 bond atom 0.4 ";
|
||||||
|
|
||||||
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);
|
||||||
@ -383,7 +405,7 @@ void ImageViewer::createImage()
|
|||||||
|
|
||||||
dumpcmd += " modify boxcolor " + settings.value("boxcolor", "yellow").toString();
|
dumpcmd += " modify boxcolor " + settings.value("boxcolor", "yellow").toString();
|
||||||
dumpcmd += " backcolor " + settings.value("background", "black").toString();
|
dumpcmd += " backcolor " + settings.value("background", "black").toString();
|
||||||
if (!adiams.isEmpty()) dumpcmd += blank + elements + blank + adiams;
|
if (!adiams.isEmpty()) dumpcmd += blank + elements + blank + adiams + blank;
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
lammps->command(dumpcmd.toLocal8Bit());
|
lammps->command(dumpcmd.toLocal8Bit());
|
||||||
|
|||||||
@ -49,6 +49,7 @@ private slots:
|
|||||||
void reset_view();
|
void reset_view();
|
||||||
void toggle_ssao();
|
void toggle_ssao();
|
||||||
void toggle_anti();
|
void toggle_anti();
|
||||||
|
void toggle_vdw();
|
||||||
void toggle_box();
|
void toggle_box();
|
||||||
void toggle_axes();
|
void toggle_axes();
|
||||||
void do_zoom_in();
|
void do_zoom_in();
|
||||||
@ -89,7 +90,7 @@ private:
|
|||||||
QString filename;
|
QString filename;
|
||||||
int xsize, ysize;
|
int xsize, ysize;
|
||||||
int hrot, vrot;
|
int hrot, vrot;
|
||||||
double zoom;
|
double zoom, vdwfactor;
|
||||||
bool showbox, showaxes, antialias, usessao;
|
bool showbox, showaxes, antialias, usessao;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -43,5 +43,6 @@
|
|||||||
<file>antialias.png</file>
|
<file>antialias.png</file>
|
||||||
<file>ovito.png</file>
|
<file>ovito.png</file>
|
||||||
<file>vmd.png</file>
|
<file>vmd.png</file>
|
||||||
|
<file>vdw-style.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@ -138,6 +138,8 @@ void Preferences::accept()
|
|||||||
if (box) settings->setValue("box", box->isChecked());
|
if (box) settings->setValue("box", box->isChecked());
|
||||||
box = tabWidget->findChild<QCheckBox *>("axes");
|
box = tabWidget->findChild<QCheckBox *>("axes");
|
||||||
if (box) settings->setValue("axes", box->isChecked());
|
if (box) settings->setValue("axes", box->isChecked());
|
||||||
|
box = tabWidget->findChild<QCheckBox *>("vdwstyle");
|
||||||
|
if (box) settings->setValue("vdwstyle", box->isChecked());
|
||||||
QComboBox *combo = tabWidget->findChild<QComboBox *>("background");
|
QComboBox *combo = tabWidget->findChild<QComboBox *>("background");
|
||||||
if (combo) settings->setValue("background", combo->currentText());
|
if (combo) settings->setValue("background", combo->currentText());
|
||||||
combo = tabWidget->findChild<QComboBox *>("boxcolor");
|
combo = tabWidget->findChild<QComboBox *>("boxcolor");
|
||||||
@ -395,6 +397,7 @@ SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) :
|
|||||||
auto *ssao = new QLabel("HQ Image mode:");
|
auto *ssao = new QLabel("HQ Image mode:");
|
||||||
auto *bbox = new QLabel("Show Box:");
|
auto *bbox = new QLabel("Show Box:");
|
||||||
auto *axes = new QLabel("Show Axes:");
|
auto *axes = new QLabel("Show Axes:");
|
||||||
|
auto *vdw = new QLabel("VDW Style:");
|
||||||
auto *cback = new QLabel("Background Color:");
|
auto *cback = new QLabel("Background Color:");
|
||||||
auto *cbox = new QLabel("Box Color:");
|
auto *cbox = new QLabel("Box Color:");
|
||||||
settings->beginGroup("snapshot");
|
settings->beginGroup("snapshot");
|
||||||
@ -405,6 +408,7 @@ SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) :
|
|||||||
auto *sval = new QCheckBox;
|
auto *sval = new QCheckBox;
|
||||||
auto *bval = new QCheckBox;
|
auto *bval = new QCheckBox;
|
||||||
auto *eval = new QCheckBox;
|
auto *eval = new QCheckBox;
|
||||||
|
auto *vval = 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->setCheckState(settings->value("antialias", false).toBool() ? Qt::Checked : Qt::Unchecked);
|
aval->setCheckState(settings->value("antialias", false).toBool() ? Qt::Checked : Qt::Unchecked);
|
||||||
@ -413,6 +417,8 @@ SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) :
|
|||||||
bval->setObjectName("box");
|
bval->setObjectName("box");
|
||||||
eval->setCheckState(settings->value("axes", false).toBool() ? Qt::Checked : Qt::Unchecked);
|
eval->setCheckState(settings->value("axes", false).toBool() ? Qt::Checked : Qt::Unchecked);
|
||||||
eval->setObjectName("axes");
|
eval->setObjectName("axes");
|
||||||
|
vval->setCheckState(settings->value("vdwstyle", false).toBool() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
vval->setObjectName("vdwstyle");
|
||||||
|
|
||||||
auto *intval = new QIntValidator(100, 100000, this);
|
auto *intval = new QIntValidator(100, 100000, this);
|
||||||
xval->setValidator(intval);
|
xval->setValidator(intval);
|
||||||
@ -449,8 +455,9 @@ SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) :
|
|||||||
grid->addWidget(ssao, 4, 0, Qt::AlignTop);
|
grid->addWidget(ssao, 4, 0, Qt::AlignTop);
|
||||||
grid->addWidget(bbox, 5, 0, Qt::AlignTop);
|
grid->addWidget(bbox, 5, 0, Qt::AlignTop);
|
||||||
grid->addWidget(axes, 6, 0, Qt::AlignTop);
|
grid->addWidget(axes, 6, 0, Qt::AlignTop);
|
||||||
grid->addWidget(cback, 7, 0, Qt::AlignTop);
|
grid->addWidget(vdw, 7, 0, Qt::AlignTop);
|
||||||
grid->addWidget(cbox, 8, 0, Qt::AlignTop);
|
grid->addWidget(cback, 8, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(cbox, 9, 0, Qt::AlignTop);
|
||||||
grid->addWidget(xval, 0, 1, Qt::AlignTop);
|
grid->addWidget(xval, 0, 1, Qt::AlignTop);
|
||||||
grid->addWidget(yval, 1, 1, Qt::AlignTop);
|
grid->addWidget(yval, 1, 1, Qt::AlignTop);
|
||||||
grid->addWidget(zval, 2, 1, Qt::AlignTop);
|
grid->addWidget(zval, 2, 1, Qt::AlignTop);
|
||||||
@ -458,12 +465,13 @@ SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) :
|
|||||||
grid->addWidget(sval, 4, 1, Qt::AlignVCenter);
|
grid->addWidget(sval, 4, 1, Qt::AlignVCenter);
|
||||||
grid->addWidget(bval, 5, 1, Qt::AlignVCenter);
|
grid->addWidget(bval, 5, 1, Qt::AlignVCenter);
|
||||||
grid->addWidget(eval, 6, 1, Qt::AlignVCenter);
|
grid->addWidget(eval, 6, 1, Qt::AlignVCenter);
|
||||||
grid->addWidget(background, 7, 1, Qt::AlignVCenter);
|
grid->addWidget(vval, 7, 1, Qt::AlignVCenter);
|
||||||
|
grid->addWidget(background, 8, 1, Qt::AlignVCenter);
|
||||||
grid->addWidget(boxcolor, 8, 1, Qt::AlignVCenter);
|
grid->addWidget(boxcolor, 8, 1, Qt::AlignVCenter);
|
||||||
|
|
||||||
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 9, 0);
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 10, 0);
|
||||||
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 9, 1);
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 10, 1);
|
||||||
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding), 9, 2);
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding), 10, 2);
|
||||||
setLayout(grid);
|
setLayout(grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user