diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index d81db3dc9a..7696e2718b 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -43,7 +43,6 @@ __PACKAGE__->mk_accessors( qw(_quat init on_move on_model_update volumes - _hover_volume_idx _drag_volume_idx _drag_start_pos @@ -170,13 +169,12 @@ sub new { #============================================================================================================================== Slic3r::GUI::_3DScene::add_canvas($self, $self->GetContext); + Slic3r::GUI::_3DScene::allow_multisample($self, $can_multisample); # my $context = $self->GetContext; # $self->SetCurrent($context); # Slic3r::GUI::_3DScene::add_canvas($self, $context); -#============================================================================================================================== - - $self->{can_multisample} = $can_multisample; -#============================================================================================================================== +# +# $self->{can_multisample} = $can_multisample; # $self->background(1); #============================================================================================================================== $self->_quat((0, 0, 0, 1)); @@ -486,7 +484,10 @@ sub mouse_event { } elsif ($e->LeftDown || $e->RightDown) { # If user pressed left or right button we first check whether this happened # on a volume or not. - my $volume_idx = $self->_hover_volume_idx // -1; +#============================================================================================================================== + my $volume_idx = Slic3r::GUI::_3DScene::get_hover_volume_id($self); +# my $volume_idx = $self->_hover_volume_idx // -1; +#============================================================================================================================== $self->_layer_height_edited(0); if ($object_idx_selected != -1 && $self->_variable_layer_thickness_bar_rect_mouse_inside($e)) { # A volume is selected and the mouse is hovering over a layer thickness bar. @@ -1342,55 +1343,56 @@ sub InitGL { $self->zoom_to_bed; - glClearColor(0, 0, 0, 1); - glColor3f(1, 0, 0); - glEnable(GL_DEPTH_TEST); - glClearDepth(1.0); - glDepthFunc(GL_LEQUAL); - glEnable(GL_CULL_FACE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - # Set antialiasing/multisampling - glDisable(GL_LINE_SMOOTH); - glDisable(GL_POLYGON_SMOOTH); - - # See "GL_MULTISAMPLE and GL_ARRAY_BUFFER_ARB messages on failed launch" - # https://github.com/alexrj/Slic3r/issues/4085 - eval { - # Disable the multi sampling by default, so the picking by color will work correctly. - glDisable(GL_MULTISAMPLE); - }; - # Disable multi sampling if the eval failed. - $self->{can_multisample} = 0 if $@; - - # ambient lighting - glLightModelfv_p(GL_LIGHT_MODEL_AMBIENT, 0.3, 0.3, 0.3, 1); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); - - # light from camera - glLightfv_p(GL_LIGHT1, GL_POSITION, 1, 0, 1, 0); - glLightfv_p(GL_LIGHT1, GL_SPECULAR, 0.3, 0.3, 0.3, 1); - glLightfv_p(GL_LIGHT1, GL_DIFFUSE, 0.2, 0.2, 0.2, 1); - - # Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. - glShadeModel(GL_SMOOTH); - -# glMaterialfv_p(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, 0.5, 0.3, 0.3, 1); -# glMaterialfv_p(GL_FRONT_AND_BACK, GL_SPECULAR, 1, 1, 1, 1); -# glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50); -# glMaterialfv_p(GL_FRONT_AND_BACK, GL_EMISSION, 0.1, 0, 0, 0.9); - - # A handy trick -- have surface material mirror the color. - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - glEnable(GL_COLOR_MATERIAL); - glEnable(GL_MULTISAMPLE) if ($self->{can_multisample}); - #=================================================================================================================================== Slic3r::GUI::_3DScene::init($self, $self->UseVBOs); + +# glClearColor(0, 0, 0, 1); +# glColor3f(1, 0, 0); +# glEnable(GL_DEPTH_TEST); +# glClearDepth(1.0); +# glDepthFunc(GL_LEQUAL); +# glEnable(GL_CULL_FACE); +# glEnable(GL_BLEND); +# glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +# +# # Set antialiasing/multisampling +# glDisable(GL_LINE_SMOOTH); +# glDisable(GL_POLYGON_SMOOTH); +# +# # See "GL_MULTISAMPLE and GL_ARRAY_BUFFER_ARB messages on failed launch" +# # https://github.com/alexrj/Slic3r/issues/4085 +# eval { +# # Disable the multi sampling by default, so the picking by color will work correctly. +# glDisable(GL_MULTISAMPLE); +# }; +# # Disable multi sampling if the eval failed. +# $self->{can_multisample} = 0 if $@; +# +# # ambient lighting +# glLightModelfv_p(GL_LIGHT_MODEL_AMBIENT, 0.3, 0.3, 0.3, 1); +# +# glEnable(GL_LIGHTING); +# glEnable(GL_LIGHT0); +# glEnable(GL_LIGHT1); +# +# # light from camera +# glLightfv_p(GL_LIGHT1, GL_POSITION, 1, 0, 1, 0); +# glLightfv_p(GL_LIGHT1, GL_SPECULAR, 0.3, 0.3, 0.3, 1); +# glLightfv_p(GL_LIGHT1, GL_DIFFUSE, 0.2, 0.2, 0.2, 1); +# +# # Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. +# glShadeModel(GL_SMOOTH); +# +## glMaterialfv_p(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, 0.5, 0.3, 0.3, 1); +## glMaterialfv_p(GL_FRONT_AND_BACK, GL_SPECULAR, 1, 1, 1, 1); +## glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50); +## glMaterialfv_p(GL_FRONT_AND_BACK, GL_EMISSION, 0.1, 0, 0, 0.9); +# +# # A handy trick -- have surface material mirror the color. +# glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); +# glEnable(GL_COLOR_MATERIAL); +# glEnable(GL_MULTISAMPLE) if ($self->{can_multisample}); +# # if ($self->UseVBOs) { # my $shader = new Slic3r::GUI::_3DScene::GLShader; ## if (! $shader->load($self->_fragment_shader_Phong, $self->_vertex_shader_Phong)) { @@ -1436,7 +1438,9 @@ sub Render { glClearColor(1, 1, 1, 1); glClearDepth(1); glDepthFunc(GL_LESS); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +#============================================================================================================================== +# glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +#============================================================================================================================== glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -1476,50 +1480,42 @@ sub Render { glLightfv_p(GL_LIGHT1, GL_POSITION, 1, 0, 1, 0); #============================================================================================================================== - if (Slic3r::GUI::_3DScene::is_picking_enabled($self) && !Slic3r::GUI::_3DScene::is_mouse_dragging($self)) { - my $pos = Slic3r::GUI::_3DScene::get_mouse_position($self); - if ($pos) { -# if ($self->enable_picking && !$self->_mouse_dragging) { -# if (my $pos = $self->_mouse_pos) { -#============================================================================================================================== - # Render the object for picking. - # FIXME This cannot possibly work in a multi-sampled context as the color gets mangled by the anti-aliasing. - # Better to use software ray-casting on a bounding-box hierarchy. - glPushAttrib(GL_ENABLE_BIT); - glDisable(GL_MULTISAMPLE) if ($self->{can_multisample}); - glDisable(GL_LIGHTING); - glDisable(GL_BLEND); -#============================================================================================================================== - Slic3r::GUI::_3DScene::render_volumes($self, 1); -# $self->draw_volumes(1); -#============================================================================================================================== - glPopAttrib(); - glFlush(); - my $col = [ glReadPixels_p($pos->x, $self->GetSize->GetHeight - $pos->y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE) ]; - my $volume_idx = $col->[0] + $col->[1]*256 + $col->[2]*256*256; - $self->_hover_volume_idx(undef); - $_->set_hover(0) for @{$self->volumes}; - if ($volume_idx <= $#{$self->volumes}) { - $self->_hover_volume_idx($volume_idx); - - $self->volumes->[$volume_idx]->set_hover(1); - my $group_id = $self->volumes->[$volume_idx]->select_group_id; - if ($group_id != -1) { - $_->set_hover(1) for grep { $_->select_group_id == $group_id } @{$self->volumes}; - } - -#============================================================================================================================== -# $self->on_hover->($volume_idx) if $self->on_hover; -#============================================================================================================================== - } - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } - } - -#============================================================================================================================== + Slic3r::GUI::_3DScene::picking_pass($self); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Slic3r::GUI::_3DScene::render_background($self); Slic3r::GUI::_3DScene::render_bed($self); +# if ($self->enable_picking && !$self->_mouse_dragging) { +# if (my $pos = $self->_mouse_pos) { +# # Render the object for picking. +# # FIXME This cannot possibly work in a multi-sampled context as the color gets mangled by the anti-aliasing. +# # Better to use software ray-casting on a bounding-box hierarchy. +# glPushAttrib(GL_ENABLE_BIT); +# glDisable(GL_MULTISAMPLE) if ($self->{can_multisample}); +# glDisable(GL_LIGHTING); +# glDisable(GL_BLEND); +# $self->draw_volumes(1); +# glPopAttrib(); +# glFlush(); +# my $col = [ glReadPixels_p($pos->x, $self->GetSize->GetHeight - $pos->y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE) ]; +# my $volume_idx = $col->[0] + $col->[1]*256 + $col->[2]*256*256; +# $self->_hover_volume_idx(undef); +# $_->set_hover(0) for @{$self->volumes}; +# if ($volume_idx <= $#{$self->volumes}) { +# $self->_hover_volume_idx($volume_idx); +# +# $self->volumes->[$volume_idx]->set_hover(1); +# my $group_id = $self->volumes->[$volume_idx]->select_group_id; +# if ($group_id != -1) { +# $_->set_hover(1) for grep { $_->select_group_id == $group_id } @{$self->volumes}; +# } +# +# $self->on_hover->($volume_idx) if $self->on_hover; +# } +# glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +# } +# } +# # # draw fixed background # if ($self->background) { # glDisable(GL_LIGHTING); diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index eee1110667..a6e46b11a5 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1934,6 +1934,11 @@ bool _3DScene::is_shader_enabled(wxGLCanvas* canvas) return s_canvas_mgr.is_shader_enabled(canvas); } +bool _3DScene::is_multisample_allowed(wxGLCanvas* canvas) +{ + return s_canvas_mgr.is_multisample_allowed(canvas); +} + void _3DScene::enable_warning_texture(wxGLCanvas* canvas, bool enable) { s_canvas_mgr.enable_warning_texture(canvas, enable); @@ -1954,6 +1959,11 @@ void _3DScene::enable_shader(wxGLCanvas* canvas, bool enable) s_canvas_mgr.enable_shader(canvas, enable); } +void _3DScene::allow_multisample(wxGLCanvas* canvas, bool allow) +{ + s_canvas_mgr.allow_multisample(canvas, allow); +} + bool _3DScene::is_mouse_dragging(wxGLCanvas* canvas) { return s_canvas_mgr.is_mouse_dragging(canvas); @@ -1975,6 +1985,16 @@ void _3DScene::set_mouse_position(wxGLCanvas* canvas, const Pointf* position) s_canvas_mgr.set_mouse_position(canvas, *position); } +int _3DScene::get_hover_volume_id(wxGLCanvas* canvas) +{ + return s_canvas_mgr.get_hover_volume_id(canvas); +} + +void _3DScene::set_hover_volume_id(wxGLCanvas* canvas, int id) +{ + s_canvas_mgr.set_hover_volume_id(canvas, id); +} + void _3DScene::zoom_to_bed(wxGLCanvas* canvas) { s_canvas_mgr.zoom_to_bed(canvas); @@ -2000,6 +2020,11 @@ void _3DScene::stop_using_shader(wxGLCanvas* canvas) s_canvas_mgr.stop_using_shader(canvas); } +void _3DScene::picking_pass(wxGLCanvas* canvas) +{ + s_canvas_mgr.picking_pass(canvas); +} + void _3DScene::render_background(wxGLCanvas* canvas) { s_canvas_mgr.render_background(canvas); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index a34e962867..03b2421642 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -597,11 +597,13 @@ public: static bool is_layers_editing_enabled(wxGLCanvas* canvas); static bool is_picking_enabled(wxGLCanvas* canvas); static bool is_shader_enabled(wxGLCanvas* canvas); + static bool is_multisample_allowed(wxGLCanvas* canvas); static void enable_warning_texture(wxGLCanvas* canvas, bool enable); static void enable_legend_texture(wxGLCanvas* canvas, bool enable); static void enable_picking(wxGLCanvas* canvas, bool enable); static void enable_shader(wxGLCanvas* canvas, bool enable); + static void allow_multisample(wxGLCanvas* canvas, bool allow); static bool is_mouse_dragging(wxGLCanvas* canvas); static void set_mouse_dragging(wxGLCanvas* canvas, bool dragging); @@ -609,6 +611,9 @@ public: static Pointf get_mouse_position(wxGLCanvas* canvas); static void set_mouse_position(wxGLCanvas* canvas, const Pointf* position); + static int get_hover_volume_id(wxGLCanvas* canvas); + static void set_hover_volume_id(wxGLCanvas* canvas, int id); + static void zoom_to_bed(wxGLCanvas* canvas); static void zoom_to_volumes(wxGLCanvas* canvas); static void select_view(wxGLCanvas* canvas, const std::string& direction); @@ -616,6 +621,8 @@ public: static bool start_using_shader(wxGLCanvas* canvas); static void stop_using_shader(wxGLCanvas* canvas); + static void picking_pass(wxGLCanvas* canvas); + static void render_background(wxGLCanvas* canvas); static void render_bed(wxGLCanvas* canvas); static void render_axes(wxGLCanvas* canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 65ca546121..da639b144d 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -5,6 +5,7 @@ #include "../../libslic3r/ClipperUtils.hpp" #include "../../libslic3r/PrintConfig.hpp" +#include #include #include @@ -506,9 +507,11 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) , m_config(nullptr) , m_dirty(true) , m_apply_zoom_to_volumes_filter(false) + , m_hover_volume_id(-1) , m_warning_texture_enabled(false) , m_legend_texture_enabled(false) , m_picking_enabled(false) + , m_multisample_allowed(false) { } @@ -520,6 +523,45 @@ GLCanvas3D::~GLCanvas3D() bool GLCanvas3D::init(bool useVBOs) { + ::glClearColor(0.0f, 0.0f, 0.0f, 1.0f); +// ::glColor3f(1.0f, 0.0f, 0.0f); + ::glEnable(GL_DEPTH_TEST); + ::glClearDepth(1.0f); + ::glDepthFunc(GL_LEQUAL); + ::glEnable(GL_CULL_FACE); + ::glEnable(GL_BLEND); + ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Set antialiasing / multisampling + ::glDisable(GL_LINE_SMOOTH); + ::glDisable(GL_POLYGON_SMOOTH); + + // ambient lighting + GLfloat ambient[4] = { 0.3f, 0.3f, 0.3f, 1.0f }; + ::glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); + +// ::glEnable(GL_LIGHTING); + ::glEnable(GL_LIGHT0); + ::glEnable(GL_LIGHT1); + + // light from camera + GLfloat position[4] = { 1.0f, 0.0f, 1.0f, 0.0f }; + ::glLightfv(GL_LIGHT1, GL_POSITION, position); + GLfloat specular[4] = { 0.3f, 0.3f, 0.3f, 1.0f }; + ::glLightfv(GL_LIGHT1, GL_SPECULAR, specular); + GLfloat diffuse[4] = { 0.2f, 0.2f, 0.2f, 1.0f }; + ::glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); + + // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. + ::glShadeModel(GL_SMOOTH); + + // A handy trick -- have surface material mirror the color. + ::glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + ::glEnable(GL_COLOR_MATERIAL); + + if (is_multisample_allowed()) + ::glEnable(GL_MULTISAMPLE); + if (useVBOs && !m_shader.init("gouraud.vs", "gouraud.fs")) return false; @@ -809,6 +851,11 @@ bool GLCanvas3D::is_shader_enabled() const return m_shader.is_enabled(); } +bool GLCanvas3D::is_multisample_allowed() const +{ + return m_multisample_allowed; +} + void GLCanvas3D::enable_warning_texture(bool enable) { m_warning_texture_enabled = enable; @@ -829,6 +876,11 @@ void GLCanvas3D::enable_shader(bool enable) m_shader.set_enabled(enable); } +void GLCanvas3D::allow_multisample(bool allow) +{ + m_multisample_allowed = allow; +} + bool GLCanvas3D::is_mouse_dragging() const { return m_mouse.is_dragging(); @@ -849,6 +901,16 @@ void GLCanvas3D::set_mouse_position(const Pointf& position) m_mouse.set_position(position); } +int GLCanvas3D::get_hover_volume_id() const +{ + return m_hover_volume_id; +} + +void GLCanvas3D::set_hover_volume_id(int id) +{ + m_hover_volume_id = id; +} + void GLCanvas3D::zoom_to_bed() { _zoom_to_bounding_box(bed_bounding_box()); @@ -902,6 +964,66 @@ void GLCanvas3D::stop_using_shader() const m_shader.stop(); } +void GLCanvas3D::picking_pass() +{ + if (is_picking_enabled() && !is_mouse_dragging() && (m_volumes != nullptr)) + { + const Pointf& pos = get_mouse_position(); +// if (pos) { + // Render the object for picking. + // FIXME This cannot possibly work in a multi - sampled context as the color gets mangled by the anti - aliasing. + // Better to use software ray - casting on a bounding - box hierarchy. + + if (is_multisample_allowed()) + ::glDisable(GL_MULTISAMPLE); + + ::glDisable(GL_LIGHTING); + ::glDisable(GL_BLEND); + + ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + ::glPushAttrib(GL_ENABLE_BIT); + + render_volumes(true); + + ::glPopAttrib(); + + if (is_multisample_allowed()) + ::glEnable(GL_MULTISAMPLE); + +// ::glFlush(); + + const std::pair& cnv_size = _get_canvas_size(); + + GLubyte color[4]; + ::glReadPixels(pos.x, cnv_size.second - pos.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color); + int volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256; + + set_hover_volume_id(-1); + + for (GLVolume* vol : m_volumes->volumes) + { + vol->hover = false; + } + + if (volume_id < m_volumes->volumes.size()) + { + set_hover_volume_id(volume_id); + m_volumes->volumes[volume_id]->hover = true; + int group_id = m_volumes->volumes[volume_id]->select_group_id; + if (group_id != -1) + { + for (GLVolume* vol : m_volumes->volumes) + { + if (vol->select_group_id == group_id) + vol->hover = true; + } + } + } + } +// } +} + void GLCanvas3D::render_background() const { static const float COLOR[3] = { 10.0f / 255.0f, 98.0f / 255.0f, 144.0f / 255.0f }; @@ -1059,7 +1181,7 @@ void GLCanvas3D::render_warning_texture() const ::glPushMatrix(); ::glLoadIdentity(); - std::pair cnv_size = _get_canvas_size(); + const std::pair& 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; @@ -1092,7 +1214,7 @@ void GLCanvas3D::render_legend_texture() const ::glPushMatrix(); ::glLoadIdentity(); - std::pair cnv_size = _get_canvas_size(); + const std::pair& 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)cnv_size.first) * inv_zoom; @@ -1156,8 +1278,8 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt) if (m_canvas != nullptr) { - std::pair size = _get_canvas_size(); - resize((unsigned int)size.first, (unsigned int)size.second); + const std::pair& cnv_size = _get_canvas_size(); + resize((unsigned int)cnv_size.first, (unsigned int)cnv_size.second); m_canvas->Refresh(); } } @@ -1211,8 +1333,8 @@ void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) if (is_shown_on_screen()) { - std::pair size = _get_canvas_size(); - resize((unsigned int)size.first, (unsigned int)size.second); + const std::pair& cnv_size = _get_canvas_size(); + resize((unsigned int)cnv_size.first, (unsigned int)cnv_size.second); if (m_canvas != nullptr) m_canvas->Refresh(); } @@ -1311,8 +1433,8 @@ float GLCanvas3D::_get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) co max_x *= 2.0; max_y *= 2.0; - std::pair cvs_size = _get_canvas_size(); - return (float)std::min((coordf_t)cvs_size.first / max_x, (coordf_t)cvs_size.second / max_y); + const std::pair& cnv_size = _get_canvas_size(); + return (float)std::min((coordf_t)cnv_size.first / max_x, (coordf_t)cnv_size.second / max_y); } void GLCanvas3D::_deregister_callbacks() diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index 5198c89c66..3c0275c9e6 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -192,9 +192,11 @@ private: bool m_dirty; bool m_apply_zoom_to_volumes_filter; + int m_hover_volume_id; bool m_warning_texture_enabled; bool m_legend_texture_enabled; bool m_picking_enabled; + bool m_multisample_allowed; PerlCallback m_on_viewport_changed_callback; PerlCallback m_on_mark_volumes_for_layer_height_callback; @@ -263,11 +265,13 @@ public: bool is_layers_editing_enabled() const; bool is_picking_enabled() const; bool is_shader_enabled() const; + bool is_multisample_allowed() const; void enable_warning_texture(bool enable); void enable_legend_texture(bool enable); void enable_picking(bool enable); void enable_shader(bool enable); + void allow_multisample(bool allow); bool is_mouse_dragging() const; void set_mouse_dragging(bool dragging); @@ -275,6 +279,9 @@ public: const Pointf& get_mouse_position() const; void set_mouse_position(const Pointf& position); + int get_hover_volume_id() const; + void set_hover_volume_id(int id); + void zoom_to_bed(); void zoom_to_volumes(); void select_view(const std::string& direction); @@ -282,6 +289,8 @@ public: bool start_using_shader() const; void stop_using_shader() const; + void picking_pass(); + void render_background() const; void render_bed() const; void render_axes() const; diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index c08d08156e..c5a15696d6 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -383,6 +383,12 @@ bool GLCanvas3DManager::is_shader_enabled(wxGLCanvas* canvas) const return (it != m_canvases.end()) ? it->second->is_shader_enabled() : false; } +bool GLCanvas3DManager::is_multisample_allowed(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->is_multisample_allowed() : false; +} + void GLCanvas3DManager::enable_warning_texture(wxGLCanvas* canvas, bool enable) { CanvasesMap::iterator it = _get_canvas(canvas); @@ -411,6 +417,13 @@ void GLCanvas3DManager::enable_shader(wxGLCanvas* canvas, bool enable) it->second->enable_shader(enable); } +void GLCanvas3DManager::allow_multisample(wxGLCanvas* canvas, bool allow) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->allow_multisample(allow); +} + bool GLCanvas3DManager::is_mouse_dragging(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); @@ -437,6 +450,19 @@ void GLCanvas3DManager::set_mouse_position(wxGLCanvas* canvas, const Pointf& pos it->second->set_mouse_position(position); } +int GLCanvas3DManager::get_hover_volume_id(wxGLCanvas* canvas) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_hover_volume_id() : -1; +} + +void GLCanvas3DManager::set_hover_volume_id(wxGLCanvas* canvas, int id) +{ + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->set_hover_volume_id(id); +} + void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas) { CanvasesMap::iterator it = _get_canvas(canvas); @@ -471,6 +497,13 @@ void GLCanvas3DManager::stop_using_shader(wxGLCanvas* canvas) const it->second->stop_using_shader(); } +void GLCanvas3DManager::picking_pass(wxGLCanvas* canvas) +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->picking_pass(); +} + void GLCanvas3DManager::render_background(wxGLCanvas* canvas) const { CanvasesMap::const_iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 13cedce8aa..e0b2a1d2e2 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -105,11 +105,13 @@ public: bool is_layers_editing_enabled(wxGLCanvas* canvas) const; bool is_picking_enabled(wxGLCanvas* canvas) const; bool is_shader_enabled(wxGLCanvas* canvas) const; + bool is_multisample_allowed(wxGLCanvas* canvas) const; void enable_warning_texture(wxGLCanvas* canvas, bool enable); void enable_legend_texture(wxGLCanvas* canvas, bool enable); void enable_picking(wxGLCanvas* canvas, bool enable); void enable_shader(wxGLCanvas* canvas, bool enable); + void allow_multisample(wxGLCanvas* canvas, bool allow); bool is_mouse_dragging(wxGLCanvas* canvas) const; void set_mouse_dragging(wxGLCanvas* canvas, bool dragging); @@ -117,6 +119,9 @@ public: Pointf get_mouse_position(wxGLCanvas* canvas) const; void set_mouse_position(wxGLCanvas* canvas, const Pointf& position); + int get_hover_volume_id(wxGLCanvas* canvas) const; + void set_hover_volume_id(wxGLCanvas* canvas, int id); + void zoom_to_bed(wxGLCanvas* canvas); void zoom_to_volumes(wxGLCanvas* canvas); void select_view(wxGLCanvas* canvas, const std::string& direction); @@ -124,6 +129,8 @@ public: bool start_using_shader(wxGLCanvas* canvas) const; void stop_using_shader(wxGLCanvas* canvas) const; + void picking_pass(wxGLCanvas* canvas); + void render_background(wxGLCanvas* canvas) const; void render_bed(wxGLCanvas* canvas) const; void render_axes(wxGLCanvas* canvas) const; diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index 83bf8b7975..a2be3b1df6 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -455,6 +455,14 @@ is_shader_enabled(canvas) OUTPUT: RETVAL +bool +is_multisample_allowed(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::is_multisample_allowed((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + void enable_warning_texture(canvas, enable) SV *canvas; @@ -483,6 +491,13 @@ enable_shader(canvas, enable) CODE: _3DScene::enable_shader((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable); +void +allow_multisample(canvas, allow) + SV *canvas; + bool allow; + CODE: + _3DScene::allow_multisample((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), allow); + bool is_mouse_dragging(canvas) SV *canvas; @@ -513,6 +528,21 @@ set_mouse_position(canvas, position) CODE: _3DScene::set_mouse_position((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), position); +int +get_hover_volume_id(canvas) + SV *canvas; + CODE: + RETVAL = _3DScene::get_hover_volume_id((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL + +void +set_hover_volume_id(canvas, id) + SV *canvas; + int id; + CODE: + _3DScene::set_hover_volume_id((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id); + void zoom_to_bed(canvas) SV *canvas; @@ -546,6 +576,12 @@ stop_using_shader(canvas) CODE: _3DScene::stop_using_shader((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); +void +picking_pass(canvas) + SV *canvas; + CODE: + _3DScene::picking_pass((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + void render_background(canvas) SV *canvas;