FIX:fix scale problem
add tool tip for move,rotate,scale gizmo Jira: STUDIO-6425 STUDIO-6419 Change-Id: I0b89c9b70f83cde21c6a407bcecd78c925515cfa
This commit is contained in:
parent
9155058cdc
commit
6dad59102b
|
@ -63,7 +63,11 @@ bool GLGizmoMove3D::on_init()
|
|||
|
||||
std::string GLGizmoMove3D::on_get_name() const
|
||||
{
|
||||
return _u8L("Move");
|
||||
if (!on_is_activable() && m_state == EState::Off) {
|
||||
return _u8L("Move") + ":\n" + _u8L("Please select at least one object.");
|
||||
} else {
|
||||
return _u8L("Move");
|
||||
}
|
||||
}
|
||||
|
||||
bool GLGizmoMove3D::on_is_activable() const
|
||||
|
@ -72,6 +76,12 @@ bool GLGizmoMove3D::on_is_activable() const
|
|||
return !selection.is_any_cut_volume() && !selection.is_any_connector() && !selection.is_empty();
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_set_state() {
|
||||
if (get_state() == On) {
|
||||
m_object_manipulation->set_coordinates_type(ECoordinatesType::World);
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoMove3D::on_start_dragging()
|
||||
{
|
||||
if (m_hover_id != -1) {
|
||||
|
|
|
@ -46,6 +46,7 @@ protected:
|
|||
virtual std::string on_get_name() const override;
|
||||
std::string on_get_name_str() override { return "Move"; }
|
||||
virtual bool on_is_activable() const override;
|
||||
virtual void on_set_state() override;
|
||||
virtual void on_start_dragging() override;
|
||||
virtual void on_stop_dragging() override;
|
||||
virtual void on_update(const UpdateData& data) override;
|
||||
|
|
|
@ -473,11 +473,24 @@ bool GLGizmoRotate3D::on_init()
|
|||
|
||||
std::string GLGizmoRotate3D::on_get_name() const
|
||||
{
|
||||
return _u8L("Rotate");
|
||||
if (!on_is_activable() && m_state == EState::Off) {
|
||||
return _u8L("Rotate") + ":\n" + _u8L("Please select at least one object.");
|
||||
} else {
|
||||
return _u8L("Rotate");
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_set_state()
|
||||
{
|
||||
for (GLGizmoRotate &g : m_gizmos)
|
||||
g.set_state(m_state);
|
||||
if (get_state() == On) {
|
||||
m_object_manipulation->set_coordinates_type(ECoordinatesType::World);
|
||||
}
|
||||
}
|
||||
|
||||
bool GLGizmoRotate3D::on_is_activable() const
|
||||
{
|
||||
{
|
||||
const Selection &selection = m_parent.get_selection();
|
||||
return !selection.is_empty() && !selection.is_wipe_tower() // BBS: don't support rotate wipe tower
|
||||
&&!selection.is_any_cut_volume() && !selection.is_any_connector();
|
||||
|
|
|
@ -115,11 +115,7 @@ protected:
|
|||
bool on_init() override;
|
||||
std::string on_get_name() const override;
|
||||
std::string on_get_name_str() override { return "Rotate"; }
|
||||
void on_set_state() override
|
||||
{
|
||||
for (GLGizmoRotate& g : m_gizmos)
|
||||
g.set_state(m_state);
|
||||
}
|
||||
void on_set_state() override;
|
||||
void on_set_hover_id() override
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
|
|
|
@ -95,7 +95,11 @@ bool GLGizmoScale3D::on_init()
|
|||
|
||||
std::string GLGizmoScale3D::on_get_name() const
|
||||
{
|
||||
return _u8L("Scale");
|
||||
if (!on_is_activable() && m_state == EState::Off) {
|
||||
return _u8L("Scale") + ":\n" + _u8L("Please select at least one object.");
|
||||
} else {
|
||||
return _u8L("Scale");
|
||||
}
|
||||
}
|
||||
|
||||
bool GLGizmoScale3D::on_is_activable() const
|
||||
|
@ -104,6 +108,12 @@ bool GLGizmoScale3D::on_is_activable() const
|
|||
return !selection.is_empty() && !selection.is_wipe_tower() && !selection.is_any_cut_volume() && !selection.is_any_connector();
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_set_state() {
|
||||
if (get_state() == On) {
|
||||
m_object_manipulation->set_coordinates_type(ECoordinatesType::Local);
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoScale3D::on_start_dragging()
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
|||
virtual std::string on_get_name() const override;
|
||||
virtual std::string on_get_name_str() override { return "Scale"; }
|
||||
virtual bool on_is_activable() const override;
|
||||
virtual void on_set_state() override;
|
||||
virtual void on_start_dragging() override;
|
||||
virtual void on_update(const UpdateData& data) override;
|
||||
virtual void on_render() override;
|
||||
|
|
|
@ -81,21 +81,19 @@ void GizmoObjectManipulation::update_settings_value(const Selection& selection)
|
|||
m_new_rotate_label_string = L("Rotation");
|
||||
m_new_scale_label_string = L("Scale ratios");
|
||||
|
||||
m_world_coordinates = true;
|
||||
|
||||
ObjectList* obj_list = wxGetApp().obj_list();
|
||||
if (selection.is_single_full_instance()) {
|
||||
// all volumes in the selection belongs to the same instance, any of them contains the needed instance data, so we take the first one
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
m_new_position = volume->get_instance_offset();
|
||||
|
||||
if (m_world_coordinates) {
|
||||
if (is_world_coordinates()) {//for move and rotate
|
||||
m_new_rotate_label_string = L("Rotate");
|
||||
m_new_rotation = volume->get_instance_rotation() * (180. / M_PI);
|
||||
m_new_size = selection.get_scaled_instance_bounding_box().size();
|
||||
m_new_scale = m_new_size.cwiseProduct(selection.get_unscaled_instance_bounding_box().size().cwiseInverse()) * 100.;
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {//if (is_local_coordinates()) {//for scale
|
||||
m_new_rotation = volume->get_instance_rotation() * (180. / M_PI);
|
||||
m_new_size = volume->get_instance_transformation().get_scaling_factor().cwiseProduct(wxGetApp().model().objects[volume->object_idx()]->raw_mesh_bounding_box().size());
|
||||
m_new_scale = volume->get_instance_scaling_factor() * 100.;
|
||||
|
@ -118,24 +116,19 @@ void GizmoObjectManipulation::update_settings_value(const Selection& selection)
|
|||
}
|
||||
else if (selection.is_single_modifier() || selection.is_single_volume()) {
|
||||
const GLVolume *volume = selection.get_first_volume();
|
||||
if (is_world_coordinates()) {
|
||||
if (is_world_coordinates()) {//for move and rotate
|
||||
const Geometry::Transformation trafo(volume->world_matrix());
|
||||
|
||||
const Vec3d &offset = trafo.get_offset();
|
||||
|
||||
m_new_position = offset;
|
||||
m_new_rotate_label_string = L("Rotate (relative)");
|
||||
m_new_scale_label_string = L("Scale");
|
||||
m_new_scale = Vec3d(100.0, 100.0, 100.0);
|
||||
m_new_rotation = Vec3d::Zero();
|
||||
m_new_rotation = volume->get_volume_rotation() * (180. / M_PI);
|
||||
m_new_scale = volume->get_volume_scaling_factor() * 100.;
|
||||
m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
|
||||
} else if (is_local_coordinates()) {
|
||||
m_new_move_label_string = L("Translate (relative) [World]");
|
||||
m_new_rotate_label_string = L("Rotate (relative)");
|
||||
} else if (is_local_coordinates()) {//for scale
|
||||
m_new_position = Vec3d::Zero();
|
||||
m_new_rotation = Vec3d::Zero();
|
||||
m_new_scale = volume->get_volume_scaling_factor() * 100.0;
|
||||
m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
|
||||
m_new_size = volume->get_instance_transformation().get_scaling_factor().cwiseProduct(
|
||||
volume->get_volume_transformation().get_scaling_factor().cwiseProduct(volume->bounding_box().size()));
|
||||
} else {
|
||||
m_new_position = volume->get_volume_offset();
|
||||
m_new_rotate_label_string = L("Rotate (relative)");
|
||||
|
@ -145,6 +138,7 @@ void GizmoObjectManipulation::update_settings_value(const Selection& selection)
|
|||
m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
|
||||
}
|
||||
m_new_enabled = true;
|
||||
m_new_title_string = L("Volume Operations");
|
||||
}
|
||||
else if (obj_list->multiple_selection() || obj_list->is_selected(itInstanceRoot)) {
|
||||
reset_settings_value();
|
||||
|
@ -301,7 +295,7 @@ void GizmoObjectManipulation::change_rotation_value(int axis, double value)
|
|||
TransformationType transformation_type(TransformationType::World_Relative_Joint);
|
||||
if (selection.is_single_full_instance() || selection.requires_local_axes())
|
||||
transformation_type.set_independent();
|
||||
if (selection.is_single_full_instance() && ! m_world_coordinates) {
|
||||
if (selection.is_single_full_instance() && !is_world_coordinates()) {
|
||||
//FIXME Selection::rotate() does not process absoulte rotations correctly: It does not recognize the axis index, which was changed.
|
||||
// transformation_type.set_absolute();
|
||||
transformation_type.set_local();
|
||||
|
@ -320,6 +314,8 @@ void GizmoObjectManipulation::change_rotation_value(int axis, double value)
|
|||
|
||||
void GizmoObjectManipulation::change_scale_value(int axis, double value)
|
||||
{
|
||||
if (value <= 0.0)
|
||||
return;
|
||||
if (std::abs(m_cache.scale_rounded(axis) - value) < EPSILON)
|
||||
return;
|
||||
|
||||
|
@ -341,6 +337,8 @@ void GizmoObjectManipulation::change_scale_value(int axis, double value)
|
|||
|
||||
void GizmoObjectManipulation::change_size_value(int axis, double value)
|
||||
{
|
||||
if (value <= 0.0)
|
||||
return;
|
||||
if (std::abs(m_cache.size_rounded(axis) - value) < EPSILON)
|
||||
return;
|
||||
|
||||
|
@ -356,7 +354,7 @@ void GizmoObjectManipulation::change_size_value(int axis, double value)
|
|||
ref_size = Vec3d(instance_scale[0] * ref_size[0], instance_scale[1] * ref_size[1], instance_scale[2] * ref_size[2]);
|
||||
}
|
||||
else if (selection.is_single_full_instance())
|
||||
ref_size = m_world_coordinates ?
|
||||
ref_size = is_world_coordinates() ?
|
||||
selection.get_unscaled_instance_bounding_box().size() :
|
||||
wxGetApp().model().objects[selection.get_volume(*selection.get_volume_idxs().begin())->object_idx()]->raw_mesh_bounding_box().size();
|
||||
|
||||
|
@ -375,7 +373,7 @@ void GizmoObjectManipulation::do_scale(int axis, const Vec3d &scale) const
|
|||
TransformationType transformation_type(TransformationType::World_Relative_Joint);
|
||||
if (selection.is_single_full_instance()) {
|
||||
transformation_type.set_absolute();
|
||||
if (! m_world_coordinates)
|
||||
if (!is_world_coordinates())
|
||||
transformation_type.set_local();
|
||||
}
|
||||
|
||||
|
@ -482,7 +480,6 @@ void GizmoObjectManipulation::set_coordinates_type(ECoordinatesType type)
|
|||
if (m_coordinates_type == type) return;
|
||||
|
||||
m_coordinates_type = type;
|
||||
m_world_coordinates = type == ECoordinatesType::World ? true : false;
|
||||
//m_word_local_combo->SetSelection((int) m_coordinates_type);
|
||||
this->UpdateAndShow(true);
|
||||
GLCanvas3D *canvas = wxGetApp().plater()->canvas3D();
|
||||
|
|
|
@ -81,7 +81,6 @@ public:
|
|||
bool m_new_enabled {true};
|
||||
bool m_uniform_scale {true};
|
||||
// Does the object manipulation panel work in World or Local coordinates?
|
||||
bool m_world_coordinates = true;
|
||||
ECoordinatesType m_coordinates_type{ECoordinatesType::World};
|
||||
|
||||
bool m_show_clear_rotation { false };
|
||||
|
|
|
@ -301,6 +301,7 @@ public:
|
|||
bool is_single_volume() const { return m_type == SingleVolume; }
|
||||
bool is_multiple_volume() const { return m_type == MultipleVolume; }
|
||||
bool is_any_volume() const { return is_single_volume() || is_multiple_volume(); }
|
||||
bool is_single_volume_or_modifier() const { return is_single_volume() || is_single_modifier(); }
|
||||
bool is_any_connector() const;
|
||||
bool is_any_cut_volume() const;
|
||||
bool is_mixed() const { return m_type == Mixed; }
|
||||
|
|
Loading…
Reference in New Issue