mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-02-07 12:21:50 +03:00
update slic3r
This commit is contained in:
@@ -95,6 +95,9 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||
wxDataViewCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_MULTIPLE)
|
||||
{
|
||||
wxGetApp().UpdateDVCDarkUI(this, true);
|
||||
#ifdef __linux__
|
||||
this->SetForegroundColour(*wxBLACK);
|
||||
#endif
|
||||
SetFont(Label::sysFont(13));
|
||||
#ifdef __WXMSW__
|
||||
GenericGetHeader()->SetFont(Label::sysFont(13));
|
||||
@@ -554,7 +557,6 @@ MeshErrorsInfo ObjectList::get_mesh_errors_info(wxString* sidebar_info /*= nullp
|
||||
else
|
||||
return { "", "" };
|
||||
}
|
||||
assert(obj_idx >= 0);
|
||||
|
||||
return get_mesh_errors_info(obj_idx, vol_idx, sidebar_info, non_manifold_edges);
|
||||
}
|
||||
@@ -695,6 +697,111 @@ void ObjectList::update_filament_values_for_items(const size_t filaments_count)
|
||||
wxGetApp().plater()->update();
|
||||
}
|
||||
|
||||
void ObjectList::update_filament_values_for_items_when_delete_filament(const size_t filament_id, const int replace_id)
|
||||
{
|
||||
int replace_filament_id = replace_id == -1 ? 1 : (replace_id + 1);
|
||||
for (size_t i = 0; i < m_objects->size(); ++i) {
|
||||
wxDataViewItem item = m_objects_model->GetItemById(i);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
auto object = (*m_objects)[i];
|
||||
wxString extruder;
|
||||
if (!object->config.has("extruder")) {
|
||||
extruder = std::to_string(1);
|
||||
object->config.set_key_value("extruder", new ConfigOptionInt(1));
|
||||
}
|
||||
else if (size_t(object->config.extruder()) == filament_id + 1) {
|
||||
extruder = std::to_string(replace_filament_id);
|
||||
object->config.set_key_value("extruder", new ConfigOptionInt(replace_filament_id));
|
||||
} else {
|
||||
int new_extruder = object->config.extruder() > filament_id ? object->config.extruder() - 1 : object->config.extruder();
|
||||
extruder = wxString::Format("%d", new_extruder);
|
||||
object->config.set_key_value("extruder", new ConfigOptionInt(new_extruder));
|
||||
}
|
||||
m_objects_model->SetExtruder(extruder, item);
|
||||
|
||||
static const char *keys[] = {"support_filament", "support_interface_filament"};
|
||||
for (auto key : keys) {
|
||||
if (object->config.has(key)) {
|
||||
if(object->config.opt_int(key) == filament_id + 1)
|
||||
object->config.erase(key);
|
||||
else {
|
||||
int new_value = object->config.opt_int(key) > filament_id ? object->config.opt_int(key) - 1 : object->config.opt_int(key);
|
||||
object->config.set_key_value(key, new ConfigOptionInt(new_value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (object->volumes.size() > 1) {
|
||||
for (size_t id = 0; id < object->volumes.size(); id++) {
|
||||
item = m_objects_model->GetItemByVolumeId(i, id);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
for (auto key : keys) {
|
||||
if (object->volumes[id]->config.has(key)) {
|
||||
if (object->volumes[id]->config.opt_int(key) == filament_id + 1)
|
||||
object->volumes[id]->config.erase(key);
|
||||
else {
|
||||
int new_value = object->volumes[id]->config.opt_int(key) > filament_id ? object->volumes[id]->config.opt_int(key) - 1 :
|
||||
object->volumes[id]->config.opt_int(key);
|
||||
object->config.set_key_value(key, new ConfigOptionInt(new_value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!object->volumes[id]->config.has("extruder")) {
|
||||
continue;
|
||||
}
|
||||
else if (size_t(object->volumes[id]->config.extruder()) == filament_id + 1) {
|
||||
object->volumes[id]->config.set_key_value("extruder", new ConfigOptionInt(replace_filament_id));
|
||||
} else {
|
||||
int new_extruder = object->volumes[id]->config.extruder() > filament_id ? object->volumes[id]->config.extruder() - 1 : object->volumes[id]->config.extruder();
|
||||
extruder = wxString::Format("%d", new_extruder);
|
||||
object->volumes[id]->config.set_key_value("extruder", new ConfigOptionInt(new_extruder));
|
||||
}
|
||||
|
||||
m_objects_model->SetExtruder(extruder, item);
|
||||
}
|
||||
//}
|
||||
|
||||
item = m_objects_model->GetItemById(i);
|
||||
ObjectDataViewModelNode *object_node = static_cast<ObjectDataViewModelNode *>(item.GetID());
|
||||
if (object_node->GetChildCount() == 0)
|
||||
continue;
|
||||
|
||||
// update height_range
|
||||
for (size_t i = 0; i < object_node->GetChildCount(); i++) {
|
||||
ObjectDataViewModelNode * layer_root_node = object_node->GetNthChild(i);
|
||||
if (layer_root_node->GetType() != ItemType::itLayerRoot)
|
||||
continue;
|
||||
for (size_t j = 0; j < layer_root_node->GetChildCount(); j++) {
|
||||
ObjectDataViewModelNode * layer_node = layer_root_node->GetNthChild(j);
|
||||
auto layer_item = wxDataViewItem((void *) layer_root_node->GetNthChild(j));
|
||||
if (!layer_item)
|
||||
continue;
|
||||
auto l_iter = object->layer_config_ranges.find(layer_node->GetLayerRange());
|
||||
if (l_iter != object->layer_config_ranges.end()) {
|
||||
auto& layer_range_item = *(l_iter);
|
||||
if (layer_range_item.second.has("extruder") && layer_range_item.second.option("extruder")->getInt() == filament_id + 1) {
|
||||
int new_extruder = replace_id == -1 ? 0 : (replace_id + 1);
|
||||
extruder = wxString::Format("%d", new_extruder);
|
||||
layer_range_item.second.set("extruder", new_extruder);
|
||||
} else {
|
||||
int layer_filament_id = layer_range_item.second.option("extruder")->getInt();
|
||||
int new_extruder = layer_filament_id > filament_id ? layer_filament_id - 1 : layer_filament_id;
|
||||
extruder = wxString::Format("%d", new_extruder);
|
||||
layer_range_item.second.set("extruder", new_extruder);
|
||||
}
|
||||
m_objects_model->SetExtruder(extruder, layer_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ObjectList::update_plate_values_for_items()
|
||||
{
|
||||
#ifdef __WXOSX__
|
||||
@@ -840,6 +947,24 @@ void ObjectList::update_objects_list_filament_column(size_t filaments_count)
|
||||
m_prevent_update_filament_in_config = false;
|
||||
}
|
||||
|
||||
void ObjectList::update_objects_list_filament_column_when_delete_filament(size_t filament_id, size_t filaments_count, int replace_filament_id)
|
||||
{
|
||||
m_prevent_update_filament_in_config = true;
|
||||
|
||||
// QDS: update extruder values even when filaments_count is 1, because it may be reduced from value greater than 1
|
||||
if (m_objects)
|
||||
update_filament_values_for_items_when_delete_filament(filament_id, replace_filament_id);
|
||||
|
||||
update_filament_colors();
|
||||
|
||||
// set show/hide for this column
|
||||
set_filament_column_hidden(filaments_count == 1);
|
||||
// a workaround for a wrong last column width updating under OSX
|
||||
GetColumn(colEditing)->SetWidth(25);
|
||||
|
||||
m_prevent_update_filament_in_config = false;
|
||||
}
|
||||
|
||||
void ObjectList::update_filament_colors()
|
||||
{
|
||||
m_objects_model->UpdateColumValues(colFilament);
|
||||
@@ -913,11 +1038,8 @@ void ObjectList::update_filament_in_config(const wxDataViewItem& item)
|
||||
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;
|
||||
int volume_in3d_idx = m_objects_model->get_real_volume_index_in_3d(obj_idx,ui_volume_idx);
|
||||
m_config = &(*m_objects)[obj_idx]->volumes[volume_in3d_idx]->config;
|
||||
}
|
||||
else if (item_type & itLayer)
|
||||
m_config = &get_item_config(item);
|
||||
@@ -1261,7 +1383,7 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
|
||||
toggle_printable_state();
|
||||
else if (col_num == colSupportPaint) {
|
||||
ObjectDataViewModelNode* node = (ObjectDataViewModelNode*)item.GetID();
|
||||
if (node->HasSupportPainting()) {
|
||||
if (node && node->HasSupportPainting()) {
|
||||
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->get_view3D_canvas3D()->get_gizmos_manager();
|
||||
if (gizmos_mgr.get_current_type() != GLGizmosManager::EType::FdmSupports)
|
||||
gizmos_mgr.open_gizmo(GLGizmosManager::EType::FdmSupports);
|
||||
@@ -1272,7 +1394,7 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
|
||||
else if (col_num == colColorPaint) {
|
||||
if (wxGetApp().plater()->get_current_canvas3D()->get_canvas_type() != GLCanvas3D::CanvasAssembleView) {
|
||||
ObjectDataViewModelNode* node = (ObjectDataViewModelNode*)item.GetID();
|
||||
if (node->HasColorPainting()) {
|
||||
if (node && node->HasColorPainting()) {
|
||||
GLGizmosManager& gizmos_mgr = wxGetApp().plater()->get_view3D_canvas3D()->get_gizmos_manager();
|
||||
if (gizmos_mgr.get_current_type() != GLGizmosManager::EType::MmuSegmentation)
|
||||
gizmos_mgr.open_gizmo(GLGizmosManager::EType::MmuSegmentation);
|
||||
@@ -1284,6 +1406,9 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
|
||||
else if (col_num == colSinking) {
|
||||
Plater * plater = wxGetApp().plater();
|
||||
GLCanvas3D *cnv = plater->canvas3D();
|
||||
if (cnv->get_canvas_type() == GLCanvas3D::ECanvasType::CanvasPreview) {//ban reload_scene in Preview scene
|
||||
return;
|
||||
}
|
||||
Plater::TakeSnapshot(plater, "Shift objects to bed");
|
||||
int obj_idx, vol_idx;
|
||||
get_selected_item_indexes(obj_idx, vol_idx, item);
|
||||
@@ -2048,8 +2173,7 @@ void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& mo
|
||||
model = Model::read_from_file(input_file, nullptr, nullptr, LoadStrategy::LoadModel);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
// auto msg = _L("Error!") + " " + input_file + " : " + e.what() + ".";
|
||||
auto msg = _L("Error!") + " " + _L("Failed to get the model data in the current file.");
|
||||
auto msg = _L("Error!") + " " + _L("Failed to get the model data in the current file.") + e.what();
|
||||
show_error(parent, msg);
|
||||
return;
|
||||
}
|
||||
@@ -2912,6 +3036,13 @@ void ObjectList::merge(bool to_multipart_object)
|
||||
// merge layers
|
||||
for (const auto& range : object->layer_config_ranges)
|
||||
new_object->layer_config_ranges.emplace(range);
|
||||
|
||||
// merge brim ears
|
||||
BrimPoints temp_brim_points = object->brim_points;
|
||||
for(auto& p : temp_brim_points) {
|
||||
p.set_transform(transformation_matrix);
|
||||
new_object->brim_points.push_back(p);
|
||||
}
|
||||
}
|
||||
|
||||
//QDS: ensure on bed, and no need to center around origin
|
||||
@@ -2920,8 +3051,13 @@ void ObjectList::merge(bool to_multipart_object)
|
||||
new_object->translate_instances(-new_object->origin_translation);
|
||||
new_object->origin_translation = Vec3d::Zero();
|
||||
//QDS init asssmble transformation
|
||||
Geometry::Transformation t = new_object->instances[0]->get_transformation();
|
||||
new_object->instances[0]->set_assemble_transformation(t);
|
||||
Geometry::Transformation new_object_trsf = new_object->instances[0]->get_transformation();
|
||||
new_object->instances[0]->set_assemble_transformation(new_object_trsf);
|
||||
|
||||
const Transform3d& new_object_inverse_matrix = new_object_trsf.get_matrix().inverse();
|
||||
for (auto& p : new_object->brim_points) {
|
||||
p.set_transform(new_object_inverse_matrix);
|
||||
}
|
||||
//QDS: notify it before remove
|
||||
notify_instance_updated(m_objects->size() - 1);
|
||||
|
||||
@@ -3634,7 +3770,7 @@ void ObjectList::update_variable_layer_obj_num(ObjectDataViewModelNode* obj_node
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selections/* = nullptr*/, bool added_object/* = false*/)
|
||||
void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray *selections /* = nullptr*/, bool added_object /* = false*/, bool color_mode_changed /* = false*/)
|
||||
{
|
||||
// QDS
|
||||
if (obj_idx >= m_objects->size())
|
||||
@@ -3692,6 +3828,9 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
|
||||
else if (!shows && should_show) {
|
||||
m_objects_model->SetSupportPaintState(true, item_obj);
|
||||
}
|
||||
if (color_mode_changed && shows) {
|
||||
m_objects_model->SetSupportPaintState(true, item_obj,true);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -3707,6 +3846,9 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
|
||||
else if (!shows && should_show) {
|
||||
m_objects_model->SetColorPaintState(true, item_obj);
|
||||
}
|
||||
if (color_mode_changed && shows) {
|
||||
m_objects_model->SetColorPaintState(true, item_obj, true);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -3719,6 +3861,9 @@ void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selectio
|
||||
else if (!shows && should_show) {
|
||||
m_objects_model->SetSinkState(true, item_obj);
|
||||
}
|
||||
if (color_mode_changed && shows) {
|
||||
m_objects_model->SetSinkState(true, item_obj, true);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -3897,7 +4042,11 @@ wxDataViewItemArray ObjectList::add_volumes_to_object_in_list(size_t obj_idx, st
|
||||
|
||||
int volume_idx{-1};
|
||||
auto& ui_and_3d_volume_map = m_objects_model->get_ui_and_3d_volume_map();
|
||||
ui_and_3d_volume_map.clear();
|
||||
for (auto item : ui_and_3d_volume_map) {
|
||||
if (item.first == obj_idx) {
|
||||
item.second.clear();
|
||||
}
|
||||
}
|
||||
int ui_volume_idx = 0;
|
||||
for (const ModelVolume *volume : object->volumes) {
|
||||
++volume_idx;
|
||||
@@ -3912,7 +4061,7 @@ wxDataViewItemArray ObjectList::add_volumes_to_object_in_list(size_t obj_idx, st
|
||||
get_warning_icon_name(volume->mesh().stats()),
|
||||
volume->config.has("extruder") ? volume->config.extruder() : 0,
|
||||
false);
|
||||
ui_and_3d_volume_map[ui_volume_idx] = volume_idx;
|
||||
ui_and_3d_volume_map[obj_idx][ui_volume_idx] = volume_idx;
|
||||
ui_volume_idx++;
|
||||
add_settings_item(vol_item, &volume->config.get());
|
||||
|
||||
@@ -4227,18 +4376,18 @@ void ObjectList::del_layer_range(const t_layer_height_range& range)
|
||||
static double get_min_layer_height(const int extruder_idx)
|
||||
{
|
||||
const DynamicPrintConfig& config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
return config.opt_float("min_layer_height", std::max(0, extruder_idx - 1));
|
||||
return config.opt_float_nullable("min_layer_height", std::max(0, extruder_idx - 1));
|
||||
}
|
||||
|
||||
static double get_max_layer_height(const int extruder_idx)
|
||||
{
|
||||
const DynamicPrintConfig& config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
int extruder_idx_zero_based = std::max(0, extruder_idx - 1);
|
||||
double max_layer_height = config.opt_float("max_layer_height", extruder_idx_zero_based);
|
||||
double max_layer_height = config.opt_float_nullable("max_layer_height", extruder_idx_zero_based);
|
||||
|
||||
// In case max_layer_height is set to zero, it should default to 75 % of nozzle diameter:
|
||||
if (max_layer_height < EPSILON)
|
||||
max_layer_height = 0.75 * config.opt_float("nozzle_diameter", extruder_idx_zero_based);
|
||||
max_layer_height = 0.75 * config.opt_float_nullable("nozzle_diameter", extruder_idx_zero_based);
|
||||
|
||||
return max_layer_height;
|
||||
}
|
||||
@@ -4638,7 +4787,7 @@ void ObjectList::update_selections()
|
||||
if (object(obj_idx)->volumes[vol_idx]->is_cut_connector())
|
||||
sels.Add(m_objects_model->GetInfoItemByType(m_objects_model->GetItemById(obj_idx), InfoItemType::CutConnectors));
|
||||
else {
|
||||
vol_idx = m_objects_model->get_real_volume_index_in_ui(vol_idx);
|
||||
vol_idx = m_objects_model->get_real_volume_index_in_ui(obj_idx,vol_idx);
|
||||
sels.Add(m_objects_model->GetItemByVolumeId(obj_idx, vol_idx));
|
||||
}
|
||||
}
|
||||
@@ -4745,7 +4894,7 @@ void ObjectList::update_selections_on_canvas()
|
||||
|
||||
if (type == itVolume) {
|
||||
int vol_idx = m_objects_model->GetVolumeIdByItem(item);
|
||||
vol_idx = m_objects_model->get_real_volume_index_in_3d(vol_idx);
|
||||
vol_idx = m_objects_model->get_real_volume_index_in_3d(obj_idx,vol_idx);
|
||||
std::vector<unsigned int> idxs = selection.get_volume_idxs_from_volume(obj_idx, std::max(instance_idx, 0), vol_idx);
|
||||
volume_idxs.insert(volume_idxs.end(), idxs.begin(), idxs.end());
|
||||
}
|
||||
@@ -5855,8 +6004,8 @@ void ObjectList::set_extruder_for_selected_items(const int extruder)
|
||||
ItemType type = m_objects_model->GetItemType(item);
|
||||
if (type & itVolume) {
|
||||
const int obj_idx = m_objects_model->GetObjectIdByItem(item);
|
||||
const int vol_idx = m_objects_model->GetVolumeIdByItem(item);
|
||||
|
||||
int vol_idx = m_objects_model->GetVolumeIdByItem(item);
|
||||
vol_idx = m_objects_model->get_real_volume_index_in_3d(obj_idx, vol_idx);
|
||||
if ((obj_idx < m_objects->size()) && (obj_idx < (*m_objects)[obj_idx]->volumes.size())) {
|
||||
auto volume_type = (*m_objects)[obj_idx]->volumes[vol_idx]->type();
|
||||
if (volume_type != ModelVolumeType::MODEL_PART && volume_type != ModelVolumeType::PARAMETER_MODIFIER)
|
||||
@@ -5878,11 +6027,25 @@ void ObjectList::set_extruder_for_selected_items(const int extruder)
|
||||
}
|
||||
}
|
||||
|
||||
ModelConfig& config = get_item_config(item);
|
||||
if (config.has("extruder"))
|
||||
config.set("extruder", new_extruder);
|
||||
else
|
||||
config.set_key_value("extruder", new ConfigOptionInt(new_extruder));
|
||||
if (type & itInfo && m_objects_model->GetInfoItemType(item) == InfoItemType::CutConnectors) {
|
||||
const int obj_idx = m_objects_model->GetObjectIdByItem(item);
|
||||
for (size_t i = 0; i < (*m_objects)[obj_idx]->volumes.size(); i++) {
|
||||
auto mv = (*m_objects)[obj_idx]->volumes[i];
|
||||
if (mv->is_cut_connector()) {
|
||||
ModelConfig &config = mv->config;
|
||||
if (config.has("extruder"))
|
||||
config.set("extruder", new_extruder);
|
||||
else
|
||||
config.set_key_value("extruder", new ConfigOptionInt(new_extruder));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ModelConfig &config = get_item_config(item);
|
||||
if (config.has("extruder"))
|
||||
config.set("extruder", new_extruder);
|
||||
else
|
||||
config.set_key_value("extruder", new ConfigOptionInt(new_extruder));
|
||||
}
|
||||
|
||||
// for object, clear all its part volume's extruder config
|
||||
if (type & itObject) {
|
||||
|
||||
Reference in New Issue
Block a user