Skip to content

Commit

Permalink
ObjectList: Fixed update of the selection, when some gizmo in 3D-Scen…
Browse files Browse the repository at this point in the history
…e is activated
  • Loading branch information
YuSanka committed May 4, 2021
1 parent cb294e0 commit 4fe6f72
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
32 changes: 13 additions & 19 deletions src/slic3r/GUI/GUI_ObjectList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2470,28 +2470,22 @@ void ObjectList::unselect_objects()
m_prevent_list_events = false;
}

void ObjectList::select_current_object(int idx)
void ObjectList::select_object_item(bool is_msr_gizmo)
{
m_prevent_list_events = true;
UnselectAll();
if (idx >= 0)
Select(m_objects_model->GetItemById(idx));
part_selection_changed();
m_prevent_list_events = false;
}
if (wxDataViewItem item = GetSelection()) {
ItemType type = m_objects_model->GetItemType(item);
bool is_volume_item = type == itVolume || type == itSettings && m_objects_model->GetItemType(m_objects_model->GetParent(item)) == itVolume;
if (is_msr_gizmo && is_volume_item || type == itObject)
return;

void ObjectList::select_current_volume(int idx, int vol_idx)
{
if (vol_idx < 0) {
select_current_object(idx);
return;
if (wxDataViewItem obj_item = m_objects_model->GetTopParent(item)) {
m_prevent_list_events = true;
UnselectAll();
Select(obj_item);
part_selection_changed();
m_prevent_list_events = false;
}
}
m_prevent_list_events = true;
UnselectAll();
if (idx >= 0)
Select(m_objects_model->GetItemByVolumeId(idx, vol_idx));
part_selection_changed();
m_prevent_list_events = false;
}

static void update_selection(wxDataViewItemArray& sels, ObjectList::SELECTION_MODE mode, ObjectDataViewModel* model)
Expand Down
7 changes: 3 additions & 4 deletions src/slic3r/GUI/GUI_ObjectList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,9 @@ class ObjectList : public wxDataViewCtrl
// #ys_FIXME_to_delete
// Unselect all objects in the list on c++ side
void unselect_objects();
// Select current object in the list on c++ side
void select_current_object(int idx);
// Select current volume in the list on c++ side
void select_current_volume(int idx, int vol_idx);
// Select object item in the ObjectList, when some gizmo is activated
// "is_msr_gizmo" indicates if Move/Scale/Rotate gizmo was activated
void select_object_item(bool is_msr_gizmo);

// Remove objects/sub-object from the list
void remove();
Expand Down
5 changes: 4 additions & 1 deletion src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
#include "slic3r/GUI/NotificationManager.hpp"
Expand Down Expand Up @@ -1084,8 +1085,10 @@ void GLGizmosManager::update_on_off_state(const Vec2d& mouse_pos)
return;

size_t idx = get_gizmo_idx_from_mouse(mouse_pos);
if (idx != Undefined && m_gizmos[idx]->is_activable() && m_hover == idx)
if (idx != Undefined && m_gizmos[idx]->is_activable() && m_hover == idx) {
activate_gizmo(m_current == idx ? Undefined : (EType)idx);
wxGetApp().obj_list()->select_object_item((EType)idx <= Rotate);
}
}

std::string GLGizmosManager::update_hover_state(const Vec2d& mouse_pos)
Expand Down

0 comments on commit 4fe6f72

Please sign in to comment.