mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 06:04:01 -06:00
FIX:[STUDIO-3974] Model reset by plate center when machine switching
jira:STUDIO-3974 Change-Id: I44f5d238a5e7afffc24bbc4359c7ede226d24b4a
This commit is contained in:
parent
d9de09bba6
commit
ab0f9d95fc
7 changed files with 92 additions and 1 deletions
|
@ -2069,6 +2069,11 @@ void GLCanvas3D::select_curr_plate_all()
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::select_object_from_idx(std::vector<int>& object_idxs) {
|
||||||
|
m_selection.add_object_from_idx(object_idxs);
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void GLCanvas3D::remove_curr_plate_all()
|
void GLCanvas3D::remove_curr_plate_all()
|
||||||
{
|
{
|
||||||
|
@ -4738,6 +4743,13 @@ void GLCanvas3D::do_center()
|
||||||
m_selection.center();
|
m_selection.center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::do_center_plate(const int plate_idx) {
|
||||||
|
if (m_model == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_selection.center_plate(plate_idx);
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::do_mirror(const std::string& snapshot_type)
|
void GLCanvas3D::do_mirror(const std::string& snapshot_type)
|
||||||
{
|
{
|
||||||
if (m_model == nullptr)
|
if (m_model == nullptr)
|
||||||
|
|
|
@ -876,6 +876,7 @@ public:
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void select_curr_plate_all();
|
void select_curr_plate_all();
|
||||||
|
void select_object_from_idx(std::vector<int>& object_idxs);
|
||||||
void remove_curr_plate_all();
|
void remove_curr_plate_all();
|
||||||
void update_plate_thumbnails();
|
void update_plate_thumbnails();
|
||||||
|
|
||||||
|
@ -941,6 +942,7 @@ public:
|
||||||
void do_scale(const std::string& snapshot_type);
|
void do_scale(const std::string& snapshot_type);
|
||||||
void do_flatten(const Vec3d& normal, const std::string& snapshot_type);
|
void do_flatten(const Vec3d& normal, const std::string& snapshot_type);
|
||||||
void do_center();
|
void do_center();
|
||||||
|
void do_center_plate(const int plate_idx);
|
||||||
void do_mirror(const std::string& snapshot_type);
|
void do_mirror(const std::string& snapshot_type);
|
||||||
|
|
||||||
void update_gizmos_on_off_state();
|
void update_gizmos_on_off_state();
|
||||||
|
|
|
@ -124,6 +124,11 @@ void View3D::select_curr_plate_all()
|
||||||
m_canvas->select_curr_plate_all();
|
m_canvas->select_curr_plate_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View3D::select_object_from_idx(std::vector<int>& object_idxs) {
|
||||||
|
if (m_canvas != nullptr)
|
||||||
|
m_canvas->select_object_from_idx(object_idxs);
|
||||||
|
}
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void View3D::remove_curr_plate_all()
|
void View3D::remove_curr_plate_all()
|
||||||
{
|
{
|
||||||
|
@ -155,6 +160,11 @@ void View3D::center_selected()
|
||||||
m_canvas->do_center();
|
m_canvas->do_center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View3D::center_selected_plate(const int plate_idx) {
|
||||||
|
if (m_canvas != nullptr)
|
||||||
|
m_canvas->do_center_plate(plate_idx);
|
||||||
|
}
|
||||||
|
|
||||||
void View3D::mirror_selection(Axis axis)
|
void View3D::mirror_selection(Axis axis)
|
||||||
{
|
{
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
|
|
|
@ -58,12 +58,14 @@ public:
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void select_curr_plate_all();
|
void select_curr_plate_all();
|
||||||
|
void select_object_from_idx(std::vector<int> &object_idxs);
|
||||||
void remove_curr_plate_all();
|
void remove_curr_plate_all();
|
||||||
|
|
||||||
void select_all();
|
void select_all();
|
||||||
void deselect_all();
|
void deselect_all();
|
||||||
void delete_selected();
|
void delete_selected();
|
||||||
void center_selected();
|
void center_selected();
|
||||||
|
void center_selected_plate(const int plate_idx);
|
||||||
void mirror_selection(Axis axis);
|
void mirror_selection(Axis axis);
|
||||||
|
|
||||||
bool is_layers_editing_enabled() const;
|
bool is_layers_editing_enabled() const;
|
||||||
|
|
|
@ -5780,13 +5780,31 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||||
|
|
||||||
auto idx = combo->get_filament_idx();
|
auto idx = combo->get_filament_idx();
|
||||||
|
|
||||||
|
// BBS:Save the plate parameters before switching
|
||||||
|
PartPlateList& old_plate_list = this->partplate_list;
|
||||||
|
PartPlate* old_plate = old_plate_list.get_selected_plate();
|
||||||
|
Vec3d old_plate_pos = old_plate->get_center_origin();
|
||||||
|
|
||||||
|
// BBS: Save the model in the current platelist
|
||||||
|
std::vector<vector<int> > plate_object;
|
||||||
|
for (size_t i = 0; i < old_plate_list.get_plate_count(); ++i) {
|
||||||
|
PartPlate* plate = old_plate_list.get_plate(i);
|
||||||
|
std::vector<int> obj_idxs;
|
||||||
|
for (int obj_idx = 0; obj_idx < model.objects.size(); obj_idx++) {
|
||||||
|
if (plate && plate->contain_instance(obj_idx, 0)) {
|
||||||
|
obj_idxs.emplace_back(obj_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plate_object.emplace_back(obj_idxs);
|
||||||
|
}
|
||||||
|
|
||||||
//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox,
|
//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox,
|
||||||
//! but the OSX version derived from wxOwnerDrawnCombo.
|
//! but the OSX version derived from wxOwnerDrawnCombo.
|
||||||
//! So, to get selected string we do
|
//! So, to get selected string we do
|
||||||
//! combo->GetString(combo->GetSelection())
|
//! combo->GetString(combo->GetSelection())
|
||||||
//! instead of
|
//! instead of
|
||||||
//! combo->GetStringSelection().ToUTF8().data());
|
//! combo->GetStringSelection().ToUTF8().data());
|
||||||
|
|
||||||
std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
|
std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
|
||||||
Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data()));
|
Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data()));
|
||||||
|
|
||||||
|
@ -5826,6 +5844,21 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||||
* and for SLA presets they should be deleted
|
* and for SLA presets they should be deleted
|
||||||
*/
|
*/
|
||||||
wxGetApp().obj_list()->update_object_list_by_printer_technology();
|
wxGetApp().obj_list()->update_object_list_by_printer_technology();
|
||||||
|
|
||||||
|
// BBS:Model reset by plate center
|
||||||
|
PartPlateList& cur_plate_list = this->partplate_list;
|
||||||
|
PartPlate* cur_plate = cur_plate_list.get_curr_plate();
|
||||||
|
Vec3d cur_plate_pos = cur_plate->get_center_origin();
|
||||||
|
|
||||||
|
if (old_plate_pos.x() != cur_plate_pos.x() || old_plate_pos.y() != cur_plate_pos.y()) {
|
||||||
|
for (int i = 0; i < plate_object.size(); ++i) {
|
||||||
|
view3D->select_object_from_idx(plate_object[i]);
|
||||||
|
this->sidebar->obj_list()->update_selections();
|
||||||
|
view3D->center_selected_plate(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
view3D->deselect_all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
|
|
@ -414,6 +414,22 @@ void Selection::add_curr_plate()
|
||||||
this->set_bounding_boxes_dirty();
|
this->set_bounding_boxes_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Selection::add_object_from_idx(std::vector<int>& object_idxs) {
|
||||||
|
if (!m_valid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_mode = Instance;
|
||||||
|
clear();
|
||||||
|
|
||||||
|
for (int obj_idx = 0; obj_idx < object_idxs.size(); obj_idx++) {
|
||||||
|
std::vector<unsigned int> volume_idxs = get_volume_idxs_from_object(object_idxs[obj_idx]);
|
||||||
|
do_add_volumes(volume_idxs);
|
||||||
|
}
|
||||||
|
|
||||||
|
update_type();
|
||||||
|
this->set_bounding_boxes_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
void Selection::remove_curr_plate()
|
void Selection::remove_curr_plate()
|
||||||
{
|
{
|
||||||
if (!m_valid)
|
if (!m_valid)
|
||||||
|
@ -464,6 +480,20 @@ void Selection::center()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Selection::center_plate(const int plate_idx) {
|
||||||
|
|
||||||
|
PartPlate* plate = wxGetApp().plater()->get_partplate_list().get_plate(plate_idx);
|
||||||
|
|
||||||
|
|
||||||
|
Vec3d src_pos = this->get_bounding_box().center();
|
||||||
|
Vec3d tar_pos = plate->get_center_origin();
|
||||||
|
Vec3d distance = Vec3d(tar_pos.x() - src_pos.x(), tar_pos.y() - src_pos.y(), 0);
|
||||||
|
|
||||||
|
this->move_to_center(distance);
|
||||||
|
wxGetApp().plater()->get_view3D_canvas3D()->do_move(L("Move Object"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void Selection::set_printable(bool printable)
|
void Selection::set_printable(bool printable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -260,9 +260,11 @@ public:
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void add_curr_plate();
|
void add_curr_plate();
|
||||||
|
void add_object_from_idx(std::vector<int>& object_idxs);
|
||||||
void remove_curr_plate();
|
void remove_curr_plate();
|
||||||
void clone(int numbers = 1);
|
void clone(int numbers = 1);
|
||||||
void center();
|
void center();
|
||||||
|
void center_plate(const int plate_idx);
|
||||||
void set_printable(bool printable);
|
void set_printable(bool printable);
|
||||||
|
|
||||||
void add_all();
|
void add_all();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue