diff --git a/CMakeLists.txt b/CMakeLists.txt index fad1af6f3..76c937cae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ endif() option(SLIC3R_STATIC "Compile Slic3r with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL}) option(SLIC3R_GUI "Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1) option(SLIC3R_FHS "Assume Slic3r is to be installed in a FHS directory structure" 0) +option(SLIC3R_WX_STABLE "Build against wxWidgets stable (3.0) as oppsed to dev (3.1) on Linux" 0) option(SLIC3R_PROFILE "Compile Slic3r with an invasive Shiny profiler" 0) option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1) option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1) @@ -112,14 +113,17 @@ if (APPLE) endif () if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - # Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD. - add_compile_options(-std=c++11 -Wall -Wno-reorder) find_package(PkgConfig REQUIRED) + + if (CMAKE_VERSION VERSION_LESS "3.1") + # Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif() endif() if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX) # Adding -fext-numeric-literals to enable GCC extensions on definitions of quad float literals, which are required by Boost. - add_compile_options(-fext-numeric-literals) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals" ) if (SLIC3R_SYNTAXONLY) set(CMAKE_CXX_ARCHIVE_CREATE "true") @@ -136,9 +140,15 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX) endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_compile_options(-Wall) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder" ) + # On GCC and Clang, no return from a non-void function is a warning only. Here, we make it an error. add_compile_options(-Werror=return-type) + #removes LOTS of extraneous Eigen warnings + add_compile_options(-Wno-ignored-attributes) + if (SLIC3R_ASAN) add_compile_options(-fsanitize=address -fno-omit-frame-pointer) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") @@ -245,7 +255,7 @@ endif() # Find eigen3 or use bundled version if (NOT SLIC3R_STATIC) - find_package(Eigen3) + find_package(Eigen3 3) endif () if (NOT Eigen3_FOUND) set(Eigen3_FOUND 1) diff --git a/cmake/modules/PrecompiledHeader.cmake b/cmake/modules/PrecompiledHeader.cmake index 2880da9f2..e46302144 100644 --- a/cmake/modules/PrecompiledHeader.cmake +++ b/cmake/modules/PrecompiledHeader.cmake @@ -68,11 +68,37 @@ function(export_all_flags _filename) set(_compile_definitions "$") set(_compile_flags "$") set(_compile_options "$") + + #handle config-specific cxx flags + string(TOUPPER ${CMAKE_BUILD_TYPE} _config) + set(_build_cxx_flags ${CMAKE_CXX_FLAGS_${_config}}) + + #handle fpie option + get_target_property(_fpie ${_target} POSITION_INDEPENDENT_CODE) + if (_fpie AND CMAKE_POSITION_INDEPENDENT_CODE) + list(APPEND _compile_options ${CMAKE_CXX_COMPILE_OPTIONS_PIC}) + endif() + + #handle compiler standard (GCC only) + if(CMAKE_COMPILER_IS_GNUCXX) + get_target_property(_cxx_standard ${_target} CXX_STANDARD) + if ((NOT "${_cxx_standard}" STREQUAL NOTFOUND) AND (NOT "${_cxx_standard}" STREQUAL "")) + get_target_property(_cxx_extensions ${_target} CXX_EXTENSIONS) + get_property(_exists TARGET ${_target} PROPERTY CXX_EXTENSIONS SET) + if (NOT _exists OR ${_cxx_extensions}) + list(APPEND _compile_options "-std=gnu++${_cxx_standard}") + else() + list(APPEND _compile_options "-std=c++${_cxx_standard}") + endif() + endif() + endif() + set(_include_directories "$<$:-I$\n>") set(_compile_definitions "$<$:-D$\n>") set(_compile_flags "$<$:$\n>") set(_compile_options "$<$:$\n>") - file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}\n") + set(_cxx_flags "$<$:${CMAKE_CXX_FLAGS}\n>$<$:${_build_cxx_flags}\n>") + file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}${_cxx_flags}\n") endfunction() function(add_precompiled_header _target _input) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 1b23c5864..386320d81 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -33,6 +33,7 @@ endif () set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory") option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON) +option(DEP_WX_STABLE "Build against wxWidgets stable 3.0 as opposed to default 3.1 (Linux only)" OFF) message(STATUS "Slic3r deps DESTDIR: ${DESTDIR}") message(STATUS "Slic3r deps debug build: ${DEP_DEBUG}") diff --git a/deps/deps-linux.cmake b/deps/deps-linux.cmake index 3f504b400..bf39f59e7 100644 --- a/deps/deps-linux.cmake +++ b/deps/deps-linux.cmake @@ -88,16 +88,24 @@ ExternalProject_Add(dep_libcurl INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" ) +if (DEP_WX_STABLE) + set(DEP_WX_URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.4/wxWidgets-3.0.4.tar.bz2") + set(DEP_WX_HASH "SHA256=96157f988d261b7368e5340afa1a0cad943768f35929c22841f62c25b17bf7f0") +else () + set(DEP_WX_URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2") + set(DEP_WX_HASH "SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e") +endif() + 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 + URL "${DEP_WX_URL}" + URL_HASH "${DEP_WX_HASH}" 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 diff --git a/doc/How to build - Windows.md b/doc/How to build - Windows.md index 898c830d0..90fcfde7d 100644 --- a/doc/How to build - Windows.md +++ b/doc/How to build - Windows.md @@ -7,7 +7,7 @@ CMake installer can be downloaded from [the official website](https://cmake.org/ Building with newer versions of MSVS (2015, 2017) may work too as reported by some of our users. -_Note:_ Thanks to **@supermerill** for testing and inspiration on this guide. +_Note:_ Thanks to [**@supermerill**](https://github.com/supermerill) for testing and inspiration on this guide. ### Dependencies diff --git a/resources/icons/gcode.icns b/resources/icons/gcode.icns new file mode 100644 index 000000000..d5be3bd57 Binary files /dev/null and b/resources/icons/gcode.icns differ diff --git a/resources/icons/stl.icns b/resources/icons/stl.icns new file mode 100644 index 000000000..a96989598 Binary files /dev/null and b/resources/icons/stl.icns differ diff --git a/resources/models/mk3_bed.stl b/resources/models/mk3_bed.stl index cfa6d8c6d..1bd1a8faa 100644 Binary files a/resources/models/mk3_bed.stl and b/resources/models/mk3_bed.stl differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa043cf9e..fd5a735d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,19 @@ if (SLIC3R_GUI) endif() endif() - find_package(wxWidgets REQUIRED COMPONENTS base core adv html gl) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + if (SLIC3R_WX_STABLE) + find_package(wxWidgets 3.0 REQUIRED COMPONENTS base core adv html gl) + else () + find_package(wxWidgets 3.1 QUIET COMPONENTS base core adv html gl) + if (NOT wxWidgets_FOUND) + message(FATAL_ERROR "\nCould not find wxWidgets 3.1.\nHint: On Linux you can set -DSLIC3R_WX_STABLE=1 to use wxWidgets 3.0") + endif () + endif () + else () + find_package(wxWidgets 3.1 REQUIRED COMPONENTS base core adv html gl) + endif () + include(${wxWidgets_USE_FILE}) endif() diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index c9fbe90ac..6f22ba89e 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -561,6 +561,12 @@ bool DynamicConfig::read_cli(int argc, char** argv, t_config_option_keys* extra) extra->push_back(token); continue; } +#ifdef __APPLE__ + if (boost::starts_with(token, "-psn_")) + // OSX launcher may add a "process serial number", for example "-psn_0_989382" to the command line. + // While it is supposed to be dropped since OSX 10.9, we will rather ignore it. + continue; +#endif /* __APPLE__ */ // Stop parsing tokens as options when -- is supplied. if (token == "--") { parse_options = false; diff --git a/src/libslic3r/Geometry.cpp b/src/libslic3r/Geometry.cpp index fc5b158c7..8faa49ea0 100644 --- a/src/libslic3r/Geometry.cpp +++ b/src/libslic3r/Geometry.cpp @@ -1181,22 +1181,34 @@ Transform3d assemble_transform(const Vec3d& translation, const Vec3d& rotation, Vec3d extract_euler_angles(const Eigen::Matrix& rotation_matrix) { + auto y_only = [](const Eigen::Matrix& matrix) -> bool { + return (matrix(0, 1) == 0.0) && (matrix(1, 0) == 0.0) && (matrix(1, 1) == 1.0) && (matrix(1, 2) == 0.0) && (matrix(2, 1) == 0.0); + }; + // see: https://www.learnopencv.com/rotation-matrix-to-euler-angles/ - double sy = ::sqrt(sqr(rotation_matrix(0, 0)) + sqr(rotation_matrix(1, 0))); + double cy_abs = ::sqrt(sqr(rotation_matrix(0, 0)) + sqr(rotation_matrix(1, 0))); Vec3d angles = Vec3d::Zero(); - if (sy >= 1e-6) + if (cy_abs >= 1e-6) { angles(0) = ::atan2(rotation_matrix(2, 1), rotation_matrix(2, 2)); - angles(1) = ::atan2(-rotation_matrix(2, 0), sy); + angles(1) = ::atan2(-rotation_matrix(2, 0), cy_abs); angles(2) = ::atan2(rotation_matrix(1, 0), rotation_matrix(0, 0)); + + // this is an hack to try to avoid this function to return "strange" values due to gimbal lock + if (y_only(rotation_matrix) && (angles(0) == (double)PI) && (angles(2) == (double)PI)) + { + angles(0) = 0.0; + angles(1) = ::atan2(rotation_matrix(2, 0), cy_abs) - (double)PI; + angles(2) = 0.0; + } } else { angles(0) = 0.0; - angles(1) = ::atan2(-rotation_matrix(2, 0), sy); - angles(2) = (angles(1) >-0.0) ? ::atan2(rotation_matrix(1, 2), rotation_matrix(1, 1)) : ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1)); + angles(1) = ::atan2(-rotation_matrix(2, 0), cy_abs); + angles(2) = (angles(1) >= 0.0) ? ::atan2(rotation_matrix(1, 2), rotation_matrix(1, 1)) : ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1)); } return angles; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 7da839dc3..1efbe2209 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2527,6 +2527,22 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->default_value = new ConfigOptionFloat(1.0); + def = this->add("support_pillar_connection_mode", coEnum); + def->label = L("Support pillar connection mode"); + def->tooltip = L("Controls the bridge type between two neigboring pillars." + " Can be zig-zag, cross (double zig-zag) or dynamic which" + " will automatically switch between the first two depending" + " on the distance of the two pillars."); + def->cli = ""; + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values.push_back("zigzag"); + def->enum_values.push_back("cross"); + def->enum_values.push_back("dynamic"); + def->enum_labels.push_back(L("Zig-Zag")); + def->enum_labels.push_back(L("Cross")); + def->enum_labels.push_back(L("Dynamic")); + def->default_value = new ConfigOptionEnum(slapcmDynamic); + def = this->add("support_pillar_widening_factor", coFloat); def->label = L("Pillar widening factor"); def->category = L("Supports"); @@ -3044,7 +3060,7 @@ CLIConfigDef::CLIConfigDef() def->tooltip = L("Forces the GUI launch instead of command line slicing " "(if you supply a model file, it will be loaded into the plater)"); def->cli = "gui"; - def->default_value = new ConfigOptionBool(true); + def->default_value = new ConfigOptionBool(false); def = this->add("info", coBool); def->label = L("Output Model Info"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 4e12114df..4842156d6 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -61,6 +61,12 @@ enum SLADisplayOrientation { sladoPortrait }; +enum SLAPillarConnectionMode { + slapcmZigZag, + slapcmCross, + slapcmDynamic +}; + template<> inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { static t_config_enum_values keys_map; if (keys_map.empty()) { @@ -162,6 +168,16 @@ template<> inline const t_config_enum_values& ConfigOptionEnum inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { + static const t_config_enum_values keys_map = { + {"zigzag", slapcmZigZag}, + {"cross", slapcmCross}, + {"dynamic", slapcmDynamic} + }; + + return keys_map; +} + // Defines each and every confiuration option of Slic3r, including the properties of the GUI dialogs. // Does not store the actual values, but defines default values. class PrintConfigDef : public ConfigDef @@ -949,6 +965,9 @@ public: // Radius in mm of the support pillars. ConfigOptionFloat support_pillar_diameter /*= 0.8*/; + // How the pillars are bridged together + ConfigOptionEnum support_pillar_connection_mode; + // TODO: unimplemented at the moment. This coefficient will have an impact // when bridges and pillars are merged. The resulting pillar should be a bit // thicker than the ones merging into it. How much thicker? I don't know @@ -1003,6 +1022,7 @@ protected: OPT_PTR(support_head_penetration); OPT_PTR(support_head_width); OPT_PTR(support_pillar_diameter); + OPT_PTR(support_pillar_connection_mode); OPT_PTR(support_pillar_widening_factor); OPT_PTR(support_base_diameter); OPT_PTR(support_base_height); diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 5239255b1..bc02d2b58 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -1249,8 +1249,13 @@ bool SLASupportTree::generate(const PointSet &points, if(chkd >= bridge_distance) { result.add_bridge(sj, ej, pillar.r); + auto pcm = cfg.pillar_connection_mode; + // double bridging: (crosses) - if(pillar_dist > 2*cfg.base_radius_mm) { + if( pcm == PillarConnectionMode::cross || + (pcm == PillarConnectionMode::dynamic && + pillar_dist > 2*cfg.base_radius_mm)) + { // If the columns are close together, no need to // double bridge them Vec3d bsj(ej(X), ej(Y), sj(Z)); diff --git a/src/libslic3r/SLA/SLASupportTree.hpp b/src/libslic3r/SLA/SLASupportTree.hpp index c187cf5b3..5a86d4623 100644 --- a/src/libslic3r/SLA/SLASupportTree.hpp +++ b/src/libslic3r/SLA/SLASupportTree.hpp @@ -28,6 +28,12 @@ using SlicedSupports = std::vector; namespace sla { +enum class PillarConnectionMode { + zigzag, + cross, + dynamic +}; + struct SupportConfig { // Radius in mm of the pointing side of the head. double head_front_radius_mm = 0.2; @@ -46,6 +52,9 @@ struct SupportConfig { // headless pillars will have half of this value. double headless_pillar_radius_mm = 0.4; + // How to connect pillars + PillarConnectionMode pillar_connection_mode = PillarConnectionMode::dynamic; + // TODO: unimplemented at the moment. This coefficient will have an impact // when bridges and pillars are merged. The resulting pillar should be a bit // thicker than the ones merging into it. How much thicker? I don't know diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index aa759a47a..5cddadb5b 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -407,6 +407,14 @@ sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) { scfg.tilt = c.support_critical_angle.getFloat() * PI / 180.0 ; scfg.max_bridge_length_mm = c.support_max_bridge_length.getFloat(); scfg.headless_pillar_radius_mm = 0.375*c.support_pillar_diameter.getFloat(); + switch(c.support_pillar_connection_mode.getInt()) { + case slapcmZigZag: + scfg.pillar_connection_mode = sla::PillarConnectionMode::zigzag; break; + case slapcmCross: + scfg.pillar_connection_mode = sla::PillarConnectionMode::cross; break; + case slapcmDynamic: + scfg.pillar_connection_mode = sla::PillarConnectionMode::dynamic; break; + } scfg.pillar_widening_factor = c.support_pillar_widening_factor.getFloat(); scfg.base_radius_mm = 0.5*c.support_base_diameter.getFloat(); scfg.base_height_mm = c.support_base_height.getFloat(); @@ -1058,6 +1066,7 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vector???? CFBundleVersion @SLIC3R_BUILD_ID@ - CGDisableCoalescedUpdates - - NSPrincipalClass - NSApplication - NSHighResolutionCapable - - + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + stl + STL + + CFBundleTypeIconFile + stl.icns + CFBundleTypeName + STL + CFBundleTypeRole + Viewer + LISsAppleDefaultForType + + LSHandlerRank + Alternate + + + CFBundleTypeExtensions + + obj + OBJ + + CFBundleTypeIconFile + Slic3r.icns + CFBundleTypeName + STL + CFBundleTypeRole + Viewer + LISsAppleDefaultForType + + LSHandlerRank + Alternate + + + CFBundleTypeExtensions + + amf + AMF + + CFBundleTypeIconFile + Slic3r.icns + CFBundleTypeName + AMF + CFBundleTypeRole + Viewer + LISsAppleDefaultForType + + LSHandlerRank + Alternate + + + CFBundleTypeExtensions + + 3mf + 3MF + + CFBundleTypeIconFile + Slic3r.icns + CFBundleTypeName + 3MF + CFBundleTypeRole + Viewer + LISsAppleDefaultForType + + LSHandlerRank + Alternate + + + CFBundleTypeExtensions + + gcode + GCODE + + CFBundleTypeIconFile + gcode.icns + CFBundleTypeName + GCODE + CFBundleTypeRole + Editor + LISsAppleDefaultForType + + LSHandlerRank + Alternate + + + LSMinimumSystemVersion + 10.9 + NSPrincipalClass + NSApplication + NSHighResolutionCapable + + diff --git a/src/slic3r.cpp b/src/slic3r.cpp index d242df168..04076d567 100644 --- a/src/slic3r.cpp +++ b/src/slic3r.cpp @@ -96,6 +96,11 @@ int main(int argc, char **argv) // apply command line options to a more handy CLIConfig CLIConfig cli_config; +#ifdef __APPLE__ + // Enable the GUI mode by default, to support drag & drop. + cli_config.gui.value = true; +#endif /* __APPLE__ */ + cli_config.apply(all_config, true); set_data_dir(cli_config.datadir.value); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index e64bf3d5f..817de5d4f 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -718,6 +718,8 @@ boost::any& Choice::get_value() m_value = static_cast(ret_enum); else if (m_opt_id.compare("display_orientation") == 0) m_value = static_cast(ret_enum); + else if (m_opt_id.compare("support_pillar_connection_mode") == 0) + m_value = static_cast(ret_enum); } else if (m_opt.gui_type == "f_enum_open") { const int ret_enum = static_cast(window)->GetSelection(); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9d70fbc1b..20ecc70b9 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2041,7 +2041,7 @@ void GLCanvas3D::Selection::render_sidebar_hints(const std::string& sidebar_fiel if (is_single_full_instance()) { ::glTranslated(center(0), center(1), center(2)); - if (boost::starts_with(sidebar_field, "scale")) + if (boost::starts_with(sidebar_field, "scale") || boost::starts_with(sidebar_field, "size")) { Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); ::glMultMatrixd(orient_matrix.data()); @@ -2983,7 +2983,7 @@ bool GLCanvas3D::Gizmos::is_running() const bool GLCanvas3D::Gizmos::handle_shortcut(int key, const Selection& selection) { - if (!m_enabled) + if (!m_enabled || selection.is_empty()) return false; bool handled = false; @@ -6915,22 +6915,31 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c } } ctxt; - ctxt.shifted_copies = &print_object.copies(); - - // order layers by print_z - ctxt.layers.reserve(print_object.layers().size() + print_object.support_layers().size()); - for (const Layer *layer : print_object.layers()) - ctxt.layers.push_back(layer); - for (const Layer *layer : print_object.support_layers()) - ctxt.layers.push_back(layer); - std::sort(ctxt.layers.begin(), ctxt.layers.end(), [](const Layer *l1, const Layer *l2) { return l1->print_z < l2->print_z; }); - - // Maximum size of an allocation block: 32MB / sizeof(float) ctxt.has_perimeters = print_object.is_step_done(posPerimeters); ctxt.has_infill = print_object.is_step_done(posInfill); ctxt.has_support = print_object.is_step_done(posSupportMaterial); ctxt.tool_colors = tool_colors.empty() ? nullptr : &tool_colors; + ctxt.shifted_copies = &print_object.copies(); + + // order layers by print_z + { + size_t nlayers = 0; + if (ctxt.has_perimeters || ctxt.has_infill) + nlayers = print_object.layers().size(); + if (ctxt.has_support) + nlayers += print_object.support_layers().size(); + ctxt.layers.reserve(nlayers); + } + if (ctxt.has_perimeters || ctxt.has_infill) + for (const Layer *layer : print_object.layers()) + ctxt.layers.push_back(layer); + if (ctxt.has_support) + for (const Layer *layer : print_object.support_layers()) + ctxt.layers.push_back(layer); + std::sort(ctxt.layers.begin(), ctxt.layers.end(), [](const Layer *l1, const Layer *l2) { return l1->print_z < l2->print_z; }); + + // Maximum size of an allocation block: 32MB / sizeof(float) BOOST_LOG_TRIVIAL(debug) << "Loading print object toolpaths in parallel - start"; //FIXME Improve the heuristics for a grain size. diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index 0ac7e983e..292ef472a 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -36,7 +36,7 @@ bool GLTexture::load_from_file(const std::string& filename, bool generate_mipmap // Load a PNG with an alpha channel. wxImage image; - if (!image.LoadFile(wxString::FromUTF8(filename), wxBITMAP_TYPE_PNG)) + if (!image.LoadFile(wxString::FromUTF8(filename.c_str()), wxBITMAP_TYPE_PNG)) { reset(); return false; diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 0a27af9fa..bb5ab29e0 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -200,6 +200,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("display_orientation") == 0) config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); + else if(opt_key.compare("support_pillar_connection_mode") == 0) + config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); } break; case coPoints:{ @@ -232,7 +234,7 @@ void show_error(wxWindow* parent, const wxString& message) void show_error_id(int id, const std::string& message) { auto *parent = id != 0 ? wxWindow::FindWindowById(id) : nullptr; - show_error(parent, wxString::FromUTF8(message.data())); + show_error(parent, from_u8(message)); } void show_info(wxWindow* parent, const wxString& message, const wxString& title) @@ -322,7 +324,7 @@ wxString from_path(const boost::filesystem::path &path) #ifdef _WIN32 return wxString(path.string()); #else - return wxString::FromUTF8(path.string()); + return from_u8(path.string()); #endif } @@ -403,7 +405,7 @@ void desktop_open_datadir_folder() const auto path = data_dir(); #ifdef _WIN32 - const auto widepath = wxString::FromUTF8(path.data()); + const wxString widepath = from_u8(path); const wchar_t *argv[] = { L"explorer", widepath.GetData(), nullptr }; ::wxExecute(const_cast(argv), wxEXEC_ASYNC, nullptr); #elif __APPLE__ diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index b2111c4b1..4441c8c8b 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -67,7 +67,7 @@ wxString file_wildcards(FileType file_type, const std::string &custom_extension) out += std::string(";*") + custom_extension; } } - return wxString::FromUTF8(out.c_str()); + return from_u8(out); } static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); } @@ -464,7 +464,7 @@ bool GUI_App::select_language( wxArrayString & names, { m_wxLocale = new wxLocale; m_wxLocale->Init(identifiers[index]); - m_wxLocale->AddCatalogLookupPathPrefix(wxString::FromUTF8(localization_dir())); + m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir())); m_wxLocale->AddCatalog(/*GetAppName()*/"Slic3rPE"); //FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only. wxSetlocale(LC_NUMERIC, "C"); @@ -492,7 +492,7 @@ bool GUI_App::load_language() { m_wxLocale = new wxLocale; m_wxLocale->Init(identifiers[i]); - m_wxLocale->AddCatalogLookupPathPrefix(wxString::FromUTF8(localization_dir())); + m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir())); m_wxLocale->AddCatalog(/*GetAppName()*/"Slic3rPE"); //FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only. wxSetlocale(LC_NUMERIC, "C"); @@ -520,7 +520,7 @@ void GUI_App::get_installed_languages(wxArrayString & names, wxArrayLong & ident names.Clear(); identifiers.Clear(); - wxDir dir(wxString::FromUTF8(localization_dir())); + wxDir dir(from_u8(localization_dir())); wxString filename; const wxLanguageInfo * langinfo; wxString name = wxLocale::GetLanguageName(wxLANGUAGE_DEFAULT); @@ -742,6 +742,17 @@ void GUI_App::load_current_presets() } } +#ifdef __APPLE__ +// wxWidgets override to get an event on open files. +void GUI_App::MacOpenFiles(const wxArrayString &fileNames) +{ + std::vector files; + for (size_t i = 0; i < fileNames.GetCount(); ++ i) + files.emplace_back(fileNames[i].ToUTF8().data()); + this->plater()->load_files(files, true, true); +} +#endif /* __APPLE */ + Sidebar& GUI_App::sidebar() { return plater_->sidebar(); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 6027be71e..a0e20d7d4 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -144,6 +144,11 @@ public: void delete_tab_from_list(Tab* tab); void load_current_presets(); +#ifdef __APPLE__ + // wxWidgets override to get an event on open files. + void MacOpenFiles(const wxArrayString &fileNames) override; +#endif /* __APPLE */ + Sidebar& sidebar(); ObjectManipulation* obj_manipul(); ObjectSettings* obj_settings(); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 1092c761f..560d5b69c 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -685,29 +685,24 @@ void Preview::load_print_as_fff() // we require that there's at least one object and the posSlice step // is performed on all of them(this ensures that _shifted_copies was // populated and we know the number of layers) - unsigned int n_layers = 0; + bool has_layers = false; const Print *print = m_process->fff_print(); - if (print->is_step_done(posSlice)) - { - std::set zs; + if (print->is_step_done(posSlice)) { for (const PrintObject* print_object : print->objects()) - { - const LayerPtrs& layers = print_object->layers(); - const SupportLayerPtrs& support_layers = print_object->support_layers(); - for (const Layer* layer : layers) - { - zs.insert(layer->print_z); + if (! print_object->layers().empty()) { + has_layers = true; + break; } - for (const SupportLayer* layer : support_layers) - { - zs.insert(layer->print_z); + } + if (print->is_step_done(posSupportMaterial)) { + for (const PrintObject* print_object : print->objects()) + if (! print_object->support_layers().empty()) { + has_layers = true; + break; } - } - - n_layers = (unsigned int)zs.size(); } - if (n_layers == 0) + if (! has_layers) { reset_sliders(); m_canvas->reset_legend_texture(); @@ -761,8 +756,8 @@ void Preview::load_print_as_fff() show_hide_ui_elements("full"); // recalculates zs and update sliders accordingly - n_layers = (unsigned int)m_canvas->get_current_print_zs(true).size(); - if (n_layers == 0) + has_layers = ! m_canvas->get_current_print_zs(true).empty(); + if (! has_layers) { // all layers filtered out reset_sliders(); @@ -777,7 +772,7 @@ void Preview::load_print_as_fff() } - if (n_layers > 0) + if (has_layers) update_sliders(m_canvas->get_current_print_zs(true)); m_loaded = true; diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index bf7b3ed58..72c6f676b 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -557,6 +557,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config else if (opt_key.compare("display_orientation") == 0) { ret = static_cast(config.option>(opt_key)->value); } + else if (opt_key.compare("support_pillar_connection_mode") == 0) { + ret = static_cast(config.option>(opt_key)->value); + } } break; case coPoints: diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 14ddaad49..102b0610e 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -410,6 +410,7 @@ const std::vector& Preset::sla_print_options() "support_head_penetration", "support_head_width", "support_pillar_diameter", + "support_pillar_connection_mode", "support_pillar_widening_factor", "support_base_diameter", "support_base_height", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index dc3f5fbca..53ead470e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3161,6 +3161,7 @@ void TabSLAPrint::build() optgroup = page->new_optgroup(_(L("Support pillar"))); optgroup->append_single_option_line("support_pillar_diameter"); + optgroup->append_single_option_line("support_pillar_connection_mode"); optgroup->append_single_option_line("support_pillar_widening_factor"); optgroup->append_single_option_line("support_base_diameter"); optgroup->append_single_option_line("support_base_height"); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 3219a1e32..6c0b4a5e5 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -9,9 +9,12 @@ #include #include "BitmapCache.hpp" +#include "GUI.hpp" #include "GUI_App.hpp" #include "GUI_ObjectList.hpp" +using Slic3r::GUI::from_u8; + wxDEFINE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent); wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent); @@ -37,7 +40,7 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description, std::function cb, const std::string& icon, wxEvtHandler* event_handler) { - const wxBitmap& bmp = !icon.empty() ? wxBitmap(wxString::FromUTF8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG) : wxNullBitmap; + const wxBitmap& bmp = !icon.empty() ? wxBitmap(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG) : wxNullBitmap; return append_menu_item(menu, id, string, description, cb, bmp, event_handler); } @@ -48,7 +51,7 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin wxMenuItem* item = new wxMenuItem(menu, id, string, description); if (!icon.empty()) - item->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG)); + item->SetBitmap(wxBitmap(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG)); item->SetSubMenu(sub_menu); menu->Append(item); diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 1fad86e10..8979239d5 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -330,7 +330,7 @@ public: { if (GetChildCount() == 0) return; - for (size_t id = GetChildCount() - 1; id >= 0; --id) + for (int id = int(GetChildCount()) - 1; id >= 0; --id) { if (m_children.Item(id)->GetChildCount() > 0) m_children[id]->RemoveAllChildren();