mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-25 02:54:29 +08:00
fix default arrange distance when 0 and when opening the slicer.
supermerill/SuperSlicer#1648
This commit is contained in:
parent
52e58ff357
commit
240a282625
@ -702,13 +702,13 @@ void PrintConfigDef::init_fff_params()
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("duplicate_distance", coFloat);
|
||||
def->label = L("Distance between objects");
|
||||
def->label = L("Default distance between objects");
|
||||
def->category = OptionCategory::output;
|
||||
def->tooltip = L("Default distance used for the auto-arrange feature of the plater.\nSet to 0 to use the last value instead.");
|
||||
def->sidetext = L("mm");
|
||||
def->aliases = { "multiply_distance" };
|
||||
def->min = 0;
|
||||
def->set_default_value(new ConfigOptionFloat(6));
|
||||
def->set_default_value(new ConfigOptionFloat(0));
|
||||
|
||||
def = this->add("end_gcode", coString);
|
||||
def->label = L("End G-code");
|
||||
|
@ -1137,13 +1137,13 @@ void GLCanvas3D::load_arrange_settings()
|
||||
wxGetApp().app_config->get("arrange", "enable_rotation_sla");
|
||||
|
||||
if (!dist_fff_str.empty())
|
||||
m_arrange_settings_fff.distance = std::stof(dist_fff_str);
|
||||
m_arrange_settings_fff.previously_used_distance = std::stof(dist_fff_str);
|
||||
|
||||
if (!dist_fff_seq_print_str.empty())
|
||||
m_arrange_settings_fff_seq_print.distance = std::stof(dist_fff_seq_print_str);
|
||||
m_arrange_settings_fff_seq_print.previously_used_distance = std::stof(dist_fff_seq_print_str);
|
||||
|
||||
if (!dist_sla_str.empty())
|
||||
m_arrange_settings_sla.distance = std::stof(dist_sla_str);
|
||||
m_arrange_settings_sla.previously_used_distance = std::stof(dist_sla_str);
|
||||
|
||||
if (!en_rot_fff_str.empty())
|
||||
m_arrange_settings_fff.enable_rotation = (en_rot_fff_str == "1" || en_rot_fff_str == "yes");
|
||||
@ -1159,9 +1159,8 @@ void GLCanvas3D::load_arrange_settings()
|
||||
void GLCanvas3D::set_arrange_settings(const DynamicPrintConfig& conf, PrinterTechnology tech) {
|
||||
|
||||
const ConfigOptionFloat* dd_opt = conf.option<ConfigOptionFloat>("duplicate_distance");
|
||||
const ConfigOptionFloat* dd2_opt = m_config->option<ConfigOptionFloat>("duplicate_distance");
|
||||
|
||||
if (dd_opt && dd_opt != 0) {
|
||||
if (dd_opt && dd_opt->value != 0) {
|
||||
float dist = 6.f;
|
||||
if (tech == ptSLA) {
|
||||
dist = dd_opt->value;
|
||||
@ -1175,9 +1174,42 @@ void GLCanvas3D::set_arrange_settings(const DynamicPrintConfig& conf, PrinterTec
|
||||
dist += dd_opt->value;
|
||||
}
|
||||
this->get_arrange_settings().distance = dist;
|
||||
} else {
|
||||
this->get_arrange_settings().distance = this->get_arrange_settings().previously_used_distance;
|
||||
}
|
||||
}
|
||||
|
||||
// update last arrange dist from current print conf.
|
||||
void GLCanvas3D::set_last_arrange_settings(float new_value) {
|
||||
|
||||
PrinterTechnology ptech = current_printer_technology();
|
||||
std::string postfix;
|
||||
|
||||
auto* ptr = &m_arrange_settings_fff;
|
||||
|
||||
if (ptech == ptSLA) {
|
||||
ptr = &m_arrange_settings_sla;
|
||||
postfix = "_sla";
|
||||
} else if (ptech == ptFFF) {
|
||||
auto co_opt = m_config->template option<ConfigOptionBool>("complete_objects");
|
||||
if (co_opt && co_opt->value) {
|
||||
ptr = &m_arrange_settings_fff_seq_print;
|
||||
postfix = "_fff_seq_print";
|
||||
} else {
|
||||
ptr = &m_arrange_settings_fff;
|
||||
postfix = "_fff";
|
||||
}
|
||||
}
|
||||
ptr->previously_used_distance = new_value;
|
||||
|
||||
auto& appcfg = wxGetApp().app_config;
|
||||
std::string dist_key = "min_object_distance", rot_key = "enable_rotation";
|
||||
dist_key += postfix;
|
||||
rot_key += postfix;
|
||||
appcfg->set("arrange", dist_key.c_str(), std::to_string(new_value));
|
||||
appcfg->set("arrange", rot_key.c_str(), ptr->enable_rotation ? "1" : "0");
|
||||
}
|
||||
|
||||
PrinterTechnology GLCanvas3D::current_printer_technology() const
|
||||
{
|
||||
return m_process->current_printer_technology();
|
||||
@ -4060,47 +4092,38 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
||||
ArrangeSettings settings = get_arrange_settings();
|
||||
ArrangeSettings &settings_out = get_arrange_settings();
|
||||
|
||||
auto &appcfg = wxGetApp().app_config;
|
||||
PrinterTechnology ptech = m_process->current_printer_technology();
|
||||
|
||||
bool settings_changed = false;
|
||||
float dist_min = 0.f;
|
||||
std::string dist_key = "min_object_distance", rot_key = "enable_rotation";
|
||||
std::string postfix;
|
||||
|
||||
if (ptech == ptSLA) {
|
||||
dist_min = 0.f;
|
||||
postfix = "_sla";
|
||||
dist_min = 0.f;
|
||||
} else if (ptech == ptFFF) {
|
||||
auto co_opt = m_config->option<ConfigOptionBool>("complete_objects");
|
||||
if (co_opt && co_opt->value) {
|
||||
dist_min = float(PrintConfig::min_object_distance(m_config) * 2);
|
||||
postfix = "_fff_seq_print";
|
||||
dist_min = float(PrintConfig::min_object_distance(m_config) * 2);
|
||||
} else {
|
||||
dist_min = 0.f;
|
||||
postfix = "_fff";
|
||||
dist_min = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
dist_key += postfix;
|
||||
rot_key += postfix;
|
||||
|
||||
imgui->text(GUI::format_wxstr(_L("Press %1%left mouse button to enter the exact value"), shortkey_ctrl_prefix()));
|
||||
|
||||
if (imgui->slider_float(_L("Spacing"), &settings.distance, dist_min, 100.0f, "%5.2f") || dist_min > settings.distance) {
|
||||
if (dist_min > settings.distance) {
|
||||
const ConfigOptionFloat* dd_opt = this->m_config->option<ConfigOptionFloat>("duplicate_distance");
|
||||
if (dd_opt)
|
||||
settings.distance = dist_min + dd_opt->value;
|
||||
if (dd_opt->value == 0)
|
||||
settings_out.distance = settings.previously_used_distance;
|
||||
else
|
||||
settings.distance = dist_min + dd_opt->value;
|
||||
}
|
||||
settings_out.distance = settings.distance;
|
||||
appcfg->set("arrange", dist_key.c_str(), std::to_string(settings_out.distance));
|
||||
settings_changed = true;
|
||||
}
|
||||
|
||||
if (imgui->checkbox(_L("Enable rotations (slow)"), settings.enable_rotation)) {
|
||||
settings_out.enable_rotation = settings.enable_rotation;
|
||||
appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0");
|
||||
settings_changed = true;
|
||||
}
|
||||
|
||||
@ -4109,11 +4132,12 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
||||
if (imgui->button(_L("Reset"))) {
|
||||
settings_out = ArrangeSettings{};
|
||||
const ConfigOptionFloat* dd_opt = this->m_config->option<ConfigOptionFloat>("duplicate_distance");
|
||||
if(dd_opt)
|
||||
if (dd_opt)
|
||||
if (dd_opt->value == 0)
|
||||
settings_out.distance = settings.previously_used_distance;
|
||||
else
|
||||
settings_out.distance = dist_min + dd_opt->value;
|
||||
settings_out.distance = std::max(dist_min, settings_out.distance);
|
||||
appcfg->set("arrange", dist_key.c_str(), std::to_string(settings_out.distance));
|
||||
appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0");
|
||||
settings_changed = true;
|
||||
}
|
||||
|
||||
|
@ -426,6 +426,7 @@ public:
|
||||
|
||||
struct ArrangeSettings
|
||||
{
|
||||
float previously_used_distance = 6.; // last distance used when last pressed on "arrange". Used when "duplicate_distance" is set to 0
|
||||
float distance = 6.;
|
||||
// float distance_seq_print = 6.; // Used when sequential print is ON
|
||||
// float distance_sla = 6.;
|
||||
@ -783,6 +784,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
void set_arrange_settings(const DynamicPrintConfig& conf, PrinterTechnology tech);
|
||||
void set_last_arrange_settings(float new_dist);
|
||||
|
||||
// Timestamp for FPS calculation and notification fade-outs.
|
||||
static int64_t timestamp_now() {
|
||||
|
@ -200,6 +200,11 @@ void ArrangeJob::process()
|
||||
"Some geometries may be invalid.")));
|
||||
}
|
||||
|
||||
//update last arrange value
|
||||
if (!was_canceled()) {
|
||||
m_plater->canvas3D()->set_last_arrange_settings(settings.distance);
|
||||
}
|
||||
|
||||
// finalize just here.
|
||||
update_status(int(count),
|
||||
was_canceled() ? _(L("Arranging canceled."))
|
||||
|
@ -1187,6 +1187,10 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
wxGetApp().plater()->on_extruders_change(boost::any_cast<int>(value));
|
||||
}
|
||||
|
||||
if (opt_key == "duplicate_distance") {
|
||||
wxGetApp().mainframe->plater()->canvas3D()->set_arrange_settings(m_presets->get_edited_preset().config, m_presets->get_edited_preset().printer_technology());
|
||||
}
|
||||
|
||||
//wxGetApp().preset_bundle->value_changed(opt_key);
|
||||
// update phony fields
|
||||
|
||||
@ -3099,6 +3103,12 @@ void Tab::load_current_preset()
|
||||
|
||||
update_ui_items_related_on_parent_preset(m_presets->get_selected_preset_parent());
|
||||
|
||||
|
||||
// apply duplicate_distance for print preset
|
||||
if (m_type == Preset::TYPE_FFF_PRINT || m_type == Preset::TYPE_SLA_PRINT) {
|
||||
wxGetApp().mainframe->plater()->canvas3D()->set_arrange_settings(m_presets->get_edited_preset().config, m_presets->get_edited_preset().printer_technology());
|
||||
}
|
||||
|
||||
// m_undo_to_sys_btn->Enable(!preset.is_default);
|
||||
|
||||
#if 0
|
||||
@ -3416,13 +3426,6 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
|
||||
|
||||
load_current_preset();
|
||||
|
||||
// apply duplicate_distance for print preset
|
||||
if (m_type == Preset::TYPE_FFF_PRINT || m_type == Preset::TYPE_SLA_PRINT) {
|
||||
wxGetApp().mainframe->plater()->canvas3D()->set_arrange_settings(m_presets->get_edited_preset().config, m_presets->get_edited_preset().printer_technology());
|
||||
}
|
||||
if (m_type == Preset::TYPE_PRINTER) {
|
||||
wxGetApp().mainframe->plater()->canvas3D()->set_arrange_settings(m_preset_bundle->prints(m_presets->get_edited_preset().printer_technology()).get_edited_preset().config, m_presets->get_edited_preset().printer_technology());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user