arrange changes:

* check is now correct (was half the right distance)
* now the duplicate_distance field is used to reset the widget, and it's not used as a shadow-min anymore
* when switching preset, the arrange widget will change value according to the new duplicate_distance, unless it's set to 0
TODO: update widget when manually updating duplicate_distance or extruder_clearance_radius
This commit is contained in:
supermerill 2021-08-06 19:58:46 +02:00 committed by remi durand
parent 60a38c394c
commit aa1abc251a
6 changed files with 49 additions and 12 deletions

View File

@ -466,6 +466,7 @@ int CLI::run(int argc, char **argv)
if (! m_config.opt_bool("dont_arrange")) {
ArrangeParams arrange_cfg;
arrange_cfg.min_obj_distance = scaled(PrintConfig::min_object_distance(&m_print_config)) * 2;
arrange_cfg.min_obj_distance += m_print_config.opt_float("duplicate_distance");
if (dups > 1) {
try {
// if all input objects have defined position(s) apply duplication to the whole model

View File

@ -1276,7 +1276,7 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin
Polygons convex_hulls_other;
std::map<ObjectID, Polygon> map_model_object_to_convex_hull;
for (const PrintObject *print_object : print.objects()) {
double dist_grow = PrintConfig::min_object_distance(&print.full_print_config());// &print_object->config());
double dist_grow = PrintConfig::min_object_distance(&print.full_print_config()) * 2 ;// &print_object->config());
assert(! print_object->model_object()->instances.empty());
assert(! print_object->instances().empty());
ObjectID model_object_id = print_object->model_object()->id();

View File

@ -667,7 +667,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("duplicate_distance", coFloat);
def->label = L("Distance between objects");
def->category = OptionCategory::output;
def->tooltip = L("Distance used for the auto-arrange feature of the plater.");
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;
@ -5660,9 +5660,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei
//test if called from usaslicer::l240 where it's called on an empty config...
if (dd_opt == nullptr) return 0;
// /2 becasue we only count the grawing for the current object
const double duplicate_distance = dd_opt->value / 2;
double base_dist = duplicate_distance;
double base_dist = 0;
//std::cout << "START min_object_distance =>" << base_dist << "\n";
const ConfigOptionBool* co_opt = config->option<ConfigOptionBool>("complete_objects");
if (co_opt && co_opt->value) {
@ -5676,7 +5674,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei
// min object distance is max(duplicate_distance, clearance_radius)
// /2 becasue we only count the grawing for the current object
//add 1 as safety offset.
double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat() / 2 + 1;
double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat() / 2;
if (extruder_clearance_radius > base_dist) {
base_dist = extruder_clearance_radius;
}

View File

@ -1154,6 +1154,29 @@ void GLCanvas3D::load_arrange_settings()
m_arrange_settings_sla.enable_rotation = (en_rot_sla_str == "1" || en_rot_sla_str == "yes");
}
// update arrange dist from current print conf.
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) {
float dist = 6.f;
if (tech == ptSLA) {
dist = dd_opt->value;
} else if (tech == ptFFF) {
const ConfigOptionBool* co_opt = conf.option<ConfigOptionBool>("complete_objects");
if (co_opt && co_opt->value) {
dist = float(PrintConfig::min_object_distance(m_config) * 2);
} else {
dist = 0.f;
}
dist += dd_opt->value;
}
this->get_arrange_settings().distance = dist;
}
}
PrinterTechnology GLCanvas3D::current_printer_technology() const
{
return m_process->current_printer_technology();
@ -4045,7 +4068,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
} 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));
dist_min = float(PrintConfig::min_object_distance(m_config) * 2);
postfix = "_fff_seq_print";
} else {
dist_min = 0.f;
@ -4059,7 +4082,11 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
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) {
settings.distance = std::max(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;
}
settings_out.distance = settings.distance;
appcfg->set("arrange", dist_key.c_str(), std::to_string(settings_out.distance));
settings_changed = true;
@ -4075,6 +4102,9 @@ 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)
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");

View File

@ -776,12 +776,9 @@ public:
{
const ArrangeSettings &settings = get_arrange_settings(this);
ArrangeSettings ret = settings;
if (&settings == &m_arrange_settings_fff_seq_print) {
ret.distance = std::max(ret.distance, float(PrintConfig::min_object_distance(m_config)));
}
return ret;
}
void set_arrange_settings(const DynamicPrintConfig& conf, PrinterTechnology tech);
// Timestamp for FPS calculation and notification fade-outs.
static int64_t timestamp_now() {

View File

@ -44,6 +44,7 @@
#include "GUI_ObjectList.hpp"
#include "Plater.hpp"
#include "MainFrame.hpp"
#include "GLCanvas3D.hpp"
#include "format.hpp"
#include "PhysicalPrinterDialog.hpp"
#include "UnsavedChangesDialog.hpp"
@ -3369,6 +3370,16 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
apply_config_from_cache();
load_current_preset();
// apply duplicate_distance for print preset
if (m_type == Preset::TYPE_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.get_edited_preset().config, m_presets->get_edited_preset().printer_technology());
}
}
}