From b8c8dfbb2f5575e73a694aa0c7d85dfc4238b395 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 18 Dec 2018 12:05:13 +0100 Subject: [PATCH 1/2] Fix of Linux/OSX build --- src/libslic3r/utils.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index af6373361..8081828c7 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -426,6 +426,11 @@ std::string log_memory_info() return out; } +#else +std::string log_memory_info() +{ + return std::string(); +} #endif }; // namespace Slic3r From 3f96f6df84b7db79ea4364a61f7a9d5e8255209f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 18 Dec 2018 12:35:49 +0100 Subject: [PATCH 2/2] Rendering of selection center (disabled) --- src/libslic3r/Technologies.hpp | 2 ++ src/slic3r/GUI/GLCanvas3D.cpp | 49 +++++++++++++++++++++++++++++++++- src/slic3r/GUI/GLCanvas3D.hpp | 13 +++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index d604896ad..0f0ae974b 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -40,6 +40,8 @@ #define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0) // Adds background texture to toolbars #define ENABLE_TOOLBAR_BACKGROUND_TEXTURE (1 && ENABLE_1_42_0) +// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active +#define ENABLE_RENDER_SELECTION_CENTER (0 && ENABLE_1_42_0) #endif // _technologies_h_ diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index f34341a0e..776a31c47 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1162,8 +1162,21 @@ GLCanvas3D::Selection::Selection() , m_valid(false) , m_bounding_box_dirty(true) { +#if ENABLE_RENDER_SELECTION_CENTER + m_quadric = ::gluNewQuadric(); + if (m_quadric != nullptr) + ::gluQuadricDrawStyle(m_quadric, GLU_FILL); +#endif // ENABLE_RENDER_SELECTION_CENTER } +#if ENABLE_RENDER_SELECTION_CENTER +GLCanvas3D::Selection::~Selection() +{ + if (m_quadric != nullptr) + ::gluDeleteQuadric(m_quadric); +} +#endif // ENABLE_RENDER_SELECTION_CENTER + void GLCanvas3D::Selection::set_volumes(GLVolumePtrs* volumes) { m_volumes = volumes; @@ -1994,7 +2007,7 @@ void GLCanvas3D::Selection::erase() void GLCanvas3D::Selection::render() const { - if (is_empty()) + if (!m_valid || is_empty()) return; // render cumulative bounding box of selected volumes @@ -2002,6 +2015,28 @@ void GLCanvas3D::Selection::render() const _render_synchronized_volumes(); } +#if ENABLE_RENDER_SELECTION_CENTER +void GLCanvas3D::Selection::render_center() const +{ + if (!m_valid || is_empty() || (m_quadric == nullptr)) + return; + + const Vec3d& center = get_bounding_box().center(); + + ::glDisable(GL_DEPTH_TEST); + + ::glEnable(GL_LIGHTING); + + ::glColor3f(1.0f, 1.0f, 1.0f); + ::glPushMatrix(); + ::glTranslated(center(0), center(1), center(2)); + ::gluSphere(m_quadric, 0.75, 32, 32); + ::glPopMatrix(); + + ::glDisable(GL_LIGHTING); +} +#endif // ENABLE_RENDER_SELECTION_CENTER + void GLCanvas3D::Selection::_update_valid() { m_valid = (m_volumes != nullptr) && (m_model != nullptr); @@ -4097,6 +4132,10 @@ void GLCanvas3D::render() if (!is_custom_bed) // textured bed needs to be rendered after objects _render_bed(theta); +#if ENABLE_RENDER_SELECTION_CENTER + _render_selection_center(); +#endif // ENABLE_RENDER_SELECTION_CENTER + // we need to set the mouse's scene position here because the depth buffer // could be invalidated by the following gizmo render methods // this position is used later into on_mouse() to drag the objects @@ -6138,6 +6177,14 @@ void GLCanvas3D::_render_selection() const m_selection.render(); } +#if ENABLE_RENDER_SELECTION_CENTER +void GLCanvas3D::_render_selection_center() const +{ + if (!m_gizmos.is_running()) + m_selection.render_center(); +} +#endif // ENABLE_RENDER_SELECTION_CENTER + void GLCanvas3D::_render_warning_texture() const { if (!m_warning_texture_enabled) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 906412e6a..9fb514c86 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -491,8 +491,15 @@ public: mutable BoundingBoxf3 m_bounding_box; mutable bool m_bounding_box_dirty; +#if ENABLE_RENDER_SELECTION_CENTER + GLUquadricObj* m_quadric; +#endif // ENABLE_RENDER_SELECTION_CENTER + public: Selection(); +#if ENABLE_RENDER_SELECTION_CENTER + ~Selection(); +#endif // ENABLE_RENDER_SELECTION_CENTER void set_volumes(GLVolumePtrs* volumes); @@ -567,6 +574,9 @@ public: void erase(); void render() const; +#if ENABLE_RENDER_SELECTION_CENTER + void render_center() const; +#endif // ENABLE_RENDER_SELECTION_CENTER private: void _update_valid(); @@ -1024,6 +1034,9 @@ private: void _render_axes() const; void _render_objects() const; void _render_selection() const; +#if ENABLE_RENDER_SELECTION_CENTER + void _render_selection_center() const; +#endif // ENABLE_RENDER_SELECTION_CENTER void _render_warning_texture() const; void _render_legend_texture() const; void _render_layer_editing_overlay() const;