update slic3r

This commit is contained in:
QIDI TECH
2024-11-28 15:19:12 +08:00
parent a26696f35e
commit 7eb6543991
196 changed files with 18701 additions and 3803 deletions

View File

@@ -38,6 +38,7 @@
#include <wx/renderer.h>
#endif /* __WXMSW__ */
#include "Gizmos/GLGizmoScale.hpp"
#include "Gizmos/GLGizmoMeshBoolean.hpp"
namespace Slic3r
{
@@ -366,6 +367,7 @@ void ObjectList::create_objects_ctrl()
m_columns_width.resize(colCount);
m_columns_width[colName] = 22;
m_columns_width[colHeight] = 3;
m_columns_width[colPrint] = 3;
m_columns_width[colFilament] = 5;
m_columns_width[colSupportPaint] = 3;
@@ -387,6 +389,10 @@ void ObjectList::create_objects_ctrl()
//name_col->SetBitmap(create_scaled_bitmap("organize", nullptr, FromDIP(18)));
AppendColumn(name_col);
// column Variable height Property (Icon) of the view control:
AppendBitmapColumn(" ", colHeight, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, 3 * em,
wxALIGN_CENTER_HORIZONTAL, 0);
// column PrintableProperty (Icon) of the view control:
AppendBitmapColumn(" ", colPrint, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, 3*em,
wxALIGN_CENTER_HORIZONTAL, 0);
@@ -866,6 +872,12 @@ void ObjectList::set_filament_column_hidden(const bool hide) const
update_name_column_width();
}
void ObjectList::set_variable_height_column_hidden(const bool hide) const
{
GetColumn(colHeight)->SetHidden(hide);
update_name_column_width();
}
// QDS
void ObjectList::set_color_paint_hidden(const bool hide) const
{
@@ -897,12 +909,15 @@ void ObjectList::update_filament_in_config(const wxDataViewItem& item)
}
else {
const int obj_idx = m_objects_model->GetIdByItem(m_objects_model->GetObject(item));
if (item_type & itVolume)
{
const int volume_id = m_objects_model->GetVolumeIdByItem(item);
if (obj_idx < 0 || volume_id < 0)
return;
m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config;
if (item_type & itVolume){
const int ui_volume_idx = m_objects_model->GetVolumeIdByItem(item);
if (obj_idx < 0 || ui_volume_idx < 0)
return;
auto &ui_and_3d_volume_map = m_objects_model->get_ui_and_3d_volume_map();
if (ui_and_3d_volume_map.find(ui_volume_idx) == ui_and_3d_volume_map.end()) {
return;
}
m_config = &(*m_objects)[obj_idx]->volumes[ui_and_3d_volume_map[ui_volume_idx]]->config;
}
else if (item_type & itLayer)
m_config = &get_item_config(item);
@@ -1240,7 +1255,9 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
{
const wxString title = col->GetTitle();
ColumnNumber col_num = (ColumnNumber)col->GetModelColumn();
if (col_num == colPrint)
if (col_num == colHeight)
enable_layers_editing();
else if (col_num == colPrint)
toggle_printable_state();
else if (col_num == colSupportPaint) {
ObjectDataViewModelNode* node = (ObjectDataViewModelNode*)item.GetID();
@@ -1336,20 +1353,27 @@ void ObjectList::show_context_menu(const bool evt_context_menu)
if (volume_type != ModelVolumeType::MODEL_PART)
return;
}
menu = plater->assemble_multi_selection_menu();
}
else {
menu = type & itPlate ? plater->plate_menu() :
type & itInstance ? plater->instance_menu() :
type & itVolume ? plater->part_menu() :
printer_technology() == ptFFF ? plater->object_menu() :
plater->sla_object_menu();
plater->SetPlateIndexByRightMenuInLeftUI(-1);
if (type & itPlate) {
int plate_idx = -1;
const ItemType type0 = m_objects_model->GetItemType(item, plate_idx);
if (plate_idx >= 0) {
plater->SetPlateIndexByRightMenuInLeftUI(plate_idx);
if (type & itVolume) {
int obj_idx, vol_idx;
get_selected_item_indexes(obj_idx, vol_idx, item);
if (obj_idx < 0 || vol_idx < 0) return;
const ModelVolume *volume = object(obj_idx)->volumes[vol_idx];
menu = volume->is_svg() ? plater->svg_part_menu() : // ORCA fixes missing "Edit SVG" item for Add/Negative/Modifier SVG objects in object list
plater->part_menu();
}
else {
menu = type & itPlate ? plater->plate_menu() :
type & itInstance ? plater->instance_menu() :
printer_technology() == ptFFF ? plater->object_menu() :
plater->sla_object_menu();
plater->SetPlateIndexByRightMenuInLeftUI(-1);
if (type & itPlate) {
int plate_idx = -1;
const ItemType type0 = m_objects_model->GetItemType(item, plate_idx);
if (plate_idx >= 0) { plater->SetPlateIndexByRightMenuInLeftUI(plate_idx); }
}
}
}
@@ -1372,7 +1396,7 @@ void ObjectList::extruder_editing()
wxPoint pos = this->get_mouse_position_in_control();
wxSize size = wxSize(column_width, -1);
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + GetColumn(colHeight)->GetWidth() + 5;
pos.y -= GetTextExtent("m").y;
apply_extruder_selector(&m_extruder_editor, this, "1", pos, size);
@@ -2100,6 +2124,8 @@ static TriangleMesh create_mesh(const std::string& type_name, const BoundingBoxf
mesh = TriangleMesh(its_make_cube(bb.size().x() * 1.5, bb.size().y() * 1.5, bb.size().z() * 0.5));
else if (type_name == "Cone")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/model/cone.stl").c_str(), true, nullptr);
else if (type_name == "Double Tear Romboid Cylinder")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/model/double_tear_romboid_cylinder.stl").c_str(), true, nullptr);
else if (type_name == "Disc")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/model/Disc.stl").c_str(), true, nullptr);
else if (type_name == "Torus")
@@ -2280,8 +2306,7 @@ void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name
new_object->ensure_on_bed();
//QDS init assmeble transformation
Geometry::Transformation t = new_object->instances[0]->get_transformation();
new_object->instances[0]->set_assemble_transformation(t);
new_object->get_model()->set_assembly_pos(new_object);
object_idxs.push_back(model.objects.size() - 1);
#ifdef _DEBUG
@@ -2345,6 +2370,55 @@ int ObjectList::load_mesh_part(const TriangleMesh &mesh, const wxString &name, c
return mo->volumes.size() - 1;
}
int GUI::ObjectList::add_text_part(const TriangleMesh &mesh, const wxString &name, const TextInfo &text_info, const Transform3d &text_in_object_tran, bool is_temp)
{
wxDataViewItem item = GetSelection();
// we can add volumes for Object or Instance
if (!item || !(m_objects_model->GetItemType(item) & (itObject | itInstance)))
return -1;
const int obj_idx = m_objects_model->GetObjectIdByItem(item);
if (obj_idx < 0)
return -1;
// Get object item, if Instance is selected
if (m_objects_model->GetItemType(item) & itInstance)
item = m_objects_model->GetItemById(obj_idx);
ModelObject *mo = (*m_objects)[obj_idx];
Geometry::Transformation instance_transformation = mo->instances[0]->get_transformation();
ModelVolume *mv = mo->add_volume(mesh,false);
mv->set_transformation(text_in_object_tran);
mo->invalidate_bounding_box();
mv->name = name.ToStdString();
if (!text_info.m_text.empty())
mv->set_text_info(text_info);
if (!is_temp) {
std::vector<ModelVolume *> volumes;
volumes.push_back(mv);
wxDataViewItemArray items = reorder_volumes_and_get_selection(obj_idx, [volumes](const ModelVolume *volume) {
return std::find(volumes.begin(), volumes.end(), volume) != volumes.end();
});
wxGetApp().plater()->get_view3D_canvas3D()->update_instance_printable_state_for_object((size_t) obj_idx);
if (items.size() > 1) {
m_selection_mode = smVolume;
m_last_selected_item = wxDataViewItem(nullptr);
}
select_items(items);
selection_changed();
}
// QDS: notify partplate the modify
notify_instance_updated(obj_idx);
return mo->volumes.size() - 1;
}
//QDS
bool ObjectList::del_object(const int obj_idx, bool refresh_immediately)
{
@@ -2636,6 +2710,7 @@ void ObjectList::split()
for (const ModelVolume* volume : model_object->volumes) {
const wxDataViewItem& vol_item = m_objects_model->AddVolumeChild(parent, from_u8(volume->name),
volume->type(),// is_modifier() ? ModelVolumeType::PARAMETER_MODIFIER : ModelVolumeType::MODEL_PART,
volume->is_svg(),
get_warning_icon_name(volume->mesh().stats()),
volume->config.has("extruder") ? volume->config.extruder() : 0,
false);
@@ -2966,7 +3041,7 @@ void ObjectList::boolean()
Plater::TakeSnapshot snapshot(wxGetApp().plater(), "boolean");
ModelObject* object = (*m_objects)[obj_idxs.front()];
TriangleMesh mesh = Plater::combine_mesh_fff(*object, -1, [this](const std::string& msg) {return wxGetApp().notification_manager()->push_plater_error_notification(msg); });
TriangleMesh mesh = Plater::combine_mesh_fff(*object, -1, [this](const std::string &msg) { return wxGetApp().notification_manager()->push_plater_warning_notification(msg); });
// add mesh to model as a new object, keep the original object's name and config
Model* model = object->get_model();
@@ -3391,7 +3466,16 @@ void ObjectList::part_selection_changed()
m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config;
update_and_show_settings = true;
const ModelVolume *volume = (*m_objects)[obj_idx]->volumes[volume_id];
ModelVolume *volume = (*m_objects)[obj_idx]->volumes[volume_id];
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->canvas3D()->get_gizmos_manager();
if (gizmos_mgr.get_current_type() == GLGizmosManager::EType::MeshBoolean) {
GLGizmoMeshBoolean* mesh_boolean = static_cast<GLGizmoMeshBoolean*>(gizmos_mgr.get_gizmo(GLGizmosManager::MeshBoolean));
if (mesh_boolean->get_selecting_state() == MeshBooleanSelectingState::SelectSource)
mesh_boolean->set_src_volume(volume);
else if (mesh_boolean->get_selecting_state() == MeshBooleanSelectingState::SelectTool)
mesh_boolean->set_tool_volume(volume);
}
enable_manipulation = !((*m_objects)[obj_idx]->is_cut() && (volume->is_cut_connector() || volume->is_model_part()));
}
else if (type & itInstance) {
@@ -3538,6 +3622,18 @@ wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const D
#endif
}
void ObjectList::update_variable_layer_obj_num(ObjectDataViewModelNode* obj_node, size_t layer_data_count) {
if (obj_node){
if (obj_node->IsVaribaleHeight() == hiVariable && layer_data_count <= 4){
m_variable_layer_obj_num--;
}
else if (obj_node->IsVaribaleHeight() == hiUnVariable && layer_data_count > 4){
m_variable_layer_obj_num++;
}
GetColumn(colHeight)->SetHidden(m_variable_layer_obj_num == 0);
update_name_column_width();
}
}
void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selections/* = nullptr*/, bool added_object/* = false*/)
{
@@ -3576,6 +3672,14 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
}
}
{
ObjectDataViewModelNode* obj_node = static_cast<ObjectDataViewModelNode*>(item_obj.GetID());
auto layer_data_count = model_object->layer_height_profile.get().size();
update_variable_layer_obj_num(obj_node, layer_data_count);
// If the length of layer_height_profile is greater than 4, variable layer height is applied
m_objects_model->SetObjectVariableHeightState(layer_data_count > 4 ? hiVariable : hiUnVariable, item_obj);
}
{
bool shows = m_objects_model->IsSupportPainted(item_obj);
bool should_show = printer_technology() == ptFFF
@@ -3738,6 +3842,8 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed,
else
m_objects_model->SetPrintableState(model_object->instances[0]->printable ? piPrintable : piUnprintable, obj_idx);
m_objects_model->SetObjectVariableHeightState(model_object->layer_height_profile.get().size() > 4 ? hiVariable : hiUnVariable, m_objects_model->GetItemById(obj_idx));
// add settings to the object, if it has those
add_settings_item(item, &model_object->config.get());
@@ -3803,6 +3909,7 @@ wxDataViewItemArray ObjectList::add_volumes_to_object_in_list(size_t obj_idx, st
object_item,
from_u8(volume->name),
volume->type(),
volume->is_svg(),
get_warning_icon_name(volume->mesh().stats()),
volume->config.has("extruder") ? volume->config.extruder() : 0,
false);
@@ -3855,10 +3962,16 @@ void ObjectList::delete_from_model_and_list(const ItemType type, const int obj_i
if (type&itObject) {
bool was_cut = object(obj_idx)->is_cut();
// For variable layer height, the size of layer data is larger than 4
bool vari_layer_height = (object(obj_idx)->layer_height_profile.get().size() > 4);
if (del_object(obj_idx)) {
delete_object_from_list(obj_idx);
if (was_cut)
update_lock_icons_for_model();
if (vari_layer_height) {
m_variable_layer_obj_num--;
set_variable_height_column_hidden(m_variable_layer_obj_num == 0);
}
}
}
else {
@@ -3887,11 +4000,17 @@ void ObjectList::delete_from_model_and_list(const std::vector<ItemForDelete>& it
need_update = true;
bool refresh_immediately = false;
bool was_cut = object(item->obj_idx)->is_cut();
// For variable layer height, the size of layer data is larger than 4
bool vari_layer_height = (object(item->obj_idx)->layer_height_profile.get().size() > 4);
if (!del_object(item->obj_idx, refresh_immediately))
return;
m_objects_model->Delete(m_objects_model->GetItemById(item->obj_idx));
if (was_cut)
update_lock_icons_for_model();
if (vari_layer_height) {
m_variable_layer_obj_num--;
set_variable_height_column_hidden(m_variable_layer_obj_num == 0);
}
}
else {
if (!del_subobject_from_object(item->obj_idx, item->sub_obj_idx, item->type))
@@ -4674,8 +4793,6 @@ void ObjectList::update_selections_on_canvas()
if (sel_cnt == 1) {
wxDataViewItem item = GetSelection();
if (m_objects_model->GetInfoItemType(item) == InfoItemType::CutConnectors)
selection.remove_all();
if (m_objects_model->GetItemType(item) & (itSettings | itInstanceRoot | itLayerRoot | itLayer))
add_to_selection(m_objects_model->GetParent(item), selection, instance_idx, mode);
@@ -4712,6 +4829,9 @@ void ObjectList::update_selections_on_canvas()
// to avoid lost of some volumes in selection
// check non-selected volumes only if selection mode wasn't changed
// OR there is no single selection
if (is_connectors_item_selected() && !selection.is_empty()) {
return;
}
if (selection.get_mode() == mode || !single_selection)
volume_idxs = selection.get_unselected_volume_idxs_from(volume_idxs);
Plater::TakeSnapshot snapshot(wxGetApp().plater(), "Add selected to list", UndoRedo::SnapshotType::Selection);
@@ -4827,6 +4947,9 @@ void ObjectList::select_all()
void ObjectList::select_item_all_children()
{
if (wxGetApp().plater() && !wxGetApp().plater()->canvas3D()->get_gizmos_manager().is_allow_select_all()) {
return;
}
wxDataViewItemArray sels;
// There is no selection before OR some object is selected => select all objects
@@ -5017,6 +5140,11 @@ void ObjectList::fix_cut_selection()
m_prevent_list_events = false;
}
auto canvas_type = wxGetApp().plater()->get_current_canvas3D()->get_canvas_type();
if (canvas_type == GLCanvas3D::ECanvasType::CanvasView3D && is_connectors_item_selected()) {
Selection &selection = wxGetApp().plater()->get_view3D_canvas3D()->get_selection();
selection.remove_all();
}
}
bool ObjectList::fix_cut_selection(wxDataViewItemArray &sels)
@@ -5072,9 +5200,16 @@ ModelVolume* ObjectList::get_selected_model_volume()
void ObjectList::change_part_type()
{
ModelVolume* volume = get_selected_model_volume();
if (!volume)
return;
if (!volume) {
auto canvas_type = wxGetApp().plater()->get_current_canvas3D()->get_canvas_type();
if (canvas_type == GLCanvas3D::ECanvasType::CanvasView3D && is_connectors_item_selected()) {
const Selection &selection = wxGetApp().plater()->get_view3D_canvas3D()->get_selection();
const GLVolume * gl_volume = selection.get_first_volume();
volume = get_model_volume(*gl_volume, selection.get_model()->objects);
} else {
return;
}
}
const int obj_idx = get_selected_obj_idx();
if (obj_idx < 0) return;
@@ -5093,8 +5228,19 @@ void ObjectList::change_part_type()
}
}
const wxString names[] = { _L("Part"), _L("Negative Part"), _L("Modifier"), _L("Support Blocker"), _L("Support Enforcer") };
SingleChoiceDialog dlg(_L("Type:"), _L("Choose part type"), wxArrayString(5, names), int(type));
// ORCA: Fix crash when changing type of svg / text modifier
wxArrayString names;
names.Add(_L("Part"));
names.Add(_L("Negative Part"));
if (!volume->is_cut_connector()) {
names.Add(_L("Modifier"));
if (!volume->is_svg()) {
names.Add(_L("Support Blocker"));
names.Add(_L("Support Enforcer"));
}
}
SingleChoiceDialog dlg(_L("Type:"), _L("Choose part type"), names, int(type));
auto new_type = ModelVolumeType(dlg.GetSingleChoiceIndex());
if (new_type == type || new_type == ModelVolumeType::INVALID)
@@ -5527,6 +5673,7 @@ void ObjectList::msw_rescale()
const int em = wxGetApp().em_unit();
GetColumn(colName )->SetWidth(20 * em);
GetColumn(colHeight)->SetWidth(3 * em);
GetColumn(colPrint )->SetWidth( 3 * em);
GetColumn(colFilament)->SetWidth( 5 * em);
// QDS
@@ -5819,6 +5966,7 @@ void ObjectList::reload_all_plates(bool notify_partplate)
wxGetApp().plater()->update();
// update printable states on canvas
wxGetApp().plater()->get_view3D_canvas3D()->update_instance_printable_state_for_objects(obj_idxs);
ppl.update_plate_trans(ppl.get_plate_count());
}
void ObjectList::on_plate_selected(int plate_index)
@@ -5943,6 +6091,26 @@ void ObjectList::toggle_printable_state()
wxGetApp().plater()->reload_paint_after_background_process_apply();
}
void ObjectList::enable_layers_editing()
{
wxDataViewItemArray sels;
GetSelections(sels);
if (sels.IsEmpty())
return;
wxDataViewItem frst_item = sels[0];
ItemType type = m_objects_model->GetItemType(frst_item);
if (!(type & itObject))
return;
//take_snapshot("");
auto view3d = wxGetApp().plater()->get_view3D_canvas3D();
if (view3d != nullptr && m_objects_model->IsVariableHeight(frst_item)){
view3d->enable_layers_editing(true);
}
}
ModelObject* ObjectList::object(const int obj_idx) const
{
if (obj_idx < 0)