mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 00:01:09 -06:00
Turn fill_density into percentage
This commit is contained in:
parent
30aa255bb5
commit
7421a7bf63
11 changed files with 54 additions and 16 deletions
|
@ -95,6 +95,8 @@ ConfigBase::get(t_config_option_key opt_key) {
|
|||
if (opt == NULL) return &PL_sv_undef;
|
||||
if (ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt)) {
|
||||
return newSVnv(optv->value);
|
||||
} else if (ConfigOptionPercent* optv = dynamic_cast<ConfigOptionPercent*>(opt)) {
|
||||
return newSVnv(optv->value);
|
||||
} else if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) {
|
||||
AV* av = newAV();
|
||||
av_fill(av, optv->values.size()-1);
|
||||
|
@ -257,6 +259,8 @@ DynamicConfig::option(const t_config_option_key opt_key, bool create) {
|
|||
opt = new ConfigOptionString ();
|
||||
} else if (optdef->type == coStrings) {
|
||||
opt = new ConfigOptionStrings ();
|
||||
} else if (optdef->type == coPercent) {
|
||||
opt = new ConfigOptionPercent ();
|
||||
} else if (optdef->type == coFloatOrPercent) {
|
||||
opt = new ConfigOptionFloatOrPercent ();
|
||||
} else if (optdef->type == coPoint) {
|
||||
|
|
|
@ -181,6 +181,30 @@ class ConfigOptionStrings : public ConfigOption, public ConfigOptionVector<std::
|
|||
};
|
||||
};
|
||||
|
||||
class ConfigOptionPercent : public ConfigOption
|
||||
{
|
||||
public:
|
||||
double value;
|
||||
ConfigOptionPercent() : value(0) {};
|
||||
|
||||
double get_abs_value(double ratio_over) const {
|
||||
return ratio_over * this->value / 100;
|
||||
};
|
||||
|
||||
std::string serialize() const {
|
||||
std::ostringstream ss;
|
||||
ss << this->value;
|
||||
std::string s(ss.str());
|
||||
s += "%";
|
||||
return s;
|
||||
};
|
||||
|
||||
void deserialize(std::string str) {
|
||||
// don't try to parse the trailing % since it's optional
|
||||
sscanf(str.c_str(), "%lf", &this->value);
|
||||
};
|
||||
};
|
||||
|
||||
class ConfigOptionFloatOrPercent : public ConfigOption
|
||||
{
|
||||
public:
|
||||
|
@ -360,6 +384,7 @@ enum ConfigOptionType {
|
|||
coInts,
|
||||
coString,
|
||||
coStrings,
|
||||
coPercent,
|
||||
coFloatOrPercent,
|
||||
coPoint,
|
||||
coPoints,
|
||||
|
|
|
@ -241,11 +241,12 @@ class PrintConfigDef
|
|||
Options["fill_angle"].cli = "fill-angle=i";
|
||||
Options["fill_angle"].max = 359;
|
||||
|
||||
Options["fill_density"].type = coFloat;
|
||||
Options["fill_density"].type = coPercent;
|
||||
Options["fill_density"].label = "Fill density";
|
||||
Options["fill_density"].category = "Infill";
|
||||
Options["fill_density"].tooltip = "Density of internal infill, expressed in the range 0 - 1.";
|
||||
Options["fill_density"].cli = "fill-density=f";
|
||||
Options["fill_density"].tooltip = "Density of internal infill, expressed in the range 0% - 100%.";
|
||||
Options["fill_density"].sidetext = "%";
|
||||
Options["fill_density"].cli = "fill-density=s";
|
||||
|
||||
Options["fill_pattern"].type = coEnum;
|
||||
Options["fill_pattern"].label = "Fill pattern";
|
||||
|
@ -962,7 +963,7 @@ class PrintRegionConfig : public virtual StaticConfig
|
|||
ConfigOptionInt bottom_solid_layers;
|
||||
ConfigOptionBool extra_perimeters;
|
||||
ConfigOptionInt fill_angle;
|
||||
ConfigOptionFloat fill_density;
|
||||
ConfigOptionPercent fill_density;
|
||||
ConfigOptionEnum<InfillPattern> fill_pattern;
|
||||
ConfigOptionInt infill_extruder;
|
||||
ConfigOptionFloatOrPercent infill_extrusion_width;
|
||||
|
@ -984,7 +985,7 @@ class PrintRegionConfig : public virtual StaticConfig
|
|||
this->bottom_solid_layers.value = 3;
|
||||
this->extra_perimeters.value = true;
|
||||
this->fill_angle.value = 45;
|
||||
this->fill_density.value = 0.4;
|
||||
this->fill_density.value = 40;
|
||||
this->fill_pattern.value = ipHoneycomb;
|
||||
this->infill_extruder.value = 1;
|
||||
this->infill_extrusion_width.value = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue