Merge remote-tracking branch 'origin/master' into ys_new_features

This commit is contained in:
YuSanka 2019-05-22 13:51:49 +02:00
commit ccdd68f157
20 changed files with 9564 additions and 1428 deletions

View file

@ -728,7 +728,7 @@ void GUI_App::update_mode()
void GUI_App::add_config_menu(wxMenuBar *menu)
{
auto local_menu = new wxMenu();
wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt);
wxWindowID config_id_base = wxWindow::NewControlId(int(ConfigMenuCnt));
const auto config_wizard_name = _(ConfigWizard::name(true).wx_str());
const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), config_wizard_name);
@ -750,9 +750,9 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("Simple")), _(L("Simple View Mode")));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _(L("Advanced")), _(L("Advanced View Mode")));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _(L("Expert")), _(L("Expert View Mode")));
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comSimple); }, config_id_base + ConfigMenuModeSimple);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comAdvanced); }, config_id_base + ConfigMenuModeAdvanced);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comExpert); }, config_id_base + ConfigMenuModeExpert);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comSimple) evt.Check(true); }, config_id_base + ConfigMenuModeSimple);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comAdvanced) evt.Check(true); }, config_id_base + ConfigMenuModeAdvanced);
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert);
local_menu->AppendSubMenu(mode_menu, _(L("Mode")), wxString::Format(_(L("%s View Mode")), SLIC3R_APP_NAME));
local_menu->AppendSeparator();
@ -831,10 +831,14 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
break;
}
});
mode_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
int id_mode = event.GetId() - config_id_base;
save_mode(id_mode - ConfigMenuModeSimple);
});
using std::placeholders::_1;
auto modfn = [this](int mode, wxCommandEvent&) { if(get_mode() != mode) save_mode(mode); };
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert);
menu->Append(local_menu, _(L("&Configuration")));
}

View file

@ -1457,9 +1457,6 @@ void ObjectList::load_part( ModelObject* model_object,
delta = model_object->origin_translation - object->origin_translation;
}
for (auto volume : object->volumes) {
#if !ENABLE_VOLUMES_CENTERING_FIXES
volume->center_geometry();
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
volume->translate(delta);
auto new_volume = model_object->add_volume(*volume);
new_volume->set_type(type);
@ -1582,14 +1579,6 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
ModelVolume *new_volume = model_object.add_volume(std::move(mesh));
new_volume->set_type(type);
#if !ENABLE_GENERIC_SUBPARTS_PLACEMENT
new_volume->set_offset(Vec3d(0.0, 0.0, model_object.origin_translation(2) - mesh.stl.stats.min(2)));
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
#if !ENABLE_VOLUMES_CENTERING_FIXES
new_volume->center_geometry();
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
if (instance_idx != -1)
{
// First (any) GLVolume of the selected instance. They all share the same instance matrix.
@ -1605,7 +1594,6 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
Vec3d(instance_bb.max(0), instance_bb.min(1), instance_bb.min(2)) + 0.5 * mesh_bb.size() - v->get_instance_offset();
new_volume->set_offset(v->get_instance_transformation().get_matrix(true).inverse() * offset);
}
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
new_volume->name = into_u8(name);
// set a default extruder value, since user can't add it manually

View file

@ -487,11 +487,9 @@ void MainFrame::init_menubar()
append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) + sep + GUI::shortkey_ctrl_prefix() + sep_space + "A",
_(L("Selects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->select_all(); },
"", nullptr, [this](){return can_select(); }, this);
#if !DISABLE_DESELECT_ALL_MENU_ITEM
append_menu_item(editMenu, wxID_ANY, _(L("D&eselect all")) + sep + GUI::shortkey_ctrl_prefix() + sep + "Esc",
append_menu_item(editMenu, wxID_ANY, _(L("D&eselect all")) + sep + "Esc",
_(L("Deselects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->deselect_all(); },
"", nullptr, [this](){return can_deselect(); }, this);
#endif // !DISABLE_DESELECT_ALL_MENU_ITEM
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _(L("&Delete selected")) + sep + hotkey_delete,
_(L("Deletes the current selection")),[this](wxCommandEvent&) { m_plater->remove_selected(); },

View file

@ -832,7 +832,7 @@ void Sidebar::update_presets(Preset::Type preset_type)
if (filament_cnt == 1) {
// Single filament printer, synchronize the filament presets.
const std::string &name = preset_bundle.filaments.get_selected_preset().name;
const std::string &name = preset_bundle.filaments.get_selected_preset_name();
preset_bundle.set_filament_preset(0, name);
}
@ -1251,9 +1251,7 @@ struct Plater::priv
static const std::regex pattern_3mf;
static const std::regex pattern_zip_amf;
static const std::regex pattern_any_amf;
#if ENABLE_VOLUMES_CENTERING_FIXES
static const std::regex pattern_prusa;
#endif // ENABLE_VOLUMES_CENTERING_FIXES
priv(Plater *q, MainFrame *main_frame);
@ -1387,9 +1385,7 @@ const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf
const std::regex Plater::priv::pattern_3mf(".*3mf", std::regex::icase);
const std::regex Plater::priv::pattern_zip_amf(".*[.]zip[.]amf", std::regex::icase);
const std::regex Plater::priv::pattern_any_amf(".*[.](amf|amf[.]xml|zip[.]amf)", std::regex::icase);
#if ENABLE_VOLUMES_CENTERING_FIXES
const std::regex Plater::priv::pattern_prusa(".*prusa", std::regex::icase);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
Plater::priv::priv(Plater *q, MainFrame *main_frame)
: q(q)
@ -1644,9 +1640,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
#if ENABLE_VOLUMES_CENTERING_FIXES
const bool type_prusa = std::regex_match(path.string(), pattern_prusa);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
Slic3r::Model model;
try {
@ -1691,9 +1685,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
{
// The model should now be initialized
#if ENABLE_VOLUMES_CENTERING_FIXES
if (!type_3mf && !type_any_amf && !type_prusa) {
#endif // ENABLE_VOLUMES_CENTERING_FIXES
if (model.looks_like_multipart_object()) {
wxMessageDialog dlg(q, _(L(
"This file contains several objects positioned at multiple heights. "
@ -1704,7 +1696,6 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
model.convert_multipart_object(nozzle_dmrs->values.size());
}
}
#if ENABLE_VOLUMES_CENTERING_FIXES
}
else if ((wxGetApp().get_mode() == comSimple) && (type_3mf || type_any_amf))
{
@ -1761,22 +1752,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
return obj_idxs;
}
}
#endif // ENABLE_VOLUMES_CENTERING_FIXES
#if !ENABLE_VOLUMES_CENTERING_FIXES
if (type_3mf || type_any_amf) {
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
for (ModelObject* model_object : model.objects) {
#if ENABLE_VOLUMES_CENTERING_FIXES
model_object->center_around_origin(false);
#else
model_object->center_around_origin();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
model_object->ensure_on_bed();
}
#if !ENABLE_VOLUMES_CENTERING_FIXES
}
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
// check multi-part object adding for the SLA-printing
if (printer_technology == ptSLA)

View file

@ -526,9 +526,9 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
opt->value = boost::algorithm::clamp<int>(opt->value, 0, int(num_extruders));
}
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset().name;
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset_name();
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = this->filament_presets;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset().name;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
// Serialize the collected "compatible_printers_condition" and "inherits" fields.
// There will be 1 + num_exturders fields for "inherits" and 2 + num_extruders for "compatible_printers_condition" stored.
@ -577,9 +577,9 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
out.erase("compatible_printers_condition");
out.erase("inherits");
out.option<ConfigOptionString >("sla_print_settings_id", true)->value = this->sla_prints.get_selected_preset().name;
out.option<ConfigOptionString >("sla_material_settings_id", true)->value = this->sla_materials.get_selected_preset().name;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset().name;
out.option<ConfigOptionString >("sla_print_settings_id", true)->value = this->sla_prints.get_selected_preset_name();
out.option<ConfigOptionString >("sla_material_settings_id", true)->value = this->sla_materials.get_selected_preset_name();
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
// Serialize the collected "compatible_printers_condition" and "inherits" fields.
// There will be 1 + num_exturders fields for "inherits" and 2 + num_extruders for "compatible_printers_condition" stored.
@ -854,11 +854,11 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
collection_dst.load_preset(path, preset_name_dst, std::move(preset_src->config), activate).is_external = true;
return preset_name_dst;
};
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset().name, true);
load_one(this->sla_prints, tmp_bundle.sla_prints, tmp_bundle.sla_prints .get_selected_preset().name, true);
load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filaments .get_selected_preset().name, true);
load_one(this->sla_materials, tmp_bundle.sla_materials, tmp_bundle.sla_materials.get_selected_preset().name, true);
load_one(this->printers, tmp_bundle.printers, tmp_bundle.printers .get_selected_preset().name, true);
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset_name(), true);
load_one(this->sla_prints, tmp_bundle.sla_prints, tmp_bundle.sla_prints .get_selected_preset_name(), true);
load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filaments .get_selected_preset_name(), true);
load_one(this->sla_materials, tmp_bundle.sla_materials, tmp_bundle.sla_materials.get_selected_preset_name(), true);
load_one(this->printers, tmp_bundle.printers, tmp_bundle.printers .get_selected_preset_name(), true);
this->update_multi_material_filament_presets();
for (size_t i = 1; i < std::min(tmp_bundle.filament_presets.size(), this->filament_presets.size()); ++ i)
this->filament_presets[i] = load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filament_presets[i], false);
@ -1372,10 +1372,10 @@ void PresetBundle::export_configbundle(const std::string &path, bool export_syst
// Export the names of the active presets.
c << std::endl << "[presets]" << std::endl;
c << "print = " << this->prints.get_selected_preset().name << std::endl;
c << "sla_print = " << this->sla_prints.get_selected_preset().name << std::endl;
c << "sla_material = " << this->sla_materials.get_selected_preset().name << std::endl;
c << "printer = " << this->printers.get_selected_preset().name << std::endl;
c << "print = " << this->prints.get_selected_preset_name() << std::endl;
c << "sla_print = " << this->sla_prints.get_selected_preset_name() << std::endl;
c << "sla_material = " << this->sla_materials.get_selected_preset_name() << std::endl;
c << "printer = " << this->printers.get_selected_preset_name() << std::endl;
for (size_t i = 0; i < this->filament_presets.size(); ++ i) {
char suffix[64];
if (i > 0)

View file

@ -67,7 +67,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
int idx_extruder = 0;
int num_extruders = (int)preset_bundle.filament_presets.size();
for (; idx_extruder < num_extruders; ++ idx_extruder)
if (preset_bundle.filament_presets[idx_extruder] == preset_bundle.filaments.get_selected_preset().name)
if (preset_bundle.filament_presets[idx_extruder] == preset_bundle.filaments.get_selected_preset_name())
break;
if (idx_extruder == num_extruders)
// The current filament preset is not active for any extruder.

View file

@ -2557,6 +2557,11 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
{_(L("Expert")), "mode_expert_sq.png"}
};
auto modebtnfn = [](wxCommandEvent &event, int mode_id) {
Slic3r::GUI::wxGetApp().save_mode(mode_id);
event.Skip();
};
m_mode_btns.reserve(3);
for (const auto& button : buttons) {
#ifdef __WXOSX__
@ -2567,37 +2572,22 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
#else
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first));;
#endif // __WXOSX__
m_mode_btns.back()->Bind(wxEVT_BUTTON, std::bind(modebtnfn, std::placeholders::_1, m_mode_btns.size() - 1));
Add(m_mode_btns.back());
}
for (auto btn : m_mode_btns)
{
btn->Bind(wxEVT_BUTTON, [btn, this](wxCommandEvent &event) {
event.Skip();
int mode_id = 0;
for (auto cur_btn : m_mode_btns) {
if (cur_btn == btn)
break;
else
mode_id++;
}
Slic3r::GUI::wxGetApp().save_mode(mode_id);
});
Add(btn);
}
}
void ModeSizer::SetMode(const int mode)
{
for (int m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->SetState(m == mode);
for (size_t m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->SetState(int(m) == mode);
}
void ModeSizer::msw_rescale()
{
for (int m = 0; m < m_mode_btns.size(); m++)
for (size_t m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->msw_rescale();
}