NEW: add align_to_y_axis option for auto-arrange

1. Add align_to_y_axis option for auto-arrange.
   This is useful for auto-arranging of i3 type printers.
2. Change default value of align_to_origin to true when switching
   from non-i3 printers to i3 printers.

JIRA: STUDIO-2583

Change-Id: I7dabab846022a0da030a9fec060a60a4207537a0
(cherry picked from commit 9c549c18ecc1f513644e1bc4a60d6936721a13ac)
This commit is contained in:
manch1n
2023-08-18 19:47:35 +08:00
committed by Lane.Wei
parent 971d219d75
commit 2a79af5729
8 changed files with 143 additions and 7 deletions

View File

@@ -5384,6 +5384,7 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
std::string bed_shrink_x_key = "bed_shrink_x", bed_shrink_y_key = "bed_shrink_y";
std::string multi_material_key = "allow_multi_materials_on_same_plate";
std::string avoid_extrusion_key = "avoid_extrusion_cali_region";
std::string align_to_y_axis_key = "align_to_y_axis";
std::string postfix;
//BBS:
bool seq_print = false;
@@ -5450,6 +5451,22 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
settings_out.avoid_extrusion_cali_region = false;
}
// Align to Y axis. Only enable this option when auto rotation not enabled
{
if (settings_out.enable_rotation) { // do not allow align to Y axis if rotation is enabled
imgui->disabled_begin(true);
settings_out.align_to_y_axis = false;
}
if (imgui->bbl_checkbox(_L("Align to Y axis"), settings.align_to_y_axis)) {
settings_out.align_to_y_axis = settings.align_to_y_axis;
appcfg->set("arrange", align_to_y_axis_key, settings_out.align_to_y_axis ? "1" : "0");
settings_changed = true;
}
if (settings_out.enable_rotation == true) { imgui->disabled_end(); }
}
ImGui::Separator();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(15.0f, 10.0f));
if (imgui->button(_L("Arrange"))) {
@@ -5464,8 +5481,16 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
settings_out.distance = std::max(dist_min, settings_out.distance);
//BBS: add specific arrange settings
if (seq_print) settings_out.is_seq_print = true;
appcfg->set("arrange", dist_key.c_str(), float_to_string_decimal_point(settings_out.distance));
appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0");
if (auto printer_structure_opt = wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnum<PrinterStructure>>("printer_structure")) {
settings_out.align_to_y_axis = (printer_structure_opt->value == PrinterStructure::psI3);
}
else
settings_out.align_to_y_axis = false;
appcfg->set("arrange", dist_key, float_to_string_decimal_point(settings_out.distance));
appcfg->set("arrange", rot_key, settings_out.enable_rotation ? "1" : "0");
appcfg->set("arrange", align_to_y_axis_key, settings_out.align_to_y_axis ? "1" : "0");
settings_changed = true;
}
ImGui::PopStyleVar(1);

View File

@@ -483,6 +483,7 @@ public:
bool is_seq_print = false;
float bed_shrink_x = 0.f;
float bed_shrink_y = 0.f;
bool align_to_y_axis = false;
};
struct OrientSettings
@@ -626,7 +627,6 @@ private:
return *ptr;
}
ArrangeSettings &get_arrange_settings() { return get_arrange_settings(this); }
//BBS:record key botton frequency
@@ -652,6 +652,7 @@ public:
}
void load_arrange_settings();
ArrangeSettings& get_arrange_settings() { return get_arrange_settings(this); }
class SequentialPrintClearance
{

View File

@@ -509,6 +509,7 @@ void ArrangeJob::process()
update_arrange_params(params, *m_plater, m_selected);
update_selected_items_inflation(m_selected, m_plater->config(), params);
update_unselected_items_inflation(m_unselected, m_plater->config(), params);
update_selected_items_axis_align(m_selected, m_plater->config(), params);
Points bedpts = get_shrink_bedpts(m_plater->config(),params);
double scaled_exclusion_gap = scale_(1);
@@ -751,6 +752,7 @@ arrangement::ArrangeParams init_arrange_params(Plater *p)
params.min_obj_distance = scaled(settings.distance);
params.bed_shrink_x = settings.bed_shrink_x;
params.bed_shrink_y = settings.bed_shrink_y;
params.align_to_y_axis = settings.align_to_y_axis;
int state = p->get_prepare_state();
if (state == Job::JobPrepareState::PREPARE_STATE_MENU) {

View File

@@ -82,7 +82,6 @@ arrangement::ArrangeParams init_arrange_params(Plater *p);
void update_arrange_params(arrangement::ArrangeParams &params, const Plater &p, const arrangement::ArrangePolygons &selected);
}} // namespace Slic3r::GUI
#endif // ARRANGEJOB_HPP

View File

@@ -1194,8 +1194,17 @@ void Sidebar::update_presets(Preset::Type preset_type)
printer_tab->update();
}
bool isBBL = wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle);
Preset& printer_preset = wxGetApp().preset_bundle->printers.get_edited_preset();
bool isBBL = printer_preset.is_bbl_vendor_preset(wxGetApp().preset_bundle);
wxGetApp().mainframe->show_calibration_button(!isBBL);
if (auto printer_structure_opt = printer_preset.config.option<ConfigOptionEnum<PrinterStructure>>("printer_structure")) {
wxGetApp().plater()->get_current_canvas3D()->get_arrange_settings().align_to_y_axis = (printer_structure_opt->value == PrinterStructure::psI3);
}
else
wxGetApp().plater()->get_current_canvas3D()->get_arrange_settings().align_to_y_axis = false;
break;
}
@@ -5803,7 +5812,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
//! combo->GetString(combo->GetSelection())
//! instead of
//! combo->GetStringSelection().ToUTF8().data());
std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data()));