mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-17 09:23:05 +00:00
Use placeholder STL to create needed layers
This commit is contained in:
@@ -1452,7 +1452,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
// change_layer() in turn increments the progress bar status.
|
||||
m_layer_count = 0;
|
||||
if (print.calib_params().mode == CalibMode::Calib_PA_Pattern) {
|
||||
m_layer_count = CalibPressureAdvancePattern(this).num_layers();
|
||||
// m_layer_count = CalibPressureAdvancePattern(this).num_layers();
|
||||
} else if (print.config().print_sequence == PrintSequence::ByObject) {
|
||||
// Add each of the object's layers separately.
|
||||
for (auto object : print.objects()) {
|
||||
@@ -1871,7 +1871,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true;
|
||||
|
||||
// SoftFever: calib
|
||||
if (print.calib_params().mode == CalibMode::Calib_PA_Line || print.calib_params().mode == CalibMode::Calib_PA_Pattern) {
|
||||
if (print.calib_params().mode == CalibMode::Calib_PA_Line) {
|
||||
std::string gcode;
|
||||
if ((m_config.default_acceleration.value > 0 && m_config.outer_wall_acceleration.value > 0)) {
|
||||
gcode += m_writer.set_acceleration((unsigned int)floor(m_config.outer_wall_acceleration.value + 0.5));
|
||||
@@ -1884,7 +1884,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
|
||||
auto params = print.calib_params();
|
||||
|
||||
if (print.calib_params().mode == CalibMode::Calib_PA_Line) {
|
||||
// if (print.calib_params().mode == CalibMode::Calib_PA_Line) {
|
||||
CalibPressureAdvanceLine pa_test(this);
|
||||
|
||||
double filament_max_volumetric_speed = m_config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(initial_extruder_id);
|
||||
@@ -1896,69 +1896,69 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
pa_test.draw_numbers() = print.calib_params().print_numbers;
|
||||
|
||||
gcode += pa_test.generate_test(params.start, params.step, std::llround(std::ceil((params.end - params.start) / params.step)));
|
||||
} else if (print.calib_params().mode == CalibMode::Calib_PA_Pattern) {
|
||||
CalibPressureAdvancePattern pa_test(this);
|
||||
std::vector<std::string> gcode_layers = pa_test.generate_test(params.start, params.end, params.step);
|
||||
// } else if (print.calib_params().mode == CalibMode::Calib_PA_Pattern) {
|
||||
// CalibPressureAdvancePattern pa_test(this);
|
||||
// std::vector<std::string> gcode_layers = pa_test.generate_test(params.start, params.end, params.step);
|
||||
|
||||
m_max_layer_z = pa_test.max_layer_z();
|
||||
coordf_t print_z;
|
||||
bool first_layer;
|
||||
// m_max_layer_z = pa_test.max_layer_z();
|
||||
// coordf_t print_z;
|
||||
// bool first_layer;
|
||||
|
||||
for (auto i = 0; i < gcode_layers.size(); ++i) {
|
||||
m_nominal_z = pa_test.layer_z()[i];
|
||||
print_z = m_nominal_z;
|
||||
// for (auto i = 0; i < gcode_layers.size(); ++i) {
|
||||
// m_nominal_z = pa_test.layer_z()[i];
|
||||
// print_z = m_nominal_z;
|
||||
|
||||
first_layer = (i == 0);
|
||||
m_writer.set_is_first_layer(first_layer);
|
||||
// first_layer = (i == 0);
|
||||
// m_writer.set_is_first_layer(first_layer);
|
||||
|
||||
// add tag for processor
|
||||
gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Layer_Change) + "\n";
|
||||
// export layer z
|
||||
char buf[64];
|
||||
sprintf(buf, print.is_BBL_printer() ? "; Z_HEIGHT: %g\n" : ";Z:%g\n", print_z);
|
||||
gcode += buf;
|
||||
// export layer height
|
||||
float height = first_layer ? static_cast<float>(print_z) : static_cast<float>(print_z) - m_last_layer_z;
|
||||
sprintf(buf, ";%s%g\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Height).c_str(), height);
|
||||
gcode += buf;
|
||||
// update caches
|
||||
m_last_layer_z = static_cast<float>(print_z);
|
||||
m_max_layer_z = std::max(m_max_layer_z, m_last_layer_z);
|
||||
m_last_height = height;
|
||||
// // add tag for processor
|
||||
// gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Layer_Change) + "\n";
|
||||
// // export layer z
|
||||
// char buf[64];
|
||||
// sprintf(buf, print.is_BBL_printer() ? "; Z_HEIGHT: %g\n" : ";Z:%g\n", print_z);
|
||||
// gcode += buf;
|
||||
// // export layer height
|
||||
// float height = first_layer ? static_cast<float>(print_z) : static_cast<float>(print_z) - m_last_layer_z;
|
||||
// sprintf(buf, ";%s%g\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Height).c_str(), height);
|
||||
// gcode += buf;
|
||||
// // update caches
|
||||
// m_last_layer_z = static_cast<float>(print_z);
|
||||
// m_max_layer_z = std::max(m_max_layer_z, m_last_layer_z);
|
||||
// m_last_height = height;
|
||||
|
||||
if (! print.config().before_layer_change_gcode.value.empty()) {
|
||||
DynamicConfig config;
|
||||
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index + 1));
|
||||
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||
gcode += this->placeholder_parser_process(
|
||||
"before_layer_change_gcode",
|
||||
print.config().before_layer_change_gcode.value,
|
||||
m_writer.extruder()->id(),
|
||||
&config
|
||||
) + "\n";
|
||||
}
|
||||
// if (! print.config().before_layer_change_gcode.value.empty()) {
|
||||
// DynamicConfig config;
|
||||
// config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index + 1));
|
||||
// config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||
// config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||
// gcode += this->placeholder_parser_process(
|
||||
// "before_layer_change_gcode",
|
||||
// print.config().before_layer_change_gcode.value,
|
||||
// m_writer.extruder()->id(),
|
||||
// &config
|
||||
// ) + "\n";
|
||||
// }
|
||||
|
||||
gcode += m_writer.update_progress(++ m_layer_index, m_layer_count);
|
||||
// gcode += m_writer.update_progress(++ m_layer_index, m_layer_count);
|
||||
|
||||
if (! print.config().layer_change_gcode.value.empty()) {
|
||||
DynamicConfig config;
|
||||
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
||||
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||
// if (! print.config().layer_change_gcode.value.empty()) {
|
||||
// DynamicConfig config;
|
||||
// config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
||||
// config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||
|
||||
gcode += this->placeholder_parser_process(
|
||||
"layer_change_gcode",
|
||||
print.config().layer_change_gcode.value,
|
||||
m_writer.extruder()->id(),
|
||||
&config
|
||||
) + "\n";
|
||||
// gcode += this->placeholder_parser_process(
|
||||
// "layer_change_gcode",
|
||||
// print.config().layer_change_gcode.value,
|
||||
// m_writer.extruder()->id(),
|
||||
// &config
|
||||
// ) + "\n";
|
||||
|
||||
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||
}
|
||||
// config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||
// }
|
||||
|
||||
gcode += gcode_layers[i];
|
||||
}
|
||||
}
|
||||
// gcode += gcode_layers[i];
|
||||
// }
|
||||
// }
|
||||
|
||||
file.write(gcode);
|
||||
} else {
|
||||
|
||||
@@ -318,7 +318,9 @@ std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double star
|
||||
|
||||
std::vector<std::string> CalibPressureAdvancePattern::generate_test(double start_pa, double end_pa, double step_pa)
|
||||
{
|
||||
BoundingBoxf bed_ext = get_extents(mp_gcodegen->config().printable_area.values);
|
||||
BoundingBoxf bed_ext = get_extents(
|
||||
m_printer_config->opt<ConfigOptionPoints>("printable_area")->values
|
||||
);
|
||||
|
||||
if (is_delta()) {
|
||||
delta_scale_bed_ext(bed_ext);
|
||||
@@ -369,8 +371,8 @@ std::vector<double> CalibPressureAdvancePattern::layer_z() {
|
||||
}
|
||||
|
||||
CalibPressureAdvancePattern::PatternSettings::PatternSettings() {
|
||||
GCode gc;
|
||||
const CalibPressureAdvancePattern cpap(&gc);
|
||||
DynamicPrintConfig a, b, c;
|
||||
const CalibPressureAdvancePattern cpap(&a, &b, &c);
|
||||
|
||||
anchor_line_width = cpap.line_width_anchor();
|
||||
anchor_perimeters = cpap.m_anchor_perimeters;
|
||||
|
||||
@@ -28,11 +28,17 @@ struct Calib_Params
|
||||
|
||||
class CalibPressureAdvance {
|
||||
protected:
|
||||
CalibPressureAdvance() :
|
||||
m_draw_digit_mode(DrawDigitMode::Left_To_Right),
|
||||
m_digit_segment_len(2),
|
||||
m_digit_gap_len(1),
|
||||
m_max_number_len(5)
|
||||
{ };
|
||||
CalibPressureAdvance(GCode* gcodegen);
|
||||
~CalibPressureAdvance() { };
|
||||
|
||||
enum class DrawDigitMode {
|
||||
Left_To_Right = 0,
|
||||
Left_To_Right,
|
||||
Bottom_To_Top
|
||||
};
|
||||
|
||||
@@ -115,8 +121,14 @@ private:
|
||||
|
||||
class CalibPressureAdvancePattern : public CalibPressureAdvance {
|
||||
public:
|
||||
CalibPressureAdvancePattern(GCode* gcodegen) :
|
||||
CalibPressureAdvance(gcodegen),
|
||||
CalibPressureAdvancePattern(
|
||||
DynamicPrintConfig* printer_config,
|
||||
DynamicPrintConfig* print_config,
|
||||
DynamicPrintConfig* filament_config
|
||||
) :
|
||||
m_printer_config(printer_config),
|
||||
m_print_config(print_config),
|
||||
m_filament_config(filament_config),
|
||||
|
||||
m_line_ratio(112.5),
|
||||
m_num_layers(4),
|
||||
@@ -151,10 +163,12 @@ public:
|
||||
double step_pa = 0.005
|
||||
);
|
||||
|
||||
int& num_layers() { return m_num_layers; };
|
||||
int num_layers() const { return m_num_layers; };
|
||||
std::vector<double> layer_z();
|
||||
double& max_layer_z() { return m_max_layer_z; }
|
||||
double max_layer_z() const { return m_max_layer_z; }
|
||||
|
||||
double first_layer_height() const { return m_height_first_layer; };
|
||||
double layer_height() const { return m_layer_height; };
|
||||
private:
|
||||
struct PatternCalc {
|
||||
PatternCalc(
|
||||
@@ -289,6 +303,10 @@ private:
|
||||
|
||||
std::vector<std::string> print_pa_pattern(PatternCalc& calc);
|
||||
|
||||
DynamicPrintConfig* m_printer_config;
|
||||
DynamicPrintConfig* m_print_config;
|
||||
DynamicPrintConfig* m_filament_config;
|
||||
|
||||
double m_line_ratio;
|
||||
int m_num_layers;
|
||||
double m_height_first_layer;
|
||||
|
||||
@@ -8105,13 +8105,17 @@ void Plater::calib_pa(const Calib_Params& params) {
|
||||
new_project(false, false, calib_pa_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
|
||||
if (params.mode == CalibMode::Calib_PA_Line || params.mode == CalibMode::Calib_PA_Pattern) {
|
||||
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config;
|
||||
|
||||
if (params.mode == CalibMode::Calib_PA_Line) {
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/PressureAdvance/pressure_advance_test.stl");
|
||||
} else if (params.mode == CalibMode::Calib_PA_Pattern) {
|
||||
_prep_calib_pa_pattern(params, printer_config, print_config, filament_config);
|
||||
} else {
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/PressureAdvance/tower_with_seam.stl");
|
||||
auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config;
|
||||
|
||||
filament_config->set_key_value("slow_down_layer_time", new ConfigOptionFloats{ 1.0f });
|
||||
print_config->set_key_value("default_jerk", new ConfigOptionFloat(1.0f));
|
||||
print_config->set_key_value("outer_wall_jerk", new ConfigOptionFloat(1.0f));
|
||||
@@ -8134,7 +8138,9 @@ void Plater::calib_pa(const Calib_Params& params) {
|
||||
std::array<Vec3d, 4> plane_pts = get_cut_plane(obj_bb, new_height);
|
||||
cut(0, 0, plane_pts, ModelObjectCutAttribute::KeepLower);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.mode == CalibMode::Calib_PA_Pattern || params.mode == CalibMode::Calib_PA_Tower) {
|
||||
// automatic selection of added objects
|
||||
// update printable state for new volumes on canvas3D
|
||||
wxGetApp().plater()->canvas3D()->update_instance_printable_state_for_objects({0});
|
||||
@@ -8153,6 +8159,38 @@ void Plater::calib_pa(const Calib_Params& params) {
|
||||
p->background_process.fff_print()->set_calib_params(params);
|
||||
}
|
||||
|
||||
void Plater::_prep_calib_pa_pattern(const Calib_Params& params, DynamicPrintConfig* printer_config, DynamicPrintConfig* print_config, DynamicPrintConfig* filament_config) {
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/PressureAdvance/pressure_advance_test.stl");
|
||||
orient();
|
||||
|
||||
CalibPressureAdvancePattern pa_pattern(printer_config, print_config, filament_config);
|
||||
|
||||
double first_layer_height = pa_pattern.first_layer_height();
|
||||
double layer_height = pa_pattern.layer_height();
|
||||
|
||||
auto new_height = pa_pattern.max_layer_z();
|
||||
for (auto i = 0; i < model().objects.size(); ++i) {
|
||||
auto _obj = model().objects[i];
|
||||
|
||||
auto original_height = _obj->get_max_z();
|
||||
auto zscale = new_height / original_height;
|
||||
_obj->scale(1, 1, zscale);
|
||||
|
||||
changed_object(i);
|
||||
}
|
||||
|
||||
print_config->set_key_value("layer_height", new ConfigOptionFloat(layer_height));
|
||||
print_config->set_key_value("initial_layer_print_height", new ConfigOptionFloat(first_layer_height));
|
||||
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->update_dirty();
|
||||
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->reload_config();
|
||||
}
|
||||
|
||||
void Plater::calib_flowrate(int pass) {
|
||||
if (pass != 1 && pass != 2)
|
||||
return;
|
||||
@@ -8240,7 +8278,6 @@ void Plater::calib_flowrate(int pass) {
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->reload_config();
|
||||
|
||||
}
|
||||
|
||||
void Plater::calib_temp(const Calib_Params& params) {
|
||||
|
||||
@@ -234,6 +234,7 @@ public:
|
||||
|
||||
// SoftFever
|
||||
void calib_pa(const Calib_Params& params);
|
||||
void _prep_calib_pa_pattern(const Calib_Params& params, DynamicPrintConfig* printer_config, DynamicPrintConfig* print_config, DynamicPrintConfig* filament_profile);
|
||||
void calib_flowrate(int pass);
|
||||
void calib_temp(const Calib_Params& params);
|
||||
void calib_max_vol_speed(const Calib_Params& params);
|
||||
|
||||
Reference in New Issue
Block a user