colormap_selector.cpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #include "colormap_selector.h"
8 #include "ui_colormap_selector.h"
9 #include "color_map.h"
10 #include "colormap_editor.h"
11 #include <QSettings>
12 
13 ColormapSelectorDialog::ColormapSelectorDialog(QString series, QString default_colormap,
14  QWidget* parent)
15  : QDialog(parent), ui(new Ui::colormap_selector)
16 {
17  ui->setupUi(this);
18  ui->lineSeries->setText(series);
19 
20  if (default_colormap.isEmpty())
21  {
22  QSettings settings;
23  default_colormap =
24  settings.value("ColormapSelectorDialog::prevColorMap", "").toString();
25  }
26 
27  for (auto it : ColorMapLibrary())
28  {
29  ui->comboBox->addItem(it.first);
30  }
31  if (ColorMapLibrary().count(default_colormap))
32  {
33  ui->comboBox->setCurrentText(default_colormap);
34  }
35 
36  auto reset_button = ui->buttonBox->button(QDialogButtonBox::Reset);
37  connect(reset_button, &QPushButton::clicked, this, [this]() {
38  _selected.clear();
39  this->accept();
40  });
41 }
42 
44 {
45  QSettings settings;
46  settings.setValue("ColormapSelectorDialog::prevColorMap", ui->comboBox->currentText());
47 
48  delete ui;
49 }
50 
52 {
53  return _selected;
54 }
55 
57 {
58  ColorMapEditor dialog;
59  dialog.exec();
60 
61  QString default_colormap = ui->comboBox->currentText();
62 
63  ui->comboBox->clear();
64  for (auto it : ColorMapLibrary())
65  {
66  ui->comboBox->addItem(it.first);
67  }
68  if (ColorMapLibrary().count(default_colormap))
69  {
70  ui->comboBox->setCurrentText(default_colormap);
71  }
72 }
73 
75 {
76  _selected = name;
77 }
ColormapSelectorDialog::on_comboBox_currentTextChanged
void on_comboBox_currentTextChanged(const QString &arg1)
Definition: colormap_selector.cpp:74
color_map.h
ColormapSelectorDialog::on_buttonEditor_clicked
void on_buttonEditor_clicked()
Definition: colormap_selector.cpp:56
ColormapSelectorDialog::_selected
QString _selected
Definition: colormap_selector.h:35
ColormapSelectorDialog::ui
Ui::colormap_selector * ui
Definition: colormap_selector.h:34
ColorMapEditor
Definition: colormap_editor.h:22
detail::count
constexpr auto count() -> size_t
Definition: core.h:1222
colormap_editor.h
Ui
Definition: cheatsheet_dialog.h:6
colormap_selector.h
ColorMapLibrary
std::map< QString, ColorMap::Ptr > & ColorMapLibrary()
Definition: color_map.cpp:48
ColormapSelectorDialog::~ColormapSelectorDialog
~ColormapSelectorDialog()
Definition: colormap_selector.cpp:43
ColormapSelectorDialog::ColormapSelectorDialog
ColormapSelectorDialog(QString series, QString default_colormap, QWidget *parent=nullptr)
Definition: colormap_selector.cpp:13
ColormapSelectorDialog::selectedColorMap
QString selectedColorMap() const
Definition: colormap_selector.cpp:51


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:43