mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
GCode Preview - Added visualization of volumetric flow rate
This commit is contained in:
parent
78d1d83583
commit
4a179c81d2
5 changed files with 28 additions and 1 deletions
|
@ -69,6 +69,7 @@ sub new {
|
||||||
$choice_view_type->Append(L("Height"));
|
$choice_view_type->Append(L("Height"));
|
||||||
$choice_view_type->Append(L("Width"));
|
$choice_view_type->Append(L("Width"));
|
||||||
$choice_view_type->Append(L("Speed"));
|
$choice_view_type->Append(L("Speed"));
|
||||||
|
$choice_view_type->Append(L("Volumetric flow rate"));
|
||||||
$choice_view_type->Append(L("Tool"));
|
$choice_view_type->Append(L("Tool"));
|
||||||
$choice_view_type->SetSelection(0);
|
$choice_view_type->SetSelection(0);
|
||||||
|
|
||||||
|
|
|
@ -670,14 +670,16 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
||||||
float z = FLT_MAX;
|
float z = FLT_MAX;
|
||||||
Polyline polyline;
|
Polyline polyline;
|
||||||
Pointf3 position(FLT_MAX, FLT_MAX, FLT_MAX);
|
Pointf3 position(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||||
|
float volumetric_rate = FLT_MAX;
|
||||||
GCodePreviewData::Range height_range;
|
GCodePreviewData::Range height_range;
|
||||||
GCodePreviewData::Range width_range;
|
GCodePreviewData::Range width_range;
|
||||||
GCodePreviewData::Range feedrate_range;
|
GCodePreviewData::Range feedrate_range;
|
||||||
|
GCodePreviewData::Range volumetric_rate_range;
|
||||||
|
|
||||||
// constructs the polylines while traversing the moves
|
// constructs the polylines while traversing the moves
|
||||||
for (const GCodeMove& move : extrude_moves->second)
|
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
|
// store current polyline
|
||||||
polyline.remove_duplicate_points();
|
polyline.remove_duplicate_points();
|
||||||
|
@ -693,9 +695,11 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
||||||
// update current values
|
// update current values
|
||||||
data = move.data;
|
data = move.data;
|
||||||
z = move.start_position.z;
|
z = move.start_position.z;
|
||||||
|
volumetric_rate = move.data.feedrate * (float)move.data.mm3_per_mm;
|
||||||
height_range.update_from(move.data.height);
|
height_range.update_from(move.data.height);
|
||||||
width_range.update_from(move.data.width);
|
width_range.update_from(move.data.width);
|
||||||
feedrate_range.update_from(move.data.feedrate);
|
feedrate_range.update_from(move.data.feedrate);
|
||||||
|
volumetric_rate_range.update_from(volumetric_rate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// append end vertex of the move to current polyline
|
// append end vertex of the move to current polyline
|
||||||
|
@ -713,6 +717,7 @@ void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& previ
|
||||||
preview_data.ranges.height.set_from(height_range);
|
preview_data.ranges.height.set_from(height_range);
|
||||||
preview_data.ranges.width.set_from(width_range);
|
preview_data.ranges.width.set_from(width_range);
|
||||||
preview_data.ranges.feedrate.set_from(feedrate_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)
|
void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data)
|
||||||
|
|
|
@ -235,6 +235,7 @@ void GCodePreviewData::set_default()
|
||||||
::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * 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.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.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();
|
extrusion.set_default();
|
||||||
travel.set_default();
|
travel.set_default();
|
||||||
|
@ -248,6 +249,7 @@ void GCodePreviewData::reset()
|
||||||
ranges.width.reset();
|
ranges.width.reset();
|
||||||
ranges.height.reset();
|
ranges.height.reset();
|
||||||
ranges.feedrate.reset();
|
ranges.feedrate.reset();
|
||||||
|
ranges.volumetric_rate.reset();
|
||||||
extrusion.layers.clear();
|
extrusion.layers.clear();
|
||||||
travel.polylines.clear();
|
travel.polylines.clear();
|
||||||
retraction.positions.clear();
|
retraction.positions.clear();
|
||||||
|
@ -279,6 +281,11 @@ const GCodePreviewData::Color& GCodePreviewData::get_feedrate_color(float feedra
|
||||||
return 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)
|
void GCodePreviewData::set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < Extrusion::Num_Extrusion_Roles; ++i)
|
for (unsigned int i = 0; i < Extrusion::Num_Extrusion_Roles; ++i)
|
||||||
|
@ -345,6 +352,8 @@ std::string GCodePreviewData::get_legend_title() const
|
||||||
return L("Width (mm)");
|
return L("Width (mm)");
|
||||||
case Extrusion::Feedrate:
|
case Extrusion::Feedrate:
|
||||||
return L("Speed (mm/s)");
|
return L("Speed (mm/s)");
|
||||||
|
case Extrusion::VolumetricRate:
|
||||||
|
return L("Volumetric flow rate (mm3/s)");
|
||||||
case Extrusion::Tool:
|
case Extrusion::Tool:
|
||||||
return L("Tool");
|
return L("Tool");
|
||||||
}
|
}
|
||||||
|
@ -402,6 +411,11 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
|
||||||
Helper::FillListFromRange(items, ranges.feedrate, 0, 1.0f);
|
Helper::FillListFromRange(items, ranges.feedrate, 0, 1.0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Extrusion::VolumetricRate:
|
||||||
|
{
|
||||||
|
Helper::FillListFromRange(items, ranges.volumetric_rate, 3, 1.0f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Extrusion::Tool:
|
case Extrusion::Tool:
|
||||||
{
|
{
|
||||||
unsigned int tools_colors_count = tool_colors.size() / 4;
|
unsigned int tools_colors_count = tool_colors.size() / 4;
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
Range height;
|
Range height;
|
||||||
Range width;
|
Range width;
|
||||||
Range feedrate;
|
Range feedrate;
|
||||||
|
Range volumetric_rate;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LegendItem
|
struct LegendItem
|
||||||
|
@ -70,6 +71,7 @@ public:
|
||||||
Height,
|
Height,
|
||||||
Width,
|
Width,
|
||||||
Feedrate,
|
Feedrate,
|
||||||
|
VolumetricRate,
|
||||||
Tool,
|
Tool,
|
||||||
Num_View_Types
|
Num_View_Types
|
||||||
};
|
};
|
||||||
|
@ -190,6 +192,7 @@ public:
|
||||||
const Color& get_height_color(float height) const;
|
const Color& get_height_color(float height) const;
|
||||||
const Color& get_width_color(float width) const;
|
const Color& get_width_color(float width) const;
|
||||||
const Color& get_feedrate_color(float feedrate) 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_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);
|
void set_extrusion_paths_colors(const std::vector<std::string>& colors);
|
||||||
|
|
|
@ -2039,6 +2039,8 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
|
||||||
return path.width;
|
return path.width;
|
||||||
case GCodePreviewData::Extrusion::Feedrate:
|
case GCodePreviewData::Extrusion::Feedrate:
|
||||||
return path.feedrate;
|
return path.feedrate;
|
||||||
|
case GCodePreviewData::Extrusion::VolumetricRate:
|
||||||
|
return path.feedrate * (float)path.mm3_per_mm;
|
||||||
case GCodePreviewData::Extrusion::Tool:
|
case GCodePreviewData::Extrusion::Tool:
|
||||||
return (float)path.extruder_id;
|
return (float)path.extruder_id;
|
||||||
}
|
}
|
||||||
|
@ -2058,6 +2060,8 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
|
||||||
return data.get_width_color(value);
|
return data.get_width_color(value);
|
||||||
case GCodePreviewData::Extrusion::Feedrate:
|
case GCodePreviewData::Extrusion::Feedrate:
|
||||||
return data.get_feedrate_color(value);
|
return data.get_feedrate_color(value);
|
||||||
|
case GCodePreviewData::Extrusion::VolumetricRate:
|
||||||
|
return data.get_volumetric_rate_color(value);
|
||||||
case GCodePreviewData::Extrusion::Tool:
|
case GCodePreviewData::Extrusion::Tool:
|
||||||
{
|
{
|
||||||
static GCodePreviewData::Color color;
|
static GCodePreviewData::Color color;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue