mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-15 02:31:51 +08:00
Merge branch 'master' of https://github.com/Prusa3d/Slic3r
This commit is contained in:
commit
df9abe7d78
@ -809,6 +809,25 @@ TriangleMesh ModelObject::raw_mesh() const
|
|||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Non-transformed (non-rotated, non-scaled, non-translated) sum of all object volumes.
|
||||||
|
TriangleMesh ModelObject::full_raw_mesh() const
|
||||||
|
{
|
||||||
|
TriangleMesh mesh;
|
||||||
|
for (const ModelVolume *v : this->volumes)
|
||||||
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
|
{
|
||||||
|
TriangleMesh vol_mesh(v->mesh);
|
||||||
|
vol_mesh.transform(v->get_matrix());
|
||||||
|
mesh.merge(vol_mesh);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
mesh.merge(v->mesh);
|
||||||
|
}
|
||||||
|
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
// A transformed snug bounding box around the non-modifier object volumes, without the translation applied.
|
// A transformed snug bounding box around the non-modifier object volumes, without the translation applied.
|
||||||
// This bounding box is only used for the actual slicing.
|
// This bounding box is only used for the actual slicing.
|
||||||
BoundingBoxf3 ModelObject::raw_bounding_box() const
|
BoundingBoxf3 ModelObject::raw_bounding_box() const
|
||||||
|
@ -218,6 +218,8 @@ public:
|
|||||||
// Non-transformed (non-rotated, non-scaled, non-translated) sum of non-modifier object volumes.
|
// Non-transformed (non-rotated, non-scaled, non-translated) sum of non-modifier object volumes.
|
||||||
// Currently used by ModelObject::mesh() and to calculate the 2D envelope for 2D platter.
|
// Currently used by ModelObject::mesh() and to calculate the 2D envelope for 2D platter.
|
||||||
TriangleMesh raw_mesh() const;
|
TriangleMesh raw_mesh() const;
|
||||||
|
// Non-transformed (non-rotated, non-scaled, non-translated) sum of all object volumes.
|
||||||
|
TriangleMesh full_raw_mesh() const;
|
||||||
// A transformed snug bounding box around the non-modifier object volumes, without the translation applied.
|
// A transformed snug bounding box around the non-modifier object volumes, without the translation applied.
|
||||||
// This bounding box is only used for the actual slicing.
|
// This bounding box is only used for the actual slicing.
|
||||||
BoundingBoxf3 raw_bounding_box() const;
|
BoundingBoxf3 raw_bounding_box() const;
|
||||||
|
@ -1548,11 +1548,16 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation, bool local)
|
|||||||
{
|
{
|
||||||
if (is_single_full_instance())
|
if (is_single_full_instance())
|
||||||
#if ENABLE_WORLD_ROTATIONS
|
#if ENABLE_WORLD_ROTATIONS
|
||||||
|
{
|
||||||
|
if (local)
|
||||||
|
(*m_volumes)[i]->set_instance_rotation(rotation);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
|
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
|
||||||
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_instance_rotation_matrix());
|
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_instance_rotation_matrix());
|
||||||
(*m_volumes)[i]->set_instance_rotation(new_rotation);
|
(*m_volumes)[i]->set_instance_rotation(new_rotation);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
(*m_volumes)[i]->set_instance_rotation(rotation);
|
(*m_volumes)[i]->set_instance_rotation(rotation);
|
||||||
@ -3581,6 +3586,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
|||||||
, m_view_toolbar(nullptr)
|
, m_view_toolbar(nullptr)
|
||||||
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
||||||
, m_use_clipping_planes(false)
|
, m_use_clipping_planes(false)
|
||||||
|
, m_sidebar_field("")
|
||||||
, m_config(nullptr)
|
, m_config(nullptr)
|
||||||
, m_process(nullptr)
|
, m_process(nullptr)
|
||||||
, m_model(nullptr)
|
, m_model(nullptr)
|
||||||
@ -5566,6 +5572,17 @@ void GLCanvas3D::update_gizmos_on_off_state()
|
|||||||
m_gizmos.update_on_off_state(get_selection());
|
m_gizmos.update_on_off_state(get_selection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::handle_sidebar_focus_event(const std::string& opt_key, bool focus_on)
|
||||||
|
{
|
||||||
|
m_sidebar_field = focus_on ? opt_key : "";
|
||||||
|
|
||||||
|
if (!m_sidebar_field.empty())
|
||||||
|
{
|
||||||
|
m_gizmos.reset_all_states();
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::_is_shown_on_screen() const
|
bool GLCanvas3D::_is_shown_on_screen() const
|
||||||
{
|
{
|
||||||
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;
|
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;
|
||||||
|
@ -794,6 +794,7 @@ private:
|
|||||||
ClippingPlane m_clipping_planes[2];
|
ClippingPlane m_clipping_planes[2];
|
||||||
bool m_use_clipping_planes;
|
bool m_use_clipping_planes;
|
||||||
mutable SlaCap m_sla_caps[2];
|
mutable SlaCap m_sla_caps[2];
|
||||||
|
std::string m_sidebar_field;
|
||||||
|
|
||||||
mutable GLVolumeCollection m_volumes;
|
mutable GLVolumeCollection m_volumes;
|
||||||
Selection m_selection;
|
Selection m_selection;
|
||||||
@ -995,7 +996,7 @@ public:
|
|||||||
void viewport_changed();
|
void viewport_changed();
|
||||||
#endif // ENABLE_CONSTRAINED_CAMERA_TARGET
|
#endif // ENABLE_CONSTRAINED_CAMERA_TARGET
|
||||||
|
|
||||||
void handle_sidebar_focus_event(const std::string& opt_key) {}
|
void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _is_shown_on_screen() const;
|
bool _is_shown_on_screen() const;
|
||||||
|
@ -39,29 +39,51 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
change_rotation_value(new_value);
|
change_rotation_value(new_value);
|
||||||
else if (param == "scale")
|
else if (param == "scale")
|
||||||
change_scale_value(new_value);
|
change_scale_value(new_value);
|
||||||
|
else if (param == "size")
|
||||||
|
change_size_value(new_value);
|
||||||
|
|
||||||
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_og->m_fill_empty_value = [this](const std::string& opt_key)
|
m_og->m_fill_empty_value = [this](const std::string& opt_key)
|
||||||
{
|
{
|
||||||
if (opt_key == "scale_unit")
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::string param;
|
std::string param;
|
||||||
std::copy(opt_key.begin(), opt_key.end() - 2, std::back_inserter(param));
|
std::copy(opt_key.begin(), opt_key.end() - 2, std::back_inserter(param));
|
||||||
|
|
||||||
|
double value = 0.0;
|
||||||
|
|
||||||
if (param == "position") {
|
if (param == "position") {
|
||||||
int axis = opt_key.back() == 'x' ? 0 :
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
opt_key.back() == 'y' ? 1 : 2;
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
m_og->set_value(opt_key, double_to_string(cache_position(axis)));
|
value = cache_position(axis);
|
||||||
return;
|
}
|
||||||
|
else if (param == "rotation") {
|
||||||
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
|
value = cache_rotation(axis);
|
||||||
|
}
|
||||||
|
else if (param == "scale") {
|
||||||
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
|
value = cache_scale(axis);
|
||||||
|
}
|
||||||
|
else if (param == "size") {
|
||||||
|
int axis = opt_key.back() == 'x' ? 0 :
|
||||||
|
opt_key.back() == 'y' ? 1 : 2;
|
||||||
|
|
||||||
|
value = cache_size(axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_og->set_value(opt_key, double_to_string(0.0));
|
m_og->set_value(opt_key, double_to_string(value));
|
||||||
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_og->m_set_focus = [this](const std::string& opt_key)
|
m_og->m_set_focus = [this](const std::string& opt_key)
|
||||||
{
|
{
|
||||||
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key);
|
wxGetApp().plater()->canvas3D()->handle_sidebar_focus_event(opt_key, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigOptionDef def;
|
ConfigOptionDef def;
|
||||||
@ -94,59 +116,37 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
auto add_og_to_object_settings = [](const std::string& option_name, const std::string& sidetext)
|
auto add_og_to_object_settings = [](const std::string& option_name, const std::string& sidetext)
|
||||||
{
|
{
|
||||||
Line line = { _(option_name), "" };
|
Line line = { _(option_name), "" };
|
||||||
if (option_name == "Scale") {
|
|
||||||
line.near_label_widget = [](wxWindow* parent) {
|
|
||||||
auto btn = new PrusaLockButton(parent, wxID_ANY);
|
|
||||||
btn->Bind(wxEVT_BUTTON, [btn](wxCommandEvent &event) {
|
|
||||||
event.Skip();
|
|
||||||
wxTheApp->CallAfter([btn]() {
|
|
||||||
wxGetApp().obj_manipul()->set_uniform_scaling(btn->IsLocked());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return btn;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigOptionDef def;
|
ConfigOptionDef def;
|
||||||
def.type = coFloat;
|
def.type = coFloat;
|
||||||
def.default_value = new ConfigOptionFloat(0.0);
|
def.default_value = new ConfigOptionFloat(0.0);
|
||||||
def.width = 50;
|
def.width = 50;
|
||||||
|
|
||||||
if (option_name == "Rotation")
|
if (option_name == "Rotation")
|
||||||
|
{
|
||||||
def.min = -360;
|
def.min = -360;
|
||||||
|
def.max = 360;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string lower_name = boost::algorithm::to_lower_copy(option_name);
|
const std::string lower_name = boost::algorithm::to_lower_copy(option_name);
|
||||||
|
|
||||||
std::vector<std::string> axes{ "x", "y", "z" };
|
std::vector<std::string> axes{ "x", "y", "z" };
|
||||||
for (auto axis : axes) {
|
for (auto axis : axes) {
|
||||||
if (axis == "z" && option_name != "Scale")
|
if (axis == "z")
|
||||||
def.sidetext = sidetext;
|
def.sidetext = sidetext;
|
||||||
Option option = Option(def, lower_name + "_" + axis);
|
Option option = Option(def, lower_name + "_" + axis);
|
||||||
option.opt.full_width = true;
|
option.opt.full_width = true;
|
||||||
line.append_option(option);
|
line.append_option(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option_name == "Scale")
|
|
||||||
{
|
|
||||||
def.width = 45;
|
|
||||||
def.type = coStrings;
|
|
||||||
def.gui_type = "select_open";
|
|
||||||
def.enum_labels.push_back(L("%"));
|
|
||||||
def.enum_labels.push_back(L("mm"));
|
|
||||||
def.default_value = new ConfigOptionStrings{ "mm" };
|
|
||||||
|
|
||||||
const Option option = Option(def, lower_name + "_unit");
|
|
||||||
line.append_option(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Settings table
|
// Settings table
|
||||||
m_og->append_line(add_og_to_object_settings(L("Position"), L("mm")), &m_move_Label);
|
m_og->append_line(add_og_to_object_settings(L("Position"), L("mm")), &m_move_Label);
|
||||||
m_og->append_line(add_og_to_object_settings(L("Rotation"), "°"));
|
m_og->append_line(add_og_to_object_settings(L("Rotation"), "°"), &m_rotate_Label);
|
||||||
m_og->append_line(add_og_to_object_settings(L("Scale"), "mm"));
|
m_og->append_line(add_og_to_object_settings(L("Scale"), "%"), &m_scale_Label);
|
||||||
|
m_og->append_line(add_og_to_object_settings(L("Size"), "mm"));
|
||||||
|
|
||||||
/* Unused parameter at this time
|
/* Unused parameter at this time
|
||||||
def.label = L("Place on bed");
|
def.label = L("Place on bed");
|
||||||
@ -192,9 +192,11 @@ int ObjectManipulation::ol_selection()
|
|||||||
|
|
||||||
void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& selection)
|
void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& selection)
|
||||||
{
|
{
|
||||||
wxString move_label = _(L("Position"));
|
wxString move_label = _(L("Position:"));
|
||||||
|
wxString rotate_label = _(L("Rotation:"));
|
||||||
|
wxString scale_label = _(L("Scale factors:"));
|
||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
if (selection.is_single_full_instance() || selection.is_single_full_object())
|
if (selection.is_single_full_instance())
|
||||||
#else
|
#else
|
||||||
if (selection.is_single_full_object())
|
if (selection.is_single_full_object())
|
||||||
{
|
{
|
||||||
@ -220,6 +222,7 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
|
|||||||
update_position_value(volume->get_instance_offset());
|
update_position_value(volume->get_instance_offset());
|
||||||
update_rotation_value(volume->get_instance_rotation());
|
update_rotation_value(volume->get_instance_rotation());
|
||||||
update_scale_value(volume->get_instance_scaling_factor());
|
update_scale_value(volume->get_instance_scaling_factor());
|
||||||
|
update_size_value(volume->get_instance_transformation().get_matrix(true, true) * volume->bounding_box.size());
|
||||||
#else
|
#else
|
||||||
update_position_value(volume->get_offset());
|
update_position_value(volume->get_offset());
|
||||||
update_rotation_value(volume->get_rotation());
|
update_rotation_value(volume->get_rotation());
|
||||||
@ -227,19 +230,15 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
|
|||||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||||
m_og->enable();
|
m_og->enable();
|
||||||
}
|
}
|
||||||
else if (selection.is_wipe_tower())
|
else if (selection.is_single_full_object())
|
||||||
{
|
{
|
||||||
// the selection contains a single volume
|
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
update_position_value(box.center());
|
||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
reset_rotation_value();
|
||||||
update_position_value(volume->get_volume_offset());
|
reset_scale_value();
|
||||||
update_rotation_value(volume->get_volume_rotation());
|
update_size_value(box.size());
|
||||||
update_scale_value(volume->get_volume_scaling_factor());
|
rotate_label = _(L("Rotate:"));
|
||||||
#else
|
scale_label = _(L("Scale:"));
|
||||||
update_position_value(volume->get_offset());
|
|
||||||
update_rotation_value(volume->get_rotation());
|
|
||||||
update_scale_value(volume->get_scaling_factor());
|
|
||||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
|
||||||
m_og->enable();
|
m_og->enable();
|
||||||
}
|
}
|
||||||
else if (selection.is_single_modifier() || selection.is_single_volume())
|
else if (selection.is_single_modifier() || selection.is_single_volume())
|
||||||
@ -250,6 +249,7 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
|
|||||||
update_position_value(volume->get_volume_offset());
|
update_position_value(volume->get_volume_offset());
|
||||||
update_rotation_value(volume->get_volume_rotation());
|
update_rotation_value(volume->get_volume_rotation());
|
||||||
update_scale_value(volume->get_volume_scaling_factor());
|
update_scale_value(volume->get_volume_scaling_factor());
|
||||||
|
update_size_value(volume->bounding_box.size());
|
||||||
#else
|
#else
|
||||||
update_position_value(volume->get_offset());
|
update_position_value(volume->get_offset());
|
||||||
update_rotation_value(volume->get_rotation());
|
update_rotation_value(volume->get_rotation());
|
||||||
@ -260,14 +260,16 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
|
|||||||
else if (wxGetApp().obj_list()->multiple_selection())
|
else if (wxGetApp().obj_list()->multiple_selection())
|
||||||
{
|
{
|
||||||
reset_settings_value();
|
reset_settings_value();
|
||||||
move_label = _(L("Displacement"));
|
move_label = _(L("Translate:"));
|
||||||
|
update_size_value(selection.get_bounding_box().size());
|
||||||
m_og->enable();
|
m_og->enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
reset_settings_value();
|
reset_settings_value();
|
||||||
|
|
||||||
m_move_Label->SetLabel(move_label);
|
m_move_Label->SetLabel(move_label);
|
||||||
m_og->get_field("scale_unit")->disable();// temporary decision
|
m_rotate_Label->SetLabel(rotate_label);
|
||||||
|
m_scale_Label->SetLabel(scale_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::reset_settings_value()
|
void ObjectManipulation::reset_settings_value()
|
||||||
@ -287,7 +289,7 @@ void ObjectManipulation::reset_position_value()
|
|||||||
m_og->set_value("position_y", def_0);
|
m_og->set_value("position_y", def_0);
|
||||||
m_og->set_value("position_z", def_0);
|
m_og->set_value("position_z", def_0);
|
||||||
|
|
||||||
cache_position = { 0., 0., 0. };
|
cache_position = Vec3d::Zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::reset_rotation_value()
|
void ObjectManipulation::reset_rotation_value()
|
||||||
@ -295,15 +297,26 @@ void ObjectManipulation::reset_rotation_value()
|
|||||||
m_og->set_value("rotation_x", def_0);
|
m_og->set_value("rotation_x", def_0);
|
||||||
m_og->set_value("rotation_y", def_0);
|
m_og->set_value("rotation_y", def_0);
|
||||||
m_og->set_value("rotation_z", def_0);
|
m_og->set_value("rotation_z", def_0);
|
||||||
|
|
||||||
|
cache_rotation = Vec3d::Zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::reset_scale_value()
|
void ObjectManipulation::reset_scale_value()
|
||||||
{
|
{
|
||||||
m_is_percent_scale = true;
|
|
||||||
m_og->set_value("scale_unit", _("%"));
|
|
||||||
m_og->set_value("scale_x", def_100);
|
m_og->set_value("scale_x", def_100);
|
||||||
m_og->set_value("scale_y", def_100);
|
m_og->set_value("scale_y", def_100);
|
||||||
m_og->set_value("scale_z", def_100);
|
m_og->set_value("scale_z", def_100);
|
||||||
|
|
||||||
|
cache_scale = Vec3d(100.0, 100.0, 100.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectManipulation::reset_size_value()
|
||||||
|
{
|
||||||
|
m_og->set_value("size_x", def_0);
|
||||||
|
m_og->set_value("size_y", def_0);
|
||||||
|
m_og->set_value("size_z", def_0);
|
||||||
|
|
||||||
|
cache_size = Vec3d::Zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::update_position_value(const Vec3d& position)
|
void ObjectManipulation::update_position_value(const Vec3d& position)
|
||||||
@ -317,19 +330,21 @@ void ObjectManipulation::update_position_value(const Vec3d& position)
|
|||||||
|
|
||||||
void ObjectManipulation::update_scale_value(const Vec3d& scaling_factor)
|
void ObjectManipulation::update_scale_value(const Vec3d& scaling_factor)
|
||||||
{
|
{
|
||||||
// this is temporary
|
|
||||||
// to be able to update the values as size
|
|
||||||
// we need to store somewhere the original size
|
|
||||||
// or have it passed as parameter
|
|
||||||
if (!m_is_percent_scale) {
|
|
||||||
m_is_percent_scale = true;
|
|
||||||
m_og->set_value("scale_unit", _("%"));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto scale = scaling_factor * 100.0;
|
auto scale = scaling_factor * 100.0;
|
||||||
m_og->set_value("scale_x", double_to_string(scale(0), 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_y", double_to_string(scale(1), 2));
|
||||||
m_og->set_value("scale_z", double_to_string(scale(2), 2));
|
m_og->set_value("scale_z", double_to_string(scale(2), 2));
|
||||||
|
|
||||||
|
cache_scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectManipulation::update_size_value(const Vec3d& size)
|
||||||
|
{
|
||||||
|
m_og->set_value("size_x", double_to_string(size(0), 2));
|
||||||
|
m_og->set_value("size_y", double_to_string(size(1), 2));
|
||||||
|
m_og->set_value("size_z", double_to_string(size(2), 2));
|
||||||
|
|
||||||
|
cache_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::update_rotation_value(const Vec3d& rotation)
|
void ObjectManipulation::update_rotation_value(const Vec3d& rotation)
|
||||||
@ -337,15 +352,15 @@ 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));
|
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_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));
|
m_og->set_value("rotation_z", double_to_string(round_nearest(Geometry::rad2deg(rotation(2)), 0), 2));
|
||||||
|
|
||||||
|
cache_rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::change_position_value(const Vec3d& position)
|
void ObjectManipulation::change_position_value(const Vec3d& position)
|
||||||
{
|
{
|
||||||
Vec3d displacement(position - cache_position);
|
|
||||||
|
|
||||||
auto canvas = wxGetApp().plater()->canvas3D();
|
auto canvas = wxGetApp().plater()->canvas3D();
|
||||||
canvas->get_selection().start_dragging();
|
canvas->get_selection().start_dragging();
|
||||||
canvas->get_selection().translate(displacement);
|
canvas->get_selection().translate(position - cache_position);
|
||||||
canvas->do_move();
|
canvas->do_move();
|
||||||
|
|
||||||
cache_position = position;
|
cache_position = position;
|
||||||
@ -353,38 +368,56 @@ void ObjectManipulation::change_position_value(const Vec3d& position)
|
|||||||
|
|
||||||
void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
||||||
{
|
{
|
||||||
|
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
|
||||||
|
const GLCanvas3D::Selection& selection = canvas->get_selection();
|
||||||
|
|
||||||
Vec3d rad_rotation;
|
Vec3d rad_rotation;
|
||||||
for (size_t i = 0; i < 3; ++i)
|
for (size_t i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
rad_rotation(i) = Geometry::deg2rad(rotation(i));
|
rad_rotation(i) = Geometry::deg2rad(rotation(i));
|
||||||
auto canvas = wxGetApp().plater()->canvas3D();
|
}
|
||||||
|
|
||||||
canvas->get_selection().start_dragging();
|
canvas->get_selection().start_dragging();
|
||||||
canvas->get_selection().rotate(rad_rotation, false);
|
canvas->get_selection().rotate(rad_rotation, selection.is_single_full_instance());
|
||||||
canvas->do_rotate();
|
canvas->do_rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::change_scale_value(const Vec3d& scale)
|
void ObjectManipulation::change_scale_value(const Vec3d& scale)
|
||||||
{
|
{
|
||||||
Vec3d scaling_factor;
|
Vec3d scaling_factor = scale;
|
||||||
if (m_is_percent_scale)
|
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||||
scaling_factor = scale*0.01;
|
bool needs_uniform_scale = selection.is_single_full_object() && !selection.is_single_full_instance();
|
||||||
else {
|
|
||||||
int selection = ol_selection();
|
|
||||||
ModelObjectPtrs& objects = *wxGetApp().model_objects();
|
|
||||||
|
|
||||||
auto size = objects[selection]->instance_bounding_box(0).size();
|
if (needs_uniform_scale)
|
||||||
for (size_t i = 0; i < 3; ++i)
|
{
|
||||||
scaling_factor(i) = scale(i) / size(i);
|
double min = scaling_factor.minCoeff();
|
||||||
|
double max = scaling_factor.maxCoeff();
|
||||||
|
if (min != 100.0)
|
||||||
|
scaling_factor = Vec3d(min, min, min);
|
||||||
|
else if (max != 100.0)
|
||||||
|
scaling_factor = Vec3d(max, max, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scaling_factor *= 0.01;
|
||||||
|
|
||||||
auto canvas = wxGetApp().plater()->canvas3D();
|
auto canvas = wxGetApp().plater()->canvas3D();
|
||||||
canvas->get_selection().start_dragging();
|
canvas->get_selection().start_dragging();
|
||||||
canvas->get_selection().scale(scaling_factor, false);
|
canvas->get_selection().scale(scaling_factor, false);
|
||||||
canvas->do_scale();
|
canvas->do_scale();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::print_cashe_value(const std::string& label, const Vec3d& v)
|
void ObjectManipulation::change_size_value(const Vec3d& size)
|
||||||
{
|
{
|
||||||
std::cout << label << " => " << " X:" << v(0) << " Y:" << v(1) << " Z:" << v(2) << std::endl;
|
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||||
|
|
||||||
|
Vec3d ref_size = cache_size;
|
||||||
|
if (selection.is_single_full_instance())
|
||||||
|
{
|
||||||
|
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||||
|
ref_size = volume->bounding_box.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
change_scale_value(100.0 * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace GUI
|
} //namespace GUI
|
||||||
|
@ -14,12 +14,14 @@ namespace GUI {
|
|||||||
|
|
||||||
class ObjectManipulation : public OG_Settings
|
class ObjectManipulation : public OG_Settings
|
||||||
{
|
{
|
||||||
bool m_is_percent_scale = false; // true -> percentage scale unit
|
|
||||||
// false -> uniform scale unit
|
|
||||||
bool m_is_uniform_scale = false; // It indicates if scale is uniform
|
|
||||||
|
|
||||||
Vec3d cache_position { 0., 0., 0. };
|
Vec3d cache_position { 0., 0., 0. };
|
||||||
|
Vec3d cache_rotation { 0., 0., 0. };
|
||||||
|
Vec3d cache_scale { 100., 100., 100. };
|
||||||
|
Vec3d cache_size { 0., 0., 0. };
|
||||||
|
|
||||||
wxStaticText* m_move_Label = nullptr;
|
wxStaticText* m_move_Label = nullptr;
|
||||||
|
wxStaticText* m_scale_Label = nullptr;
|
||||||
|
wxStaticText* m_rotate_Label = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ObjectManipulation(wxWindow* parent);
|
ObjectManipulation(wxWindow* parent);
|
||||||
@ -36,25 +38,22 @@ public:
|
|||||||
void reset_position_value();
|
void reset_position_value();
|
||||||
void reset_rotation_value();
|
void reset_rotation_value();
|
||||||
void reset_scale_value();
|
void reset_scale_value();
|
||||||
|
void reset_size_value();
|
||||||
|
|
||||||
// update position values displacements or "gizmos"
|
// update position values displacements or "gizmos"
|
||||||
void update_position_value(const Vec3d& position);
|
void update_position_value(const Vec3d& position);
|
||||||
// update scale values after scale unit changing or "gizmos"
|
// update scale values after scale unit changing or "gizmos"
|
||||||
void update_scale_value(const Vec3d& scaling_factor);
|
void update_scale_value(const Vec3d& scaling_factor);
|
||||||
|
// update size values after scale unit changing or "gizmos"
|
||||||
|
void update_size_value(const Vec3d& size);
|
||||||
// update rotation value after "gizmos"
|
// update rotation value after "gizmos"
|
||||||
void update_rotation_value(const Vec3d& rotation);
|
void update_rotation_value(const Vec3d& rotation);
|
||||||
|
|
||||||
void set_uniform_scaling(const bool uniform_scale) { m_is_uniform_scale = uniform_scale; }
|
|
||||||
|
|
||||||
|
|
||||||
// change values
|
// change values
|
||||||
void change_position_value(const Vec3d& position);
|
void change_position_value(const Vec3d& position);
|
||||||
void change_rotation_value(const Vec3d& rotation);
|
void change_rotation_value(const Vec3d& rotation);
|
||||||
void change_scale_value(const Vec3d& scale);
|
void change_scale_value(const Vec3d& scale);
|
||||||
|
void change_size_value(const Vec3d& size);
|
||||||
|
|
||||||
private:
|
|
||||||
void print_cashe_value(const std::string& label, const Vec3d& value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user