FIX: CLI: fix the brim related issues

1. move the global functions to Model
2. set brim automation paremeters before process
JIRA: STUDIO-4208

Change-Id: I3f75175ec74d214ca2a6d5f3ade56d08e0ecd4f3
(cherry picked from commit bcc88bc01ec396e8fb8af1186b47a75cd5116f3c)
This commit is contained in:
lane.wei 2023-08-25 15:28:44 +08:00 committed by Lane.Wei
parent 7f642112d2
commit d5b9dcfbbe
6 changed files with 159 additions and 126 deletions

View file

@ -2875,12 +2875,14 @@ int CLI::run(int argc, char **argv)
// is supplied); if any object has no instances, it will get a default one // is supplied); if any object has no instances, it will get a default one
// and all instances will be rearranged (unless --dont-arrange is supplied). // and all instances will be rearranged (unless --dont-arrange is supplied).
std::string outfile; std::string outfile;
Print fff_print; //Print fff_print;
while(!finished) while(!finished)
{ {
//BBS: slice every partplate one by one //BBS: slice every partplate one by one
PrintBase *print=NULL; PrintBase *print=NULL;
Print *print_fff = NULL;
Slic3r::GUI::GCodeResult *gcode_result = NULL; Slic3r::GUI::GCodeResult *gcode_result = NULL;
int print_index; int print_index;
for (int index = 0; index < partplate_list.get_plate_count(); index ++) for (int index = 0; index < partplate_list.get_plate_count(); index ++)
@ -2895,6 +2897,8 @@ int CLI::run(int argc, char **argv)
//get the current partplate //get the current partplate
Slic3r::GUI::PartPlate* part_plate = partplate_list.get_plate(index); Slic3r::GUI::PartPlate* part_plate = partplate_list.get_plate(index);
part_plate->get_print(&print, &gcode_result, &print_index); part_plate->get_print(&print, &gcode_result, &print_index);
print_fff = dynamic_cast<Print *>(print);
/*if (outfile_config.empty()) /*if (outfile_config.empty())
{ {
outfile = "plate_" + std::to_string(index + 1) + ".gcode"; outfile = "plate_" + std::to_string(index + 1) + ".gcode";
@ -3074,6 +3078,11 @@ int CLI::run(int argc, char **argv)
BOOST_LOG_TRIVIAL(info) << boost::format("new_printer_name: %1%, current_printer_system_name %2%, is_bbl_vendor_preset %3%")%new_printer_name %current_printer_system_name %is_bbl_vendor_preset; BOOST_LOG_TRIVIAL(info) << boost::format("new_printer_name: %1%, current_printer_system_name %2%, is_bbl_vendor_preset %3%")%new_printer_name %current_printer_system_name %is_bbl_vendor_preset;
} }
(dynamic_cast<Print*>(print))->set_BBL_Printer(is_bbl_vendor_preset); (dynamic_cast<Print*>(print))->set_BBL_Printer(is_bbl_vendor_preset);
//update information for brim
const PrintConfig& print_config = print_fff->config();
Model::setExtruderParams(m_print_config, filament_count);
Model::setPrintSpeedTable(m_print_config, print_config);
if (load_slicedata) { if (load_slicedata) {
std::string plate_dir = load_slice_data_dir+"/"+std::to_string(index+1); std::string plate_dir = load_slice_data_dir+"/"+std::to_string(index+1);
int ret = print->load_cached_data(plate_dir); int ret = print->load_cached_data(plate_dir);
@ -3098,12 +3107,13 @@ int CLI::run(int argc, char **argv)
print->process(); print->process();
} }
if (printer_technology == ptFFF) { if (printer_technology == ptFFF) {
std::string conflict_result = dynamic_cast<Print *>(print)->get_conflict_string(); std::string conflict_result = print_fff->get_conflict_string();
if (!conflict_result.empty()) { if (!conflict_result.empty()) {
BOOST_LOG_TRIVIAL(error) << "plate "<< index+1<< ": found slicing result conflict!"<< std::endl; BOOST_LOG_TRIVIAL(error) << "plate "<< index+1<< ": found slicing result conflict!"<< std::endl;
record_exit_reson(outfile_dir, CLI_GCODE_PATH_CONFLICTS, index+1, cli_errors[CLI_GCODE_PATH_CONFLICTS]); record_exit_reson(outfile_dir, CLI_GCODE_PATH_CONFLICTS, index+1, cli_errors[CLI_GCODE_PATH_CONFLICTS]);
flush_and_exit(CLI_GCODE_PATH_CONFLICTS); flush_and_exit(CLI_GCODE_PATH_CONFLICTS);
} }
// The outfile is processed by a PlaceholderParser. // The outfile is processed by a PlaceholderParser.
//outfile = part_plate->get_tmp_gcode_path(); //outfile = part_plate->get_tmp_gcode_path();
if (outfile_dir.empty()) { if (outfile_dir.empty()) {
@ -3114,7 +3124,7 @@ int CLI::run(int argc, char **argv)
part_plate->set_tmp_gcode_path(outfile); part_plate->set_tmp_gcode_path(outfile);
} }
BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl; BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl;
outfile = (dynamic_cast<Print*>(print))->export_gcode(outfile, gcode_result, nullptr); outfile = print_fff->export_gcode(outfile, gcode_result, nullptr);
//outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile); //outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile);
//m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); }); //m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
}/* else { }/* else {

View file

@ -2100,7 +2100,7 @@ ModelObjectPtrs ModelObject::cut(size_t instance, std::array<Vec3d, 4> plane_poi
// Displacement (in instance coordinates) to be applied to place the upper parts // Displacement (in instance coordinates) to be applied to place the upper parts
Vec3d local_displace = Vec3d::Zero(); Vec3d local_displace = Vec3d::Zero();
Vec3d local_dowels_displace = Vec3d::Zero(); Vec3d local_dowels_displace = Vec3d::Zero();
for (ModelVolume *volume : volumes) { for (ModelVolume *volume : volumes) {
const auto volume_matrix = volume->get_matrix(); const auto volume_matrix = volume->get_matrix();
@ -2125,7 +2125,7 @@ ModelObjectPtrs ModelObject::cut(size_t instance, std::array<Vec3d, 4> plane_poi
} }
ModelObjectPtrs res; ModelObjectPtrs res;
if (attributes.has(ModelObjectCutAttribute::CutToParts) && !upper->volumes.empty()) { if (attributes.has(ModelObjectCutAttribute::CutToParts) && !upper->volumes.empty()) {
reset_instance_transformation(upper, instance, cut_matrix); reset_instance_transformation(upper, instance, cut_matrix);
res.push_back(upper); res.push_back(upper);
@ -2359,7 +2359,7 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
{ {
Vec3d shift = model_instance->get_transformation().get_matrix(true) * new_vol->get_offset(); Vec3d shift = model_instance->get_transformation().get_matrix(true) * new_vol->get_offset();
model_instance->set_offset(model_instance->get_offset() + shift); model_instance->set_offset(model_instance->get_offset() + shift);
//BBS: add assemble_view related logic //BBS: add assemble_view related logic
Geometry::Transformation instance_transformation_copy = model_instance->get_transformation(); Geometry::Transformation instance_transformation_copy = model_instance->get_transformation();
instance_transformation_copy.set_offset(-new_vol->get_offset()); instance_transformation_copy.set_offset(-new_vol->get_offset());
@ -3238,6 +3238,91 @@ void ModelInstance::transform_polygon(Polygon* polygon) const
} }
//BBS //BBS
// BBS set print speed table and find maximum speed
void Model::setPrintSpeedTable(const DynamicPrintConfig& config, const PrintConfig& print_config) {
//Slic3r::DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
printSpeedMap.maxSpeed = 0;
if (config.has("inner_wall_speed")) {
printSpeedMap.perimeterSpeed = config.opt_float("inner_wall_speed");
if (printSpeedMap.perimeterSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.perimeterSpeed;
}
if (config.has("outer_wall_speed")) {
printSpeedMap.externalPerimeterSpeed = config.opt_float("outer_wall_speed");
printSpeedMap.maxSpeed = std::max(printSpeedMap.maxSpeed, printSpeedMap.externalPerimeterSpeed);
}
if (config.has("sparse_infill_speed")) {
printSpeedMap.infillSpeed = config.opt_float("sparse_infill_speed");
if (printSpeedMap.infillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.infillSpeed;
}
if (config.has("internal_solid_infill_speed")) {
printSpeedMap.solidInfillSpeed = config.opt_float("internal_solid_infill_speed");
if (printSpeedMap.solidInfillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.solidInfillSpeed;
}
if (config.has("top_surface_speed")) {
printSpeedMap.topSolidInfillSpeed = config.opt_float("top_surface_speed");
if (printSpeedMap.topSolidInfillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.topSolidInfillSpeed;
}
if (config.has("support_speed")) {
printSpeedMap.supportSpeed = config.opt_float("support_speed");
if (printSpeedMap.supportSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.supportSpeed;
}
//auto& print = wxGetApp().plater()->get_partplate_list().get_current_fff_print();
//auto print_config = print.config();
//printSpeedMap.bed_poly.points = get_bed_shape(*(wxGetApp().plater()->config()));
printSpeedMap.bed_poly.points = get_bed_shape(config);
Pointfs excluse_area_points = print_config.bed_exclude_area.values;
Polygons exclude_polys;
Polygon exclude_poly;
for (int i = 0; i < excluse_area_points.size(); i++) {
auto pt = excluse_area_points[i];
exclude_poly.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
if (i % 4 == 3) { // exclude areas are always rectangle
exclude_polys.push_back(exclude_poly);
exclude_poly.points.clear();
}
}
printSpeedMap.bed_poly = diff({ printSpeedMap.bed_poly }, exclude_polys)[0];
}
// find temperature of heatend and bed and matierial of an given extruder
void Model::setExtruderParams(const DynamicPrintConfig& config, int extruders_count) {
extruderParamsMap.clear();
//Slic3r::DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
// BBS
//int numExtruders = wxGetApp().preset_bundle->filament_presets.size();
for (unsigned int i = 0; i != extruders_count; ++i) {
std::string matName = "";
// BBS
int bedTemp = 35;
double endTemp = 0.f;
if (config.has("filament_type")) {
matName = config.opt_string("filament_type", i);
}
if (config.has("nozzle_temperature")) {
endTemp = config.opt_int("nozzle_temperature", i);
}
// FIXME: curr_bed_type is now a plate config rather than a global config.
// Currently bed temp is not used for brim generation, so just comment it for now.
#if 0
if (config.has("curr_bed_type")) {
BedType curr_bed_type = config.opt_enum<BedType>("curr_bed_type");
bedTemp = config.opt_int(get_bed_temp_key(curr_bed_type), i);
}
#endif
if (i == 0) extruderParamsMap.insert({ i,{matName, bedTemp, endTemp} });
extruderParamsMap.insert({ i + 1,{matName, bedTemp, endTemp} });
}
}
// update the maxSpeed of an object if it is different from the global configuration // update the maxSpeed of an object if it is different from the global configuration
double Model::findMaxSpeed(const ModelObject* object) { double Model::findMaxSpeed(const ModelObject* object) {
auto objectKeys = object->config.keys(); auto objectKeys = object->config.keys();

View file

@ -1545,6 +1545,9 @@ public:
static double getThermalLength(const ModelVolume* modelVolumePtr); static double getThermalLength(const ModelVolume* modelVolumePtr);
static double getThermalLength(const std::vector<ModelVolume*> modelVolumePtrs); static double getThermalLength(const std::vector<ModelVolume*> modelVolumePtrs);
static Polygon getBedPolygon() { return Model::printSpeedMap.bed_poly; } static Polygon getBedPolygon() { return Model::printSpeedMap.bed_poly; }
//BBS static functions that update extruder params and speed table
static void setPrintSpeedTable(const DynamicPrintConfig& config, const PrintConfig& print_config);
static void setExtruderParams(const DynamicPrintConfig& config, int extruders_count);
// BBS: backup // BBS: backup
static Model read_from_archive( static Model read_from_archive(

View file

@ -270,7 +270,7 @@ void ArrangeJob::prepare_wipe_tower()
break; break;
} }
} }
// if multile extruders have same bed temp, we need wipe tower // if multile extruders have same bed temp, we need wipe tower
// 允许不同材料落在相同盘,且所有选定对象中使用了多种热床温度相同的材料 // 允许不同材料落在相同盘,且所有选定对象中使用了多种热床温度相同的材料
if (params.allow_multi_materials_on_same_plate) { if (params.allow_multi_materials_on_same_plate) {
@ -395,8 +395,13 @@ void ArrangeJob::prepare()
params = init_arrange_params(m_plater); params = init_arrange_params(m_plater);
//BBS update extruder params and speed table before arranging //BBS update extruder params and speed table before arranging
Plater::setExtruderParams(Model::extruderParamsMap); const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config();
Plater::setPrintSpeedTable(Model::printSpeedMap); auto& print = wxGetApp().plater()->get_partplate_list().get_current_fff_print();
auto print_config = print.config();
int numExtruders = wxGetApp().preset_bundle->filament_presets.size();
Model::setExtruderParams(config, numExtruders);
Model::setPrintSpeedTable(config, print_config);
int state = m_plater->get_prepare_state(); int state = m_plater->get_prepare_state();
if (state == Job::JobPrepareState::PREPARE_STATE_DEFAULT) { if (state == Job::JobPrepareState::PREPARE_STATE_DEFAULT) {
@ -500,7 +505,7 @@ void ArrangeJob::process()
const Slic3r::DynamicPrintConfig& global_config = wxGetApp().preset_bundle->full_config(); const Slic3r::DynamicPrintConfig& global_config = wxGetApp().preset_bundle->full_config();
if (params.avoid_extrusion_cali_region && global_config.opt_bool("scan_first_layer")) if (params.avoid_extrusion_cali_region && global_config.opt_bool("scan_first_layer"))
partplate_list.preprocess_nonprefered_areas(m_unselected, MAX_NUM_PLATES); partplate_list.preprocess_nonprefered_areas(m_unselected, MAX_NUM_PLATES);
update_arrange_params(params, *m_plater, m_selected); update_arrange_params(params, *m_plater, m_selected);
update_selected_items_inflation(m_selected, m_plater->config(), params); update_selected_items_inflation(m_selected, m_plater->config(), params);
update_unselected_items_inflation(m_unselected, m_plater->config(), params); update_unselected_items_inflation(m_unselected, m_plater->config(), params);

View file

@ -170,7 +170,7 @@ wxDEFINE_EVENT(EVT_INSTALL_PLUGIN_HINT, wxCommandEvent);
wxDEFINE_EVENT(EVT_PREVIEW_ONLY_MODE_HINT, wxCommandEvent); wxDEFINE_EVENT(EVT_PREVIEW_ONLY_MODE_HINT, wxCommandEvent);
//BBS: change light/dark mode //BBS: change light/dark mode
wxDEFINE_EVENT(EVT_GLCANVAS_COLOR_MODE_CHANGED, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_COLOR_MODE_CHANGED, SimpleEvent);
//BBS: print //BBS: print
wxDEFINE_EVENT(EVT_PRINT_FROM_SDCARD_VIEW, SimpleEvent); wxDEFINE_EVENT(EVT_PRINT_FROM_SDCARD_VIEW, SimpleEvent);
@ -1065,7 +1065,7 @@ void Sidebar::update_all_preset_comboboxes()
; ;
} }
if(!url.empty()) if(!url.empty())
{ {
if(!url.Lower().starts_with("http")) if(!url.Lower().starts_with("http"))
url = wxString::Format("http://%s",url); url = wxString::Format("http://%s",url);
@ -1449,7 +1449,7 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
void Sidebar::load_ams_list(std::string const &device, MachineObject* obj) void Sidebar::load_ams_list(std::string const &device, MachineObject* obj)
{ {
std::map<int, DynamicPrintConfig> filament_ams_list = build_filament_ams_list(obj); std::map<int, DynamicPrintConfig> filament_ams_list = build_filament_ams_list(obj);
if (!obj) { if (!obj) {
p->ams_list_device = device; p->ams_list_device = device;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " clear list"; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " clear list";
@ -2807,89 +2807,6 @@ void Plater::priv::select_view(const std::string& direction)
assemble_view->select_view(direction); assemble_view->select_view(direction);
} }
} }
// BBS set print speed table and find maximum speed
void Plater::setPrintSpeedTable(GlobalSpeedMap &printSpeedMap) {
Slic3r::DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
printSpeedMap.maxSpeed = 0;
if (config.has("inner_wall_speed")) {
printSpeedMap.perimeterSpeed = config.opt_float("inner_wall_speed");
if (printSpeedMap.perimeterSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.perimeterSpeed;
}
if (config.has("outer_wall_speed")) {
printSpeedMap.externalPerimeterSpeed = config.opt_float("outer_wall_speed");
printSpeedMap.maxSpeed = std::max(printSpeedMap.maxSpeed, printSpeedMap.externalPerimeterSpeed);
}
if (config.has("sparse_infill_speed")) {
printSpeedMap.infillSpeed = config.opt_float("sparse_infill_speed");
if (printSpeedMap.infillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.infillSpeed;
}
if (config.has("internal_solid_infill_speed")) {
printSpeedMap.solidInfillSpeed = config.opt_float("internal_solid_infill_speed");
if (printSpeedMap.solidInfillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.solidInfillSpeed;
}
if (config.has("top_surface_speed")) {
printSpeedMap.topSolidInfillSpeed = config.opt_float("top_surface_speed");
if (printSpeedMap.topSolidInfillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.topSolidInfillSpeed;
}
if (config.has("support_speed")) {
printSpeedMap.supportSpeed = config.opt_float("support_speed");
if (printSpeedMap.supportSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.supportSpeed;
}
auto& print = wxGetApp().plater()->get_partplate_list().get_current_fff_print();
auto print_config = print.config();
printSpeedMap.bed_poly.points = get_bed_shape(*(wxGetApp().plater()->config()));
Pointfs excluse_area_points = print_config.bed_exclude_area.values;
Polygons exclude_polys;
Polygon exclude_poly;
for (int i = 0; i < excluse_area_points.size(); i++) {
auto pt = excluse_area_points[i];
exclude_poly.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
if (i % 4 == 3) { // exclude areas are always rectangle
exclude_polys.push_back(exclude_poly);
exclude_poly.points.clear();
}
}
printSpeedMap.bed_poly = diff({ printSpeedMap.bed_poly }, exclude_polys)[0];
}
// find temperature of heatend and bed and matierial of an given extruder
void Plater::setExtruderParams(std::map<size_t, Slic3r::ExtruderParams>& extParas) {
extParas.clear();
Slic3r::DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
// BBS
int numExtruders = wxGetApp().preset_bundle->filament_presets.size();
for (unsigned int i = 0; i != numExtruders; ++i) {
std::string matName = "";
// BBS
int bedTemp = 35;
double endTemp = 0.f;
if (config.has("filament_type")) {
matName = config.opt_string("filament_type", i);
}
if (config.has("nozzle_temperature")) {
endTemp = config.opt_int("nozzle_temperature", i);
}
// FIXME: curr_bed_type is now a plate config rather than a global config.
// Currently bed temp is not used for brim generation, so just comment it for now.
#if 0
if (config.has("curr_bed_type")) {
BedType curr_bed_type = config.opt_enum<BedType>("curr_bed_type");
bedTemp = config.opt_int(get_bed_temp_key(curr_bed_type), i);
}
#endif
if (i == 0) extParas.insert({ i,{matName, bedTemp, endTemp} });
extParas.insert({ i + 1,{matName, bedTemp, endTemp} });
}
}
wxColour Plater::get_next_color_for_filament() wxColour Plater::get_next_color_for_filament()
{ {
@ -2955,8 +2872,13 @@ void Plater::priv::select_view_3D(const std::string& name, bool no_slice)
else if (name == "Preview") { else if (name == "Preview") {
BOOST_LOG_TRIVIAL(info) << "select preview"; BOOST_LOG_TRIVIAL(info) << "select preview";
//BBS update extruder params and speed table before slicing //BBS update extruder params and speed table before slicing
Plater::setExtruderParams(Slic3r::Model::extruderParamsMap); const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config();
Plater::setPrintSpeedTable(Slic3r::Model::printSpeedMap); auto& print = q->get_partplate_list().get_current_fff_print();
auto print_config = print.config();
int numExtruders = wxGetApp().preset_bundle->filament_presets.size();
Model::setExtruderParams(config, numExtruders);
Model::setPrintSpeedTable(config, print_config);
set_current_panel(preview, no_slice); set_current_panel(preview, no_slice);
} }
else if (name == "Assemble") { else if (name == "Assemble") {
@ -4794,7 +4716,7 @@ unsigned int Plater::priv::update_restart_background_process(bool force_update_s
} }
void Plater::priv::update_fff_scene() void Plater::priv::update_fff_scene()
{ {
if (this->preview != nullptr) if (this->preview != nullptr)
this->preview->reload_print(); this->preview->reload_print();
// In case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth: // In case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
@ -6031,8 +5953,8 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt)
} }
} else { } else {
std::vector<const ModelObject *> ptrs; std::vector<const ModelObject *> ptrs;
for (auto oid : message.second) for (auto oid : message.second)
{ {
const PrintObject *print_object = this->background_process.m_fff_print->get_object(ObjectID(oid)); const PrintObject *print_object = this->background_process.m_fff_print->get_object(ObjectID(oid));
if (print_object) { ptrs.push_back(print_object->model_object()); } if (print_object) { ptrs.push_back(print_object->model_object()); }
} }
@ -6244,8 +6166,13 @@ void Plater::priv::on_action_slice_plate(SimpleEvent&)
if (q != nullptr) { if (q != nullptr) {
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice plate event\n" ; BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice plate event\n" ;
//BBS update extruder params and speed table before slicing //BBS update extruder params and speed table before slicing
Plater::setExtruderParams(Slic3r::Model::extruderParamsMap); const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config();
Plater::setPrintSpeedTable(Slic3r::Model::printSpeedMap); auto& print = q->get_partplate_list().get_current_fff_print();
auto print_config = print.config();
int numExtruders = wxGetApp().preset_bundle->filament_presets.size();
Model::setExtruderParams(config, numExtruders);
Model::setPrintSpeedTable(config, print_config);
m_slice_all = false; m_slice_all = false;
q->reslice(); q->reslice();
q->select_view_3D("Preview"); q->select_view_3D("Preview");
@ -6258,8 +6185,13 @@ void Plater::priv::on_action_slice_all(SimpleEvent&)
if (q != nullptr) { if (q != nullptr) {
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice project event\n" ; BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice project event\n" ;
//BBS update extruder params and speed table before slicing //BBS update extruder params and speed table before slicing
Plater::setExtruderParams(Slic3r::Model::extruderParamsMap); const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config();
Plater::setPrintSpeedTable(Slic3r::Model::printSpeedMap); auto& print = q->get_partplate_list().get_current_fff_print();
auto print_config = print.config();
int numExtruders = wxGetApp().preset_bundle->filament_presets.size();
Model::setExtruderParams(config, numExtruders);
Model::setPrintSpeedTable(config, print_config);
m_slice_all = true; m_slice_all = true;
m_slice_all_only_has_gcode = true; m_slice_all_only_has_gcode = true;
m_cur_slice_plate = 0; m_cur_slice_plate = 0;
@ -6735,7 +6667,7 @@ wxString Plater::priv::get_project_filename(const wxString& extension) const
} }
} }
wxString Plater::priv::get_export_gcode_filename(const wxString& extension, bool only_filename, bool export_all) wxString Plater::priv::get_export_gcode_filename(const wxString& extension, bool only_filename, bool export_all)
{ {
wxString curr_project_name = m_project_name; wxString curr_project_name = m_project_name;
@ -7634,10 +7566,10 @@ void Plater::priv::update_after_undo_redo(const UndoRedo::Snapshot& snapshot, bo
// triangle meshes may have gotten released from the scene or the background processing, therefore now being calculated into the Undo / Redo stack size. // triangle meshes may have gotten released from the scene or the background processing, therefore now being calculated into the Undo / Redo stack size.
this->undo_redo_stack().release_least_recently_used(); this->undo_redo_stack().release_least_recently_used();
//YS_FIXME update obj_list from the deserialized model (maybe store ObjectIDs into the tree?) (no selections at this point of time) //YS_FIXME update obj_list from the deserialized model (maybe store ObjectIDs into the tree?) (no selections at this point of time)
get_current_canvas3D()->get_canvas_type() == GLCanvas3D::CanvasAssembleView ? get_current_canvas3D()->get_canvas_type() == GLCanvas3D::CanvasAssembleView ?
assemble_view->get_canvas3d()->get_selection().set_deserialized(GUI::Selection::EMode(this->undo_redo_stack().selection_deserialized().mode), this->undo_redo_stack().selection_deserialized().volumes_and_instances) : assemble_view->get_canvas3d()->get_selection().set_deserialized(GUI::Selection::EMode(this->undo_redo_stack().selection_deserialized().mode), this->undo_redo_stack().selection_deserialized().volumes_and_instances) :
this->view3D->get_canvas3d()->get_selection().set_deserialized(GUI::Selection::EMode(this->undo_redo_stack().selection_deserialized().mode), this->undo_redo_stack().selection_deserialized().volumes_and_instances); this->view3D->get_canvas3d()->get_selection().set_deserialized(GUI::Selection::EMode(this->undo_redo_stack().selection_deserialized().mode), this->undo_redo_stack().selection_deserialized().volumes_and_instances);
get_current_canvas3D()->get_canvas_type() == GLCanvas3D::CanvasAssembleView ? get_current_canvas3D()->get_canvas_type() == GLCanvas3D::CanvasAssembleView ?
assemble_view->get_canvas3d()->get_gizmos_manager().update_after_undo_redo(snapshot) : assemble_view->get_canvas3d()->get_gizmos_manager().update_after_undo_redo(snapshot) :
this->view3D->get_canvas3d()->get_gizmos_manager().update_after_undo_redo(snapshot); this->view3D->get_canvas3d()->get_gizmos_manager().update_after_undo_redo(snapshot);
@ -10926,24 +10858,24 @@ void Plater::send_gcode_legacy(int plate_idx, Export3mfProgressFn proFn)
try { try {
json j; json j;
switch (dlg.post_action()) { switch (dlg.post_action()) {
case PrintHostPostUploadAction::None: case PrintHostPostUploadAction::None:
j["post_action"] = "Upload"; j["post_action"] = "Upload";
break; break;
case PrintHostPostUploadAction::StartPrint: case PrintHostPostUploadAction::StartPrint:
j["post_action"] = "StartPrint"; j["post_action"] = "StartPrint";
break; break;
case PrintHostPostUploadAction::StartSimulation: case PrintHostPostUploadAction::StartSimulation:
j["post_action"] = "StartSimulation"; j["post_action"] = "StartSimulation";
break; break;
} }
PresetBundle *preset_bundle = wxGetApp().preset_bundle; PresetBundle *preset_bundle = wxGetApp().preset_bundle;
if (preset_bundle) { if (preset_bundle) {
j["gcode_printer_model"] = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); j["gcode_printer_model"] = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
} }
if (physical_printer_config) { if (physical_printer_config) {
j["printer_preset"] = physical_printer_config->opt_string("inherits"); j["printer_preset"] = physical_printer_config->opt_string("inherits");
} }
NetworkAgent *agent = wxGetApp().getAgent(); NetworkAgent *agent = wxGetApp().getAgent();
@ -11038,7 +10970,7 @@ void Plater::print_job_finished(wxCommandEvent &evt)
p->enter_prepare_mode(); p->enter_prepare_mode();
} }
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
@ -11173,7 +11105,7 @@ void Plater::on_filaments_change(size_t num_filaments)
for (int i = 0; i < plate_list.get_plate_count(); ++i) { for (int i = 0; i < plate_list.get_plate_count(); ++i) {
PartPlate* part_plate = plate_list.get_plate(i); PartPlate* part_plate = plate_list.get_plate(i);
part_plate->update_first_layer_print_sequence(num_filaments); part_plate->update_first_layer_print_sequence(num_filaments);
} }
for (ModelObject* mo : wxGetApp().model().objects) { for (ModelObject* mo : wxGetApp().model().objects) {
for (ModelVolume* mv : mo->volumes) { for (ModelVolume* mv : mo->volumes) {
@ -11433,7 +11365,7 @@ void Plater::update_print_error_info(int code, std::string msg, std::string extr
if (p->main_frame->m_calibration) if (p->main_frame->m_calibration)
p->main_frame->m_calibration->update_print_error_info(code, msg, extra); p->main_frame->m_calibration->update_print_error_info(code, msg, extra);
} }
wxString Plater::get_project_filename(const wxString& extension) const wxString Plater::get_project_filename(const wxString& extension) const
{ {
return p->get_project_filename(extension); return p->get_project_filename(extension);
@ -12248,7 +12180,7 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi
if (!ret) { if (!ret) {
PlateNameEditDialog dlg(this, wxID_ANY, _L("Edit Plate Name")); PlateNameEditDialog dlg(this, wxID_ANY, _L("Edit Plate Name"));
PartPlate * curr_plate = p->partplate_list.get_curr_plate(); PartPlate * curr_plate = p->partplate_list.get_curr_plate();
wxString curr_plate_name = from_u8(curr_plate->get_plate_name()); wxString curr_plate_name = from_u8(curr_plate->get_plate_name());
dlg.set_plate_name(curr_plate_name); dlg.set_plate_name(curr_plate_name);

View file

@ -255,9 +255,7 @@ public:
void update_all_plate_thumbnails(bool force_update = false); void update_all_plate_thumbnails(bool force_update = false);
void invalid_all_plate_thumbnails(); void invalid_all_plate_thumbnails();
void force_update_all_plate_thumbnails(); void force_update_all_plate_thumbnails();
//BBS static functions that update extruder params and speed table
static void setPrintSpeedTable(Slic3r::GlobalSpeedMap& printSpeedMap);
static void setExtruderParams(std::map<size_t, Slic3r::ExtruderParams>& extParas);
static wxColour get_next_color_for_filament(); static wxColour get_next_color_for_filament();
static wxString get_slice_warning_string(GCodeProcessorResult::SliceWarning& warning); static wxString get_slice_warning_string(GCodeProcessorResult::SliceWarning& warning);
@ -288,7 +286,7 @@ public:
bool is_view3D_overhang_shown() const; bool is_view3D_overhang_shown() const;
void show_view3D_overhang(bool show); void show_view3D_overhang(bool show);
bool is_sidebar_collapsed() const; bool is_sidebar_collapsed() const;
void collapse_sidebar(bool show); void collapse_sidebar(bool show);