ENH: support custom the first layer print sequence

Change-Id: I0516948292933fe47d39fb3ae2f7e91473b45b3a
(cherry picked from commit 5bbdb28c86509d5f94b5b9c33a0f2e1b2749e94b)
(cherry picked from commit 22c6e9f1d2c6f1b86c70827c8bec65a857fe2bc5)
This commit is contained in:
zhimin.zeng 2023-08-08 10:54:07 +08:00 committed by SoftFever
parent a35264e910
commit 79a7201f52
6 changed files with 124 additions and 0 deletions

View file

@ -2766,6 +2766,56 @@ int PartPlate::load_pattern_box_data(std::string filename)
}
}
std::vector<int> PartPlate::get_first_layer_print_sequence() const
{
const ConfigOptionInts *op_print_sequence_1st = m_config.option<ConfigOptionInts>("first_layer_print_sequence");
if (op_print_sequence_1st)
return op_print_sequence_1st->values;
else
return std::vector<int>();
}
void PartPlate::set_first_layer_print_sequence(const std::vector<int>& sorted_filaments)
{
if (sorted_filaments.size() > 0) {
if (sorted_filaments.size() == 1 && sorted_filaments[0] == 0) {
m_config.erase("first_layer_print_sequence");
}
else {
ConfigOptionInts *op_print_sequence_1st = m_config.option<ConfigOptionInts>("first_layer_print_sequence");
if (op_print_sequence_1st)
op_print_sequence_1st->values = sorted_filaments;
else
m_config.set_key_value("first_layer_print_sequence", new ConfigOptionInts(sorted_filaments));
}
}
else {
m_config.erase("first_layer_print_sequence");
}
}
void PartPlate::update_first_layer_print_sequence(size_t filament_nums)
{
ConfigOptionInts * op_print_sequence_1st = m_config.option<ConfigOptionInts>("first_layer_print_sequence");
if (!op_print_sequence_1st) {
return;
}
std::vector<int> &print_sequence_1st = op_print_sequence_1st->values;
if (print_sequence_1st.size() == 0 || print_sequence_1st[0] == 0)
return;
if (print_sequence_1st.size() > filament_nums) {
print_sequence_1st.erase(std::remove_if(print_sequence_1st.begin(), print_sequence_1st.end(), [filament_nums](int n) { return n > filament_nums; }),
print_sequence_1st.end());
}
else if (print_sequence_1st.size() < filament_nums) {
for (size_t extruder_id = print_sequence_1st.size(); extruder_id < filament_nums; ++extruder_id) {
print_sequence_1st.push_back(extruder_id + 1);
}
}
}
void PartPlate::print() const
{
unsigned int count=0;

View file

@ -442,6 +442,10 @@ public:
//load pattern box data from file
int load_pattern_box_data(std::string filename);
std::vector<int> get_first_layer_print_sequence() const;
void set_first_layer_print_sequence(const std::vector<int> &sorted_filaments);
void update_first_layer_print_sequence(size_t filament_nums);
void print() const;
friend class cereal::access;

View file

@ -10918,6 +10918,12 @@ void Plater::on_filaments_change(size_t num_filaments)
sidebar().on_filaments_change(num_filaments);
sidebar().obj_list()->update_objects_list_filament_column(num_filaments);
Slic3r::GUI::PartPlateList &plate_list = get_partplate_list();
for (int i = 0; i < plate_list.get_plate_count(); ++i) {
PartPlate* part_plate = plate_list.get_plate(i);
part_plate->update_first_layer_print_sequence(num_filaments);
}
for (ModelObject* mo : wxGetApp().model().objects) {
for (ModelVolume* mv : mo->volumes) {
mv->update_extruder_count(num_filaments);