From c82d346c1a5b119aeb8c5176f832ccf19e7dbd9f Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 31 Jan 2019 15:09:16 +0100 Subject: [PATCH] Fixed a bug in initialization of some StaticPrintConfig derived classes. Merged implementation of support for "Octoprint-Cancelobject" #972 thanks @supermerill --- src/libslic3r/GCode.cpp | 6 +++++- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 9 +++++++++ src/libslic3r/PrintConfig.hpp | 6 ++++-- src/slic3r/GUI/Preset.cpp | 4 ++-- src/slic3r/GUI/Tab.cpp | 1 + 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 66698d4ad..ec9392ec4 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1622,6 +1622,8 @@ void GCode::process_layer( unsigned int copy_id = 0; for (const Point © : copies) { + if (this->config().gcode_label_objects) + gcode += std::string("; printing object ") + print_object->model_object()->name + " id:" + std::to_string(layer_id) + " copy " + std::to_string(copy_id) + "\n"; // When starting a new object, use the external motion planner for the first travel move. std::pair this_object_copy(print_object, copy); if (m_last_obj_copy != this_object_copy) @@ -1646,7 +1648,9 @@ void GCode::process_layer( gcode += this->extrude_infill(print,by_region_specific); } } - ++copy_id; + if (this->config().gcode_label_objects) + gcode += std::string("; stop printing object ") + print_object->model_object()->name + " id:" + std::to_string(layer_id) + " copy " + std::to_string(copy_id) + "\n"; + ++ copy_id; } } } diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 3efb18599..42fda92fe 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -127,6 +127,7 @@ bool Print::invalidate_state_by_config_options(const std::vectormode = comExpert; def->default_value = new ConfigOptionEnum(gcfRepRap); + def = this->add("gcode_label_objects", coBool); + def->label = "Label objects"; + def->tooltip = "Enable this to add comments into the G-Code labeling print moves with what object they belong to," + " which is useful for the Octoprint CancelObject plugin. This settings is NOT compatible with " + "Single Extruder Multi Material setup and Wipe into Object / Wipe into Infill."; + def->cli = "gcode-label-objects!"; + def->mode = comAdvanced; + def->default_value = new ConfigOptionBool(0); + def = this->add("high_current_on_filament_swap", coBool); def->label = L("High extruder current on filament swap"); def->tooltip = L("It may be beneficial to increase the extruder motor current during the filament exchange" diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 1b218a192..6b9e68eef 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -619,6 +619,7 @@ public: ConfigOptionStrings filament_ramming_parameters; ConfigOptionBool gcode_comments; ConfigOptionEnum gcode_flavor; + ConfigOptionBool gcode_label_objects; ConfigOptionString layer_gcode; ConfigOptionFloat max_print_speed; ConfigOptionFloat max_volumetric_speed; @@ -690,6 +691,7 @@ protected: OPT_PTR(filament_ramming_parameters); OPT_PTR(gcode_comments); OPT_PTR(gcode_flavor); + OPT_PTR(gcode_label_objects); OPT_PTR(layer_gcode); OPT_PTR(max_print_speed); OPT_PTR(max_volumetric_speed); @@ -730,7 +732,7 @@ protected: class PrintConfig : public MachineEnvelopeConfig, public GCodeConfig { STATIC_PRINT_CONFIG_CACHE_DERIVED(PrintConfig) - PrintConfig() : GCodeConfig(0) { initialize_cache(); *this = s_cache_PrintConfig.defaults(); } + PrintConfig() : MachineEnvelopeConfig(0), GCodeConfig(0) { initialize_cache(); *this = s_cache_PrintConfig.defaults(); } public: double min_object_distance() const; static double min_object_distance(const ConfigBase *config); @@ -808,7 +810,7 @@ public: ConfigOptionFloat exp_time_first; protected: - PrintConfig(int) : GCodeConfig(1) {} + PrintConfig(int) : MachineEnvelopeConfig(1), GCodeConfig(1) {} void initialize(StaticCacheBase &cache, const char *base_ptr) { this->MachineEnvelopeConfig::initialize(cache, base_ptr); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index ef1caf035..53650481c 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -336,7 +336,7 @@ const std::vector& Preset::print_options() "support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers", "support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance", "support_material_buildplate_only", "dont_support_bridges", "notes", "complete_objects", "extruder_clearance_radius", - "extruder_clearance_height", "gcode_comments", "output_filename_format", "post_process", "perimeter_extruder", + "extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "perimeter_extruder", "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", @@ -1163,7 +1163,7 @@ std::string PresetCollection::name() const case Preset::TYPE_PRINT: return L("print"); case Preset::TYPE_FILAMENT: return L("filament"); case Preset::TYPE_SLA_PRINT: return L("SLA print"); - case Preset::TYPE_SLA_MATERIAL: return L("SLA material"); + case Preset::TYPE_SLA_MATERIAL: return L("SLA material"); case Preset::TYPE_PRINTER: return L("printer"); default: return "invalid"; } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 3f76b4f78..06282cd24 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1095,6 +1095,7 @@ void TabPrint::build() optgroup = page->new_optgroup(_(L("Output file"))); optgroup->append_single_option_line("gcode_comments"); + optgroup->append_single_option_line("gcode_label_objects"); option = optgroup->get_option("output_filename_format"); option.opt.full_width = true; optgroup->append_single_option_line(option);