mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 00:37:51 -06:00
Added "change position" from modification pane
This commit is contained in:
parent
72b5da952d
commit
caaacb4c4f
4 changed files with 52 additions and 5 deletions
|
@ -933,13 +933,13 @@ private:
|
||||||
void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data);
|
void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data);
|
||||||
void _update_toolpath_volumes_outside_state();
|
void _update_toolpath_volumes_outside_state();
|
||||||
void _show_warning_texture_if_needed();
|
void _show_warning_texture_if_needed();
|
||||||
|
public:
|
||||||
void _on_move();
|
void _on_move();
|
||||||
void _on_rotate();
|
void _on_rotate();
|
||||||
void _on_scale();
|
void _on_scale();
|
||||||
void _on_flatten();
|
void _on_flatten();
|
||||||
void _on_mirror();
|
void _on_mirror();
|
||||||
|
private:
|
||||||
// generates the legend texture in dependence of the current shown view type
|
// generates the legend texture in dependence of the current shown view type
|
||||||
void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,17 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent):
|
||||||
update_scale_values();
|
update_scale_values();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string param;
|
||||||
|
std::copy(opt_key.begin(), opt_key.end() - 2, std::back_inserter(param));
|
||||||
|
|
||||||
|
if (param == "position") {
|
||||||
|
Vec3d displacement;
|
||||||
|
displacement(0) = boost::any_cast<double>(m_og->get_value("position_x"));
|
||||||
|
displacement(1) = boost::any_cast<double>(m_og->get_value("position_y"));
|
||||||
|
displacement(2) = boost::any_cast<double>(m_og->get_value("position_z"));
|
||||||
|
change_position_value(displacement);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigOptionDef def;
|
ConfigOptionDef def;
|
||||||
|
@ -248,6 +259,8 @@ void ObjectManipulation::reset_position_value()
|
||||||
m_og->set_value("position_x", def_0);
|
m_og->set_value("position_x", def_0);
|
||||||
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. };
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::reset_rotation_value()
|
void ObjectManipulation::reset_rotation_value()
|
||||||
|
@ -324,6 +337,8 @@ void ObjectManipulation::update_position_value(const Vec3d& position)
|
||||||
m_og->set_value("position_x", double_to_string(position(0), 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_y", double_to_string(position(1), 2));
|
||||||
m_og->set_value("position_z", double_to_string(position(2), 2));
|
m_og->set_value("position_z", double_to_string(position(2), 2));
|
||||||
|
|
||||||
|
cache_position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::update_scale_value(const Vec3d& scaling_factor)
|
void ObjectManipulation::update_scale_value(const Vec3d& scaling_factor)
|
||||||
|
@ -371,5 +386,25 @@ 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));
|
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);
|
||||||
|
|
||||||
|
auto canvas = _3DScene::get_canvas(wxGetApp().canvas3D());
|
||||||
|
canvas->get_selection().start_dragging();
|
||||||
|
canvas->get_selection().translate(displacement);
|
||||||
|
canvas->_on_move();
|
||||||
|
|
||||||
|
cache_position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ObjectManipulation::print_cashe_value(const std::string& label, const Vec3d& value)
|
||||||
|
{
|
||||||
|
std::cout << label << " => " << " X:" << value(0) << " Y:" << value(1) << " Z:" << value(2) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace GUI
|
} //namespace GUI
|
||||||
} //namespace Slic3r
|
} //namespace Slic3r
|
|
@ -17,6 +17,10 @@ class ObjectManipulation : public OG_Settings
|
||||||
// false -> uniform scale unit
|
// false -> uniform scale unit
|
||||||
bool m_is_uniform_scale = false; // It indicates if scale is uniform
|
bool m_is_uniform_scale = false; // It indicates if scale is uniform
|
||||||
|
|
||||||
|
Vec3d cache_position { 0., 0., 0. };
|
||||||
|
Vec3d cache_rotation { 0., 0., 0. };
|
||||||
|
Vec3d cache_scale { 0., 0., 0. };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ObjectManipulation(wxWindow* parent);
|
ObjectManipulation(wxWindow* parent);
|
||||||
~ObjectManipulation() {}
|
~ObjectManipulation() {}
|
||||||
|
@ -48,6 +52,13 @@ public:
|
||||||
|
|
||||||
void set_uniform_scaling(const bool uniform_scale) { m_is_uniform_scale = uniform_scale; }
|
void set_uniform_scaling(const bool uniform_scale) { m_is_uniform_scale = uniform_scale; }
|
||||||
|
|
||||||
|
|
||||||
|
// change values
|
||||||
|
void change_position_value(const Vec3d& position);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void print_cashe_value(const std::string& label, const Vec3d& value);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -692,14 +692,15 @@ void Sidebar::update_objects_list_extruder_column(int extruders_count)
|
||||||
void Sidebar::show_info_sizer()
|
void Sidebar::show_info_sizer()
|
||||||
{
|
{
|
||||||
if (!p->plater->is_single_full_object_selection() ||
|
if (!p->plater->is_single_full_object_selection() ||
|
||||||
m_mode < ConfigMenuModeExpert ) {
|
m_mode < ConfigMenuModeExpert ||
|
||||||
|
p->plater->model().objects.empty()) {
|
||||||
p->object_info->Show(false);
|
p->object_info->Show(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int obj_idx = p->plater->get_selected_object_idx();
|
int obj_idx = p->plater->get_selected_object_idx();
|
||||||
|
|
||||||
const ModelObject* model_object = (*wxGetApp().model_objects())[obj_idx];
|
const ModelObject* model_object = p->plater->model().objects[obj_idx];
|
||||||
// hack to avoid crash when deleting the last object on the bed
|
// hack to avoid crash when deleting the last object on the bed
|
||||||
if (model_object->volumes.empty())
|
if (model_object->volumes.empty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue