mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
FIX: CLI: fix serveral issues of CLI
1. duplicate id issue, MAK-1702 2. shrink issue, STUDIO-4048 Change-Id: Ie952f1ecc5267a60f0ce3220c4a5ea31cf7199ff
This commit is contained in:
parent
990b0947e7
commit
f6ac8b60b7
2 changed files with 27 additions and 5 deletions
|
@ -1814,7 +1814,7 @@ int CLI::run(int argc, char **argv)
|
||||||
//plate_stride = partplate_list.plate_stride_x();
|
//plate_stride = partplate_list.plate_stride_x();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto translate_models = [translate_old, shrink_to_new_bed, old_printable_width, old_printable_depth, old_printable_height, current_printable_width, current_printable_depth, current_printable_height] (Slic3r::GUI::PartPlateList& plate_list) {
|
auto translate_models = [translate_old, shrink_to_new_bed, old_printable_width, old_printable_depth, old_printable_height, current_printable_width, current_printable_depth, current_printable_height] (Slic3r::GUI::PartPlateList& plate_list, DynamicPrintConfig& print_config) {
|
||||||
//BBS: translate old 3mf to correct positions
|
//BBS: translate old 3mf to correct positions
|
||||||
if (translate_old) {
|
if (translate_old) {
|
||||||
//translate the objects
|
//translate the objects
|
||||||
|
@ -1834,6 +1834,11 @@ int CLI::run(int argc, char **argv)
|
||||||
if (shrink_to_new_bed)
|
if (shrink_to_new_bed)
|
||||||
{
|
{
|
||||||
int plate_count = plate_list.get_plate_count();
|
int plate_count = plate_list.get_plate_count();
|
||||||
|
ConfigOptionFloats *wipe_x_option = nullptr, *wipe_y_option = nullptr;
|
||||||
|
if (print_config.has("wipe_tower_x")) {
|
||||||
|
wipe_x_option = dynamic_cast<ConfigOptionFloats *>(print_config.option("wipe_tower_x"));
|
||||||
|
wipe_y_option = dynamic_cast<ConfigOptionFloats *>(print_config.option("wipe_tower_y"));
|
||||||
|
}
|
||||||
for (int index = 0; index < plate_count; index ++) {
|
for (int index = 0; index < plate_count; index ++) {
|
||||||
Slic3r::GUI::PartPlate* cur_plate = (Slic3r::GUI::PartPlate *)plate_list.get_plate(index);
|
Slic3r::GUI::PartPlate* cur_plate = (Slic3r::GUI::PartPlate *)plate_list.get_plate(index);
|
||||||
|
|
||||||
|
@ -1845,6 +1850,16 @@ int CLI::run(int argc, char **argv)
|
||||||
Vec3d offset = new_center - cur_center;
|
Vec3d offset = new_center - cur_center;
|
||||||
|
|
||||||
cur_plate->translate_all_instance(offset);
|
cur_plate->translate_all_instance(offset);
|
||||||
|
if (wipe_x_option) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << boost::format("shrink_to_new_bed, plate %1%: wipe tower src: {%2%, %3%}")%(index+1) %wipe_x_option->get_at(index) %wipe_y_option->get_at(index);
|
||||||
|
ConfigOptionFloat wipe_tower_x(wipe_x_option->get_at(index) + offset(0));
|
||||||
|
ConfigOptionFloat wipe_tower_y(wipe_y_option->get_at(index) + offset(1));
|
||||||
|
|
||||||
|
wipe_x_option->set_at(&wipe_tower_x, index, 0);
|
||||||
|
wipe_y_option->set_at(&wipe_tower_y, index, 0);
|
||||||
|
BOOST_LOG_TRIVIAL(info) << boost::format("shrink_to_new_bed, plate %1% wipe tower changes to: {%2%, %3%}")%(index+1) %wipe_x_option->get_at(index) %wipe_y_option->get_at(index);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("shrink_to_new_bed, plate %1% translate offset: {%2%, %3%, %4%}")%(index+1) %offset[0] %offset[1] %offset[2];
|
BOOST_LOG_TRIVIAL(info) << boost::format("shrink_to_new_bed, plate %1% translate offset: {%2%, %3%, %4%}")%(index+1) %offset[0] %offset[1] %offset[2];
|
||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("shrink_to_new_bed, shrink all the models to current bed size,{%1%, %2%, %3%}")%current_printable_width %current_printable_depth %current_printable_height;
|
BOOST_LOG_TRIVIAL(info) << boost::format("shrink_to_new_bed, shrink all the models to current bed size,{%1%, %2%, %3%}")%current_printable_width %current_printable_depth %current_printable_height;
|
||||||
|
@ -1855,7 +1870,7 @@ int CLI::run(int argc, char **argv)
|
||||||
{
|
{
|
||||||
partplate_list.load_from_3mf_structure(plate_data_src);
|
partplate_list.load_from_3mf_structure(plate_data_src);
|
||||||
|
|
||||||
translate_models(partplate_list);
|
translate_models(partplate_list, m_print_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*for (ModelObject *model_object : m_models[0].objects)
|
/*for (ModelObject *model_object : m_models[0].objects)
|
||||||
|
@ -2535,7 +2550,7 @@ int CLI::run(int argc, char **argv)
|
||||||
model = original_model;
|
model = original_model;
|
||||||
partplate_list.load_from_3mf_structure(plate_data_src);
|
partplate_list.load_from_3mf_structure(plate_data_src);
|
||||||
|
|
||||||
translate_models(partplate_list);
|
translate_models(partplate_list, m_print_config);
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": exit arrange process");
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": exit arrange process");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -2551,7 +2566,7 @@ int CLI::run(int argc, char **argv)
|
||||||
model = original_model;
|
model = original_model;
|
||||||
partplate_list.load_from_3mf_structure(plate_data_src);
|
partplate_list.load_from_3mf_structure(plate_data_src);
|
||||||
|
|
||||||
translate_models(partplate_list);
|
translate_models(partplate_list, m_print_config);
|
||||||
duplicate_count = 0;
|
duplicate_count = 0;
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": exit arrange process");
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": exit arrange process");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -2137,7 +2137,7 @@ void PartPlate::duplicate_all_instance(unsigned int dup_count, bool need_skip, s
|
||||||
ModelObject* newObj = m_model->add_object(*object);
|
ModelObject* newObj = m_model->add_object(*object);
|
||||||
newObj->name = object->name +"_"+ std::to_string(index+1);
|
newObj->name = object->name +"_"+ std::to_string(index+1);
|
||||||
int new_obj_id = m_model->objects.size() - 1;
|
int new_obj_id = m_model->objects.size() - 1;
|
||||||
for ( size_t new_instance_id = 0; new_instance_id < object->instances.size(); new_instance_id++ )
|
for ( size_t new_instance_id = 0; new_instance_id < newObj->instances.size(); new_instance_id++ )
|
||||||
{
|
{
|
||||||
obj_to_instance_set.emplace(std::pair(new_obj_id, new_instance_id));
|
obj_to_instance_set.emplace(std::pair(new_obj_id, new_instance_id));
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": duplicate object into plate: index_pair [%1%,%2%], obj_id %3%") % new_obj_id % new_instance_id % newObj->id().id;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": duplicate object into plate: index_pair [%1%,%2%], obj_id %3%") % new_obj_id % new_instance_id % newObj->id().id;
|
||||||
|
@ -2159,6 +2159,13 @@ void PartPlate::duplicate_all_instance(unsigned int dup_count, bool need_skip, s
|
||||||
if (instance->printable)
|
if (instance->printable)
|
||||||
{
|
{
|
||||||
instance->loaded_id = instance->id().id;
|
instance->loaded_id = instance->id().id;
|
||||||
|
if (need_skip) {
|
||||||
|
while (skip_objects.find(instance->loaded_id) != skip_objects.end())
|
||||||
|
{
|
||||||
|
instance->loaded_id ++;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": duplicated id %1% with skip, try new one %2%") %instance->id().id % instance->loaded_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": set obj %1% instance %2%'s loaded_id to its id %3%, name %4%") % obj_id %instance_id %instance->loaded_id % object->name;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": set obj %1% instance %2%'s loaded_id to its id %3%, name %4%") % obj_id %instance_id %instance->loaded_id % object->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue