transform_selector.cpp
Go to the documentation of this file.
1 #include "transform_selector.h"
2 #include "ui_transform_selector.h"
3 #include <QSettings>
4 #include <QDomDocument>
5 #include <QTableWidget>
6 #include <QComboBox>
7 #include <QDebug>
8 
9 TransformSelector::TransformSelector(QStringList builtin_transform,
10  QStringList available_transforms,
11  QString* default_tansform,
12  std::map<std::string, QString>* curve_transforms,
13  QWidget* parent)
14  : QDialog(parent)
15  , ui(new Ui::transform_selector)
16  , _curves_trans(curve_transforms)
17  , _default_trans(default_tansform)
18 {
19  ui->setupUi(this);
20 
21  QStringList transforms = builtin_transform + available_transforms;
22 
23  ui->comboDefault->insertItems(0, transforms);
24  ui->comboDefault->insertSeparator(builtin_transform.size());
25  if (transforms.contains(*default_tansform))
26  {
27  ui->comboDefault->setCurrentText(*default_tansform);
28  }
29 
30  ui->tableWidget->setRowCount(int(curve_transforms->size()));
31  ui->tableWidget->setColumnCount(2);
32 
33  int row = 0;
34  for (const auto& it : *curve_transforms)
35  {
36  const auto& trans = it.second;
37  auto item_name = new QTableWidgetItem(QString::fromStdString(it.first));
38  auto item_combo = new QComboBox();
39  item_combo->insertItems(0, transforms);
40  item_combo->insertSeparator(3);
41  ui->tableWidget->setItem(row, 0, item_name);
42  ui->tableWidget->setCellWidget(row, 1, item_combo);
43  if (transforms.contains(trans))
44  {
45  item_combo->setCurrentText(trans);
46  }
47  row++;
48  }
49  QHeaderView* header = ui->tableWidget->horizontalHeader();
50  header->setSectionResizeMode(QHeaderView::Stretch);
51 }
52 
54 {
55  delete ui;
56 }
57 
59 {
60  int default_index = ui->comboDefault->currentIndex();
61  for (int row = 0; row < ui->tableWidget->rowCount(); row++)
62  {
63  auto combo = static_cast<QComboBox*>(ui->tableWidget->cellWidget(row, 1));
64  combo->setCurrentIndex(default_index);
65  }
66 }
67 
69 {
70  for (int row = 0; row < ui->tableWidget->rowCount(); row++)
71  {
72  auto combo = static_cast<QComboBox*>(ui->tableWidget->cellWidget(row, 1));
73  combo->setCurrentIndex(0);
74  }
75 }
76 
78 {
79  for (int row = 0; row < ui->tableWidget->rowCount(); row++)
80  {
81  const auto& name = ui->tableWidget->item(row, 0)->text();
82  auto combo = static_cast<QComboBox*>(ui->tableWidget->cellWidget(row, 1));
83  (*_curves_trans)[name.toStdString()] = combo->currentText();
84  }
85  *_default_trans = ui->comboDefault->currentText();
86 }
TransformSelector::on_buttonResetAll_clicked
void on_buttonResetAll_clicked()
Definition: transform_selector.cpp:68
TransformSelector::TransformSelector
TransformSelector(QStringList builtin_transform, QStringList available_transforms, QString *default_tansform, std::map< std::string, QString > *curve_transforms, QWidget *parent=nullptr)
Definition: transform_selector.cpp:9
transform_selector.h
TransformSelector::on_transform_selector_accepted
void on_transform_selector_accepted()
Definition: transform_selector.cpp:77
TransformSelector::on_buttonApplyDefault_clicked
void on_buttonApplyDefault_clicked()
Definition: transform_selector.cpp:58
Ui
Definition: cheatsheet_dialog.h:6
TransformSelector::~TransformSelector
~TransformSelector()
Definition: transform_selector.cpp:53
TransformSelector::ui
Ui::transform_selector * ui
Definition: transform_selector.h:31
TransformSelector::_default_trans
QString * _default_trans
Definition: transform_selector.h:35
header
const std::string header


plotjuggler
Author(s): Davide Faconti
autogenerated on Tue Nov 26 2024 03:24:11