From f289efab23d97078c051a6957dd5db95566ecddb Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 30 Nov 2018 14:26:41 +0100 Subject: [PATCH 01/11] Fixed a few bugs with pad_enable and supports_enable --- src/libslic3r/PrintConfig.cpp | 8 ++++---- src/libslic3r/SLAPrint.cpp | 17 +++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 77fc4dee4..9cb62aa9c 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2349,14 +2349,14 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("Width of the display"); def->cli = "display-width=f"; def->min = 1; - def->default_value = new ConfigOptionFloat(150.); + def->default_value = new ConfigOptionFloat(120.); def = this->add("display_height", coFloat); def->label = L("Display height"); def->tooltip = L("Height of the display"); def->cli = "display-height=f"; def->min = 1; - def->default_value = new ConfigOptionFloat(100.); + def->default_value = new ConfigOptionFloat(68.); def = this->add("display_pixels_x", coInt); def->full_label = L("Number of pixels in"); @@ -2364,14 +2364,14 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("Number of pixels in X"); def->cli = "display-pixels-x=i"; def->min = 100; - def->default_value = new ConfigOptionInt(2000); + def->default_value = new ConfigOptionInt(2560); def = this->add("display_pixels_y", coInt); def->label = ("Y"); def->tooltip = L("Number of pixels in Y"); def->cli = "display-pixels-y=i"; def->min = 100; - def->default_value = new ConfigOptionInt(1000); + def->default_value = new ConfigOptionInt(1440); def = this->add("printer_correction", coFloats); def->full_label = L("Printer scaling correction"); diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 6721decf9..77cac33ce 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -927,8 +927,10 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vector steps; bool invalidated = false; for (const t_config_option_key &opt_key : opt_keys) { - if ( opt_key == "supports_enable" - || opt_key == "support_head_front_diameter" + if( opt_key == "supports_enable") { + steps.emplace_back(slaposSupportPoints); + } else if ( + opt_key == "support_head_front_diameter" || opt_key == "support_head_penetration" || opt_key == "support_head_width" || opt_key == "support_pillar_diameter" @@ -1071,21 +1073,20 @@ TriangleMesh SLAPrintObject::get_mesh(SLAPrintObjectStep step) const } } - - const TriangleMesh& SLAPrintObject::support_mesh() const { - if(m_supportdata && m_supportdata->support_tree_ptr) - return m_supportdata->support_tree_ptr->merged_mesh(); + if(m_config.supports_enable.getBool() && m_supportdata && + m_supportdata->support_tree_ptr) return m_supportdata->support_tree_ptr->merged_mesh(); return EMPTY_MESH; } const TriangleMesh& SLAPrintObject::pad_mesh() const { - if(!m_supportdata || !m_supportdata->support_tree_ptr) return EMPTY_MESH; + if(m_config.pad_enable.getBool() && m_supportdata && m_supportdata->support_tree_ptr) + return m_supportdata->support_tree_ptr->get_pad(); - return m_supportdata->support_tree_ptr->get_pad(); + return EMPTY_MESH; } const TriangleMesh &SLAPrintObject::transformed_mesh() const { From d50644eef829b5a56f7e1cb81f836d42d14e2937 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 30 Nov 2018 15:41:45 +0100 Subject: [PATCH 02/11] Fix for uninitialized variable which might break sla auto rotation --- src/slic3r/GUI/Plater.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index af5c79bd3..f21bbabf7 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1061,6 +1061,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) #endif // ENABLE_NEW_MENU_LAYOUT { arranging.store(false); + rotoptimizing.store(false); background_process.set_fff_print(&print); background_process.set_sla_print(&sla_print); background_process.set_gcode_preview_data(&gcode_preview_data); From 138c98b5ec10a21d5197329ce1a04099265040b3 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 30 Nov 2018 18:00:35 +0100 Subject: [PATCH 03/11] Deps: Windows: Fix a couple of configurations --- CMakeLists.txt | 2 +- deps/deps-windows.cmake | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13f278ef1..7bee6c59b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,7 +272,7 @@ add_custom_target(pot # libslic3r, Slic3r GUI and the slic3r executable. add_subdirectory(src) -set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT slic3r) +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT slic3r_app_console) # Perl bindings, currently only used for the unit / integration tests of libslic3r. # Also runs the unit / integration tests. diff --git a/deps/deps-windows.cmake b/deps/deps-windows.cmake index a47a29be1..f366fe73e 100644 --- a/deps/deps-windows.cmake +++ b/deps/deps-windows.cmake @@ -45,7 +45,7 @@ ExternalProject_Add(dep_tbb URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_ARGS - -DCMAKE_DEBUG_POSTFIX=d + -DCMAKE_DEBUG_POSTFIX=_debug -DTBB_BUILD_SHARED=OFF -DTBB_BUILD_TESTS=OFF "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local" @@ -69,6 +69,7 @@ ExternalProject_Add(dep_gtest URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_ARGS -DBUILD_GMOCK=OFF + -Dgtest_force_shared_crt=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local" BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj @@ -91,6 +92,7 @@ ExternalProject_Add(dep_nlopt URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_ARGS + -DBUILD_SHARED_LIBS=OFF -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_MATLAB=OFF @@ -118,6 +120,7 @@ ExternalProject_Add(dep_zlib URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066 CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_ARGS + "-DINSTALL_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}\\fallout" # I found no better way of preventing zlib creating & installing DLLs :-/ -DCMAKE_POSITION_INDEPENDENT_CODE=ON "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local" BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj From 624df6bf9a668a5ee92584deb57d34c9e7dee815 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 3 Dec 2018 08:51:18 +0100 Subject: [PATCH 04/11] Extended grabbers for gizmo move --- src/slic3r/GUI/GLGizmo.cpp | 57 ++++++++++++++++++++++++++++++++++---- src/slic3r/GUI/GLGizmo.hpp | 1 + 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index 6eb057372..3d162f5a3 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -565,7 +565,7 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool picking) const { - float size = m_dragging ? m_grabbers[0].get_dragging_half_size((float)box.max_size()) : m_grabbers[0].get_half_size((float)box.max_size()); + double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[0].get_half_size((float)box.max_size()); float color[3]; ::memcpy((void*)color, (const void*)m_grabbers[0].color, 3 * sizeof(float)); @@ -587,9 +587,9 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick ::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0); ::glRotated(90.0, 1.0, 0.0, 0.0); ::glTranslated(0.0, 0.0, 2.0 * size); - ::gluCylinder(quadric, 0.75f * size, 0.0f, 3.0f * size, 36, 1); + ::gluCylinder(quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); ::gluQuadricOrientation(quadric, GLU_INSIDE); - ::gluDisk(quadric, 0.0f, 0.75f * size, 36, 1); + ::gluDisk(quadric, 0.0, 0.75 * size, 36, 1); ::glPopMatrix(); ::glPushMatrix(); ::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)); @@ -597,9 +597,9 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick ::glRotated(-90.0, 1.0, 0.0, 0.0); ::glTranslated(0.0, 0.0, 2.0 * size); ::gluQuadricOrientation(quadric, GLU_OUTSIDE); - ::gluCylinder(quadric, 0.75f * size, 0.0f, 3.0f * size, 36, 1); + ::gluCylinder(quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); ::gluQuadricOrientation(quadric, GLU_INSIDE); - ::gluDisk(quadric, 0.0f, 0.75f * size, 36, 1); + ::gluDisk(quadric, 0.0, 0.75 * size, 36, 1); ::glPopMatrix(); ::gluDeleteQuadric(quadric); @@ -1248,6 +1248,9 @@ void GLGizmoMove3D::on_render(const GLCanvas3D::Selection& selection) const // draw grabbers render_grabbers(box); + render_grabber_extension(X, box, false); + render_grabber_extension(Y, box, false); + render_grabber_extension(Z, box, false); } else { @@ -1260,6 +1263,7 @@ void GLGizmoMove3D::on_render(const GLCanvas3D::Selection& selection) const // draw grabber m_grabbers[m_hover_id].render(true, box.max_size()); + render_grabber_extension((Axis)m_hover_id, box, false); } } @@ -1267,7 +1271,11 @@ void GLGizmoMove3D::on_render_for_picking(const GLCanvas3D::Selection& selection { ::glDisable(GL_DEPTH_TEST); - render_grabbers_for_picking(selection.get_bounding_box()); + const BoundingBoxf3& box = selection.get_bounding_box(); + render_grabbers_for_picking(box); + render_grabber_extension(X, box, true); + render_grabber_extension(Y, box, true); + render_grabber_extension(Z, box, true); } #if ENABLE_IMGUI @@ -1315,6 +1323,43 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const return projection; } +void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const +{ + double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[axis].get_half_size((float)box.max_size()); + + float color[3]; + ::memcpy((void*)color, (const void*)m_grabbers[axis].color, 3 * sizeof(float)); + if (!picking && (m_hover_id != -1)) + { + color[0] = 1.0f - color[0]; + color[1] = 1.0f - color[1]; + color[2] = 1.0f - color[2]; + } + + if (!picking) + ::glEnable(GL_LIGHTING); + + ::glColor3fv(color); + GLUquadricObj* quadric = ::gluNewQuadric(); + ::gluQuadricDrawStyle(quadric, GLU_FILL); + ::glPushMatrix(); + ::glTranslated(m_grabbers[axis].center(0), m_grabbers[axis].center(1), m_grabbers[axis].center(2)); + if (axis == X) + ::glRotated(90.0, 0.0, 1.0, 0.0); + else if (axis == Y) + ::glRotated(-90.0, 1.0, 0.0, 0.0); + + ::glTranslated(0.0, 0.0, 2.0 * size); + ::gluCylinder(quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); + ::gluQuadricOrientation(quadric, GLU_INSIDE); + ::gluDisk(quadric, 0.0, 0.75 * size, 36, 1); + ::glPopMatrix(); + ::gluDeleteQuadric(quadric); + + if (!picking) + ::glDisable(GL_LIGHTING); +} + GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent) : GLGizmoBase(parent) , m_normal(Vec3d::Zero()) diff --git a/src/slic3r/GUI/GLGizmo.hpp b/src/slic3r/GUI/GLGizmo.hpp index cedd4a67d..674fe1c3c 100644 --- a/src/slic3r/GUI/GLGizmo.hpp +++ b/src/slic3r/GUI/GLGizmo.hpp @@ -378,6 +378,7 @@ protected: private: double calc_projection(const UpdateData& data) const; + void render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const; }; class GLGizmoFlatten : public GLGizmoBase From 020994f98748b92d5a24ee964097949cc98a4d04 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 3 Dec 2018 09:37:46 +0100 Subject: [PATCH 05/11] Refactoring into extended gizmo grabbers --- src/slic3r/GUI/GLGizmo.cpp | 85 +++++++++++++++++++++++++++++++------- src/slic3r/GUI/GLGizmo.hpp | 10 +++++ 2 files changed, 79 insertions(+), 16 deletions(-) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index 3d162f5a3..d9cf881c3 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -309,6 +309,7 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis) : GLGizmoBase(parent) , m_axis(axis) , m_angle(0.0) + , m_quadric(nullptr) , m_center(0.0, 0.0, 0.0) , m_radius(0.0f) , m_snap_coarse_in_radius(0.0f) @@ -316,6 +317,32 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis) , m_snap_fine_in_radius(0.0f) , m_snap_fine_out_radius(0.0f) { + m_quadric = ::gluNewQuadric(); + if (m_quadric != nullptr) + ::gluQuadricDrawStyle(m_quadric, GLU_FILL); +} + +GLGizmoRotate::GLGizmoRotate(const GLGizmoRotate& other) + : GLGizmoBase(other.m_parent) + , m_axis(other.m_axis) + , m_angle(other.m_angle) + , m_quadric(nullptr) + , m_center(other.m_center) + , m_radius(other.m_radius) + , m_snap_coarse_in_radius(other.m_snap_coarse_in_radius) + , m_snap_coarse_out_radius(other.m_snap_coarse_out_radius) + , m_snap_fine_in_radius(other.m_snap_fine_in_radius) + , m_snap_fine_out_radius(other.m_snap_fine_out_radius) +{ + m_quadric = ::gluNewQuadric(); + if (m_quadric != nullptr) + ::gluQuadricDrawStyle(m_quadric, GLU_FILL); +} + +GLGizmoRotate::~GLGizmoRotate() +{ + if (m_quadric != nullptr) + ::gluDeleteQuadric(m_quadric); } void GLGizmoRotate::set_angle(double angle) @@ -565,6 +592,9 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool picking) const { + if (m_quadric == nullptr) + return; + double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[0].get_half_size((float)box.max_size()); float color[3]; @@ -580,28 +610,26 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick ::glEnable(GL_LIGHTING); ::glColor3fv(color); - GLUquadricObj* quadric = ::gluNewQuadric(); - ::gluQuadricDrawStyle(quadric, GLU_FILL); ::glPushMatrix(); ::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)); ::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0); ::glRotated(90.0, 1.0, 0.0, 0.0); ::glTranslated(0.0, 0.0, 2.0 * size); - ::gluCylinder(quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); - ::gluQuadricOrientation(quadric, GLU_INSIDE); - ::gluDisk(quadric, 0.0, 0.75 * size, 36, 1); + ::gluQuadricOrientation(m_quadric, GLU_OUTSIDE); + ::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); + ::gluQuadricOrientation(m_quadric, GLU_INSIDE); + ::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1); ::glPopMatrix(); ::glPushMatrix(); ::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)); ::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0); ::glRotated(-90.0, 1.0, 0.0, 0.0); ::glTranslated(0.0, 0.0, 2.0 * size); - ::gluQuadricOrientation(quadric, GLU_OUTSIDE); - ::gluCylinder(quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); - ::gluQuadricOrientation(quadric, GLU_INSIDE); - ::gluDisk(quadric, 0.0, 0.75 * size, 36, 1); + ::gluQuadricOrientation(m_quadric, GLU_OUTSIDE); + ::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); + ::gluQuadricOrientation(m_quadric, GLU_INSIDE); + ::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1); ::glPopMatrix(); - ::gluDeleteQuadric(quadric); if (!picking) ::glDisable(GL_LIGHTING); @@ -1136,7 +1164,31 @@ GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent) , m_starting_drag_position(Vec3d::Zero()) , m_starting_box_center(Vec3d::Zero()) , m_starting_box_bottom_center(Vec3d::Zero()) + , m_quadric(nullptr) { + m_quadric = ::gluNewQuadric(); + if (m_quadric != nullptr) + ::gluQuadricDrawStyle(m_quadric, GLU_FILL); +} + +GLGizmoMove3D::GLGizmoMove3D(const GLGizmoMove3D& other) + : GLGizmoBase(other.m_parent) + , m_displacement(other.m_displacement) + , m_snap_step(other.m_snap_step) + , m_starting_drag_position(other.m_starting_drag_position) + , m_starting_box_center(other.m_starting_box_center) + , m_starting_box_bottom_center(other.m_starting_box_bottom_center) + , m_quadric(nullptr) +{ + m_quadric = ::gluNewQuadric(); + if (m_quadric != nullptr) + ::gluQuadricDrawStyle(m_quadric, GLU_FILL); +} + +GLGizmoMove3D::~GLGizmoMove3D() +{ + if (m_quadric != nullptr) + ::gluDeleteQuadric(m_quadric); } bool GLGizmoMove3D::on_init() @@ -1325,6 +1377,9 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const { + if (m_quadric == nullptr) + return; + double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[axis].get_half_size((float)box.max_size()); float color[3]; @@ -1340,8 +1395,6 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box ::glEnable(GL_LIGHTING); ::glColor3fv(color); - GLUquadricObj* quadric = ::gluNewQuadric(); - ::gluQuadricDrawStyle(quadric, GLU_FILL); ::glPushMatrix(); ::glTranslated(m_grabbers[axis].center(0), m_grabbers[axis].center(1), m_grabbers[axis].center(2)); if (axis == X) @@ -1350,11 +1403,11 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box ::glRotated(-90.0, 1.0, 0.0, 0.0); ::glTranslated(0.0, 0.0, 2.0 * size); - ::gluCylinder(quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); - ::gluQuadricOrientation(quadric, GLU_INSIDE); - ::gluDisk(quadric, 0.0, 0.75 * size, 36, 1); + ::gluQuadricOrientation(m_quadric, GLU_OUTSIDE); + ::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1); + ::gluQuadricOrientation(m_quadric, GLU_INSIDE); + ::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1); ::glPopMatrix(); - ::gluDeleteQuadric(quadric); if (!picking) ::glDisable(GL_LIGHTING); diff --git a/src/slic3r/GUI/GLGizmo.hpp b/src/slic3r/GUI/GLGizmo.hpp index 674fe1c3c..ae2cf660c 100644 --- a/src/slic3r/GUI/GLGizmo.hpp +++ b/src/slic3r/GUI/GLGizmo.hpp @@ -14,6 +14,8 @@ class wxWindow; +class GLUquadric; +typedef class GLUquadric GLUquadricObj; namespace Slic3r { @@ -199,6 +201,8 @@ private: Axis m_axis; double m_angle; + GLUquadricObj* m_quadric; + mutable Vec3d m_center; mutable float m_radius; @@ -209,6 +213,8 @@ private: public: GLGizmoRotate(GLCanvas3D& parent, Axis axis); + GLGizmoRotate(const GLGizmoRotate& other); + virtual ~GLGizmoRotate(); double get_angle() const { return m_angle; } void set_angle(double angle); @@ -355,8 +361,12 @@ class GLGizmoMove3D : public GLGizmoBase Vec3d m_starting_box_center; Vec3d m_starting_box_bottom_center; + GLUquadricObj* m_quadric; + public: explicit GLGizmoMove3D(GLCanvas3D& parent); + GLGizmoMove3D(const GLGizmoMove3D& other); + virtual ~GLGizmoMove3D(); double get_snap_step(double step) const { return m_snap_step; } void set_snap_step(double step) { m_snap_step = step; } From 693a4168f84e86a138d3b4206619a9f433126a02 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 3 Dec 2018 10:17:42 +0100 Subject: [PATCH 06/11] Always show axis name when hovering over gizmo grabbers --- src/slic3r/GUI/GLGizmo.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index d9cf881c3..df566cd48 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -418,17 +418,19 @@ void GLGizmoRotate::on_render(const GLCanvas3D::Selection& selection) const std::string axis; switch (m_axis) { - case X: { axis = "X: "; break; } - case Y: { axis = "Y: "; break; } - case Z: { axis = "Z: "; break; } + case X: { axis = "X"; break; } + case Y: { axis = "Y"; break; } + case Z: { axis = "Z"; break; } } #if ENABLE_WORLD_ROTATIONS - if (m_dragging) + if (!m_dragging && (m_hover_id == 0)) + set_tooltip(axis); + else if (m_dragging) #else if ((single_selection && (m_hover_id == 0)) || m_dragging) #endif // ENABLE_WORLD_ROTATIONS - set_tooltip(axis + format((float)Geometry::rad2deg(m_angle), 4) + "\u00B0"); + set_tooltip(axis + ": " + format((float)Geometry::rad2deg(m_angle), 4) + "\u00B0"); else { m_center = box.center(); @@ -875,10 +877,16 @@ void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const if ((single_selection && ((m_hover_id == 0) || (m_hover_id == 1))) || m_grabbers[0].dragging || m_grabbers[1].dragging) set_tooltip("X: " + format(scale(0), 4) + "%"); + else if (!m_grabbers[0].dragging && !m_grabbers[1].dragging && ((m_hover_id == 0) || (m_hover_id == 1))) + set_tooltip("X"); else if ((single_selection && ((m_hover_id == 2) || (m_hover_id == 3))) || m_grabbers[2].dragging || m_grabbers[3].dragging) set_tooltip("Y: " + format(scale(1), 4) + "%"); + else if (!m_grabbers[2].dragging && !m_grabbers[3].dragging && ((m_hover_id == 2) || (m_hover_id == 3))) + set_tooltip("Y"); else if ((single_selection && ((m_hover_id == 4) || (m_hover_id == 5))) || m_grabbers[4].dragging || m_grabbers[5].dragging) set_tooltip("Z: " + format(scale(2), 4) + "%"); + else if (!m_grabbers[4].dragging && !m_grabbers[5].dragging && ((m_hover_id == 4) || (m_hover_id == 5))) + set_tooltip("Z"); else if ((single_selection && ((m_hover_id == 6) || (m_hover_id == 7) || (m_hover_id == 8) || (m_hover_id == 9))) || m_grabbers[6].dragging || m_grabbers[7].dragging || m_grabbers[8].dragging || m_grabbers[9].dragging) { @@ -887,6 +895,9 @@ void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const tooltip += "Z: " + format(scale(2), 4) + "%"; set_tooltip(tooltip); } + else if (!m_grabbers[6].dragging && !m_grabbers[7].dragging && !m_grabbers[8].dragging && !m_grabbers[9].dragging && + ((m_hover_id == 6) || (m_hover_id == 7) || (m_hover_id == 8) || (m_hover_id == 9))) + set_tooltip("X/Y/Z"); #if ENABLE_GIZMOS_ON_TOP ::glClear(GL_DEPTH_BUFFER_BIT); @@ -1256,10 +1267,16 @@ void GLGizmoMove3D::on_render(const GLCanvas3D::Selection& selection) const if ((show_position && (m_hover_id == 0)) || m_grabbers[0].dragging) set_tooltip("X: " + format(show_position ? position(0) : m_displacement(0), 2)); + else if (!m_grabbers[0].dragging && (m_hover_id == 0)) + set_tooltip("X"); else if ((show_position && (m_hover_id == 1)) || m_grabbers[1].dragging) set_tooltip("Y: " + format(show_position ? position(1) : m_displacement(1), 2)); + else if (!m_grabbers[1].dragging && (m_hover_id == 1)) + set_tooltip("Y"); else if ((show_position && (m_hover_id == 2)) || m_grabbers[2].dragging) set_tooltip("Z: " + format(show_position ? position(2) : m_displacement(2), 2)); + else if (!m_grabbers[2].dragging && (m_hover_id == 2)) + set_tooltip("Z"); #if ENABLE_GIZMOS_ON_TOP ::glClear(GL_DEPTH_BUFFER_BIT); From 6693b2102d914c4af36e62b5cc97455ccb521567 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Fri, 30 Nov 2018 20:52:45 +0100 Subject: [PATCH 07/11] deps script for Mac OS, XCode support fix --- deps/CMakeLists.txt | 16 ++- ...eps-unix-static.cmake => deps-linux.cmake} | 75 +++---------- deps/deps-macos.cmake | 103 ++++++++++++++++++ deps/deps-unix-common.cmake | 60 ++++++++++ deps/deps-windows.cmake | 3 +- src/CMakeLists.txt | 7 ++ 6 files changed, 198 insertions(+), 66 deletions(-) rename deps/{deps-unix-static.cmake => deps-linux.cmake} (60%) create mode 100644 deps/deps-macos.cmake create mode 100644 deps/deps-unix-common.cmake diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index eca86a7c5..e2c525480 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -20,16 +20,18 @@ project(Slic3r-deps) cmake_minimum_required(VERSION 3.2) include(ExternalProject) - include(ProcessorCount) + ProcessorCount(NPROC) if (NPROC EQUAL 0) set(NPROC 1) endif () set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory") -option(DEP_DEBUG "Build debug variants (currently only works on Windows)" ON) +option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON) +message(STATUS "Slic3r deps DESTDIR: ${DESTDIR}") +message(STATUS "Slic3r deps debug build: ${DEP_DEBUG}") if (MSVC) if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") @@ -43,8 +45,16 @@ if (MSVC) else () message(FATAL_ERROR "Unable to detect architecture") endif () +elseif (APPLE) + set(DEPS_OSX_TARGET "10.9" CACHE STRING "OS X SDK version to build against") + set(DEPS_OSX_SYSROOT + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${DEPS_OSX_TARGET}.sdk" + CACHE PATH "OS X SDK directory" + ) + + include("deps-macos.cmake") else () - include("deps-unix-static.cmake") + include("deps-linux.cmake") endif() add_custom_target(deps ALL diff --git a/deps/deps-unix-static.cmake b/deps/deps-linux.cmake similarity index 60% rename from deps/deps-unix-static.cmake rename to deps/deps-linux.cmake index cbba0f14d..3f504b400 100644 --- a/deps/deps-unix-static.cmake +++ b/deps/deps-linux.cmake @@ -1,4 +1,9 @@ +set(DEP_CMAKE_OPTS "-DCMAKE_POSITION_INDEPENDENT_CODE=ON") + +include("deps-unix-common.cmake") + + ExternalProject_Add(dep_boost EXCLUDE_FROM_ALL 1 URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz" @@ -9,74 +14,17 @@ ExternalProject_Add(dep_boost "--prefix=${DESTDIR}/usr/local" BUILD_COMMAND ./b2 -j ${NPROC} + --reconfigure link=static variant=release threading=multi boost.locale.icu=off - cxxflags=-fPIC cflags=-fPIC + cflags=-fPIC + cxxflags=-fPIC install INSTALL_COMMAND "" # b2 does that already ) -ExternalProject_Add(dep_tbb - EXCLUDE_FROM_ALL 1 - URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz" - URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe - CMAKE_ARGS -DTBB_BUILD_SHARED=OFF - -DTBB_BUILD_TESTS=OFF - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" -) - -ExternalProject_Add(dep_gtest - EXCLUDE_FROM_ALL 1 - URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" - URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c - CMAKE_ARGS -DBUILD_GMOCK=OFF - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" -) - -ExternalProject_Add(dep_nlopt - EXCLUDE_FROM_ALL 1 - URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz" - URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae - CMAKE_GENERATOR "${DEP_MSVC_GEN}" - CMAKE_ARGS - -DNLOPT_PYTHON=OFF - -DNLOPT_OCTAVE=OFF - -DNLOPT_MATLAB=OFF - -DNLOPT_GUILE=OFF - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" - INSTALL_COMMAND "" -) - -ExternalProject_Add(dep_zlib - EXCLUDE_FROM_ALL 1 - URL "https://zlib.net/zlib-1.2.11.tar.xz" - URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066 - CMAKE_GENERATOR "${DEP_MSVC_GEN}" - CMAKE_ARGS - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" - INSTALL_COMMAND "" -) - -ExternalProject_Add(dep_libpng - DEPENDS dep_zlib - EXCLUDE_FROM_ALL 1 - URL "http://prdownloads.sourceforge.net/libpng/libpng-1.6.35.tar.xz?download" - URL_HASH SHA256=23912ec8c9584917ed9b09c5023465d71709dce089be503c7867fec68a93bcd7 - CMAKE_GENERATOR "${DEP_MSVC_GEN}" - CMAKE_ARGS - -DPNG_SHARED=OFF - -DPNG_TESTS=OFF - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" - INSTALL_COMMAND "" -) - ExternalProject_Add(dep_libopenssl EXCLUDE_FROM_ALL 1 URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_0g.tar.gz" @@ -94,7 +42,7 @@ ExternalProject_Add(dep_libopenssl ExternalProject_Add(dep_libcurl EXCLUDE_FROM_ALL 1 - DEPENDS dep_libopenssl + DEPENDS dep_libopenssl URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz" URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115 BUILD_IN_SOURCE 1 @@ -145,10 +93,11 @@ ExternalProject_Add(dep_wxwidgets URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2" URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e BUILD_IN_SOURCE 1 + PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h CONFIGURE_COMMAND ./configure "--prefix=${DESTDIR}/usr/local" --disable-shared - --with-gtk=2 + --with-gtk=2 --with-opengl --enable-unicode --enable-graphics_ctx @@ -162,6 +111,8 @@ ExternalProject_Add(dep_wxwidgets --disable-precomp-headers --enable-debug_info --enable-debug_gdb + --disable-debug + --disable-debug_flag BUILD_COMMAND make "-j${NPROC}" && make -C locale allmo INSTALL_COMMAND make install ) diff --git a/deps/deps-macos.cmake b/deps/deps-macos.cmake new file mode 100644 index 000000000..10c15dace --- /dev/null +++ b/deps/deps-macos.cmake @@ -0,0 +1,103 @@ + +set(DEP_CMAKE_OPTS + "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" + "-DCMAKE_OSX_SYSROOT=${DEPS_OSX_SYSROOT}" + "-DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPS_OSX_TARGET}" +) + +include("deps-unix-common.cmake") + + +ExternalProject_Add(dep_boost + EXCLUDE_FROM_ALL 1 + URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz" + URL_HASH SHA256=bd0df411efd9a585e5a2212275f8762079fed8842264954675a4fddc46cfcf60 + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./bootstrap.sh + --with-libraries=system,filesystem,thread,log,locale,regex + "--prefix=${DESTDIR}/usr/local" + BUILD_COMMAND ./b2 + -j ${NPROC} + --reconfigure + link=static + variant=release + threading=multi + boost.locale.icu=off + "cflags=cflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}" + "cxxflags=cxxflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}" + install + INSTALL_COMMAND "" # b2 does that already +) + +ExternalProject_Add(dep_libcurl + EXCLUDE_FROM_ALL 1 + URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz" + URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115 + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure + --enable-static + --disable-shared + "--with-ssl=${DESTDIR}/usr/local" + --with-pic + --enable-ipv6 + --enable-versioned-symbols + --enable-threaded-resolver + --with-darwinssl + --without-ssl # disables OpenSSL + --disable-ldap + --disable-ldaps + --disable-manual + --disable-rtsp + --disable-dict + --disable-telnet + --disable-pop3 + --disable-imap + --disable-smb + --disable-smtp + --disable-gopher + --disable-crypto-auth + --without-gssapi + --without-libpsl + --without-libidn2 + --without-gnutls + --without-polarssl + --without-mbedtls + --without-cyassl + --without-nss + --without-axtls + --without-brotli + --without-libmetalink + --without-libssh + --without-libssh2 + --without-librtmp + --without-nghttp2 + --without-zsh-functions-dir + BUILD_COMMAND make "-j${NPROC}" + INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" +) + +ExternalProject_Add(dep_wxwidgets + EXCLUDE_FROM_ALL 1 + URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2" + URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e + BUILD_IN_SOURCE 1 + PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h + CONFIGURE_COMMAND ./configure + "--prefix=${DESTDIR}/usr/local" + --disable-shared + --with-osx_cocoa + "--with-macosx-version-min=${DEPS_OSX_TARGET}" + "--with-macosx-sdk=${DEPS_OSX_SYSROOT}" + --with-opengl + --with-regex=builtin + --with-libpng=builtin + --with-libxpm=builtin + --with-libjpeg=builtin + --with-libtiff=builtin + --with-zlib=builtin + --with-expat=builtin + --disable-debug + --disable-debug_flag + BUILD_COMMAND make "-j${NPROC}" && make -C locale allmo + INSTALL_COMMAND make install +) diff --git a/deps/deps-unix-common.cmake b/deps/deps-unix-common.cmake new file mode 100644 index 000000000..7ad1b4290 --- /dev/null +++ b/deps/deps-unix-common.cmake @@ -0,0 +1,60 @@ + +# The unix common part expects DEP_CMAKE_OPTS to be set + +ExternalProject_Add(dep_tbb + EXCLUDE_FROM_ALL 1 + URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz" + URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe + CMAKE_ARGS + -DTBB_BUILD_SHARED=OFF + -DTBB_BUILD_TESTS=OFF + ${DEP_CMAKE_OPTS} + INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" +) + +ExternalProject_Add(dep_gtest + EXCLUDE_FROM_ALL 1 + URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" + URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c + CMAKE_ARGS -DBUILD_GMOCK=OFF ${DEP_CMAKE_OPTS} + INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" +) + +ExternalProject_Add(dep_nlopt + EXCLUDE_FROM_ALL 1 + URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz" + URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae + CMAKE_GENERATOR "${DEP_MSVC_GEN}" + CMAKE_ARGS + -DNLOPT_PYTHON=OFF + -DNLOPT_OCTAVE=OFF + -DNLOPT_MATLAB=OFF + -DNLOPT_GUILE=OFF + ${DEP_CMAKE_OPTS} + INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" + INSTALL_COMMAND "" +) + +ExternalProject_Add(dep_zlib + EXCLUDE_FROM_ALL 1 + URL "https://zlib.net/zlib-1.2.11.tar.xz" + URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066 + CMAKE_GENERATOR "${DEP_MSVC_GEN}" + CMAKE_ARGS ${DEP_CMAKE_OPTS} + INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" + INSTALL_COMMAND "" +) + +ExternalProject_Add(dep_libpng + DEPENDS dep_zlib + EXCLUDE_FROM_ALL 1 + URL "http://prdownloads.sourceforge.net/libpng/libpng-1.6.35.tar.xz?download" + URL_HASH SHA256=23912ec8c9584917ed9b09c5023465d71709dce089be503c7867fec68a93bcd7 + CMAKE_GENERATOR "${DEP_MSVC_GEN}" + CMAKE_ARGS + -DPNG_SHARED=OFF + -DPNG_TESTS=OFF + ${DEP_CMAKE_OPTS} + INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" + INSTALL_COMMAND "" +) diff --git a/deps/deps-windows.cmake b/deps/deps-windows.cmake index f366fe73e..d49434ecb 100644 --- a/deps/deps-windows.cmake +++ b/deps/deps-windows.cmake @@ -68,7 +68,8 @@ ExternalProject_Add(dep_gtest URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c CMAKE_GENERATOR "${DEP_MSVC_GEN}" - CMAKE_ARGS -DBUILD_GMOCK=OFF + CMAKE_ARGS + -DBUILD_GMOCK=OFF -Dgtest_force_shared_crt=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b60319611..d714eb91a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -163,6 +163,13 @@ if (MSVC) VERBATIM ) endif () +elseif (XCODE) + # Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level + add_custom_command(TARGET slic3r POST_BUILD + COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/resources" + COMMENT "Symlinking the resources directory into the build tree" + VERBATIM + ) else () add_custom_command(TARGET slic3r POST_BUILD COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/../resources" From e1c90c83e83615d26bd16838dd2eae079cd8619b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 3 Dec 2018 10:37:46 +0100 Subject: [PATCH 08/11] Fixed GLVolumes reuse after instance deletion --- src/libslic3r/Model.cpp | 8 ++++++++ src/libslic3r/Model.hpp | 3 +++ src/slic3r/GUI/GUI_ObjectList.cpp | 1 + 3 files changed, 12 insertions(+) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 59477db4a..c16fb7ab5 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -690,6 +690,14 @@ void ModelObject::clear_volumes() this->invalidate_bounding_box(); } +void ModelObject::reset_volumes_idxs() +{ + for (ModelVolume *v : this->volumes) + { + v->set_new_unique_id(); + } +}//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + ModelInstance* ModelObject::add_instance() { ModelInstance* i = new ModelInstance(this); diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index b9831336c..5b2599282 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -200,6 +200,9 @@ public: void clear_volumes(); bool is_multiparts() const { return volumes.size() > 1; } + // set a new unique id to all volumes + void reset_volumes_idxs(); + ModelInstance* add_instance(); ModelInstance* add_instance(const ModelInstance &instance); ModelInstance* add_instance(const Vec3d &offset, const Vec3d &scaling_factor, const Vec3d &rotation); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 3c8efbf22..3de6ca281 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -949,6 +949,7 @@ bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, con return false; } (*m_objects)[obj_idx]->delete_instance(idx); + (*m_objects)[obj_idx]->reset_volumes_idxs(); } else return false; From 2bdb86c7ed2d621334653db67e2a2b17edd0f71c Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 3 Dec 2018 10:48:06 +0100 Subject: [PATCH 09/11] deps: warn that wx-config can't be moved into another location --- CMakeLists.txt | 9 +++++---- deps/CMakeLists.txt | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bee6c59b..7e094a85f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,11 +44,12 @@ endif () # CMAKE_PREFIX_PATH is used to point CMake to the remaining dependencies (Boost, TBB, ...) # We pick it from environment if it is not defined in another way -if(NOT DEFINED CMAKE_PREFIX_PATH) - if(DEFINED ENV{CMAKE_PREFIX_PATH}) +if (NOT DEFINED CMAKE_PREFIX_PATH) + if (DEFINED ENV{CMAKE_PREFIX_PATH}) set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") - endif() -endif() + endif () +endif () +message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") # Add our own cmake module path. list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index e2c525480..8f98e0bda 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -15,6 +15,9 @@ # On Windows, architecture (64 vs 32 bits) is judged based on the compiler variant. # To build dependencies for either 64 or 32 bit OS, use the respective compiler command line. # +# WARNING: On UNIX platforms wxWidgets hardcode the destdir path into its `wx-conffig` utility, +# therefore, unfortunatelly, the installation cannot be copied/moved elsewhere without re-installing wxWidgets. +# project(Slic3r-deps) cmake_minimum_required(VERSION 3.2) From c205e3fb0cea93a531e5f7f75b892fe127814c46 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 3 Dec 2018 11:14:17 +0100 Subject: [PATCH 10/11] Gizmo flatten -> allow for only single instance and let planes follow the instance when moving the object by dragging it on the scene --- src/libslic3r/Model.cpp | 2 +- src/slic3r/GUI/GLGizmo.cpp | 79 ++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 46 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index c16fb7ab5..74683e2cc 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -696,7 +696,7 @@ void ModelObject::reset_volumes_idxs() { v->set_new_unique_id(); } -}//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +} ModelInstance* ModelObject::add_instance() { diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index df566cd48..9609c2166 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -1464,9 +1464,7 @@ std::string GLGizmoFlatten::on_get_name() const bool GLGizmoFlatten::on_is_activable(const GLCanvas3D::Selection& selection) const { - return (selection.is_from_single_object() - && (selection.is_single_full_instance() || selection.is_multiple_full_instance() || selection.is_single_full_object()) - && !selection.is_wipe_tower() && !selection.is_modifier()); + return selection.is_single_full_instance(); } void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection) @@ -1480,44 +1478,33 @@ void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection) void GLGizmoFlatten::on_render(const GLCanvas3D::Selection& selection) const { - // The planes are rendered incorrectly when the object is being moved. We better won't render anything in that case. - // This indeed has a better solution (to be implemented when there is more time) - Vec3d dragged_offset(Vec3d::Zero()); - if (m_starting_center == Vec3d::Zero()) - m_starting_center = selection.get_bounding_box().center(); - dragged_offset = selection.get_bounding_box().center() - m_starting_center; - if (dragged_offset.norm() > 0.001) - return; - - #if ENABLE_GIZMOS_ON_TOP ::glClear(GL_DEPTH_BUFFER_BIT); #endif // ENABLE_GIZMOS_ON_TOP + ::glEnable(GL_DEPTH_TEST); ::glEnable(GL_BLEND); - if (selection.is_from_single_object()) { - if (m_model_object) { - //for (const int instance_idx : instances_list) { - for (const ModelInstance* inst : m_model_object->instances) { - Transform3d m = inst->get_matrix(); - for (int i=0; i<(int)m_planes.size(); ++i) { - if (i == m_hover_id) - ::glColor4f(0.9f, 0.9f, 0.9f, 0.75f); - else - ::glColor4f(0.9f, 0.9f, 0.9f, 0.5f); + if (selection.is_single_full_instance()) + { + const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(); + ::glPushMatrix(); + ::glMultMatrixd(m.data()); + for (int i = 0; i < (int)m_planes.size(); ++i) + { + if (i == m_hover_id) + ::glColor4f(0.9f, 0.9f, 0.9f, 0.75f); + else + ::glColor4f(0.9f, 0.9f, 0.9f, 0.5f); - m.pretranslate(dragged_offset); - ::glPushMatrix(); - ::glMultMatrixd(m.data()); - ::glBegin(GL_POLYGON); - for (const Vec3d& vertex : m_planes[i].vertices) - ::glVertex3dv(vertex.data()); - ::glEnd(); - ::glPopMatrix(); - } + ::glBegin(GL_POLYGON); + for (const Vec3d& vertex : m_planes[i].vertices) + { + ::glVertex3dv(vertex.data()); } + ::glEnd(); } + ::glPopMatrix(); } ::glEnable(GL_CULL_FACE); @@ -1529,20 +1516,22 @@ void GLGizmoFlatten::on_render_for_picking(const GLCanvas3D::Selection& selectio ::glDisable(GL_DEPTH_TEST); ::glDisable(GL_BLEND); - if (selection.is_from_single_object()) { - if (m_model_object) - for (const ModelInstance* inst : m_model_object->instances) { - for (int i=0; i<(int)m_planes.size(); ++i) { - ::glColor3f(1.0f, 1.0f, picking_color_component(i)); - ::glPushMatrix(); - ::glMultMatrixd(inst->get_matrix().data()); - ::glBegin(GL_POLYGON); - for (const Vec3d& vertex : m_planes[i].vertices) - ::glVertex3dv(vertex.data()); - ::glEnd(); - ::glPopMatrix(); - } + if (selection.is_single_full_instance()) + { + const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(); + ::glPushMatrix(); + ::glMultMatrixd(m.data()); + for (int i = 0; i < (int)m_planes.size(); ++i) + { + ::glColor3f(1.0f, 1.0f, picking_color_component(i)); + ::glBegin(GL_POLYGON); + for (const Vec3d& vertex : m_planes[i].vertices) + { + ::glVertex3dv(vertex.data()); } + ::glEnd(); + } + ::glPopMatrix(); } ::glEnable(GL_CULL_FACE); From d522e8ea70014bac834b2e9d9ecdf72d133cb067 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 3 Dec 2018 12:13:18 +0100 Subject: [PATCH 11/11] Delete mixed selection --- src/slic3r/GUI/GLCanvas3D.cpp | 53 +++++++++++++++++++++++++++++++ src/slic3r/GUI/GUI_ObjectList.hpp | 12 +++++++ 2 files changed, 65 insertions(+) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 2eb1464ba..bffc3725f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1854,6 +1854,59 @@ void GLCanvas3D::Selection::erase() wxGetApp().obj_list()->delete_from_model_and_list(items); } + else if (is_mixed()) + { + std::set items_set; + std::map volumes_in_obj; + + for (auto i : m_list) { + const auto gl_vol = (*m_volumes)[i]; + const auto glv_obj_idx = gl_vol->object_idx(); + const auto model_object = m_model->objects[glv_obj_idx]; + + if (model_object->instances.size() == 1) { + if (model_object->volumes.size() == 1) + items_set.insert(ItemForDelete(ItemType::itObject, glv_obj_idx, -1)); + else { + items_set.insert(ItemForDelete(ItemType::itVolume, glv_obj_idx, gl_vol->volume_idx())); + int idx = (volumes_in_obj.find(glv_obj_idx) == volumes_in_obj.end()) ? 0 : volumes_in_obj.at(glv_obj_idx); + volumes_in_obj[glv_obj_idx] = ++idx; + } + continue; + } + + const auto glv_ins_idx = gl_vol->instance_idx(); + + for (auto obj_ins : m_cache.content) { + if (obj_ins.first == glv_obj_idx) { + if (obj_ins.second.find(glv_ins_idx) != obj_ins.second.end()) { + if (obj_ins.second.size() == model_object->instances.size()) + items_set.insert(ItemForDelete(ItemType::itVolume, glv_obj_idx, gl_vol->volume_idx())); + else + items_set.insert(ItemForDelete(ItemType::itInstance, glv_obj_idx, glv_ins_idx)); + + break; + } + } + } + } + + std::vector items; + items.reserve(items_set.size()); + for (const ItemForDelete& i : items_set) { + if (i.type == ItemType::itVolume ) { + const int vol_in_obj_cnt = volumes_in_obj.find(i.obj_idx) == volumes_in_obj.end() ? 0 : volumes_in_obj.at(i.obj_idx); + if (vol_in_obj_cnt == m_model->objects[i.obj_idx]->volumes.size()) { + if (i.sub_obj_idx == vol_in_obj_cnt - 1) + items.emplace_back(ItemType::itObject, i.obj_idx, 0); + continue; + } + } + items.emplace_back(i.type, i.obj_idx, i.sub_obj_idx); + } + + wxGetApp().obj_list()->delete_from_model_and_list(items); + } else { std::set> volumes_idxs; diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index f93db2a39..ea89ae6f5 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -34,6 +34,18 @@ struct ItemForDelete ItemForDelete(ItemType type, int obj_idx, int sub_obj_idx) : type(type), obj_idx(obj_idx), sub_obj_idx(sub_obj_idx) {} + + bool operator==(const ItemForDelete& r) const + { + return (type == r.type && obj_idx == r.obj_idx && sub_obj_idx == r.sub_obj_idx); + } + + bool operator<(const ItemForDelete& r) const + { + if (obj_idx != r.obj_idx) + return (obj_idx < r.obj_idx); + return (sub_obj_idx < r.sub_obj_idx); + } }; class ObjectList : public wxDataViewCtrl