Tech ENABLE_BINARIZED_GCODE set as default

This commit is contained in:
enricoturri1966 2023-09-05 12:17:47 +02:00
parent 317326bf9c
commit 53adc68717
22 changed files with 64 additions and 586 deletions

View File

@ -43,9 +43,7 @@
#include <boost/format.hpp>
#include <string.h>
#if ENABLE_BINARIZED_GCODE
#include <LibBGCode/binarize/binarize.hpp>
#endif // ENABLE_BINARIZED_GCODE
//FIXME for GCodeFlavor and gcfMarlin (for forward-compatibility conversion)
// This is not nice, likely it would be better to pass the ConfigSubstitutionContext to handle_legacy().
@ -746,7 +744,6 @@ void ConfigBase::setenv_() const
ConfigSubstitutions ConfigBase::load(const std::string& filename, ForwardCompatibilitySubstitutionRule compatibility_rule)
{
#if ENABLE_BINARIZED_GCODE
enum class EFileType
{
Ini,
@ -759,10 +756,10 @@ ConfigSubstitutions ConfigBase::load(const std::string& filename, ForwardCompati
if (is_gcode_file(filename)) {
FILE* file = boost::nowide::fopen(filename.c_str(), "rb");
if (file == nullptr)
throw Slic3r::RuntimeError("Error opening the file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Error opening file %1%", filename));
using namespace bgcode::core;
std::vector<uint8_t> cs_buffer(65536);
using namespace bgcode::core;
file_type = (is_valid_binary_gcode(*file, true, cs_buffer.data(), cs_buffer.size()) == EResult::Success) ? EFileType::BinaryGCode : EFileType::AsciiGCode;
fclose(file);
}
@ -774,13 +771,8 @@ ConfigSubstitutions ConfigBase::load(const std::string& filename, ForwardCompati
case EFileType::Ini: { return this->load_from_ini(filename, compatibility_rule); }
case EFileType::AsciiGCode: { return this->load_from_gcode_file(filename, compatibility_rule);}
case EFileType::BinaryGCode: { return this->load_from_binary_gcode_file(filename, compatibility_rule);}
default: { throw Slic3r::RuntimeError("Invalid file: " + filename + "\n"); }
default: { throw Slic3r::RuntimeError(format("Invalid file %1%", filename)); }
}
#else
return is_gcode_file(filename) ?
this->load_from_gcode_file(filename, compatibility_rule) :
this->load_from_ini(filename, compatibility_rule);
#endif // ENABLE_BINARIZED_GCODE
}
ConfigSubstitutions ConfigBase::load_from_ini(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
@ -1086,38 +1078,38 @@ ConfigSubstitutions ConfigBase::load_from_gcode_file(const std::string &filename
return std::move(substitutions_ctxt.substitutions);
}
#if ENABLE_BINARIZED_GCODE
ConfigSubstitutions ConfigBase::load_from_binary_gcode_file(const std::string& filename, ForwardCompatibilitySubstitutionRule compatibility_rule)
{
ConfigSubstitutionContext substitutions_ctxt(compatibility_rule);
FilePtr file{ boost::nowide::fopen(filename.c_str(), "rb") };
if (file.f == nullptr)
throw Slic3r::RuntimeError(format("Error opening the file: %1%", filename));
throw Slic3r::RuntimeError(format("Error opening file %1%", filename));
using namespace bgcode::core;
using namespace bgcode::binarize;
std::vector<uint8_t> cs_buffer(65536);
EResult res = is_valid_binary_gcode(*file.f, true, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError(format("The selected file is not a valid binary gcode.\nError: %1%", std::string(translate_result(res))));
throw Slic3r::RuntimeError(format("File %1% does not contain a valid binary gcode\nError: %2%", filename,
std::string(translate_result(res))));
FileHeader file_header;
res = read_header(*file.f, file_header, nullptr);
if (res != EResult::Success)
throw Slic3r::RuntimeError(format("Error while reading file '%1%': %2%", filename, std::string(translate_result(res))));
throw Slic3r::RuntimeError(format("Error while reading file %1%: %2%", filename, std::string(translate_result(res))));
// searches for config block
BlockHeader block_header;
res = read_next_block_header(*file.f, file_header, block_header, EBlockType::SlicerMetadata, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError(format("Error while reading file '%1%': %2%", filename, std::string(translate_result(res))));
throw Slic3r::RuntimeError(format("Error while reading file %1%: %2%", filename, std::string(translate_result(res))));
if ((EBlockType)block_header.type != EBlockType::SlicerMetadata)
throw Slic3r::RuntimeError(format("Unable to find slicer metadata block in file: '%1%'", filename));
throw Slic3r::RuntimeError(format("Unable to find slicer metadata block in file %1%", filename));
SlicerMetadataBlock slicer_metadata_block;
res = slicer_metadata_block.read_data(*file.f, file_header, block_header);
if (res != EResult::Success)
throw Slic3r::RuntimeError(format("Error while reading file '%1%': %2%", filename, std::string(translate_result(res))));
throw Slic3r::RuntimeError(format("Error while reading file %1%: %2%", filename, std::string(translate_result(res))));
// extracts data from block
for (const auto& [key, value] : slicer_metadata_block.raw_data) {
@ -1126,7 +1118,6 @@ ConfigSubstitutions ConfigBase::load_from_binary_gcode_file(const std::string& f
return std::move(substitutions_ctxt.substitutions);
}
#endif // ENABLE_BINARIZED_GCODE
void ConfigBase::save(const std::string &file) const
{

View File

@ -2329,9 +2329,7 @@ public:
// Accepts the same data as load_from_ini_string(), only with each configuration line possibly prefixed with a semicolon (G-code comment).
ConfigSubstitutions load_from_ini_string_commented(std::string &&data, ForwardCompatibilitySubstitutionRule compatibility_rule);
ConfigSubstitutions load_from_gcode_file(const std::string &filename, ForwardCompatibilitySubstitutionRule compatibility_rule);
#if ENABLE_BINARIZED_GCODE
ConfigSubstitutions load_from_binary_gcode_file(const std::string& filename, ForwardCompatibilitySubstitutionRule compatibility_rule);
#endif // ENABLE_BINARIZED_GCODE
ConfigSubstitutions load(const boost::property_tree::ptree &tree, ForwardCompatibilitySubstitutionRule compatibility_rule);
void save(const std::string &file) const;

View File

@ -43,9 +43,6 @@
#include "libslic3r.h"
#include "LocalesUtils.hpp"
#include "format.hpp"
#if ENABLE_BINARIZED_GCODE
#include "libslic3r_version.h"
#endif // ENABLE_BINARIZED_GCODE
#include <algorithm>
#include <cstdlib>
@ -581,9 +578,7 @@ void GCodeGenerator::do_export(Print* print, const char* path, GCodeProcessorRes
m_processor.initialize(path_tmp);
m_processor.set_print(print);
#if ENABLE_BINARIZED_GCODE
m_processor.get_binary_data() = bgcode::binarize::BinaryData();
#endif // ENABLE_BINARIZED_GCODE
GCodeOutputStream file(boost::nowide::fopen(path_tmp.c_str(), "wb"), m_processor);
if (! file.is_open())
throw Slic3r::RuntimeError(std::string("G-code export to ") + path + " failed.\nCannot open the file for writing.\n");
@ -716,7 +711,6 @@ namespace DoExport {
}
// Fill in print_statistics and return formatted string containing filament statistics to be inserted into G-code comment section.
#if ENABLE_BINARIZED_GCODE
static std::string update_print_stats_and_format_filament_stats(
const bool has_wipe_tower,
const WipeTowerData &wipe_tower_data,
@ -726,15 +720,6 @@ namespace DoExport {
PrintStatistics &print_statistics,
bool export_binary_data,
bgcode::binarize::BinaryData &binary_data)
#else
static std::string update_print_stats_and_format_filament_stats(
const bool has_wipe_tower,
const WipeTowerData &wipe_tower_data,
const FullPrintConfig &config,
const std::vector<Extruder> &extruders,
unsigned int initial_extruder_id,
PrintStatistics &print_statistics)
#endif // ENABLE_BINARIZED_GCODE
{
std::string filament_stats_string_out;
@ -743,17 +728,10 @@ namespace DoExport {
print_statistics.initial_extruder_id = initial_extruder_id;
std::vector<std::string> filament_types;
if (! extruders.empty()) {
#if ENABLE_BINARIZED_GCODE
std::pair<std::string, unsigned int> out_filament_used_mm(PrintStatistics::FilamentUsedMmMask + " ", 0);
std::pair<std::string, unsigned int> out_filament_used_cm3(PrintStatistics::FilamentUsedCm3Mask + " ", 0);
std::pair<std::string, unsigned int> out_filament_used_g(PrintStatistics::FilamentUsedGMask + " ", 0);
std::pair<std::string, unsigned int> out_filament_cost(PrintStatistics::FilamentCostMask + " ", 0);
#else
std::pair<std::string, unsigned int> out_filament_used_mm("; filament used [mm] = ", 0);
std::pair<std::string, unsigned int> out_filament_used_cm3("; filament used [cm3] = ", 0);
std::pair<std::string, unsigned int> out_filament_used_g ("; filament used [g] = ", 0);
std::pair<std::string, unsigned int> out_filament_cost("; filament cost = ", 0);
#endif // ENABLE_BINARIZED_GCODE
for (const Extruder &extruder : extruders) {
print_statistics.printing_extruders.emplace_back(extruder.id());
filament_types.emplace_back(config.filament_type.get_at(extruder.id()));
@ -776,25 +754,17 @@ namespace DoExport {
dst.first += buf;
++ dst.second;
};
#if ENABLE_BINARIZED_GCODE
if (!export_binary_data) {
#endif // ENABLE_BINARIZED_GCODE
append(out_filament_used_mm, "%.2lf", used_filament);
append(out_filament_used_cm3, "%.2lf", extruded_volume * 0.001);
#if ENABLE_BINARIZED_GCODE
}
#endif // ENABLE_BINARIZED_GCODE
if (filament_weight > 0.) {
print_statistics.total_weight = print_statistics.total_weight + filament_weight;
#if ENABLE_BINARIZED_GCODE
if (!export_binary_data)
#endif // ENABLE_BINARIZED_GCODE
append(out_filament_used_g, "%.2lf", filament_weight);
if (filament_cost > 0.) {
print_statistics.total_cost = print_statistics.total_cost + filament_cost;
#if ENABLE_BINARIZED_GCODE
if (!export_binary_data)
#endif // ENABLE_BINARIZED_GCODE
append(out_filament_cost, "%.2lf", filament_cost);
}
}
@ -803,18 +773,14 @@ namespace DoExport {
print_statistics.total_wipe_tower_filament += has_wipe_tower ? used_filament - extruder.used_filament() : 0.;
print_statistics.total_wipe_tower_cost += has_wipe_tower ? (extruded_volume - extruder.extruded_volume())* extruder.filament_density() * 0.001 * extruder.filament_cost() * 0.001 : 0.;
}
#if ENABLE_BINARIZED_GCODE
if (!export_binary_data) {
#endif // ENABLE_BINARIZED_GCODE
filament_stats_string_out += out_filament_used_mm.first;
filament_stats_string_out += "\n" + out_filament_used_cm3.first;
if (out_filament_used_g.second)
filament_stats_string_out += "\n" + out_filament_used_g.first;
if (out_filament_cost.second)
filament_stats_string_out += "\n" + out_filament_cost.first;
#if ENABLE_BINARIZED_GCODE
}
#endif // ENABLE_BINARIZED_GCODE
print_statistics.initial_filament_type = config.filament_type.get_at(initial_extruder_id);
std::sort(filament_types.begin(), filament_types.end());
print_statistics.printing_filament_types = filament_types.front();
@ -895,7 +861,6 @@ static inline GCode::SmoothPathCache smooth_path_interpolate_global(const Print&
void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
{
#if ENABLE_BINARIZED_GCODE
const bool export_to_binary_gcode = print.full_print_config().option<ConfigOptionBool>("gcode_binary")->value;
// if exporting gcode in binary format:
// we generate here the data to be passed to the post-processor, who is responsible to export them to file
@ -981,7 +946,6 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
binary_data.printer_metadata.raw_data.emplace_back("extruder_colour", extruder_colours_str); // duplicated into config data
}
}
#endif // ENABLE_BINARIZED_GCODE
// modifies m_silent_time_estimator_enabled
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
@ -1036,24 +1000,18 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
this->m_avoid_crossing_curled_overhangs.init_bed_shape(get_bed_shape(print.config()));
}
#if ENABLE_BINARIZED_GCODE
if (!export_to_binary_gcode)
#endif // ENABLE_BINARIZED_GCODE
// Write information on the generator.
file.write_format("; %s\n\n", Slic3r::header_slic3r_generated().c_str());
#if ENABLE_BINARIZED_GCODE
// if exporting gcode in ascii format, generate the thumbnails here
if (! export_to_binary_gcode) {
#endif // ENABLE_BINARIZED_GCODE
// if exporting gcode in ascii format, generate the thumbnails here
if (std::vector<std::pair<GCodeThumbnailsFormat, Vec2d>> thumbnails = GCodeThumbnails::make_thumbnail_list(print.full_print_config());
! thumbnails.empty())
GCodeThumbnails::export_thumbnails_to_file(thumbnail_cb, thumbnails,
[&file](const char* sz) { file.write(sz); },
[&print]() { print.throw_if_canceled(); });
#if ENABLE_BINARIZED_GCODE
}
#endif // ENABLE_BINARIZED_GCODE
// Write notes (content of the Print Settings tab -> Notes)
{
@ -1075,9 +1033,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
const double layer_height = first_object->config().layer_height.value;
assert(! print.config().first_layer_height.percent);
const double first_layer_height = print.config().first_layer_height.value;
#if ENABLE_BINARIZED_GCODE
if (!export_to_binary_gcode) {
#endif // ENABLE_BINARIZED_GCODE
for (size_t region_id = 0; region_id < print.num_print_regions(); ++ region_id) {
const PrintRegion &region = print.get_print_region(region_id);
file.write_format("; external perimeters extrusion width = %.2fmm\n", region.flow(*first_object, frExternalPerimeter, layer_height).width());
@ -1092,9 +1048,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
file.write_format("\n");
}
print.throw_if_canceled();
#if ENABLE_BINARIZED_GCODE
}
#endif // ENABLE_BINARIZED_GCODE
// adds tags for time estimators
if (print.config().remaining_times.value)
@ -1408,7 +1362,6 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
print.throw_if_canceled();
// Get filament stats.
#if ENABLE_BINARIZED_GCODE
const std::string filament_stats_string_out = DoExport::update_print_stats_and_format_filament_stats(
// Const inputs
has_wipe_tower, print.wipe_tower_data(),
@ -1433,34 +1386,15 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
binary_data.printer_metadata.raw_data.emplace_back("max_layer_z", buf);
}
else {
#else
file.write(DoExport::update_print_stats_and_format_filament_stats(
// Const inputs
has_wipe_tower, print.wipe_tower_data(),
this->config(),
m_writer.extruders(),
initial_extruder_id,
// Modifies
print.m_print_statistics));
#endif // ENABLE_BINARIZED_GCODE
#if ENABLE_BINARIZED_GCODE
// if exporting gcode in ascii format, statistics export is done here
#endif // ENABLE_BINARIZED_GCODE
file.write("\n");
#if ENABLE_BINARIZED_GCODE
file.write_format(PrintStatistics::TotalFilamentUsedGValueMask.c_str(), print.m_print_statistics.total_weight);
file.write_format(PrintStatistics::TotalFilamentCostValueMask.c_str(), print.m_print_statistics.total_cost);
#else
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);
#endif // ENABLE_BINARIZED_GCODE
if (print.m_print_statistics.total_toolchanges > 0)
file.write_format("; total toolchanges = %i\n", print.m_print_statistics.total_toolchanges);
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str());
#if ENABLE_BINARIZED_GCODE
// if exporting gcode in ascii format, config export is done here
#endif // ENABLE_BINARIZED_GCODE
// Append full config, delimited by two 'phony' configuration keys prusaslicer_config = begin and prusaslicer_config = end.
// The delimiters are structured as configuration key / value pairs to be parsable by older versions of PrusaSlicer G-code viewer.
{
@ -1471,9 +1405,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
file.write(full_config);
file.write("; prusaslicer_config = end\n");
}
#if ENABLE_BINARIZED_GCODE
}
#endif // ENABLE_BINARIZED_GCODE
print.throw_if_canceled();
}
@ -2582,34 +2514,13 @@ void GCodeGenerator::apply_print_config(const PrintConfig &print_config)
void GCodeGenerator::append_full_config(const Print &print, std::string &str)
{
#if ENABLE_BINARIZED_GCODE
std::vector<std::pair<std::string, std::string>> config;
encode_full_config(print, config);
for (const auto& [key, value] : config) {
str += "; " + key + " = " + value + "\n";
}
#else
const DynamicPrintConfig &cfg = print.full_print_config();
// Sorted list of config keys, which shall not be stored into the G-code. Initializer list.
static constexpr auto banned_keys = {
"compatible_printers"sv,
"compatible_prints"sv,
//FIXME The print host keys should not be exported to full_print_config anymore. The following keys may likely be removed.
"print_host"sv,
"printhost_apikey"sv,
"printhost_cafile"sv
};
assert(std::is_sorted(banned_keys.begin(), banned_keys.end()));
auto is_banned = [](const std::string &key) {
return std::binary_search(banned_keys.begin(), banned_keys.end(), key);
};
for (const std::string &key : cfg.keys())
if (! is_banned(key) && ! cfg.option(key)->is_nil())
str += "; " + key + " = " + cfg.opt_serialize(key) + "\n";
#endif // ENABLE_BINARIZED_GCODE
}
#if ENABLE_BINARIZED_GCODE
void GCodeGenerator::encode_full_config(const Print& print, std::vector<std::pair<std::string, std::string>>& config)
{
const DynamicPrintConfig& cfg = print.full_print_config();
@ -2633,7 +2544,6 @@ void GCodeGenerator::encode_full_config(const Print& print, std::vector<std::pai
}
config.shrink_to_fit();
}
#endif // ENABLE_BINARIZED_GCODE
void GCodeGenerator::set_extruders(const std::vector<unsigned int> &extruder_ids)
{

View File

@ -46,10 +46,6 @@
//#include "GCode/PressureEqualizer.hpp"
#if ENABLE_BINARIZED_GCODE
#include <LibBGCode/binarize/binarize.hpp>
#endif // ENABLE_BINARIZED_GCODE
namespace Slic3r {
// Forward declarations.
@ -168,10 +164,8 @@ public:
// append full config to the given string
static void append_full_config(const Print& print, std::string& str);
#if ENABLE_BINARIZED_GCODE
// translate full config into a list of <key, value> items
static void encode_full_config(const Print& print, std::vector<std::pair<std::string, std::string>>& config);
#endif // ENABLE_BINARIZED_GCODE
// Object and support extrusions of the same PrintObject at the same print_z.
// public, so that it could be accessed by free helper functions from GCode.cpp

View File

@ -69,20 +69,18 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags = {
const float GCodeProcessor::Wipe_Width = 0.05f;
const float GCodeProcessor::Wipe_Height = 0.05f;
#if ENABLE_BINARIZED_GCODE
bgcode::binarize::BinarizerConfig GCodeProcessor::s_binarizer_config{
{
bgcode::core::ECompressionType::None, // file metadata
bgcode::core::ECompressionType::None, // printer metadata
bgcode::core::ECompressionType::Deflate, // print metadata
bgcode::core::ECompressionType::Deflate, // slicer metadata
bgcode::core::ECompressionType::None, // file metadata
bgcode::core::ECompressionType::None, // printer metadata
bgcode::core::ECompressionType::Deflate, // print metadata
bgcode::core::ECompressionType::Deflate, // slicer metadata
bgcode::core::ECompressionType::Heatshrink_12_4, // gcode
},
bgcode::core::EGCodeEncodingType::MeatPackComments,
bgcode::core::EMetadataEncodingType::INI,
bgcode::core::EChecksumType::CRC32
};
#endif // ENABLE_BINARIZED_GCODE
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "MM3_PER_MM:";
@ -474,10 +472,7 @@ void GCodeProcessorResult::reset() {
}
#else
void GCodeProcessorResult::reset() {
#if ENABLE_BINARIZED_GCODE
is_binary_file = false;
#endif // ENABLE_BINARIZED_GCODE
moves.clear();
lines_ends.clear();
bed_shape = Pointfs();
@ -576,10 +571,8 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
{
m_parser.apply_config(config);
#if ENABLE_BINARIZED_GCODE
m_binarizer.set_enabled(config.gcode_binary);
m_result.is_binary_file = config.gcode_binary;
#endif // ENABLE_BINARIZED_GCODE
m_producer = EProducer::PrusaSlicer;
m_flavor = config.gcode_flavor;
@ -1050,11 +1043,10 @@ static inline const char* remove_eols(const char *begin, const char *end) {
// Load a G-code into a stand-alone G-code viewer.
// throws CanceledException through print->throw_if_canceled() (sent by the caller as callback).
void GCodeProcessor::process_file(const std::string& filename, std::function<void()> cancel_callback)
#if ENABLE_BINARIZED_GCODE
{
FILE* file = boost::nowide::fopen(filename.c_str(), "rb");
if (file == nullptr)
throw Slic3r::RuntimeError("Error opening the file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Error opening file %1%", filename));
using namespace bgcode::core;
std::vector<uint8_t> cs_buffer(65536);
@ -1068,7 +1060,6 @@ void GCodeProcessor::process_file(const std::string& filename, std::function<voi
}
void GCodeProcessor::process_ascii_file(const std::string& filename, std::function<void()> cancel_callback)
#endif // ENABLE_BINARIZED_GCODE
{
CNumericLocalesSetter locales_setter;
@ -1119,9 +1110,7 @@ void GCodeProcessor::process_ascii_file(const std::string& filename, std::functi
// process gcode
m_result.filename = filename;
#if ENABLE_BINARIZED_GCODE
m_result.is_binary_file = false;
#endif // ENABLE_BINARIZED_GCODE
m_result.id = ++s_result_id;
initialize_result_moves();
size_t parse_line_callback_cntr = 10000;
@ -1139,7 +1128,6 @@ void GCodeProcessor::process_ascii_file(const std::string& filename, std::functi
this->finalize(false);
}
#if ENABLE_BINARIZED_GCODE
static void update_lines_ends_and_out_file_pos(const std::string& out_string, std::vector<size_t>& lines_ends, size_t* out_file_pos)
{
for (size_t i = 0; i < out_string.size(); ++i) {
@ -1158,7 +1146,7 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
FilePtr file{ boost::nowide::fopen(filename.c_str(), "rb") };
if (file.f == nullptr)
throw Slic3r::RuntimeError("Unable to open file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Error opening file %1%", filename));
fseek(file.f, 0, SEEK_END);
const long file_size = ftell(file.f);
@ -1170,21 +1158,21 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
FileHeader file_header;
EResult res = read_header(*file.f, file_header, nullptr);
if (res != EResult::Success)
throw Slic3r::RuntimeError("File: " + filename + "does not contain a valid binary gcode\n Error: " +
std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("File %1% does not contain a valid binary gcode\nError: %2%", filename,
std::string(translate_result(res))));
// read file metadata block
BlockHeader block_header;
std::vector<uint8_t> cs_buffer(65536);
res = read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
if ((EBlockType)block_header.type != EBlockType::FileMetadata)
throw Slic3r::RuntimeError("Unable to find file metadata block in file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Unable to find file metadata block in file %1%", filename));
FileMetadataBlock file_metadata_block;
res = file_metadata_block.read_data(*file.f, file_header, block_header);
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
auto producer_it = std::find_if(file_metadata_block.raw_data.begin(), file_metadata_block.raw_data.end(),
[](const std::pair<std::string, std::string>& item) { return item.first == "Producer"; });
if (producer_it != file_metadata_block.raw_data.end() && boost::starts_with(producer_it->second, std::string(SLIC3R_APP_NAME)))
@ -1195,47 +1183,47 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
// read printer metadata block
res = read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
if ((EBlockType)block_header.type != EBlockType::PrinterMetadata)
throw Slic3r::RuntimeError("Unable to find printer metadata block in file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Unable to find printer metadata block in file %1%", filename));
PrinterMetadataBlock printer_metadata_block;
res = printer_metadata_block.read_data(*file.f, file_header, block_header);
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
// read thumbnail blocks
res = read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
while ((EBlockType)block_header.type == EBlockType::Thumbnail) {
ThumbnailBlock thumbnail_block;
res = thumbnail_block.read_data(*file.f, file_header, block_header);
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
res = read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
}
// read print metadata block
if ((EBlockType)block_header.type != EBlockType::PrintMetadata)
throw Slic3r::RuntimeError("Unable to find print metadata block in file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Unable to find print metadata block in file %1%", filename));
PrintMetadataBlock print_metadata_block;
res = print_metadata_block.read_data(*file.f, file_header, block_header);
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
// read slicer metadata block
res = read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
if ((EBlockType)block_header.type != EBlockType::SlicerMetadata)
throw Slic3r::RuntimeError("Unable to find slicer metadata block in file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Unable to find slicer metadata block in file %1%", filename));
SlicerMetadataBlock slicer_metadata_block;
res = slicer_metadata_block.read_data(*file.f, file_header, block_header);
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
DynamicPrintConfig config;
config.apply(FullPrintConfig::defaults());
std::string str;
@ -1256,14 +1244,14 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
// read gcodes block
res = read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
if ((EBlockType)block_header.type != EBlockType::GCode)
throw Slic3r::RuntimeError("Unable to find gcode block in file: " + filename + "\n");
throw Slic3r::RuntimeError(format("Unable to find gcode block in file %1%", filename));
while ((EBlockType)block_header.type == EBlockType::GCode) {
GCodeBlock block;
res = block.read_data(*file.f, file_header, block_header);
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
std::vector<size_t>& lines_ends = m_result.lines_ends.emplace_back(std::vector<size_t>());
update_lines_ends_and_out_file_pos(block.raw_data, lines_ends, nullptr);
@ -1277,13 +1265,12 @@ void GCodeProcessor::process_binary_file(const std::string& filename, std::funct
res = read_next_block_header(*file.f, file_header, block_header, cs_buffer.data(), cs_buffer.size());
if (res != EResult::Success)
throw Slic3r::RuntimeError("Error while reading file '" + filename + "': " + std::string(translate_result(res)) + "\n");
throw Slic3r::RuntimeError(format("Error reading file %1%: %2%", filename, std::string(translate_result(res))));
}
// Don't post-process the G-code to update time stamps.
this->finalize(false);
}
#endif // ENABLE_BINARIZED_GCODE
void GCodeProcessor::initialize(const std::string& filename)
{
@ -3656,7 +3643,6 @@ void GCodeProcessor::post_process()
if (out.f == nullptr)
throw Slic3r::RuntimeError(std::string("GCode processor post process export failed.\nCannot open file for writing.\n"));
#if ENABLE_BINARIZED_GCODE
std::vector<double> filament_mm(m_result.extruders_count, 0.0);
std::vector<double> filament_cm3(m_result.extruders_count, 0.0);
std::vector<double> filament_g(m_result.extruders_count, 0.0);
@ -3715,9 +3701,8 @@ void GCodeProcessor::post_process()
const bgcode::core::EResult res = m_binarizer.initialize(*out.f, s_binarizer_config);
if (res != bgcode::core::EResult::Success)
throw Slic3r::RuntimeError(std::string("Unable to initialize the gcode binarizer.\n"));
throw Slic3r::RuntimeError(std::string("Unable to initialize the gcode binarizer."));
}
#endif // ENABLE_BINARIZED_GCODE
auto time_in_minutes = [](float time_in_seconds) {
assert(time_in_seconds >= 0.f);
@ -3835,26 +3820,15 @@ void GCodeProcessor::post_process()
size_t m_curr_g1_id{ 0 };
size_t m_out_file_pos{ 0 };
#if ENABLE_BINARIZED_GCODE
bgcode::binarize::Binarizer& m_binarizer;
#endif // ENABLE_BINARIZED_GCODE
public:
#if ENABLE_BINARIZED_GCODE
ExportLines(bgcode::binarize::Binarizer& binarizer, EWriteType type, TimeMachine& machine)
#ifndef NDEBUG
: m_statistics(*this), m_binarizer(binarizer), m_write_type(type), m_machine(machine) {}
#else
: m_binarizer(binarizer), m_write_type(type), m_machine(machine) {}
#endif // NDEBUG
#else
ExportLines(EWriteType type, TimeMachine& machine)
#ifndef NDEBUG
: m_statistics(*this), m_write_type(type), m_machine(machine) {}
#else
: m_write_type(type), m_machine(machine) {}
#endif // NDEBUG
#endif // ENABLE_BINARIZED_GCODE
void update(size_t lines_counter, size_t g1_lines_counter) {
m_gcode_lines_map.push_back({ lines_counter, 0 });
@ -3965,18 +3939,14 @@ void GCodeProcessor::post_process()
}
}
#if ENABLE_BINARIZED_GCODE
if (m_binarizer.is_enabled()) {
if (m_binarizer.append_gcode(out_string) != bgcode::core::EResult::Success)
throw Slic3r::RuntimeError(std::string("Error while sending gcode to the binarizer.\n"));
throw Slic3r::RuntimeError("Error while sending gcode to the binarizer.");
}
else {
write_to_file(out, out_string, result, out_path);
update_lines_ends_and_out_file_pos(out_string, result.lines_ends.front(), &m_out_file_pos);
}
#else
write_to_file(out, out_string, result, out_path);
#endif // ENABLE_BINARIZED_GCODE
}
// flush the current content of the cache to file
@ -3992,18 +3962,14 @@ void GCodeProcessor::post_process()
m_statistics.remove_all_lines();
#endif // NDEBUG
#if ENABLE_BINARIZED_GCODE
if (m_binarizer.is_enabled()) {
if (m_binarizer.append_gcode(out_string) != bgcode::core::EResult::Success)
throw Slic3r::RuntimeError(std::string("Error while sending gcode to the binarizer.\n"));
throw Slic3r::RuntimeError("Error while sending gcode to the binarizer.");
}
else {
write_to_file(out, out_string, result, out_path);
update_lines_ends_and_out_file_pos(out_string, result.lines_ends.front(), &m_out_file_pos);
}
#else
write_to_file(out, out_string, result, out_path);
#endif // ENABLE_BINARIZED_GCODE
}
void synchronize_moves(GCodeProcessorResult& result) const {
@ -4022,33 +3988,19 @@ void GCodeProcessor::post_process()
private:
void write_to_file(FilePtr& out, const std::string& out_string, GCodeProcessorResult& result, const std::string& out_path) {
if (!out_string.empty()) {
#if ENABLE_BINARIZED_GCODE
if (!m_binarizer.is_enabled()) {
#endif // ENABLE_BINARIZED_GCODE
fwrite((const void*)out_string.c_str(), 1, out_string.length(), out.f);
if (ferror(out.f)) {
out.close();
boost::nowide::remove(out_path.c_str());
throw Slic3r::RuntimeError(std::string("GCode processor post process export failed.\nIs the disk full?\n"));
throw Slic3r::RuntimeError("GCode processor post process export failed.\nIs the disk full?");
}
#if ENABLE_BINARIZED_GCODE
}
#else
for (size_t i = 0; i < out_string.size(); ++i) {
if (out_string[i] == '\n')
result.lines_ends.emplace_back(m_out_file_pos + i + 1);
}
m_out_file_pos += out_string.size();
#endif // ENABLE_BINARIZED_GCODE
}
}
};
#if ENABLE_BINARIZED_GCODE
ExportLines export_lines(m_binarizer, m_result.backtrace_enabled ? ExportLines::EWriteType::ByTime : ExportLines::EWriteType::BySize, m_time_processor.machines[0]);
#else
ExportLines export_lines(m_result.backtrace_enabled ? ExportLines::EWriteType::ByTime : ExportLines::EWriteType::BySize, m_time_processor.machines[0]);
#endif // ENABLE_BINARIZED_GCODE
// replace placeholder lines with the proper final value
// gcode_line is in/out parameter, to reduce expensive memory allocation
@ -4111,25 +4063,6 @@ void GCodeProcessor::post_process()
return processed;
};
#if !ENABLE_BINARIZED_GCODE
std::vector<double> filament_mm(m_result.extruders_count, 0.0);
std::vector<double> filament_cm3(m_result.extruders_count, 0.0);
std::vector<double> filament_g(m_result.extruders_count, 0.0);
std::vector<double> filament_cost(m_result.extruders_count, 0.0);
double filament_total_g = 0.0;
double filament_total_cost = 0.0;
for (const auto& [id, volume] : m_result.print_statistics.volumes_per_extruder) {
filament_mm[id] = volume / (static_cast<double>(M_PI) * sqr(0.5 * m_result.filament_diameters[id]));
filament_cm3[id] = volume * 0.001;
filament_g[id] = filament_cm3[id] * double(m_result.filament_densities[id]);
filament_cost[id] = filament_g[id] * double(m_result.filament_cost[id]) * 0.001;
filament_total_g += filament_g[id];
filament_total_cost += filament_cost[id];
}
#endif // !ENABLE_BINARIZED_GCODE
auto process_used_filament = [&](std::string& gcode_line) {
// Prefilter for parsing speed.
if (gcode_line.size() < 8 || gcode_line[0] != ';' || gcode_line[1] != ' ')
@ -4150,21 +4083,12 @@ void GCodeProcessor::post_process()
};
bool ret = false;
#if ENABLE_BINARIZED_GCODE
ret |= process_tag(gcode_line, PrintStatistics::FilamentUsedMmMask, filament_mm);
ret |= process_tag(gcode_line, PrintStatistics::FilamentUsedGMask, filament_g);
ret |= process_tag(gcode_line, PrintStatistics::TotalFilamentUsedGMask, { filament_total_g });
ret |= process_tag(gcode_line, PrintStatistics::FilamentUsedCm3Mask, filament_cm3);
ret |= process_tag(gcode_line, PrintStatistics::FilamentCostMask, filament_cost);
ret |= process_tag(gcode_line, PrintStatistics::TotalFilamentCostMask, { filament_total_cost });
#else
ret |= process_tag(gcode_line, "; filament used [mm] =", filament_mm);
ret |= process_tag(gcode_line, "; filament used [g] =", filament_g);
ret |= process_tag(gcode_line, "; total filament used [g] =", { filament_total_g });
ret |= process_tag(gcode_line, "; filament used [cm3] =", filament_cm3);
ret |= process_tag(gcode_line, "; filament cost =", filament_cost);
ret |= process_tag(gcode_line, "; total filament cost =", { filament_total_cost });
#endif // ENABLE_BINARIZED_GCODE
return ret;
};
@ -4303,9 +4227,7 @@ void GCodeProcessor::post_process()
};
m_result.lines_ends.clear();
#if ENABLE_BINARIZED_GCODE
m_result.lines_ends.emplace_back(std::vector<size_t>());
#endif // ENABLE_BINARIZED_GCODE
unsigned int line_id = 0;
// Backtrace data for Tx gcode lines
@ -4375,17 +4297,14 @@ void GCodeProcessor::post_process()
export_lines.flush(out, m_result, out_path);
#if ENABLE_BINARIZED_GCODE
if (m_binarizer.is_enabled()) {
if (m_binarizer.finalize() != bgcode::core::EResult::Success)
throw Slic3r::RuntimeError(std::string("Error while finalizing the gcode binarizer.\n"));
throw Slic3r::RuntimeError("Error while finalizing the gcode binarizer.");
}
#endif // ENABLE_BINARIZED_GCODE
out.close();
in.close();
#if ENABLE_BINARIZED_GCODE
if (m_binarizer.is_enabled()) {
// updates m_result.lines_ends from binarized gcode file
m_result.lines_ends.clear();
@ -4437,7 +4356,6 @@ void GCodeProcessor::post_process()
m_result.lines_ends = { std::vector<size_t>() };
}
}
#endif // ENABLE_BINARIZED_GCODE
export_lines.synchronize_moves(m_result);

View File

@ -13,9 +13,7 @@
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/CustomGCode.hpp"
#if ENABLE_BINARIZED_GCODE
#include <LibBGCode/binarize/binarize.hpp>
#endif // ENABLE_BINARIZED_GCODE
#include <cstdint>
#include <array>
@ -150,17 +148,13 @@ namespace Slic3r {
};
std::string filename;
#if ENABLE_BINARIZED_GCODE
bool is_binary_file;
#endif // ENABLE_BINARIZED_GCODE
unsigned int id;
std::vector<MoveVertex> moves;
// Positions of ends of lines of the final G-code this->filename after TimeProcessor::post_process() finalizes the G-code.
#if ENABLE_BINARIZED_GCODE
// Binarized gcodes usually have several gcode blocks. Each block has its own list on ends of lines.
// Ascii gcodes have only one list on ends of lines
std::vector<std::vector<size_t>> lines_ends;
#else
std::vector<size_t> lines_ends;
#endif // ENABLE_BINARIZED_GCODE
Pointfs bed_shape;
float max_print_height;
SettingsIds settings_ids;
@ -545,16 +539,12 @@ namespace Slic3r {
};
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
#if ENABLE_BINARIZED_GCODE_DEBUG_WINDOW
static bgcode::binarize::BinarizerConfig& get_binarizer_config() { return s_binarizer_config; }
#endif // ENABLE_BINARIZED_GCODE_DEBUG_WINDOW
private:
GCodeReader m_parser;
#if ENABLE_BINARIZED_GCODE
bgcode::binarize::Binarizer m_binarizer;
static bgcode::binarize::BinarizerConfig s_binarizer_config;
#endif // ENABLE_BINARIZED_GCODE
EUnits m_units;
EPositioningType m_global_positioning_type;
@ -652,10 +642,8 @@ namespace Slic3r {
void apply_config(const PrintConfig& config);
void set_print(Print* print) { m_print = print; }
#if ENABLE_BINARIZED_GCODE
bgcode::binarize::BinaryData& get_binary_data() { return m_binarizer.get_binary_data(); }
const bgcode::binarize::BinaryData& get_binary_data() const { return m_binarizer.get_binary_data(); }
#endif // ENABLE_BINARIZED_GCODE
void enable_stealth_time_estimator(bool enabled);
bool is_stealth_time_estimator_enabled() const {
@ -698,10 +686,8 @@ namespace Slic3r {
void apply_config_kissslicer(const std::string& filename);
void process_gcode_line(const GCodeReader::GCodeLine& line, bool producers_enabled);
#if ENABLE_BINARIZED_GCODE
void process_ascii_file(const std::string& filename, std::function<void()> cancel_callback = nullptr);
void process_binary_file(const std::string& filename, std::function<void()> cancel_callback = nullptr);
#endif // ENABLE_BINARIZED_GCODE
// Process tags embedded into comments
void process_tags(const std::string_view comment, bool producers_enabled);

View File

@ -13,9 +13,7 @@
#include <memory>
#include <string_view>
#if ENABLE_BINARIZED_GCODE
#include <LibBGCode/binarize/binarize.hpp>
#endif // ENABLE_BINARIZED_GCODE
#include <boost/beast/core/detail/base64.hpp>
@ -67,7 +65,6 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
}
}
#if ENABLE_BINARIZED_GCODE
template<typename ThrowIfCanceledCallback>
inline void generate_binary_thumbnails(ThumbnailsGeneratorCallback& thumbnail_cb, std::vector<bgcode::binarize::ThumbnailBlock>& out_thumbnails,
const std::vector<std::pair<GCodeThumbnailsFormat, Vec2d>> &thumbnails_list, ThrowIfCanceledCallback throw_if_canceled)
@ -98,7 +95,6 @@ inline void generate_binary_thumbnails(ThumbnailsGeneratorCallback& thumbnail_cb
}
}
}
#endif // ENABLE_BINARIZED_GCODE
} // namespace Slic3r::GCodeThumbnails

View File

@ -199,20 +199,12 @@ bool GCodeReader::parse_file(const std::string &file, callback_t callback)
return this->parse_file_internal(file, callback, [](size_t){});
}
#if ENABLE_BINARIZED_GCODE
bool GCodeReader::parse_file(const std::string& file, callback_t callback, std::vector<std::vector<size_t>>& lines_ends)
{
lines_ends.clear();
lines_ends.push_back(std::vector<size_t>());
return this->parse_file_internal(file, callback, [&lines_ends](size_t file_pos) { lines_ends.front().emplace_back(file_pos); });
}
#else
bool GCodeReader::parse_file(const std::string &file, callback_t callback, std::vector<size_t> &lines_ends)
{
lines_ends.clear();
return this->parse_file_internal(file, callback, [&lines_ends](size_t file_pos){ lines_ends.emplace_back(file_pos); });
}
#endif // ENABLE_BINARIZED_GCODE
bool GCodeReader::parse_file_raw(const std::string &filename, raw_line_callback_t line_callback)
{

View File

@ -135,11 +135,7 @@ public:
bool parse_file(const std::string &file, callback_t callback);
// Collect positions of line ends in the binary G-code to be used by the G-code viewer when memory mapping and displaying section of G-code
// as an overlay in the 3D scene.
#if ENABLE_BINARIZED_GCODE
bool parse_file(const std::string& file, callback_t callback, std::vector<std::vector<size_t>>& lines_ends);
#else
bool parse_file(const std::string &file, callback_t callback, std::vector<size_t> &lines_ends);
#endif // ENABLE_BINARIZED_GCODE
// Just read the G-code file line by line, calls callback (const char *begin, const char *end). Returns false if reading the file failed.
bool parse_file_raw(const std::string &file, raw_line_callback_t callback);

View File

@ -459,11 +459,7 @@ static std::vector<std::string> s_Preset_print_options {
"support_tree_angle", "support_tree_angle_slow", "support_tree_branch_diameter", "support_tree_branch_diameter_angle", "support_tree_branch_diameter_double_wall",
"support_tree_top_rate", "support_tree_branch_distance", "support_tree_tip_diameter",
"dont_support_bridges", "thick_bridges", "notes", "complete_objects", "extruder_clearance_radius",
#if ENABLE_BINARIZED_GCODE
"extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "gcode_substitutions", "gcode_binary", "perimeter_extruder",
#else
"extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "gcode_substitutions", "perimeter_extruder",
#endif // ENABLE_BINARIZED_GCODE
"infill_extruder", "solid_infill_extruder", "support_material_extruder", "support_material_interface_extruder",
"ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width",
"perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width",

View File

@ -28,9 +28,7 @@
#include <boost/locale.hpp>
#include <boost/log/trivial.hpp>
#if ENABLE_BINARIZED_GCODE
#include <LibBGCode/core/core.hpp>
#endif // ENABLE_BINARIZED_GCODE
// Store the print/filament/printer presets into a "presets" subdirectory of the Slic3rPE config dir.
// This breaks compatibility with the upstream Slic3r if the --datadir is used to switch between the two versions.
@ -886,11 +884,10 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
// If the file is loaded successfully, its print / filament / printer profiles will be activated.
ConfigSubstitutions PresetBundle::load_config_file(const std::string &path, ForwardCompatibilitySubstitutionRule compatibility_rule)
{
#if ENABLE_BINARIZED_GCODE
if (is_gcode_file(path)) {
FILE* file = boost::nowide::fopen(path.c_str(), "rb");
if (file == nullptr)
throw Slic3r::RuntimeError("Error opening the file: " + path + "\n");
throw Slic3r::RuntimeError(format("Error opening file %1%", path));
std::vector<uint8_t> cs_buffer(65536);
const bool is_binary = bgcode::core::is_valid_binary_gcode(*file, true, cs_buffer.data(), cs_buffer.size()) == bgcode::core::EResult::Success;
fclose(file);
@ -903,16 +900,6 @@ ConfigSubstitutions PresetBundle::load_config_file(const std::string &path, Forw
load_config_file_config(path, true, std::move(config));
return config_substitutions;
}
#else
if (is_gcode_file(path)) {
DynamicPrintConfig config;
config.apply(FullPrintConfig::defaults());
ConfigSubstitutions config_substitutions = config.load_from_gcode_file(path, compatibility_rule);
Preset::normalize(config);
load_config_file_config(path, true, std::move(config));
return config_substitutions;
}
#endif // ENABLE_BINARIZED_GCODE
// 1) Try to load the config file into a boost property tree.
boost::property_tree::ptree tree;

View File

@ -139,9 +139,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"perimeter_acceleration",
"post_process",
"gcode_substitutions",
#if ENABLE_BINARIZED_GCODE
"gcode_binary",
#endif // ENABLE_BINARIZED_GCODE
"printer_notes",
"retract_before_travel",
"retract_before_wipe",
@ -1637,27 +1635,25 @@ std::string Print::output_filename(const std::string &filename_base) const
return this->PrintBase::output_filename(m_config.output_filename_format.value, ".gcode", filename_base, &config);
}
#if ENABLE_BINARIZED_GCODE
const std::string PrintStatistics::FilamentUsedG = "filament used [g]";
const std::string PrintStatistics::FilamentUsedGMask = "; " + PrintStatistics::FilamentUsedG + " =";
const std::string PrintStatistics::FilamentUsedGMask = "; filament used [g] =";
const std::string PrintStatistics::TotalFilamentUsedG = "total " + PrintStatistics::FilamentUsedG;
const std::string PrintStatistics::TotalFilamentUsedGMask = "; " + PrintStatistics::TotalFilamentUsedG + " =";
const std::string PrintStatistics::TotalFilamentUsedGValueMask = TotalFilamentUsedGMask + " %.2lf\n";
const std::string PrintStatistics::TotalFilamentUsedG = "total filament used [g]";
const std::string PrintStatistics::TotalFilamentUsedGMask = "; total filament used [g] =";
const std::string PrintStatistics::TotalFilamentUsedGValueMask = "; total filament used [g] = %.2lf\n";
const std::string PrintStatistics::FilamentUsedCm3 = "filament used [cm3]";
const std::string PrintStatistics::FilamentUsedCm3Mask = "; " + PrintStatistics::FilamentUsedCm3 + " =";
const std::string PrintStatistics::FilamentUsedCm3Mask = "; filament used [cm3] =";
const std::string PrintStatistics::FilamentUsedMm = "filament used [mm]";
const std::string PrintStatistics::FilamentUsedMmMask = "; " + PrintStatistics::FilamentUsedMm + " =";
const std::string PrintStatistics::FilamentUsedMmMask = "; filament used [mm] =";
const std::string PrintStatistics::FilamentCost = "filament cost";
const std::string PrintStatistics::FilamentCostMask = "; " + PrintStatistics::FilamentCost + " =";
const std::string PrintStatistics::FilamentCostMask = "; filament cost =";
const std::string PrintStatistics::TotalFilamentCost = "total " + PrintStatistics::FilamentCost;
const std::string PrintStatistics::TotalFilamentCostMask = "; " + PrintStatistics::TotalFilamentCost + " =";
const std::string PrintStatistics::TotalFilamentCostValueMask = PrintStatistics::TotalFilamentCostMask + " %.2lf\n";
#endif // ENABLE_BINARIZED_GCODE
const std::string PrintStatistics::TotalFilamentCost = "total filament cost";
const std::string PrintStatistics::TotalFilamentCostMask = "; total filament cost =";
const std::string PrintStatistics::TotalFilamentCostValueMask = "; total filament cost = %.2lf\n";
DynamicConfig PrintStatistics::config() const
{

View File

@ -550,7 +550,6 @@ struct PrintStatistics
printing_extruders.clear();
}
#if ENABLE_BINARIZED_GCODE
static const std::string FilamentUsedG;
static const std::string FilamentUsedGMask;
static const std::string TotalFilamentUsedG;
@ -565,7 +564,6 @@ struct PrintStatistics
static const std::string TotalFilamentCost;
static const std::string TotalFilamentCostMask;
static const std::string TotalFilamentCostValueMask;
#endif // ENABLE_BINARIZED_GCODE
};
using PrintObjectPtrs = std::vector<PrintObject*>;

View File

@ -1504,13 +1504,11 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionStrings());
#if ENABLE_BINARIZED_GCODE
def = this->add("gcode_binary", coBool);
def->label = L("Export as binary G-code");
def->tooltip = L("Exports the G-code in binary format.");
def->tooltip = L("Exports G-code in binary format.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(0));
#endif // ENABLE_BINARIZED_GCODE
def = this->add("high_current_on_filament_swap", coBool);
def->label = L("High extruder current on filament swap");

View File

@ -736,9 +736,7 @@ PRINT_CONFIG_CLASS_DEFINE(
// i - case insensitive
// w - whole word
((ConfigOptionStrings, gcode_substitutions))
//#if ENABLE_BINARIZED_GCODE
((ConfigOptionBool, gcode_binary))
//#endif // ENABLE_BINARIZED_GCODE
((ConfigOptionString, layer_gcode))
((ConfigOptionFloat, max_print_speed))
((ConfigOptionFloat, max_volumetric_speed))

View File

@ -58,13 +58,7 @@
// Enable OpenGL debug messages using debug context
#define ENABLE_OPENGL_DEBUG_OPTION (1 && ENABLE_GL_CORE_PROFILE)
//====================
// 2.6.2.alpha1 techs
//====================
#define ENABLE_2_6_2_ALPHA1 1
// Enable export of binarized gcode
#define ENABLE_BINARIZED_GCODE (1 && ENABLE_2_6_2_ALPHA1)
#define ENABLE_BINARIZED_GCODE_DEBUG_WINDOW (1 && ENABLE_BINARIZED_GCODE)
// Enable imgui dialog which allows to set the parameters used to export binarized gcode
#define ENABLE_BINARIZED_GCODE_DEBUG_WINDOW 1
#endif // _prusaslicer_technologies_h_

View File

@ -368,38 +368,13 @@ void GCodeViewer::SequentialView::Marker::render()
ImGui::PopStyleVar();
}
#if ENABLE_BINARIZED_GCODE
void GCodeViewer::SequentialView::GCodeWindow::load_gcode(const GCodeProcessorResult& gcode_result)
{
m_filename = gcode_result.filename;
m_is_binary_file = gcode_result.is_binary_file;
m_lines_ends = gcode_result.lines_ends;
}
#else
void GCodeViewer::SequentialView::GCodeWindow::load_gcode(const std::string& filename, const std::vector<size_t>& lines_ends)
{
assert(!m_file.is_open());
if (m_file.is_open())
return;
m_filename = filename;
m_lines_ends = lines_ends;
m_selected_line_id = 0;
m_last_lines_size = 0;
try
{
m_file.open(boost::filesystem::path(m_filename));
}
catch (...)
{
BOOST_LOG_TRIVIAL(error) << "Unable to map file " << m_filename << ". Cannot show G-code window.";
reset();
}
}
#endif // ENABLE_BINARIZED_GCODE
#if ENABLE_BINARIZED_GCODE
void GCodeViewer::SequentialView::GCodeWindow::add_gcode_line_to_lines_cache(const std::string& src)
{
std::string command;
@ -681,175 +656,6 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s
imgui.set_requires_extra_frame();
}
}
#else
void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, uint64_t curr_line_id) const
{
auto update_lines = [this](uint64_t start_id, uint64_t end_id) {
std::vector<Line> ret;
ret.reserve(end_id - start_id + 1);
for (uint64_t id = start_id; id <= end_id; ++id) {
// read line from file
const size_t start = id == 1 ? 0 : m_lines_ends[id - 2];
const size_t len = m_lines_ends[id - 1] - start;
std::string gline(m_file.data() + start, len);
std::string command;
std::string parameters;
std::string comment;
// extract comment
std::vector<std::string> tokens;
boost::split(tokens, gline, boost::is_any_of(";"), boost::token_compress_on);
command = tokens.front();
if (tokens.size() > 1)
comment = ";" + tokens.back();
// extract gcode command and parameters
if (!command.empty()) {
boost::split(tokens, command, boost::is_any_of(" "), boost::token_compress_on);
command = tokens.front();
if (tokens.size() > 1) {
for (size_t i = 1; i < tokens.size(); ++i) {
parameters += " " + tokens[i];
}
}
}
ret.push_back({ command, parameters, comment });
}
return ret;
};
static const ImVec4 LINE_NUMBER_COLOR = ImGuiWrapper::COL_ORANGE_LIGHT;
static const ImVec4 SELECTION_RECT_COLOR = ImGuiWrapper::COL_ORANGE_DARK;
static const ImVec4 COMMAND_COLOR = { 0.8f, 0.8f, 0.0f, 1.0f };
static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f };
static const ImVec4 ELLIPSIS_COLOR = { 0.0f, 0.7f, 0.0f, 1.0f };
if (!m_visible || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
return;
// window height
const float wnd_height = bottom - top;
// number of visible lines
const float text_height = ImGui::CalcTextSize("0").y;
const ImGuiStyle& style = ImGui::GetStyle();
const uint64_t lines_count = static_cast<uint64_t>((wnd_height - 2.0f * style.WindowPadding.y + style.ItemSpacing.y) / (text_height + style.ItemSpacing.y));
if (lines_count == 0)
return;
// visible range
const uint64_t half_lines_count = lines_count / 2;
uint64_t start_id = (curr_line_id >= half_lines_count) ? curr_line_id - half_lines_count : 0;
uint64_t end_id = start_id + lines_count - 1;
if (end_id >= static_cast<uint64_t>(m_lines_ends.size())) {
end_id = static_cast<uint64_t>(m_lines_ends.size()) - 1;
start_id = end_id - lines_count + 1;
}
// updates list of lines to show, if needed
if (m_selected_line_id != curr_line_id || m_last_lines_size != end_id - start_id + 1) {
try
{
*const_cast<std::vector<Line>*>(&m_lines) = update_lines(start_id, end_id);
}
catch (...)
{
BOOST_LOG_TRIVIAL(error) << "Error while loading from file " << m_filename << ". Cannot show G-code window.";
return;
}
*const_cast<uint64_t*>(&m_selected_line_id) = curr_line_id;
*const_cast<size_t*>(&m_last_lines_size) = m_lines.size();
}
// line number's column width
const float id_width = ImGui::CalcTextSize(std::to_string(end_id).c_str()).x;
ImGuiWrapper& imgui = *wxGetApp().imgui();
auto add_item_to_line = [&imgui](const std::string& txt, const ImVec4& color, float spacing, size_t& current_length) {
static const size_t LENGTH_THRESHOLD = 60;
if (txt.empty())
return false;
std::string out_text = txt;
bool reduced = false;
if (current_length + out_text.length() > LENGTH_THRESHOLD) {
out_text = out_text.substr(0, LENGTH_THRESHOLD - current_length);
reduced = true;
}
current_length += out_text.length();
ImGui::SameLine(0.0f, spacing);
ImGui::PushStyleColor(ImGuiCol_Text, color);
imgui.text(out_text);
ImGui::PopStyleColor();
if (reduced) {
ImGui::SameLine(0.0f, 0.0f);
ImGui::PushStyleColor(ImGuiCol_Text, ELLIPSIS_COLOR);
imgui.text("...");
ImGui::PopStyleColor();
}
return reduced;
};
imgui.set_next_window_pos(0.0f, top, ImGuiCond_Always, 0.0f, 0.0f);
imgui.set_next_window_size(0.0f, wnd_height, ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::SetNextWindowBgAlpha(0.6f);
imgui.begin(std::string("G-code"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
// center the text in the window by pushing down the first line
const float f_lines_count = static_cast<float>(lines_count);
ImGui::SetCursorPosY(0.5f * (wnd_height - f_lines_count * text_height - (f_lines_count - 1.0f) * style.ItemSpacing.y));
// render text lines
for (uint64_t id = start_id; id <= end_id; ++id) {
const Line& line = m_lines[id - start_id];
// rect around the current selected line
if (id == curr_line_id) {
const float pos_y = ImGui::GetCursorScreenPos().y;
const float half_ItemSpacing_y = 0.5f * style.ItemSpacing.y;
const float half_padding_x = 0.5f * style.WindowPadding.x;
ImGui::GetWindowDrawList()->AddRect({ half_padding_x, pos_y - half_ItemSpacing_y },
{ ImGui::GetCurrentWindow()->Size.x - half_padding_x, pos_y + text_height + half_ItemSpacing_y },
ImGui::GetColorU32(SELECTION_RECT_COLOR));
}
const std::string id_str = std::to_string(id);
// spacer to right align text
ImGui::Dummy({ id_width - ImGui::CalcTextSize(id_str.c_str()).x, text_height });
size_t line_length = 0;
// render line number
bool stop_adding = add_item_to_line(id_str, LINE_NUMBER_COLOR, 0.0f, line_length);
if (!stop_adding && !line.command.empty())
// render command
stop_adding = add_item_to_line(line.command, COMMAND_COLOR, -1.0f, line_length);
if (!stop_adding && !line.parameters.empty())
// render parameters
stop_adding = add_item_to_line(line.parameters, PARAMETERS_COLOR, 0.0f, line_length);
if (!stop_adding && !line.comment.empty())
// render comment
stop_adding = add_item_to_line(line.comment, COMMENT_COLOR, line.command.empty() ? -1.0f : 0.0f, line_length);
}
imgui.end();
ImGui::PopStyleVar();
}
void GCodeViewer::SequentialView::GCodeWindow::stop_mapping_file()
{
if (m_file.is_open())
m_file.close();
}
#endif // ENABLE_BINARIZED_GCODE
void GCodeViewer::SequentialView::render(float legend_height)
{
@ -1029,11 +835,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
// release gpu memory, if used
reset();
#if ENABLE_BINARIZED_GCODE
m_sequential_view.gcode_window.load_gcode(gcode_result);
#else
m_sequential_view.gcode_window.load_gcode(gcode_result.filename, gcode_result.lines_ends);
#endif // ENABLE_BINARIZED_GCODE
if (wxGetApp().is_gcode_viewer())
m_custom_gcode_per_print_z = gcode_result.custom_gcode_per_print_z;
@ -2656,9 +2458,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
case EViewType::Temperature: { color = m_extrusions.ranges.temperature.get_color_at(path.temperature); break; }
case EViewType::LayerTimeLinear:
case EViewType::LayerTimeLogarithmic: {
#if ENABLE_BINARIZED_GCODE
if (!m_layers_times.empty() && m_layers.size() == m_layers_times.front().size()) {
#endif // ENABLE_BINARIZED_GCODE
const Path::Sub_Path& sub_path = path.sub_paths.front();
double z = static_cast<double>(sub_path.first.position.z());
const std::vector<double>& zs = m_layers.get_zs();
@ -2673,9 +2473,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
}
}
}
#if ENABLE_BINARIZED_GCODE
}
#endif // ENABLE_BINARIZED_GCODE
break;
}
case EViewType::VolumetricRate: { color = m_extrusions.ranges.volumetric_rate.get_color_at(path.volumetric_rate); break; }
@ -3945,7 +3743,6 @@ void GCodeViewer::render_legend(float& legend_height)
ImGui::PushStyleColor(ImGuiCol_FrameBg, { 0.1f, 0.1f, 0.1f, 0.8f });
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, { 0.2f, 0.2f, 0.2f, 0.8f });
#if ENABLE_BINARIZED_GCODE
std::vector<std::string> view_options;
std::vector<int> view_options_id;
if (!m_layers_times.empty() && m_layers.size() == m_layers_times.front().size()) {
@ -3965,19 +3762,6 @@ void GCodeViewer::render_legend(float& legend_height)
int view_type_id = (view_type_it == view_options_id.end()) ? 0 : std::distance(view_options_id.begin(), view_type_it);
if (imgui.combo(std::string(), view_options, view_type_id, ImGuiComboFlags_HeightLargest, 0.0f, -1.0f))
view_type = view_options_id[view_type_id];
#else
imgui.combo(std::string(), { _u8L("Feature type"),
_u8L("Height (mm)"),
_u8L("Width (mm)"),
_u8L("Speed (mm/s)"),
_u8L("Fan speed (%)"),
_u8L("Temperature (°C)"),
_u8L("Volumetric flow rate (mm³/s)"),
_u8L("Layer time (linear)"),
_u8L("Layer time (logarithmic)"),
_u8L("Tool"),
_u8L("Color Print") }, view_type, ImGuiComboFlags_HeightLargest, 0.0f, -1.0f);
#endif // ENABLE_BINARIZED_GCODE
ImGui::PopStyleColor(2);
if (old_view_type != view_type) {

View File

@ -12,10 +12,6 @@
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "GLModel.hpp"
#if !ENABLE_BINARIZED_GCODE
#include <boost/iostreams/device/mapped_file.hpp>
#endif // !ENABLE_BINARIZED_GCODE
#include <cstdint>
#include <float.h>
#include <set>
@ -681,7 +677,6 @@ public:
void render();
};
#if ENABLE_BINARIZED_GCODE
class GCodeWindow
{
struct Line
@ -728,43 +723,6 @@ public:
private:
void add_gcode_line_to_lines_cache(const std::string& src);
};
#else
class GCodeWindow
{
struct Line
{
std::string command;
std::string parameters;
std::string comment;
};
bool m_visible{ true };
uint64_t m_selected_line_id{ 0 };
size_t m_last_lines_size{ 0 };
std::string m_filename;
boost::iostreams::mapped_file_source m_file;
// map for accessing data in file by line number
std::vector<size_t> m_lines_ends;
// current visible lines
std::vector<Line> m_lines;
public:
GCodeWindow() = default;
~GCodeWindow() { stop_mapping_file(); }
void load_gcode(const std::string& filename, const std::vector<size_t>& lines_ends);
void reset() {
stop_mapping_file();
m_lines_ends.clear();
m_lines.clear();
m_filename.clear();
}
void toggle_visibility() { m_visible = !m_visible; }
void render(float top, float bottom, uint64_t curr_line_id) const;
void stop_mapping_file();
};
#endif // ENABLE_BINARIZED_GCODE
struct Endpoints
{

View File

@ -1370,16 +1370,14 @@ void MainFrame::init_menubar_as_editor()
[]() {return true; }, this);
append_submenu(fileMenu, export_menu, wxID_ANY, _L("&Export"), "");
#if ENABLE_BINARIZED_GCODE
wxMenu* convert_menu = new wxMenu();
append_menu_item(convert_menu, wxID_ANY, _L("Convert ascii G-code to &binary") + dots, _L("Convert a G-code file from ascii to binary format"),
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->convert_gcode_to_binary(); }, "convert_file", nullptr,
[this]() { return true; }, this);
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->convert_gcode_to_binary(); }, "convert_file", nullptr,
[this]() { return true; }, this);
append_menu_item(convert_menu, wxID_ANY, _L("Convert binary G-code to &ascii") + dots, _L("Convert a G-code file from binary to ascii format"),
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->convert_gcode_to_ascii(); }, "convert_file", nullptr,
[this]() { return true; }, this);
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->convert_gcode_to_ascii(); }, "convert_file", nullptr,
[this]() { return true; }, this);
append_submenu(fileMenu, convert_menu, wxID_ANY, _L("&Convert"), "");
#endif // ENABLE_BINARIZED_GCODE
append_menu_item(fileMenu, wxID_ANY, _L("Ejec&t SD Card / Flash Drive") + dots + "\tCtrl+T", _L("Eject SD card / Flash drive after the G-code was exported to it."),
[this](wxCommandEvent&) { if (m_plater) m_plater->eject_drive(); }, "eject_sd", nullptr,
@ -1653,7 +1651,6 @@ void MainFrame::init_menubar_as_gcodeviewer()
_L("Reload the plater from disk"), [this](wxCommandEvent&) { m_plater->reload_gcode_from_disk(); },
"", nullptr, [this]() { return !m_plater->get_last_loaded_gcode().empty(); }, this);
#endif // __APPLE__
#if ENABLE_BINARIZED_GCODE
fileMenu->AppendSeparator();
append_menu_item(fileMenu, wxID_ANY, _L("Convert ascii G-code to &binary") + dots, _L("Convert a G-code file from ascii to binary format"),
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->convert_gcode_to_binary(); }, "convert_file", nullptr,
@ -1661,7 +1658,6 @@ void MainFrame::init_menubar_as_gcodeviewer()
append_menu_item(fileMenu, wxID_ANY, _L("Convert binary G-code to &ascii") + dots, _L("Convert a G-code file from binary to ascii format"),
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->convert_gcode_to_ascii(); }, "convert_file", nullptr,
[this]() { return true; }, this);
#endif // ENABLE_BINARIZED_GCODE
fileMenu->AppendSeparator();
append_menu_item(fileMenu, wxID_ANY, _L("Export &Toolpaths as OBJ") + dots, _L("Export toolpaths as OBJ"),
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->export_toolpaths_to_obj(); }, "export_plater", nullptr,

