GCodeProcessor/GCodeViewer -> Extract bed shape from gcode files generated by PrusaSlicer
This commit is contained in:
parent
16e282110d
commit
9d4344a78c
@ -356,6 +356,10 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
|
|||||||
m_filament_diameters.push_back(static_cast<float>(diam));
|
m_filament_diameters.push_back(static_cast<float>(diam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ConfigOptionPoints* bed_shape = config.option<ConfigOptionPoints>("bed_shape");
|
||||||
|
if (bed_shape != nullptr)
|
||||||
|
m_result.bed_shape = bed_shape->values;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeProcessor::enable_stealth_time_estimator(bool enabled)
|
void GCodeProcessor::enable_stealth_time_estimator(bool enabled)
|
||||||
|
@ -210,11 +210,27 @@ namespace Slic3r {
|
|||||||
{
|
{
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
std::vector<MoveVertex> moves;
|
std::vector<MoveVertex> moves;
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
|
Pointfs bed_shape;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
long long time{ 0 };
|
long long time{ 0 };
|
||||||
void reset() { time = 0; moves = std::vector<MoveVertex>(); }
|
void reset()
|
||||||
|
{
|
||||||
|
time = 0;
|
||||||
|
moves = std::vector<MoveVertex>();
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
|
bed_shape = Pointfs();
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void reset() { moves = std::vector<MoveVertex>(); }
|
void reset()
|
||||||
|
{
|
||||||
|
moves = std::vector<MoveVertex>();
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
|
bed_shape = Pointfs();
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -323,14 +323,20 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print&
|
|||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_AS_STATE
|
#if ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
||||||
// adjust printbed size in dependence of toolpaths bbox
|
Pointfs bed_shape;
|
||||||
const double margin = 10.0;
|
if (!gcode_result.bed_shape.empty())
|
||||||
Vec2d min(m_paths_bounding_box.min(0) - margin, m_paths_bounding_box.min(1) - margin);
|
// bed shape detected in the gcode
|
||||||
Vec2d max(m_paths_bounding_box.max(0) + margin, m_paths_bounding_box.max(1) + margin);
|
bed_shape = gcode_result.bed_shape;
|
||||||
Pointfs bed_shape = { { min(0), min(1) },
|
else {
|
||||||
{ max(0), min(1) },
|
// adjust printbed size in dependence of toolpaths bbox
|
||||||
{ max(0), max(1) },
|
const double margin = 10.0;
|
||||||
{ min(0), max(1) } };
|
Vec2d min(m_paths_bounding_box.min(0) - margin, m_paths_bounding_box.min(1) - margin);
|
||||||
|
Vec2d max(m_paths_bounding_box.max(0) + margin, m_paths_bounding_box.max(1) + margin);
|
||||||
|
bed_shape = { { min(0), min(1) },
|
||||||
|
{ max(0), min(1) },
|
||||||
|
{ max(0), max(1) },
|
||||||
|
{ min(0), max(1) } };
|
||||||
|
}
|
||||||
wxGetApp().plater()->set_bed_shape(bed_shape, "", "");
|
wxGetApp().plater()->set_bed_shape(bed_shape, "", "");
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER_AS_STATE
|
#endif // ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
|
Loading…
Reference in New Issue
Block a user