not much use for editing x axis label. better give more space to other options
This commit is contained in:
@ -58,7 +58,7 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
|
|||||||
QWidget(parent), menu(new QMenuBar), file(new QMenu("&File")), saveAsAct(nullptr),
|
QWidget(parent), menu(new QMenuBar), file(new QMenu("&File")), saveAsAct(nullptr),
|
||||||
exportCsvAct(nullptr), exportDatAct(nullptr), exportYamlAct(nullptr), closeAct(nullptr),
|
exportCsvAct(nullptr), exportDatAct(nullptr), exportYamlAct(nullptr), closeAct(nullptr),
|
||||||
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), chartYlabel(nullptr), filename(_filename)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
auto *top = new QHBoxLayout;
|
auto *top = new QHBoxLayout;
|
||||||
@ -73,7 +73,6 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
|
|||||||
settings.beginGroup("charts");
|
settings.beginGroup("charts");
|
||||||
chartTitle =
|
chartTitle =
|
||||||
new QLineEdit(settings.value("title", "Thermo: %f").toString().replace("%f", filename));
|
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
|
||||||
@ -121,8 +120,6 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
|
|||||||
top->addWidget(dummy);
|
top->addWidget(dummy);
|
||||||
top->addWidget(new QLabel("Title:"));
|
top->addWidget(new QLabel("Title:"));
|
||||||
top->addWidget(chartTitle);
|
top->addWidget(chartTitle);
|
||||||
top->addWidget(new QLabel("X:"));
|
|
||||||
top->addWidget(chartXlabel);
|
|
||||||
top->addWidget(new QLabel("Y:"));
|
top->addWidget(new QLabel("Y:"));
|
||||||
top->addWidget(chartYlabel);
|
top->addWidget(chartYlabel);
|
||||||
top->addWidget(new QLabel("Plot:"));
|
top->addWidget(new QLabel("Plot:"));
|
||||||
@ -156,8 +153,7 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
|
|||||||
layout->addLayout(top);
|
layout->addLayout(top);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
connect(chartTitle, &QLineEdit::editingFinished, this, &ChartWindow::update_labels);
|
connect(chartTitle, &QLineEdit::editingFinished, this, &ChartWindow::update_tlabel);
|
||||||
connect(chartXlabel, &QLineEdit::editingFinished, this, &ChartWindow::update_labels);
|
|
||||||
connect(chartYlabel, &QLineEdit::editingFinished, this, &ChartWindow::update_ylabel);
|
connect(chartYlabel, &QLineEdit::editingFinished, this, &ChartWindow::update_ylabel);
|
||||||
connect(smooth, SIGNAL(currentIndexChanged(int)), this, SLOT(select_smooth(int)));
|
connect(smooth, SIGNAL(currentIndexChanged(int)), this, SLOT(select_smooth(int)));
|
||||||
connect(window, &QAbstractSpinBox::editingFinished, this, &ChartWindow::update_smooth);
|
connect(window, &QAbstractSpinBox::editingFinished, this, &ChartWindow::update_smooth);
|
||||||
@ -213,7 +209,7 @@ void ChartWindow::add_chart(const QString &title, int index)
|
|||||||
chartYlabel->setText(title);
|
chartYlabel->setText(title);
|
||||||
}
|
}
|
||||||
charts.append(chart);
|
charts.append(chart);
|
||||||
update_labels();
|
update_tlabel();
|
||||||
select_smooth(0);
|
select_smooth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,10 +275,10 @@ void ChartWindow::update_smooth()
|
|||||||
c->smooth_param(do_raw, do_smooth, wval, oval);
|
c->smooth_param(do_raw, do_smooth, wval, oval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChartWindow::update_labels()
|
void ChartWindow::update_tlabel()
|
||||||
{
|
{
|
||||||
for (auto &c : charts)
|
for (auto &c : charts)
|
||||||
c->set_labels(chartTitle->text(), chartXlabel->text());
|
c->set_tlabel(chartTitle->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChartWindow::update_ylabel()
|
void ChartWindow::update_ylabel()
|
||||||
@ -412,7 +408,6 @@ void ChartWindow::change_chart(int)
|
|||||||
if (choice == c->get_index()) {
|
if (choice == c->get_index()) {
|
||||||
c->show();
|
c->show();
|
||||||
chartTitle->setText(c->get_tlabel());
|
chartTitle->setText(c->get_tlabel());
|
||||||
chartXlabel->setText(c->get_xlabel());
|
|
||||||
chartYlabel->setText(c->get_ylabel());
|
chartYlabel->setText(c->get_ylabel());
|
||||||
} else {
|
} else {
|
||||||
c->hide();
|
c->hide();
|
||||||
@ -460,7 +455,7 @@ ChartViewer::ChartViewer(const QString &title, int _index, QWidget *parent) :
|
|||||||
chart->legend()->hide();
|
chart->legend()->hide();
|
||||||
chart->addAxis(xaxis, Qt::AlignBottom);
|
chart->addAxis(xaxis, Qt::AlignBottom);
|
||||||
chart->addAxis(yaxis, Qt::AlignLeft);
|
chart->addAxis(yaxis, Qt::AlignLeft);
|
||||||
chart->setTitle("Thermo Output");
|
chart->setTitle("");
|
||||||
xaxis->setTitleText("Time step");
|
xaxis->setTitleText("Time step");
|
||||||
xaxis->setTickCount(5);
|
xaxis->setTickCount(5);
|
||||||
xaxis->setLabelFormat("%d");
|
xaxis->setLabelFormat("%d");
|
||||||
@ -587,10 +582,9 @@ void ChartViewer::smooth_param(bool _do_raw, bool _do_smooth, int _window, int _
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ChartViewer::set_labels(const QString &tlabel, const QString &xlabel)
|
void ChartViewer::set_tlabel(const QString &tlabel)
|
||||||
{
|
{
|
||||||
chart->setTitle(tlabel);
|
chart->setTitle(tlabel);
|
||||||
xaxis->setTitleText(xlabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -53,7 +53,7 @@ private slots:
|
|||||||
void stop_run();
|
void stop_run();
|
||||||
void select_smooth(int selection);
|
void select_smooth(int selection);
|
||||||
void update_smooth();
|
void update_smooth();
|
||||||
void update_labels();
|
void update_tlabel();
|
||||||
void update_ylabel();
|
void update_ylabel();
|
||||||
|
|
||||||
void saveAs();
|
void saveAs();
|
||||||
@ -76,7 +76,7 @@ private:
|
|||||||
QAction *closeAct, *stopAct, *quitAct;
|
QAction *closeAct, *stopAct, *quitAct;
|
||||||
QComboBox *smooth;
|
QComboBox *smooth;
|
||||||
QSpinBox *window, *order;
|
QSpinBox *window, *order;
|
||||||
QLineEdit *chartTitle, *chartXlabel, *chartYlabel;
|
QLineEdit *chartTitle, *chartYlabel;
|
||||||
|
|
||||||
QString filename;
|
QString filename;
|
||||||
QList<QtCharts::ChartViewer *> charts;
|
QList<QtCharts::ChartViewer *> charts;
|
||||||
@ -107,7 +107,7 @@ public:
|
|||||||
QString get_title() const { return series->name(); }
|
QString get_title() const { return series->name(); }
|
||||||
double get_step(int index) const { return (index < 0) ? 0.0 : series->at(index).x(); }
|
double get_step(int index) const { return (index < 0) ? 0.0 : series->at(index).x(); }
|
||||||
double get_data(int index) const { return (index < 0) ? 0.0 : series->at(index).y(); }
|
double get_data(int index) const { return (index < 0) ? 0.0 : series->at(index).y(); }
|
||||||
void set_labels(const QString &tlabel, const QString &xlabel);
|
void set_tlabel(const QString &tlabel);
|
||||||
void set_ylabel(const QString &ylabel);
|
void set_ylabel(const QString &ylabel);
|
||||||
QString get_tlabel() const { return chart->title(); }
|
QString get_tlabel() const { return chart->title(); }
|
||||||
QString get_xlabel() const { return xaxis->titleText(); }
|
QString get_xlabel() const { return xaxis->titleText(); }
|
||||||
|
|||||||
@ -62,6 +62,7 @@
|
|||||||
Add option to visualize molecules defined through the molecule command
|
Add option to visualize molecules defined through the molecule command
|
||||||
Add text fields for editing plot title and axis labels for charts
|
Add text fields for editing plot title and axis labels for charts
|
||||||
Add option to automatically open tutorial websites (enabled by default)
|
Add option to automatically open tutorial websites (enabled by default)
|
||||||
|
Add preferences tab for charts to set default for title, plot colors, smooth/raw plot, smooth params
|
||||||
</description>
|
</description>
|
||||||
</release>
|
</release>
|
||||||
<release version="1.6.12" timestamp="1734890080">
|
<release version="1.6.12" timestamp="1734890080">
|
||||||
|
|||||||
@ -213,8 +213,6 @@ void Preferences::accept()
|
|||||||
settings->beginGroup("charts");
|
settings->beginGroup("charts");
|
||||||
field = tabWidget->findChild<QLineEdit *>("title");
|
field = tabWidget->findChild<QLineEdit *>("title");
|
||||||
if (field) settings->setValue("title", field->text());
|
if (field) settings->setValue("title", field->text());
|
||||||
field = tabWidget->findChild<QLineEdit *>("xlabel");
|
|
||||||
if (field) settings->setValue("xlabel", field->text());
|
|
||||||
combo = tabWidget->findChild<QComboBox *>("smoothchoice");
|
combo = tabWidget->findChild<QComboBox *>("smoothchoice");
|
||||||
if (combo) settings->setValue("smoothchoice", combo->currentIndex());
|
if (combo) settings->setValue("smoothchoice", combo->currentIndex());
|
||||||
combo = tabWidget->findChild<QComboBox *>("rawbrush");
|
combo = tabWidget->findChild<QComboBox *>("rawbrush");
|
||||||
@ -666,9 +664,6 @@ ChartsTab::ChartsTab(QSettings *_settings, QWidget *parent) : QWidget(parent), s
|
|||||||
auto *titletxt = new QLineEdit(settings->value("title", "Thermo: %f").toString());
|
auto *titletxt = new QLineEdit(settings->value("title", "Thermo: %f").toString());
|
||||||
auto *titlehlp = new QLabel("(use %f for current input file)");
|
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
|
// list of choices must be kepy in sync with list in chartviewer
|
||||||
auto *smoothlbl = new QLabel("Default plot data choice:");
|
auto *smoothlbl = new QLabel("Default plot data choice:");
|
||||||
auto *smoothval = new QComboBox;
|
auto *smoothval = new QComboBox;
|
||||||
@ -727,8 +722,6 @@ ChartsTab::ChartsTab(QSettings *_settings, QWidget *parent) : QWidget(parent), s
|
|||||||
grid->addWidget(titlelbl, i, 0, Qt::AlignTop);
|
grid->addWidget(titlelbl, i, 0, Qt::AlignTop);
|
||||||
grid->addWidget(titletxt, i, 1, Qt::AlignTop);
|
grid->addWidget(titletxt, i, 1, Qt::AlignTop);
|
||||||
grid->addWidget(titlehlp, i++, 2, 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(smoothlbl, i, 0, Qt::AlignTop);
|
||||||
grid->addWidget(smoothval, i++, 1, Qt::AlignTop);
|
grid->addWidget(smoothval, i++, 1, Qt::AlignTop);
|
||||||
grid->addWidget(rawbrlbl, i, 0, Qt::AlignTop);
|
grid->addWidget(rawbrlbl, i, 0, Qt::AlignTop);
|
||||||
|
|||||||
Reference in New Issue
Block a user