3DScene update_volumes_colors_by_extruder method moved to c++

This commit is contained in:
Enrico Turri 2018-05-29 15:07:06 +02:00
parent 5ee5465f94
commit df14a3c399
11 changed files with 64 additions and 22 deletions

View file

@ -1985,13 +1985,13 @@ sub Render {
# }
# }
#}
#
#sub update_volumes_colors_by_extruder {
# my ($self, $config) = @_;
# $self->volumes->update_colors_by_extruder($config);
#}
#==============================================================================================================================
sub update_volumes_colors_by_extruder {
my ($self, $config) = @_;
$self->volumes->update_colors_by_extruder($config);
}
sub opengl_info
{
my ($self, %params) = @_;

View file

@ -245,7 +245,10 @@ sub reload_scene {
}
}
$self->update_volumes_colors_by_extruder($self->{config});
#==============================================================================================================================
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self);
# $self->update_volumes_colors_by_extruder($self->{config});
#==============================================================================================================================
# checks for geometry outside the print volume to render it accordingly
if (scalar @{$self->volumes} > 0)

View file

@ -119,12 +119,14 @@ sub new {
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas);
Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ Slic3r::GUI::_3DScene::get_volumes_bounding_box($canvas)->size }));
# Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size }));
# $canvas->set_auto_bed_shape;
#==============================================================================================================================
$canvas->SetSize([500,500]);
$canvas->SetMinSize($canvas->GetSize);
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_config($canvas, $self->GetParent->{config});
#==============================================================================================================================
}
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
@ -264,12 +266,13 @@ sub _update {
$self->{canvas}->load_object($_, undef, undef, [0]) for @objects;
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_cutting_plane($self->{canvas}, $self->{cut_options}{z}, [@expolygons]);
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
# $self->{canvas}->SetCuttingPlane(
# $self->{cut_options}{z},
# [@expolygons],
# );
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config});
#==============================================================================================================================
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config});
$self->{canvas}->Render;
}
}

View file

@ -169,12 +169,15 @@ sub new {
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas);
Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ Slic3r::GUI::_3DScene::get_volumes_bounding_box($canvas)->size }));
# Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size }));
# $canvas->set_auto_bed_shape;
#==============================================================================================================================
$canvas->SetSize([500,700]);
$canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_config($canvas, $self->GetParent->GetParent->GetParent->{config});
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($canvas);
# $canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
}
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
@ -506,9 +509,10 @@ sub _parts_changed {
$self->{canvas}->load_object($self->{model_object});
#==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_volumes($self->{canvas});
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
# $self->{canvas}->zoom_to_volumes;
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
$self->{canvas}->Render;
}
}
@ -563,7 +567,10 @@ sub _update_canvas {
}
}
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
$self->{canvas}->Render;
}
}
@ -591,7 +598,10 @@ sub _update {
# $self->{canvas}->reset_objects;
#==============================================================================================================================
$self->{canvas}->load_object($_, undef, [0]) for @objects;
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
$self->{canvas}->Render;
}

View file

@ -2105,6 +2105,11 @@ void _3DScene::select_view(wxGLCanvas* canvas, const std::string& direction)
s_canvas_mgr.select_view(canvas, direction);
}
void _3DScene::update_volumes_colors_by_extruder(wxGLCanvas* canvas)
{
s_canvas_mgr.update_volumes_colors_by_extruder(canvas);
}
bool _3DScene::start_using_shader(wxGLCanvas* canvas)
{
return s_canvas_mgr.start_using_shader(canvas);

View file

@ -645,13 +645,13 @@ public:
static void zoom_to_volumes(wxGLCanvas* canvas);
static void select_view(wxGLCanvas* canvas, const std::string& direction);
static void update_volumes_colors_by_extruder(wxGLCanvas* canvas);
static bool start_using_shader(wxGLCanvas* canvas);
static void stop_using_shader(wxGLCanvas* canvas);
static void render(wxGLCanvas* canvas);
static void render_volumes(wxGLCanvas* canvas, bool fake_colors);
static void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top);
static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);

View file

@ -1520,6 +1520,14 @@ void GLCanvas3D::select_view(const std::string& direction)
}
}
void GLCanvas3D::update_volumes_colors_by_extruder()
{
if ((m_volumes == nullptr) || (m_config == nullptr))
return;
m_volumes->update_colors_by_extruder(m_config);
}
bool GLCanvas3D::start_using_shader() const
{
return m_shader.start_using();

View file

@ -428,13 +428,13 @@ public:
void zoom_to_volumes();
void select_view(const std::string& direction);
void update_volumes_colors_by_extruder();
bool start_using_shader() const;
void stop_using_shader() const;
void render(bool useVBOs) const;
void render_volumes(bool fake_colors) const;
void render_texture(unsigned int tex_id, float left, float right, float bottom, float top) const;
void register_on_viewport_changed_callback(void* callback);

View file

@ -597,6 +597,13 @@ void GLCanvas3DManager::select_view(wxGLCanvas* canvas, const std::string& direc
it->second->select_view(direction);
}
void GLCanvas3DManager::update_volumes_colors_by_extruder(wxGLCanvas* canvas)
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
if (it != m_canvases.end())
it->second->update_volumes_colors_by_extruder();
}
bool GLCanvas3DManager::start_using_shader(wxGLCanvas* canvas) const
{
CanvasesMap::const_iterator it = _get_canvas(canvas);

View file

@ -145,13 +145,13 @@ public:
void zoom_to_volumes(wxGLCanvas* canvas);
void select_view(wxGLCanvas* canvas, const std::string& direction);
void update_volumes_colors_by_extruder(wxGLCanvas* canvas);
bool start_using_shader(wxGLCanvas* canvas) const;
void stop_using_shader(wxGLCanvas* canvas) const;
void render(wxGLCanvas* canvas) const;
void render_volumes(wxGLCanvas* canvas, bool fake_colors) const;
void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) const;
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);

View file

@ -717,6 +717,12 @@ select_view(canvas, direction)
CODE:
_3DScene::select_view((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), direction);
void
update_volumes_colors_by_extruder(canvas)
SV *canvas;
CODE:
_3DScene::update_volumes_colors_by_extruder((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
bool
start_using_shader(canvas)
SV *canvas;