Added function to update of custom_gcode_per_print_z in Model from configuration

considering "colorprint_heights" option.

Changed thumb_up/down icons to better preview (feedback from #3256)

Commented some uncertain code
This commit is contained in:
YuSanka 2019-12-17 13:16:28 +01:00
parent afcc6bbb08
commit 8824468882
7 changed files with 45 additions and 6 deletions

View File

@ -4,7 +4,7 @@
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="hex_x5F_plus">
<g>
<polygon fill="#ED6B21" points="2,8 2,11 8,15 14,11 14,8 "/>
<polygon fill="#ED6B21" points="1,8 1,11 8,16 15,11 15,8 " style="stroke:white;stroke-width:1"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 482 B

View File

@ -4,7 +4,7 @@
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="hex_x5F_plus">
<g>
<polygon fill="#ED6B21" points="8,1 2,5 2,7 2,8 14,8 14,7 14,5 "/>
<polygon fill="#ED6B21" points="8,0 1,5 1,7 1,8 15,8 15,7 15,5" style="stroke:white;stroke-width:1"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 487 B

View File

@ -1124,9 +1124,11 @@ void GCode::_do_export(Print& print, FILE* file)
}
print.throw_if_canceled();
// #ys_FIXME_no_exported_codes
/*
/* To avoid change filament for non-used extruder for Multi-material,
* check model->custom_gcode_per_print_z using tool_ordering values
* */
* /
if (!m_custom_gcode_per_print_z. empty())
{
bool delete_executed = false;
@ -1155,7 +1157,7 @@ void GCode::_do_export(Print& print, FILE* file)
/* If we are there, current extruder wouldn't be used,
* so this color change is a redundant move.
* Delete this item from m_custom_gcode_per_print_z
* */
* /
it = m_custom_gcode_per_print_z.erase(it);
delete_executed = true;
}
@ -1163,7 +1165,7 @@ void GCode::_do_export(Print& print, FILE* file)
if (delete_executed)
model->custom_gcode_per_print_z = m_custom_gcode_per_print_z;
}
*/
m_cooling_buffer->set_current_extruder(initial_extruder_id);

View File

@ -19,6 +19,7 @@
#include "SVG.hpp"
#include <Eigen/Dense>
#include "GCodeWriter.hpp"
#include "GCode/PreviewData.hpp"
namespace Slic3r {
@ -125,6 +126,8 @@ Model Model::read_from_file(const std::string& input_file, DynamicPrintConfig* c
if (add_default_instances)
model.add_default_instances();
update_custom_gcode_per_print_z_from_config(model.custom_gcode_per_print_z, config);
return model;
}
@ -160,6 +163,8 @@ Model Model::read_from_archive(const std::string& input_file, DynamicPrintConfig
if (add_default_instances)
model.add_default_instances();
update_custom_gcode_per_print_z_from_config(model.custom_gcode_per_print_z, config);
return model;
}
@ -1933,6 +1938,30 @@ extern bool model_has_advanced_features(const Model &model)
return false;
}
extern void update_custom_gcode_per_print_z_from_config(std::vector<Model::CustomGCode>& custom_gcode_per_print_z, DynamicPrintConfig* config)
{
if (!config->has("colorprint_heights"))
return;
const std::vector<std::string>& colors = GCodePreviewData::ColorPrintColors();
const auto& colorprint_values = config->option<ConfigOptionFloats>("colorprint_heights")->values;
if (!colorprint_values.empty())
{
custom_gcode_per_print_z.clear();
custom_gcode_per_print_z.reserve(colorprint_values.size());
int i = 0;
for (auto val : colorprint_values)
custom_gcode_per_print_z.emplace_back(Model::CustomGCode{ val, ColorChangeCode, 1, colors[(++i)%7] });
}
/* There is one and only place this configuration option is used now.
* It wouldn't be used in the future, so erase it.
* */
config->erase("colorprint_heights");
}
#ifndef NDEBUG
// Verify whether the IDs of Model / ModelObject / ModelVolume / ModelInstance / ModelMaterial are valid and unique.
void check_model_ids_validity(const Model &model)

View File

@ -874,6 +874,10 @@ extern bool model_volume_list_changed(const ModelObject &model_object_old, const
extern bool model_has_multi_part_objects(const Model &model);
// If the model has advanced features, then it cannot be processed in simple mode.
extern bool model_has_advanced_features(const Model &model);
/* If loaded configuration has a "colorprint_heights" option (if it was imported from older Slicer),
* then model.custom_gcode_per_print_z should be updated considering this option
* */
extern void update_custom_gcode_per_print_z_from_config(std::vector<Model::CustomGCode>& custom_gcode_per_print_z, DynamicPrintConfig* config);
#ifndef NDEBUG
// Verify whether the IDs of Model / ModelObject / ModelVolume / ModelInstance / ModelMaterial are valid and unique.

View File

@ -94,12 +94,13 @@ void BackgroundSlicingProcess::process_fff()
m_fff_print->export_gcode(m_temp_output_path, m_gcode_preview_data);
#endif // ENABLE_THUMBNAIL_GENERATOR
/* #ys_FIXME_no_exported_codes
if (m_fff_print->model().custom_gcode_per_print_z != GUI::wxGetApp().model().custom_gcode_per_print_z) {
GUI::wxGetApp().model().custom_gcode_per_print_z = m_fff_print->model().custom_gcode_per_print_z;
// #ys_FIXME : controll text
GUI::show_info(nullptr, _(L("To except of redundant tool manipulation, \n"
"Color change(s) for unused extruder(s) was(were) deleted")), _(L("Info")));
}
*/
if (this->set_step_started(bspsGCodeFinalize)) {
if (! m_export_path.empty()) {

View File

@ -869,6 +869,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
}
// 4) Load the project config values (the per extruder wipe matrix etc).
this->project_config.apply_only(config, s_project_options);
update_custom_gcode_per_print_z_from_config(GUI::wxGetApp().plater()->model().custom_gcode_per_print_z, &this->project_config);
break;
}
case ptSLA: