2014-11-09 18:02:45 +00:00
|
|
|
#ifndef slic3r_GCodeWriter_hpp_
|
|
|
|
#define slic3r_GCodeWriter_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2014-11-09 18:02:45 +00:00
|
|
|
#include <string>
|
|
|
|
#include "Extruder.hpp"
|
|
|
|
#include "Point.hpp"
|
|
|
|
#include "PrintConfig.hpp"
|
2017-06-23 08:13:09 +00:00
|
|
|
#include "GCode/CoolingBuffer.hpp"
|
2014-11-09 18:02:45 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class GCodeWriter {
|
2016-09-26 10:49:29 +00:00
|
|
|
public:
|
2014-11-09 18:02:45 +00:00
|
|
|
GCodeConfig config;
|
|
|
|
bool multiple_extruders;
|
|
|
|
|
2017-05-03 16:28:22 +00:00
|
|
|
GCodeWriter() :
|
2017-06-30 18:01:32 +00:00
|
|
|
multiple_extruders(false), m_extrusion_axis("E"), m_extruder(nullptr),
|
2017-05-25 20:52:28 +00:00
|
|
|
m_single_extruder_multi_material(false),
|
2017-06-21 15:45:55 +00:00
|
|
|
m_last_acceleration(0), m_last_fan_speed(0),
|
|
|
|
m_last_bed_temperature(0), m_last_bed_temperature_reached(true),
|
|
|
|
m_lifted(0)
|
2017-05-03 16:28:22 +00:00
|
|
|
{}
|
2017-06-23 08:13:09 +00:00
|
|
|
Extruder* extruder() { return m_extruder; }
|
|
|
|
const Extruder* extruder() const { return m_extruder; }
|
|
|
|
|
|
|
|
std::string extrusion_axis() const { return m_extrusion_axis; }
|
|
|
|
void apply_print_config(const PrintConfig &print_config);
|
2017-06-22 10:59:23 +00:00
|
|
|
// Extruders are expected to be sorted in an increasing order.
|
2017-06-23 08:13:09 +00:00
|
|
|
void set_extruders(const std::vector<unsigned int> &extruder_ids);
|
2017-06-22 10:59:23 +00:00
|
|
|
const std::vector<Extruder>& extruders() const { return m_extruders; }
|
2017-05-03 16:28:22 +00:00
|
|
|
std::vector<unsigned int> extruder_ids() const {
|
|
|
|
std::vector<unsigned int> out;
|
2017-06-22 10:59:23 +00:00
|
|
|
out.reserve(m_extruders.size());
|
|
|
|
for (const Extruder &e : m_extruders)
|
|
|
|
out.push_back(e.id());
|
2017-05-03 16:28:22 +00:00
|
|
|
return out;
|
|
|
|
}
|
2014-11-09 18:02:45 +00:00
|
|
|
std::string preamble();
|
2015-07-27 23:26:01 +00:00
|
|
|
std::string postamble() const;
|
|
|
|
std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1) const;
|
2017-06-21 15:45:55 +00:00
|
|
|
std::string set_bed_temperature(unsigned int temperature, bool wait = false);
|
2014-11-09 18:02:45 +00:00
|
|
|
std::string set_fan(unsigned int speed, bool dont_save = false);
|
|
|
|
std::string set_acceleration(unsigned int acceleration);
|
|
|
|
std::string reset_e(bool force = false);
|
2015-07-27 23:26:01 +00:00
|
|
|
std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const;
|
2017-05-03 16:28:22 +00:00
|
|
|
// return false if this extruder was already selected
|
|
|
|
bool need_toolchange(unsigned int extruder_id) const
|
2017-06-22 10:59:23 +00:00
|
|
|
{ return m_extruder == nullptr || m_extruder->id() != extruder_id; }
|
2017-05-03 16:28:22 +00:00
|
|
|
std::string set_extruder(unsigned int extruder_id)
|
|
|
|
{ return this->need_toolchange(extruder_id) ? this->toolchange(extruder_id) : ""; }
|
2017-06-30 15:05:58 +00:00
|
|
|
// Prefix of the toolchange G-code line, to be used by the CoolingBuffer to separate sections of the G-code
|
|
|
|
// printed with the same extruder.
|
|
|
|
std::string toolchange_prefix() const;
|
2014-11-09 18:02:45 +00:00
|
|
|
std::string toolchange(unsigned int extruder_id);
|
2016-05-12 15:31:26 +00:00
|
|
|
std::string set_speed(double F, const std::string &comment = std::string(), const std::string &cooling_marker = std::string()) const;
|
2014-11-09 18:02:45 +00:00
|
|
|
std::string travel_to_xy(const Pointf &point, const std::string &comment = std::string());
|
|
|
|
std::string travel_to_xyz(const Pointf3 &point, const std::string &comment = std::string());
|
|
|
|
std::string travel_to_z(double z, const std::string &comment = std::string());
|
2017-05-03 16:28:22 +00:00
|
|
|
bool will_move_z(double z) const;
|
2014-11-09 18:02:45 +00:00
|
|
|
std::string extrude_to_xy(const Pointf &point, double dE, const std::string &comment = std::string());
|
|
|
|
std::string extrude_to_xyz(const Pointf3 &point, double dE, const std::string &comment = std::string());
|
2017-05-19 17:24:21 +00:00
|
|
|
std::string retract(bool before_wipe = false);
|
|
|
|
std::string retract_for_toolchange(bool before_wipe = false);
|
2014-11-09 18:02:45 +00:00
|
|
|
std::string unretract();
|
|
|
|
std::string lift();
|
|
|
|
std::string unlift();
|
2017-06-21 15:45:55 +00:00
|
|
|
Pointf3 get_position() const { return m_pos; }
|
2017-05-03 16:28:22 +00:00
|
|
|
|
2016-09-26 10:49:29 +00:00
|
|
|
private:
|
2017-06-23 08:13:09 +00:00
|
|
|
std::vector<Extruder> m_extruders;
|
2017-06-21 15:45:55 +00:00
|
|
|
std::string m_extrusion_axis;
|
2017-05-25 20:52:28 +00:00
|
|
|
bool m_single_extruder_multi_material;
|
2017-06-21 15:45:55 +00:00
|
|
|
Extruder* m_extruder;
|
|
|
|
unsigned int m_last_acceleration;
|
|
|
|
unsigned int m_last_fan_speed;
|
|
|
|
unsigned int m_last_bed_temperature;
|
|
|
|
bool m_last_bed_temperature_reached;
|
|
|
|
double m_lifted;
|
|
|
|
Pointf3 m_pos;
|
2017-05-25 20:52:28 +00:00
|
|
|
|
2014-11-09 18:02:45 +00:00
|
|
|
std::string _travel_to_z(double z, const std::string &comment);
|
|
|
|
std::string _retract(double length, double restart_extra, const std::string &comment);
|
|
|
|
};
|
|
|
|
|
2016-09-26 10:49:29 +00:00
|
|
|
} /* namespace Slic3r */
|
2014-11-09 18:02:45 +00:00
|
|
|
|
2016-09-26 10:49:29 +00:00
|
|
|
#endif /* slic3r_GCodeWriter_hpp_ */
|