GizmoScale: Suppress ununiversal scale for cut objects

+ Gizmos/GLGizmoRotate: Deleted changes which was made for GizmoCut, but aren't used any more
This commit is contained in:
YuSanka 2022-07-28 14:23:51 +02:00
parent 05c22604fb
commit 31800bb85d
8 changed files with 25 additions and 19 deletions

View File

@ -12,6 +12,7 @@
#include "MainFrame.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
#include "Gizmos/GLGizmoCut.hpp"
#include "Gizmos/GLGizmoScale.hpp"
#include "OptionsGroup.hpp"
#include "Tab.hpp"
@ -2503,6 +2504,8 @@ void ObjectList::part_selection_changed()
const auto item = GetSelection();
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager();
if ( multiple_selection() || (item && m_objects_model->GetItemType(item) == itInstanceRoot )) {
og_name = _L("Group manipulation");
@ -2579,7 +2582,6 @@ void ObjectList::part_selection_changed()
info_type == InfoItemType::CustomSeam ? GLGizmosManager::EType::Seam :
info_type == InfoItemType::Cut ? GLGizmosManager::EType::Cut :
GLGizmosManager::EType::MmuSegmentation;
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager();
if (gizmos_mgr.get_current_type() != gizmo_type)
gizmos_mgr.open_gizmo(gizmo_type);
if (info_type == InfoItemType::Cut) {
@ -2656,6 +2658,9 @@ void ObjectList::part_selection_changed()
if (disable_ununiform_scale)
wxGetApp().obj_manipul()->DisableUnuniformScale();
}
if (GLGizmoScale3D* scale = dynamic_cast<GLGizmoScale3D*>(gizmos_mgr.get_gizmo(GLGizmosManager::Scale)))
scale->enable_ununiversal_scale(!disable_ununiform_scale);
}
if (update_and_show_settings)

View File

@ -602,7 +602,7 @@ void ObjectManipulation::DisableScale()
void ObjectManipulation::DisableUnuniformScale()
{
m_lock_bnt->disable();
m_lock_bnt->Enable(false);
}
void ObjectManipulation::update_ui_from_settings()

View File

