add new tab to preferences for charts window settings
This commit is contained in:
@ -2,11 +2,6 @@ LAMMPS-GUI TODO list:
|
|||||||
|
|
||||||
# Short term goals (v1.x)
|
# Short term goals (v1.x)
|
||||||
|
|
||||||
- add a "Charts tab" to the preferences with the following (default) settings:
|
|
||||||
- default filter data yes/no
|
|
||||||
- default smooth parameters
|
|
||||||
- default plot colors
|
|
||||||
- enable "raw" or "smooth" or "both"
|
|
||||||
- add a "Colors" menu to the image viewer to adjust color settings for the
|
- add a "Colors" menu to the image viewer to adjust color settings for the
|
||||||
current image (unlike the defaults in the perferences) including assigning
|
current image (unlike the defaults in the perferences) including assigning
|
||||||
colors to individual atom types.
|
colors to individual atom types.
|
||||||
|
|||||||
@ -49,6 +49,7 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
|
|||||||
stopAct(nullptr), quitAct(nullptr), smooth(nullptr), window(nullptr), order(nullptr),
|
stopAct(nullptr), quitAct(nullptr), smooth(nullptr), window(nullptr), order(nullptr),
|
||||||
chartTitle(nullptr), chartXlabel(nullptr), chartYlabel(nullptr), filename(_filename)
|
chartTitle(nullptr), chartXlabel(nullptr), chartYlabel(nullptr), filename(_filename)
|
||||||
{
|
{
|
||||||
|
QSettings settings;
|
||||||
auto *top = new QHBoxLayout;
|
auto *top = new QHBoxLayout;
|
||||||
menu->addMenu(file);
|
menu->addMenu(file);
|
||||||
menu->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
menu->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||||
@ -58,30 +59,47 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
|
|||||||
dummy->hide();
|
dummy->hide();
|
||||||
|
|
||||||
// plot title and axis labels
|
// plot title and axis labels
|
||||||
|
settings.beginGroup("charts");
|
||||||
chartTitle = new QLineEdit(QString("Thermo: %1").arg(filename));
|
chartTitle =
|
||||||
chartXlabel = new QLineEdit("Time step");
|
new QLineEdit(settings.value("title", "Thermo: %f").toString().replace("%f", filename));
|
||||||
|
chartXlabel = new QLineEdit(settings.value("xlabel", "Time step").toString());
|
||||||
chartYlabel = new QLineEdit("");
|
chartYlabel = new QLineEdit("");
|
||||||
|
|
||||||
// plot smoothing
|
// plot smoothing
|
||||||
|
int smoothchoice = settings.value("smoothchoice",2).toInt();
|
||||||
|
switch (smoothchoice) {
|
||||||
|
case 0:
|
||||||
|
do_raw = true;
|
||||||
|
do_smooth = false;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
do_raw = false;
|
||||||
|
do_smooth = true;
|
||||||
|
break;
|
||||||
|
case 2: // fallthrough
|
||||||
|
default:
|
||||||
do_raw = true;
|
do_raw = true;
|
||||||
do_smooth = true;
|
do_smooth = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// list of choices must be kepy in sync with list in preferences
|
||||||
smooth = new QComboBox;
|
smooth = new QComboBox;
|
||||||
smooth->addItem("Raw");
|
smooth->addItem("Raw");
|
||||||
smooth->addItem("Smooth");
|
smooth->addItem("Smooth");
|
||||||
smooth->addItem("Both");
|
smooth->addItem("Both");
|
||||||
smooth->setCurrentIndex(2);
|
smooth->setCurrentIndex(smoothchoice);
|
||||||
smooth->show();
|
smooth->show();
|
||||||
window = new QSpinBox;
|
window = new QSpinBox;
|
||||||
window->setRange(5, 999);
|
window->setRange(5, 999);
|
||||||
window->setValue(10);
|
window->setValue(settings.value("smoothwindow", 10).toInt());
|
||||||
window->setEnabled(true);
|
window->setEnabled(true);
|
||||||
window->setToolTip("Smoothing Window Size");
|
window->setToolTip("Smoothing Window Size");
|
||||||
order = new QSpinBox;
|
order = new QSpinBox;
|
||||||
order->setRange(1, 20);
|
order->setRange(1, 20);
|
||||||
order->setValue(4);
|
order->setValue(settings.value("smoothorder", 4).toInt());
|
||||||
order->setEnabled(true);
|
order->setEnabled(true);
|
||||||
order->setToolTip("Smoothing Order");
|
order->setToolTip("Smoothing Order");
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
auto *normal = new QPushButton(QIcon(":/icons/gtk-zoom-fit.png"), "");
|
auto *normal = new QPushButton(QIcon(":/icons/gtk-zoom-fit.png"), "");
|
||||||
normal->setToolTip("Reset zoom to normal");
|
normal->setToolTip("Reset zoom to normal");
|
||||||
@ -139,7 +157,6 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
|
|||||||
connect(columns, SIGNAL(currentIndexChanged(int)), this, SLOT(change_chart(int)));
|
connect(columns, SIGNAL(currentIndexChanged(int)), this, SLOT(change_chart(int)));
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
resize(settings.value("chartx", 500).toInt(), settings.value("charty", 320).toInt());
|
resize(settings.value("chartx", 500).toInt(), settings.value("charty", 320).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +203,7 @@ void ChartWindow::add_chart(const QString &title, int index)
|
|||||||
}
|
}
|
||||||
charts.append(chart);
|
charts.append(chart);
|
||||||
update_labels();
|
update_labels();
|
||||||
|
select_smooth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChartWindow::add_data(int step, double data, int index)
|
void ChartWindow::add_data(int step, double data, int index)
|
||||||
|
|||||||
@ -67,6 +67,7 @@ Preferences::Preferences(LammpsWrapper *_lammps, QWidget *parent) :
|
|||||||
tabWidget->addTab(new AcceleratorTab(settings, lammps), "&Accelerators");
|
tabWidget->addTab(new AcceleratorTab(settings, lammps), "&Accelerators");
|
||||||
tabWidget->addTab(new SnapshotTab(settings), "&Snapshot Image");
|
tabWidget->addTab(new SnapshotTab(settings), "&Snapshot Image");
|
||||||
tabWidget->addTab(new EditorTab(settings), "&Editor Settings");
|
tabWidget->addTab(new EditorTab(settings), "&Editor Settings");
|
||||||
|
tabWidget->addTab(new ChartsTab(settings), "Cha&rts Settings");
|
||||||
|
|
||||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &Preferences::accept);
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &Preferences::accept);
|
||||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
@ -77,7 +78,7 @@ Preferences::Preferences(LammpsWrapper *_lammps, QWidget *parent) :
|
|||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
setWindowIcon(QIcon(":/icons/lammps-icon-128x128.png"));
|
setWindowIcon(QIcon(":/icons/lammps-icon-128x128.png"));
|
||||||
setWindowTitle("LAMMPS-GUI - Preferences");
|
setWindowTitle("LAMMPS-GUI - Preferences");
|
||||||
resize(600, 450);
|
resize(700, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences::~Preferences()
|
Preferences::~Preferences()
|
||||||
@ -207,6 +208,25 @@ void Preferences::accept()
|
|||||||
if (box) settings->setValue("autosave", box->isChecked());
|
if (box) settings->setValue("autosave", box->isChecked());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
|
// chart window settings
|
||||||
|
|
||||||
|
settings->beginGroup("charts");
|
||||||
|
field = tabWidget->findChild<QLineEdit *>("title");
|
||||||
|
if (field) settings->setValue("title", field->text());
|
||||||
|
field = tabWidget->findChild<QLineEdit *>("xlabel");
|
||||||
|
if (field) settings->setValue("xlabel", field->text());
|
||||||
|
combo = tabWidget->findChild<QComboBox *>("smoothchoice");
|
||||||
|
if (combo) settings->setValue("smoothchoice", combo->currentIndex());
|
||||||
|
spin = tabWidget->findChild<QSpinBox *>("smoothwindow");
|
||||||
|
if (spin) settings->setValue("smoothwindow", spin->value());
|
||||||
|
spin = tabWidget->findChild<QSpinBox *>("smoothorder");
|
||||||
|
if (spin) settings->setValue("smoothorder", spin->value());
|
||||||
|
settings->endGroup();
|
||||||
|
spin = tabWidget->findChild<QSpinBox *>("chartx");
|
||||||
|
if (spin) settings->setValue("chartx", spin->value());
|
||||||
|
spin = tabWidget->findChild<QSpinBox *>("charty");
|
||||||
|
if (spin) settings->setValue("charty", spin->value());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,6 +642,7 @@ EditorTab::EditorTab(QSettings *_settings, QWidget *parent) : QWidget(parent), s
|
|||||||
grid->addWidget(retval, i++, 1, Qt::AlignVCenter);
|
grid->addWidget(retval, i++, 1, Qt::AlignVCenter);
|
||||||
grid->addWidget(autolbl, i, 0, Qt::AlignTop);
|
grid->addWidget(autolbl, i, 0, Qt::AlignTop);
|
||||||
grid->addWidget(autoval, i++, 1, Qt::AlignVCenter);
|
grid->addWidget(autoval, i++, 1, Qt::AlignVCenter);
|
||||||
|
grid->addWidget(new QLabel(" "), i++, 0);
|
||||||
grid->addWidget(savlbl, i, 0, Qt::AlignTop);
|
grid->addWidget(savlbl, i, 0, Qt::AlignTop);
|
||||||
grid->addWidget(savval, i++, 1, Qt::AlignVCenter);
|
grid->addWidget(savval, i++, 1, Qt::AlignVCenter);
|
||||||
|
|
||||||
@ -631,6 +652,75 @@ EditorTab::EditorTab(QSettings *_settings, QWidget *parent) : QWidget(parent), s
|
|||||||
setLayout(grid);
|
setLayout(grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChartsTab::ChartsTab(QSettings *_settings, QWidget *parent) : QWidget(parent), settings(_settings)
|
||||||
|
{
|
||||||
|
auto *grid = new QGridLayout;
|
||||||
|
auto *chartlbl = new QLabel("Charts default settings:");
|
||||||
|
|
||||||
|
settings->beginGroup("charts");
|
||||||
|
auto *titlelbl = new QLabel("Default chart title:");
|
||||||
|
auto *titletxt = new QLineEdit(settings->value("title", "Thermo: %f").toString());
|
||||||
|
auto *titlehlp = new QLabel("(use %f for current input file)");
|
||||||
|
|
||||||
|
auto *xlabellbl = new QLabel("Default x-axis label:");
|
||||||
|
auto *xlabeltxt = new QLineEdit(settings->value("xlabel", "Time step").toString());
|
||||||
|
|
||||||
|
// list of choices must be kepy in sync with list in chartviewer
|
||||||
|
auto *smoothlbl = new QLabel("Default plot data choice:");
|
||||||
|
auto *smoothval = new QComboBox;
|
||||||
|
smoothval->addItem("Raw");
|
||||||
|
smoothval->addItem("Smooth");
|
||||||
|
smoothval->addItem("Both");
|
||||||
|
smoothval->setObjectName("smoothchoice");
|
||||||
|
smoothval->setCurrentIndex(settings->value("smoothchoice", 2).toInt());
|
||||||
|
|
||||||
|
auto *smwindlbl = new QLabel("Default smoothing window:");
|
||||||
|
auto *smwindval = new QSpinBox;
|
||||||
|
smwindval->setRange(5, 999);
|
||||||
|
smwindval->setValue(settings->value("smoothwindow", 10).toInt());
|
||||||
|
smwindval->setObjectName("smoothwindow");
|
||||||
|
|
||||||
|
auto *smordrlbl = new QLabel("Default smoothing order:");
|
||||||
|
auto *smordrval = new QSpinBox;
|
||||||
|
smordrval->setRange(1, 20);
|
||||||
|
smordrval->setValue(settings->value("smoothorder", 4).toInt());
|
||||||
|
smordrval->setObjectName("smoothorder");
|
||||||
|
settings->endGroup();
|
||||||
|
|
||||||
|
auto *chartxlbl = new QLabel("Chart default width:");
|
||||||
|
auto *chartxval = new QSpinBox;
|
||||||
|
chartxval->setRange(400, 40000);
|
||||||
|
chartxval->setValue(settings->value("chartx", 500).toInt());
|
||||||
|
chartxval->setObjectName("chartx");
|
||||||
|
auto *chartylbl = new QLabel("Chart default height:");
|
||||||
|
auto *chartyval = new QSpinBox;
|
||||||
|
chartyval->setRange(300, 30000);
|
||||||
|
chartyval->setValue(settings->value("charty", 320).toInt());
|
||||||
|
chartyval->setObjectName("charty");
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
grid->addWidget(chartlbl, i++, 0, 1, 2, Qt::AlignTop | Qt::AlignHCenter);
|
||||||
|
grid->addWidget(titlelbl, i, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(titletxt, i, 1, Qt::AlignTop);
|
||||||
|
grid->addWidget(titlehlp, i++, 2, Qt::AlignTop);
|
||||||
|
grid->addWidget(xlabellbl, i, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(xlabeltxt, i++, 1, Qt::AlignTop);
|
||||||
|
grid->addWidget(smoothlbl, i, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(smoothval, i++, 1, Qt::AlignTop);
|
||||||
|
grid->addWidget(smwindlbl, i, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(smwindval, i++, 1, Qt::AlignTop);
|
||||||
|
grid->addWidget(smordrlbl, i, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(smordrval, i++, 1, Qt::AlignVCenter);
|
||||||
|
grid->addWidget(chartxlbl, i, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(chartxval, i++, 1, Qt::AlignVCenter);
|
||||||
|
grid->addWidget(chartylbl, i, 0, Qt::AlignTop);
|
||||||
|
grid->addWidget(chartyval, i++, 1, Qt::AlignVCenter);
|
||||||
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), i, 0);
|
||||||
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), i, 1);
|
||||||
|
grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding), i, 2);
|
||||||
|
setLayout(grid);
|
||||||
|
}
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// c-basic-offset: 4
|
// c-basic-offset: 4
|
||||||
// End:
|
// End:
|
||||||
|
|||||||
@ -93,6 +93,16 @@ private:
|
|||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ChartsTab : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ChartsTab(QSettings *settings, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSettings *settings;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
|
|||||||
Reference in New Issue
Block a user