mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 15:35:56 +08:00
Use ModelWipeTower instead of config for wipe tower pos and rot (backend part) - SPE-2520
This commit is contained in:
parent
1f9344a5dc
commit
c41290bc07
@ -1312,7 +1312,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
|
||||
std::vector<std::pair<coordf_t, ObjectsLayerToPrint>> layers_to_print = collect_layers_to_print(print);
|
||||
// Prusa Multi-Material wipe tower.
|
||||
if (has_wipe_tower && ! layers_to_print.empty()) {
|
||||
m_wipe_tower = std::make_unique<GCode::WipeTowerIntegration>(print.config(), *print.wipe_tower_data().priming.get(), print.wipe_tower_data().tool_changes, *print.wipe_tower_data().final_purge.get());
|
||||
m_wipe_tower = std::make_unique<GCode::WipeTowerIntegration>(print.model().wipe_tower.position.cast<float>(), print.model().wipe_tower.rotation, print.config(), *print.wipe_tower_data().priming.get(), print.wipe_tower_data().tool_changes, *print.wipe_tower_data().final_purge.get());
|
||||
|
||||
// Set position for wipe tower generation.
|
||||
Vec3d new_position = this->writer().get_position();
|
||||
|
@ -151,8 +151,8 @@ BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_
|
||||
// Wipe tower extrusions are saved as if the tower was at the origin with no rotation
|
||||
// We need to get position and angle of the wipe tower to transform them to actual position.
|
||||
Transform2d trafo =
|
||||
Eigen::Translation2d(print.config().wipe_tower_x.value, print.config().wipe_tower_y.value) *
|
||||
Eigen::Rotation2Dd(Geometry::deg2rad(print.config().wipe_tower_rotation_angle.value));
|
||||
Eigen::Translation2d(print.model().wipe_tower.position.x(), print.model().wipe_tower.position.y()) *
|
||||
Eigen::Rotation2Dd(Geometry::deg2rad(print.model().wipe_tower.rotation));
|
||||
|
||||
BoundingBoxf bbox;
|
||||
for (const std::vector<WipeTower::ToolChangeResult> &tool_changes : print.wipe_tower_data().tool_changes) {
|
||||
|
@ -541,11 +541,11 @@ WipeTower::ToolChangeResult WipeTower::construct_tcr(WipeTowerWriter& writer,
|
||||
|
||||
|
||||
|
||||
WipeTower::WipeTower(const PrintConfig& config, const PrintRegionConfig& default_region_config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
|
||||
WipeTower::WipeTower(const Vec2f& pos, double rotation_deg, const PrintConfig& config, const PrintRegionConfig& default_region_config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
|
||||
m_semm(config.single_extruder_multi_material.value),
|
||||
m_wipe_tower_pos(config.wipe_tower_x, config.wipe_tower_y),
|
||||
m_wipe_tower_pos(pos),
|
||||
m_wipe_tower_width(float(config.wipe_tower_width)),
|
||||
m_wipe_tower_rotation_angle(float(config.wipe_tower_rotation_angle)),
|
||||
m_wipe_tower_rotation_angle(rotation_deg),
|
||||
m_wipe_tower_brim_width(float(config.wipe_tower_brim_width)),
|
||||
m_wipe_tower_cone_angle(float(config.wipe_tower_cone_angle)),
|
||||
m_extra_flow(float(config.wipe_tower_extra_flow/100.)),
|
||||
|
@ -139,7 +139,9 @@ public:
|
||||
// y -- y coordinates of wipe tower in mm ( left bottom corner )
|
||||
// width -- width of wipe tower in mm ( default 60 mm - leave as it is )
|
||||
// wipe_area -- space available for one toolchange in mm
|
||||
WipeTower(const PrintConfig& config,
|
||||
WipeTower(const Vec2f& position,
|
||||
double rotation_deg,
|
||||
const PrintConfig& config,
|
||||
const PrintRegionConfig& default_region_config,
|
||||
const std::vector<std::vector<float>>& wiping_matrix,
|
||||
size_t initial_tool);
|
||||
|
@ -20,14 +20,16 @@ namespace GCode {
|
||||
class WipeTowerIntegration {
|
||||
public:
|
||||
WipeTowerIntegration(
|
||||
Vec2f pos,
|
||||
double rotation,
|
||||
const PrintConfig &print_config,
|
||||
const std::vector<WipeTower::ToolChangeResult> &priming,
|
||||
const std::vector<std::vector<WipeTower::ToolChangeResult>> &tool_changes,
|
||||
const WipeTower::ToolChangeResult &final_purge) :
|
||||
m_left(/*float(print_config.wipe_tower_x.value)*/ 0.f),
|
||||
m_right(float(/*print_config.wipe_tower_x.value +*/ print_config.wipe_tower_width.value)),
|
||||
m_wipe_tower_pos(float(print_config.wipe_tower_x.value), float(print_config.wipe_tower_y.value)),
|
||||
m_wipe_tower_rotation(float(print_config.wipe_tower_rotation_angle)),
|
||||
m_left( 0.f),
|
||||
m_right(float(print_config.wipe_tower_width.value)),
|
||||
m_wipe_tower_pos(pos),
|
||||
m_wipe_tower_rotation(rotation),
|
||||
m_extruder_offsets(print_config.extruder_offset.values),
|
||||
m_priming(priming),
|
||||
m_tool_changes(tool_changes),
|
||||
|
@ -1049,8 +1049,8 @@ void Print::process()
|
||||
if (this->has_wipe_tower()) {
|
||||
// These values have to be updated here, not during wipe tower generation.
|
||||
// When the wipe tower is moved/rotated, it is not regenerated.
|
||||
m_wipe_tower_data.position = { m_config.wipe_tower_x, m_config.wipe_tower_y };
|
||||
m_wipe_tower_data.rotation_angle = m_config.wipe_tower_rotation_angle;
|
||||
m_wipe_tower_data.position = model().wipe_tower.position;
|
||||
m_wipe_tower_data.rotation_angle = model().wipe_tower.rotation;
|
||||
}
|
||||
auto conflictRes = ConflictChecker::find_inter_of_lines_in_diff_objs(objects(), m_wipe_tower_data);
|
||||
|
||||
@ -1279,8 +1279,8 @@ Points Print::first_layer_wipe_tower_corners() const
|
||||
pts.emplace_back(center + r*Vec2d(std::cos(alpha)/cone_x_scale, std::sin(alpha)));
|
||||
|
||||
for (Vec2d& pt : pts) {
|
||||
pt = Eigen::Rotation2Dd(Geometry::deg2rad(m_config.wipe_tower_rotation_angle.value)) * pt;
|
||||
pt += Vec2d(m_config.wipe_tower_x.value, m_config.wipe_tower_y.value);
|
||||
pt = Eigen::Rotation2Dd(Geometry::deg2rad(model().wipe_tower.rotation)) * pt;
|
||||
pt += model().wipe_tower.position;
|
||||
pts_scaled.emplace_back(Point(scale_(pt.x()), scale_(pt.y())));
|
||||
}
|
||||
}
|
||||
@ -1554,7 +1554,7 @@ void Print::_make_wipe_tower()
|
||||
this->throw_if_canceled();
|
||||
|
||||
// Initialize the wipe tower.
|
||||
WipeTower wipe_tower(m_config, m_default_region_config, wipe_volumes, m_wipe_tower_data.tool_ordering.first_extruder());
|
||||
WipeTower wipe_tower(model().wipe_tower.position.cast<float>(), model().wipe_tower.rotation, m_config, m_default_region_config, wipe_volumes, m_wipe_tower_data.tool_ordering.first_extruder());
|
||||
|
||||
// Set the extruder & material properties at the wipe tower object.
|
||||
for (size_t i = 0; i < m_config.nozzle_diameter.size(); ++ i)
|
||||
|
@ -1067,6 +1067,12 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
}
|
||||
}
|
||||
|
||||
// Check the position and rotation of the wipe tower.
|
||||
if (model.wipe_tower != m_model.wipe_tower)
|
||||
update_apply_status(this->invalidate_step(psSkirtBrim));
|
||||
m_model.wipe_tower.position = model.wipe_tower.position;
|
||||
m_model.wipe_tower.rotation = model.wipe_tower.rotation;
|
||||
|
||||
ModelObjectStatusDB model_object_status_db;
|
||||
|
||||
// 1) Synchronize model objects.
|
||||
|
@ -1690,8 +1690,8 @@ void GCodeViewer::load_wipetower_shell(const Print& print)
|
||||
const std::vector<std::pair<float, float>> z_and_depth_pairs = print.wipe_tower_data(extruders_count).z_and_depth_pairs;
|
||||
const float brim_width = wipe_tower_data.brim_width;
|
||||
if (depth != 0.) {
|
||||
m_shells.volumes.load_wipe_tower_preview(config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, depth, z_and_depth_pairs,
|
||||
max_z, config.wipe_tower_cone_angle, config.wipe_tower_rotation_angle, false, brim_width);
|
||||
m_shells.volumes.load_wipe_tower_preview(wxGetApp().plater()->model().wipe_tower.position.x(), wxGetApp().plater()->model().wipe_tower.position.y(), config.wipe_tower_width, depth, z_and_depth_pairs,
|
||||
max_z, config.wipe_tower_cone_angle, wxGetApp().plater()->model().wipe_tower.rotation, false, brim_width);
|
||||
GLVolume* volume = m_shells.volumes.volumes.back();
|
||||
volume->color.a(0.25f);
|
||||
volume->force_native_color = true;
|
||||
|
@ -427,8 +427,8 @@ public:
|
||||
if (wipe_tower_data.final_purge)
|
||||
m_final.emplace_back(*wipe_tower_data.final_purge.get());
|
||||
|
||||
m_angle = config.wipe_tower_rotation_angle.value / 180.0f * PI;
|
||||
m_position = Slic3r::Vec2f(config.wipe_tower_x.value, config.wipe_tower_y.value);
|
||||
m_angle = print.model().wipe_tower.rotation / 180.0f * PI;
|
||||
m_position = print.model().wipe_tower.position.cast<float>();
|
||||
m_layers_count = wipe_tower_data.tool_changes.size() + (m_priming.empty() ? 0 : 1);
|
||||
}
|
||||
|
||||
|
@ -2091,12 +2091,6 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
||||
if (full_config.has("binary_gcode")) // needed for SLA
|
||||
full_config.set("binary_gcode", bool(full_config.opt_bool("binary_gcode") & wxGetApp().app_config->get_bool("use_binary_gcode_when_supported")));
|
||||
|
||||
// Also tell the backend about the position of the wipe tower.
|
||||
// TODO: Refactor the backend and the apply function to take this from the Model.
|
||||
full_config.set("wipe_tower_x", model.wipe_tower.position.x(), true);
|
||||
full_config.set("wipe_tower_y", model.wipe_tower.position.y(), true);
|
||||
full_config.set("wipe_tower_rotation_angle", model.wipe_tower.rotation, true);
|
||||
|
||||
const Preset &selected_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
|
||||
std::string printer_model_serialized = full_config.option("printer_model")->serialize();
|
||||
std::string vendor_repo_prefix;
|
||||
|
Loading…
x
Reference in New Issue
Block a user