3DScene mark_volumes_for_layer_height method moved to c++
This commit is contained in:
parent
c3b1eca2c7
commit
5ee5465f94
@ -273,14 +273,6 @@ sub new {
|
||||
$self->_variable_layer_thickness_action(undef);
|
||||
});
|
||||
|
||||
#==============================================================================================================================
|
||||
my $on_mark_volumes_for_layer_height = sub {
|
||||
$self->mark_volumes_for_layer_height;
|
||||
};
|
||||
|
||||
Slic3r::GUI::_3DScene::register_on_mark_volumes_for_layer_height_callback($self, $on_mark_volumes_for_layer_height);
|
||||
#==============================================================================================================================
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -1677,9 +1669,9 @@ sub Render {
|
||||
# $self->draw_legend;
|
||||
#
|
||||
# $self->draw_active_object_annotations;
|
||||
#
|
||||
# $self->SwapBuffers();
|
||||
#==============================================================================================================================
|
||||
|
||||
$self->SwapBuffers();
|
||||
}
|
||||
|
||||
#==============================================================================================================================
|
||||
@ -1721,34 +1713,23 @@ sub Render {
|
||||
# glDisable(GL_BLEND);
|
||||
# glEnable(GL_CULL_FACE);
|
||||
#}
|
||||
#==============================================================================================================================
|
||||
|
||||
sub mark_volumes_for_layer_height {
|
||||
my ($self) = @_;
|
||||
|
||||
foreach my $volume_idx (0..$#{$self->volumes}) {
|
||||
my $volume = $self->volumes->[$volume_idx];
|
||||
my $object_id = int($volume->select_group_id / 1000000);
|
||||
#==============================================================================================================================
|
||||
my $shader = Slic3r::GUI::_3DScene::get_layers_editing_shader($self);
|
||||
|
||||
if (Slic3r::GUI::_3DScene::is_layers_editing_enabled($self) && $shader && $volume->selected &&
|
||||
$volume->has_layer_height_texture && $object_id < $self->{print}->object_count) {
|
||||
$volume->set_layer_height_texture_data(Slic3r::GUI::_3DScene::get_layers_editing_z_texture_id($self), $shader->shader_program_id,
|
||||
$self->{print}->get_object($object_id), Slic3r::GUI::_3DScene::get_layers_editing_cursor_z_relative($self), Slic3r::GUI::_3DScene::get_layers_editing_band_width($self));
|
||||
|
||||
#
|
||||
#sub mark_volumes_for_layer_height {
|
||||
# my ($self) = @_;
|
||||
#
|
||||
# foreach my $volume_idx (0..$#{$self->volumes}) {
|
||||
# my $volume = $self->volumes->[$volume_idx];
|
||||
# my $object_id = int($volume->select_group_id / 1000000);
|
||||
# if ($self->layer_editing_enabled && $volume->selected && $self->{layer_height_edit_shader} &&
|
||||
# $volume->has_layer_height_texture && $object_id < $self->{print}->object_count) {
|
||||
# $volume->set_layer_height_texture_data($self->{layer_preview_z_texture_id}, $self->{layer_height_edit_shader}->shader_program_id,
|
||||
# $self->{print}->get_object($object_id), $self->_variable_layer_thickness_bar_mouse_cursor_z_relative, $self->{layer_height_edit_band_width});
|
||||
#==============================================================================================================================
|
||||
} else {
|
||||
$volume->reset_layer_height_texture_data();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#==============================================================================================================================
|
||||
# } else {
|
||||
# $volume->reset_layer_height_texture_data();
|
||||
# }
|
||||
# }
|
||||
#}
|
||||
#
|
||||
#sub _load_image_set_texture {
|
||||
# my ($self, $file_name) = @_;
|
||||
# # Load a PNG with an alpha channel.
|
||||
|
@ -2065,7 +2065,7 @@ void _3DScene::set_layers_editing_last_action(wxGLCanvas* canvas, unsigned int a
|
||||
s_canvas_mgr.set_layers_editing_last_action(canvas, action);
|
||||
}
|
||||
|
||||
GLShader* _3DScene::get_layers_editing_shader(wxGLCanvas* canvas)
|
||||
const GLShader* _3DScene::get_layers_editing_shader(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_layers_editing_shader(canvas);
|
||||
}
|
||||
@ -2135,11 +2135,6 @@ void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* c
|
||||
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);
|
||||
}
|
||||
|
||||
void _3DScene::register_on_mark_volumes_for_layer_height_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_on_mark_volumes_for_layer_height_callback(canvas, callback);
|
||||
}
|
||||
|
||||
//void _3DScene::_glew_init()
|
||||
//{
|
||||
// glewInit();
|
||||
|
@ -634,7 +634,7 @@ public:
|
||||
static unsigned int get_layers_editing_last_action(wxGLCanvas* canvas);
|
||||
static void set_layers_editing_last_action(wxGLCanvas* canvas, unsigned int action);
|
||||
|
||||
static GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
||||
static const GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
||||
|
||||
static float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas);
|
||||
static int get_layers_editing_first_selected_object_id(wxGLCanvas* canvas, unsigned int objects_count);
|
||||
@ -655,7 +655,6 @@ public:
|
||||
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);
|
||||
static void register_on_mark_volumes_for_layer_height_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
// static void _glew_init();
|
||||
//##################################################################################################################
|
||||
|
@ -559,7 +559,7 @@ void GLCanvas3D::Shader::set_uniform(const std::string& name, float value) const
|
||||
m_shader->set_uniform(name.c_str(), value);
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3D::Shader::get_shader()
|
||||
const GLShader* GLCanvas3D::Shader::get_shader() const
|
||||
{
|
||||
return m_shader;
|
||||
}
|
||||
@ -739,7 +739,7 @@ void GLCanvas3D::LayersEditing::render(const GLCanvas3D& canvas, const PrintObje
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3D::LayersEditing::get_shader()
|
||||
const GLShader* GLCanvas3D::LayersEditing::get_shader() const
|
||||
{
|
||||
return m_shader.get_shader();
|
||||
}
|
||||
@ -1532,6 +1532,9 @@ void GLCanvas3D::stop_using_shader() const
|
||||
|
||||
void GLCanvas3D::render(bool useVBOs) const
|
||||
{
|
||||
if (m_canvas == nullptr)
|
||||
return;
|
||||
|
||||
Pointf3 neg_target = get_camera_target().negative();
|
||||
::glTranslatef((GLfloat)neg_target.x, (GLfloat)neg_target.y, (GLfloat)neg_target.z);
|
||||
|
||||
@ -1556,6 +1559,8 @@ void GLCanvas3D::render(bool useVBOs) const
|
||||
_render_warning_texture();
|
||||
_render_legend_texture();
|
||||
_render_layer_editing_overlay();
|
||||
|
||||
m_canvas->SwapBuffers();
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3D::get_layers_editing_z_texture_id() const
|
||||
@ -1613,7 +1618,7 @@ void GLCanvas3D::set_layers_editing_last_action(unsigned int action)
|
||||
m_layers_editing.set_last_action(action);
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3D::get_layers_editing_shader()
|
||||
const GLShader* GLCanvas3D::get_layers_editing_shader() const
|
||||
{
|
||||
return m_layers_editing.get_shader();
|
||||
}
|
||||
@ -1718,12 +1723,6 @@ void GLCanvas3D::register_on_viewport_changed_callback(void* callback)
|
||||
m_on_viewport_changed_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::register_on_mark_volumes_for_layer_height_callback(void* callback)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
m_on_mark_volumes_for_layer_height_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_size(wxSizeEvent& evt)
|
||||
{
|
||||
set_dirty(true);
|
||||
@ -1942,7 +1941,27 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co
|
||||
void GLCanvas3D::_deregister_callbacks()
|
||||
{
|
||||
m_on_viewport_changed_callback.deregister_callback();
|
||||
m_on_mark_volumes_for_layer_height_callback.deregister_callback();
|
||||
}
|
||||
|
||||
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
||||
{
|
||||
if ((m_volumes == nullptr) || (m_print == nullptr))
|
||||
return;
|
||||
|
||||
for (GLVolume* vol : m_volumes->volumes)
|
||||
{
|
||||
int object_id = int(vol->select_group_id / 1000000);
|
||||
const GLShader* shader = get_layers_editing_shader();
|
||||
|
||||
if (is_layers_editing_enabled() && (shader != nullptr) && vol->selected &&
|
||||
vol->has_layer_height_texture() && (object_id < (int)m_print->objects.size()))
|
||||
{
|
||||
vol->set_layer_height_texture_data(get_layers_editing_z_texture_id(), shader->shader_program_id,
|
||||
m_print->get_object(object_id), get_layers_editing_cursor_z_relative(), get_layers_editing_band_width());
|
||||
}
|
||||
else
|
||||
vol->reset_layer_height_texture_data();
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::_refresh_if_shown_on_screen()
|
||||
@ -2068,7 +2087,7 @@ void GLCanvas3D::_render_objects(bool useVBOs) const
|
||||
{
|
||||
if (is_picking_enabled())
|
||||
{
|
||||
m_on_mark_volumes_for_layer_height_callback.call();
|
||||
_mark_volumes_for_layer_height();
|
||||
|
||||
if (m_config != nullptr)
|
||||
{
|
||||
|
@ -194,7 +194,7 @@ public:
|
||||
|
||||
void set_uniform(const std::string& name, float value) const;
|
||||
|
||||
GLShader* get_shader();
|
||||
const GLShader* get_shader() const;
|
||||
|
||||
private:
|
||||
void _reset();
|
||||
@ -255,7 +255,7 @@ public:
|
||||
|
||||
void render(const GLCanvas3D& canvas, const PrintObject& print_object, const GLVolume& volume) const;
|
||||
|
||||
GLShader* get_shader();
|
||||
const GLShader* get_shader() const;
|
||||
|
||||
static float get_cursor_z_relative(const GLCanvas3D& canvas);
|
||||
static int get_first_selected_object_id(const GLVolumeCollection& volumes, unsigned int objects_count);
|
||||
@ -315,7 +315,6 @@ private:
|
||||
bool m_multisample_allowed;
|
||||
|
||||
PerlCallback m_on_viewport_changed_callback;
|
||||
PerlCallback m_on_mark_volumes_for_layer_height_callback;
|
||||
|
||||
public:
|
||||
GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
||||
@ -418,7 +417,7 @@ public:
|
||||
unsigned int get_layers_editing_last_action() const;
|
||||
void set_layers_editing_last_action(unsigned int action);
|
||||
|
||||
GLShader* get_layers_editing_shader();
|
||||
const GLShader* get_layers_editing_shader() const;
|
||||
|
||||
float get_layers_editing_cursor_z_relative() const;
|
||||
int get_layers_editing_first_selected_object_id(unsigned int objects_count) const;
|
||||
@ -439,7 +438,6 @@ public:
|
||||
void render_texture(unsigned int tex_id, float left, float right, float bottom, float top) const;
|
||||
|
||||
void register_on_viewport_changed_callback(void* callback);
|
||||
void register_on_mark_volumes_for_layer_height_callback(void* callback);
|
||||
|
||||
void on_size(wxSizeEvent& evt);
|
||||
void on_idle(wxIdleEvent& evt);
|
||||
@ -455,6 +453,7 @@ private:
|
||||
|
||||
void _deregister_callbacks();
|
||||
|
||||
void _mark_volumes_for_layer_height() const;
|
||||
void _refresh_if_shown_on_screen();
|
||||
|
||||
void _picking_pass() const;
|
||||
|
@ -546,7 +546,7 @@ void GLCanvas3DManager::set_layers_editing_last_action(wxGLCanvas* canvas, unsig
|
||||
it->second->set_layers_editing_last_action(action);
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3DManager::get_layers_editing_shader(wxGLCanvas* canvas)
|
||||
const GLShader* GLCanvas3DManager::get_layers_editing_shader(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->get_layers_editing_shader() : nullptr;
|
||||
@ -638,13 +638,6 @@ void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas
|
||||
it->second->register_on_viewport_changed_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::register_on_mark_volumes_for_layer_height_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->register_on_mark_volumes_for_layer_height_callback(callback);
|
||||
}
|
||||
|
||||
GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas)
|
||||
{
|
||||
return (canvas == nullptr) ? m_canvases.end() : m_canvases.find(canvas);
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
unsigned int get_layers_editing_last_action(wxGLCanvas* canvas) const;
|
||||
void set_layers_editing_last_action(wxGLCanvas* canvas, unsigned int action);
|
||||
|
||||
GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
||||
const GLShader* get_layers_editing_shader(wxGLCanvas* canvas) const;
|
||||
|
||||
float get_layers_editing_cursor_z_relative(wxGLCanvas* canvas) const;
|
||||
int get_layers_editing_first_selected_object_id(wxGLCanvas* canvas, unsigned int objects_count) const;
|
||||
@ -155,7 +155,6 @@ public:
|
||||
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);
|
||||
void register_on_mark_volumes_for_layer_height_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
private:
|
||||
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
|
||||
|
@ -762,13 +762,6 @@ register_on_viewport_changed_callback(canvas, callback)
|
||||
CODE:
|
||||
_3DScene::register_on_viewport_changed_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback);
|
||||
|
||||
void
|
||||
register_on_mark_volumes_for_layer_height_callback(canvas, callback)
|
||||
SV *canvas;
|
||||
SV *callback;
|
||||
CODE:
|
||||
_3DScene::register_on_mark_volumes_for_layer_height_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback);
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
|
Loading…
Reference in New Issue
Block a user