Ported from the playground branch. Various documentation and optimization.

This commit is contained in:
bubnikv 2016-09-13 13:30:00 +02:00
parent a5b7f14dfa
commit 620c6c7378
38 changed files with 586 additions and 92 deletions

View file

@ -1,3 +1,20 @@
// Configuration store of Slic3r.
//
// The configuration store is either static or dynamic.
// DynamicPrintConfig is used mainly at the user interface. while the StaticPrintConfig is used
// during the slicing and the g-code generation.
//
// The classes derived from StaticPrintConfig form a following hierarchy.
// Virtual inheritance is used for some of the parent objects.
//
// FullPrintConfig
// PrintObjectConfig
// PrintRegionConfig
// PrintConfig
// GCodeConfig
// HostConfig
//
#ifndef slic3r_PrintConfig_hpp_
#define slic3r_PrintConfig_hpp_
@ -22,7 +39,7 @@ enum SupportMaterialPattern {
};
enum SeamPosition {
spRandom, spNearest, spAligned
spRandom, spNearest, spAligned //, spPreferred
};
template<> inline t_config_enum_values ConfigOptionEnum<GCodeFlavor>::get_enum_values() {
@ -65,17 +82,23 @@ template<> inline t_config_enum_values ConfigOptionEnum<SeamPosition>::get_enum_
keys_map["random"] = spRandom;
keys_map["nearest"] = spNearest;
keys_map["aligned"] = spAligned;
// keys_map["preferred"] = spPreferred;
return keys_map;
}
// Defines each and every confiuration option of Slic3r, including the properties of the GUI dialogs.
// Does not store the actual values, but defines default values.
class PrintConfigDef : public ConfigDef
{
public:
PrintConfigDef();
};
// The one and only global definition of SLic3r configuration options.
// This definition is constant.
extern PrintConfigDef print_config_def;
// Slic3r configuration storage with print_config_def assigned.
class PrintConfigBase : public virtual ConfigBase
{
public:
@ -86,6 +109,12 @@ class PrintConfigBase : public virtual ConfigBase
double min_object_distance() const;
};
// Slic3r dynamic configuration, used to override the configuration
// per object, per modification volume or per printing material.
// The dynamic configuration is also used to store user modifications of the print global parameters,
// so the modified configuration values may be diffed against the active configuration
// to invalidate the proper slicing resp. g-code generation processing steps.
// This object is mapped to Perl as Slic3r::Config.
class DynamicPrintConfig : public PrintConfigBase, public DynamicConfig
{
public:
@ -93,12 +122,14 @@ class DynamicPrintConfig : public PrintConfigBase, public DynamicConfig
void normalize();
};
class StaticPrintConfig : public PrintConfigBase, public StaticConfig
{
public:
StaticPrintConfig() : PrintConfigBase(), StaticConfig() {};
};
// This object is mapped to Perl as Slic3r::Config::PrintObject.
class PrintObjectConfig : public virtual StaticPrintConfig
{
public:
@ -110,6 +141,8 @@ class PrintObjectConfig : public virtual StaticPrintConfig
ConfigOptionFloat layer_height;
ConfigOptionInt raft_layers;
ConfigOptionEnum<SeamPosition> seam_position;
// ConfigOptionFloat seam_preferred_direction;
// ConfigOptionFloat seam_preferred_direction_jitter;
ConfigOptionBool support_material;
ConfigOptionInt support_material_angle;
ConfigOptionFloat support_material_contact_distance;
@ -130,7 +163,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
if (initialize)
this->set_defaults();
}
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(dont_support_bridges);
OPT_PTR(extrusion_width);
@ -140,6 +173,8 @@ class PrintObjectConfig : public virtual StaticPrintConfig
OPT_PTR(layer_height);
OPT_PTR(raft_layers);
OPT_PTR(seam_position);
// OPT_PTR(seam_preferred_direction);
// OPT_PTR(seam_preferred_direction_jitter);
OPT_PTR(support_material);
OPT_PTR(support_material_angle);
OPT_PTR(support_material_contact_distance);
@ -160,6 +195,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
};
};
// This object is mapped to Perl as Slic3r::Config::PrintRegion.
class PrintRegionConfig : public virtual StaticPrintConfig
{
public:
@ -200,7 +236,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig
if (initialize)
this->set_defaults();
}
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(bottom_solid_layers);
OPT_PTR(bridge_flow_ratio);
@ -239,6 +275,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig
};
};
// This object is mapped to Perl as Slic3r::Config::GCode.
class GCodeConfig : public virtual StaticPrintConfig
{
public:
@ -315,6 +352,7 @@ class GCodeConfig : public virtual StaticPrintConfig
};
};
// This object is mapped to Perl as Slic3r::Config::Print.
class PrintConfig : public GCodeConfig
{
public:
@ -373,7 +411,7 @@ class PrintConfig : public GCodeConfig
if (initialize)
this->set_defaults();
}
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(avoid_crossing_perimeters);
OPT_PTR(bed_shape);
@ -446,7 +484,7 @@ class HostConfig : public virtual StaticPrintConfig
if (initialize)
this->set_defaults();
}
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(octoprint_host);
OPT_PTR(octoprint_apikey);
@ -457,6 +495,7 @@ class HostConfig : public virtual StaticPrintConfig
};
};
// This object is mapped to Perl as Slic3r::Config::Full.
class FullPrintConfig
: public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig
{