imageviewer updates
- new zoom icons - resetview option - properly track pushbutton checked state - add preferences options for selecting background and box color
This commit is contained in:
@ -53,7 +53,7 @@ int ChartWindow::get_step() const
|
|||||||
{
|
{
|
||||||
if (charts.size() > 0) {
|
if (charts.size() > 0) {
|
||||||
auto *v = charts[0];
|
auto *v = charts[0];
|
||||||
return (int)v->get_step(v->get_count()-1);
|
return (int)v->get_step(v->get_count() - 1);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 4.7 KiB |
@ -72,6 +72,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
auto *rotright = new QPushButton(QIcon(":/object-rotate-right.png"), "");
|
auto *rotright = new QPushButton(QIcon(":/object-rotate-right.png"), "");
|
||||||
auto *rotup = new QPushButton(QIcon(":/gtk-go-up.png"), "");
|
auto *rotup = new QPushButton(QIcon(":/gtk-go-up.png"), "");
|
||||||
auto *rotdown = new QPushButton(QIcon(":/gtk-go-down.png"), "");
|
auto *rotdown = new QPushButton(QIcon(":/gtk-go-down.png"), "");
|
||||||
|
auto *reset = new QPushButton(QIcon(":/gtk-zoom-fit.png"), "");
|
||||||
auto *combo = new QComboBox;
|
auto *combo = new QComboBox;
|
||||||
combo->setObjectName("group");
|
combo->setObjectName("group");
|
||||||
int ngroup = lammps->id_count("group");
|
int ngroup = lammps->id_count("group");
|
||||||
@ -93,6 +94,7 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
menuLayout->addWidget(rotright);
|
menuLayout->addWidget(rotright);
|
||||||
menuLayout->addWidget(rotup);
|
menuLayout->addWidget(rotup);
|
||||||
menuLayout->addWidget(rotdown);
|
menuLayout->addWidget(rotdown);
|
||||||
|
menuLayout->addWidget(reset);
|
||||||
menuLayout->addWidget(new QLabel(" Group: "));
|
menuLayout->addWidget(new QLabel(" Group: "));
|
||||||
menuLayout->addWidget(combo);
|
menuLayout->addWidget(combo);
|
||||||
|
|
||||||
@ -106,26 +108,20 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
connect(rotright, &QPushButton::released, this, &ImageViewer::do_rot_right);
|
connect(rotright, &QPushButton::released, this, &ImageViewer::do_rot_right);
|
||||||
connect(rotup, &QPushButton::released, this, &ImageViewer::do_rot_up);
|
connect(rotup, &QPushButton::released, this, &ImageViewer::do_rot_up);
|
||||||
connect(rotdown, &QPushButton::released, this, &ImageViewer::do_rot_down);
|
connect(rotdown, &QPushButton::released, this, &ImageViewer::do_rot_down);
|
||||||
|
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(menuLayout);
|
||||||
mainLayout->addWidget(scrollArea);
|
mainLayout->addWidget(scrollArea);
|
||||||
mainLayout->addWidget(buttonBox);
|
mainLayout->addWidget(buttonBox);
|
||||||
setWindowTitle(QString("Image Viewer: ") + QFileInfo(fileName).completeBaseName());
|
setWindowTitle(QString("Image Viewer: ") + QFileInfo(fileName).fileName());
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup("snapshot");
|
|
||||||
zoom = settings.value("zoom", 1.0).toDouble();
|
|
||||||
hrot = settings.value("hrot", 60).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();
|
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
createImage();
|
|
||||||
|
reset_view();
|
||||||
|
dobox->setChecked(showbox);
|
||||||
|
doaxes->setChecked(showaxes);
|
||||||
|
dossao->setChecked(usessao);
|
||||||
|
doanti->setChecked(antialias);
|
||||||
|
|
||||||
scaleFactor = 1.0;
|
scaleFactor = 1.0;
|
||||||
resize(image.width() + 20, image.height() + 50);
|
resize(image.width() + 20, image.height() + 50);
|
||||||
@ -137,6 +133,37 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
|
|||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageViewer::reset_view()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.beginGroup("snapshot");
|
||||||
|
zoom = settings.value("zoom", 1.0).toDouble();
|
||||||
|
hrot = settings.value("hrot", 60).toInt();
|
||||||
|
vrot = settings.value("vrot", 30).toInt();
|
||||||
|
showbox = settings.value("box", true).toBool();
|
||||||
|
showaxes = settings.value("axes", false).toBool();
|
||||||
|
usessao = settings.value("ssao", false).toBool();
|
||||||
|
antialias = settings.value("antialias", false).toBool();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
// reset state of checkable push buttons (only after main layout is set up)
|
||||||
|
auto *lo = layout();
|
||||||
|
if (lo) {
|
||||||
|
lo = lo->itemAt(0)->layout();
|
||||||
|
auto *button = qobject_cast<QPushButton *>(lo->itemAt(1)->widget());
|
||||||
|
button->setChecked(usessao);
|
||||||
|
button = qobject_cast<QPushButton *>(lo->itemAt(2)->widget());
|
||||||
|
button->setChecked(antialias);
|
||||||
|
button = qobject_cast<QPushButton *>(lo->itemAt(3)->widget());
|
||||||
|
button->setChecked(showbox);
|
||||||
|
button = qobject_cast<QPushButton *>(lo->itemAt(4)->widget());
|
||||||
|
button->setChecked(showaxes);
|
||||||
|
auto *cb = qobject_cast<QComboBox *>(lo->itemAt(lo->count() - 1)->widget());
|
||||||
|
cb->setCurrentText("all");
|
||||||
|
}
|
||||||
|
createImage();
|
||||||
|
}
|
||||||
|
|
||||||
void ImageViewer::toggle_ssao()
|
void ImageViewer::toggle_ssao()
|
||||||
{
|
{
|
||||||
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
||||||
@ -251,7 +278,8 @@ void ImageViewer::createImage()
|
|||||||
else
|
else
|
||||||
dumpcmd += QString(" axes no 0.0 0.0");
|
dumpcmd += QString(" axes no 0.0 0.0");
|
||||||
|
|
||||||
dumpcmd += " modify boxcolor silver";
|
dumpcmd += " modify boxcolor " + settings.value("boxcolor", "yellow").toString();
|
||||||
|
dumpcmd += " backcolor " + settings.value("background", "black").toString();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
lammps->command(dumpcmd.toLocal8Bit());
|
lammps->command(dumpcmd.toLocal8Bit());
|
||||||
|
|||||||
@ -45,6 +45,7 @@ private slots:
|
|||||||
void normalSize();
|
void normalSize();
|
||||||
void fitToWindow();
|
void fitToWindow();
|
||||||
|
|
||||||
|
void reset_view();
|
||||||
void toggle_ssao();
|
void toggle_ssao();
|
||||||
void toggle_anti();
|
void toggle_anti();
|
||||||
void toggle_box();
|
void toggle_box();
|
||||||
|
|||||||
@ -39,7 +39,7 @@ int LammpsWrapper::extract_setting(const char *keyword)
|
|||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
val = ((liblammpsplugin_t *)plugin_handle)->extract_setting(lammps_handle, keyword);
|
val = ((liblammpsplugin_t *)plugin_handle)->extract_setting(lammps_handle, keyword);
|
||||||
#else
|
#else
|
||||||
val = lammps_extract_setting(lammps_handle, keyword);
|
val = lammps_extract_setting(lammps_handle, keyword);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
@ -52,7 +52,7 @@ int LammpsWrapper::id_count(const char *keyword)
|
|||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
val = ((liblammpsplugin_t *)plugin_handle)->id_count(lammps_handle, keyword);
|
val = ((liblammpsplugin_t *)plugin_handle)->id_count(lammps_handle, keyword);
|
||||||
#else
|
#else
|
||||||
val = lammps_id_count(lammps_handle, keyword);
|
val = lammps_id_count(lammps_handle, keyword);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
@ -65,7 +65,7 @@ int LammpsWrapper::id_name(const char *keyword, int idx, char *buf, int len)
|
|||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
val = ((liblammpsplugin_t *)plugin_handle)->id_name(lammps_handle, keyword, idx, buf, len);
|
val = ((liblammpsplugin_t *)plugin_handle)->id_name(lammps_handle, keyword, idx, buf, len);
|
||||||
#else
|
#else
|
||||||
val = lammps_id_name(lammps_handle, keyword, idx, buf, len);
|
val = lammps_id_name(lammps_handle, keyword, idx, buf, len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
@ -78,7 +78,7 @@ double LammpsWrapper::get_thermo(const char *keyword)
|
|||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
val = ((liblammpsplugin_t *)plugin_handle)->get_thermo(lammps_handle, keyword);
|
val = ((liblammpsplugin_t *)plugin_handle)->get_thermo(lammps_handle, keyword);
|
||||||
#else
|
#else
|
||||||
val = lammps_get_thermo(lammps_handle, keyword);
|
val = lammps_get_thermo(lammps_handle, keyword);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
@ -91,7 +91,7 @@ void *LammpsWrapper::last_thermo(const char *keyword, int index)
|
|||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
ptr = ((liblammpsplugin_t *)plugin_handle)->last_thermo(lammps_handle, keyword, index);
|
ptr = ((liblammpsplugin_t *)plugin_handle)->last_thermo(lammps_handle, keyword, index);
|
||||||
#else
|
#else
|
||||||
ptr = lammps_last_thermo(lammps_handle, keyword, index);
|
ptr = lammps_last_thermo(lammps_handle, keyword, index);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
@ -104,7 +104,7 @@ bool LammpsWrapper::is_running()
|
|||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
val = ((liblammpsplugin_t *)plugin_handle)->is_running(lammps_handle);
|
val = ((liblammpsplugin_t *)plugin_handle)->is_running(lammps_handle);
|
||||||
#else
|
#else
|
||||||
val = lammps_is_running(lammps_handle);
|
val = lammps_is_running(lammps_handle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return val != 0;
|
return val != 0;
|
||||||
|
|||||||
@ -120,6 +120,10 @@ 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());
|
||||||
|
QComboBox *combo = tabWidget->findChild<QComboBox *>("background");
|
||||||
|
if (combo) settings->setValue("background", combo->currentText());
|
||||||
|
combo = tabWidget->findChild<QComboBox *>("boxcolor");
|
||||||
|
if (combo) settings->setValue("boxcolor", combo->currentText());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
// general settings
|
// general settings
|
||||||
@ -367,6 +371,8 @@ 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 *cback = new QLabel("Background Color:");
|
||||||
|
auto *cbox = new QLabel("Box Color:");
|
||||||
settings->beginGroup("snapshot");
|
settings->beginGroup("snapshot");
|
||||||
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());
|
||||||
@ -383,7 +389,6 @@ 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");
|
||||||
settings->endGroup();
|
|
||||||
|
|
||||||
auto *intval = new QIntValidator(100, 100000, this);
|
auto *intval = new QIntValidator(100, 100000, this);
|
||||||
xval->setValidator(intval);
|
xval->setValidator(intval);
|
||||||
@ -393,6 +398,26 @@ SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) :
|
|||||||
zval->setValidator(new QDoubleValidator(0.01, 100.0, 100, this));
|
zval->setValidator(new QDoubleValidator(0.01, 100.0, 100, this));
|
||||||
zval->setObjectName("zoom");
|
zval->setObjectName("zoom");
|
||||||
|
|
||||||
|
auto *background = new QComboBox;
|
||||||
|
background->setObjectName("background");
|
||||||
|
background->addItem("black");
|
||||||
|
background->addItem("white");
|
||||||
|
background->addItem("darkgray");
|
||||||
|
background->addItem("gray");
|
||||||
|
background->addItem("silver");
|
||||||
|
background->setCurrentText(settings->value("background", "black").toString());
|
||||||
|
|
||||||
|
auto *boxcolor = new QComboBox;
|
||||||
|
boxcolor->setObjectName("boxcolor");
|
||||||
|
boxcolor->addItem("yellow");
|
||||||
|
boxcolor->addItem("silver");
|
||||||
|
boxcolor->addItem("gray");
|
||||||
|
boxcolor->addItem("red");
|
||||||
|
boxcolor->addItem("green");
|
||||||
|
boxcolor->addItem("blue");
|
||||||
|
boxcolor->setCurrentText(settings->value("boxcolor", "yellow").toString());
|
||||||
|
settings->endGroup();
|
||||||
|
|
||||||
grid->addWidget(xsize, 0, 0, Qt::AlignTop);
|
grid->addWidget(xsize, 0, 0, Qt::AlignTop);
|
||||||
grid->addWidget(ysize, 1, 0, Qt::AlignTop);
|
grid->addWidget(ysize, 1, 0, Qt::AlignTop);
|
||||||
grid->addWidget(zoom, 2, 0, Qt::AlignTop);
|
grid->addWidget(zoom, 2, 0, Qt::AlignTop);
|
||||||
@ -400,6 +425,8 @@ 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(cbox, 8, 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);
|
||||||
@ -407,9 +434,12 @@ 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->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 7, 0);
|
grid->addWidget(background, 7, 1, Qt::AlignVCenter);
|
||||||
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 7, 1);
|
grid->addWidget(boxcolor, 8, 1, Qt::AlignVCenter);
|
||||||
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding), 7, 2);
|
|
||||||
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 9, 0);
|
||||||
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 9, 1);
|
||||||
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding), 9, 2);
|
||||||
setLayout(grid);
|
setLayout(grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user