94{
95 std::string group_category;
96 int different_count = 0;
97
101
102 if (!config || is_multiple_selection || !object)
103 return false;
104
106
107
109 wxGetApp().preset_bundle->prints.get_edited_preset().config :
110 wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
111
112
113
114 if (!is_object)
115 {
117 }
118
121
122
123 std::map<std::string, std::vector<SimpleSettingData>> cat_options;
125 bool display_multiple = false;
126 auto is_option_modified = [this](std::string key) {
129 if (!config_option1 && config_option2)
130 return true;
131 else if (config_option1 && config_option2 && (*config_option1 != *config_option2))
132 return true;
133
134 return false;
135 };
136
137
138 if (category_settings.size() == 0) {
139 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "can not find settings for category " <<category <<", display all the modified settings instead!!!" << std::endl;
140
142 std::map<std::string, std::vector<SimpleSettingData>>::iterator it1 = cat_options.begin();
143
144 while (it1 != cat_options.end())
145 {
146 std::vector<SimpleSettingData>& settings = it1->second;
147 std::vector<SimpleSettingData>::iterator it2 = settings.begin();
148
149 while ( it2 != settings.end() )
150 {
151 if (!is_option_modified(it2->name)) {
152 it2 = settings.erase(it2);
153 }
154 else {
155 BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" category %1% , keep option %2%")%it1->first % it2->name;
156 it2++;
157 }
158 }
159 if (settings.size() > 0)
160 it1++;
161 else
162 it1 = cat_options.erase(it1);
163 }
164 display_multiple = true;
165 }
166 else {
167 cat_options.emplace(category, category_settings);
168 }
169 std::vector<std::string> categories;
170 categories.reserve(cat_options.size());
171
172 for (auto& cat : cat_options)
173 {
174 categories.push_back(cat.first);
175 group_category = cat.first;
176
177 auto extra_column = [
this, is_object, object, config, group_category](wxWindow*
parent,
const Line& line)
178 {
179 auto opt_key = (line.get_options())[0].opt_id;
180
182 btn->SetToolTip(
_(
L(
"Reset parameter")));
183
184 #ifdef __WINDOWS__
185 btn->SetBackgroundColour(
parent->GetBackgroundColour());
186 #endif
187
188
191
192 #ifdef __WINDOWS__
194 #endif
195
196 #ifdef __WXOSX_MAC__
197 btn->Bind(EVT_LOCK_DISABLE, [
this, btn](
auto &e) { btn->SetBitmap(
m_bmp_reset_disable.bmp()); });
198 btn->Bind(EVT_LOCK_ENABLE, [
this, btn](
auto &e) { btn->SetBitmap(
m_bmp_reset_focus.bmp()); });
199 #endif
200
201 btn->Bind(wxEVT_BUTTON, [opt_key, this, is_object, object, config, group_category](wxEvent &event) {
202
203 config->erase(opt_key);
204
205 wxGetApp().obj_list()->changed_object();
206
207
208
209
211
212
213
214
219
220 #ifdef __WXOSX_MAC__
221
222 if (auto *btn = dynamic_cast<ScalableButton *>(event.GetEventObject())) {
223 if (!btn->IsEnabled()) {
225 } else {
227 }
228 }
229 #endif
230 });
231 (const_cast<Line&>(line)).extra_widget_win = btn;
232 return btn;
233 };
234
235 auto optgroup = std::make_shared<ConfigOptionsGroup>(
m_og->ctrl_parent(),
_(cat.first), &
m_current_config,
false, extra_column);
236 optgroup->label_width = 20;
239
240 std::weak_ptr<ConfigOptionsGroup> weak_optgroup(optgroup);
241 optgroup->m_on_change = [
this, is_object, object, config, group_category](
const t_config_option_key &opt_id,
const boost::any &value) {
244 wxGetApp().obj_list()->changed_object();
246
247 };
248
249
250 optgroup->rescale_extra_column_item = [this](wxWindow* win) {
251 auto *ctrl = dynamic_cast<ScalableButton*>(win);
252 if (ctrl == nullptr)
253 return;
257 #ifdef __WINDOWS__
259 #endif
260 };
261
262 const bool is_extruders_cat = cat.first == "Extruders";
263 for (auto& opt : cat.second)
264 {
265 Option option = optgroup->get_option(opt.name);
267 if (is_extruders_cat)
268 option.opt.max = wxGetApp().extruders_edited_cnt();
269 optgroup->append_single_option_line(option);
270
271 if (!opt.label.empty()) {
272 auto line = optgroup->get_line(opt.name);
273 if (line)
275 }
276 }
277 optgroup->activate();
278 for (auto& opt : cat.second)
279 optgroup->get_field(opt.name)->m_on_change = [weak_optgroup](const std::string& opt_id, const boost::any& value) {
280
281 wxGetApp().plater()->take_snapshot((boost::format("Change Option %s") % opt_id).str());
282 weak_optgroup.lock()->on_change_OG(opt_id, value);
283 };
284
285 optgroup->reload_config();
288 if (different_count > 0)
290
291
292
293
294
295
296
297
298
299
300
303
304 auto toggle_field = [optgroup](
const t_config_option_key & opt_key,
bool toggle,
int opt_index)
305 {
306 Field* field = optgroup->get_fieldc(opt_key, opt_index);;
307 if (field)
308 field->toggle(toggle);
309 };
310 auto toggle_line = [optgroup](
const t_config_option_key &opt_key,
bool toggle,
int opt_index)
311 {
312 Line* line = optgroup->get_line(opt_key);
313 if (line) line->toggle_visible = toggle;
314 };
315 ConfigManipulation config_manipulation(
nullptr, toggle_field, toggle_line,
nullptr, &
m_current_config);
316
317 bool is_BBL_printer = wxGetApp().preset_bundle->is_bbl_vendor();
318 config_manipulation.set_is_BBL_Printer(is_BBL_printer);
319
322 optgroup->update_visibility(wxGetApp().get_mode());
323 }
324
325
326
327
329 m_table->enable_reset_all_button(
true);
330 else
331 m_table->enable_reset_all_button(
false);
332
333 return true;
334}
#define _(s)
Definition 3mf.cpp:306
#define L(s)
Definition ExtrusionEntity.cpp:25
static int def_width_wider()
Definition Field.cpp:402
static int def_width_thinner()
Definition Field.cpp:403
int m_current_different
Definition GUI_ObjectTableSettings.hpp:64
@ TYPE_PRINT
Definition Preset.hpp:246
wxString from_u8(const std::string &str)
Definition GUI.cpp:544