mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 08:55:58 +08:00
#7326 - Fixed crash when starting GCodeViewer
This commit is contained in:
parent
1b7975639e
commit
a4baecb340
@ -252,12 +252,16 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
|||||||
BoundingBoxf3 Bed3D::calc_extended_bounding_box() const
|
BoundingBoxf3 Bed3D::calc_extended_bounding_box() const
|
||||||
{
|
{
|
||||||
BoundingBoxf3 out { m_build_volume.bounding_volume() };
|
BoundingBoxf3 out { m_build_volume.bounding_volume() };
|
||||||
|
const Vec3d size = out.size();
|
||||||
|
// ensures that the bounding box is set as defined or the following calls to merge() will not work as intented
|
||||||
|
if (size.x() > 0.0 && size.y() > 0.0 && !out.defined)
|
||||||
|
out.defined = true;
|
||||||
// Reset the build volume Z, we don't want to zoom to the top of the build volume if it is empty.
|
// Reset the build volume Z, we don't want to zoom to the top of the build volume if it is empty.
|
||||||
out.min.z() = 0;
|
out.min.z() = 0.0;
|
||||||
out.max.z() = 0;
|
out.max.z() = 0.0;
|
||||||
// extend to contain axes
|
// extend to contain axes
|
||||||
out.merge(m_axes.get_origin() + m_axes.get_total_length() * Vec3d::Ones());
|
out.merge(m_axes.get_origin() + m_axes.get_total_length() * Vec3d::Ones());
|
||||||
out.merge(out.min + Vec3d(-Axes::DefaultTipRadius, -Axes::DefaultTipRadius, out.max(2)));
|
out.merge(out.min + Vec3d(-Axes::DefaultTipRadius, -Axes::DefaultTipRadius, out.max.z()));
|
||||||
// extend to contain model, if any
|
// extend to contain model, if any
|
||||||
BoundingBoxf3 model_bb = m_model.get_bounding_box();
|
BoundingBoxf3 model_bb = m_model.get_bounding_box();
|
||||||
if (model_bb.defined) {
|
if (model_bb.defined) {
|
||||||
|
@ -1119,6 +1119,8 @@ void GLCanvas3D::reset_volumes()
|
|||||||
|
|
||||||
ModelInstanceEPrintVolumeState GLCanvas3D::check_volumes_outside_state() const
|
ModelInstanceEPrintVolumeState GLCanvas3D::check_volumes_outside_state() const
|
||||||
{
|
{
|
||||||
|
assert(m_initialized);
|
||||||
|
|
||||||
ModelInstanceEPrintVolumeState state;
|
ModelInstanceEPrintVolumeState state;
|
||||||
m_volumes.check_outside_state(m_bed.build_volume(), &state);
|
m_volumes.check_outside_state(m_bed.build_volume(), &state);
|
||||||
return state;
|
return state;
|
||||||
|
@ -486,7 +486,7 @@ void MainFrame::update_layout()
|
|||||||
case ESettingsLayout::GCodeViewer:
|
case ESettingsLayout::GCodeViewer:
|
||||||
{
|
{
|
||||||
m_main_sizer->Add(m_plater, 1, wxEXPAND);
|
m_main_sizer->Add(m_plater, 1, wxEXPAND);
|
||||||
m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, 0, {}, {}, true);
|
m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, 0.0, {}, {}, true);
|
||||||
m_plater->get_collapse_toolbar().set_enabled(false);
|
m_plater->get_collapse_toolbar().set_enabled(false);
|
||||||
m_plater->collapse_sidebar(true);
|
m_plater->collapse_sidebar(true);
|
||||||
m_plater->Show();
|
m_plater->Show();
|
||||||
|
@ -3867,18 +3867,20 @@ void Plater::priv::set_current_panel(wxPanel* panel)
|
|||||||
|
|
||||||
preview->get_canvas3d()->bind_event_handlers();
|
preview->get_canvas3d()->bind_event_handlers();
|
||||||
|
|
||||||
// see: Plater::priv::object_list_changed()
|
if (wxGetApp().is_editor()) {
|
||||||
// FIXME: it may be better to have a single function making this check and let it be called wherever needed
|
// see: Plater::priv::object_list_changed()
|
||||||
bool export_in_progress = this->background_process.is_export_scheduled();
|
// FIXME: it may be better to have a single function making this check and let it be called wherever needed
|
||||||
bool model_fits = view3D->get_canvas3d()->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside;
|
bool export_in_progress = this->background_process.is_export_scheduled();
|
||||||
if (!model.objects.empty() && !export_in_progress && model_fits) {
|
bool model_fits = view3D->get_canvas3d()->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside;
|
||||||
|
if (!model.objects.empty() && !export_in_progress && model_fits) {
|
||||||
#if ENABLE_SEAMS_USING_MODELS
|
#if ENABLE_SEAMS_USING_MODELS
|
||||||
preview->get_canvas3d()->init_gcode_viewer();
|
preview->get_canvas3d()->init_gcode_viewer();
|
||||||
#endif // ENABLE_SEAMS_USING_MODELS
|
#endif // ENABLE_SEAMS_USING_MODELS
|
||||||
q->reslice();
|
q->reslice();
|
||||||
|
}
|
||||||
|
// keeps current gcode preview, if any
|
||||||
|
preview->reload_print(true);
|
||||||
}
|
}
|
||||||
// keeps current gcode preview, if any
|
|
||||||
preview->reload_print(true);
|
|
||||||
|
|
||||||
preview->set_as_dirty();
|
preview->set_as_dirty();
|
||||||
// reset cached size to force a resize on next call to render() to keep imgui in synch with canvas size
|
// reset cached size to force a resize on next call to render() to keep imgui in synch with canvas size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user