mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Merge branch 'master' into wipe_tower_improvements
This commit is contained in:
commit
eb9917536c
27 changed files with 457 additions and 170 deletions
|
@ -1443,10 +1443,10 @@ namespace Slic3r {
|
|||
IdToObjectDataMap m_objects_data;
|
||||
|
||||
public:
|
||||
bool save_model_to_file(const std::string& filename, Model& model, const Print& print);
|
||||
bool save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config);
|
||||
|
||||
private:
|
||||
bool _save_model_to_file(const std::string& filename, Model& model, const Print& print);
|
||||
bool _save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config);
|
||||
bool _add_content_types_file_to_archive(mz_zip_archive& archive);
|
||||
bool _add_relationships_file_to_archive(mz_zip_archive& archive);
|
||||
bool _add_model_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
|
@ -1457,13 +1457,13 @@ namespace Slic3r {
|
|||
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model);
|
||||
};
|
||||
|
||||
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const Print& print)
|
||||
bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config)
|
||||
{
|
||||
clear_errors();
|
||||
return _save_model_to_file(filename, model, print);
|
||||
return _save_model_to_file(filename, model, print, export_print_config);
|
||||
}
|
||||
|
||||
bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const Print& print)
|
||||
bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const Print& print, bool export_print_config)
|
||||
{
|
||||
mz_zip_archive archive;
|
||||
mz_zip_zero_struct(&archive);
|
||||
|
@ -1502,11 +1502,14 @@ namespace Slic3r {
|
|||
}
|
||||
|
||||
// adds slic3r print config file
|
||||
if (!_add_print_config_file_to_archive(archive, print))
|
||||
if (export_print_config)
|
||||
{
|
||||
mz_zip_writer_end(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
return false;
|
||||
if (!_add_print_config_file_to_archive(archive, print))
|
||||
{
|
||||
mz_zip_writer_end(&archive);
|
||||
boost::filesystem::remove(filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// adds slic3r model config file
|
||||
|
@ -1863,13 +1866,13 @@ namespace Slic3r {
|
|||
return res;
|
||||
}
|
||||
|
||||
bool store_3mf(const char* path, Model* model, Print* print)
|
||||
bool store_3mf(const char* path, Model* model, Print* print, bool export_print_config)
|
||||
{
|
||||
if ((path == nullptr) || (model == nullptr) || (print == nullptr))
|
||||
return false;
|
||||
|
||||
_3MF_Exporter exporter;
|
||||
bool res = exporter.save_model_to_file(path, *model, *print);
|
||||
bool res = exporter.save_model_to_file(path, *model, *print, export_print_config);
|
||||
|
||||
if (!res)
|
||||
exporter.log_errors();
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Slic3r {
|
|||
|
||||
// Save the given model and the config data contained in the given Print into a 3mf file.
|
||||
// The model could be modified during the export process if meshes are not repaired or have no shared vertices
|
||||
extern bool store_3mf(const char* path, Model* model, Print* print);
|
||||
extern bool store_3mf(const char* path, Model* model, Print* print, bool export_print_config);
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
|
|
|
@ -576,8 +576,7 @@ bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf");
|
||||
if (internal_amf_filename != stat.m_filename)
|
||||
if (!boost::iends_with(stat.m_filename, ".amf"))
|
||||
{
|
||||
printf("Found invalid internal filename\n");
|
||||
mz_zip_reader_end(&archive);
|
||||
|
@ -644,15 +643,20 @@ bool load_amf(const char *path, PresetBundle* bundle, Model *model)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool store_amf(const char *path, Model *model, Print* print)
|
||||
bool store_amf(const char *path, Model *model, Print* print, bool export_print_config)
|
||||
{
|
||||
if ((path == nullptr) || (model == nullptr) || (print == nullptr))
|
||||
return false;
|
||||
|
||||
// forces ".zip.amf" extension
|
||||
std::string export_path = path;
|
||||
if (!boost::iends_with(export_path, ".zip.amf"))
|
||||
export_path = boost::filesystem::path(export_path).replace_extension(".zip.amf").string();
|
||||
|
||||
mz_zip_archive archive;
|
||||
mz_zip_zero_struct(&archive);
|
||||
|
||||
mz_bool res = mz_zip_writer_init_file(&archive, path, 0);
|
||||
mz_bool res = mz_zip_writer_init_file(&archive, export_path.c_str(), 0);
|
||||
if (res == 0)
|
||||
return false;
|
||||
|
||||
|
@ -661,9 +665,12 @@ bool store_amf(const char *path, Model *model, Print* print)
|
|||
stream << "<amf unit=\"millimeter\">\n";
|
||||
stream << "<metadata type=\"cad\">Slic3r " << SLIC3R_VERSION << "</metadata>\n";
|
||||
|
||||
std::string config = "\n";
|
||||
GCode::append_full_config(*print, config);
|
||||
stream << "<metadata type=\"" << SLIC3R_CONFIG_TYPE << "\">" << config << "</metadata>\n";
|
||||
if (export_print_config)
|
||||
{
|
||||
std::string config = "\n";
|
||||
GCode::append_full_config(*print, config);
|
||||
stream << "<metadata type=\"" << SLIC3R_CONFIG_TYPE << "\">" << config << "</metadata>\n";
|
||||
}
|
||||
|
||||
for (const auto &material : model->materials) {
|
||||
if (material.first.empty())
|
||||
|
@ -767,20 +774,20 @@ bool store_amf(const char *path, Model *model, Print* print)
|
|||
}
|
||||
stream << "</amf>\n";
|
||||
|
||||
std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf");
|
||||
std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(export_path).filename().string(), ".zip.amf", ".amf");
|
||||
std::string out = stream.str();
|
||||
|
||||
if (!mz_zip_writer_add_mem(&archive, internal_amf_filename.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION))
|
||||
{
|
||||
mz_zip_writer_end(&archive);
|
||||
boost::filesystem::remove(path);
|
||||
boost::filesystem::remove(export_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mz_zip_writer_finalize_archive(&archive))
|
||||
{
|
||||
mz_zip_writer_end(&archive);
|
||||
boost::filesystem::remove(path);
|
||||
boost::filesystem::remove(export_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ extern bool load_amf(const char *path, PresetBundle* bundle, Model *model);
|
|||
|
||||
// Save the given model and the config data contained in the given Print into an amf file.
|
||||
// The model could be modified during the export process if meshes are not repaired or have no shared vertices
|
||||
extern bool store_amf(const char *path, Model *model, Print* print);
|
||||
extern bool store_amf(const char *path, Model *model, Print* print, bool export_print_config);
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ GCodeAnalyzer::GCodeAnalyzer()
|
|||
void GCodeAnalyzer::reset()
|
||||
{
|
||||
_set_units(Millimeters);
|
||||
_set_positioning_xyz_type(Absolute);
|
||||
_set_positioning_e_type(Relative);
|
||||
_set_global_positioning_type(Absolute);
|
||||
_set_e_local_positioning_type(Absolute);
|
||||
_set_extrusion_role(erNone);
|
||||
_set_extruder_id(DEFAULT_EXTRUDER_ID);
|
||||
_set_mm3_per_mm(Default_mm3_per_mm);
|
||||
|
@ -177,6 +177,16 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi
|
|||
_processG1(line);
|
||||
break;
|
||||
}
|
||||
case 10: // Retract
|
||||
{
|
||||
_processG10(line);
|
||||
break;
|
||||
}
|
||||
case 11: // Unretract
|
||||
{
|
||||
_processG11(line);
|
||||
break;
|
||||
}
|
||||
case 22: // Firmware controlled Retract
|
||||
{
|
||||
_processG22(line);
|
||||
|
@ -237,13 +247,13 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi
|
|||
}
|
||||
|
||||
// Returns the new absolute position on the given axis in dependence of the given parameters
|
||||
float axis_absolute_position_from_G1_line(GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeAnalyzer::EUnits units, GCodeAnalyzer::EPositioningType type, float current_absolute_position)
|
||||
float axis_absolute_position_from_G1_line(GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeAnalyzer::EUnits units, bool is_relative, float current_absolute_position)
|
||||
{
|
||||
float lengthsScaleFactor = (units == GCodeAnalyzer::Inches) ? INCHES_TO_MM : 1.0f;
|
||||
if (lineG1.has(Slic3r::Axis(axis)))
|
||||
{
|
||||
float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor;
|
||||
return (type == GCodeAnalyzer::Absolute) ? ret : current_absolute_position + ret;
|
||||
return is_relative ? current_absolute_position + ret : ret;
|
||||
}
|
||||
else
|
||||
return current_absolute_position;
|
||||
|
@ -256,7 +266,11 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line)
|
|||
float new_pos[Num_Axis];
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, (a == E) ? _get_positioning_e_type() : _get_positioning_xyz_type(), _get_axis_position((EAxis)a));
|
||||
bool is_relative = (_get_global_positioning_type() == Relative);
|
||||
if (a == E)
|
||||
is_relative |= (_get_e_local_positioning_type() == Relative);
|
||||
|
||||
new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, is_relative, _get_axis_position((EAxis)a));
|
||||
}
|
||||
|
||||
// updates feedrate from line, if present
|
||||
|
@ -305,6 +319,18 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line)
|
|||
_store_move(type);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processG10(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
// stores retract move
|
||||
_store_move(GCodeMove::Retract);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processG11(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
// stores unretract move
|
||||
_store_move(GCodeMove::Unretract);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processG22(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
// stores retract move
|
||||
|
@ -319,12 +345,12 @@ void GCodeAnalyzer::_processG23(const GCodeReader::GCodeLine& line)
|
|||
|
||||
void GCodeAnalyzer::_processG90(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_xyz_type(Absolute);
|
||||
_set_global_positioning_type(Absolute);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processG91(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_xyz_type(Relative);
|
||||
_set_global_positioning_type(Relative);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line)
|
||||
|
@ -367,12 +393,12 @@ void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line)
|
|||
|
||||
void GCodeAnalyzer::_processM82(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_e_type(Absolute);
|
||||
_set_e_local_positioning_type(Absolute);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processM83(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_e_type(Relative);
|
||||
_set_e_local_positioning_type(Relative);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line)
|
||||
|
@ -466,24 +492,24 @@ GCodeAnalyzer::EUnits GCodeAnalyzer::_get_units() const
|
|||
return m_state.units;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_positioning_xyz_type(GCodeAnalyzer::EPositioningType type)
|
||||
void GCodeAnalyzer::_set_global_positioning_type(GCodeAnalyzer::EPositioningType type)
|
||||
{
|
||||
m_state.positioning_xyz_type = type;
|
||||
m_state.global_positioning_type = type;
|
||||
}
|
||||
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_xyz_type() const
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_global_positioning_type() const
|
||||
{
|
||||
return m_state.positioning_xyz_type;
|
||||
return m_state.global_positioning_type;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_positioning_e_type(GCodeAnalyzer::EPositioningType type)
|
||||
void GCodeAnalyzer::_set_e_local_positioning_type(GCodeAnalyzer::EPositioningType type)
|
||||
{
|
||||
m_state.positioning_e_type = type;
|
||||
m_state.e_local_positioning_type = type;
|
||||
}
|
||||
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_e_type() const
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_e_local_positioning_type() const
|
||||
{
|
||||
return m_state.positioning_e_type;
|
||||
return m_state.e_local_positioning_type;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_extrusion_role(ExtrusionRole extrusion_role)
|
||||
|
@ -648,14 +674,16 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
|||
float z = FLT_MAX;
|
||||
Polyline polyline;
|
||||
Pointf3 position(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
float volumetric_rate = FLT_MAX;
|
||||
GCodePreviewData::Range height_range;
|
||||
GCodePreviewData::Range width_range;
|
||||
GCodePreviewData::Range feedrate_range;
|
||||
GCodePreviewData::Range volumetric_rate_range;
|
||||
|
||||
// constructs the polylines while traversing the moves
|
||||
for (const GCodeMove& move : extrude_moves->second)
|
||||
{
|
||||
if ((data != move.data) || (data.feedrate != move.data.feedrate) || (z != move.start_position.z) || (position != move.start_position))
|
||||
if ((data != move.data) || (z != move.start_position.z) || (position != move.start_position) || (volumetric_rate != move.data.feedrate * (float)move.data.mm3_per_mm))
|
||||
{
|
||||
// store current polyline
|
||||
polyline.remove_duplicate_points();
|
||||
|
@ -671,9 +699,11 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
|||
// update current values
|
||||
data = move.data;
|
||||
z = move.start_position.z;
|
||||
volumetric_rate = move.data.feedrate * (float)move.data.mm3_per_mm;
|
||||
height_range.update_from(move.data.height);
|
||||
width_range.update_from(move.data.width);
|
||||
feedrate_range.update_from(move.data.feedrate);
|
||||
volumetric_rate_range.update_from(volumetric_rate);
|
||||
}
|
||||
else
|
||||
// append end vertex of the move to current polyline
|
||||
|
@ -688,9 +718,10 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
|||
Helper::store_polyline(polyline, data, z, preview_data);
|
||||
|
||||
// updates preview ranges data
|
||||
preview_data.extrusion.ranges.height.set_from(height_range);
|
||||
preview_data.extrusion.ranges.width.set_from(width_range);
|
||||
preview_data.extrusion.ranges.feedrate.set_from(feedrate_range);
|
||||
preview_data.ranges.height.set_from(height_range);
|
||||
preview_data.ranges.width.set_from(width_range);
|
||||
preview_data.ranges.feedrate.set_from(feedrate_range);
|
||||
preview_data.ranges.volumetric_rate.set_from(volumetric_rate_range);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data)
|
||||
|
@ -717,6 +748,10 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data)
|
|||
float feedrate = FLT_MAX;
|
||||
unsigned int extruder_id = -1;
|
||||
|
||||
GCodePreviewData::Range height_range;
|
||||
GCodePreviewData::Range width_range;
|
||||
GCodePreviewData::Range feedrate_range;
|
||||
|
||||
// constructs the polylines while traversing the moves
|
||||
for (const GCodeMove& move : travel_moves->second)
|
||||
{
|
||||
|
@ -745,11 +780,19 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data)
|
|||
type = move_type;
|
||||
feedrate = move.data.feedrate;
|
||||
extruder_id = move.data.extruder_id;
|
||||
height_range.update_from(move.data.height);
|
||||
width_range.update_from(move.data.width);
|
||||
feedrate_range.update_from(move.data.feedrate);
|
||||
}
|
||||
|
||||
// store last polyline
|
||||
polyline.remove_duplicate_points();
|
||||
Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data);
|
||||
|
||||
// updates preview ranges data
|
||||
preview_data.ranges.height.set_from(height_range);
|
||||
preview_data.ranges.width.set_from(width_range);
|
||||
preview_data.ranges.feedrate.set_from(feedrate_range);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_data)
|
||||
|
|
|
@ -90,8 +90,8 @@ private:
|
|||
struct State
|
||||
{
|
||||
EUnits units;
|
||||
EPositioningType positioning_xyz_type;
|
||||
EPositioningType positioning_e_type;
|
||||
EPositioningType global_positioning_type;
|
||||
EPositioningType e_local_positioning_type;
|
||||
Metadata data;
|
||||
Pointf3 start_position;
|
||||
float start_extrusion;
|
||||
|
@ -127,6 +127,12 @@ private:
|
|||
// Move
|
||||
void _processG1(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Retract
|
||||
void _processG10(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Unretract
|
||||
void _processG11(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Firmware controlled Retract
|
||||
void _processG22(const GCodeReader::GCodeLine& line);
|
||||
|
||||
|
@ -170,11 +176,11 @@ private:
|
|||
void _set_units(EUnits units);
|
||||
EUnits _get_units() const;
|
||||
|
||||
void _set_positioning_xyz_type(EPositioningType type);
|
||||
EPositioningType _get_positioning_xyz_type() const;
|
||||
void _set_global_positioning_type(EPositioningType type);
|
||||
EPositioningType _get_global_positioning_type() const;
|
||||
|
||||
void _set_positioning_e_type(EPositioningType type);
|
||||
EPositioningType _get_positioning_e_type() const;
|
||||
void _set_e_local_positioning_type(EPositioningType type);
|
||||
EPositioningType _get_e_local_positioning_type() const;
|
||||
|
||||
void _set_extrusion_role(ExtrusionRole extrusion_role);
|
||||
ExtrusionRole _get_extrusion_role() const;
|
||||
|
|
|
@ -85,6 +85,12 @@ void GCodePreviewData::Range::update_from(float value)
|
|||
max = std::max(max, value);
|
||||
}
|
||||
|
||||
void GCodePreviewData::Range::update_from(const Range& other)
|
||||
{
|
||||
min = std::min(min, other.min);
|
||||
max = std::max(max, other.max);
|
||||
}
|
||||
|
||||
void GCodePreviewData::Range::set_from(const Range& other)
|
||||
{
|
||||
min = other.min;
|
||||
|
@ -158,9 +164,6 @@ void GCodePreviewData::Extrusion::set_default()
|
|||
view_type = Default_View_Type;
|
||||
|
||||
::memcpy((void*)role_colors, (const void*)Default_Extrusion_Role_Colors, Num_Extrusion_Roles * sizeof(Color));
|
||||
::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
|
||||
::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
|
||||
::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
|
||||
|
||||
for (unsigned int i = 0; i < Num_Extrusion_Roles; ++i)
|
||||
{
|
||||
|
@ -198,6 +201,7 @@ void GCodePreviewData::Travel::set_default()
|
|||
width = Default_Width;
|
||||
height = Default_Height;
|
||||
::memcpy((void*)type_colors, (const void*)Default_Type_Colors, Num_Types * sizeof(Color));
|
||||
|
||||
is_visible = false;
|
||||
}
|
||||
|
||||
|
@ -228,6 +232,11 @@ GCodePreviewData::GCodePreviewData()
|
|||
|
||||
void GCodePreviewData::set_default()
|
||||
{
|
||||
::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
|
||||
::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
|
||||
::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
|
||||
::memcpy((void*)ranges.volumetric_rate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
|
||||
|
||||
extrusion.set_default();
|
||||
travel.set_default();
|
||||
retraction.set_default();
|
||||
|
@ -237,6 +246,10 @@ void GCodePreviewData::set_default()
|
|||
|
||||
void GCodePreviewData::reset()
|
||||
{
|
||||
ranges.width.reset();
|
||||
ranges.height.reset();
|
||||
ranges.feedrate.reset();
|
||||
ranges.volumetric_rate.reset();
|
||||
extrusion.layers.clear();
|
||||
travel.polylines.clear();
|
||||
retraction.positions.clear();
|
||||
|
@ -253,19 +266,24 @@ const GCodePreviewData::Color& GCodePreviewData::get_extrusion_role_color(Extrus
|
|||
return extrusion.role_colors[role];
|
||||
}
|
||||
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_extrusion_height_color(float height) const
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_height_color(float height) const
|
||||
{
|
||||
return extrusion.ranges.height.get_color_at(height);
|
||||
return ranges.height.get_color_at(height);
|
||||
}
|
||||
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_extrusion_width_color(float width) const
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_width_color(float width) const
|
||||
{
|
||||
return extrusion.ranges.width.get_color_at(width);
|
||||
return ranges.width.get_color_at(width);
|
||||
}
|
||||
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_extrusion_feedrate_color(float feedrate) const
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_feedrate_color(float feedrate) const
|
||||
{
|
||||
return extrusion.ranges.feedrate.get_color_at(feedrate);
|
||||
return ranges.feedrate.get_color_at(feedrate);
|
||||
}
|
||||
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_volumetric_rate_color(float rate) const
|
||||
{
|
||||
return ranges.volumetric_rate.get_color_at(rate);
|
||||
}
|
||||
|
||||
void GCodePreviewData::set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha)
|
||||
|
@ -334,6 +352,8 @@ std::string GCodePreviewData::get_legend_title() const
|
|||
return L("Width (mm)");
|
||||
case Extrusion::Feedrate:
|
||||
return L("Speed (mm/s)");
|
||||
case Extrusion::VolumetricRate:
|
||||
return L("Volumetric flow rate (mm3/s)");
|
||||
case Extrusion::Tool:
|
||||
return L("Tool");
|
||||
}
|
||||
|
@ -348,10 +368,11 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
|
|||
static void FillListFromRange(LegendItemsList& list, const Range& range, unsigned int decimals, float scale_factor)
|
||||
{
|
||||
list.reserve(Range::Colors_Count);
|
||||
|
||||
float step = range.step_size();
|
||||
for (unsigned int i = 0; i < Range::Colors_Count; ++i)
|
||||
{
|
||||
char buf[32];
|
||||
char buf[1024];
|
||||
sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (range.min + (float)i * step), decimals, scale_factor * (range.min + (float)(i + 1) * step));
|
||||
list.emplace_back(buf, range.colors[i]);
|
||||
}
|
||||
|
@ -377,17 +398,22 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
|
|||
}
|
||||
case Extrusion::Height:
|
||||
{
|
||||
Helper::FillListFromRange(items, extrusion.ranges.height, 3, 1.0f);
|
||||
Helper::FillListFromRange(items, ranges.height, 3, 1.0f);
|
||||
break;
|
||||
}
|
||||
case Extrusion::Width:
|
||||
{
|
||||
Helper::FillListFromRange(items, extrusion.ranges.width, 3, 1.0f);
|
||||
Helper::FillListFromRange(items, ranges.width, 3, 1.0f);
|
||||
break;
|
||||
}
|
||||
case Extrusion::Feedrate:
|
||||
{
|
||||
Helper::FillListFromRange(items, extrusion.ranges.feedrate, 0, 1.0f);
|
||||
Helper::FillListFromRange(items, ranges.feedrate, 0, 1.0f);
|
||||
break;
|
||||
}
|
||||
case Extrusion::VolumetricRate:
|
||||
{
|
||||
Helper::FillListFromRange(items, ranges.volumetric_rate, 3, 1.0f);
|
||||
break;
|
||||
}
|
||||
case Extrusion::Tool:
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
void reset();
|
||||
bool empty() const;
|
||||
void update_from(float value);
|
||||
void update_from(const Range& other);
|
||||
void set_from(const Range& other);
|
||||
float step_size() const;
|
||||
|
||||
|
@ -44,6 +45,14 @@ public:
|
|||
const Color& get_color_at_max() const;
|
||||
};
|
||||
|
||||
struct Ranges
|
||||
{
|
||||
Range height;
|
||||
Range width;
|
||||
Range feedrate;
|
||||
Range volumetric_rate;
|
||||
};
|
||||
|
||||
struct LegendItem
|
||||
{
|
||||
std::string text;
|
||||
|
@ -62,6 +71,7 @@ public:
|
|||
Height,
|
||||
Width,
|
||||
Feedrate,
|
||||
VolumetricRate,
|
||||
Tool,
|
||||
Num_View_Types
|
||||
};
|
||||
|
@ -71,13 +81,6 @@ public:
|
|||
static const std::string Default_Extrusion_Role_Names[Num_Extrusion_Roles];
|
||||
static const EViewType Default_View_Type;
|
||||
|
||||
struct Ranges
|
||||
{
|
||||
Range height;
|
||||
Range width;
|
||||
Range feedrate;
|
||||
};
|
||||
|
||||
struct Layer
|
||||
{
|
||||
float z;
|
||||
|
@ -91,7 +94,6 @@ public:
|
|||
EViewType view_type;
|
||||
Color role_colors[Num_Extrusion_Roles];
|
||||
std::string role_names[Num_Extrusion_Roles];
|
||||
Ranges ranges;
|
||||
LayersList layers;
|
||||
unsigned int role_flags;
|
||||
|
||||
|
@ -178,6 +180,7 @@ public:
|
|||
Retraction retraction;
|
||||
Retraction unretraction;
|
||||
Shell shell;
|
||||
Ranges ranges;
|
||||
|
||||
GCodePreviewData();
|
||||
|
||||
|
@ -186,9 +189,10 @@ public:
|
|||
bool empty() const;
|
||||
|
||||
const Color& get_extrusion_role_color(ExtrusionRole role) const;
|
||||
const Color& get_extrusion_height_color(float height) const;
|
||||
const Color& get_extrusion_width_color(float width) const;
|
||||
const Color& get_extrusion_feedrate_color(float feedrate) const;
|
||||
const Color& get_height_color(float height) const;
|
||||
const Color& get_width_color(float width) const;
|
||||
const Color& get_feedrate_color(float feedrate) const;
|
||||
const Color& get_volumetric_rate_color(float rate) const;
|
||||
|
||||
void set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha);
|
||||
void set_extrusion_paths_colors(const std::vector<std::string>& colors);
|
||||
|
|
|
@ -369,24 +369,24 @@ namespace Slic3r {
|
|||
return _state.units;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::set_positioning_xyz_type(GCodeTimeEstimator::EPositioningType type)
|
||||
void GCodeTimeEstimator::set_global_positioning_type(GCodeTimeEstimator::EPositioningType type)
|
||||
{
|
||||
_state.positioning_xyz_type = type;
|
||||
_state.global_positioning_type = type;
|
||||
}
|
||||
|
||||
GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_positioning_xyz_type() const
|
||||
GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_global_positioning_type() const
|
||||
{
|
||||
return _state.positioning_xyz_type;
|
||||
return _state.global_positioning_type;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::set_positioning_e_type(GCodeTimeEstimator::EPositioningType type)
|
||||
void GCodeTimeEstimator::set_e_local_positioning_type(GCodeTimeEstimator::EPositioningType type)
|
||||
{
|
||||
_state.positioning_e_type = type;
|
||||
_state.e_local_positioning_type = type;
|
||||
}
|
||||
|
||||
GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_positioning_e_type() const
|
||||
GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_e_local_positioning_type() const
|
||||
{
|
||||
return _state.positioning_e_type;
|
||||
return _state.e_local_positioning_type;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::add_additional_time(float timeSec)
|
||||
|
@ -408,8 +408,8 @@ namespace Slic3r {
|
|||
{
|
||||
set_units(Millimeters);
|
||||
set_dialect(gcfRepRap);
|
||||
set_positioning_xyz_type(Absolute);
|
||||
set_positioning_e_type(Relative);
|
||||
set_global_positioning_type(Absolute);
|
||||
set_e_local_positioning_type(Absolute);
|
||||
|
||||
set_feedrate(DEFAULT_FEEDRATE);
|
||||
set_acceleration(DEFAULT_ACCELERATION);
|
||||
|
@ -628,13 +628,13 @@ namespace Slic3r {
|
|||
}
|
||||
|
||||
// Returns the new absolute position on the given axis in dependence of the given parameters
|
||||
float axis_absolute_position_from_G1_line(GCodeTimeEstimator::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeTimeEstimator::EUnits units, GCodeTimeEstimator::EPositioningType type, float current_absolute_position)
|
||||
float axis_absolute_position_from_G1_line(GCodeTimeEstimator::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeTimeEstimator::EUnits units, bool is_relative, float current_absolute_position)
|
||||
{
|
||||
float lengthsScaleFactor = (units == GCodeTimeEstimator::Inches) ? INCHES_TO_MM : 1.0f;
|
||||
if (lineG1.has(Slic3r::Axis(axis)))
|
||||
{
|
||||
float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor;
|
||||
return (type == GCodeTimeEstimator::Absolute) ? ret : current_absolute_position + ret;
|
||||
return is_relative ? current_absolute_position + ret : ret;
|
||||
}
|
||||
else
|
||||
return current_absolute_position;
|
||||
|
@ -647,7 +647,11 @@ namespace Slic3r {
|
|||
float new_pos[Num_Axis];
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, (a == E) ? get_positioning_e_type() : get_positioning_xyz_type(), get_axis_position((EAxis)a));
|
||||
bool is_relative = (get_global_positioning_type() == Relative);
|
||||
if (a == E)
|
||||
is_relative |= (get_e_local_positioning_type() == Relative);
|
||||
|
||||
new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, is_relative, get_axis_position((EAxis)a));
|
||||
}
|
||||
|
||||
// updates feedrate from line, if present
|
||||
|
@ -865,14 +869,12 @@ namespace Slic3r {
|
|||
|
||||
void GCodeTimeEstimator::_processG90(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
set_positioning_xyz_type(Absolute);
|
||||
set_global_positioning_type(Absolute);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processG91(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
// TODO: THERE ARE DIALECT VARIANTS
|
||||
|
||||
set_positioning_xyz_type(Relative);
|
||||
set_global_positioning_type(Relative);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processG92(const GCodeReader::GCodeLine& line)
|
||||
|
@ -922,12 +924,12 @@ namespace Slic3r {
|
|||
|
||||
void GCodeTimeEstimator::_processM82(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
set_positioning_e_type(Absolute);
|
||||
set_e_local_positioning_type(Absolute);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processM83(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
set_positioning_e_type(Relative);
|
||||
set_e_local_positioning_type(Relative);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processM109(const GCodeReader::GCodeLine& line)
|
||||
|
|
|
@ -61,8 +61,8 @@ namespace Slic3r {
|
|||
{
|
||||
GCodeFlavor dialect;
|
||||
EUnits units;
|
||||
EPositioningType positioning_xyz_type;
|
||||
EPositioningType positioning_e_type;
|
||||
EPositioningType global_positioning_type;
|
||||
EPositioningType e_local_positioning_type;
|
||||
Axis axis[Num_Axis];
|
||||
float feedrate; // mm/s
|
||||
float acceleration; // mm/s^2
|
||||
|
@ -257,11 +257,11 @@ namespace Slic3r {
|
|||
void set_units(EUnits units);
|
||||
EUnits get_units() const;
|
||||
|
||||
void set_positioning_xyz_type(EPositioningType type);
|
||||
EPositioningType get_positioning_xyz_type() const;
|
||||
void set_global_positioning_type(EPositioningType type);
|
||||
EPositioningType get_global_positioning_type() const;
|
||||
|
||||
void set_positioning_e_type(EPositioningType type);
|
||||
EPositioningType get_positioning_e_type() const;
|
||||
void set_e_local_positioning_type(EPositioningType type);
|
||||
EPositioningType get_e_local_positioning_type() const;
|
||||
|
||||
void add_additional_time(float timeSec);
|
||||
void set_additional_time(float timeSec);
|
||||
|
|
|
@ -450,6 +450,8 @@ bool Model::fits_print_volume(const DynamicPrintConfig* config) const
|
|||
|
||||
BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values));
|
||||
BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height")));
|
||||
// Allow the objects to protrude below the print bed
|
||||
print_volume.min.z = -1e10;
|
||||
return print_volume.contains(transformed_bounding_box());
|
||||
}
|
||||
|
||||
|
@ -459,6 +461,8 @@ bool Model::fits_print_volume(const FullPrintConfig &config) const
|
|||
return true;
|
||||
BoundingBox bed_box_2D = get_extents(Polygon::new_scale(config.bed_shape.values));
|
||||
BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config.max_print_height));
|
||||
// Allow the objects to protrude below the print bed
|
||||
print_volume.min.z = -1e10;
|
||||
return print_volume.contains(transformed_bounding_box());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue