8 #include "ui_plotwidget_transforms.h"
10 #include <QVBoxLayout>
12 #include <QListWidgetItem>
14 #include <QMouseEvent>
15 #include <QPushButton>
16 #include <QDialogButtonBox>
21 : QDialog(plotwidget), ui(new
Ui::plotwidget_transforms), _plotwidget_origin(plotwidget)
31 auto layout =
new QVBoxLayout();
32 ui->framePlotPreview->setLayout(layout);
42 restoreGeometry(settings.value(
"DialogTransformEditor.geometry").toByteArray());
44 ui->listCurves->setStyleSheet(
"QListView::item:selected { background: #ddeeff; }");
46 auto names = TransformFactory::registeredTransforms();
48 for (
const auto& name : names)
50 ui->listTransforms->addItem(QString::fromStdString(name));
53 if (
ui->listCurves->count() != 0)
55 ui->listCurves->item(0)->setSelected(
true);
64 for (
auto& it : colors)
67 auto name = QString::fromStdString(curve_it->src_name);
68 auto color = it.second;
69 auto item =
new QListWidgetItem();
71 ui->listCurves->addItem(item);
73 item->setSizeHint(plot_row->sizeHint());
74 ui->listCurves->setItemWidget(item, plot_row);
83 settings.setValue(
"DialogTransformEditor.geometry", saveGeometry());
90 auto layout =
new QHBoxLayout();
94 setStyleSheet(QString(
"color: %1;").
arg(
color.name()));
97 layout->addWidget(
_text);
102 return _text->text();
112 auto selected =
ui->listCurves->selectedItems();
113 if (selected.size() != 1)
117 auto item = selected.front();
118 auto row_widget =
dynamic_cast<RowWidget*
>(
ui->listCurves->itemWidget(item));
119 auto curve_name = row_widget->
text();
122 int transform_row = 0;
127 for (
int row = 1; row <
ui->listTransforms->count(); row++)
129 if (
ui->listTransforms->item(row)->text() == ts->transformName())
138 int selected_row = -1;
139 auto selected_transforms =
ui->listTransforms->selectedItems();
140 if (selected_transforms.size() == 1)
142 selected_row =
ui->listTransforms->row(selected_transforms.front());
145 if (selected_row == transform_row)
152 ui->listTransforms->item(transform_row)->setSelected(
true);
158 auto selected_curves =
ui->listCurves->selectedItems();
159 if (selected_curves.size() != 1)
164 dynamic_cast<RowWidget*
>(
ui->listCurves->itemWidget(selected_curves.front()));
166 QString curve_name = row_widget->
text();
168 auto selected_transforms =
ui->listTransforms->selectedItems();
169 if (selected_transforms.size() != 1)
173 QString transform_ID = selected_transforms.front()->text();
176 auto qwt_curve = curve_info->
curve;
179 QSignalBlocker
block(
ui->lineEditAlias);
181 if (transform_ID.isEmpty() || transform_ID ==
ui->listTransforms->item(0)->text())
183 ts->setTransform({});
184 ts->updateCache(
true);
185 ui->stackedWidgetArguments->setCurrentIndex(0);
187 ui->lineEditAlias->setText(
"");
188 ui->lineEditAlias->setEnabled(
false);
189 qwt_curve->setTitle(curve_name);
193 ts->setTransform(transform_ID);
194 ts->updateCache(
true);
195 ui->lineEditAlias->setEnabled(
true);
197 QString curve_title = qwt_curve->title().text();
198 if (ts->alias().isEmpty())
200 auto src_name = QString::fromStdString(curve_info->src_name);
201 auto new_title = QString(
"%1[%2]").arg(src_name).arg(transform_ID);
202 ts->setAlias(new_title);
205 ui->lineEditAlias->setText(ts->alias());
206 qwt_curve->setTitle(ts->alias());
208 auto widget = ts->transform()->optionsWidget();
209 int index =
ui->stackedWidgetArguments->indexOf(widget);
210 if (index == -1 && widget)
212 index =
ui->stackedWidgetArguments->addWidget(widget);
215 ui->stackedWidgetArguments->setCurrentIndex(index);
219 connect(ts->transform().get(), &TransformFunction::parametersChanged,
this, [=]() {
220 ts->updateCache(true);
221 if (ui->checkBoxAutoZoom->isChecked())
223 _plotwidget->zoomOut(false);
227 _plotwidget->replot();
247 bool autozoom_filter_applied =
248 settings.value(
"Preferences::autozoom_filter_applied",
true).toBool();
253 if (autozoom_filter_applied)
263 auto selected_curves =
ui->listCurves->selectedItems();
264 if (selected_curves.size() != 1)
269 dynamic_cast<RowWidget*
>(
ui->listCurves->itemWidget(selected_curves.front()));
271 QString curve_name = row_widget->
text();
276 curve_it->curve->setTitle(
ui->lineEditAlias->text());
278 if (ts && ts->transform())