not much use for editing x axis label. better give more space to other options

This commit is contained in:
Axel Kohlmeyer
2025-04-13 19:33:07 -04:00
parent f181ca6aec
commit 0bab80a26e
4 changed files with 11 additions and 23 deletions

View File

@ -58,7 +58,7 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
QWidget(parent), menu(new QMenuBar), file(new QMenu("&File")), saveAsAct(nullptr),
exportCsvAct(nullptr), exportDatAct(nullptr), exportYamlAct(nullptr), closeAct(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;
auto *top = new QHBoxLayout;
@ -73,7 +73,6 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
settings.beginGroup("charts");
chartTitle =
new QLineEdit(settings.value("title", "Thermo: %f").toString().replace("%f", filename));
chartXlabel = new QLineEdit(settings.value("xlabel", "Time step").toString());
chartYlabel = new QLineEdit("");
// plot smoothing
@ -121,8 +120,6 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
top->addWidget(dummy);
top->addWidget(new QLabel("Title:"));
top->addWidget(chartTitle);
top->addWidget(new QLabel("X:"));
top->addWidget(chartXlabel);
top->addWidget(new QLabel("Y:"));
top->addWidget(chartYlabel);
top->addWidget(new QLabel("Plot:"));
@ -156,8 +153,7 @@ ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
layout->addLayout(top);
setLayout(layout);
connect(chartTitle, &QLineEdit::editingFinished, this, &ChartWindow::update_labels);
connect(chartXlabel, &QLineEdit::editingFinished, this, &ChartWindow::update_labels);
connect(chartTitle, &QLineEdit::editingFinished, this, &ChartWindow::update_tlabel);
connect(chartYlabel, &QLineEdit::editingFinished, this, &ChartWindow::update_ylabel);
connect(smooth, SIGNAL(currentIndexChanged(int)), this, SLOT(select_smooth(int)));
connect(window, &QAbstractSpinBox::editingFinished, this, &ChartWindow::update_smooth);
@ -213,7 +209,7 @@ void ChartWindow::add_chart(const QString &title, int index)
chartYlabel->setText(title);
}
charts.append(chart);
update_labels();
update_tlabel();
select_smooth(0);
}
@ -279,10 +275,10 @@ void ChartWindow::update_smooth()
c->smooth_param(do_raw, do_smooth, wval, oval);
}
void ChartWindow::update_labels()
void ChartWindow::update_tlabel()
{
for (auto &c : charts)
c->set_labels(chartTitle->text(), chartXlabel->text());
c->set_tlabel(chartTitle->text());
}
void ChartWindow::update_ylabel()
@ -412,7 +408,6 @@ void ChartWindow::change_chart(int)
if (choice == c->get_index()) {
c->show();
chartTitle->setText(c->get_tlabel());
chartXlabel->setText(c->get_xlabel());
chartYlabel->setText(c->get_ylabel());
} else {
c->hide();
@ -460,7 +455,7 @@ ChartViewer::ChartViewer(const QString &title, int _index, QWidget *parent) :
chart->legend()->hide();
chart->addAxis(xaxis, Qt::AlignBottom);
chart->addAxis(yaxis, Qt::AlignLeft);
chart->setTitle("Thermo Output");
chart->setTitle("");
xaxis->setTitleText("Time step");
xaxis->setTickCount(5);
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);
xaxis->setTitleText(xlabel);
}
/* -------------------------------------------------------------------- */

View File

@ -53,7 +53,7 @@ private slots:
void stop_run();
void select_smooth(int selection);
void update_smooth();
void update_labels();
void update_tlabel();
void update_ylabel();
void saveAs();
@ -76,7 +76,7 @@ private:
QAction *closeAct, *stopAct, *quitAct;
QComboBox *smooth;
QSpinBox *window, *order;
QLineEdit *chartTitle, *chartXlabel, *chartYlabel;
QLineEdit *chartTitle, *chartYlabel;
QString filename;
QList<QtCharts::ChartViewer *> charts;
@ -107,7 +107,7 @@ public:
QString get_title() const { return series->name(); }
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(); }
void set_labels(const QString &tlabel, const QString &xlabel);
void set_tlabel(const QString &tlabel);
void set_ylabel(const QString &ylabel);
QString get_tlabel() const { return chart->title(); }
QString get_xlabel() const { return xaxis->titleText(); }

View File

@ -62,6 +62,7 @@
Add option to visualize molecules defined through the molecule command
Add text fields for editing plot title and axis labels for charts
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>
</release>
<release version="1.6.12" timestamp="1734890080">

View File

@ -213,8 +213,6 @@ void Preferences::accept()
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());
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 *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;
@ -727,8 +722,6 @@ ChartsTab::ChartsTab(QSettings *_settings, QWidget *parent) : QWidget(parent), s
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(rawbrlbl, i, 0, Qt::AlignTop);