mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Next step of Perl to C++ configuration layer conversion.
This commit is contained in:
parent
337f6c5808
commit
95c284c764
15 changed files with 414 additions and 394 deletions
|
@ -16,7 +16,6 @@
|
|||
#include <boost/nowide/cenv.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(setenv) && defined(_putenv_s)
|
||||
|
@ -329,11 +328,15 @@ void ConfigBase::load(const std::string &file)
|
|||
|
||||
void ConfigBase::load_from_ini(const std::string &file)
|
||||
{
|
||||
namespace pt = boost::property_tree;
|
||||
pt::ptree tree;
|
||||
boost::property_tree::ptree tree;
|
||||
boost::nowide::ifstream ifs(file);
|
||||
pt::read_ini(ifs, tree);
|
||||
for (const pt::ptree::value_type &v : tree) {
|
||||
boost::property_tree::read_ini(ifs, tree);
|
||||
this->load(tree);
|
||||
}
|
||||
|
||||
void ConfigBase::load(const boost::property_tree::ptree &tree)
|
||||
{
|
||||
for (const boost::property_tree::ptree::value_type &v : tree) {
|
||||
try {
|
||||
t_config_option_key opt_key = v.first;
|
||||
this->set_deserialize(opt_key, v.second.get_value<std::string>());
|
||||
|
@ -428,6 +431,18 @@ void ConfigBase::save(const std::string &file) const
|
|||
c.close();
|
||||
}
|
||||
|
||||
bool DynamicConfig::operator==(const DynamicConfig &rhs) const
|
||||
{
|
||||
t_options_map::const_iterator it1 = this->options.begin();
|
||||
t_options_map::const_iterator it1_end = this->options.end();
|
||||
t_options_map::const_iterator it2 = rhs.options.begin();
|
||||
t_options_map::const_iterator it2_end = rhs.options.end();
|
||||
for (; it1 != it1_end && it2 != it2_end; ++ it1, ++ it2)
|
||||
if (*it1->second != *it2->second)
|
||||
return false;
|
||||
return it1 == it1_end && it2 == it2_end;
|
||||
}
|
||||
|
||||
ConfigOption* DynamicConfig::optptr(const t_config_option_key &opt_key, bool create)
|
||||
{
|
||||
t_options_map::iterator it = options.find(opt_key);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "libslic3r.h"
|
||||
#include "Point.hpp"
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// Name of the configuration option.
|
||||
|
@ -62,7 +64,7 @@ enum ConfigOptionType {
|
|||
// A generic value of a configuration option.
|
||||
class ConfigOption {
|
||||
public:
|
||||
virtual ~ConfigOption() {};
|
||||
virtual ~ConfigOption() {}
|
||||
|
||||
virtual ConfigOptionType type() const = 0;
|
||||
virtual std::string serialize() const = 0;
|
||||
|
@ -94,7 +96,7 @@ public:
|
|||
throw std::runtime_error("ConfigOptionSingle: Assigning an incompatible type");
|
||||
assert(dynamic_cast<const ConfigOptionSingle<T>*>(rhs));
|
||||
this->value = static_cast<const ConfigOptionSingle<T>*>(rhs)->value;
|
||||
};
|
||||
}
|
||||
|
||||
bool operator==(const ConfigOption &rhs) const override
|
||||
{
|
||||
|
@ -122,6 +124,9 @@ public:
|
|||
// This function is useful to split values from multiple extrder / filament settings into separate configurations.
|
||||
virtual void set_at(const ConfigOption *rhs, size_t i, size_t j) = 0;
|
||||
|
||||
virtual void resize(size_t n, const ConfigOption *opt_default = nullptr) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
// Used to verify type compatibility when assigning to / from a scalar ConfigOption.
|
||||
ConfigOptionType scalar_type() const { return static_cast<ConfigOptionType>(this->type() - coVectorType); }
|
||||
|
@ -132,6 +137,9 @@ template <class T>
|
|||
class ConfigOptionVector : public ConfigOptionVectorBase
|
||||
{
|
||||
public:
|
||||
ConfigOptionVector() {}
|
||||
explicit ConfigOptionVector(size_t n, const T &value) : values(n, value) {}
|
||||
explicit ConfigOptionVector(std::initializer_list<T> il) : values(std::move(il)) {}
|
||||
std::vector<T> values;
|
||||
|
||||
void set(const ConfigOption *rhs) override
|
||||
|
@ -194,6 +202,31 @@ public:
|
|||
|
||||
const T& get_at(size_t i) const { return const_cast<ConfigOptionVector<T>*>(this)->get_at(i); }
|
||||
|
||||
// Resize this vector by duplicating the last value.
|
||||
// If the current vector is empty, the default value is used instead.
|
||||
void resize(size_t n, const ConfigOption *opt_default = nullptr) override
|
||||
{
|
||||
assert(opt_default == nullptr || opt_default->is_vector());
|
||||
assert(opt_default == nullptr || dynamic_cast<ConfigOptionVector<T>>(opt_default));
|
||||
assert(! this->values.empty() || opt_default != nullptr);
|
||||
if (n == 0)
|
||||
this->values.clear();
|
||||
else if (n < this->values.size())
|
||||
this->values.erase(this->values.begin() + n, this->values.end());
|
||||
else if (n > this->values.size())
|
||||
if (this->values.empty()) {
|
||||
if (opt_default == nullptr) {
|
||||
throw std::runtime_error("ConfigOptionVector::resize(): No default value provided.");
|
||||
if (opt_default->type() != this->type())
|
||||
throw std::runtime_error("ConfigOptionVector::resize(): Extending with an incompatible type.");
|
||||
this->values.resize(n, static_cast<const ConfigOptionVector<T>*>(opt_default)->values.front());
|
||||
} else {
|
||||
// Resize by duplicating the last value.
|
||||
this->values.resize(n, this->values.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const ConfigOption &rhs) const override
|
||||
{
|
||||
if (rhs.type() != this->type())
|
||||
|
@ -209,8 +242,8 @@ public:
|
|||
class ConfigOptionFloat : public ConfigOptionSingle<double>
|
||||
{
|
||||
public:
|
||||
ConfigOptionFloat() : ConfigOptionSingle<double>(0) {};
|
||||
explicit ConfigOptionFloat(double _value) : ConfigOptionSingle<double>(_value) {};
|
||||
ConfigOptionFloat() : ConfigOptionSingle<double>(0) {}
|
||||
explicit ConfigOptionFloat(double _value) : ConfigOptionSingle<double>(_value) {}
|
||||
|
||||
ConfigOptionType type() const override { return coFloat; }
|
||||
double getFloat() const override { return this->value; }
|
||||
|
@ -242,6 +275,10 @@ public:
|
|||
class ConfigOptionFloats : public ConfigOptionVector<double>
|
||||
{
|
||||
public:
|
||||
ConfigOptionFloats() : ConfigOptionVector<double>() {}
|
||||
explicit ConfigOptionFloats(size_t n, double value) : ConfigOptionVector<double>(n, value) {}
|
||||
explicit ConfigOptionFloats(std::initializer_list<double> il) : ConfigOptionVector<double>(std::move(il)) {}
|
||||
|
||||
ConfigOptionType type() const override { return coFloats; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionFloats(*this); }
|
||||
bool operator==(const ConfigOptionFloats &rhs) const { return this->values == rhs.values; }
|
||||
|
@ -254,7 +291,7 @@ public:
|
|||
ss << *it;
|
||||
}
|
||||
return ss.str();
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> vserialize() const override
|
||||
{
|
||||
|
@ -293,13 +330,13 @@ public:
|
|||
class ConfigOptionInt : public ConfigOptionSingle<int>
|
||||
{
|
||||
public:
|
||||
ConfigOptionInt() : ConfigOptionSingle<int>(0) {};
|
||||
explicit ConfigOptionInt(int value) : ConfigOptionSingle<int>(value) {};
|
||||
explicit ConfigOptionInt(double _value) : ConfigOptionSingle<int>(int(floor(_value + 0.5))) {};
|
||||
ConfigOptionInt() : ConfigOptionSingle<int>(0) {}
|
||||
explicit ConfigOptionInt(int value) : ConfigOptionSingle<int>(value) {}
|
||||
explicit ConfigOptionInt(double _value) : ConfigOptionSingle<int>(int(floor(_value + 0.5))) {}
|
||||
|
||||
ConfigOptionType type() const override { return coInt; }
|
||||
int getInt() const override { return this->value; };
|
||||
void setInt(int val) { this->value = val; };
|
||||
int getInt() const override { return this->value; }
|
||||
void setInt(int val) { this->value = val; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionInt(*this); }
|
||||
bool operator==(const ConfigOptionInt &rhs) const { return this->value == rhs.value; }
|
||||
|
||||
|
@ -328,6 +365,10 @@ public:
|
|||
class ConfigOptionInts : public ConfigOptionVector<int>
|
||||
{
|
||||
public:
|
||||
ConfigOptionInts() : ConfigOptionVector<int>() {}
|
||||
explicit ConfigOptionInts(size_t n, int value) : ConfigOptionVector<int>(n, value) {}
|
||||
explicit ConfigOptionInts(std::initializer_list<int> il) : ConfigOptionVector<int>(std::move(il)) {}
|
||||
|
||||
ConfigOptionType type() const override { return coInts; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionInts(*this); }
|
||||
ConfigOptionInts& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||
|
@ -373,8 +414,8 @@ public:
|
|||
class ConfigOptionString : public ConfigOptionSingle<std::string>
|
||||
{
|
||||
public:
|
||||
ConfigOptionString() : ConfigOptionSingle<std::string>("") {};
|
||||
explicit ConfigOptionString(std::string _value) : ConfigOptionSingle<std::string>(_value) {};
|
||||
ConfigOptionString() : ConfigOptionSingle<std::string>("") {}
|
||||
explicit ConfigOptionString(const std::string &value) : ConfigOptionSingle<std::string>(value) {}
|
||||
|
||||
ConfigOptionType type() const override { return coString; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionString(*this); }
|
||||
|
@ -397,6 +438,10 @@ public:
|
|||
class ConfigOptionStrings : public ConfigOptionVector<std::string>
|
||||
{
|
||||
public:
|
||||
ConfigOptionStrings() : ConfigOptionVector<std::string>() {}
|
||||
explicit ConfigOptionStrings(size_t n, const std::string &value) : ConfigOptionVector<std::string>(n, value) {}
|
||||
explicit ConfigOptionStrings(std::initializer_list<std::string> il) : ConfigOptionVector<std::string>(std::move(il)) {}
|
||||
|
||||
ConfigOptionType type() const override { return coStrings; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionStrings(*this); }
|
||||
ConfigOptionStrings& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||
|
@ -423,8 +468,8 @@ public:
|
|||
class ConfigOptionPercent : public ConfigOptionFloat
|
||||
{
|
||||
public:
|
||||
ConfigOptionPercent() : ConfigOptionFloat(0) {};
|
||||
explicit ConfigOptionPercent(double _value) : ConfigOptionFloat(_value) {};
|
||||
ConfigOptionPercent() : ConfigOptionFloat(0) {}
|
||||
explicit ConfigOptionPercent(double _value) : ConfigOptionFloat(_value) {}
|
||||
|
||||
ConfigOptionType type() const override { return coPercent; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionPercent(*this); }
|
||||
|
@ -454,6 +499,10 @@ public:
|
|||
class ConfigOptionPercents : public ConfigOptionFloats
|
||||
{
|
||||
public:
|
||||
ConfigOptionPercents() : ConfigOptionFloats() {}
|
||||
explicit ConfigOptionPercents(size_t n, double value) : ConfigOptionFloats(n, value) {}
|
||||
explicit ConfigOptionPercents(std::initializer_list<double> il) : ConfigOptionFloats(std::move(il)) {}
|
||||
|
||||
ConfigOptionType type() const override { return coPercents; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionPercents(*this); }
|
||||
ConfigOptionPercents& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||
|
@ -504,9 +553,9 @@ class ConfigOptionFloatOrPercent : public ConfigOptionPercent
|
|||
{
|
||||
public:
|
||||
bool percent;
|
||||
ConfigOptionFloatOrPercent() : ConfigOptionPercent(0), percent(false) {};
|
||||
explicit ConfigOptionFloatOrPercent(double _value, bool _percent) : ConfigOptionPercent(_value), percent(_percent) {};
|
||||
|
||||
ConfigOptionFloatOrPercent() : ConfigOptionPercent(0), percent(false) {}
|
||||
explicit ConfigOptionFloatOrPercent(double _value, bool _percent) : ConfigOptionPercent(_value), percent(_percent) {}
|
||||
|
||||
ConfigOptionType type() const override { return coFloatOrPercent; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionFloatOrPercent(*this); }
|
||||
ConfigOptionFloatOrPercent& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||
|
@ -544,8 +593,8 @@ public:
|
|||
class ConfigOptionPoint : public ConfigOptionSingle<Pointf>
|
||||
{
|
||||
public:
|
||||
ConfigOptionPoint() : ConfigOptionSingle<Pointf>(Pointf(0,0)) {};
|
||||
explicit ConfigOptionPoint(const Pointf &value) : ConfigOptionSingle<Pointf>(value) {};
|
||||
ConfigOptionPoint() : ConfigOptionSingle<Pointf>(Pointf(0,0)) {}
|
||||
explicit ConfigOptionPoint(const Pointf &value) : ConfigOptionSingle<Pointf>(value) {}
|
||||
|
||||
ConfigOptionType type() const override { return coPoint; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionPoint(*this); }
|
||||
|
@ -576,6 +625,10 @@ public:
|
|||
class ConfigOptionPoints : public ConfigOptionVector<Pointf>
|
||||
{
|
||||
public:
|
||||
ConfigOptionPoints() : ConfigOptionVector<Pointf>() {}
|
||||
explicit ConfigOptionPoints(size_t n, const Pointf &value) : ConfigOptionVector<Pointf>(n, value) {}
|
||||
explicit ConfigOptionPoints(std::initializer_list<Pointf> il) : ConfigOptionVector<Pointf>(std::move(il)) {}
|
||||
|
||||
ConfigOptionType type() const override { return coPoints; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionPoints(*this); }
|
||||
ConfigOptionPoints& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||
|
@ -629,11 +682,11 @@ public:
|
|||
class ConfigOptionBool : public ConfigOptionSingle<bool>
|
||||
{
|
||||
public:
|
||||
ConfigOptionBool() : ConfigOptionSingle<bool>(false) {};
|
||||
explicit ConfigOptionBool(bool _value) : ConfigOptionSingle<bool>(_value) {};
|
||||
ConfigOptionBool() : ConfigOptionSingle<bool>(false) {}
|
||||
explicit ConfigOptionBool(bool _value) : ConfigOptionSingle<bool>(_value) {}
|
||||
|
||||
ConfigOptionType type() const override { return coBool; }
|
||||
bool getBool() const override { return this->value; };
|
||||
bool getBool() const override { return this->value; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionBool(*this); }
|
||||
ConfigOptionBool& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||
bool operator==(const ConfigOptionBool &rhs) const { return this->value == rhs.value; }
|
||||
|
@ -654,6 +707,10 @@ public:
|
|||
class ConfigOptionBools : public ConfigOptionVector<unsigned char>
|
||||
{
|
||||
public:
|
||||
ConfigOptionBools() : ConfigOptionVector<unsigned char>() {}
|
||||
explicit ConfigOptionBools(size_t n, bool value) : ConfigOptionVector<unsigned char>(n, (unsigned char)value) {}
|
||||
explicit ConfigOptionBools(std::initializer_list<bool> il) { values.reserve(il.size()); for (bool b : il) values.emplace_back((unsigned char)b); }
|
||||
|
||||
ConfigOptionType type() const override { return coBools; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionBools(*this); }
|
||||
ConfigOptionBools& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||
|
@ -711,8 +768,8 @@ class ConfigOptionEnum : public ConfigOptionSingle<T>
|
|||
{
|
||||
public:
|
||||
// by default, use the first value (0) of the T enum type
|
||||
ConfigOptionEnum() : ConfigOptionSingle<T>(static_cast<T>(0)) {};
|
||||
explicit ConfigOptionEnum(T _value) : ConfigOptionSingle<T>(_value) {};
|
||||
ConfigOptionEnum() : ConfigOptionSingle<T>(static_cast<T>(0)) {}
|
||||
explicit ConfigOptionEnum(T _value) : ConfigOptionSingle<T>(_value) {}
|
||||
|
||||
ConfigOptionType type() const override { return coEnum; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionEnum<T>(*this); }
|
||||
|
@ -954,6 +1011,7 @@ public:
|
|||
void load(const std::string &file);
|
||||
void load_from_ini(const std::string &file);
|
||||
void load_from_gcode(const std::string &file);
|
||||
void load(const boost::property_tree::ptree &tree);
|
||||
void save(const std::string &file) const;
|
||||
|
||||
private:
|
||||
|
@ -986,6 +1044,9 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const DynamicConfig &rhs) const;
|
||||
bool operator!=(const DynamicConfig &rhs) const { return ! (*this == rhs); }
|
||||
|
||||
void swap(DynamicConfig &other)
|
||||
{
|
||||
std::swap(this->options, other.options);
|
||||
|
|
|
@ -23,14 +23,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
|
||||
def = this->add("bed_shape", coPoints);
|
||||
def->label = "Bed shape";
|
||||
{
|
||||
ConfigOptionPoints* opt = new ConfigOptionPoints();
|
||||
opt->values.push_back(Pointf(0,0));
|
||||
opt->values.push_back(Pointf(200,0));
|
||||
opt->values.push_back(Pointf(200,200));
|
||||
opt->values.push_back(Pointf(0,200));
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionPoints { Pointf(0,0), Pointf(200,0), Pointf(200,200), Pointf(0,200) };
|
||||
|
||||
def = this->add("bed_temperature", coInts);
|
||||
def->label = "Other layers";
|
||||
|
@ -39,11 +32,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->full_label = "Bed temperature";
|
||||
def->min = 0;
|
||||
def->max = 300;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 0 };
|
||||
|
||||
def = this->add("before_layer_gcode", coString);
|
||||
def->label = "Before layer change G-code";
|
||||
|
@ -87,11 +76,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->cli = "bridge-fan-speed=i@";
|
||||
def->min = 0;
|
||||
def->max = 100;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(100);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 100 };
|
||||
|
||||
def = this->add("bridge_flow_ratio", coFloat);
|
||||
def->label = "Bridge flow ratio";
|
||||
|
@ -139,11 +124,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->label = "Enable auto cooling";
|
||||
def->tooltip = "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time.";
|
||||
def->cli = "cooling!";
|
||||
{
|
||||
ConfigOptionBools* opt = new ConfigOptionBools();
|
||||
opt->values.push_back(true);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionBools { true };
|
||||
|
||||
def = this->add("default_acceleration", coFloat);
|
||||
def->label = "Default";
|
||||
|
@ -160,11 +141,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->cli = "disable-fan-first-layers=i@";
|
||||
def->min = 0;
|
||||
def->max = 1000;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(3);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 3 };
|
||||
|
||||
def = this->add("dont_support_bridges", coBool);
|
||||
def->label = "Don't support bridges";
|
||||
|
@ -207,11 +184,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
{
|
||||
ConfigOptionStrings* opt = new ConfigOptionStrings();
|
||||
opt->values.push_back("; Filament-specific end gcode \n;END gcode for filament\n");
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionStrings { "; Filament-specific end gcode \n;END gcode for filament\n" };
|
||||
|
||||
def = this->add("ensure_vertical_shell_thickness", coBool);
|
||||
def->label = "Ensure vertical shell thickness";
|
||||
|
@ -305,24 +278,15 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "This is only used in the Slic3r interface as a visual help.";
|
||||
def->cli = "extruder-color=s@";
|
||||
def->gui_type = "color";
|
||||
{
|
||||
ConfigOptionStrings* opt = new ConfigOptionStrings();
|
||||
// Empty string means no color assigned yet.
|
||||
// opt->values.push_back("#FFFFFF");
|
||||
opt->values.push_back("");
|
||||
def->default_value = opt;
|
||||
}
|
||||
// Empty string means no color assigned yet.
|
||||
def->default_value = new ConfigOptionStrings { "" };
|
||||
|
||||
def = this->add("extruder_offset", coPoints);
|
||||
def->label = "Extruder offset";
|
||||
def->tooltip = "If your firmware doesn't handle the extruder displacement you need the G-code to take it into account. This option lets you specify the displacement of each extruder with respect to the first one. It expects positive coordinates (they will be subtracted from the XY coordinate).";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "extruder-offset=s@";
|
||||
{
|
||||
ConfigOptionPoints* opt = new ConfigOptionPoints();
|
||||
opt->values.push_back(Pointf(0,0));
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionPoints { Pointf(0,0) };
|
||||
|
||||
def = this->add("extrusion_axis", coString);
|
||||
def->label = "Extrusion axis";
|
||||
|
@ -334,11 +298,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->label = "Extrusion multiplier";
|
||||
def->tooltip = "This factor changes the amount of flow proportionally. You may need to tweak this setting to get nice surface finish and correct single wall widths. Usual values are between 0.9 and 1.1. If you think you need to change this more, check filament diameter and your firmware E steps.";
|
||||
def->cli = "extrusion-multiplier=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(1);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 1. };
|
||||
|
||||
def = this->add("extrusion_width", coFloatOrPercent);
|
||||
def->label = "Default extrusion width";
|
||||
|
@ -352,11 +312,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->label = "Keep fan always on";
|
||||
def->tooltip = "If this is enabled, fan will never be disabled and will be kept running at least at its minimum speed. Useful for PLA, harmful for ABS.";
|
||||
def->cli = "fan-always-on!";
|
||||
{
|
||||
ConfigOptionBools* opt = new ConfigOptionBools();
|
||||
opt->values.push_back(false);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionBools { false };
|
||||
|
||||
def = this->add("fan_below_layer_time", coInts);
|
||||
def->label = "Enable fan if layer print time is below";
|
||||
|
@ -366,22 +322,14 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->width = 60;
|
||||
def->min = 0;
|
||||
def->max = 1000;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(60);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 60 };
|
||||
|
||||
def = this->add("filament_colour", coStrings);
|
||||
def->label = "Color";
|
||||
def->tooltip = "This is only used in the Slic3r interface as a visual help.";
|
||||
def->cli = "filament-color=s@";
|
||||
def->gui_type = "color";
|
||||
{
|
||||
ConfigOptionStrings* opt = new ConfigOptionStrings();
|
||||
opt->values.push_back("#FFFFFF");
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionStrings { "#29b2b2" };
|
||||
|
||||
def = this->add("filament_notes", coStrings);
|
||||
def->label = "Filament notes";
|
||||
|
@ -390,11 +338,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
{
|
||||
ConfigOptionStrings* opt = new ConfigOptionStrings();
|
||||
opt->values.push_back("");
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionStrings { "" };
|
||||
|
||||
def = this->add("filament_max_volumetric_speed", coFloats);
|
||||
def->label = "Max volumetric speed";
|
||||
|
@ -402,11 +346,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->sidetext = "mm³/s";
|
||||
def->cli = "filament-max-volumetric-speed=f@";
|
||||
def->min = 0;
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0.f);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("filament_diameter", coFloats);
|
||||
def->label = "Diameter";
|
||||
|
@ -414,11 +354,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->sidetext = "mm";
|
||||
def->cli = "filament-diameter=f@";
|
||||
def->min = 0;
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(3);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 3. };
|
||||
|
||||
def = this->add("filament_density", coFloats);
|
||||
def->label = "Density";
|
||||
|
@ -426,11 +362,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->sidetext = "g/cm^3";
|
||||
def->cli = "filament-density=f@";
|
||||
def->min = 0;
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("filament_type", coStrings);
|
||||
def->label = "Filament type";
|
||||
|
@ -447,21 +379,13 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->enum_values.push_back("EDGE");
|
||||
def->enum_values.push_back("NGEN");
|
||||
def->enum_values.push_back("PVA");
|
||||
{
|
||||
ConfigOptionStrings* opt = new ConfigOptionStrings();
|
||||
opt->values.push_back("PLA");
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionStrings { "PLA" };
|
||||
|
||||
def = this->add("filament_soluble", coBools);
|
||||
def->label = "Soluble material";
|
||||
def->tooltip = "Soluble material is most likely used for a soluble support.";
|
||||
def->cli = "filament-soluble!";
|
||||
{
|
||||
ConfigOptionBools* opt = new ConfigOptionBools();
|
||||
opt->values.push_back(false);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionBools { false };
|
||||
|
||||
def = this->add("filament_cost", coFloats);
|
||||
def->label = "Cost";
|
||||
|
@ -469,15 +393,11 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->sidetext = "money/kg";
|
||||
def->cli = "filament-cost=f@";
|
||||
def->min = 0;
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
|
||||
def = this->add("filament_settings_id", coString);
|
||||
def->default_value = new ConfigOptionString("");
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("filament_settings_id", coStrings);
|
||||
def->default_value = new ConfigOptionStrings { "" };
|
||||
|
||||
def = this->add("fill_angle", coFloat);
|
||||
def->label = "Fill angle";
|
||||
def->category = "Infill";
|
||||
|
@ -574,11 +494,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->cli = "first-layer-bed-temperature=i@";
|
||||
def->max = 0;
|
||||
def->max = 300;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 0 };
|
||||
|
||||
def = this->add("first_layer_extrusion_width", coFloatOrPercent);
|
||||
def->label = "First layer";
|
||||
|
@ -612,11 +528,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->cli = "first-layer-temperature=i@";
|
||||
def->min = 0;
|
||||
def->max = 500;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(200);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 200 };
|
||||
|
||||
def = this->add("gap_fill_speed", coFloat);
|
||||
def->label = "Gap fill";
|
||||
|
@ -757,11 +669,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->cli = "max-fan-speed=i@";
|
||||
def->min = 0;
|
||||
def->max = 100;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(100);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 100 };
|
||||
|
||||
def = this->add("max_layer_height", coFloats);
|
||||
def->label = "Max";
|
||||
|
@ -769,11 +677,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->sidetext = "mm";
|
||||
def->cli = "max-layer-height=f@";
|
||||
def->min = 0;
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("max_print_speed", coFloat);
|
||||
def->label = "Max print speed";
|
||||
|
@ -816,11 +720,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->cli = "min-fan-speed=i@";
|
||||
def->min = 0;
|
||||
def->max = 100;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(35);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 35 };
|
||||
|
||||
def = this->add("min_layer_height", coFloats);
|
||||
def->label = "Min";
|
||||
|
@ -828,11 +728,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->sidetext = "mm";
|
||||
def->cli = "min-layer-height=f@";
|
||||
def->min = 0;
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0.07);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0.07 };
|
||||
|
||||
def = this->add("min_print_speed", coFloats);
|
||||
def->label = "Min print speed";
|
||||
|
@ -840,11 +736,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->sidetext = "mm/s";
|
||||
def->cli = "min-print-speed=f@";
|
||||
def->min = 0;
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(10.);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 10. };
|
||||
|
||||
def = this->add("min_skirt_length", coFloat);
|
||||
def->label = "Minimum extrusion length";
|
||||
|
@ -868,11 +760,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "nozzle-diameter=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0.5);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0.5 };
|
||||
|
||||
def = this->add("octoprint_apikey", coString);
|
||||
def->label = "API Key";
|
||||
|
@ -1003,32 +891,20 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "Retraction is not triggered when travel moves are shorter than this length.";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "retract-before-travel=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(2);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 2. };
|
||||
|
||||
def = this->add("retract_before_wipe", coPercents);
|
||||
def->label = "Retract amount before wipe";
|
||||
def->tooltip = "With bowden extruders, it may be wise to do some amount of quick retract before doing the wipe movement.";
|
||||
def->sidetext = "%";
|
||||
def->cli = "retract-before-wipe=s@";
|
||||
{
|
||||
ConfigOptionPercents* opt = new ConfigOptionPercents();
|
||||
opt->values.push_back(0.f);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionPercents { 0. };
|
||||
|
||||
def = this->add("retract_layer_change", coBools);
|
||||
def->label = "Retract on layer change";
|
||||
def->tooltip = "This flag enforces a retraction whenever a Z move is done.";
|
||||
def->cli = "retract-layer-change!";
|
||||
{
|
||||
ConfigOptionBools* opt = new ConfigOptionBools();
|
||||
opt->values.push_back(false);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionBools { false };
|
||||
|
||||
def = this->add("retract_length", coFloats);
|
||||
def->label = "Length";
|
||||
|
@ -1036,11 +912,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "When retraction is triggered, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder).";
|
||||
def->sidetext = "mm (zero to disable)";
|
||||
def->cli = "retract-length=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(2);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 2. };
|
||||
|
||||
def = this->add("retract_length_toolchange", coFloats);
|
||||
def->label = "Length";
|
||||
|
@ -1048,22 +920,14 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "When retraction is triggered before changing tool, filament is pulled back by the specified amount (the length is measured on raw filament, before it enters the extruder).";
|
||||
def->sidetext = "mm (zero to disable)";
|
||||
def->cli = "retract-length-toolchange=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(10);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 10. };
|
||||
|
||||
def = this->add("retract_lift", coFloats);
|
||||
def->label = "Lift Z";
|
||||
def->tooltip = "If you set this to a positive value, Z is quickly raised every time a retraction is triggered. When using multiple extruders, only the setting for the first extruder will be considered.";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "retract-lift=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("retract_lift_above", coFloats);
|
||||
def->label = "Above Z";
|
||||
|
@ -1071,11 +935,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "If you set this to a positive value, Z lift will only take place above the specified absolute Z. You can tune this setting for skipping lift on the first layers.";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "retract-lift-above=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("retract_lift_below", coFloats);
|
||||
def->label = "Below Z";
|
||||
|
@ -1083,33 +943,21 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "If you set this to a positive value, Z lift will only take place below the specified absolute Z. You can tune this setting for limiting lift to the first layers.";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "retract-lift-below=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("retract_restart_extra", coFloats);
|
||||
def->label = "Extra length on restart";
|
||||
def->tooltip = "When the retraction is compensated after the travel move, the extruder will push this additional amount of filament. This setting is rarely needed.";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "retract-restart-extra=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("retract_restart_extra_toolchange", coFloats);
|
||||
def->label = "Extra length on restart";
|
||||
def->tooltip = "When the retraction is compensated after changing tool, the extruder will push this additional amount of filament.";
|
||||
def->sidetext = "mm";
|
||||
def->cli = "retract-restart-extra-toolchange=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("retract_speed", coFloats);
|
||||
def->label = "Retraction Speed";
|
||||
|
@ -1117,11 +965,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "The speed for retractions (it only applies to the extruder motor).";
|
||||
def->sidetext = "mm/s";
|
||||
def->cli = "retract-speed=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(40);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 40. };
|
||||
|
||||
def = this->add("deretract_speed", coFloats);
|
||||
def->label = "Deretraction Speed";
|
||||
|
@ -1129,11 +973,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->tooltip = "The speed for loading of a filament into extruder after retraction (it only applies to the extruder motor). If left to zero, the retraction speed is used.";
|
||||
def->sidetext = "mm/s";
|
||||
def->cli = "retract-speed=f@";
|
||||
{
|
||||
ConfigOptionFloats* opt = new ConfigOptionFloats();
|
||||
opt->values.push_back(0);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionFloats { 0. };
|
||||
|
||||
def = this->add("seam_position", coEnum);
|
||||
def->label = "Seam position";
|
||||
|
@ -1227,11 +1067,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->width = 60;
|
||||
def->min = 0;
|
||||
def->max = 1000;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(5);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 5 };
|
||||
|
||||
def = this->add("small_perimeter_speed", coFloatOrPercent);
|
||||
def->label = "Small perimeters";
|
||||
|
@ -1327,11 +1163,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
{
|
||||
ConfigOptionStrings* opt = new ConfigOptionStrings();
|
||||
opt->values.push_back("; Filament gcode\n");
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionStrings { "; Filament gcode\n" };
|
||||
|
||||
def = this->add("single_extruder_multi_material", coBool);
|
||||
def->label = "Single Extruder Multi Material";
|
||||
|
@ -1522,11 +1354,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->full_label = "Temperature";
|
||||
def->max = 0;
|
||||
def->max = 500;
|
||||
{
|
||||
ConfigOptionInts* opt = new ConfigOptionInts();
|
||||
opt->values.push_back(200);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionInts { 200 };
|
||||
|
||||
def = this->add("thin_walls", coBool);
|
||||
def->label = "Detect thin walls";
|
||||
|
@ -1619,11 +1447,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->label = "Wipe while retracting";
|
||||
def->tooltip = "This flag will move the nozzle while retracting to minimize the possible blob on leaky extruders.";
|
||||
def->cli = "wipe!";
|
||||
{
|
||||
ConfigOptionBools* opt = new ConfigOptionBools();
|
||||
opt->values.push_back(false);
|
||||
def->default_value = opt;
|
||||
}
|
||||
def->default_value = new ConfigOptionBools { false };
|
||||
|
||||
def = this->add("wipe_tower", coBool);
|
||||
def->label = "Enable";
|
||||
|
@ -1798,7 +1622,7 @@ std::string DynamicPrintConfig::validate()
|
|||
{
|
||||
// Full print config is initialized from the defaults.
|
||||
FullPrintConfig fpc;
|
||||
fpc.apply(*this);
|
||||
fpc.apply(*this, true);
|
||||
// Verify this print options through the FullPrintConfig.
|
||||
return fpc.validate();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ extern std::string normalize_utf8_nfc(const char *src);
|
|||
extern std::string timestamp_str();
|
||||
// Standard "generated by Slic3r version xxx timestamp xxx" header string,
|
||||
// to be placed at the top of Slic3r generated files.
|
||||
inline std::string header_slic3r_generated() { return std::string("generated by Slic3r " SLIC3R_VERSION " on ") + timestamp_str(); }
|
||||
inline std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_FORK_NAME " " SLIC3R_VERSION " " ) + timestamp_str(); }
|
||||
|
||||
// Compute the next highest power of 2 of 32-bit v
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html
|
||||
|
|
|
@ -237,21 +237,13 @@ std::string normalize_utf8_nfc(const char *src)
|
|||
|
||||
std::string timestamp_str()
|
||||
{
|
||||
#if 1
|
||||
std::time_t now;
|
||||
time(&now);
|
||||
char buf[sizeof "0000-00-00 00:00:00"];
|
||||
strftime(buf, sizeof(buf), "%F %T", gmtime(&now));
|
||||
#else
|
||||
const auto now = boost::posix_time::second_clock::local_time();
|
||||
const auto date = now.date();
|
||||
char buf[2048];
|
||||
sprintf(buf, "on %04d-%02d-%02d at %02d:%02d:%02d",
|
||||
SLIC3R_VERSION,
|
||||
// Local date in an ANSII format.
|
||||
int(now.date().year()), int(now.date().month()), int(now.date().day()),
|
||||
int(now.time_of_day().hours()), int(now.time_of_day().minutes()), int(now.time_of_day().seconds()));
|
||||
#endif
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue