Fix of SPE-691 Slicer crash after extruder change

Added synchronization of GCodePreviewData between the front end / back end
(GCodePreview data is only used if PrintStep psGCodeExport is finished).
Added reset of GCodePreviewData on Print::apply() to conserve RAM.
This commit is contained in:
bubnikv 2018-12-19 14:47:16 +01:00
parent 354458ae73
commit e9990ed79e
12 changed files with 46 additions and 40 deletions

View file

@ -483,8 +483,9 @@ bool DynamicConfig::operator==(const DynamicConfig &rhs) const
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;
if (it1->first != it2->first || *it1->second != *it2->second)
// key or value differ
return false;
return it1 == it1_end && it2 == it2_end;
}

View file

@ -668,6 +668,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
{
static GCodePreviewData::Extrusion::Layer& get_layer_at_z(GCodePreviewData::Extrusion::LayersList& layers, float z)
{
//FIXME this has a terrible time complexity
for (GCodePreviewData::Extrusion::Layer& layer : layers)
{
// if layer found, return it
@ -863,20 +864,4 @@ size_t GCodeAnalyzer::memory_used() const
return out;
}
GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2)
{
return GCodePreviewData::Color(clamp(0.0f, 1.0f, c1.rgba[0] + c2.rgba[0]),
clamp(0.0f, 1.0f, c1.rgba[1] + c2.rgba[1]),
clamp(0.0f, 1.0f, c1.rgba[2] + c2.rgba[2]),
clamp(0.0f, 1.0f, c1.rgba[3] + c2.rgba[3]));
}
GCodePreviewData::Color operator * (float f, const GCodePreviewData::Color& color)
{
return GCodePreviewData::Color(clamp(0.0f, 1.0f, f * color.rgba[0]),
clamp(0.0f, 1.0f, f * color.rgba[1]),
clamp(0.0f, 1.0f, f * color.rgba[2]),
clamp(0.0f, 1.0f, f * color.rgba[3]));
}
} // namespace Slic3r

View file

@ -521,4 +521,20 @@ size_t GCodePreviewData::memory_used() const
sizeof(shell) + sizeof(ranges);
}
GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2)
{
return GCodePreviewData::Color(clamp(0.0f, 1.0f, c1.rgba[0] + c2.rgba[0]),
clamp(0.0f, 1.0f, c1.rgba[1] + c2.rgba[1]),
clamp(0.0f, 1.0f, c1.rgba[2] + c2.rgba[2]),
clamp(0.0f, 1.0f, c1.rgba[3] + c2.rgba[3]));
}
GCodePreviewData::Color operator * (float f, const GCodePreviewData::Color& color)
{
return GCodePreviewData::Color(clamp(0.0f, 1.0f, f * color.rgba[0]),
clamp(0.0f, 1.0f, f * color.rgba[1]),
clamp(0.0f, 1.0f, f * color.rgba[2]),
clamp(0.0f, 1.0f, f * color.rgba[3]));
}
} // namespace Slic3r

View file

@ -22,6 +22,7 @@ public:
static const Color Dummy;
};
// Color mapping from a <min, max> range into a smooth rainbow of 10 colors.
struct Range
{
static const unsigned int Colors_Count = 10;
@ -45,9 +46,13 @@ public:
struct Ranges
{
// Color mapping by layer height.
Range height;
// Color mapping by extrusion width.
Range width;
// Color mapping by feedrate.
Range feedrate;
// Color mapping by volumetric extrusion rate.
Range volumetric_rate;
};