View File

@ -55,9 +55,7 @@
#include <wx/popupwin.h>
#endif
#if ENABLE_BINARIZED_GCODE
#include <LibBGCode/convert/convert.hpp>
#endif // ENABLE_BINARIZED_GCODE
#include "libslic3r/libslic3r.h"
#include "libslic3r/Format/STL.hpp"
@ -5471,7 +5469,6 @@ void Plater::reload_gcode_from_disk()
load_gcode(filename);
}
#if ENABLE_BINARIZED_GCODE
void Plater::convert_gcode_to_ascii()
{
// Ask user for a gcode file name.
@ -5514,7 +5511,7 @@ void Plater::convert_gcode_to_ascii()
}
}
MessageDialog msg_dlg(this, _L("Succesfully created gcode ascii file:\n") + output_file, _L("Convert gcode file to ascii format"), wxICON_ERROR | wxOK);
MessageDialog msg_dlg(this, _L("Succesfully created gcode ascii file \n") + output_file, _L("Convert gcode file to ascii format"), wxICON_ERROR | wxOK);
msg_dlg.ShowModal();
}
@ -5561,10 +5558,9 @@ void Plater::convert_gcode_to_binary()
}
}
MessageDialog msg_dlg(this, _L("Succesfully created gcode binary file:\n") + output_file, _L("Convert gcode file to binary format"), wxICON_ERROR | wxOK);
MessageDialog msg_dlg(this, _L("Succesfully created gcode binary file \n") + output_file, _L("Convert gcode file to binary format"), wxICON_ERROR | wxOK);
msg_dlg.ShowModal();
}
#endif // ENABLE_BINARIZED_GCODE
void Plater::refresh_print()
{

View File

@ -188,10 +188,8 @@ public:
void load_gcode();
void load_gcode(const wxString& filename);
void reload_gcode_from_disk();
#if ENABLE_BINARIZED_GCODE
void convert_gcode_to_ascii();
void convert_gcode_to_binary();
#endif // ENABLE_BINARIZED_GCODE
void refresh_print();
std::vector<size_t> load_files(const std::vector<boost::filesystem::path>& input_files, bool load_model = true, bool load_config = true, bool imperial_units = false);

View File

@ -1717,9 +1717,7 @@ void TabPrint::build()
Option option = optgroup->get_option("output_filename_format");
option.opt.full_width = true;
optgroup->append_single_option_line(option);
#if ENABLE_BINARIZED_GCODE
optgroup->append_single_option_line("gcode_binary");
#endif // ENABLE_BINARIZED_GCODE
optgroup = page->new_optgroup(L("Other"));