mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Changed the "non-uniform scaling is not possible" message.
This commit is contained in:
parent
f2bb070ab9
commit
0ab96ed6b5
8 changed files with 150 additions and 153 deletions
|
@ -54,10 +54,10 @@ Selection::Selection()
|
|||
, m_mode(Instance)
|
||||
, m_type(Empty)
|
||||
, m_valid(false)
|
||||
, m_bounding_box_dirty(true)
|
||||
, m_curved_arrow(16)
|
||||
, m_scale_factor(1.0f)
|
||||
{
|
||||
this->set_bounding_boxes_dirty();
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
m_quadric = ::gluNewQuadric();
|
||||
if (m_quadric != nullptr)
|
||||
|
@ -148,7 +148,7 @@ void Selection::add(unsigned int volume_idx, bool as_single_selection, bool chec
|
|||
}
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::remove(unsigned int volume_idx)
|
||||
|
@ -173,7 +173,7 @@ void Selection::remove(unsigned int volume_idx)
|
|||
}
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::add_object(unsigned int object_idx, bool as_single_selection)
|
||||
|
@ -190,7 +190,7 @@ void Selection::add_object(unsigned int object_idx, bool as_single_selection)
|
|||
do_add_object(object_idx);
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::remove_object(unsigned int object_idx)
|
||||
|
@ -201,7 +201,7 @@ void Selection::remove_object(unsigned int object_idx)
|
|||
do_remove_object(object_idx);
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::add_instance(unsigned int object_idx, unsigned int instance_idx, bool as_single_selection)
|
||||
|
@ -218,7 +218,7 @@ void Selection::add_instance(unsigned int object_idx, unsigned int instance_idx,
|
|||
do_add_instance(object_idx, instance_idx);
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::remove_instance(unsigned int object_idx, unsigned int instance_idx)
|
||||
|
@ -229,7 +229,7 @@ void Selection::remove_instance(unsigned int object_idx, unsigned int instance_i
|
|||
do_remove_instance(object_idx, instance_idx);
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::add_volume(unsigned int object_idx, unsigned int volume_idx, int instance_idx, bool as_single_selection)
|
||||
|
@ -254,7 +254,7 @@ void Selection::add_volume(unsigned int object_idx, unsigned int volume_idx, int
|
|||
}
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::remove_volume(unsigned int object_idx, unsigned int volume_idx)
|
||||
|
@ -270,7 +270,7 @@ void Selection::remove_volume(unsigned int object_idx, unsigned int volume_idx)
|
|||
}
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::add_all()
|
||||
|
@ -288,7 +288,7 @@ void Selection::add_all()
|
|||
}
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::clear()
|
||||
|
@ -304,7 +304,7 @@ void Selection::clear()
|
|||
m_list.clear();
|
||||
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
|
||||
// resets the cache in the sidebar
|
||||
wxGetApp().obj_manipul()->reset_cache();
|
||||
|
@ -323,7 +323,7 @@ void Selection::instances_changed(const std::vector<size_t> &instance_ids_select
|
|||
this->do_add_volume(volume_idx);
|
||||
}
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
// Update the selection based on the map from old indices to new indices after m_volumes changed.
|
||||
|
@ -341,7 +341,7 @@ void Selection::volumes_changed(const std::vector<size_t> &map_volume_old_to_new
|
|||
}
|
||||
m_list = std::move(list_new);
|
||||
update_type();
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
bool Selection::is_single_full_instance() const
|
||||
|
@ -426,6 +426,14 @@ const BoundingBoxf3& Selection::get_bounding_box() const
|
|||
return m_bounding_box;
|
||||
}
|
||||
|
||||
const BoundingBoxf3& Selection::get_unscaled_instance_bounding_box() const
|
||||
{
|
||||
if (m_unscaled_instance_bounding_box_dirty)
|
||||
calc_unscaled_instance_bounding_box();
|
||||
|
||||
return m_unscaled_instance_bounding_box;
|
||||
}
|
||||
|
||||
void Selection::start_dragging()
|
||||
{
|
||||
if (!m_valid)
|
||||
|
@ -473,7 +481,7 @@ void Selection::translate(const Vec3d& displacement, bool local)
|
|||
synchronize_unselected_volumes();
|
||||
#endif // !DISABLE_INSTANCES_SYNCH
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
// Rotate an object around one of the axes. Only one rotation component is expected to be changing.
|
||||
|
@ -580,7 +588,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||
synchronize_unselected_volumes();
|
||||
#endif // !DISABLE_INSTANCES_SYNCH
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::flattening_rotate(const Vec3d& normal)
|
||||
|
@ -621,7 +629,7 @@ void Selection::flattening_rotate(const Vec3d& normal)
|
|||
synchronize_unselected_instances(SYNC_ROTATION_FULL);
|
||||
#endif // !DISABLE_INSTANCES_SYNCH
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::scale(const Vec3d& scale, TransformationType transformation_type)
|
||||
|
@ -629,15 +637,21 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
if (!m_valid)
|
||||
return;
|
||||
|
||||
// Only relative scaling values are allowed in the world coordinate system.
|
||||
assert(! transformation_type.world() || transformation_type.relative());
|
||||
|
||||
for (unsigned int i : m_list)
|
||||
{
|
||||
if (is_single_full_instance() && ! transformation_type.world())
|
||||
(*m_volumes)[i]->set_instance_scaling_factor(scale);
|
||||
GLVolume &volume = *(*m_volumes)[i];
|
||||
if (is_single_full_instance()) {
|
||||
assert(transformation_type.absolute());
|
||||
if (transformation_type.world() && (std::abs(scale.x() - scale.y()) > EPSILON || std::abs(scale.x() - scale.z()) > EPSILON)) {
|
||||
// Non-uniform scaling. Transform the scaling factors into the local coordinate system.
|
||||
// This is only possible, if the instance rotation is mulitples of ninety degrees.
|
||||
assert(Geometry::is_rotation_ninety_degrees(volume.get_instance_rotation()));
|
||||
volume.set_instance_scaling_factor((volume.get_instance_transformation().get_matrix(true, false, true, true).matrix().block<3, 3>(0, 0).transpose() * scale).cwiseAbs());
|
||||
} else
|
||||
volume.set_instance_scaling_factor(scale);
|
||||
}
|
||||
else if (is_single_volume() || is_single_modifier())
|
||||
(*m_volumes)[i]->set_volume_scaling_factor(scale);
|
||||
volume.set_volume_scaling_factor(scale);
|
||||
else
|
||||
{
|
||||
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale);
|
||||
|
@ -647,9 +661,9 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
// extracts scaling factors from the composed transformation
|
||||
Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm());
|
||||
if (transformation_type.joint())
|
||||
(*m_volumes)[i]->set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||
volume.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||
|
||||
(*m_volumes)[i]->set_instance_scaling_factor(new_scale);
|
||||
volume.set_instance_scaling_factor(new_scale);
|
||||
}
|
||||
else if (m_mode == Volume)
|
||||
{
|
||||
|
@ -659,9 +673,9 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
if (transformation_type.joint())
|
||||
{
|
||||
Vec3d offset = m * (m_cache.volumes_data[i].get_volume_position() + m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center);
|
||||
(*m_volumes)[i]->set_volume_offset(m_cache.dragging_center - m_cache.volumes_data[i].get_instance_position() + offset);
|
||||
volume.set_volume_offset(m_cache.dragging_center - m_cache.volumes_data[i].get_instance_position() + offset);
|
||||
}
|
||||
(*m_volumes)[i]->set_volume_scaling_factor(new_scale);
|
||||
volume.set_volume_scaling_factor(new_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -675,7 +689,7 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
|
||||
ensure_on_bed();
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::mirror(Axis axis)
|
||||
|
@ -700,7 +714,7 @@ void Selection::mirror(Axis axis)
|
|||
synchronize_unselected_volumes();
|
||||
#endif // !DISABLE_INSTANCES_SYNCH
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::translate(unsigned int object_idx, const Vec3d& displacement)
|
||||
|
@ -745,7 +759,7 @@ void Selection::translate(unsigned int object_idx, const Vec3d& displacement)
|
|||
}
|
||||
}
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::translate(unsigned int object_idx, unsigned int instance_idx, const Vec3d& displacement)
|
||||
|
@ -790,7 +804,7 @@ void Selection::translate(unsigned int object_idx, unsigned int instance_idx, co
|
|||
}
|
||||
}
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
this->set_bounding_boxes_dirty();
|
||||
}
|
||||
|
||||
void Selection::erase()
|
||||
|
@ -1396,7 +1410,23 @@ void Selection::calc_bounding_box() const
|
|||
m_bounding_box.merge((*m_volumes)[i]->transformed_convex_hull_bounding_box());
|
||||
}
|
||||
}
|
||||
m_bounding_box_dirty = false;
|
||||
m_bounding_box_dirty = false;
|
||||
}
|
||||
|
||||
void Selection::calc_unscaled_instance_bounding_box() const
|
||||
{
|
||||
m_unscaled_instance_bounding_box = BoundingBoxf3();
|
||||
if (m_valid)
|
||||
{
|
||||
for (unsigned int i : m_list)
|
||||
{
|
||||
const GLVolume &volume = *(*m_volumes)[i];
|
||||
Transform3d trafo = volume.get_instance_transformation().get_matrix(false, false, true, false) * volume.get_volume_transformation().get_matrix();
|
||||
trafo.translation()(2) += volume.get_sla_shift_z();
|
||||
m_unscaled_instance_bounding_box.merge(volume.transformed_convex_hull_bounding_box(trafo));
|
||||
}
|
||||
}
|
||||
m_unscaled_instance_bounding_box_dirty = false;
|
||||
}
|
||||
|
||||
void Selection::render_selected_volumes() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue