mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-28 11:11:16 -06:00
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:
parent
afcc6bbb08
commit
8824468882
7 changed files with 45 additions and 6 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue