mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-20 15:21:21 -06:00
Object selection (from object list to 3DScene)
This commit is contained in:
parent
77e09e683d
commit
06f395641b
8 changed files with 116 additions and 9 deletions
|
@ -5403,6 +5403,7 @@ void GLCanvas3D::_on_select(int volume_idx, int object_idx)
|
|||
}
|
||||
|
||||
m_on_select_object_callback.call(obj_id, vol_id);
|
||||
Slic3r::GUI::select_current_volume(obj_id, vol_id);
|
||||
}
|
||||
|
||||
std::vector<float> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors)
|
||||
|
|
|
@ -740,6 +740,24 @@ void select_current_object(int idx)
|
|||
g_prevent_list_events = false;
|
||||
}
|
||||
|
||||
void select_current_volume(int idx, int vol_idx)
|
||||
{
|
||||
if (vol_idx < 0) {
|
||||
select_current_object(idx);
|
||||
return;
|
||||
}
|
||||
g_prevent_list_events = true;
|
||||
m_objects_ctrl->UnselectAll();
|
||||
if (idx < 0) {
|
||||
g_prevent_list_events = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_objects_ctrl->Select(m_objects_model->GetItemByVolumeId(idx, vol_idx));
|
||||
part_selection_changed();
|
||||
g_prevent_list_events = false;
|
||||
}
|
||||
|
||||
void remove()
|
||||
{
|
||||
auto item = m_objects_ctrl->GetSelection();
|
||||
|
@ -765,8 +783,17 @@ void object_ctrl_selection_changed()
|
|||
|
||||
if (m_event_object_selection_changed > 0) {
|
||||
wxCommandEvent event(m_event_object_selection_changed);
|
||||
event.SetInt(int(m_objects_model->GetParent(m_objects_ctrl->GetSelection()) != wxDataViewItem(0)));
|
||||
event.SetId(m_selected_object_id);
|
||||
event.SetId(m_selected_object_id); // set $obj_idx
|
||||
const wxDataViewItem item = m_objects_ctrl->GetSelection();
|
||||
if (!item || m_objects_model->GetParent(item) == wxDataViewItem(0))
|
||||
event.SetInt(-1); // set $vol_idx
|
||||
else {
|
||||
const int vol_idx = m_objects_model->GetVolumeIdByItem(item);
|
||||
if (vol_idx == -2) // is settings item
|
||||
event.SetInt(m_objects_model->GetVolumeIdByItem(m_objects_model->GetParent(item))); // set $vol_idx
|
||||
else
|
||||
event.SetInt(vol_idx);
|
||||
}
|
||||
get_main_frame()->ProcessWindowEvent(event);
|
||||
}
|
||||
|
||||
|
@ -950,7 +977,7 @@ void update_settings_list()
|
|||
}
|
||||
|
||||
show_manipulation_og(show_manipulations);
|
||||
show_info_sizer(show_manipulations, true);
|
||||
show_info_sizer(show_manipulations && item && m_objects_model->GetParent(item) == wxDataViewItem(0));
|
||||
|
||||
#ifdef __linux__
|
||||
no_updates.reset(nullptr);
|
||||
|
|
|
@ -71,6 +71,8 @@ void set_object_count(int idx, int count);
|
|||
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);
|
||||
// Remove objects/sub-object from the list
|
||||
void remove();
|
||||
|
||||
|
|
|
@ -582,6 +582,26 @@ wxDataViewItem PrusaObjectDataViewModel::GetItemById(int obj_idx)
|
|||
}
|
||||
|
||||
|
||||
wxDataViewItem PrusaObjectDataViewModel::GetItemByVolumeId(int obj_idx, int volume_idx)
|
||||
{
|
||||
if (obj_idx >= m_objects.size()) {
|
||||
printf("Error! Out of objects range.\n");
|
||||
return wxDataViewItem(0);
|
||||
}
|
||||
|
||||
auto parent = m_objects[obj_idx];
|
||||
if (parent->GetChildCount() == 0) {
|
||||
printf("Error! Object has no one volume.\n");
|
||||
return wxDataViewItem(0);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < parent->GetChildCount(); i++)
|
||||
if (parent->GetNthChild(i)->m_volume_id == volume_idx)
|
||||
return wxDataViewItem(parent->GetNthChild(i));
|
||||
|
||||
return wxDataViewItem(0);
|
||||
}
|
||||
|
||||
int PrusaObjectDataViewModel::GetIdByItem(wxDataViewItem& item)
|
||||
{
|
||||
wxASSERT(item.IsOk());
|
||||
|
|
|
@ -418,6 +418,7 @@ public:
|
|||
void DeleteAll();
|
||||
void DeleteChildren(wxDataViewItem& parent);
|
||||
wxDataViewItem GetItemById(int obj_idx);
|
||||
wxDataViewItem GetItemByVolumeId(int obj_idx, int volume_idx);
|
||||
int GetIdByItem(wxDataViewItem& item);
|
||||
int GetVolumeIdByItem(const wxDataViewItem& item);
|
||||
bool IsEmpty() { return m_objects.empty(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue