mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 07:41:06 +00:00
GCode: hold the writer by value again
Belt printing turned GCode::m_writer into a unique_ptr so BeltGCode could swap in a freshly built writer carrying the belt kinematics. Nothing subclasses GCodeWriter: the machine mapping lives in its MachineKinematics, which set_kinematics() installs on an existing writer. A GCode is built for every export and the only state on the writer when init_belt_writer() runs is the plate offset, which the swap had to copy across by hand. Install the belt kinematics on the writer in place, drop the copied offset, and drop the virtual markers on GCodeWriter that the old subclass needed. Every m_writer-> in GCode.cpp goes back to m_writer., which is most of the belt diff in that file and most of its conflicts with main. The pressure-advance pattern keeps its shared_ptr writer: the unique_ptr kinematics make GCodeWriter move-only and that class must stay copyable.
This commit is contained in:
@@ -8,14 +8,10 @@ namespace Slic3r {
|
||||
|
||||
void BeltGCode::init_belt_writer(Print &print)
|
||||
{
|
||||
auto belt_writer = std::make_unique<GCodeWriter>();
|
||||
// Axis remap and build volume max are set by base GCode after init_belt_writer
|
||||
// returns; set_kinematics() replays them, so install order does not matter.
|
||||
install_belt_kinematics(*belt_writer, print.config());
|
||||
belt_writer->set_force_normal_lift(true);
|
||||
// The plate origin was stored on the writer this one replaces.
|
||||
belt_writer->set_xy_offset(m_gcode_offset.x(), m_gcode_offset.y());
|
||||
m_writer = std::move(belt_writer);
|
||||
install_belt_kinematics(m_writer, print.config());
|
||||
m_writer.set_force_normal_lift(true);
|
||||
}
|
||||
|
||||
void BeltGCode::write_belt_header(GCodeOutputStream &file, const Print &print)
|
||||
|
||||
Reference in New Issue
Block a user