From c019e648c720f25b88ef8e5e8d69cfd997fd6f3e Mon Sep 17 00:00:00 2001 From: supermerill Date: Fri, 6 Aug 2021 11:42:42 +0200 Subject: [PATCH 1/4] datadir parameter kept when launching new instance supermerill/SuperSlicer#1450 --- src/slic3r/Utils/Process.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slic3r/Utils/Process.cpp b/src/slic3r/Utils/Process.cpp index ab7cf2122ac..a97df2138c2 100644 --- a/src/slic3r/Utils/Process.cpp +++ b/src/slic3r/Utils/Process.cpp @@ -1,6 +1,7 @@ #include "Process.hpp" #include +#include #include "../GUI/GUI.hpp" // for file_wildcards() @@ -47,8 +48,10 @@ static void start_new_slicer_or_gcodeviewer(const NewSlicerInstanceType instance for (const auto& file : paths_to_open) args.emplace_back(file); } - if (instance_type == NewSlicerInstanceType::Slicer && single_instance) - args.emplace_back(L"--single-instance"); + if (instance_type == NewSlicerInstanceType::Slicer && single_instance) + args.emplace_back(L"--single-instance"); + args.emplace_back(L"--datadir"); + args.emplace_back(boost::nowide::widen(Slic3r::data_dir().c_str()).c_str()); args.emplace_back(nullptr); BOOST_LOG_TRIVIAL(info) << "Trying to spawn a new slicer \"" << into_u8(path) << "\""; // Don't call with wxEXEC_HIDE_CONSOLE, PrusaSlicer in GUI mode would just show the splash screen. It would not open the main window though, it would From 60a38c394c93d7b942dff98fe8067c140104e9d9 Mon Sep 17 00:00:00 2001 From: supermerill Date: Fri, 6 Aug 2021 17:57:33 +0200 Subject: [PATCH 2/4] fix prusa-compliant settings for 3mf export when an object-modifier setting is set --- src/libslic3r/Format/3mf.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index ad8635ba5d1..f8b4f09700b 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -2806,8 +2806,18 @@ namespace Slic3r { } // stores object's config data - for (const std::string& key : obj->config.keys()) { - stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << obj->config.opt_serialize(key) << "\"/>\n"; + if (file_path == MODEL_PRUSA_CONFIG_FILE) { + for (std::string key : obj->config.keys()) { + // convert to prusa config + std::string value = obj->config.opt_serialize(key); + obj->config.to_prusa(key, value); + if (!key.empty()) + stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n"; + } + } else { + for (const std::string& key : obj->config.keys()) { + stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << OBJECT_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << obj->config.opt_serialize(key) << "\"/>\n"; + } } for (const ModelVolume* volume : obj_metadata.second.object->volumes) @@ -2868,18 +2878,17 @@ namespace Slic3r { } // stores volume's config data - for (std::string key : volume->config.keys()) - { - // config - if (file_path == MODEL_PRUSA_CONFIG_FILE) { + if (file_path == MODEL_PRUSA_CONFIG_FILE) { + for (std::string key : volume->config.keys()) { // convert to prusa config std::string value = volume->config.opt_serialize(key); volume->config.to_prusa(key, value); if (!key.empty()) stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << value << "\"/>\n"; - } else { - stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << volume->config.opt_serialize(key) << "\"/>\n"; } + } else { + for (const std::string& key : volume->config.keys()) + stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << volume->config.opt_serialize(key) << "\"/>\n"; } stream << " \n"; From aa1abc251a8894a302c101943b4ff620227a0b46 Mon Sep 17 00:00:00 2001 From: supermerill Date: Fri, 6 Aug 2021 19:58:46 +0200 Subject: [PATCH 3/4] arrange changes: * check is now correct (was half the right distance) * now the duplicate_distance field is used to reset the widget, and it's not used as a shadow-min anymore * when switching preset, the arrange widget will change value according to the new duplicate_distance, unless it's set to 0 TODO: update widget when manually updating duplicate_distance or extruder_clearance_radius --- src/PrusaSlicer.cpp | 1 + src/libslic3r/Print.cpp | 2 +- src/libslic3r/PrintConfig.cpp | 8 +++----- src/slic3r/GUI/GLCanvas3D.cpp | 34 ++++++++++++++++++++++++++++++++-- src/slic3r/GUI/GLCanvas3D.hpp | 5 +---- src/slic3r/GUI/Tab.cpp | 11 +++++++++++ 6 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index 08bcf49c95a..17811f3c9d3 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -466,6 +466,7 @@ int CLI::run(int argc, char **argv) if (! m_config.opt_bool("dont_arrange")) { ArrangeParams arrange_cfg; arrange_cfg.min_obj_distance = scaled(PrintConfig::min_object_distance(&m_print_config)) * 2; + arrange_cfg.min_obj_distance += m_print_config.opt_float("duplicate_distance"); if (dups > 1) { try { // if all input objects have defined position(s) apply duplication to the whole model diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 9990027b549..900dae6e7b7 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1276,7 +1276,7 @@ static inline bool sequential_print_horizontal_clearance_valid(const Print &prin Polygons convex_hulls_other; std::map map_model_object_to_convex_hull; for (const PrintObject *print_object : print.objects()) { - double dist_grow = PrintConfig::min_object_distance(&print.full_print_config());// &print_object->config()); + double dist_grow = PrintConfig::min_object_distance(&print.full_print_config()) * 2 ;// &print_object->config()); assert(! print_object->model_object()->instances.empty()); assert(! print_object->instances().empty()); ObjectID model_object_id = print_object->model_object()->id(); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 031a6d1f176..7716b881e51 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -667,7 +667,7 @@ void PrintConfigDef::init_fff_params() def = this->add("duplicate_distance", coFloat); def->label = L("Distance between objects"); def->category = OptionCategory::output; - def->tooltip = L("Distance used for the auto-arrange feature of the plater."); + def->tooltip = L("Default distance used for the auto-arrange feature of the plater.\nSet to 0 to use the last value instead."); def->sidetext = L("mm"); def->aliases = { "multiply_distance" }; def->min = 0; @@ -5660,9 +5660,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei //test if called from usaslicer::l240 where it's called on an empty config... if (dd_opt == nullptr) return 0; - // /2 becasue we only count the grawing for the current object - const double duplicate_distance = dd_opt->value / 2; - double base_dist = duplicate_distance; + double base_dist = 0; //std::cout << "START min_object_distance =>" << base_dist << "\n"; const ConfigOptionBool* co_opt = config->option("complete_objects"); if (co_opt && co_opt->value) { @@ -5676,7 +5674,7 @@ double PrintConfig::min_object_distance(const ConfigBase *config, double ref_hei // min object distance is max(duplicate_distance, clearance_radius) // /2 becasue we only count the grawing for the current object //add 1 as safety offset. - double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat() / 2 + 1; + double extruder_clearance_radius = config->option("extruder_clearance_radius")->getFloat() / 2; if (extruder_clearance_radius > base_dist) { base_dist = extruder_clearance_radius; } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index d61c0b118d7..495e0ddf772 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1154,6 +1154,29 @@ void GLCanvas3D::load_arrange_settings() m_arrange_settings_sla.enable_rotation = (en_rot_sla_str == "1" || en_rot_sla_str == "yes"); } +// update arrange dist from current print conf. +void GLCanvas3D::set_arrange_settings(const DynamicPrintConfig& conf, PrinterTechnology tech) { + + const ConfigOptionFloat* dd_opt = conf.option("duplicate_distance"); + const ConfigOptionFloat* dd2_opt = m_config->option("duplicate_distance"); + + if (dd_opt && dd_opt != 0) { + float dist = 6.f; + if (tech == ptSLA) { + dist = dd_opt->value; + } else if (tech == ptFFF) { + const ConfigOptionBool* co_opt = conf.option("complete_objects"); + if (co_opt && co_opt->value) { + dist = float(PrintConfig::min_object_distance(m_config) * 2); + } else { + dist = 0.f; + } + dist += dd_opt->value; + } + this->get_arrange_settings().distance = dist; + } +} + PrinterTechnology GLCanvas3D::current_printer_technology() const { return m_process->current_printer_technology(); @@ -4045,7 +4068,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) } else if (ptech == ptFFF) { auto co_opt = m_config->option("complete_objects"); if (co_opt && co_opt->value) { - dist_min = float(PrintConfig::min_object_distance(m_config)); + dist_min = float(PrintConfig::min_object_distance(m_config) * 2); postfix = "_fff_seq_print"; } else { dist_min = 0.f; @@ -4059,7 +4082,11 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) imgui->text(GUI::format_wxstr(_L("Press %1%left mouse button to enter the exact value"), shortkey_ctrl_prefix())); if (imgui->slider_float(_L("Spacing"), &settings.distance, dist_min, 100.0f, "%5.2f") || dist_min > settings.distance) { - settings.distance = std::max(dist_min, settings.distance); + if (dist_min > settings.distance) { + const ConfigOptionFloat* dd_opt = this->m_config->option("duplicate_distance"); + if (dd_opt) + settings.distance = dist_min + dd_opt->value; + } settings_out.distance = settings.distance; appcfg->set("arrange", dist_key.c_str(), std::to_string(settings_out.distance)); settings_changed = true; @@ -4075,6 +4102,9 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) if (imgui->button(_L("Reset"))) { settings_out = ArrangeSettings{}; + const ConfigOptionFloat* dd_opt = this->m_config->option("duplicate_distance"); + if(dd_opt) + settings_out.distance = dist_min + dd_opt->value; settings_out.distance = std::max(dist_min, settings_out.distance); appcfg->set("arrange", dist_key.c_str(), std::to_string(settings_out.distance)); appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0"); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 053470432e4..7d6238c80a2 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -776,12 +776,9 @@ class GLCanvas3D { const ArrangeSettings &settings = get_arrange_settings(this); ArrangeSettings ret = settings; - if (&settings == &m_arrange_settings_fff_seq_print) { - ret.distance = std::max(ret.distance, float(PrintConfig::min_object_distance(m_config))); - } - return ret; } + void set_arrange_settings(const DynamicPrintConfig& conf, PrinterTechnology tech); // Timestamp for FPS calculation and notification fade-outs. static int64_t timestamp_now() { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 43d0392d162..32ac2a30cb4 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -44,6 +44,7 @@ #include "GUI_ObjectList.hpp" #include "Plater.hpp" #include "MainFrame.hpp" +#include "GLCanvas3D.hpp" #include "format.hpp" #include "PhysicalPrinterDialog.hpp" #include "UnsavedChangesDialog.hpp" @@ -3369,6 +3370,16 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, apply_config_from_cache(); load_current_preset(); + + // apply duplicate_distance for print preset + if (m_type == Preset::TYPE_PRINT) { + wxGetApp().mainframe->plater()->canvas3D()->set_arrange_settings(m_presets->get_edited_preset().config, m_presets->get_edited_preset().printer_technology()); + } + if (m_type == Preset::TYPE_PRINTER) { + wxGetApp().mainframe->plater()->canvas3D()->set_arrange_settings(m_preset_bundle->prints.get_edited_preset().config, m_presets->get_edited_preset().printer_technology()); + + } + } } From f88f224452cee36acfb472622966bb0e77739457 Mon Sep 17 00:00:00 2001 From: supermerill Date: Sat, 7 Aug 2021 17:45:17 +0200 Subject: [PATCH 4/4] Refine & fix BuildLinux script for fresh ubuntu 20.04 now you have to use an optino to compile, more info on -h --- BuildLinux.sh | 165 ++++++++++++++---------- src/platform/unix/BuildLinuxImage.sh.in | 23 ++-- 2 files changed, 113 insertions(+), 75 deletions(-) diff --git a/BuildLinux.sh b/BuildLinux.sh index 41d7b011411..0107695d94e 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -3,14 +3,28 @@ export ROOT=`pwd` export NCORES=`nproc --all` -while getopts ":ih" opt; do + +while getopts ":dsiuh" opt; do case ${opt} in + u ) + UPDATE_LIB="1" + ;; i ) - export BUILD_IMAGE="1" + BUILD_IMAGE="1" + ;; + d ) + BUILD_DEPS="1" ;; - h ) echo "Usage: ./BuildLinux.sh [-i][-u]" + s ) + BUILD_SLIC3R="1" + ;; + h ) echo "Usage: ./BuildLinux.sh [-i][-u][-d][-s]" echo " -i: Generate appimage (optional)" + echo " -d: build deps (optional)" + echo " -s: build slic3r (optional)" echo " -u: only update clock & dependency packets (optional and need sudo)" + echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'" + echo " and then './BuildLinux.sh -dsi'" exit 0 ;; esac @@ -22,33 +36,40 @@ then mkdir build fi - -if [[ -n "$BUILD_IMAGE" ]] +if [[ -n "$UPDATE_LIB" ]] then echo -n "Updating linux ..." - { - hwclock -s - apt update - apt install libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev - } > $ROOT/build/Build.log # Capture all command output + hwclock -s + apt update + apt install libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev cmake git echo "done" exit 0 fi -echo -n "[1/9] Updating submodules..." +FOUND_GTK2=$(dpkg -l libgtk* | grep gtk2.0-dev) +echo "FOUND_GTK2=$FOUND_GTK2)" +if [[ -z "$FOUND_GTK2" ]] +then + echo "Error, you must install the dependencies before." + echo "Use option -u with sudo" + exit 0 +fi + +echo "[1/9] Updating submodules..." { # update submodule profiles pushd resources/profiles git submodule update --init popd -} > $ROOT/build/Build.log # Capture all command output +} +# > $ROOT/build/Build.log # Capture all command output -echo -n "[2/9] Changing date in version..." +echo "[2/9] Changing date in version..." { # change date in version - sed "s/+UNKNOWN/_$(date '+%F')/" version.inc > version.date.inc - mv version.date.inc version.inc -} &> $ROOT/build/Build.log # Capture all command output + sed -i "s/+UNKNOWN/_$(date '+%F')/" version.inc +} +# &> $ROOT/build/Build.log # Capture all command output echo "done" # mkdir in deps @@ -57,66 +78,76 @@ then mkdir deps/build fi -echo -n "[3/9] Configuring dependencies..." -{ - # cmake deps - pushd deps/build - cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -} &> $ROOT/build/Build.log # Capture all command output -echo "done" - -echo -n "[4/9] Building dependencies..." -{ - # make deps - make -j$NCORES -} &> $ROOT/build/Build.log # Capture all command output -echo "done" - -echo -n "[5/9] Renaming wxscintilla library..." -{ - # rename wxscintilla - pushd destdir/usr/local/lib - cp libwxscintilla-3.1.a libwx_gtk2u_scintilla-3.1.a - popd -} &> $ROOT/build/Build.log # Capture all command output -echo "done" - -echo -n "[6/9] Cleaning dependencies..." -{ - # clean deps - rm -rf dep_* - popd -} &> $ROOT/build/Build.log # Capture all command output -echo "done" - -echo -n "[7/9] Configuring Slic3r..." -{ - # cmake - pushd build - cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" -DSLIC3R_STATIC=1 -} &> $ROOT/build/Build.log # Capture all command output -echo "done" - -echo -n "[8/9] Building Slic3r..." -{ - # make Slic3r - make -j$NCORES Slic3r +if [[ -n "$BUILD_DEPS" ]] +then + echo "[3/9] Configuring dependencies..." + + # cmake deps + pushd deps/build + cmake .. + + # &> $ROOT/build/Build.log # Capture all command output + echo "done" + + echo "[4/9] Building dependencies..." + + # make deps + make -j$NCORES + + # &> $ROOT/build/Build.log # Capture all command output + echo "done" + + echo "[5/9] Renaming wxscintilla library..." + + # rename wxscintilla + pushd destdir/usr/local/lib + cp libwxscintilla-3.1.a libwx_gtk2u_scintilla-3.1.a + popd + # &> $ROOT/build/Build.log # Capture all command output + echo "done" + + echo "[6/9] Cleaning dependencies..." + + # clean deps + rm -rf dep_* + popd + # &> $ROOT/build/Build.log # Capture all command output + echo "done" +fi - # make .mo - make gettext_po_to_mo -} &> $ROOT/build/Build.log # Capture all command output -echo "done" +if [[ -n "$BUILD_SLIC3R" ]] +then + echo "[7/9] Configuring Slic3r..." + + # cmake + pushd build + cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 + # &> $ROOT/build/Build.log # Capture all command output + echo "done" + + echo "[8/9] Building Slic3r..." + + # make Slic3r + make -j$NCORES Slic3r + + # make .mo + make gettext_po_to_mo + + popd + # &> $ROOT/build/Build.log # Capture all command output + echo "done" +fi # Give proper permissions to script chmod 755 $ROOT/build/src/BuildLinuxImage.sh -echo -n "[9/9] Generating Linux app..." -{ +echo "[9/9] Generating Linux app..." + pushd build if [[ -n "$BUILD_IMAGE" ]] then $ROOT/build/src/BuildLinuxImage.sh -i else $ROOT/build/src/BuildLinuxImage.sh fi -} &> $ROOT/build/Build.log # Capture all command output +# &> $ROOT/build/Build.log # Capture all command output echo "done" diff --git a/src/platform/unix/BuildLinuxImage.sh.in b/src/platform/unix/BuildLinuxImage.sh.in index 24d30661225..168e8c7a0e9 100644 --- a/src/platform/unix/BuildLinuxImage.sh.in +++ b/src/platform/unix/BuildLinuxImage.sh.in @@ -16,14 +16,15 @@ while getopts ":ih" opt; do done echo -n "[9/9] Generating Linux app..." -{ - +#{ # create directory and copy into it if [ -d "package" ] then rm -rf package/* + rm -rf package/.* 2&>/dev/null + else + mkdir package fi - mkdir package mkdir package/bin # copy Resources @@ -32,17 +33,23 @@ echo -n "[9/9] Generating Linux app..." # create bin echo -e '#!/bin/bash\nDIR=$(readlink -f "$0" | xargs dirname)\nexport LD_LIBRARY_PATH="$DIR/bin"\nexec "$DIR/bin/@SLIC3R_APP_CMD@" "$@"' >@SLIC3R_APP_CMD@ - chmod u+x @SLIC3R_APP_CMD@ - tar -cvf ../@SLIC3R_APP_KEY@.tar . -} &> $ROOT/Build.log # Capture all command output + chmod ug+x @SLIC3R_APP_CMD@ + cp -f @SLIC3R_APP_CMD@ package/@SLIC3R_APP_CMD@ + pushd package + tar -cvf ../@SLIC3R_APP_KEY@.tar . &>/dev/null + popd +#} &> $ROOT/Build.log # Capture all command output echo "done" if [[ -n "$BUILD_IMAGE" ]] then echo -n "Creating Appimage for distribution..." -{ +#{ + pushd package chmod +x ../build_appimage.sh ../build_appimage.sh -} &> $ROOT/Build.log # Capture all command output + popd + mv package/"@SLIC3R_APP_KEY@_ubu64.AppImage" "@SLIC3R_APP_KEY@_ubu64.AppImage" +#} &> $ROOT/Build.log # Capture all command output echo "done" fi