Info in ObjectList: Added variable layer height

This commit is contained in:
Lukas Matena 2021-04-19 15:42:57 +02:00
parent df3fb31268
commit dfe926ef63
6 changed files with 47 additions and 18 deletions

View File

@ -508,6 +508,7 @@ void GLCanvas3D::LayersEditing::reset_layer_height_profile(GLCanvas3D& canvas)
m_layer_height_profile.clear(); m_layer_height_profile.clear();
m_layers_texture.valid = false; m_layers_texture.valid = false;
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
wxGetApp().obj_list()->update_info_items(last_object_id);
} }
void GLCanvas3D::LayersEditing::adaptive_layer_height_profile(GLCanvas3D& canvas, float quality_factor) void GLCanvas3D::LayersEditing::adaptive_layer_height_profile(GLCanvas3D& canvas, float quality_factor)
@ -517,6 +518,7 @@ void GLCanvas3D::LayersEditing::adaptive_layer_height_profile(GLCanvas3D& canvas
const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile); const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile);
m_layers_texture.valid = false; m_layers_texture.valid = false;
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
wxGetApp().obj_list()->update_info_items(last_object_id);
} }
void GLCanvas3D::LayersEditing::smooth_layer_height_profile(GLCanvas3D& canvas, const HeightProfileSmoothingParams& smoothing_params) void GLCanvas3D::LayersEditing::smooth_layer_height_profile(GLCanvas3D& canvas, const HeightProfileSmoothingParams& smoothing_params)
@ -526,6 +528,7 @@ void GLCanvas3D::LayersEditing::smooth_layer_height_profile(GLCanvas3D& canvas,
const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile); const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile);
m_layers_texture.valid = false; m_layers_texture.valid = false;
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
wxGetApp().obj_list()->update_info_items(last_object_id);
} }
void GLCanvas3D::LayersEditing::generate_layer_height_texture() void GLCanvas3D::LayersEditing::generate_layer_height_texture()
@ -565,6 +568,7 @@ void GLCanvas3D::LayersEditing::accept_changes(GLCanvas3D& canvas)
wxGetApp().plater()->take_snapshot(_(L("Variable layer height - Manual edit"))); wxGetApp().plater()->take_snapshot(_(L("Variable layer height - Manual edit")));
const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile); const_cast<ModelObject*>(m_model_object)->layer_height_profile.set(m_layer_height_profile);
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
wxGetApp().obj_list()->update_info_items(last_object_id);
} }
} }
m_layer_height_profile_modified = false; m_layer_height_profile_modified = false;

View File

@ -2138,12 +2138,15 @@ void ObjectList::part_selection_changed()
if (type == itInfo) { if (type == itInfo) {
InfoItemType info_type = m_objects_model->GetInfoItemType(item); InfoItemType info_type = m_objects_model->GetInfoItemType(item);
GLGizmosManager::EType gizmo_type = if (info_type != InfoItemType::VariableLayerHeight) {
info_type == InfoItemType::CustomSupports ? GLGizmosManager::EType::FdmSupports GLGizmosManager::EType gizmo_type =
: GLGizmosManager::EType::Seam; info_type == InfoItemType::CustomSupports ? GLGizmosManager::EType::FdmSupports
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager(); : GLGizmosManager::EType::Seam;
if (gizmos_mgr.get_current_type() != gizmo_type) GLGizmosManager& gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager();
gizmos_mgr.open_gizmo(gizmo_type); if (gizmos_mgr.get_current_type() != gizmo_type)
gizmos_mgr.open_gizmo(gizmo_type);
} else
wxGetApp().plater()->toggle_layers_editing(true);
} }
} }
else { else {
@ -2266,16 +2269,30 @@ void ObjectList::update_info_items(size_t obj_idx)
wxDataViewItem item_obj = m_objects_model->GetItemById(obj_idx); wxDataViewItem item_obj = m_objects_model->GetItemById(obj_idx);
assert(item_obj.IsOk()); assert(item_obj.IsOk());
for (InfoItemType type : {InfoItemType::CustomSupports, InfoItemType::CustomSeam}) { for (InfoItemType type : {InfoItemType::CustomSupports,
InfoItemType::CustomSeam,
InfoItemType::VariableLayerHeight}) {
wxDataViewItem item = m_objects_model->GetInfoItemByType(item_obj, type); wxDataViewItem item = m_objects_model->GetInfoItemByType(item_obj, type);
bool shows = item.IsOk(); bool shows = item.IsOk();
bool should_show = printer_technology() == ptFFF bool should_show = false;
&& std::any_of(model_object->volumes.begin(), model_object->volumes.end(),
[type](const ModelVolume* mv) { switch (type) {
return ! (type == InfoItemType::CustomSupports case InfoItemType::CustomSupports :
? mv->supported_facets.empty() case InfoItemType::CustomSeam :
: mv->seam_facets.empty()); should_show = printer_technology() == ptFFF
}); && std::any_of(model_object->volumes.begin(), model_object->volumes.end(),
[type](const ModelVolume* mv) {
return ! (type == InfoItemType::CustomSupports
? mv->supported_facets.empty()
: mv->seam_facets.empty());
});
break;
case InfoItemType::VariableLayerHeight :
should_show = printer_technology() == ptFFF
&& ! model_object->layer_height_profile.empty();
break;
}
if (! shows && should_show) { if (! shows && should_show) {
m_objects_model->AddInfoChild(item_obj, type); m_objects_model->AddInfoChild(item_obj, type);

View File

@ -54,9 +54,9 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
m_type(itInfo), m_type(itInfo),
m_extruder(wxEmptyString) m_extruder(wxEmptyString)
{ {
m_name = info_type == InfoItemType::CustomSupports m_name = info_type == InfoItemType::CustomSupports ? _L("Paint-on supports")
? _L("Paint-on supports") : info_type == InfoItemType::CustomSeam ? _L("Paint-on seam")
: _L("Paint-on seam"); : _L("Variable layer height");
m_info_item_type = info_type; m_info_item_type = info_type;
} }

View File

@ -49,7 +49,8 @@ enum class InfoItemType
{ {
Undef, Undef,
CustomSupports, CustomSupports,
CustomSeam CustomSeam,
VariableLayerHeight
}; };
class ObjectDataViewModelNode; class ObjectDataViewModelNode;

View File

@ -4967,6 +4967,12 @@ void Plater::convert_unit(ConversionType conv_type)
} }
} }
void Plater::toggle_layers_editing(bool enable)
{
if (canvas3D()->is_layers_editing_enabled() != enable)
wxPostEvent(canvas3D()->get_wxglcanvas(), SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING));
}
void Plater::cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper, bool keep_lower, bool rotate_lower) void Plater::cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper, bool keep_lower, bool rotate_lower)
{ {
wxCHECK_RET(obj_idx < p->model.objects.size(), "obj_idx out of bounds"); wxCHECK_RET(obj_idx < p->model.objects.size(), "obj_idx out of bounds");

View File

@ -191,6 +191,7 @@ public:
bool is_selection_empty() const; bool is_selection_empty() const;
void scale_selection_to_fit_print_volume(); void scale_selection_to_fit_print_volume();
void convert_unit(ConversionType conv_type); void convert_unit(ConversionType conv_type);
void toggle_layers_editing(bool enable);
void cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false); void cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false);