ENH: [STUDIO-2437] new object sinking interaction
Change-Id: Ia93f3ee92abc7cd2ff5d623c6e1edfe7233e31d4
This commit is contained in:
parent
0ce72dfcb7
commit
dbe1f3f5b1
|
@ -1,4 +1,5 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="16" height="8" fill="#ED6B21"/>
|
||||
<rect y="8" width="16" height="8" fill="#808080"/>
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.53938 14.5C6.33476 14.5 6.26217 14.7709 6.43938 14.8732L11.3292 17.6964C11.8075 17.9725 12.4191 17.8086 12.6953 17.3303L14.1562 14.8C14.2331 14.6667 14.1369 14.5 13.983 14.5H6.53938Z" fill="#00AE42"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.66979 2.30406C8.19149 2.02792 7.5799 2.1918 7.30376 2.67009L2.95636 10.2C2.87938 10.3333 2.97561 10.5 3.12957 10.5H16.5241C16.5955 10.5 16.6616 10.4619 16.6973 10.4L17.6961 8.67009C17.9722 8.1918 17.8083 7.58021 17.33 7.30406L8.66979 2.30406Z" fill="#909090"/>
|
||||
<rect x="2" y="12" width="16" height="1" rx="0.5" fill="#6B6B6B"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 736 B |
|
@ -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;
|
||||
|
|
|
@ -225,6 +225,7 @@ public:
|
|||
// BBS
|
||||
void set_color_paint_hidden(const bool hide) const;
|
||||
void set_support_paint_hidden(const bool hide) const;
|
||||
void set_sinking_hidden(const bool hide) const;
|
||||
|
||||
// update extruder in current config
|
||||
void update_filament_in_config(const wxDataViewItem& item);
|
||||
|
|
|
@ -222,6 +222,15 @@ void ObjectDataViewModelNode::set_support_icon(bool enable)
|
|||
m_support_icon = create_scaled_bitmap("dot");
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::set_sinking_icon(bool enable)
|
||||
{
|
||||
m_sink_enable = enable;
|
||||
if ((m_type & itObject) && enable)
|
||||
m_sinking_icon = create_scaled_bitmap("objlist_sinking");
|
||||
else
|
||||
m_sinking_icon = create_scaled_bitmap("dot");
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
|
||||
{
|
||||
m_warning_icon_name = warning_icon_name;
|
||||
|
@ -302,6 +311,9 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
|
|||
case colSupportPaint:
|
||||
m_support_icon << variant;
|
||||
break;
|
||||
case colSinking:
|
||||
m_sinking_icon << variant;
|
||||
break;
|
||||
case colColorPaint:
|
||||
m_color_icon << variant;
|
||||
break;
|
||||
|
@ -1557,6 +1569,9 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
|
|||
case colSupportPaint:
|
||||
variant << node->m_support_icon;
|
||||
break;
|
||||
case colSinking:
|
||||
variant << node->m_sinking_icon;
|
||||
break;
|
||||
case colColorPaint:
|
||||
variant << node->m_color_icon;
|
||||
break;
|
||||
|
@ -2081,6 +2096,14 @@ bool ObjectDataViewModel::IsSupportPainted(wxDataViewItem& item) const
|
|||
return node->m_support_enable;
|
||||
}
|
||||
|
||||
bool ObjectDataViewModel::IsSinked(wxDataViewItem &item) const
|
||||
{
|
||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode *>(item.GetID());
|
||||
if (!node) return false;
|
||||
|
||||
return node->m_sink_enable;
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::SetColorPaintState(const bool painted, wxDataViewItem obj_item)
|
||||
{
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(obj_item.GetID());
|
||||
|
@ -2101,6 +2124,15 @@ void ObjectDataViewModel::SetSupportPaintState(const bool painted, wxDataViewIte
|
|||
ItemChanged(obj_item);
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::SetSinkState(const bool painted, wxDataViewItem obj_item)
|
||||
{
|
||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode *>(obj_item.GetID());
|
||||
if (!node) return;
|
||||
|
||||
node->set_sinking_icon(painted);
|
||||
ItemChanged(obj_item);
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::Rescale()
|
||||
{
|
||||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||
|
|
|
@ -42,6 +42,7 @@ enum ColumnNumber
|
|||
// BBS
|
||||
colSupportPaint ,
|
||||
colColorPaint ,
|
||||
colSinking ,
|
||||
colEditing , // item editing
|
||||
colCount ,
|
||||
};
|
||||
|
@ -87,6 +88,7 @@ class ObjectDataViewModelNode
|
|||
// BBS
|
||||
wxBitmap m_support_icon;
|
||||
wxBitmap m_color_icon;
|
||||
wxBitmap m_sinking_icon;
|
||||
PrintIndicator m_printable {piUndef};
|
||||
wxBitmap m_printable_icon;
|
||||
std::string m_warning_icon_name{ "" };
|
||||
|
@ -98,6 +100,7 @@ class ObjectDataViewModelNode
|
|||
// BBS
|
||||
bool m_support_enable = false;
|
||||
bool m_color_enable = false;
|
||||
bool m_sink_enable = false;
|
||||
|
||||
public:
|
||||
PartPlate* m_part_plate;
|
||||
|
@ -236,7 +239,8 @@ public:
|
|||
PrintIndicator IsPrintable() const { return m_printable; }
|
||||
// BBS
|
||||
bool HasColorPainting() const { return m_color_enable; }
|
||||
bool HasSupportPainting() const { return m_support_enable; }
|
||||
bool HasSupportPainting() const { return m_support_enable; }
|
||||
bool HasSinking() const { return m_sink_enable; }
|
||||
bool IsActionEnabled() const { return m_action_enable; }
|
||||
void UpdateExtruderAndColorIcon(wxString extruder = "");
|
||||
|
||||
|
@ -278,6 +282,7 @@ public:
|
|||
// BBS
|
||||
void set_color_icon(bool enable);
|
||||
void set_support_icon(bool enable);
|
||||
void set_sinking_icon(bool enable);
|
||||
|
||||
// Set warning icon for node
|
||||
void set_warning_icon(const std::string& warning_icon);
|
||||
|
@ -442,9 +447,11 @@ public:
|
|||
wxDataViewItem SetObjectPrintableState(PrintIndicator printable, wxDataViewItem obj_item);
|
||||
// BBS
|
||||
bool IsColorPainted(wxDataViewItem& item) const;
|
||||
bool IsSupportPainted(wxDataViewItem& item) const;
|
||||
bool IsSupportPainted(wxDataViewItem &item) const;
|
||||
bool IsSinked(wxDataViewItem &item) const;
|
||||
void SetColorPaintState(const bool painted, wxDataViewItem obj_item);
|
||||
void SetSupportPaintState(const bool painted, wxDataViewItem obj_item);
|
||||
void SetSinkState(const bool painted, wxDataViewItem obj_item);
|
||||
|
||||
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
|
||||
// Rescale bitmaps for existing Items
|
||||
|
|
|
@ -1596,6 +1596,7 @@ bool PartPlate::check_outside(int obj_id, int instance_id, BoundingBoxf3* boundi
|
|||
Polygon hull = instance->convex_hull_2d();
|
||||
Vec3d up_point(m_origin.x() + m_width + Slic3r::BuildVolume::SceneEpsilon, m_origin.y() + m_depth + Slic3r::BuildVolume::SceneEpsilon, m_origin.z() + m_height + Slic3r::BuildVolume::SceneEpsilon);
|
||||
Vec3d low_point(m_origin.x() - Slic3r::BuildVolume::SceneEpsilon, m_origin.y() - Slic3r::BuildVolume::SceneEpsilon, m_origin.z() - Slic3r::BuildVolume::SceneEpsilon);
|
||||
if (instance_box.max.z() > low_point.z()) low_point.z() += instance_box.min.z(); // not considering outsize if sinking
|
||||
BoundingBoxf3 plate_box(low_point, up_point);
|
||||
|
||||
if (plate_box.contains(instance_box))
|
||||
|
|
|
@ -3529,9 +3529,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
q->model().load_from(model);
|
||||
load_auxiliary_files();
|
||||
}
|
||||
// BBS: don't allow negative_z when load model objects
|
||||
// auto loaded_idxs = load_model_objects(model.objects, is_project_file);
|
||||
auto loaded_idxs = load_model_objects(model.objects);
|
||||
auto loaded_idxs = load_model_objects(model.objects, is_project_file);
|
||||
obj_idxs.insert(obj_idxs.end(), loaded_idxs.begin(), loaded_idxs.end());
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_LOAD_MODEL_OBJECTS \n");
|
||||
|
|
Loading…
Reference in New Issue