97{
100
101 if (wxGetApp().is_closing())
102 return false;
103
104 auto objects_ctrl = wxGetApp().obj_list();
105 auto objects_model = wxGetApp().obj_list()->GetModel();
106 auto config = wxGetApp().obj_list()->config();
107
108 const auto item = objects_ctrl->GetSelection();
109
110 if (!item || !objects_model->IsSettingsItem(item) || !config || objects_ctrl->multiple_selection())
111 return false;
112
113 const bool is_object_settings = objects_model->GetItemType(objects_model->GetParent(item)) ==
itObject;
115
116 if (!cat_options.empty())
117 {
118 std::vector<std::string> categories;
119 categories.reserve(cat_options.size());
120
121 auto extra_column = [config,
this](wxWindow*
parent,
const Line& line)
122 {
123 auto opt_key = (line.get_options())[0].opt_id;
124
126 btn->SetBackgroundColour(
parent->GetBackgroundColour());
127 btn->SetToolTip(
_(
L(
"Remove parameter")));
128
131
132 btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
133 wxGetApp().plater()->take_snapshot(
from_u8((boost::format(
"Delete Option %s") % opt_key).str()).ToStdString());
134 config->erase(opt_key);
135 wxGetApp().obj_list()->changed_object();
136 wxTheApp->CallAfter([this]() {
137 wxWindowUpdateLocker noUpdates(
m_parent);
140 });
141 });
142 return btn;
143 };
144
145 for (auto& cat : cat_options)
146 {
147 categories.push_back(cat.first);
148
149 auto optgroup = std::make_shared<ConfigOptionsGroup>(
m_og->ctrl_parent(),
_(cat.first), config,
false, extra_column);
150 optgroup->label_width = 15;
151 optgroup->sidetext_width = 5;
152
153 optgroup->m_on_change = [
this, config](
const t_config_option_key& opt_id,
const boost::any& value) {
155 wxGetApp().obj_list()->changed_object(); };
156
157
158 optgroup->rescale_extra_column_item = [this](wxWindow* win) {
159 auto *ctrl = dynamic_cast<ScalableButton*>(win);
160 if (ctrl == nullptr)
161 return;
165 };
166
167 const bool is_extruders_cat = cat.first == "Extruders";
168 for (auto& opt : cat.second)
169 {
170 Option option = optgroup->get_option(opt);
171 option.opt.width = 12;
172 if (is_extruders_cat)
173 option.opt.max = wxGetApp().extruders_edited_cnt();
174 optgroup->append_single_option_line(option);
175 }
176 optgroup->activate();
177 for (auto& opt : cat.second)
178 optgroup->get_field(opt)->m_on_change = [optgroup](const std::string& opt_id, const boost::any& value) {
179
180 wxGetApp().plater()->take_snapshot(
from_u8((boost::format(
"Change Option %s")% opt_id).str()).ToStdString());
181 optgroup->on_change_OG(opt_id, value);
182 };
183
184 optgroup->reload_config();
185
188 }
189
190 if (!categories.empty()) {
191 objects_model->UpdateSettingsDigest(item, categories);
193 }
194 }
195 else
196 {
197 objects_ctrl->select_item(objects_model->Delete(item));
198 return false;
199 }
200 return true;
201}
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
static Bundle get_bundle(const DynamicPrintConfig *config, bool is_object_settings, bool is_layer_settings=false)
Definition GUI_Factories.cpp:299
std::map< std::string, std::vector< std::string > > Bundle
Definition GUI_Factories.hpp:34