Offset used to place newly added volumes and instances proportional to the bed max size

This commit is contained in:
Enrico Turri 2019-04-12 15:31:33 +02:00
parent c8b467bf9f
commit 7d15ee8fd9
5 changed files with 15 additions and 7 deletions

View File

@ -3140,6 +3140,11 @@ Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos)
return Linef3(_mouse_to_3d(mouse_pos, &z0), _mouse_to_3d(mouse_pos, &z1)); return Linef3(_mouse_to_3d(mouse_pos, &z0), _mouse_to_3d(mouse_pos, &z1));
} }
double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const
{
return factor * m_bed.get_bounding_box().max_size();
}
bool GLCanvas3D::_is_shown_on_screen() const bool GLCanvas3D::_is_shown_on_screen() const
{ {
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;

View File

@ -583,6 +583,8 @@ public:
void refresh_camera_scene_box() { m_camera.set_scene_box(scene_bounding_box()); } void refresh_camera_scene_box() { m_camera.set_scene_box(scene_bounding_box()); }
bool is_mouse_dragging() const { return m_mouse.dragging; } bool is_mouse_dragging() const { return m_mouse.dragging; }
double get_size_proportional_to_max_bed_size(double factor) const;
private: private:
bool _is_shown_on_screen() const; bool _is_shown_on_screen() const;

View File

@ -1437,9 +1437,7 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
const wxString name = _(L("Generic")) + "-" + _(type_name); const wxString name = _(L("Generic")) + "-" + _(type_name);
TriangleMesh mesh; TriangleMesh mesh;
auto& bed_shape = printer_config().option<ConfigOptionPoints>("bed_shape")->values; double side = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.1);
const auto& sz = BoundingBoxf(bed_shape).size();
const auto side = 0.1 * std::max(sz(0), sz(1));
if (type_name == "Box") if (type_name == "Box")
// Sitting on the print bed, left front front corner at (0, 0). // Sitting on the print bed, left front front corner at (0, 0).

View File

@ -3225,8 +3225,9 @@ void Plater::increase_instances(size_t num)
bool was_one_instance = model_object->instances.size()==1; bool was_one_instance = model_object->instances.size()==1;
float offset = 10.0; double offset_base = canvas3D()->get_size_proportional_to_max_bed_size(0.05);
for (size_t i = 0; i < num; i++, offset += 10.0) { double offset = offset_base;
for (size_t i = 0; i < num; i++, offset += offset_base) {
Vec3d offset_vec = model_instance->get_offset() + Vec3d(offset, offset, 0.0); Vec3d offset_vec = model_instance->get_offset() + Vec3d(offset, offset, 0.0);
model_object->add_instance(offset_vec, model_instance->get_scaling_factor(), model_instance->get_rotation(), model_instance->get_mirror()); model_object->add_instance(offset_vec, model_instance->get_scaling_factor(), model_instance->get_rotation(), model_instance->get_mirror());
// p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec)); // p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec));

View File

@ -1778,7 +1778,8 @@ void Selection::paste_volumes_from_clipboard()
ModelVolume* dst_volume = dst_object->add_volume(*src_volume); ModelVolume* dst_volume = dst_object->add_volume(*src_volume);
dst_volume->config = src_volume->config; dst_volume->config = src_volume->config;
dst_volume->set_new_unique_id(); dst_volume->set_new_unique_id();
dst_volume->translate(10.0, 10.0, 0.0); double offset = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.05);
dst_volume->translate(offset, offset, 0.0);
volumes.push_back(dst_volume); volumes.push_back(dst_volume);
} }
wxGetApp().obj_list()->paste_volumes_into_list(obj_idx, volumes); wxGetApp().obj_list()->paste_volumes_into_list(obj_idx, volumes);
@ -1792,7 +1793,8 @@ void Selection::paste_objects_from_clipboard()
for (const ModelObject* src_object : src_objects) for (const ModelObject* src_object : src_objects)
{ {
ModelObject* dst_object = m_model->add_object(*src_object); ModelObject* dst_object = m_model->add_object(*src_object);
dst_object->translate(10.0, 10.0, 0.0); double offset = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.05);
dst_object->translate(offset, offset, 0.0);
object_idxs.push_back(m_model->objects.size() - 1); object_idxs.push_back(m_model->objects.size() - 1);
} }