Some code improvements

This commit is contained in:
YuSanka 2019-06-27 15:57:29 +02:00
parent 37b37cdf25
commit 0b940ec089
2 changed files with 18 additions and 18 deletions

View File

@ -822,8 +822,10 @@ namespace Slic3r {
t_layer_config_ranges config_ranges; t_layer_config_ranges config_ranges;
for (const auto& range : object_tree.get_child("ranges")) for (const auto& range : object_tree)
{ {
if (range.first != "range")
continue;
pt::ptree range_tree = range.second; pt::ptree range_tree = range.second;
double min_z = range_tree.get<double>("<xmlattr>.min_z"); double min_z = range_tree.get<double>("<xmlattr>.min_z");
double max_z = range_tree.get<double>("<xmlattr>.max_z"); double max_z = range_tree.get<double>("<xmlattr>.max_z");
@ -831,8 +833,10 @@ namespace Slic3r {
// get Z range information // get Z range information
DynamicPrintConfig& config = config_ranges[{ min_z, max_z }]; DynamicPrintConfig& config = config_ranges[{ min_z, max_z }];
for (const auto& option : range_tree.get_child("config")) for (const auto& option : range_tree)
{ {
if (option.first != "option")
continue;
std::string opt_key = option.second.get<std::string>("<xmlattr>.opt_key"); std::string opt_key = option.second.get<std::string>("<xmlattr>.opt_key");
std::string value = option.second.data(); std::string value = option.second.data();
@ -2116,23 +2120,21 @@ namespace Slic3r {
pt::ptree& obj_tree = tree.add("objects.object",""); pt::ptree& obj_tree = tree.add("objects.object","");
obj_tree.put("<xmlattr>.id", object_cnt); obj_tree.put("<xmlattr>.id", object_cnt);
obj_tree.add("ranges", "");
// Store the layer config ranges. // Store the layer config ranges.
for (const auto& range : ranges) for (const auto& range : ranges)
{ {
pt::ptree& range_tree = obj_tree.add("ranges.range", ""); pt::ptree& range_tree = obj_tree.add("range", "");
// store minX and maxZ // store minX and maxZ
range_tree.put("<xmlattr>.min_z", range.first.first); range_tree.put("<xmlattr>.min_z", range.first.first);
range_tree.put("<xmlattr>.max_z", range.first.second); range_tree.put("<xmlattr>.max_z", range.first.second);
range_tree.add("config","");
// store range configuration // store range configuration
const DynamicPrintConfig& config = range.second; const DynamicPrintConfig& config = range.second;
for (const std::string& opt_key : config.keys()) for (const std::string& opt_key : config.keys())
{ {
pt::ptree& opt_tree = range_tree.add("config.option", config.serialize(opt_key)); pt::ptree& opt_tree = range_tree.add("option", config.serialize(opt_key));
opt_tree.put("<xmlattr>.opt_key", opt_key); opt_tree.put("<xmlattr>.opt_key", opt_key);
} }
} }
@ -2145,19 +2147,14 @@ namespace Slic3r {
boost::property_tree::write_xml(oss, tree); boost::property_tree::write_xml(oss, tree);
out = oss.str(); out = oss.str();
// Post processing of the output string for a better preview // Post processing("beautification") of the output string for a better preview
// JUST
// boost::replace_all(out, "><", ">\n<");
// OR more "beautification"
boost::replace_all(out, "><object", ">\n <object"); boost::replace_all(out, "><object", ">\n <object");
boost::replace_all(out, "><ranges", ">\n <ranges"); boost::replace_all(out, "><range", ">\n <range");
boost::replace_all(out, "><range", ">\n <range"); boost::replace_all(out, "><option", ">\n <option");
boost::replace_all(out, "><config", ">\n <config"); boost::replace_all(out, "></range>", ">\n </range>");
boost::replace_all(out, "><option", ">\n <option"); boost::replace_all(out, "></object>", ">\n </object>");
boost::replace_all(out, "></config", ">\n </config"); // OR just
boost::replace_all(out, "></range>", ">\n </range>"); boost::replace_all(out, "><", ">\n<");
boost::replace_all(out, "></ranges", ">\n </ranges");
boost::replace_all(out, "></object", ">\n </object");
} }
if (!out.empty()) if (!out.empty())

View File

@ -331,6 +331,9 @@ void Selection::clear()
// resets the cache in the sidebar // resets the cache in the sidebar
wxGetApp().obj_manipul()->reset_cache(); wxGetApp().obj_manipul()->reset_cache();
// #et_FIXME fake KillFocus from sidebar
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event("", false);
} }
// Update the selection based on the new instance IDs. // Update the selection based on the new instance IDs.