ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
options_widget.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <QtCore>
11 #include <QtWidgets>
12 #include <unordered_map>
13 
14 namespace colmap {
15 
16 class OptionsWidget : public QWidget {
17 public:
18  explicit OptionsWidget(QWidget* parent);
19 
20  void AddOptionRow(const std::string& label_text,
21  QWidget* widget,
22  void* option);
23  void AddWidgetRow(const std::string& label_text, QWidget* widget);
24  void AddLayoutRow(const std::string& label_text, QLayout* layout);
25 
26  QSpinBox* AddOptionInt(int* option,
27  const std::string& label_text,
28  const int min = 0,
29  const int max = static_cast<int>(1e7));
30  QDoubleSpinBox* AddOptionDouble(double* option,
31  const std::string& label_text,
32  const double min = 0,
33  const double max = 1e7,
34  const double step = 0.01,
35  const int decimals = 2);
36  QDoubleSpinBox* AddOptionDoubleLog(double* option,
37  const std::string& label_text,
38  const double min = 0,
39  const double max = 1e7,
40  const double step = 0.01,
41  const int decimals = 2);
42  QCheckBox* AddOptionBool(bool* option, const std::string& label_text);
43  QLineEdit* AddOptionText(std::string* option,
44  const std::string& label_text);
45  QLineEdit* AddOptionFilePath(std::string* option,
46  const std::string& label_text);
47  QLineEdit* AddOptionDirPath(std::string* option,
48  const std::string& label_text);
49 
50  void AddSpacer();
51  void AddSection(const std::string& title);
52 
53  void ReadOptions();
54  void WriteOptions();
55 
56 protected:
57  void showEvent(QShowEvent* event);
58  void closeEvent(QCloseEvent* event);
59  void hideEvent(QHideEvent* event);
60 
61  void ShowOption(void* option);
62  void HideOption(void* option);
63 
64  void ShowWidget(QWidget* option);
65  void HideWidget(QWidget* option);
66 
67  void ShowLayout(QLayout* option);
68  void HideLayout(QLayout* option);
69 
70  QGridLayout* grid_layout_;
71 
72  std::unordered_map<void*, std::pair<QLabel*, QWidget*>> option_rows_;
73  std::unordered_map<QWidget*, std::pair<QLabel*, QWidget*>> widget_rows_;
74  std::unordered_map<QLayout*, std::pair<QLabel*, QWidget*>> layout_rows_;
75 
76  std::vector<std::pair<QSpinBox*, int*>> options_int_;
77  std::vector<std::pair<QDoubleSpinBox*, double*>> options_double_;
78  std::vector<std::pair<QDoubleSpinBox*, double*>> options_double_log_;
79  std::vector<std::pair<QCheckBox*, bool*>> options_bool_;
80  std::vector<std::pair<QLineEdit*, std::string*>> options_text_;
81  std::vector<std::pair<QLineEdit*, std::string*>> options_path_;
82 };
83 
84 } // namespace colmap
MouseEvent event
std::vector< std::pair< QCheckBox *, bool * > > options_bool_
void ShowOption(void *option)
QDoubleSpinBox * AddOptionDoubleLog(double *option, const std::string &label_text, const double min=0, const double max=1e7, const double step=0.01, const int decimals=2)
QLineEdit * AddOptionText(std::string *option, const std::string &label_text)
void closeEvent(QCloseEvent *event)
void HideLayout(QLayout *option)
QLineEdit * AddOptionFilePath(std::string *option, const std::string &label_text)
void HideOption(void *option)
std::unordered_map< QWidget *, std::pair< QLabel *, QWidget * > > widget_rows_
std::unordered_map< QLayout *, std::pair< QLabel *, QWidget * > > layout_rows_
QDoubleSpinBox * AddOptionDouble(double *option, const std::string &label_text, const double min=0, const double max=1e7, const double step=0.01, const int decimals=2)
std::vector< std::pair< QLineEdit *, std::string * > > options_text_
std::vector< std::pair< QDoubleSpinBox *, double * > > options_double_
OptionsWidget(QWidget *parent)
void AddWidgetRow(const std::string &label_text, QWidget *widget)
std::unordered_map< void *, std::pair< QLabel *, QWidget * > > option_rows_
void ShowWidget(QWidget *option)
void HideWidget(QWidget *option)
void hideEvent(QHideEvent *event)
std::vector< std::pair< QLineEdit *, std::string * > > options_path_
QSpinBox * AddOptionInt(int *option, const std::string &label_text, const int min=0, const int max=static_cast< int >(1e7))
void AddOptionRow(const std::string &label_text, QWidget *widget, void *option)
QLineEdit * AddOptionDirPath(std::string *option, const std::string &label_text)
void AddSection(const std::string &title)
QGridLayout * grid_layout_
void AddLayoutRow(const std::string &label_text, QLayout *layout)
void ShowLayout(QLayout *option)
std::vector< std::pair< QSpinBox *, int * > > options_int_
QCheckBox * AddOptionBool(bool *option, const std::string &label_text)
void showEvent(QShowEvent *event)
std::vector< std::pair< QDoubleSpinBox *, double * > > options_double_log_