ENH: [STUDIO-2437] new object sinking interaction

Change-Id: Ia93f3ee92abc7cd2ff5d623c6e1edfe7233e31d4
This commit is contained in:
chunmao.guo 2023-03-10 16:45:02 +08:00 committed by Lane.Wei
parent 0ce72dfcb7
commit dbe1f3f5b1
7 changed files with 117 additions and 9 deletions

View file

@ -342,10 +342,11 @@ void ObjectList::create_objects_ctrl()
const int em = wxGetApp().em_unit();
m_columns_width.resize(colCount);
m_columns_width[colName] = 25;
m_columns_width[colName] = 22;
m_columns_width[colPrint] = 3;
m_columns_width[colFilament] = 5;
m_columns_width[colSupportPaint] = 3;
m_columns_width[colSinking] = 3;
m_columns_width[colColorPaint] = 3;
m_columns_width[colEditing] = 3;
@ -385,6 +386,8 @@ void ObjectList::create_objects_ctrl()
wxALIGN_CENTER_HORIZONTAL, 0);
AppendBitmapColumn(" ", colColorPaint, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, m_columns_width[colColorPaint] * em,
wxALIGN_CENTER_HORIZONTAL, 0);
AppendBitmapColumn(" ", colSinking, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, m_columns_width[colSinking] * em,
wxALIGN_CENTER_HORIZONTAL, 0);
// column ItemEditing of the view control:
AppendBitmapColumn(" ", colEditing, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, m_columns_width[colEditing] * em,
@ -569,6 +572,10 @@ void ObjectList::set_tooltip_for_item(const wxPoint& pt)
if (node->HasColorPainting())
tooltip = _(L("Click the icon to edit color painting of the object"));
}
else if (col->GetModelColumn() == (unsigned int)colSinking) {
if (node->HasSinking())
tooltip = _(L("Click the icon to shift this object to the bed"));
}
else if (col->GetModelColumn() == (unsigned int)colName && (pt.x >= 2 * wxGetApp().em_unit() && pt.x <= 4 * wxGetApp().em_unit()))
{
if (const ItemType type = m_objects_model->GetItemType(item);
@ -825,6 +832,12 @@ void ObjectList::set_support_paint_hidden(const bool hide) const
update_name_column_width();
}
void GUI::ObjectList::set_sinking_hidden(const bool hide) const
{
GetColumn(colSinking)->SetHidden(hide);
update_name_column_width();
}
void ObjectList::update_filament_in_config(const wxDataViewItem& item)
{
if (m_prevent_update_filament_in_config)
@ -1188,6 +1201,17 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
gizmos_mgr.reset_all_states();
}
}
else if (col_num == colSinking) {
Plater * plater = wxGetApp().plater();
GLCanvas3D *cnv = plater->canvas3D();
Plater::TakeSnapshot(plater, "Shift objects to bed");
int obj_idx, vol_idx;
get_selected_item_indexes(obj_idx, vol_idx, item);
(*m_objects)[obj_idx]->ensure_on_bed();
cnv->reload_scene(true, true);
update_info_items(obj_idx);
notify_instance_updated(obj_idx);
}
else if (col_num == colEditing) {
//show_context_menu(evt_context_menu);
int obj_idx, vol_idx;
@ -3168,6 +3192,18 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
}
}
{
bool shows = m_objects_model->IsSinked(item_obj);
bool should_show = printer_technology() == ptFFF
&& wxGetApp().plater()->canvas3D()->is_object_sinking(obj_idx);
if (shows && !should_show) {
m_objects_model->SetSinkState(false, item_obj);
}
else if (!shows && should_show) {
m_objects_model->SetSinkState(true, item_obj);
}
}
{
bool shows = this->GetColumn(colSupportPaint)->IsShown();
bool should_show = false;
@ -3211,6 +3247,26 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
this->set_color_paint_hidden(false);
}
}
{
bool shows = this->GetColumn(colSinking)->IsShown();
bool should_show = false;
for (int i = 0; i < m_objects->size(); ++i) {
if (wxGetApp().plater()->canvas3D()->is_object_sinking(i)) {
should_show = true;
break;
}
if (should_show)
break;
}
if (shows && !should_show) {
this->set_sinking_hidden(true);
}
else if (!shows && should_show) {
this->set_sinking_hidden(false);
}
}
}
@ -4860,6 +4916,7 @@ void ObjectList::msw_rescale()
// BBS
GetColumn(colSupportPaint)->SetWidth(3 * em);
GetColumn(colColorPaint)->SetWidth(3 * em);
GetColumn(colSinking)->SetWidth(3 * em);
GetColumn(colEditing )->SetWidth( 3 * em);
// rescale/update existing items with bitmaps
@ -4922,6 +4979,17 @@ void ObjectList::OnEditingStarted(wxDataViewEvent &event)
}
return;
}
else if (col == colSinking) {
Plater * plater = wxGetApp().plater();
GLCanvas3D *cnv = plater->canvas3D();
Plater::TakeSnapshot(plater, "Shift objects to bed");
int obj_idx, vol_idx;
get_selected_item_indexes(obj_idx, vol_idx, item);
(*m_objects)[obj_idx]->ensure_on_bed();
cnv->reload_scene(true, true);
update_info_items(obj_idx);
notify_instance_updated(obj_idx);
}
else if (col == colEditing) {
//show_context_menu(evt_context_menu);
int obj_idx, vol_idx;