Reddish background when detected out of print volume toolpaths
This commit is contained in:
parent
c2ab8c2ae3
commit
3a1ec8285e
8 changed files with 57 additions and 18 deletions
|
@ -215,6 +215,7 @@ sub new {
|
|||
if ($Slic3r::GUI::have_OpenGL) {
|
||||
$self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{gcode_preview_data}, $self->{config});
|
||||
Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 1);
|
||||
Slic3r::GUI::_3DScene::enable_dynamic_background($self->{preview3D}->canvas, 1);
|
||||
Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{preview3D}->canvas, sub { Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas); });
|
||||
$self->{preview_notebook}->AddPage($self->{preview3D}, L('Preview'));
|
||||
$self->{preview3D_page_idx} = $self->{preview_notebook}->GetPageCount-1;
|
||||
|
|
|
@ -1787,6 +1787,11 @@ void _3DScene::enable_force_zoom_to_bed(wxGLCanvas* canvas, bool enable)
|
|||
s_canvas_mgr.enable_force_zoom_to_bed(canvas, enable);
|
||||
}
|
||||
|
||||
void _3DScene::enable_dynamic_background(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
s_canvas_mgr.enable_dynamic_background(canvas, enable);
|
||||
}
|
||||
|
||||
void _3DScene::allow_multisample(wxGLCanvas* canvas, bool allow)
|
||||
{
|
||||
s_canvas_mgr.allow_multisample(canvas, allow);
|
||||
|
|
|
@ -499,6 +499,7 @@ public:
|
|||
static void enable_gizmos(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_shader(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_force_zoom_to_bed(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_dynamic_background(wxGLCanvas* canvas, bool enable);
|
||||
static void allow_multisample(wxGLCanvas* canvas, bool allow);
|
||||
|
||||
static void zoom_to_bed(wxGLCanvas* canvas);
|
||||
|
|
|
@ -51,6 +51,9 @@ static const float UNIT_MATRIX[] = { 1.0f, 0.0f, 0.0f, 0.0f,
|
|||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
static const float DEFAULT_BG_COLOR[3] = { 10.0f / 255.0f, 98.0f / 255.0f, 144.0f / 255.0f };
|
||||
static const float ERROR_BG_COLOR[3] = { 144.0f / 255.0f, 49.0f / 255.0f, 10.0f / 255.0f };
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
@ -1703,6 +1706,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
|||
, m_picking_enabled(false)
|
||||
, m_moving_enabled(false)
|
||||
, m_shader_enabled(false)
|
||||
, m_dynamic_background_enabled(false)
|
||||
, m_multisample_allowed(false)
|
||||
, m_color_by("volume")
|
||||
, m_select_by("object")
|
||||
|
@ -2067,6 +2071,11 @@ void GLCanvas3D::enable_force_zoom_to_bed(bool enable)
|
|||
m_force_zoom_to_bed_enabled = enable;
|
||||
}
|
||||
|
||||
void GLCanvas3D::enable_dynamic_background(bool enable)
|
||||
{
|
||||
m_dynamic_background_enabled = enable;
|
||||
}
|
||||
|
||||
void GLCanvas3D::allow_multisample(bool allow)
|
||||
{
|
||||
m_multisample_allowed = allow;
|
||||
|
@ -3431,8 +3440,6 @@ void GLCanvas3D::_render_background() const
|
|||
{
|
||||
::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
static const float COLOR[3] = { 10.0f / 255.0f, 98.0f / 255.0f, 144.0f / 255.0f };
|
||||
|
||||
::glPushMatrix();
|
||||
::glLoadIdentity();
|
||||
::glMatrixMode(GL_PROJECTION);
|
||||
|
@ -3444,11 +3451,16 @@ void GLCanvas3D::_render_background() const
|
|||
|
||||
::glBegin(GL_QUADS);
|
||||
::glColor3f(0.0f, 0.0f, 0.0f);
|
||||
::glVertex3f(-1.0f, -1.0f, 1.0f);
|
||||
::glVertex3f(1.0f, -1.0f, 1.0f);
|
||||
::glColor3f(COLOR[0], COLOR[1], COLOR[2]);
|
||||
::glVertex3f(1.0f, 1.0f, 1.0f);
|
||||
::glVertex3f(-1.0f, 1.0f, 1.0f);
|
||||
::glVertex2f(-1.0f, -1.0f);
|
||||
::glVertex2f(1.0f, -1.0f);
|
||||
|
||||
if (m_dynamic_background_enabled && _is_any_volume_outside())
|
||||
::glColor3f(ERROR_BG_COLOR[0], ERROR_BG_COLOR[1], ERROR_BG_COLOR[2]);
|
||||
else
|
||||
::glColor3f(DEFAULT_BG_COLOR[0], DEFAULT_BG_COLOR[1], DEFAULT_BG_COLOR[2]);
|
||||
|
||||
::glVertex2f(1.0f, 1.0f);
|
||||
::glVertex2f(-1.0f, 1.0f);
|
||||
::glEnd();
|
||||
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
@ -4772,17 +4784,7 @@ void GLCanvas3D::_update_toolpath_volumes_outside_state()
|
|||
|
||||
void GLCanvas3D::_show_warning_texture_if_needed()
|
||||
{
|
||||
bool detected_outside = false;
|
||||
for (const GLVolume* volume : m_volumes.volumes)
|
||||
{
|
||||
if ((volume != nullptr) && volume->is_outside)
|
||||
{
|
||||
detected_outside = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (detected_outside)
|
||||
if (_is_any_volume_outside())
|
||||
{
|
||||
enable_warning_texture(true);
|
||||
_generate_warning_texture(L("Detected toolpath outside print volume"));
|
||||
|
@ -4899,5 +4901,16 @@ void GLCanvas3D::_reset_warning_texture()
|
|||
m_warning_texture.reset();
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_is_any_volume_outside() const
|
||||
{
|
||||
for (const GLVolume* volume : m_volumes.volumes)
|
||||
{
|
||||
if ((volume != nullptr) && volume->is_outside)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -449,6 +449,7 @@ private:
|
|||
bool m_picking_enabled;
|
||||
bool m_moving_enabled;
|
||||
bool m_shader_enabled;
|
||||
bool m_dynamic_background_enabled;
|
||||
bool m_multisample_allowed;
|
||||
|
||||
std::string m_color_by;
|
||||
|
@ -539,6 +540,7 @@ public:
|
|||
void enable_gizmos(bool enable);
|
||||
void enable_shader(bool enable);
|
||||
void enable_force_zoom_to_bed(bool enable);
|
||||
void enable_dynamic_background(bool enable);
|
||||
void allow_multisample(bool allow);
|
||||
|
||||
void zoom_to_bed();
|
||||
|
@ -682,6 +684,8 @@ private:
|
|||
void _generate_warning_texture(const std::string& msg);
|
||||
void _reset_warning_texture();
|
||||
|
||||
bool _is_any_volume_outside() const;
|
||||
|
||||
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
||||
};
|
||||
|
||||
|
|
|
@ -418,6 +418,13 @@ void GLCanvas3DManager::enable_force_zoom_to_bed(wxGLCanvas* canvas, bool enable
|
|||
it->second->enable_force_zoom_to_bed(enable);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::enable_dynamic_background(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->enable_dynamic_background(enable);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::allow_multisample(wxGLCanvas* canvas, bool allow)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
|
|
@ -112,6 +112,7 @@ public:
|
|||
void enable_gizmos(wxGLCanvas* canvas, bool enable);
|
||||
void enable_shader(wxGLCanvas* canvas, bool enable);
|
||||
void enable_force_zoom_to_bed(wxGLCanvas* canvas, bool enable);
|
||||
void enable_dynamic_background(wxGLCanvas* canvas, bool enable);
|
||||
void allow_multisample(wxGLCanvas* canvas, bool allow);
|
||||
|
||||
void zoom_to_bed(wxGLCanvas* canvas);
|
||||
|
|
|
@ -430,6 +430,13 @@ enable_force_zoom_to_bed(canvas, enable)
|
|||
CODE:
|
||||
_3DScene::enable_force_zoom_to_bed((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable);
|
||||
|
||||
void
|
||||
enable_dynamic_background(canvas, enable)
|
||||
SV *canvas;
|
||||
bool enable;
|
||||
CODE:
|
||||
_3DScene::enable_dynamic_background((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable);
|
||||
|
||||
void
|
||||
allow_multisample(canvas, allow)
|
||||
SV *canvas;
|
||||
|
|
Loading…
Reference in a new issue