Improved extruder_selector for DoubleSlider

This commit is contained in:
YuSanka 2019-10-16 09:45:11 +02:00
parent 4b0fe7cba4
commit 76ec1bc7e3
9 changed files with 88 additions and 49 deletions

View file

@ -1692,15 +1692,27 @@ void GCode::process_layer(
}
// we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
if (colorprint_change && print./*extruders()*/config().nozzle_diameter.size()==1)
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
// add tag for time estimator
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
// #ys_FIXME_COLOR
// gcode += "M600\n";
gcode += custom_code + "\n";
// #ys_FIXME_COLOR
// if (colorprint_change && print./*extruders()*/config().nozzle_diameter.size()==1)
// {
// // add tag for analyzer
// gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
// // add tag for time estimator
// gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
//
// gcode += "M600\n";
// }
if (colorprint_change) {
if (print.config().nozzle_diameter.size() == 1)
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
// add tag for time estimator
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
if (custom_code == "tool_change")
custom_code = "M600";
gcode += custom_code + "\n";
}
}

View file

@ -586,14 +586,15 @@ std::string Model::propose_export_file_name_and_path(const std::string &new_exte
return boost::filesystem::path(this->propose_export_file_name_and_path()).replace_extension(new_extension).string();
}
std::vector<std::pair<double, DynamicPrintConfig>> Model:: get_custom_tool_changes(double default_layer_height) const
std::vector<std::pair<double, DynamicPrintConfig>> Model::get_custom_tool_changes(double default_layer_height, size_t num_extruders) const
{
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes;
if (!custom_gcode_per_height.empty()) {
for (const CustomGCode& custom_gcode : custom_gcode_per_height)
if (custom_gcode.gcode == "tool_change") {
DynamicPrintConfig config;
config.set_key_value("extruder", new ConfigOptionInt(custom_gcode.extruder));
// If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders
config.set_key_value("extruder", new ConfigOptionInt(custom_gcode.extruder > num_extruders ? 0 : custom_gcode.extruder));
// For correct extruders(tools) changing, we should decrease custom_gcode.height value by one default layer height
custom_tool_changes.push_back({ custom_gcode.height - default_layer_height, config });
}

View file

@ -837,7 +837,7 @@ public:
std::string propose_export_file_name_and_path(const std::string &new_extension) const;
// from custom_gcode_per_height get just tool_change codes
std::vector<std::pair<double, DynamicPrintConfig>> get_custom_tool_changes(double default_layer_height) const;
std::vector<std::pair<double, DynamicPrintConfig>> get_custom_tool_changes(double default_layer_height, size_t num_extruders) const;
private:
explicit Model(int) : ObjectBase(-1) { assert(this->id().invalid()); };

View file

@ -834,7 +834,8 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
for (PrintObject *print_object : m_objects)
print_object_status.emplace(PrintObjectStatus(print_object));
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes = m_model.get_custom_tool_changes(m_default_object_config.layer_height);
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes =
m_model.get_custom_tool_changes(m_default_object_config.layer_height, num_extruders);
// 3) Synchronize ModelObjects & PrintObjects.
for (size_t idx_model_object = 0; idx_model_object < model.objects.size(); ++ idx_model_object) {