FIX: fix the bed shape not correct issue when loading old 3mf
Change-Id: I924c47ea4a1f21b5e9854abdcedfe8b689ddcb67
This commit is contained in:
parent
d484b5e5fb
commit
e20adc16dc
|
@ -550,6 +550,7 @@ int CLI::run(int argc, char **argv)
|
|||
Semver old_version(1, 5, 9);
|
||||
if ((file_version < old_version) && !config.empty()) {
|
||||
translate_old = true;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("old 3mf version %1%, need to translate")%file_version.to_string();
|
||||
}
|
||||
|
||||
/*for (ModelObject *model_object : model.objects)
|
||||
|
@ -1294,13 +1295,14 @@ int CLI::run(int argc, char **argv)
|
|||
double height_to_lid = m_print_config.opt_float("extruder_clearance_height_to_lid");
|
||||
double height_to_rod = m_print_config.opt_float("extruder_clearance_height_to_rod");
|
||||
double plate_stride;
|
||||
std::string bed_texture;
|
||||
if (m_models.size() > 0)
|
||||
{
|
||||
std::string bed_texture;
|
||||
if (translate_old) {
|
||||
current_width = bedfs[2].x() - bedfs[0].x();
|
||||
current_depth = bedfs[2].y() - bedfs[0].y();
|
||||
current_height = print_height;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("translate old 3mf, switch to old bed size,{%1%, %2%, %3%}")%(current_width + bed3d_ax3s_default_tip_radius)%(current_depth+bed3d_ax3s_default_tip_radius) %current_height;
|
||||
partplate_list.reset_size(current_width + bed3d_ax3s_default_tip_radius, current_depth + bed3d_ax3s_default_tip_radius, current_height, false);
|
||||
}
|
||||
else {
|
||||
|
@ -1325,7 +1327,8 @@ int CLI::run(int argc, char **argv)
|
|||
|
||||
cur_plate->translate_all_instance(new_origin - cur_origin);
|
||||
}
|
||||
partplate_list.reset_size(current_width, current_depth, current_height);
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("translate old 3mf, switch back to current bed size,{%1%, %2%, %3%}")%current_width %current_depth %current_height;
|
||||
partplate_list.reset_size(current_width, current_depth, current_height, true, true);
|
||||
}
|
||||
}
|
||||
/*for (ModelObject *model_object : m_models[0].objects)
|
||||
|
|
|
@ -2032,17 +2032,27 @@ void PartPlate::generate_exclude_polygon(ExPolygon &exclude_polygon)
|
|||
|
||||
bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Vec2d position, float height_to_lid, float height_to_rod)
|
||||
{
|
||||
if ((m_shape == shape)&&(m_exclude_area == exclude_areas)
|
||||
Pointfs new_shape, new_exclude_areas;
|
||||
|
||||
for (const Vec2d& p : shape) {
|
||||
new_shape.push_back(Vec2d(p.x() + position.x(), p.y() + position.y()));
|
||||
}
|
||||
|
||||
for (const Vec2d& p : exclude_areas) {
|
||||
new_exclude_areas.push_back(Vec2d(p.x() + position.x(), p.y() + position.y()));
|
||||
}
|
||||
if ((m_shape == new_shape)&&(m_exclude_area == new_exclude_areas)
|
||||
&&(m_height_to_lid == height_to_lid)&&(m_height_to_rod == height_to_rod)) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "PartPlate same shape";
|
||||
BOOST_LOG_TRIVIAL(info) << "PartPlate same shape, skip directly";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_height_to_lid = height_to_lid;
|
||||
m_height_to_rod = height_to_rod;
|
||||
|
||||
if ((m_shape != shape) || (m_exclude_area != exclude_areas))
|
||||
if ((m_shape != new_shape) || (m_exclude_area != new_exclude_areas))
|
||||
{
|
||||
m_shape.clear();
|
||||
/*m_shape.clear();
|
||||
for (const Vec2d& p : shape) {
|
||||
m_shape.push_back(Vec2d(p.x() + position.x(), p.y() + position.y()));
|
||||
}
|
||||
|
@ -2050,7 +2060,9 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve
|
|||
m_exclude_area.clear();
|
||||
for (const Vec2d& p : exclude_areas) {
|
||||
m_exclude_area.push_back(Vec2d(p.x() + position.x(), p.y() + position.y()));
|
||||
}
|
||||
}*/
|
||||
m_shape = std::move(new_shape);
|
||||
m_exclude_area = std::move(new_exclude_areas);
|
||||
|
||||
calc_bounding_boxes();
|
||||
|
||||
|
@ -2738,7 +2750,7 @@ void PartPlateList::release_icon_textures()
|
|||
}
|
||||
|
||||
//this may be happened after machine changed
|
||||
void PartPlateList::reset_size(int width, int depth, int height, bool reload_objects)
|
||||
void PartPlateList::reset_size(int width, int depth, int height, bool reload_objects, bool update_shapes)
|
||||
{
|
||||
Vec3d origin1, origin2;
|
||||
|
||||
|
@ -2750,6 +2762,9 @@ void PartPlateList::reset_size(int width, int depth, int height, bool reload_obj
|
|||
m_plate_depth = depth;
|
||||
m_plate_height = height;
|
||||
update_all_plates_pos_and_size(false, false);
|
||||
if (update_shapes) {
|
||||
set_shapes(m_shape, m_exclude_areas, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
|
||||
}
|
||||
if (reload_objects)
|
||||
reload_all_objects();
|
||||
else
|
||||
|
@ -3145,11 +3160,11 @@ int PartPlateList::select_plate(int index)
|
|||
|
||||
m_current_plate = index;
|
||||
m_plate_list[m_current_plate]->set_selected();
|
||||
|
||||
|
||||
//BBS
|
||||
if(m_model)
|
||||
m_model->curr_plate_index = index;
|
||||
|
||||
|
||||
//BBS update bed origin
|
||||
if (m_intialized && m_plater) {
|
||||
Vec2d pos = compute_shape_position(index, m_plate_cols);
|
||||
|
|
|
@ -571,7 +571,7 @@ public:
|
|||
~PartPlateList();
|
||||
|
||||
//this may be happened after machine changed
|
||||
void reset_size(int width, int depth, int height, bool reload_objects = true);
|
||||
void reset_size(int width, int depth, int height, bool reload_objects = true, bool update_shapes = false);
|
||||
//clear all the instances in the plate, but keep the plates
|
||||
void clear(bool delete_plates = false, bool release_print_list = false, bool except_locked = false, int plate_index = -1);
|
||||
//clear all the instances in the plate, and delete the plates, only keep the first default plate
|
||||
|
|
|
@ -3580,7 +3580,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
|
||||
cur_plate->translate_all_instance(new_origin - cur_origin);
|
||||
}
|
||||
partplate_list.reset_size(current_width, current_depth, current_height);
|
||||
partplate_list.reset_size(current_width, current_depth, current_height, true, true);
|
||||
}
|
||||
|
||||
//BBS: add gcode loading logic in the end
|
||||
|
|
Loading…
Reference in New Issue