9 #include <wx/checkbox.h>
10 #include <wx/combobox.h>
12 #include <wx/statbox.h>
13 #include <wx/stattext.h>
32 : wxDialog(parent, wxID_ANY,
"Visualization settings", wxDefaultPosition, wxSize(500, 340)) {
36 wxBoxSizer* sizer =
new wxBoxSizer(wxVERTICAL);
38 wxStaticBoxSizer* renderBox =
new wxStaticBoxSizer(wxVERTICAL,
this,
"Rendering");
40 wxBoxSizer* colorizerSizer =
new wxBoxSizer(wxHORIZONTAL);
41 wxStaticText* colorizerText =
new wxStaticText(renderBox->GetStaticBox(), wxID_ANY,
"Default quantity");
42 colorizerSizer->Add(colorizerText, 0, wxALIGN_CENTER_VERTICAL);
43 colorizerSizer->AddStretchSpacer(1);
44 colorizerBox =
new ComboBox(renderBox->GetStaticBox(),
"");
49 colorizerBox->Append(colorizer->
name());
50 if (
id == defaultId) {
51 colorizerBox->SetSelection(colorizerBox->GetCount() - 1);
54 colorizerSizer->Add(colorizerBox, 1, wxEXPAND);
55 renderBox->Add(colorizerSizer);
57 sizer->Add(renderBox, 1, wxEXPAND);
60 wxStaticBoxSizer* plotBox =
new wxStaticBoxSizer(wxVERTICAL,
this,
"Plots");
61 wxGridSizer* plotGrid =
new wxGridSizer(2, 1, 1);
63 wxCheckBox* sfdCheck1 =
nullptr;
64 wxCheckBox* sfdCheck2 =
nullptr;
65 for (
const auto& p : sPlotTypes) {
66 wxCheckBox* check =
new wxCheckBox(plotBox->GetStaticBox(), wxID_ANY, p.value);
67 check->SetValue(plotFlags.
has(p.key));
74 plotBoxMap.
insert(check, p.key);
76 plotBox->Add(plotGrid);
77 sizer->Add(plotBox, 1, wxEXPAND);
79 wxBoxSizer* periodSizer =
new wxBoxSizer(wxHORIZONTAL);
80 wxStaticText* periodText =
new wxStaticText(plotBox->GetStaticBox(), wxID_ANY,
"Initial period [s]");
81 periodSizer->Add(periodText, 0, wxALIGN_CENTER_VERTICAL);
84 periodSizer->AddStretchSpacer(1);
85 periodSizer->Add(periodCtrl, 0, wxALIGN_CENTER_VERTICAL);
86 plotBox->Add(periodSizer, 1, wxEXPAND);
88 wxBoxSizer* overplotSizer =
new wxBoxSizer(wxHORIZONTAL);
89 wxStaticText* overplotText =
new wxStaticText(plotBox->GetStaticBox(), wxID_ANY,
"Reference SFD");
90 overplotSizer->Add(overplotText, 0, wxALIGN_CENTER_VERTICAL);
92 overplotPath =
new wxTextCtrl(plotBox->GetStaticBox(), wxID_ANY, overplotSfd);
94 overplotPath->SetMinSize(wxSize(250, -1));
95 overplotSizer->AddStretchSpacer(1);
96 overplotSizer->Add(overplotPath, 0, wxALIGN_CENTER_VERTICAL);
97 wxButton* overplotBrowse =
new wxButton(plotBox->GetStaticBox(), wxID_ANY,
"Select...");
99 overplotSizer->Add(overplotBrowse, 0, wxALIGN_CENTER_VERTICAL);
100 plotBox->Add(overplotSizer, 1, wxEXPAND);
103 wxBoxSizer* buttonSizer =
new wxBoxSizer(wxHORIZONTAL);
104 wxButton* okButton =
new wxButton(
this, wxID_ANY,
"OK");
105 wxButton* cancelButton =
new wxButton(
this, wxID_ANY,
"Cancel");
106 buttonSizer->AddStretchSpacer(1);
107 buttonSizer->Add(okButton);
108 buttonSizer->Add(cancelButton);
109 sizer->Add(buttonSizer, 1, wxEXPAND);
111 this->SetSizer(sizer);
114 auto enableOverplot = [=](wxCommandEvent&
UNUSED(evt)) {
115 const bool doEnable = sfdCheck1->IsChecked() || sfdCheck2->IsChecked();
116 overplotPath->Enable(doEnable);
117 overplotBrowse->Enable(doEnable);
119 sfdCheck1->Bind(wxEVT_CHECKBOX, enableOverplot);
120 sfdCheck2->Bind(wxEVT_CHECKBOX, enableOverplot);
122 overplotBrowse->Bind(wxEVT_BUTTON, [
this](wxCommandEvent&
UNUSED(evt)) {
125 overplotPath->SetValue(path->native());
129 okButton->Bind(wxEVT_BUTTON, [
this](wxCommandEvent&
UNUSED(evt)) { this->commit(); });
130 cancelButton->Bind(wxEVT_BUTTON, [
this](wxCommandEvent&
UNUSED(evt)) { this->EndModal(wxID_CANCEL); });
133 void GuiSettingsDialog::commit() {
137 const int index = colorizerBox->GetSelection();
143 for (
const auto& p : plotBoxMap) {
144 enabledPlots.
setIf(p.value, p.key->GetValue());
151 this->EndModal(wxID_OK);
#define SPH_ASSERT(x,...)
Object converting quantity values of particles into colors.
ColorizerId
Special colorizers that do not directly correspond to quantities.
Array< ExtColorizerId > getColorizerIds()
Returns IDs of all colorizers available in the application.
const EmptyFlags EMPTY_FLAGS
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define NAMESPACE_SPH_END
Object representing a path on a filesystem, similar to std::filesystem::path in c++17.
Optional< Path > doOpenFileDialog(const std::string &title, Array< FileFormat > &&formats)
Random utility functions for drawing stuff to DC.
Helper type allowing to "derive" from enum class.
Wrapper of an integral value providing functions for reading and modifying individual bits.
constexpr INLINE bool has(const TEnum flag) const
Checks if the object has a given flag.
constexpr INLINE bool hasAny(const TEnum flag, const TArgs... others) const
Checks if the object has any of given flags.
INLINE void setIf(const TEnum flag, const bool use)
Sets or removes given flag based given boolean value.
Container of key-value pairs.
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
GuiSettingsDialog(wxWindow *parent)
INLINE TValue get(const GuiSettingsId id) const
INLINE GuiSettings & set(const GuiSettingsId id, const TValue &value)
virtual std::string name() const =0
Returns the name of the colorizer.
Object representing a 1D interval of real numbers.
Wrapper of type value of which may or may not be present.
GuiSettings & getGuiSettings()
static Project & getInstance()
Flags< TValue > getFlags(const TEnum idx) const
Returns Flags from underlying value stored in settings.
@ TOTAL_MOMENTUM
Evolution of the total momentum in time.
@ SPEED_HISTOGRAM
Speed histogram.
@ INTERNAL_ENERGY
Evolution of the total internal energy in time.
@ SELECTED_PARTICLE
Evolution of the selected quantity for the selected particle in time.
@ TOTAL_ANGULAR_MOMENTUM
Evolution of the total angular momentum in time.
@ KINETIC_ENERGY
Evolution of the total kinetic energy in time.
@ RELATIVE_ENERGY_CHANGE
Relative change of total energy.
@ CURRENT_SFD
Current size-frequency distribution.
@ ANGULAR_HISTOGRAM_OF_VELOCITIES
Angular histogram (in x-y plane) of velocity directions.
@ PREDICTED_SFD
Predicted size-frequency distribution.
AutoPtr< IColorizer > getColorizer(const Project &project, const ExtColorizerId id)