@ -58,12 +58,6 @@ void GLGizmoRotate::set_angle(double angle)
m_angle = angle;
}
void GLGizmoRotate::set_center(const Vec3d& center)
{
m_forced_center = center;
m_has_forced_center = true;
}
std::string GLGizmoRotate::get_tooltip() const
{
std::string axis;
@ -301,13 +295,13 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();
if (coordinates_type == ECoordinatesType::World) {
m_bounding_box = selection.get_bounding_box();
m_center = m_has_forced_center ? m_forced_center : m_bounding_box.center();
m_center = m_bounding_box.center();
}
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
const GLVolume& v = *selection.get_first_volume();
m_bounding_box = v.transformed_convex_hull_bounding_box(
v.get_instance_transformation().get_scaling_factor_matrix() * v.get_volume_transformation().get_scaling_factor_matrix());
m_center = v.world_matrix() * (m_has_forced_center ? m_forced_center : m_bounding_box.center());
m_center = v.world_matrix() * m_bounding_box.center();
}
else {
m_bounding_box.reset();
@ -318,7 +312,7 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
}
const Geometry::Transformation inst_trafo = selection.get_first_volume()->get_instance_transformation();
m_bounding_box = m_bounding_box.transformed(inst_trafo.get_scaling_factor_matrix());
m_center = inst_trafo.get_matrix_no_scaling_factor() * (m_has_forced_center ? m_forced_center : m_bounding_box.center());
m_center = inst_trafo.get_matrix_no_scaling_factor() * m_bounding_box.center();
}
m_radius = Offset + m_bounding_box.radius();
@ -867,7 +861,7 @@ GLGizmoRotate3D::GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_fil
bool GLGizmoRotate3D::on_mouse(const wxMouseEvent &mouse_event)
{
if (mouse_event.Dragging() && m_dragging && !m_use_only_grabbers) {
if (mouse_event.Dragging() && m_dragging) {
// Apply new temporary rotations
#if ENABLE_WORLD_COORDINATE
TransformationType transformation_type;
@ -954,8 +948,7 @@ void GLGizmoRotate3D::on_start_dragging()
void GLGizmoRotate3D::on_stop_dragging()
{
assert(0 <= m_hover_id && m_hover_id < 3);
if (!m_use_only_grabbers)
m_parent.do_rotate(L("Gizmo-Rotate"));
m_parent.do_rotate(L("Gizmo-Rotate"));
m_gizmos[m_hover_id].stop_dragging();
}

View File

@ -34,7 +34,6 @@ private:
float m_snap_coarse_out_radius{ 0.0f };
float m_snap_fine_in_radius{ 0.0f };
float m_snap_fine_out_radius{ 0.0f };
bool m_has_forced_center{false};
Vec3d m_forced_center{ Vec3d::Zero() };
#if ENABLE_WORLD_COORDINATE
BoundingBoxf3 m_bounding_box;
@ -70,7 +69,6 @@ public:
double get_angle() const { return m_angle; }
void set_angle(double angle);
void set_center(const Vec3d& center);
std::string get_tooltip() const override;
@ -135,15 +133,12 @@ private:
class GLGizmoRotate3D : public GLGizmoBase
{
std::array<GLGizmoRotate, 3> m_gizmos;
bool m_use_only_grabbers{ false };
public:
GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
Vec3d get_rotation() const { return Vec3d(m_gizmos[X].get_angle(), m_gizmos[Y].get_angle(), m_gizmos[Z].get_angle()); }
void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation.x()); m_gizmos[Y].set_angle(rotation.y()); m_gizmos[Z].set_angle(rotation.z()); }
void set_center(const Vec3d& center) { m_gizmos[X].set_center(center); m_gizmos[Y].set_center(center); m_gizmos[Z].set_center(center); }
void use_only_grabbers() { m_use_only_grabbers = true; }
std::string get_tooltip() const override {
std::string tooltip = m_gizmos[X].get_tooltip();

View File

@ -104,6 +104,12 @@ bool GLGizmoScale3D::on_mouse(const wxMouseEvent &mouse_event)
return use_grabbers(mouse_event);
}
void GLGizmoScale3D::enable_ununiversal_scale(bool enable)
{
for (unsigned int i = 0; i < 6; ++i)
m_grabbers[i].enabled = enable;
}
void GLGizmoScale3D::data_changed()
{
#if ENABLE_WORLD_COORDINATE

View File

@ -85,6 +85,7 @@ public:
bool on_mouse(const wxMouseEvent &mouse_event) override;
void data_changed() override;
void enable_ununiversal_scale(bool enable);
protected:
virtual bool on_init() override;
virtual std::string on_get_name() const override;

View File

@ -1042,6 +1042,11 @@ GLGizmoBase* GLGizmosManager::get_current() const
return ((m_current == Undefined) || m_gizmos.empty()) ? nullptr : m_gizmos[m_current].get();
}
GLGizmoBase* GLGizmosManager::get_gizmo(GLGizmosManager::EType type) const
{
return ((type == Undefined) || m_gizmos.empty()) ? nullptr : m_gizmos[type].get();
}
GLGizmosManager::EType GLGizmosManager::get_gizmo_from_name(const std::string& gizmo_name) const
{
std::vector<size_t> selectable_idxs = get_selectable_idxs();

View File

@ -199,6 +199,7 @@ public:
EType get_current_type() const { return m_current; }
GLGizmoBase* get_current() const;
GLGizmoBase* get_gizmo(GLGizmosManager::EType type) const;
EType get_gizmo_from_name(const std::string& gizmo_name) const;
bool is_running() const;