mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
Warning texture moved to c++
This commit is contained in:
parent
7cff6ef6db
commit
3fdc5e20a7
9 changed files with 230 additions and 76 deletions
|
@ -59,7 +59,6 @@ __PACKAGE__->mk_accessors( qw(_quat init
|
||||||
_layer_height_edited
|
_layer_height_edited
|
||||||
|
|
||||||
_legend_enabled
|
_legend_enabled
|
||||||
_warning_enabled
|
|
||||||
_mouse_dragging
|
_mouse_dragging
|
||||||
|
|
||||||
) );
|
) );
|
||||||
|
@ -193,7 +192,9 @@ sub new {
|
||||||
# $self->_zoom(1);
|
# $self->_zoom(1);
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
$self->_legend_enabled(0);
|
$self->_legend_enabled(0);
|
||||||
$self->_warning_enabled(0);
|
#==============================================================================================================================
|
||||||
|
# $self->_warning_enabled(0);
|
||||||
|
#==============================================================================================================================
|
||||||
$self->use_plain_shader(0);
|
$self->use_plain_shader(0);
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
# $self->_apply_zoom_to_volumes_filter(0);
|
# $self->_apply_zoom_to_volumes_filter(0);
|
||||||
|
@ -295,10 +296,12 @@ sub set_legend_enabled {
|
||||||
$self->_legend_enabled($value);
|
$self->_legend_enabled($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_warning_enabled {
|
#==============================================================================================================================
|
||||||
my ($self, $value) = @_;
|
#sub set_warning_enabled {
|
||||||
$self->_warning_enabled($value);
|
# my ($self, $value) = @_;
|
||||||
}
|
# $self->_warning_enabled($value);
|
||||||
|
#}
|
||||||
|
#==============================================================================================================================
|
||||||
|
|
||||||
sub Destroy {
|
sub Destroy {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
@ -1617,6 +1620,7 @@ sub Render {
|
||||||
|
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
Slic3r::GUI::_3DScene::render_cutting_plane($self);
|
Slic3r::GUI::_3DScene::render_cutting_plane($self);
|
||||||
|
Slic3r::GUI::_3DScene::render_warning_texture($self);
|
||||||
|
|
||||||
# if (defined $self->cutting_plane_z) {
|
# if (defined $self->cutting_plane_z) {
|
||||||
# # draw cutting plane
|
# # draw cutting plane
|
||||||
|
@ -1645,10 +1649,10 @@ sub Render {
|
||||||
# glVertexPointer_c(3, GL_FLOAT, 0, 0);
|
# glVertexPointer_c(3, GL_FLOAT, 0, 0);
|
||||||
# glDisableClientState(GL_VERTEX_ARRAY);
|
# glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
# }
|
# }
|
||||||
|
#
|
||||||
|
# # draw warning message
|
||||||
|
# $self->draw_warning;
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
|
|
||||||
# draw warning message
|
|
||||||
$self->draw_warning;
|
|
||||||
|
|
||||||
# draw gcode preview legend
|
# draw gcode preview legend
|
||||||
$self->draw_legend;
|
$self->draw_legend;
|
||||||
|
@ -1762,32 +1766,34 @@ sub _variable_layer_thickness_load_reset_image {
|
||||||
return $self->{layer_preview_reset_image}->{valid};
|
return $self->{layer_preview_reset_image}->{valid};
|
||||||
}
|
}
|
||||||
|
|
||||||
# Paint the tooltip.
|
#==============================================================================================================================
|
||||||
sub _render_image {
|
## Paint the tooltip.
|
||||||
my ($self, $image, $l, $r, $b, $t) = @_;
|
#sub _render_image {
|
||||||
$self->_render_texture($image->{texture_id}, $l, $r, $b, $t);
|
# my ($self, $image, $l, $r, $b, $t) = @_;
|
||||||
}
|
# $self->_render_texture($image->{texture_id}, $l, $r, $b, $t);
|
||||||
|
#}
|
||||||
sub _render_texture {
|
#
|
||||||
my ($self, $tex_id, $l, $r, $b, $t) = @_;
|
#sub _render_texture {
|
||||||
|
# my ($self, $tex_id, $l, $r, $b, $t) = @_;
|
||||||
glColor4f(1.,1.,1.,1.);
|
#
|
||||||
glDisable(GL_LIGHTING);
|
# glColor4f(1.,1.,1.,1.);
|
||||||
glEnable(GL_BLEND);
|
# glDisable(GL_LIGHTING);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
# glEnable(GL_BLEND);
|
||||||
glEnable(GL_TEXTURE_2D);
|
# glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glBindTexture(GL_TEXTURE_2D, $tex_id);
|
# glEnable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
# glBindTexture(GL_TEXTURE_2D, $tex_id);
|
||||||
glTexCoord2d(0.,1.); glVertex3f($l, $b, 0);
|
# glBegin(GL_QUADS);
|
||||||
glTexCoord2d(1.,1.); glVertex3f($r, $b, 0);
|
# glTexCoord2d(0.,1.); glVertex3f($l, $b, 0);
|
||||||
glTexCoord2d(1.,0.); glVertex3f($r, $t, 0);
|
# glTexCoord2d(1.,1.); glVertex3f($r, $b, 0);
|
||||||
glTexCoord2d(0.,0.); glVertex3f($l, $t, 0);
|
# glTexCoord2d(1.,0.); glVertex3f($r, $t, 0);
|
||||||
glEnd();
|
# glTexCoord2d(0.,0.); glVertex3f($l, $t, 0);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
# glEnd();
|
||||||
glDisable(GL_TEXTURE_2D);
|
# glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glDisable(GL_BLEND);
|
# glDisable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_LIGHTING);
|
# glDisable(GL_BLEND);
|
||||||
}
|
# glEnable(GL_LIGHTING);
|
||||||
|
#}
|
||||||
|
#==============================================================================================================================
|
||||||
|
|
||||||
sub draw_active_object_annotations {
|
sub draw_active_object_annotations {
|
||||||
# $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking.
|
# $fakecolor is a boolean indicating, that the objects shall be rendered in a color coding the object index for picking.
|
||||||
|
@ -1857,16 +1863,20 @@ sub draw_active_object_annotations {
|
||||||
my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self);
|
my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self);
|
||||||
my $gap = 10/$zoom;
|
my $gap = 10/$zoom;
|
||||||
my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$zoom + $gap, $reset_bottom + $gap);
|
my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$zoom + $gap, $reset_bottom + $gap);
|
||||||
|
Slic3r::GUI::_3DScene::render_texture($self, $self->{layer_preview_annotation}->{texture_id}, $l, $r, $t, $b);
|
||||||
|
|
||||||
# my $gap = 10/$self->_zoom;
|
# my $gap = 10/$self->_zoom;
|
||||||
# my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$self->_zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$self->_zoom + $gap, $reset_bottom + $gap);
|
# my ($l, $r, $b, $t) = ($bar_left - $self->{layer_preview_annotation}->{width}/$self->_zoom - $gap, $bar_left - $gap, $reset_bottom + $self->{layer_preview_annotation}->{height}/$self->_zoom + $gap, $reset_bottom + $gap);
|
||||||
|
# $self->_render_image($self->{layer_preview_annotation}, $l, $r, $t, $b);
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
$self->_render_image($self->{layer_preview_annotation}, $l, $r, $t, $b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Paint the reset button.
|
# Paint the reset button.
|
||||||
if ($self->_variable_layer_thickness_load_reset_image) {
|
if ($self->_variable_layer_thickness_load_reset_image) {
|
||||||
$self->_render_image($self->{layer_preview_reset_image}, $reset_left, $reset_right, $reset_bottom, $reset_top);
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::render_texture($self, $self->{layer_preview_reset_image}->{texture_id}, $reset_left, $reset_right, $reset_bottom, $reset_top);
|
||||||
|
# $self->_render_image($self->{layer_preview_reset_image}, $reset_left, $reset_right, $reset_bottom, $reset_top);
|
||||||
|
#==============================================================================================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
# Paint the graph.
|
# Paint the graph.
|
||||||
|
@ -1936,13 +1946,14 @@ sub draw_legend {
|
||||||
my $t = (0.5 * $ch) / $zoom;
|
my $t = (0.5 * $ch) / $zoom;
|
||||||
my $r = $l + $tex_w / $zoom;
|
my $r = $l + $tex_w / $zoom;
|
||||||
my $b = $t - $tex_h / $zoom;
|
my $b = $t - $tex_h / $zoom;
|
||||||
|
Slic3r::GUI::_3DScene::render_texture($self, $tex_id, $l, $r, $b, $t);
|
||||||
|
|
||||||
# my $l = (-0.5 * $cw) / $self->_zoom;
|
# my $l = (-0.5 * $cw) / $self->_zoom;
|
||||||
# my $t = (0.5 * $ch) / $self->_zoom;
|
# my $t = (0.5 * $ch) / $self->_zoom;
|
||||||
# my $r = $l + $tex_w / $self->_zoom;
|
# my $r = $l + $tex_w / $self->_zoom;
|
||||||
# my $b = $t - $tex_h / $self->_zoom;
|
# my $b = $t - $tex_h / $self->_zoom;
|
||||||
|
# $self->_render_texture($tex_id, $l, $r, $b, $t);
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
@ -1950,46 +1961,40 @@ sub draw_legend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub draw_warning {
|
|
||||||
my ($self) = @_;
|
|
||||||
|
|
||||||
if (!$self->_warning_enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# If the warning texture has not been loaded into the GPU, do it now.
|
|
||||||
my $tex_id = Slic3r::GUI::_3DScene::finalize_warning_texture;
|
|
||||||
if ($tex_id > 0)
|
|
||||||
{
|
|
||||||
my $tex_w = Slic3r::GUI::_3DScene::get_warning_texture_width;
|
|
||||||
my $tex_h = Slic3r::GUI::_3DScene::get_warning_texture_height;
|
|
||||||
if (($tex_w > 0) && ($tex_h > 0))
|
|
||||||
{
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
my ($cw, $ch) = $self->GetSizeWH;
|
|
||||||
|
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
my $zoom = Slic3r::GUI::_3DScene::get_camera_zoom($self);
|
#sub draw_warning {
|
||||||
my $l = (-0.5 * $tex_w) / $zoom;
|
# my ($self) = @_;
|
||||||
my $t = (-0.5 * $ch + $tex_h) / $zoom;
|
#
|
||||||
my $r = $l + $tex_w / $zoom;
|
# if (!$self->_warning_enabled) {
|
||||||
my $b = $t - $tex_h / $zoom;
|
# return;
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# # If the warning texture has not been loaded into the GPU, do it now.
|
||||||
|
# my $tex_id = Slic3r::GUI::_3DScene::finalize_warning_texture;
|
||||||
|
# if ($tex_id > 0)
|
||||||
|
# {
|
||||||
|
# my $tex_w = Slic3r::GUI::_3DScene::get_warning_texture_width;
|
||||||
|
# my $tex_h = Slic3r::GUI::_3DScene::get_warning_texture_height;
|
||||||
|
# if (($tex_w > 0) && ($tex_h > 0))
|
||||||
|
# {
|
||||||
|
# glDisable(GL_DEPTH_TEST);
|
||||||
|
# glPushMatrix();
|
||||||
|
# glLoadIdentity();
|
||||||
|
#
|
||||||
|
# my ($cw, $ch) = $self->GetSizeWH;
|
||||||
|
#
|
||||||
# my $l = (-0.5 * $tex_w) / $self->_zoom;
|
# my $l = (-0.5 * $tex_w) / $self->_zoom;
|
||||||
# my $t = (-0.5 * $ch + $tex_h) / $self->_zoom;
|
# my $t = (-0.5 * $ch + $tex_h) / $self->_zoom;
|
||||||
# my $r = $l + $tex_w / $self->_zoom;
|
# my $r = $l + $tex_w / $self->_zoom;
|
||||||
# my $b = $t - $tex_h / $self->_zoom;
|
# my $b = $t - $tex_h / $self->_zoom;
|
||||||
|
# $self->_render_texture($tex_id, $l, $r, $b, $t);
|
||||||
|
#
|
||||||
|
# glPopMatrix();
|
||||||
|
# glEnable(GL_DEPTH_TEST);
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#}
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
$self->_render_texture($tex_id, $l, $r, $b, $t);
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub update_volumes_colors_by_extruder {
|
sub update_volumes_colors_by_extruder {
|
||||||
my ($self, $config) = @_;
|
my ($self, $config) = @_;
|
||||||
|
|
|
@ -241,17 +241,26 @@ sub reload_scene {
|
||||||
if (scalar @{$self->volumes} > 0)
|
if (scalar @{$self->volumes} > 0)
|
||||||
{
|
{
|
||||||
if (!$self->{model}->fits_print_volume($self->{config})) {
|
if (!$self->{model}->fits_print_volume($self->{config})) {
|
||||||
$self->set_warning_enabled(1);
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::enable_warning_texture($self, 1);
|
||||||
|
# $self->set_warning_enabled(1);
|
||||||
|
#==============================================================================================================================
|
||||||
Slic3r::GUI::_3DScene::generate_warning_texture(L("Detected object outside print volume"));
|
Slic3r::GUI::_3DScene::generate_warning_texture(L("Detected object outside print volume"));
|
||||||
$self->on_enable_action_buttons->(0) if ($self->on_enable_action_buttons);
|
$self->on_enable_action_buttons->(0) if ($self->on_enable_action_buttons);
|
||||||
} else {
|
} else {
|
||||||
$self->set_warning_enabled(0);
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::enable_warning_texture($self, 0);
|
||||||
|
# $self->set_warning_enabled(0);
|
||||||
|
#==============================================================================================================================
|
||||||
$self->volumes->update_outside_state($self->{config}, 1);
|
$self->volumes->update_outside_state($self->{config}, 1);
|
||||||
Slic3r::GUI::_3DScene::reset_warning_texture();
|
Slic3r::GUI::_3DScene::reset_warning_texture();
|
||||||
$self->on_enable_action_buttons->(scalar @{$self->{model}->objects} > 0) if ($self->on_enable_action_buttons);
|
$self->on_enable_action_buttons->(scalar @{$self->{model}->objects} > 0) if ($self->on_enable_action_buttons);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$self->set_warning_enabled(0);
|
#==============================================================================================================================
|
||||||
|
Slic3r::GUI::_3DScene::enable_warning_texture($self, 0);
|
||||||
|
# $self->set_warning_enabled(0);
|
||||||
|
#==============================================================================================================================
|
||||||
Slic3r::GUI::_3DScene::reset_warning_texture();
|
Slic3r::GUI::_3DScene::reset_warning_texture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1898,6 +1898,11 @@ bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas)
|
||||||
return s_canvas_mgr.is_layers_editing_enabled(canvas);
|
return s_canvas_mgr.is_layers_editing_enabled(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _3DScene::enable_warning_texture(wxGLCanvas* canvas, bool enable)
|
||||||
|
{
|
||||||
|
s_canvas_mgr.enable_warning_texture(canvas, enable);
|
||||||
|
}
|
||||||
|
|
||||||
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.zoom_to_bed(canvas);
|
s_canvas_mgr.zoom_to_bed(canvas);
|
||||||
|
@ -1928,6 +1933,16 @@ void _3DScene::render_cutting_plane(wxGLCanvas* canvas)
|
||||||
s_canvas_mgr.render_cutting_plane(canvas);
|
s_canvas_mgr.render_cutting_plane(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _3DScene::render_warning_texture(wxGLCanvas* canvas)
|
||||||
|
{
|
||||||
|
s_canvas_mgr.render_warning_texture(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _3DScene::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top)
|
||||||
|
{
|
||||||
|
s_canvas_mgr.render_texture(canvas, tex_id, left, right, bottom, top);
|
||||||
|
}
|
||||||
|
|
||||||
void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);
|
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);
|
||||||
|
|
|
@ -590,6 +590,8 @@ public:
|
||||||
|
|
||||||
static bool is_layers_editing_enabled(wxGLCanvas* canvas);
|
static bool is_layers_editing_enabled(wxGLCanvas* canvas);
|
||||||
|
|
||||||
|
static void enable_warning_texture(wxGLCanvas* canvas, bool enable);
|
||||||
|
|
||||||
static void zoom_to_bed(wxGLCanvas* canvas);
|
static void zoom_to_bed(wxGLCanvas* canvas);
|
||||||
static void zoom_to_volumes(wxGLCanvas* canvas);
|
static void zoom_to_volumes(wxGLCanvas* canvas);
|
||||||
static void select_view(wxGLCanvas* canvas, const std::string& direction);
|
static void select_view(wxGLCanvas* canvas, const std::string& direction);
|
||||||
|
@ -597,6 +599,9 @@ public:
|
||||||
static void render_bed(wxGLCanvas* canvas);
|
static void render_bed(wxGLCanvas* canvas);
|
||||||
static void render_axes(wxGLCanvas* canvas);
|
static void render_axes(wxGLCanvas* canvas);
|
||||||
static void render_cutting_plane(wxGLCanvas* canvas);
|
static void render_cutting_plane(wxGLCanvas* canvas);
|
||||||
|
static void render_warning_texture(wxGLCanvas* canvas);
|
||||||
|
|
||||||
|
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_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
|
||||||
|
|
|
@ -411,6 +411,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
||||||
, m_volumes(nullptr)
|
, m_volumes(nullptr)
|
||||||
, m_dirty(true)
|
, m_dirty(true)
|
||||||
, m_apply_zoom_to_volumes_filter(false)
|
, m_apply_zoom_to_volumes_filter(false)
|
||||||
|
, m_warning_texture_enabled(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,6 +683,11 @@ bool GLCanvas3D::is_layers_editing_enabled() const
|
||||||
return m_layers_editing.is_enabled();
|
return m_layers_editing.is_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::enable_warning_texture(bool enable)
|
||||||
|
{
|
||||||
|
m_warning_texture_enabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::zoom_to_bed()
|
void GLCanvas3D::zoom_to_bed()
|
||||||
{
|
{
|
||||||
_zoom_to_bounding_box(bed_bounding_box());
|
_zoom_to_bounding_box(bed_bounding_box());
|
||||||
|
@ -743,6 +749,64 @@ void GLCanvas3D::render_cutting_plane()
|
||||||
m_cutting_plane.render_contour();
|
m_cutting_plane.render_contour();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::render_warning_texture()
|
||||||
|
{
|
||||||
|
if (!m_warning_texture_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If the warning texture has not been loaded into the GPU, do it now.
|
||||||
|
unsigned int tex_id = _3DScene::finalize_warning_texture();
|
||||||
|
if (tex_id > 0)
|
||||||
|
{
|
||||||
|
unsigned int w = _3DScene::get_warning_texture_width();
|
||||||
|
unsigned int h = _3DScene::get_warning_texture_height();
|
||||||
|
if ((w > 0) && (h > 0))
|
||||||
|
{
|
||||||
|
::glDisable(GL_DEPTH_TEST);
|
||||||
|
::glPushMatrix();
|
||||||
|
::glLoadIdentity();
|
||||||
|
|
||||||
|
std::pair<int, int> cnv_size = _get_canvas_size();
|
||||||
|
float zoom = get_camera_zoom();
|
||||||
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
float l = (-0.5f * (float)w) * inv_zoom;
|
||||||
|
float t = (-0.5f * cnv_size.second + (float)h) * inv_zoom;
|
||||||
|
float r = l + (float)w * inv_zoom;
|
||||||
|
float b = t - (float)h * inv_zoom;
|
||||||
|
|
||||||
|
render_texture(tex_id, l, r, b, t);
|
||||||
|
|
||||||
|
::glPopMatrix();
|
||||||
|
::glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::render_texture(unsigned int tex_id, float left, float right, float bottom, float top)
|
||||||
|
{
|
||||||
|
::glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
::glDisable(GL_LIGHTING);
|
||||||
|
::glEnable(GL_BLEND);
|
||||||
|
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
::glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id);
|
||||||
|
|
||||||
|
::glBegin(GL_QUADS);
|
||||||
|
::glTexCoord2d(0.0f, 1.0f); glVertex3f(left, bottom, 0.0f);
|
||||||
|
::glTexCoord2d(1.0f, 1.0f); glVertex3f(right, bottom, 0.0f);
|
||||||
|
::glTexCoord2d(1.0f, 0.0f); glVertex3f(right, top, 0.0f);
|
||||||
|
::glTexCoord2d(0.0f, 0.0f); glVertex3f(left, top, 0.0f);
|
||||||
|
::glEnd();
|
||||||
|
|
||||||
|
::glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
::glDisable(GL_TEXTURE_2D);
|
||||||
|
::glDisable(GL_BLEND);
|
||||||
|
::glEnable(GL_LIGHTING);
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::register_on_viewport_changed_callback(void* callback)
|
void GLCanvas3D::register_on_viewport_changed_callback(void* callback)
|
||||||
{
|
{
|
||||||
if (callback != nullptr)
|
if (callback != nullptr)
|
||||||
|
|
|
@ -151,6 +151,7 @@ private:
|
||||||
|
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
bool m_apply_zoom_to_volumes_filter;
|
bool m_apply_zoom_to_volumes_filter;
|
||||||
|
bool m_warning_texture_enabled;
|
||||||
|
|
||||||
PerlCallback m_on_viewport_changed_callback;
|
PerlCallback m_on_viewport_changed_callback;
|
||||||
|
|
||||||
|
@ -213,6 +214,8 @@ public:
|
||||||
|
|
||||||
bool is_layers_editing_enabled() const;
|
bool is_layers_editing_enabled() const;
|
||||||
|
|
||||||
|
void enable_warning_texture(bool enable);
|
||||||
|
|
||||||
void zoom_to_bed();
|
void zoom_to_bed();
|
||||||
void zoom_to_volumes();
|
void zoom_to_volumes();
|
||||||
void select_view(const std::string& direction);
|
void select_view(const std::string& direction);
|
||||||
|
@ -220,6 +223,9 @@ public:
|
||||||
void render_bed();
|
void render_bed();
|
||||||
void render_axes();
|
void render_axes();
|
||||||
void render_cutting_plane();
|
void render_cutting_plane();
|
||||||
|
void render_warning_texture();
|
||||||
|
|
||||||
|
void render_texture(unsigned int tex_id, float left, float right, float bottom, float top);
|
||||||
|
|
||||||
void register_on_viewport_changed_callback(void* callback);
|
void register_on_viewport_changed_callback(void* callback);
|
||||||
|
|
||||||
|
|
|
@ -355,6 +355,13 @@ bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const
|
||||||
return (it != m_canvases.end()) ? it->second->is_layers_editing_enabled() : false;
|
return (it != m_canvases.end()) ? it->second->is_layers_editing_enabled() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::enable_warning_texture(wxGLCanvas* canvas, bool enable)
|
||||||
|
{
|
||||||
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->enable_warning_texture(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
@ -397,6 +404,20 @@ void GLCanvas3DManager::render_cutting_plane(wxGLCanvas* canvas)
|
||||||
it->second->render_cutting_plane();
|
it->second->render_cutting_plane();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::render_warning_texture(wxGLCanvas* canvas)
|
||||||
|
{
|
||||||
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->render_warning_texture();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas3DManager::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top)
|
||||||
|
{
|
||||||
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
if (it != m_canvases.end())
|
||||||
|
it->second->render_texture(tex_id, left, right, bottom, top);
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
||||||
{
|
{
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
|
|
@ -100,6 +100,8 @@ public:
|
||||||
|
|
||||||
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
||||||
|
|
||||||
|
void enable_warning_texture(wxGLCanvas* canvas, bool enable);
|
||||||
|
|
||||||
void zoom_to_bed(wxGLCanvas* canvas);
|
void zoom_to_bed(wxGLCanvas* canvas);
|
||||||
void zoom_to_volumes(wxGLCanvas* canvas);
|
void zoom_to_volumes(wxGLCanvas* canvas);
|
||||||
void select_view(wxGLCanvas* canvas, const std::string& direction);
|
void select_view(wxGLCanvas* canvas, const std::string& direction);
|
||||||
|
@ -107,6 +109,9 @@ public:
|
||||||
void render_bed(wxGLCanvas* canvas);
|
void render_bed(wxGLCanvas* canvas);
|
||||||
void render_axes(wxGLCanvas* canvas);
|
void render_axes(wxGLCanvas* canvas);
|
||||||
void render_cutting_plane(wxGLCanvas* canvas);
|
void render_cutting_plane(wxGLCanvas* canvas);
|
||||||
|
void render_warning_texture(wxGLCanvas* canvas);
|
||||||
|
|
||||||
|
void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top);
|
||||||
|
|
||||||
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
|
||||||
|
|
|
@ -411,6 +411,13 @@ set_camera_target(canvas, target)
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target);
|
_3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target);
|
||||||
|
|
||||||
|
void
|
||||||
|
enable_warning_texture(canvas, enable)
|
||||||
|
SV *canvas;
|
||||||
|
bool enable;
|
||||||
|
CODE:
|
||||||
|
_3DScene::enable_warning_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable);
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom_to_bed(canvas)
|
zoom_to_bed(canvas)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
@ -447,7 +454,24 @@ render_cutting_plane(canvas)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::render_cutting_plane((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
_3DScene::render_cutting_plane((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||||
|
|
||||||
|
void
|
||||||
|
render_warning_texture(canvas)
|
||||||
|
SV *canvas;
|
||||||
|
CODE:
|
||||||
|
_3DScene::render_warning_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||||
|
|
||||||
|
void
|
||||||
|
render_texture(canvas, tex_id, left, right, bottom, top)
|
||||||
|
SV *canvas;
|
||||||
|
unsigned int tex_id;
|
||||||
|
float left;
|
||||||
|
float right;
|
||||||
|
float bottom;
|
||||||
|
float top;
|
||||||
|
CODE:
|
||||||
|
_3DScene::render_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), tex_id, left, right, bottom, top);
|
||||||
|
|
||||||
void
|
void
|
||||||
register_on_viewport_changed_callback(canvas, callback)
|
register_on_viewport_changed_callback(canvas, callback)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue