SpinCtrsl inside Manipulation pane is replaced to TextCtrls
+ Added "proces_enter" mode for TextCtrl (The control will generate the event wxEVT_TEXT_ENTER)
This commit is contained in:
parent
86c1f5b417
commit
62aa34b444
7 changed files with 87 additions and 80 deletions
src/slic3r/GUI
|
@ -20,7 +20,8 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent):
|
|||
m_og->set_name(_(L("Object Manipulation")));
|
||||
m_og->label_width = 100;
|
||||
m_og->set_grid_vgap(5);
|
||||
|
||||
m_og->set_process_enter(); // We need to update new values only after press ENTER
|
||||
|
||||
m_og->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
|
||||
if (opt_key == "scale_unit") {
|
||||
const wxString& selection = boost::any_cast<wxString>(value);
|
||||
|
@ -32,6 +33,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent):
|
|||
|
||||
m_is_percent_scale = selection == _("%");
|
||||
update_scale_values();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -64,7 +66,6 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent):
|
|||
|
||||
auto add_og_to_object_settings = [](const std::string& option_name, const std::string& sidetext)
|
||||
{
|
||||
int def_value = 0;
|
||||
Line line = { _(option_name), "" };
|
||||
if (option_name == "Scale") {
|
||||
line.near_label_widget = [](wxWindow* parent) {
|
||||
|
@ -80,14 +81,12 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent):
|
|||
}
|
||||
|
||||
ConfigOptionDef def;
|
||||
def.type = coInt;
|
||||
def.default_value = new ConfigOptionInt(def_value);
|
||||
def.type = coFloat;
|
||||
def.default_value = new ConfigOptionFloat(0.0);
|
||||
def.width = 55;
|
||||
|
||||
if (option_name == "Rotation")
|
||||
def.min = -360;
|
||||
else
|
||||
def.min = -1000;
|
||||
|
||||
const std::string lower_name = boost::algorithm::to_lower_copy(option_name);
|
||||
|
||||
|
@ -243,40 +242,40 @@ void ObjectManipulation::reset_settings_value()
|
|||
|
||||
void ObjectManipulation::reset_position_value()
|
||||
{
|
||||
m_og->set_value("position_x", 0);
|
||||
m_og->set_value("position_y", 0);
|
||||
m_og->set_value("position_z", 0);
|
||||
m_og->set_value("position_x", "0");
|
||||
m_og->set_value("position_y", "0");
|
||||
m_og->set_value("position_z", "0");
|
||||
}
|
||||
|
||||
void ObjectManipulation::reset_rotation_value()
|
||||
{
|
||||
m_og->set_value("rotation_x", 0);
|
||||
m_og->set_value("rotation_y", 0);
|
||||
m_og->set_value("rotation_z", 0);
|
||||
m_og->set_value("rotation_x", "0");
|
||||
m_og->set_value("rotation_y", "0");
|
||||
m_og->set_value("rotation_z", "0");
|
||||
}
|
||||
|
||||
void ObjectManipulation::reset_scale_value()
|
||||
{
|
||||
m_is_percent_scale = true;
|
||||
m_og->set_value("scale_unit", _("%"));
|
||||
m_og->set_value("scale_x", 100);
|
||||
m_og->set_value("scale_y", 100);
|
||||
m_og->set_value("scale_z", 100);
|
||||
m_og->set_value("scale_x", "100");
|
||||
m_og->set_value("scale_y", "100");
|
||||
m_og->set_value("scale_z", "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", 0);
|
||||
m_og->set_value("position_y", 0);
|
||||
m_og->set_value("position_z", 0);
|
||||
m_og->set_value("scale_x", 0);
|
||||
m_og->set_value("scale_y", 0);
|
||||
m_og->set_value("scale_z", 0);
|
||||
m_og->set_value("rotation_x", 0);
|
||||
m_og->set_value("rotation_y", 0);
|
||||
m_og->set_value("rotation_z", 0);
|
||||
m_og->set_value("position_x", "0");
|
||||
m_og->set_value("position_y", "0");
|
||||
m_og->set_value("position_z", "0");
|
||||
m_og->set_value("scale_x", "0");
|
||||
m_og->set_value("scale_y", "0");
|
||||
m_og->set_value("scale_z", "0");
|
||||
m_og->set_value("rotation_x", "0");
|
||||
m_og->set_value("rotation_y", "0");
|
||||
m_og->set_value("rotation_z", "0");
|
||||
m_og->disable();
|
||||
return;
|
||||
}
|
||||
|
@ -297,14 +296,14 @@ void ObjectManipulation::update_scale_values()
|
|||
auto size = objects[selection]->instance_bounding_box(0).size();
|
||||
|
||||
if (m_is_percent_scale) {
|
||||
m_og->set_value("scale_x", int(instance->get_scaling_factor(X) * 100));
|
||||
m_og->set_value("scale_y", int(instance->get_scaling_factor(Y) * 100));
|
||||
m_og->set_value("scale_z", int(instance->get_scaling_factor(Z) * 100));
|
||||
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", int(instance->get_scaling_factor(X) * size(0) + 0.5));
|
||||
m_og->set_value("scale_y", int(instance->get_scaling_factor(Y) * size(1) + 0.5));
|
||||
m_og->set_value("scale_z", int(instance->get_scaling_factor(Z) * size(2) + 0.5));
|
||||
m_og->set_value("scale_x", double_to_string(instance->get_scaling_factor(X) * size(0) + 0.5, 2));
|
||||
m_og->set_value("scale_y", double_to_string(instance->get_scaling_factor(Y) * size(1) + 0.5, 2));
|
||||
m_og->set_value("scale_z", double_to_string(instance->get_scaling_factor(Z) * size(2) + 0.5, 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,16 +311,16 @@ void ObjectManipulation::update_position_values()
|
|||
{
|
||||
auto instance = wxGetApp().mainframe->m_plater->model().objects[ol_selection()]->instances.front();
|
||||
|
||||
m_og->set_value("position_x", int(instance->get_offset(X)));
|
||||
m_og->set_value("position_y", int(instance->get_offset(Y)));
|
||||
m_og->set_value("position_z", int(instance->get_offset(Z)));
|
||||
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", int(position(0)));
|
||||
m_og->set_value("position_y", int(position(1)));
|
||||
m_og->set_value("position_z", int(position(2)));
|
||||
m_og->set_value("position_x", double_to_string(position(0), 2));
|
||||
m_og->set_value("position_y", double_to_string(position(1), 2));
|
||||
m_og->set_value("position_z", double_to_string(position(2), 2));
|
||||
}
|
||||
|
||||
void ObjectManipulation::update_scale_value(const Vec3d& scaling_factor)
|
||||
|
@ -334,9 +333,9 @@ void ObjectManipulation::update_scale_value(const Vec3d& scaling_factor)
|
|||
m_og->set_value("scale_unit", _("%"));
|
||||
|
||||
auto scale = scaling_factor * 100.0;
|
||||
m_og->set_value("scale_x", int(scale(0)));
|
||||
m_og->set_value("scale_y", int(scale(1)));
|
||||
m_og->set_value("scale_z", int(scale(2)));
|
||||
m_og->set_value("scale_x", double_to_string(scale(0), 2));
|
||||
m_og->set_value("scale_y", double_to_string(scale(1), 2));
|
||||
m_og->set_value("scale_z", double_to_string(scale(2), 2));
|
||||
}
|
||||
|
||||
void ObjectManipulation::update_rotation_values()
|
||||
|
@ -364,18 +363,10 @@ void ObjectManipulation::update_rotation_value(double angle, Axis axis)
|
|||
|
||||
void ObjectManipulation::update_rotation_value(const Vec3d& rotation)
|
||||
{
|
||||
m_og->set_value("rotation_x", int(round_nearest(Geometry::rad2deg(rotation(0)), 0)));
|
||||
m_og->set_value("rotation_y", int(round_nearest(Geometry::rad2deg(rotation(1)), 0)));
|
||||
m_og->set_value("rotation_z", int(round_nearest(Geometry::rad2deg(rotation(2)), 0)));
|
||||
m_og->set_value("rotation_x", double_to_string(round_nearest(Geometry::rad2deg(rotation(0)), 0), 2));
|
||||
m_og->set_value("rotation_y", double_to_string(round_nearest(Geometry::rad2deg(rotation(1)), 0), 2));
|
||||
m_og->set_value("rotation_z", double_to_string(round_nearest(Geometry::rad2deg(rotation(2)), 0), 2));
|
||||
}
|
||||
|
||||
void ObjectManipulation::show_object_name(bool show)
|
||||
{
|
||||
wxGridSizer* grid_sizer = m_og->get_grid_sizer();
|
||||
grid_sizer->Show(static_cast<size_t>(0), show);
|
||||
grid_sizer->Show(static_cast<size_t>(1), show);
|
||||
}
|
||||
|
||||
|
||||
} //namespace GUI
|
||||
} //namespace Slic3r
|
Loading…
Add table
Add a link
Reference in a new issue