diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 2f0a99129b..f2fdcf33b4 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -908,6 +908,11 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu BOOST_LOG_TRIVIAL(info) << boost::format("Will export G-code to %1% soon")%path; print->set_started(psGCodeExport); + if (print->is_BBL_printer()) + gcode_label_objects = false; + else + gcode_label_objects = true; + // check if any custom gcode contains keywords used by the gcode processor to // produce time estimation and gcode toolpaths std::vector> validation_res = DoExport::validate_custom_gcode(*print); @@ -1285,7 +1290,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato // modifies m_silent_time_estimator_enabled DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled); - + const bool is_bbl_printers = print.is_BBL_printer(); // resets analyzer's tracking data m_last_height = 0.f; m_last_layer_z = 0.f; @@ -1349,19 +1354,50 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str()); file.write_format("; HEADER_BLOCK_END\n\n"); - //BBS: write global config at the beginning of gcode file because printer need these config information - // Append full config, delimited by two 'phony' configuration keys CONFIG_BLOCK_START and CONFIG_BLOCK_END. - // The delimiters are structured as configuration key / value pairs to be parsable by older versions of PrusaSlicer G-code viewer. + + // BBS: write global config at the beginning of gcode file because printer + // need these config information + // Append full config, delimited by two 'phony' configuration keys + // CONFIG_BLOCK_START and CONFIG_BLOCK_END. The delimiters are structured + // as configuration key / value pairs to be parsable by older versions of + // PrusaSlicer G-code viewer. { - file.write_format("; hack-fix: write fake slicer info here so that Moonraker will extract thumbs.\n"); - file.write_format("; %s\n\n",std::string(std::string("generated by SuperSlicer " SLIC3R_VERSION " on " ) + Slic3r::Utils::utc_timestamp()).c_str()); + if (is_bbl_printers) { + file.write("; CONFIG_BLOCK_START\n"); + std::string full_config; + append_full_config(print, full_config); + if (!full_config.empty()) + file.write(full_config); + + // SoftFever: write compatiple image + std::vector temps_per_bed; + int first_layer_bed_temperature = 0; + get_bed_temperature(0, true, temps_per_bed, + first_layer_bed_temperature); + file.write_format("; first_layer_bed_temperature = %d\n", + first_layer_bed_temperature); + file.write_format( + "; first_layer_temperature = %d\n", + print.config().nozzle_temperature_initial_layer.get_at(0)); + file.write("; CONFIG_BLOCK_END\n\n"); + } else { + file.write_format("; hack-fix: write fake slicer info here so that " + "Moonraker will extract thumbs.\n"); + file.write_format( + "; %s\n\n", + std::string( + std::string("generated by SuperSlicer " SLIC3R_VERSION " on ") + + Slic3r::Utils::utc_timestamp()) + .c_str()); + + // BBS: add plate id into thumbnail render logic + DoExport::export_thumbnails_to_file( + thumbnail_cb, print.get_plate_index(), {Vec2d(300, 300)}, + [&file](const char *sz) { file.write(sz); }, + [&print]() { print.throw_if_canceled(); }); + } } - - //BBS: add plate id into thumbnail render logic - DoExport::export_thumbnails_to_file(thumbnail_cb, print.get_plate_index(), { Vec2d(300, 300) }, - [&file](const char* sz) { file.write(sz); }, - [&print]() { print.throw_if_canceled(); }); - + // Write some terse information on the slicing parameters. const PrintObject *first_object = print.objects().front(); @@ -1504,7 +1540,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato m_placeholder_parser.set("first_layer_print_max", new ConfigOptionFloats({ bbox.max.x(), bbox.max.y() })); m_placeholder_parser.set("first_layer_print_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() })); } - + float outer_wall_volumetric_speed = 0.0f; { int curr_bed_type = m_config.curr_bed_type.getInt(); @@ -1528,7 +1564,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato } Flow outer_wall_flow = Flow(outer_wall_line_width, m_config.layer_height, m_config.nozzle_diameter.get_at(initial_extruder_id)); float outer_wall_speed = print.default_region_config().outer_wall_speed.value; - float outer_wall_volumetric_speed = outer_wall_speed * outer_wall_flow.mm3_per_mm(); + outer_wall_volumetric_speed = outer_wall_speed * outer_wall_flow.mm3_per_mm(); if (outer_wall_volumetric_speed > filament_max_volumetric_speed) outer_wall_volumetric_speed = filament_max_volumetric_speed; m_placeholder_parser.set("outer_wall_volumetric_speed", new ConfigOptionFloat(outer_wall_volumetric_speed)); @@ -1591,12 +1627,20 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true; //BBS: open spaghetti detector - // if (print.config().spaghetti_detector.value) - file.write("M981 S1 P20000 ;open spaghetti detector\n"); - if(m_config.enable_pressure_advance.value) - { - file.write_format("M900 K%.3f ; Override pressure advance value\n",m_config.pressure_advance.values.front()); + if (is_bbl_printers) { + // if (print.config().spaghetti_detector.value) + file.write("M981 S1 P20000 ;open spaghetti detector\n"); + file.write_format("M900 K%.3f M%0.3f ; Override pressure advance value\n", + m_config.pressure_advance.values.front(), + outer_wall_volumetric_speed / (1.75 * 1.75 / 4 * 3.14) * + m_config.pressure_advance.values.front()); + } else { + if (m_config.enable_pressure_advance.value) { + file.write_format("M900 K%.3f ; Override pressure advance value\n", + m_config.pressure_advance.values.front()); + } } + // Do all objects for each layer. if (print.config().print_sequence == PrintSequence::ByObject) { size_t finished_objects = 0; @@ -1659,7 +1703,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato this->process_layers(print, tool_ordering, collect_layers_to_print(object), *print_object_instance_sequential_active - object.instances().data(), file, prime_extruder); //BBS: close powerlost recovery { - if (m_second_layer_things_done) { + if (is_bbl_printers && m_second_layer_things_done) { file.write("; close powerlost recovery\n"); file.write("M1003 S0\n"); } @@ -1730,7 +1774,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato this->process_layers(print, tool_ordering, print_object_instances_ordering, layers_to_print, file); //BBS: close powerlost recovery { - if (m_second_layer_things_done) { + if (is_bbl_printers && m_second_layer_things_done) { file.write("; close powerlost recovery\n"); file.write("M1003 S0\n"); } @@ -1796,27 +1840,40 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato m_writer.extruders(), // Modifies print.m_print_statistics)); - file.write("\n"); - file.write("; CONFIG_BLOCK_START\n"); - std::string full_config; - append_full_config(print, full_config); - if (!full_config.empty()) + if (!is_bbl_printers) { + file.write("\n"); + file.write("; CONFIG_BLOCK_START\n"); + std::string full_config; + append_full_config(print, full_config); + if (!full_config.empty()) file.write(full_config); - // SoftFever: write compatiple image - std::vector temps_per_bed; - int first_layer_bed_temperature = 0; - get_bed_temperature(0, true, temps_per_bed, first_layer_bed_temperature); - file.write_format("; first_layer_bed_temperature = %d\n", first_layer_bed_temperature); - file.write_format("; first_layer_temperature = %d\n", print.config().nozzle_temperature_initial_layer.get_at(0)); - file.write("; CONFIG_BLOCK_END\n\n"); - file.write_format("; total filament used [g] = %.2lf\n", print.m_print_statistics.total_weight); - file.write_format("; total filament cost = %.2lf\n", print.m_print_statistics.total_cost); - if (print.m_print_statistics.total_toolchanges > 0) - file.write_format("; total filament change = %i\n", print.m_print_statistics.total_toolchanges); + // SoftFever: write compatiple info + std::vector temps_per_bed; + int first_layer_bed_temperature = 0; + get_bed_temperature(0, true, temps_per_bed, first_layer_bed_temperature); + file.write_format("; first_layer_bed_temperature = %d\n", + first_layer_bed_temperature); + file.write_format( + "; first_layer_temperature = %d\n", + print.config().nozzle_temperature_initial_layer.get_at(0)); + file.write("; CONFIG_BLOCK_END\n\n"); + file.write_format("; total filament used [g] = %.2lf\n", + print.m_print_statistics.total_weight); + file.write_format("; total filament cost = %.2lf\n", + print.m_print_statistics.total_cost); + if (print.m_print_statistics.total_toolchanges > 0) + file.write_format("; total filament change = %i\n", + print.m_print_statistics.total_toolchanges); - file.write_format("; total layers count = %i\n", m_layer_count); - file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str()); + file.write_format("; total layers count = %i\n", m_layer_count); + file.write_format( + ";%s\n", + GCodeProcessor::reserved_tag( + GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder) + .c_str()); + + } print.throw_if_canceled(); } @@ -2522,20 +2579,21 @@ GCode::LayerResult GCode::process_layer( } if (! first_layer && ! m_second_layer_things_done) { - //BBS: open powerlost recovery + if (print.is_BBL_printer()) { + // BBS: open powerlost recovery { - gcode += "; open powerlost recovery\n"; - gcode += "M1003 S1\n"; + gcode += "; open powerlost recovery\n"; + gcode += "M1003 S1\n"; } // BBS: open first layer inspection at second layer if (print.config().scan_first_layer.value) { - // BBS: retract first to avoid droping when scan model - gcode += this->retract(); - gcode += "M976 S1 P1 ; scan model before printing 2nd layer\n"; - gcode += "M400 P100\n"; - gcode += this->unretract(); + // BBS: retract first to avoid droping when scan model + gcode += this->retract(); + gcode += "M976 S1 P1 ; scan model before printing 2nd layer\n"; + gcode += "M400 P100\n"; + gcode += this->unretract(); } - + } //BBS: reset acceleration at sencond layer if (m_config.default_acceleration.value > 0 && m_config.initial_layer_acceleration.value > 0) { double acceleration = m_config.default_acceleration.value; diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 761422e7bf..34809ac6ab 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -728,7 +728,11 @@ public: // Return 4 wipe tower corners in the world coordinates (shifted and rotated), including the wipe tower brim. std::vector first_layer_wipe_tower_corners(bool check_wipe_tower_existance=true) const; -protected: + //SoftFever + bool &is_BBL_printer() { return m_isBBLPrinter; } + const bool is_BBL_printer() const { return m_isBBLPrinter; } + + protected: // Invalidates the step, and its depending steps in Print. bool invalidate_step(PrintStep step); @@ -750,6 +754,9 @@ private: PrintRegionConfig m_default_region_config; PrintObjectPtrs m_objects; PrintRegionPtrs m_print_regions; + + //SoftFever + bool m_isBBLPrinter; // Ordered collections of extrusion paths to build skirt loops and brim. ExtrusionEntityCollection m_skirt; diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index d906dd17d9..55ce786201 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -183,6 +183,13 @@ std::string BackgroundSlicingProcess::output_filepath_for_project(const boost::f void BackgroundSlicingProcess::process_fff() { assert(m_print == m_fff_print); + PresetBundle &preset_bundle = *wxGetApp().preset_bundle; + + m_fff_print->is_BBL_printer() = + preset_bundle.printers.get_edited_preset().is_bbl_vendor_preset( + &preset_bundle); + + //BBS: add the logic to process from an existed gcode file if (m_print->finished()) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: skip slicing, to process previous gcode file")%__LINE__; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d583fb889d..a7a3b14407 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -918,10 +918,23 @@ void Sidebar::update_all_preset_comboboxes() ams_btn->Show(); //update print button default value for bbl or third-party printer wxGetApp().mainframe->set_print_button_to_default(MainFrame::PrintSelectType::ePrintPlate); + MonitorPanel *curr_monitor = wxGetApp().mainframe->m_monitor; + if(wxGetApp().mainframe->m_tabpanel->GetPage(3) != + curr_monitor){ + wxGetApp().mainframe->m_tabpanel->InsertPage(3, + curr_monitor, _L("Device"), + std::string("tab_monitor_active"), + std::string("tab_monitor_active")); + } + } else { connection_btn->Show(); ams_btn->Hide(); wxGetApp().mainframe->set_print_button_to_default(MainFrame::PrintSelectType::eSendGcode); + MonitorPanel *curr_monitor = wxGetApp().mainframe->m_monitor; + if (wxGetApp().mainframe->m_tabpanel->GetPage(3) == curr_monitor) { + wxGetApp().mainframe->m_tabpanel->RemovePage(3); + } } // Update the print choosers to only contain the compatible presets, update the dirty flags.