Tech ENABLE_WORLD_COORDINATE - Modified method Selection::requires_uniform_scale()

This commit is contained in:
enricoturri1966 2021-10-18 15:26:31 +02:00
parent 5649151444
commit 8cf66f52f6
2 changed files with 16 additions and 10 deletions

View File

@ -241,9 +241,12 @@ void GLGizmosManager::update_data()
enable_grabber(Rotate, 0, !is_wipe_tower);
enable_grabber(Rotate, 1, !is_wipe_tower);
#if ENABLE_WORLD_COORDINATE
bool enable_scale_xyz = !selection.requires_uniform_scale();
#else
bool enable_scale_xyz = selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier();
for (unsigned int i = 0; i < 6; ++i)
{
#endif // ENABLE_WORLD_COORDINATE
for (unsigned int i = 0; i < 6; ++i) {
enable_grabber(Scale, i, enable_scale_xyz);
}
@ -252,8 +255,7 @@ void GLGizmosManager::update_data()
? get_current()->get_requirements()
: CommonGizmosDataID(0));
if (selection.is_single_full_instance())
{
if (selection.is_single_full_instance()) {
// all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
set_scale(volume->get_instance_scaling_factor());
@ -263,8 +265,7 @@ void GLGizmosManager::update_data()
set_sla_support_data(model_object);
set_painter_gizmo_data();
}
else if (selection.is_single_volume() || selection.is_single_modifier())
{
else if (selection.is_single_volume() || selection.is_single_modifier()) {
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
set_scale(volume->get_volume_scaling_factor());
set_rotation(Vec3d::Zero());
@ -272,8 +273,7 @@ void GLGizmosManager::update_data()
set_sla_support_data(nullptr);
set_painter_gizmo_data();
}
else if (is_wipe_tower)
{
else if (is_wipe_tower) {
DynamicPrintConfig& config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
set_scale(Vec3d::Ones());
set_rotation(Vec3d(0., 0., (M_PI/180.) * dynamic_cast<const ConfigOptionFloat*>(config.option("wipe_tower_rotation_angle"))->value));
@ -281,8 +281,7 @@ void GLGizmosManager::update_data()
set_sla_support_data(nullptr);
set_painter_gizmo_data();
}
else
{
else {
set_scale(Vec3d::Ones());
set_rotation(Vec3d::Zero());
set_flattening_data(selection.is_from_single_object() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);

View File

@ -600,8 +600,15 @@ bool Selection::matches(const std::vector<unsigned int>& volume_idxs) const
bool Selection::requires_uniform_scale() const
{
#if ENABLE_WORLD_COORDINATE
if (is_single_modifier() || is_single_volume())
return !Geometry::is_rotation_ninety_degrees(Geometry::Transformation(get_volume(*m_list.begin())->world_matrix()).get_rotation());
else if (is_single_full_instance() && wxGetApp().obj_manipul()->get_world_coordinates())
return !Geometry::is_rotation_ninety_degrees(get_volume(*m_list.begin())->get_instance_rotation());
#else
if (is_single_full_instance() || is_single_modifier() || is_single_volume())
return false;
#endif // ENABLE_WORLD_COORDINATE
return true;
}