This commit is contained in:
Enrico Turri 2018-12-18 09:35:50 +01:00
commit 1dcea1da82
2 changed files with 0 additions and 95 deletions

View File

@ -25,18 +25,6 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
m_og->m_on_change = [this](const std::string& opt_key, const boost::any& value) {
std::vector<std::string> axes{ "_x", "_y", "_z" };
if (opt_key == "scale_unit") {
const wxString& selection = boost::any_cast<wxString>(value);
for (auto axis : axes) {
std::string key = "scale" + axis;
m_og->set_side_text(key, selection);
}
m_is_percent_scale = selection == _("%");
update_scale_values();
return;
}
std::string param;
std::copy(opt_key.begin(), opt_key.end() - 2, std::back_inserter(param));
@ -318,59 +306,6 @@ void ObjectManipulation::reset_scale_value()
m_og->set_value("scale_z", def_100);
}
void ObjectManipulation::update_values()
{
int selection = ol_selection();
if (selection < 0 || wxGetApp().mainframe->m_plater->model().objects.size() <= selection) {
m_og->set_value("position_x", def_0);
m_og->set_value("position_y", def_0);
m_og->set_value("position_z", def_0);
m_og->set_value("scale_x" , def_0);
m_og->set_value("scale_y" , def_0);
m_og->set_value("scale_z" , def_0);
m_og->set_value("rotation_x", def_0);
m_og->set_value("rotation_y", def_0);
m_og->set_value("rotation_z", def_0);
m_og->disable();
return;
}
m_is_percent_scale = boost::any_cast<wxString>(m_og->get_value("scale_unit")) == _("%");
update_position_values();
update_scale_values();
update_rotation_values();
m_og->enable();
}
void ObjectManipulation::update_scale_values()
{
int selection = ol_selection();
ModelObjectPtrs& objects = wxGetApp().mainframe->m_plater->model().objects;
auto instance = objects[selection]->instances.front();
auto size = objects[selection]->instance_bounding_box(0).size();
if (m_is_percent_scale) {
m_og->set_value("scale_x", double_to_string(instance->get_scaling_factor(X) * 100, 2));
m_og->set_value("scale_y", double_to_string(instance->get_scaling_factor(Y) * 100, 2));
m_og->set_value("scale_z", double_to_string(instance->get_scaling_factor(Z) * 100, 2));
}
else {
m_og->set_value("scale_x", double_to_string(size(0), 2));
m_og->set_value("scale_y", double_to_string(size(1), 2));
m_og->set_value("scale_z", double_to_string(size(2), 2));
}
}
void ObjectManipulation::update_position_values()
{
auto instance = wxGetApp().mainframe->m_plater->model().objects[ol_selection()]->instances.front();
m_og->set_value("position_x", double_to_string(instance->get_offset(X), 2));
m_og->set_value("position_y", double_to_string(instance->get_offset(Y), 2));
m_og->set_value("position_z", double_to_string(instance->get_offset(Z), 2));
}
void ObjectManipulation::update_position_value(const Vec3d& position)
{
m_og->set_value("position_x", double_to_string(position(0), 2));
@ -397,29 +332,6 @@ void ObjectManipulation::update_scale_value(const Vec3d& scaling_factor)
m_og->set_value("scale_z", double_to_string(scale(2), 2));
}
void ObjectManipulation::update_rotation_values()
{
update_rotation_value(wxGetApp().mainframe->m_plater->model().objects[ol_selection()]->instances.front()->get_rotation());
}
void ObjectManipulation::update_rotation_value(double angle, Axis axis)
{
std::string axis_str;
switch (axis) {
case X: {
axis_str = "rotation_x";
break; }
case Y: {
axis_str = "rotation_y";
break; }
case Z: {
axis_str = "rotation_z";
break; }
}
m_og->set_value(axis_str, round_nearest(int(Geometry::rad2deg(angle)), 0));
}
void ObjectManipulation::update_rotation_value(const Vec3d& rotation)
{
m_og->set_value("rotation_x", double_to_string(round_nearest(Geometry::rad2deg(rotation(0)), 0), 2));
@ -427,7 +339,6 @@ void ObjectManipulation::update_rotation_value(const Vec3d& rotation)
m_og->set_value("rotation_z", double_to_string(round_nearest(Geometry::rad2deg(rotation(2)), 0), 2));
}
void ObjectManipulation::change_position_value(const Vec3d& position)
{
Vec3d displacement(position - cache_position);

View File

@ -37,17 +37,11 @@ public:
void reset_rotation_value();
void reset_scale_value();
void update_values();
// update position values displacements or "gizmos"
void update_position_values();
void update_position_value(const Vec3d& position);
// update scale values after scale unit changing or "gizmos"
void update_scale_values();
void update_scale_value(const Vec3d& scaling_factor);
// update rotation values object selection changing
void update_rotation_values();
// update rotation value after "gizmos"
void update_rotation_value(double angle, Axis axis);
void update_rotation_value(const Vec3d& rotation);
void set_uniform_scaling(const bool uniform_scale) { m_is_uniform_scale = uniform_scale; }