diff --git a/.clang-tidy b/.clang-tidy index ed2378536e..ab2a1dfbd7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,10 +1,15 @@ # clang-tidy configuration, enforced by the clang-tidy CI job on the lines a pull -# request changes (scripts/clang_tidy_diff.py). Only missing includes are reported -# for now: a file should include the header for every symbol it uses, not rely on -# the precompiled header or another header's includes. Run with --fix to add them. +# request changes (scripts/clang_tidy_diff.py). Two things are reported. +# Missing includes: a file should include the header for every symbol it uses, not +# rely on the precompiled header or another header's includes. Run with --fix to +# add them. +# Using-directives and using-declarations in the global namespace of a header: +# they reach every file that includes the header, and a using-declaration also +# makes the header look like the one to include for that name. Qualify the name +# in the header, and put the using in the source files that want it. # Every check listed here gates pull requests, so enable a new one only once the # code it flags on touched lines is reasonable to fix in passing. -Checks: '-*,misc-include-cleaner' +Checks: '-*,misc-include-cleaner,google-global-names-in-headers' WarningsAsErrors: '*' CheckOptions: # Missing includes only. Builds without the precompiled header break on these. diff --git a/.claude/skills/orca-profiles/references/extruder-variants.md b/.claude/skills/orca-profiles/references/extruder-variants.md index 5059fd5c6b..633443cbab 100644 --- a/.claude/skills/orca-profiles/references/extruder-variants.md +++ b/.claude/skills/orca-profiles/references/extruder-variants.md @@ -105,11 +105,12 @@ Rules: `single_extruder_multi_material` off, and in the app when the printer tab loads a printer with a different number of extruders, the pair is rebuilt from `extruder_variant_list` (one `Direct Drive Standard` per extruder when the list is absent) and the variant arrays are resized to - the rebuilt pair, padded with their first value or cut. The resize skips the `machine_max_*` limits - and `hotend_heating_rate` / `hotend_cooling_rate`: they keep their width, and an extruder beyond it - reads their first value, so extruder 2 and up of a list-less printer take extruder 1's normal limit - as their silent one too. With the three in agreement that changes nothing; a pair written without - the list is replaced. A listed variant the pair lacks is a menu choice that reads variant index 0. + the rebuilt pair, padded with their first value or cut. The `machine_max_*` limits are padded the + same way, so extruder 2 and up of a list-less printer take extruder 1's normal limit as their + silent one too. The resize skips `hotend_heating_rate` / `hotend_cooling_rate`: they keep their + width, and an extruder beyond it reads their first value. With the three in agreement that changes + nothing; a pair written without the list is replaced. A listed variant the pair lacks is a menu + choice that reads variant index 0. - The pair without `extruder_variant_list` slices, but the sidebar offers no variant switch and the app cannot add variants to a list-less process: nothing is lost while every extruder has exactly one variant, and every further variant is unreachable. diff --git a/AGENTS.md b/AGENTS.md index 51db547133..8e7b141718 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,15 +4,17 @@ OrcaSlicer — open-source C++17 3D slicer. wxWidgets GUI, CMake build system. ## Build Commands +Build the Release configuration unless asked otherwise. + ```bash # macOS -cmake --build build/arm64 --config RelWithDebInfo --target all -- +cmake --build build/arm64 --config Release --target all -- # Linux -cmake --build build --config RelWithDebInfo --target all -- +cmake --build build --config Release --target all -- -# Windows (replace %build_type% with Debug/Release/RelWithDebInfo) -cmake --build . --config %build_type% --target ALL_BUILD -- -m +# Windows +cmake --build . --config Release --target ALL_BUILD -- -m ``` ## Testing diff --git a/localization/i18n/list.txt b/localization/i18n/list.txt index 981e7a040a..b1ebb54f5e 100644 --- a/localization/i18n/list.txt +++ b/localization/i18n/list.txt @@ -295,8 +295,6 @@ src/slic3r/GUI/CAD/DesignSketchTool.cpp src/slic3r/GUI/CAD/SketchInlineEditor.cpp src/slic3r/GUI/CAD/DesignOffer.hpp src/slic3r/GUI/CAD/DesignTextDialog.cpp -src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp -src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp src/slic3r/GUI/KeyChord.cpp src/slic3r/GUI/Shortcuts.cpp src/libslic3r/CAD/CadDocument.cpp diff --git a/resources/images/toolbar_modifier_cube_dark.svg b/resources/images/toolbar_modifier_cube_dark.svg deleted file mode 100644 index 7e20cd0dd5..0000000000 --- a/resources/images/toolbar_modifier_cube_dark.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/resources/images/toolbar_sketch.svg b/resources/images/toolbar_sketch.svg deleted file mode 100644 index 351b3e7924..0000000000 --- a/resources/images/toolbar_sketch.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/resources/images/toolbar_sketch_dark.svg b/resources/images/toolbar_sketch_dark.svg deleted file mode 100644 index e5cf8d6859..0000000000 --- a/resources/images/toolbar_sketch_dark.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/resources/web/guide/21/common.js b/resources/web/guide/21/common.js index 9a3c76c248..d0cc510540 100644 --- a/resources/web/guide/21/common.js +++ b/resources/web/guide/21/common.js @@ -311,7 +311,7 @@ function CreatePrinterBlock(OneModel) return '
'+ '
'+ - ' '+ + ' '+ '
'+ '
?
'+ '
'+ diff --git a/resources/web/guide/img/printer-dummy.png b/resources/web/guide/img/printer-dummy.png new file mode 100644 index 0000000000..279f80a827 Binary files /dev/null and b/resources/web/guide/img/printer-dummy.png differ diff --git a/scripts/appimage_lib_policy.sh b/scripts/appimage_lib_policy.sh index 35925227a0..81936d83c6 100755 --- a/scripts/appimage_lib_policy.sh +++ b/scripts/appimage_lib_policy.sh @@ -23,7 +23,13 @@ appimage_is_host_library() { } appimage_is_elf_file() { - file -b "$1" 2>/dev/null | grep -q '^ELF ' + # Read the four-byte ELF magic rather than asking file(1): this runs once per candidate, and an + # AppDir holds thousands of them (the bundled Python runtime alone is ~5k files, none of them + # ELF). Two processes per call made this ~14 s of a ~95 s image build on its own. + local magic + [[ -f "$1" && -r "$1" ]] || return 1 + IFS= read -r -n 4 -d '' magic < "$1" 2>/dev/null + [[ $magic == $'\177ELF' ]] } appimage_list_direct_dependencies() { diff --git a/scripts/clang_tidy_diff.py b/scripts/clang_tidy_diff.py index 130e4661df..1e716b6baf 100644 --- a/scripts/clang_tidy_diff.py +++ b/scripts/clang_tidy_diff.py @@ -311,11 +311,12 @@ def main(): for path in fixed: print(f" {path}") if failed and fixed: - print(f"\nclang-tidy still fails on {len(failed)} file(s); the findings above are what --fix could not add.") + print(f"\nclang-tidy still fails on {len(failed)} file(s); the findings above are what --fix could not fix.") return 1 if failed: print(f"\nclang-tidy failed on {len(failed)} file(s). Add the includes it names, or apply its " - "suggestions locally with scripts/run_clang_tidy.sh --fix (scripts\\run_clang_tidy.ps1 -Fix on Windows).") + "suggestions locally with scripts/run_clang_tidy.sh --fix (scripts\\run_clang_tidy.ps1 -Fix on Windows). " + "Other findings need a manual fix.") return 1 print("clang-tidy passed.") return 0 diff --git a/scripts/disable_validation.entitlements b/scripts/disable_validation.entitlements index 123d12a53e..af12034ce0 100644 --- a/scripts/disable_validation.entitlements +++ b/scripts/disable_validation.entitlements @@ -4,5 +4,10 @@ com.apple.security.cs.disable-library-validation + + com.apple.security.cs.allow-unsigned-executable-memory + diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 170a27a53a..854a05bbd9 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -23,7 +23,6 @@ #include #include #include "libslic3r/PrintBase.hpp" -#include "slic3r/Utils/json_diff.hpp" #include #include #include @@ -78,12 +77,10 @@ #include #include #include -//add json logic -#include "nlohmann/json.hpp" - -using namespace nlohmann; #endif +#include "nlohmann/json.hpp" + #include #include #include @@ -157,6 +154,7 @@ using namespace nlohmann; #include namespace fs = boost::filesystem; +using json = nlohmann::json; #ifdef __WXGTK__ #if __has_include() @@ -3529,7 +3527,7 @@ int CLI::run(int argc, char **argv) ConfigOptionStrings *curr_variant_opt = m_print_config.option("filament_extruder_variant"); if (!curr_variant_opt) { curr_variant_opt = m_print_config.option("filament_extruder_variant", true); - std::vector& filament_variants = curr_variant_opt->values; + std::vector& filament_variants = curr_variant_opt->values; filament_variants.resize(filament_count, get_extruder_variant_string(etDirectDrive, nvtStandard)); } // See the filament_self_index note above: one variant per filament for @@ -3640,6 +3638,9 @@ int CLI::run(int argc, char **argv) { if (opt_key == "compatible_prints" || opt_key == "compatible_printers" || opt_key == "model_id" || opt_key == "dev_model_name" || opt_key == "filament_settings_id") continue; + // rebuilt from every filament after this loop + if (filament_dev_options.find(opt_key) != filament_dev_options.end()) + continue; ConfigOption *opt = m_print_config.option(opt_key, true); if (opt == nullptr) { // opt_key does not exist in this ConfigBase and it cannot be created, because it is not defined by this->def(). @@ -3712,6 +3713,14 @@ int CLI::run(int argc, char **argv) } } + // The stored values cannot be told apart per filament, so they are kept as they are unless every slot has a config. + std::vector filament_configs(filament_count, nullptr); + for (size_t index = 0; index < load_filaments_config.size(); index++) + if (load_filaments_index[index] >= 1 && load_filaments_index[index] <= filament_count) + filament_configs[load_filaments_index[index] - 1] = &load_filaments_config[index]; + if (std::find(filament_configs.begin(), filament_configs.end(), nullptr) == filament_configs.end()) + set_filament_dev_options(m_print_config, filament_configs); + if (m_print_config.option("filament_extruder_variant")) { std::vector& filament_self_indice = m_print_config.option("filament_self_index", true)->values; int index_size = m_print_config.option("filament_extruder_variant")->size(); @@ -6587,7 +6596,7 @@ int CLI::run(int argc, char **argv) std::vector result_filaments; //result_filaments.reserve(conflict_filaments.size()); std::set_intersection(conflict_filament_vector.begin(), conflict_filament_vector.end(), unprintable_filament_vec[index].begin(), - unprintable_filament_vec[index].end(), insert_iterator>(result_filaments, result_filaments.begin())); + unprintable_filament_vec[index].end(), std::insert_iterator>(result_filaments, result_filaments.begin())); conflict_filament_vector = result_filaments; } } diff --git a/src/dev-utils/platform/osx/entitlements.plist b/src/dev-utils/platform/osx/entitlements.plist index 59274f955f..5ba7ca02e3 100644 --- a/src/dev-utils/platform/osx/entitlements.plist +++ b/src/dev-utils/platform/osx/entitlements.plist @@ -5,5 +5,10 @@ com.apple.security.cs.disable-library-validation + + com.apple.security.cs.allow-unsigned-executable-memory + diff --git a/src/dev-utils/platform/unix/build_linux_image.sh.in b/src/dev-utils/platform/unix/build_linux_image.sh.in index 873cf2e1b1..8466597d34 100755 --- a/src/dev-utils/platform/unix/build_linux_image.sh.in +++ b/src/dev-utils/platform/unix/build_linux_image.sh.in @@ -118,9 +118,13 @@ bundle_dependency_closure() { # (scripts/check_appimage_libs.sh). local -a search_dirs=("$dst_dir") - while [ ${#queue[@]} -gt 0 ]; do - target="${queue[0]}" - queue=("${queue[@]:1}") + # Walked with a read index rather than by reslicing the array: "${queue[@]:1}" rebuilds the whole + # queue on every pop, so draining it costs O(n^2). At the ~5k entries this bundle reaches that was + # ~22 s of the image build spent copying an array around. + local head=0 + while [ "$head" -lt ${#queue[@]} ]; do + target="${queue[$head]}" + head=$((head + 1)) if [ ! -e "$target" ] || ! appimage_is_elf_file "$target"; then continue diff --git a/src/libslic3r/AppConfig.hpp b/src/libslic3r/AppConfig.hpp index 122ca83d11..3afb2bb138 100644 --- a/src/libslic3r/AppConfig.hpp +++ b/src/libslic3r/AppConfig.hpp @@ -15,8 +15,6 @@ #include "libslic3r/Semver.hpp" #include "calib.hpp" -using namespace nlohmann; - #define ENV_DEV_HOST "0" #define ENV_QAT_HOST "1" #define ENV_PRE_HOST "2" diff --git a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp index 3248116169..077ffd1af6 100644 --- a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp +++ b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp @@ -466,8 +466,6 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys) edge.from->incident_edge = &edge; } -using NodeSet = SkeletalTrapezoidation::NodeSet; - void SkeletalTrapezoidation::separatePointyQuadEndNodes() { NodeSet visited_nodes; diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index 79d93f7909..eacb122d05 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -93,7 +93,6 @@ using namespace libnest2d; using Item = _Item; using Box = _Box; using Circle = _Circle; -using Segment = _Segment; using MultiPolygon = ExPolygons; // Summon the spatial indexing facilities from boost diff --git a/src/libslic3r/CAD/CadDocument.cpp b/src/libslic3r/CAD/CadDocument.cpp index 391ff56a87..cec5a3a74e 100644 --- a/src/libslic3r/CAD/CadDocument.cpp +++ b/src/libslic3r/CAD/CadDocument.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include // multi-body: compound of bodies for display/compat #include #include // outward-normal orientation for face-extrude diff --git a/src/libslic3r/CAD/GeometryEngine.cpp b/src/libslic3r/CAD/GeometryEngine.cpp index 827493fb26..454b37fce2 100644 --- a/src/libslic3r/CAD/GeometryEngine.cpp +++ b/src/libslic3r/CAD/GeometryEngine.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -244,30 +244,6 @@ TopoDS_Shape GeometryEngine::mesh_to_brep(const indexed_triangle_set& its, return shape; } -// ---- Primitive creation ---- - -TopoDS_Solid GeometryEngine::make_primitive(const PrimitiveParams& params) -{ - switch (params.type) { - case PrimitiveType::Box: - return BRepPrimAPI_MakeBox(gp_Pnt(-params.box_w/2, -params.box_d/2, 0), - params.box_w, params.box_d, params.box_h).Solid(); - case PrimitiveType::Cylinder: - return BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), - params.cyl_radius, params.cyl_height).Solid(); - case PrimitiveType::Sphere: - return BRepPrimAPI_MakeSphere(gp_Pnt(0,0,params.sph_radius), params.sph_radius).Solid(); - case PrimitiveType::Cone: - return BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), - params.cone_r1, params.cone_r2, params.cone_height).Solid(); - case PrimitiveType::Torus: - return BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(0,0,params.torus_r2), gp_Dir(0,0,1)), - params.torus_r1, params.torus_r2).Solid(); - default: - return BRepPrimAPI_MakeBox(gp_Pnt(-10,-10,0), 20,20,20).Solid(); - } -} - // ---- Face classification ---- FaceGroup GeometryEngine::classify_face(const TopoDS_Face& face, const TopoDS_Shape& /*solid*/) @@ -545,19 +521,6 @@ GeometryEngine::MassProps GeometryEngine::mass_properties(const TopoDS_Shape& sh return p; } -std::string GeometryEngine::primitive_name(PrimitiveType type) -{ - switch (type) { - // TRN Default name of an object created from the box primitive shape. - case PrimitiveType::Box: return _u8L("Box"); - case PrimitiveType::Cylinder: return _u8L("Cylinder"); - case PrimitiveType::Sphere: return _u8L("Sphere"); - case PrimitiveType::Cone: return _u8L("Cone"); - case PrimitiveType::Torus: return _u8L("Torus"); - default: return _u8L("Unknown"); - } -} - // ---- Topology accessors ---- int GeometryEngine::face_count(const TopoDS_Shape& shape) diff --git a/src/libslic3r/CAD/GeometryEngine.hpp b/src/libslic3r/CAD/GeometryEngine.hpp index e7e92c0438..66f00859be 100644 --- a/src/libslic3r/CAD/GeometryEngine.hpp +++ b/src/libslic3r/CAD/GeometryEngine.hpp @@ -4,15 +4,8 @@ #include "libslic3r/Point.hpp" #include "libslic3r/TriangleMesh.hpp" -#include -#include -#include -#include -#include #include #include -#include -#include #include #include #include @@ -20,44 +13,11 @@ namespace Slic3r { -enum class PrimitiveType { Box, Cylinder, Sphere, Cone, Torus, COUNT }; -enum class DressUpType { Fillet, Chamfer }; enum class FaceGroup { Top, Bottom, Lateral, All }; -struct PrimitiveParams { - PrimitiveType type{PrimitiveType::Box}; - double box_w{20}, box_h{20}, box_d{20}; - double cyl_radius{10}, cyl_height{20}; - double sph_radius{10}; - double cone_r1{10}, cone_r2{5}, cone_height{20}; - double torus_r1{10}, torus_r2{3}; - - // Dress-up - bool dressup_enabled{false}; - DressUpType dressup_type{DressUpType::Fillet}; - FaceGroup dressup_faces{FaceGroup::All}; - double dressup_radius{1.0}; // fillet radius - double dressup_chamfer_dist{1.0}; // chamfer distance (symmetric) - - // Mesh quality — the Design tab's own density (CadDocument::linear_deflection), so a - // primitive and the same body modelled in the Design tab reach the screen alike. - double linear_deflection{0.003}; - double angular_deflection{0.5}; - - template - void serialize(Archive& ar) { - ar(type, box_w, box_h, box_d, cyl_radius, cyl_height, sph_radius, - cone_r1, cone_r2, cone_height, torus_r1, torus_r2, - dressup_enabled, dressup_type, dressup_faces, dressup_radius, dressup_chamfer_dist, - linear_deflection, angular_deflection); - } -}; - class GeometryEngine { public: - static TopoDS_Solid make_primitive(const PrimitiveParams& params); - // Read a STEP file into its top-level solids (one TopoDS_Shape per solid; falls back to // the whole shape if it contains no closed solids). Reuses OCCT's STEPControl_Reader, // already linked via Format/STEP.cpp — no new dependency. err is set on failure (empty result). @@ -132,7 +92,6 @@ public: static TriangleMesh tessellate(const TopoDS_Shape& shape, double linear_deflection = 0.003, double angular_deflection = 0.5); - static std::string primitive_name(PrimitiveType type); // Topology accessors for in-viewport face/edge picking (Design tab). Face index is the // TopExp_Explorer(shape, TopAbs_FACE) ordinal — identical to SketchEngine::tessellate's diff --git a/src/libslic3r/CAD/SketchEngine.hpp b/src/libslic3r/CAD/SketchEngine.hpp index 93fbf72cb9..22dade5af0 100644 --- a/src/libslic3r/CAD/SketchEngine.hpp +++ b/src/libslic3r/CAD/SketchEngine.hpp @@ -3,7 +3,6 @@ #include "libslic3r/TriangleMesh.hpp" #include "libslic3r/Point.hpp" -#include "libslic3r/CAD/GeometryEngine.hpp" #include #include @@ -211,30 +210,6 @@ ConstraintPlan plan_entity_constraint(const std::vector& ents, bool solve_sketch_entities(std::vector& entities, const std::vector& constraints); -struct SketchParams { - // Extrude/Revolve - double extrude_len{10}; bool extrude_sym{false}; double extrude_taper{0}; - double revolve_deg{360}; - bool is_pocket{false}; // cut into selected object instead of new - - // Dress-up - bool dressup_enabled{false}; - DressUpType dressup_type{DressUpType::Fillet}; - FaceGroup dressup_faces{FaceGroup::All}; - double dressup_radius{1.0}; - double dressup_chamfer_dist{1.0}; - - // Mesh - double linear_deflection{0.01}; - - template - void serialize(Archive& ar) { - ar(extrude_len, extrude_sym, extrude_taper, revolve_deg, is_pocket, - dressup_enabled, dressup_type, dressup_faces, dressup_radius, dressup_chamfer_dist, - linear_deflection); - } -}; - class SketchEngine { public: diff --git a/src/libslic3r/ClipperUtils.hpp b/src/libslic3r/ClipperUtils.hpp index 00cf60076b..26585a1fef 100644 --- a/src/libslic3r/ClipperUtils.hpp +++ b/src/libslic3r/ClipperUtils.hpp @@ -23,11 +23,6 @@ enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; } // namespace Slic3r -// import these wherever we're included -using Slic3r::jtMiter; -using Slic3r::jtRound; -using Slic3r::jtSquare; - namespace Slic3r { static constexpr const float ClipperSafetyOffset = 10.f; diff --git a/src/libslic3r/CutSurface.cpp b/src/libslic3r/CutSurface.cpp index 8967f6c2ba..cf5bd119f4 100644 --- a/src/libslic3r/CutSurface.cpp +++ b/src/libslic3r/CutSurface.cpp @@ -2851,7 +2851,6 @@ bool is_patch_inside_of_model(const SurfacePatch &patch, /// shape point index uint32_t get_shape_point_index(const CutAOI &cut, const CutMesh &model); -using PatchNumber = CutMesh::Property_map; /// /// Separate triangles singned with number n /// diff --git a/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp b/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp index ae8d50edb7..301eabebc3 100644 --- a/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp +++ b/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp @@ -32,8 +32,6 @@ // #define DEBUG_FUZZY -using namespace Slic3r; - namespace Slic3r::Feature::FuzzySkin { // Produces a random value between 0 and 1. Thread-safe. diff --git a/src/libslic3r/Fill/FillTpmsFK.cpp b/src/libslic3r/Fill/FillTpmsFK.cpp index 61dd220e64..164e240280 100644 --- a/src/libslic3r/Fill/FillTpmsFK.cpp +++ b/src/libslic3r/Fill/FillTpmsFK.cpp @@ -122,8 +122,6 @@ Polylines get_polylines(const ScalarField& sf, const double tolerance = SCALED_E namespace Slic3r { -using namespace std; - void FillTpmsFK::_fill_surface_single(const FillParams& params, unsigned int thickness_layers, const std::pair& direction, diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp index 57165794c2..fa28d93f09 100644 --- a/src/libslic3r/Format/AMF.cpp +++ b/src/libslic3r/Format/AMF.cpp @@ -25,7 +25,6 @@ #include #include #include -namespace pt = boost::property_tree; #include #include diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index cc2bc7ea44..24fed0493c 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -1135,7 +1135,6 @@ void SeamPlacer::gather_seam_candidates(const PrintObject *po, const SeamPlacerI void SeamPlacer::calculate_candidates_visibility(const PrintObject *po, const SeamPlacerImpl::GlobalModelInfo &global_model_info) { - using namespace SeamPlacerImpl; std::vector &layers = m_seam_per_object[po].layers; tbb::parallel_for(tbb::blocked_range(0, layers.size()), diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 10b34123b6..979371e304 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -1550,7 +1550,6 @@ static FilamentGroupContext build_filament_group_context( FilamentMapMode mode, const std::unordered_map& nozzle_status) { - using namespace MultiNozzleUtils; using namespace FilamentGroupUtils; FilamentGroupContext context; @@ -1759,7 +1758,6 @@ static std::vector apply_master_extruder_preference(const FilamentGroupCont // multi-nozzle (H2C/A2L) resolves to a nozzle-granular result. MultiNozzleUtils::LayeredNozzleGroupResult ToolOrdering::get_recommended_filament_maps(const std::vector>& layer_filaments, const Print* print, const FilamentMapMode mode, const std::vector>& physical_unprintables, const std::vector>& geometric_unprintables, const std::map>& unprintable_volumes, const std::unordered_map& nozzle_status) { - using namespace FilamentGroupUtils; using namespace MultiNozzleUtils; if (!print || layer_filaments.empty()) diff --git a/src/libslic3r/Geometry/Voronoi.cpp b/src/libslic3r/Geometry/Voronoi.cpp index 7d59e2d2b8..31f9f974a7 100644 --- a/src/libslic3r/Geometry/Voronoi.cpp +++ b/src/libslic3r/Geometry/Voronoi.cpp @@ -16,6 +16,7 @@ namespace Slic3r::Geometry { +using VD = VoronoiDiagram; using PolygonsSegmentIndexConstIt = std::vector::const_iterator; using LinesIt = Lines::iterator; using ColoredLinesConstIt = ColoredLines::const_iterator; diff --git a/src/libslic3r/Geometry/VoronoiUtils.cpp b/src/libslic3r/Geometry/VoronoiUtils.cpp index d0ad07cc7e..305e9128ef 100644 --- a/src/libslic3r/Geometry/VoronoiUtils.cpp +++ b/src/libslic3r/Geometry/VoronoiUtils.cpp @@ -20,6 +20,7 @@ namespace Slic3r::Geometry { +using VD = VoronoiDiagram; using PolygonsSegmentIndexConstIt = std::vector::const_iterator; using LinesIt = Lines::iterator; using ColoredLinesIt = ColoredLines::iterator; diff --git a/src/libslic3r/Geometry/VoronoiUtils.hpp b/src/libslic3r/Geometry/VoronoiUtils.hpp index d9b15fd839..13c2492bf9 100644 --- a/src/libslic3r/Geometry/VoronoiUtils.hpp +++ b/src/libslic3r/Geometry/VoronoiUtils.hpp @@ -10,8 +10,6 @@ #include "libslic3r/Point.hpp" #include "libslic3r/libslic3r.h" -using VD = Slic3r::Geometry::VoronoiDiagram; - namespace Slic3r::Geometry { // Represent trapezoid Voronoi cell around segment. @@ -19,8 +17,8 @@ template struct SegmentCellRange { const PT source_segment_start_point; // The start point of the source segment of this cell. const PT source_segment_end_point; // The end point of the source segment of this cell. - const VD::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. - const VD::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. + const VoronoiDiagram::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. + const VoronoiDiagram::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. SegmentCellRange() = delete; explicit SegmentCellRange(const PT &source_segment_start_point, const PT &source_segment_end_point) @@ -34,8 +32,8 @@ template struct SegmentCellRange template struct PointCellRange { const PT source_point; // The source point of this cell. - const VD::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. - const VD::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. + const VoronoiDiagram::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. + const VoronoiDiagram::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. PointCellRange() = delete; explicit PointCellRange(const PT &source_point) : source_point(source_point) {} @@ -46,20 +44,20 @@ template struct PointCellRange class VoronoiUtils { public: - static Vec2i64 to_point(const VD::vertex_type *vertex); + static Vec2i64 to_point(const VoronoiDiagram::vertex_type *vertex); - static Vec2i64 to_point(const VD::vertex_type &vertex); + static Vec2i64 to_point(const VoronoiDiagram::vertex_type &vertex); - static bool is_finite(const VD::vertex_type &vertex); + static bool is_finite(const VoronoiDiagram::vertex_type &vertex); - static VD::vertex_type make_rotated_vertex(VD::vertex_type &vertex, double angle); + static VoronoiDiagram::vertex_type make_rotated_vertex(VoronoiDiagram::vertex_type &vertex, double angle); template static typename boost::polygon::enable_if< typename boost::polygon::gtl_if::value_type>::type>::type>::type, typename std::iterator_traits::reference>::type - get_source_segment(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + get_source_segment(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); template static typename boost::polygon::enable_if< @@ -73,7 +71,7 @@ public: typename boost::polygon::gtl_if::value_type>::type>::type>::type, Arachne::PolygonsPointIndex>::type - get_source_point_index(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + get_source_point_index(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); /** * Discretize a parabola based on (approximate) step size. @@ -113,7 +111,7 @@ public: typename boost::polygon::geometry_concept::value_type>::type>::type>::type, Geometry::SegmentCellRange< typename boost::polygon::segment_point_type::value_type>::type>>::type - compute_segment_cell_range(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + compute_segment_cell_range(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); /** * Compute the range of line segments that surround a cell of the skeletal @@ -140,19 +138,19 @@ public: typename boost::polygon::geometry_concept::value_type>::type>::type>::type, Geometry::PointCellRange< typename boost::polygon::segment_point_type::value_type>::type>>::type - compute_point_cell_range(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + compute_point_cell_range(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); template static bool is_in_range(double value) { return double(std::numeric_limits::lowest()) <= value && value <= double(std::numeric_limits::max()); } - template static bool is_in_range(const VD::vertex_type &vertex) + template static bool is_in_range(const VoronoiDiagram::vertex_type &vertex) { return VoronoiUtils::is_finite(vertex) && is_in_range(vertex.x()) && is_in_range(vertex.y()); } - template static bool is_in_range(const VD::edge_type &edge) + template static bool is_in_range(const VoronoiDiagram::edge_type &edge) { if (edge.vertex0() == nullptr || edge.vertex1() == nullptr) return false; diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index 5bc68c4ca5..340f9a590d 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -230,7 +230,6 @@ std::vector get_grouped_bridges( { result.reserve(bridge_expansions.size()); uint32_t group_id = 0; - using std::move_iterator; for (ExPolygon& expolygon : bridge_expolygons) result.push_back({ std::move(expolygon), group_id ++, bridge_expansions.end() }); } @@ -432,7 +431,6 @@ Surfaces expand_bridges_detect_orientations( const float closing_radius ) { - using namespace Slic3r::Algorithm; double thickness; ExPolygons bridge_expolygons = fill_surfaces_extract_expolygons(surfaces, {stBottomBridge}, thickness); diff --git a/src/libslic3r/MeshBoolean.cpp b/src/libslic3r/MeshBoolean.cpp index 2a05378f58..8f30b356d1 100644 --- a/src/libslic3r/MeshBoolean.cpp +++ b/src/libslic3r/MeshBoolean.cpp @@ -660,7 +660,6 @@ bool empty(const CGALMesh &mesh) bool repair(TriangleMesh& mesh, RepairedMeshErrors* repaired_errors, std::string* error) { - using namespace CGAL; namespace PMP = CGAL::Polygon_mesh_processing; if (mesh.empty()) diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index be20878bfb..19dbee88dc 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -63,6 +63,7 @@ namespace Slic3r { enum class EnforcerBlockerType : int8_t; } namespace Slic3r { using boost::polygon::voronoi_diagram; +using VD = Geometry::VoronoiDiagram; static inline Point mk_point(const Voronoi::VD::vertex_type *point) { return {coord_t(point->x()), coord_t(point->y())}; } diff --git a/src/libslic3r/NSVGUtils.cpp b/src/libslic3r/NSVGUtils.cpp index 5274ffad4f..d81d5d5258 100644 --- a/src/libslic3r/NSVGUtils.cpp +++ b/src/libslic3r/NSVGUtils.cpp @@ -263,7 +263,6 @@ size_t get_shapes_count(const NSVGimage &image) } // namespace Slic3r namespace { -using namespace Slic3r; // Polygon + Vec2f Point::coord_type to_coor(float val, double scale) { return static_cast(std::round(val * scale)); } diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index 8bddfc1f10..18bbc7812e 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -2175,7 +2175,6 @@ namespace client { macro_processor() : macro_processor::base_type(start) { - using namespace qi::labels; qi::alpha_type alpha; qi::alnum_type alnum; qi::eps_type eps; diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 4b2b28d4a8..2e9577e9c8 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -87,6 +87,7 @@ #include "libslic3r/GCode/Thumbnails.hpp" namespace fs = boost::filesystem; +using json = nlohmann::json; using boost::property_tree::ptree; diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index eb8321e4bd..b1fad347f1 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -80,6 +80,8 @@ #include #include +namespace fs = boost::filesystem; + // Mark string for localization and translate. #define L(s) Slic3r::I18N::translate(s) @@ -87,6 +89,8 @@ // This breaks compatibility with the upstream Slic3r if the --datadir is used to switch between the two versions. //#define SLIC3R_PROFILE_USE_PRESETS_SUBDIR +using json = nlohmann::json; + namespace Slic3r { // Project-level options imported from a loaded 3MF into project_config. s_project_options_published @@ -1527,7 +1531,6 @@ bool PresetBundle::apply_vendor_config( const std::string& preferred_printer_variant, const std::string& preferred_filament) { - namespace fs = boost::filesystem; // Get current configuration from AppConfig const auto old_vendors = app_config->vendors(); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 8e5b2e2b0f..503e7c464b 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -10266,6 +10266,13 @@ static void extend_extruder_variant(DynamicPrintConfig& config, const unsigned i printer_extruder_variant_opt->values.insert(printer_extruder_variant_opt->values.end(), variants_list.begin(), variants_list.end()); } } + + // 3. Size the machine limits to the rebuilt variants, padded with their first value like the other variant keys. + // They are not extruder option keys, so the resize loop in set_num_extruders skips them. + const auto &defaults = FullPrintConfig::defaults(); + for (const std::string &key : printer_options_with_variant_2) + if (auto *opt = config.option(key)) + opt->resize(config.get_parameter_size(key, num_extruders), defaults.option(key)); } void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders) @@ -11058,6 +11065,22 @@ void normalize_filament_values_to_variants(DynamicPrintConfig &config) } } +void set_filament_dev_options(DynamicPrintConfig &config, const std::vector &filament_configs) +{ + for (const std::string &key : filament_dev_options) { + if (std::none_of(filament_configs.begin(), filament_configs.end(), [&key](const DynamicPrintConfig *filament) { return filament->has(key); })) + continue; + const ConfigOption *default_value = print_config_def.get(key)->default_value.get(); + auto *dst = static_cast(config.option(key, true)); + dst->clear(); + for (const DynamicPrintConfig *filament : filament_configs) { + const auto *src = static_cast(filament->has(key) ? filament->option(key) : default_value); + if (!src->empty()) + dst->append(src); + } + } +} + //used for object/region config //use the smallest of multiple to single @@ -11756,12 +11779,18 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi int cur_variant_count = cur_extruder_variants.size(); int target_variant_count = target_extruder_variants.size(); + // A base variant this config does not list (the base gained it after the config was saved, or the + // config lists none) takes this config's first variant of the same extruder, as a user preset's + // values do in update_diff_values_to_child_config. Left unmatched, the base's value would silently + // replace the user's. variant_index.resize(target_variant_count, -1); if (cur_variant_count == 0) { // Defensive: target_variant_count may be 0 if the preset doesn't carry extruder_variant_name. // In that case keep variant_index empty and let the downstream size checks produce a useful error. if (!variant_index.empty()) - variant_index[0] = 0; + // This config's one value belongs to the extruder of the base's first variant. + variant_index = map_variant_indices(target_extruder_variants, target_extruder_ids, {}, + target_extruder_ids.empty() ? std::vector() : std::vector{target_extruder_ids[0]}); } else if ((cur_extruder_ids.size() > 0) && cur_variant_count != cur_extruder_ids.size()){ //should not happen @@ -11774,18 +11803,7 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi %extruder_variant_name %target_variant_count %extruder_id_name %target_extruder_ids.size(); } else { - for (int i = 0; i < target_variant_count; i++) - { - for (int j = 0; j < cur_variant_count; j++) - { - if ((target_extruder_variants[i] == cur_extruder_variants[j]) - &&(target_extruder_ids.empty() || (target_extruder_ids[i] == cur_extruder_ids[j]))) - { - variant_index[i] = j; - break; - } - } - } + variant_index = map_variant_indices(target_extruder_variants, target_extruder_ids, cur_extruder_variants, cur_extruder_ids); } for (auto& opt : keys) { @@ -11810,6 +11828,13 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi if (cur_variant_count > target_variant_count) continue; + // The variant lists are the base's layout itself, which every other value is + // carried onto: a variant this config lacks keeps its own name and id. + if (opt == extruder_id_name || opt == extruder_variant_name) { + opt_src->set(opt_target); + continue; + } + int stride = 1; if (key_set2.find(opt) != key_set2.end()) stride = 2; diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 05ee97a806..133d854a61 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -953,6 +953,11 @@ void normalize_filament_values_to_variants(DynamicPrintConfig &config); extern std::set filament_dev_options; +// Orca: a filament_dev_options option holds several values per filament, and how many is up to the +// filament preset, so one filament's values cannot be replaced in place. This rebuilds each option from +// filament_configs, one config per filament in slot order, as the filaments' values one after another. +void set_filament_dev_options(DynamicPrintConfig &config, const std::vector &filament_configs); + extern void update_static_print_config_from_dynamic(ConfigBase& config, const DynamicPrintConfig& dest_config, std::vector variant_index, std::set& key_set1, int stride = 1); extern void compute_filament_override_value(const std::string& opt_key, const ConfigOption *opt_old_machine, const ConfigOption *opt_new_machine, const ConfigOption *opt_new_filament, const DynamicPrintConfig& new_full_config, t_config_option_keys& diff_keys, DynamicPrintConfig& filament_overrides, std::vector& f_map_indices); diff --git a/src/libslic3r/ProjectTask.hpp b/src/libslic3r/ProjectTask.hpp index 47eaa37dcc..64c4ddc447 100644 --- a/src/libslic3r/ProjectTask.hpp +++ b/src/libslic3r/ProjectTask.hpp @@ -11,8 +11,6 @@ #include #include -namespace fs = boost::filesystem; - namespace Slic3r { class BBLProject; @@ -208,7 +206,7 @@ public: std::string task_profile_id; /* profile id*/ std::string task_name; /* task name, generally filename as task name */ std::string task_file; /* local full file path of 3mf or gcode */ - fs::path task_path; /* local path of 3mf or gcode */ + boost::filesystem::path task_path; /* local path of 3mf or gcode */ std::string task_gcode_in_3mf; /* gcode in 3mf */ std::string task_create_time; /* time created by cloud */ std::string task_thumbnail_url; /* url of task thumbnail */ @@ -326,7 +324,7 @@ public: std::string project_url_md5; /* md5 of project url file */ std::string project_name; std::string project_3mf_file; - fs::path project_path; + boost::filesystem::path project_path; std::string project_content; std::string project_country_code; diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 8d5ab732be..cd9ecf100d 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -404,7 +404,6 @@ std::string debug_out_path(const char *name, ...) } namespace logging = boost::log; -namespace src = boost::log::sources; namespace expr = boost::log::expressions; namespace keywords = boost::log::keywords; namespace attrs = boost::log::attributes; @@ -892,7 +891,6 @@ int copy_file_linux_read_write(int infile, int outfile, uintmax_t file_size) // and only features supported by Linux 3.10 (on our build server with CentOS 7) are kept, namely sendfile with ranges and statx() are not supported. bool copy_file_linux(const boost::filesystem::path &from, const boost::filesystem::path &to, boost::system::error_code &ec) { - using namespace boost::filesystem; struct fd_wrapper { diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index fdd7475d48..de3b69565d 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -851,11 +851,6 @@ if (SLIC3R_CAD) GUI/CAD/SketchInlineEditor.hpp GUI/CAD/McpControl.cpp GUI/CAD/McpControl.hpp - GUI/Gizmos/GLGizmoSketch.cpp - GUI/Gizmos/GLGizmoSketch.hpp - # Needs GeometryEngine (make_primitive / apply_fillet / tessellate). - GUI/Gizmos/GLGizmoPrimitive.cpp - GUI/Gizmos/GLGizmoPrimitive.hpp ) endif () diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index d53a7dc17d..5a39f9a279 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -1592,7 +1592,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo { std::vector result_filaments; //result_filaments.reserve(conflict_filaments.size()); - std::set_intersection (conflict_filament_vector.begin(), conflict_filament_vector.end(), unprintable_filament_vec[index].begin(), unprintable_filament_vec[index].end(), insert_iterator>(result_filaments, result_filaments.begin())); + std::set_intersection (conflict_filament_vector.begin(), conflict_filament_vector.end(), unprintable_filament_vec[index].begin(), unprintable_filament_vec[index].end(), std::insert_iterator>(result_filaments, result_filaments.begin())); conflict_filament_vector = result_filaments; } } diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 66e87ac3af..83dd6a2d07 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -974,8 +974,8 @@ bool AMSMaterialsSetting::Show(bool show) static void _collect_filament_info(const wxString& shown_name, const Preset& filament, - unordered_map& query_filament_vendors, - unordered_map& query_filament_types) + std::unordered_map& query_filament_vendors, + std::unordered_map& query_filament_types) { query_filament_vendors[shown_name] = filament.config.get_filament_vendor(); query_filament_types[shown_name] = filament.config.get_filament_type(); diff --git a/src/slic3r/GUI/Auxiliary.cpp b/src/slic3r/GUI/Auxiliary.cpp index bb952e8ae0..85f6533c1c 100644 --- a/src/slic3r/GUI/Auxiliary.cpp +++ b/src/slic3r/GUI/Auxiliary.cpp @@ -69,6 +69,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { @@ -855,14 +856,14 @@ void AuxiliaryPanel::Split(const std::string &src, const std::string &separator, dest.clear(); index = str.find_first_of(separator, start); do { - if (index != string::npos) { + if (index != std::string::npos) { substring = str.substr(start, index - start); dest.push_back(substring); start = index + separator.size(); index = str.find(separator, start); - if (start == string::npos) break; + if (start == std::string::npos) break; } - } while (index != string::npos); + } while (index != std::string::npos); // the last part substring = str.substr(start); diff --git a/src/slic3r/GUI/Auxiliary.hpp b/src/slic3r/GUI/Auxiliary.hpp index c7fb89f920..4f25aab439 100644 --- a/src/slic3r/GUI/Auxiliary.hpp +++ b/src/slic3r/GUI/Auxiliary.hpp @@ -11,7 +11,7 @@ #include "slic3r/GUI/Widgets/Button.hpp" #include "slic3r/GUI/Widgets/ComboBox.hpp" #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -246,7 +246,7 @@ public: void create_folder(wxString name = wxEmptyString); std::string replaceSpace(std::string s, std::string ts, std::string ns); void on_import_file(wxCommandEvent &event); - void Reload(wxString aux_path, std::map> paths); + void Reload(wxString aux_path, std::map> paths); void update_all_panel(); void update_all_cover(); diff --git a/src/slic3r/GUI/AuxiliaryDataViewModel.hpp b/src/slic3r/GUI/AuxiliaryDataViewModel.hpp index 026f22421b..c26988e9bb 100644 --- a/src/slic3r/GUI/AuxiliaryDataViewModel.hpp +++ b/src/slic3r/GUI/AuxiliaryDataViewModel.hpp @@ -18,8 +18,6 @@ class AuxiliaryModelNode; WX_DEFINE_ARRAY_PTR(AuxiliaryModelNode*, AuxiliaryModelNodePtrArray); -namespace fs = boost::filesystem; - class AuxiliaryModelNode { public: diff --git a/src/slic3r/GUI/BBLStatusBar.hpp b/src/slic3r/GUI/BBLStatusBar.hpp index e643a9b536..1ff2fd6f0f 100644 --- a/src/slic3r/GUI/BBLStatusBar.hpp +++ b/src/slic3r/GUI/BBLStatusBar.hpp @@ -73,10 +73,6 @@ private: CancelFn m_cancel_cb; }; -namespace GUI { - using Slic3r::BBLStatusBar; -} - } #endif // BBLSTATUSBAR_HPP diff --git a/src/slic3r/GUI/BBLStatusBarBind.hpp b/src/slic3r/GUI/BBLStatusBarBind.hpp index dd647aa26c..b1b06b60b6 100644 --- a/src/slic3r/GUI/BBLStatusBarBind.hpp +++ b/src/slic3r/GUI/BBLStatusBarBind.hpp @@ -80,10 +80,6 @@ private: CancelFn m_cancel_cb_fina; }; -namespace GUI { -using Slic3r::BBLStatusBarBind; -} - } // namespace Slic3r #endif // BBLSTATUSBAR_HPP diff --git a/src/slic3r/GUI/BBLStatusBarPrint.hpp b/src/slic3r/GUI/BBLStatusBarPrint.hpp index 0622516791..bc82d80068 100644 --- a/src/slic3r/GUI/BBLStatusBarPrint.hpp +++ b/src/slic3r/GUI/BBLStatusBarPrint.hpp @@ -97,10 +97,6 @@ private: CancelFn m_cancel_cb_fina; }; -namespace GUI { -using Slic3r::BBLStatusBarPrint; -} - wxDECLARE_EVENT(EVT_SHOW_ERROR_INFO, wxCommandEvent); } // namespace Slic3r diff --git a/src/slic3r/GUI/BBLStatusBarSend.hpp b/src/slic3r/GUI/BBLStatusBarSend.hpp index abe4bece3b..1c4b267c6f 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.hpp +++ b/src/slic3r/GUI/BBLStatusBarSend.hpp @@ -99,10 +99,6 @@ private: CancelFn m_cancel_cb_fina; }; -namespace GUI { -using Slic3r::BBLStatusBarSend; -} - wxDECLARE_EVENT(EVT_SHOW_ERROR_INFO_SEND, wxCommandEvent); wxDECLARE_EVENT(EVT_SHOW_ERROR_FAIL_SEND, wxCommandEvent); } // namespace Slic3r diff --git a/src/slic3r/GUI/BBLTopbar.cpp b/src/slic3r/GUI/BBLTopbar.cpp index 40f6457ae4..eb85b9413b 100644 --- a/src/slic3r/GUI/BBLTopbar.cpp +++ b/src/slic3r/GUI/BBLTopbar.cpp @@ -41,6 +41,7 @@ #define TOPBAR_TITLE_WIDTH 300 using namespace Slic3r; +using namespace Slic3r::GUI; enum CUSTOM_ID { diff --git a/src/slic3r/GUI/BBLTopbar.hpp b/src/slic3r/GUI/BBLTopbar.hpp index 3d71a56e4c..bad0727452 100644 --- a/src/slic3r/GUI/BBLTopbar.hpp +++ b/src/slic3r/GUI/BBLTopbar.hpp @@ -18,8 +18,6 @@ class wxMouseCaptureLostEvent; class wxMouseEvent; class wxWindow; -using namespace Slic3r::GUI; - class CenteredTitle : public wxControl { public: diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index e9417782db..50c69f40dc 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -218,7 +218,7 @@ std::string BackgroundSlicingProcess::output_filepath_for_project(const boost::f void BackgroundSlicingProcess::process_fff() { assert(m_print == m_fff_print); - PresetBundle& preset_bundle = *wxGetApp().preset_bundle; + PresetBundle& preset_bundle = *GUI::wxGetApp().preset_bundle; m_fff_print->is_BBL_printer() = preset_bundle.is_bbl_vendor(); // BBS: add the logic to process from an existed gcode file if (m_print->finished()) { @@ -727,7 +727,7 @@ StringObjectException BackgroundSlicingProcess::validate(std::vectoris_BBL_printer() = wxGetApp().preset_bundle->is_bbl_vendor(); + m_fff_print->is_BBL_printer() = GUI::wxGetApp().preset_bundle->is_bbl_vendor(); return m_print->validate(warnings, collison_polygons, height_polygons); } diff --git a/src/slic3r/GUI/BaseTransparentDPIFrame.cpp b/src/slic3r/GUI/BaseTransparentDPIFrame.cpp index 14575aa988..c9e4e4b76e 100644 --- a/src/slic3r/GUI/BaseTransparentDPIFrame.cpp +++ b/src/slic3r/GUI/BaseTransparentDPIFrame.cpp @@ -22,8 +22,6 @@ #include "CapsuleButton.hpp" namespace Slic3r::GUI { struct IntEvent; } -using namespace Slic3r; -using namespace Slic3r::GUI; namespace Slic3r { namespace GUI { #define ANIMATION_REFRESH_INTERVAL 20 diff --git a/src/slic3r/GUI/BindDialog.cpp b/src/slic3r/GUI/BindDialog.cpp index c16bcf016d..2f1283b790 100644 --- a/src/slic3r/GUI/BindDialog.cpp +++ b/src/slic3r/GUI/BindDialog.cpp @@ -26,7 +26,7 @@ #include #include "slic3r/GUI/BBLStatusBarBind.hpp" #include "slic3r/GUI/Jobs/BindJob.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "slic3r/GUI/DeviceCore/DevDefs.h" #include "slic3r/GUI/Jobs/Worker.hpp" #include @@ -54,6 +54,8 @@ #include "DeviceCore/DevManager.h" +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/BitmapComboBox.cpp b/src/slic3r/GUI/BitmapComboBox.cpp index 217b885b91..9e5645bb41 100644 --- a/src/slic3r/GUI/BitmapComboBox.cpp +++ b/src/slic3r/GUI/BitmapComboBox.cpp @@ -45,8 +45,6 @@ #include #endif -using Slic3r::GUI::format_wxstr; - #define BORDER_W 10 // --------------------------------- diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp index e49ebfb787..3ed3ca66df 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp @@ -1307,7 +1307,7 @@ void CalibrationPresetPage::stripWhiteSpace(std::string& str) { if (str == "") { return; } - string::iterator cur_it; + std::string::iterator cur_it; cur_it = str.begin(); while (cur_it != str.end()) { @@ -2597,7 +2597,7 @@ void CalibrationPresetPage::update_multi_extruder_filament_combobox(const std::s int ams_id_int = 0; try { if (!ams_id.empty()) - ams_id_int = stoi(ams_id.c_str()); + ams_id_int = std::stoi(ams_id.c_str()); } catch (...) {} @@ -2685,7 +2685,7 @@ void CalibrationPresetPage::update_filament_combobox(std::string ams_id) int ams_id_int = 0; try { if (!ams_id.empty()) - ams_id_int = stoi(ams_id.c_str()); + ams_id_int = std::stoi(ams_id.c_str()); } catch (...) {} diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 6596cdca0c..347973c667 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -95,7 +95,6 @@ namespace GUI { using Config::Snapshot; -using Config::SnapshotDB; // Configuration data structures extensions needed for the wizard diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index a1f9b61b00..5f7720ab84 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -43,8 +43,6 @@ #include -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { @@ -88,7 +86,7 @@ struct Bundle // cache or its profile JSONs, whichever is usable. // Returns false if not loaded. Reason for that is logged as boost::log error. //BBS: set BBL as default - bool load(fs::path dir, const std::string &vendor_name, bool is_in_resources, bool is_bbl_bundle = false); + bool load(boost::filesystem::path dir, const std::string &vendor_name, bool is_in_resources, bool is_bbl_bundle = false); const std::string& vendor_id() const { return vendor_profile->id; } }; diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 24591ae0f8..c7c9cd2760 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -25,7 +25,7 @@ #include "slic3r/GUI/Widgets/RadioBox.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include "slic3r/GUI/GUI_Utils.hpp" #include "slic3r/GUI/Widgets/Label.hpp" @@ -91,6 +91,8 @@ #define SELECT_ALL_OPTION_COLOUR wxColour("#009688") #define DEFAULT_PROMPT_TEXT_COLOUR wxColour("#ACACAC") +using json = nlohmann::json; + namespace Slic3r { namespace GUI { @@ -345,7 +347,7 @@ static std::string get_curr_timestmp() // return timestampString; } -static void get_filament_compatible_printer(Preset* preset, vector& printers) +static void get_filament_compatible_printer(Preset* preset, std::vector& printers) { auto compatible_printers = dynamic_cast(preset->config.option("compatible_printers")); if (compatible_printers == nullptr) return; @@ -1579,7 +1581,7 @@ void CreateFilamentPresetDialog::sort_printer_by_nozzle(std::vector nozzle_diameter = nozzle_diameter_map; std::sort(printer_name_to_filament_preset.begin(), printer_name_to_filament_preset.end(), - [&nozzle_diameter](const std::pair &a, const std::pair &b) { + [&nozzle_diameter](const std::pair &a, const std::pair &b) { size_t nozzle_index_a = a.first.find(" nozzle"); size_t nozzle_index_b = b.first.find(" nozzle"); if (nozzle_index_a == std::string::npos || nozzle_index_b == std::string::npos) return a.first < b.first; @@ -3141,7 +3143,7 @@ void CreatePrinterPresetDialog::set_current_visible_printer() wxArrayString CreatePrinterPresetDialog::printer_preset_sort_with_nozzle_diameter(const VendorProfile &vendor_profile, float nozzle_diameter) { - std::vector> preset_sort; + std::vector> preset_sort; auto get_nozzle_size_for_printer_model = [this](const std::string & model_name) -> size_t { auto iter = m_printer_name_to_preset.find(model_name); @@ -4962,7 +4964,7 @@ wxBoxSizer *CreatePresetForPrinterDialog::create_selected_filament_preset_sizer( m_selected_printer->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) { wxString printer_name = m_selected_printer->GetStringSelection(); - std::unordered_map>>::iterator filament_iter = m_printer_compatible_filament_presets.find(into_u8(printer_name)); + std::unordered_map>>::iterator filament_iter = m_printer_compatible_filament_presets.find(into_u8(printer_name)); if (m_printer_compatible_filament_presets.end() != filament_iter) { filament_choice_to_filament_preset.clear(); wxArrayString filament_choices; diff --git a/src/slic3r/GUI/DeviceCore/DevAxis.cpp b/src/slic3r/GUI/DeviceCore/DevAxis.cpp index 1274054507..5dc0245a3a 100644 --- a/src/slic3r/GUI/DeviceCore/DevAxis.cpp +++ b/src/slic3r/GUI/DeviceCore/DevAxis.cpp @@ -1,10 +1,12 @@ #include "DevAxis.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/DeviceCore/DevDefs.h" +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevAxis.h b/src/slic3r/GUI/DeviceCore/DevAxis.h index d543132e49..6e8b3ef20d 100644 --- a/src/slic3r/GUI/DeviceCore/DevAxis.h +++ b/src/slic3r/GUI/DeviceCore/DevAxis.h @@ -2,7 +2,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -22,7 +21,7 @@ public: bool IsArchCoreXY() const; public: - void ParseAxis(const json &print_json); + void ParseAxis(const nlohmann::json &print_json); int Ctrl_GoHome(); int Ctrl_Axis(std::string axis, double unit = 1.0f, double input_val = 1.0f, int speed = 3000); // xyz e diff --git a/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp index ee9c8f00e8..6178a0e1ce 100644 --- a/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp @@ -1,11 +1,13 @@ #include "DevAxis.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include #include #include +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevBed.cpp b/src/slic3r/GUI/DeviceCore/DevBed.cpp index 134de17e30..48ab32f947 100644 --- a/src/slic3r/GUI/DeviceCore/DevBed.cpp +++ b/src/slic3r/GUI/DeviceCore/DevBed.cpp @@ -1,7 +1,9 @@ #include "DevBed.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" +using json = nlohmann::json; + namespace Slic3r { void DevBed::ParseV1_0(const json &print_json, DevBed *system) diff --git a/src/slic3r/GUI/DeviceCore/DevBed.h b/src/slic3r/GUI/DeviceCore/DevBed.h index dcdb698449..ddfd1e8902 100644 --- a/src/slic3r/GUI/DeviceCore/DevBed.h +++ b/src/slic3r/GUI/DeviceCore/DevBed.h @@ -1,6 +1,5 @@ #pragma once #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -16,8 +15,8 @@ public: public: - static void ParseV1_0(const json &print_json, DevBed *system); - static void ParseV2_0(const json &print_json, DevBed *system); + static void ParseV1_0(const nlohmann::json &print_json, DevBed *system); + static void ParseV2_0(const nlohmann::json &print_json, DevBed *system); private: diff --git a/src/slic3r/GUI/DeviceCore/DevCalib.cpp b/src/slic3r/GUI/DeviceCore/DevCalib.cpp index 61566c83ed..ec1e55a247 100644 --- a/src/slic3r/GUI/DeviceCore/DevCalib.cpp +++ b/src/slic3r/GUI/DeviceCore/DevCalib.cpp @@ -1,6 +1,6 @@ #include #include -#include "json_diff.hpp" +#include #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/DeviceManager.hpp" @@ -22,6 +22,8 @@ #include "DevFilaSystem.h" #include "DevConfig.h" +using json = nlohmann::json; + namespace Slic3r { static float string_to_float(const std::string &str_value) diff --git a/src/slic3r/GUI/DeviceCore/DevCalib.h b/src/slic3r/GUI/DeviceCore/DevCalib.h index 54f5f4b053..f0600424e2 100644 --- a/src/slic3r/GUI/DeviceCore/DevCalib.h +++ b/src/slic3r/GUI/DeviceCore/DevCalib.h @@ -2,7 +2,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" #include "DevDefs.h" @@ -86,11 +85,11 @@ public: std::vector GetFlowRatioResult() const {return m_flow_ratio_results; } protected: - void ExtrusionCalibSetParse(const json &jj); - void ExtrusionCalibSelectParse(const json &jj); - void ExtrusionCalibGetTableParse(const json &jj); - void ExtrusionCalibGetResultParse(const json &jj); - void FlowrateGetResultParse(const json &jj); + void ExtrusionCalibSetParse(const nlohmann::json &jj); + void ExtrusionCalibSelectParse(const nlohmann::json &jj); + void ExtrusionCalibGetTableParse(const nlohmann::json &jj); + void ExtrusionCalibGetResultParse(const nlohmann::json &jj); + void FlowrateGetResultParse(const nlohmann::json &jj); private: MachineObject* m_owner{nullptr}; @@ -119,11 +118,11 @@ private: bool m_calib_finished{false}; public: - static void ParseCalibVersion(const json& j, DevCalib* system); + static void ParseCalibVersion(const nlohmann::json& j, DevCalib* system); static void ParseSupportNewAutoCalib(int flag, DevCalib* system); - static void ParseV1_0(const json& print_json, DevCalib* system, bool key_field_only); + static void ParseV1_0(const nlohmann::json& print_json, DevCalib* system, bool key_field_only); }; } // namespace Slic3r \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceCore/DevChamber.cpp b/src/slic3r/GUI/DeviceCore/DevChamber.cpp index 8cd47481f2..3c1a0c8e8b 100644 --- a/src/slic3r/GUI/DeviceCore/DevChamber.cpp +++ b/src/slic3r/GUI/DeviceCore/DevChamber.cpp @@ -3,9 +3,11 @@ #include "DevConfig.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" +using json = nlohmann::json; + namespace Slic3r { bool DevChamber::HasChamber() const { return m_owner->GetConfig()->HasChamber(); } diff --git a/src/slic3r/GUI/DeviceCore/DevChamber.h b/src/slic3r/GUI/DeviceCore/DevChamber.h index 6fcafabcf2..0e6464a839 100644 --- a/src/slic3r/GUI/DeviceCore/DevChamber.h +++ b/src/slic3r/GUI/DeviceCore/DevChamber.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -25,10 +24,10 @@ public: // getter public: // setter - void ParseChamber(const json &print_json); + void ParseChamber(const nlohmann::json &print_json); - void ParseChamberV1_0(const json& print_json); - void ParseChamberV2_0(const json& print_json); + void ParseChamberV1_0(const nlohmann::json& print_json); + void ParseChamberV2_0(const nlohmann::json& print_json); // control int CtrlSetChamberTemp(int temp); diff --git a/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp index 01201998ce..13ab7bccc9 100644 --- a/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp @@ -1,8 +1,10 @@ #include "DevChamber.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include +using json = nlohmann::json; + namespace Slic3r { int DevChamber::CtrlSetChamberTemp(int temp) diff --git a/src/slic3r/GUI/DeviceCore/DevConfig.cpp b/src/slic3r/GUI/DeviceCore/DevConfig.cpp index cce5257527..9833731040 100644 --- a/src/slic3r/GUI/DeviceCore/DevConfig.cpp +++ b/src/slic3r/GUI/DeviceCore/DevConfig.cpp @@ -2,7 +2,6 @@ #include "DevConfig.h" #include "DevUtil.h" -#include "json_diff.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevConfig.h b/src/slic3r/GUI/DeviceCore/DevConfig.h index b0cdcb936e..9fa26d9238 100644 --- a/src/slic3r/GUI/DeviceCore/DevConfig.h +++ b/src/slic3r/GUI/DeviceCore/DevConfig.h @@ -1,7 +1,7 @@ #pragma once #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include #include @@ -47,11 +47,11 @@ public: public: /*Setters*/ - void ParseConfig(const json& print_json); + void ParseConfig(const nlohmann::json& print_json); - void ParseChamberConfig(const json& print_json); // chamber - void ParsePrintOptionsConfig(const json& print_json); // print options - void ParseCalibrationConfig(const json& print_json); //cali + void ParseChamberConfig(const nlohmann::json& print_json); // chamber + void ParsePrintOptionsConfig(const nlohmann::json& print_json); // print options + void ParseCalibrationConfig(const nlohmann::json& print_json); //cali private: [[maybe_unused]] MachineObject* m_obj; diff --git a/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp b/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp index e6679f4463..b0a6f2678c 100644 --- a/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp +++ b/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp @@ -1,6 +1,6 @@ #include "DevConfigUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include diff --git a/src/slic3r/GUI/DeviceCore/DevCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevCtrl.cpp index 56547e2a03..011d9228a0 100644 --- a/src/slic3r/GUI/DeviceCore/DevCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevCtrl.cpp @@ -4,7 +4,6 @@ #include "DevCtrl.h" // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevCtrl.h b/src/slic3r/GUI/DeviceCore/DevCtrl.h index 55d0dc4c3e..6b38cc1569 100644 --- a/src/slic3r/GUI/DeviceCore/DevCtrl.h +++ b/src/slic3r/GUI/DeviceCore/DevCtrl.h @@ -1,6 +1,6 @@ #pragma once -#include "slic3r/Utils/json_diff.hpp" +#include #include #include #include @@ -15,7 +15,7 @@ class DevCtrlInfo { public: DevCtrlInfo() {}; - DevCtrlInfo(MachineObject* obj, int sequence_id, const json& req_json, int interval_max = 3, int interval_min = 0); + DevCtrlInfo(MachineObject* obj, int sequence_id, const nlohmann::json& req_json, int interval_max = 3, int interval_min = 0); public: bool CheckCanUpdateData(const nlohmann::json& jj); @@ -32,7 +32,7 @@ private: time_t m_request_time = 0; int m_request_seq = 0; - json m_request_json = json(); + nlohmann::json m_request_json = nlohmann::json(); // check int m_request_interval_max = 3; diff --git a/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp b/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp index 1947cf1d87..86cb7362c8 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp +++ b/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp @@ -5,8 +5,6 @@ #include #include -using namespace nlohmann; - namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevExtensionTool.h b/src/slic3r/GUI/DeviceCore/DevExtensionTool.h index 8ce33b6e43..0b16c95a90 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtensionTool.h +++ b/src/slic3r/GUI/DeviceCore/DevExtensionTool.h @@ -3,7 +3,7 @@ #include #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include #include "DevDefs.h" diff --git a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp index 20975a7ca3..5013d85228 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp @@ -15,7 +15,6 @@ #include "DevFilaSystem.h" // complete type for GetFilaSystem()->GetTrayIndexMap() in GetBackupAmsSlotInGroup // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/I18N.hpp" diff --git a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h index 4d9f7c9abf..e7e083050f 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h @@ -5,7 +5,7 @@ #include #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include #include diff --git a/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp index 38513a2274..9379920b27 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp @@ -1,11 +1,8 @@ -#include #include "DevExtruderSystem.h" #include "slic3r/GUI/DeviceManager.hpp" -using namespace nlohmann; - namespace Slic3r { int DevExtderSystem::CtrlRetrySwitching() diff --git a/src/slic3r/GUI/DeviceCore/DevFan.cpp b/src/slic3r/GUI/DeviceCore/DevFan.cpp index 52ac9f1d76..c4fc80116b 100644 --- a/src/slic3r/GUI/DeviceCore/DevFan.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFan.cpp @@ -6,7 +6,6 @@ #include #include #include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevFan.h b/src/slic3r/GUI/DeviceCore/DevFan.h index 393c8a477c..b36705a19b 100644 --- a/src/slic3r/GUI/DeviceCore/DevFan.h +++ b/src/slic3r/GUI/DeviceCore/DevFan.h @@ -2,7 +2,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" #include #include @@ -13,7 +12,7 @@ namespace Slic3r { class MachineObject; enum AirDuctType { AIR_FAN_TYPE, AIR_DOOR_TYPE }; -typedef std::function CommandCallBack; +typedef std::function CommandCallBack; enum AIR_FUN : int { FAN_HEAT_BREAK_0_IDX = 0, @@ -123,14 +122,14 @@ public: AirDuctData GetAirDuctData() { return m_air_duct_data; }; void converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun); // Convert the data to duct type to make the newand old protocols consistent - int command_handle_response(const json &response); + int command_handle_response(const nlohmann::json &response); int command_control_fan(int fan_type, int val); // Old protocol int command_control_fan_new(int fan_id, int val); // New protocol int command_control_air_duct(int mode_id, int submode, const CommandCallBack& cb); - void ParseV1_0(const json &print_json); - void ParseV2_0(const json &print_json); - void ParseV3_0(const json &print_json); + void ParseV1_0(const nlohmann::json &print_json); + void ParseV2_0(const nlohmann::json &print_json); + void ParseV3_0(const nlohmann::json &print_json); public: bool GetSupportAirduct() { return is_support_airduct; }; diff --git a/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp index cc8312ce9a..f86838729c 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp @@ -1,11 +1,13 @@ #include "DevFilaAmsSetting.h" #include "DevFilaSystem.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include #include "slic3r/GUI/DeviceCore/DevCtrl.h" +using json = nlohmann::json; + namespace Slic3r { int DevAmsSystemFirmwareSwitch::CrtlSwitchFirmware(int firmware_idx) { diff --git a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp index c499b89622..ef921c5620 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp @@ -14,7 +14,6 @@ #include "slic3r/GUI/DeviceCore/DevDefs.h" #include "DevFilaBlackList.h" -#include "json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" #include "slic3r/GUI/DeviceManager.hpp" #include "DevFilaSystem.h" diff --git a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h index 1f727396a8..43e50360b9 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h +++ b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h @@ -5,7 +5,7 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" +#include namespace Slic3r { @@ -67,7 +67,7 @@ public: static CheckResult check_filaments_in_blacklist(const CheckFilamentInfo& info); public: - static json filaments_blacklist; + static nlohmann::json filaments_blacklist; };// class DevFilaBlacklist }// namespace Slic3r diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp index 14880a6ef3..14d78fba1f 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp @@ -18,7 +18,6 @@ #include #include #include "DevFilaSystem.h" -#include "json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" #include "DevNozzleSystem.h" // DevNozzle / DevNozzleSystem for GetNozzleFlowStringByAmsId @@ -161,7 +160,7 @@ DevAms::~DevAms() m_trays.clear(); } -static unordered_map s_ams_display_formats = { +static std::unordered_map s_ams_display_formats = { {DevAms::AMS, "AMS-%d"}, {DevAms::AMS_LITE, "AMS Lite-%d"}, {DevAms::N3F, "AMS 2 PRO-%d"}, diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystem.h b/src/slic3r/GUI/DeviceCore/DevFilaSystem.h index 32edc06a32..27dc238e9e 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystem.h @@ -1,6 +1,6 @@ #pragma once #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include "DevDefs.h" #include "DevFilaAmsSetting.h" @@ -415,9 +415,9 @@ private: class DevFilaSystemParser { public: - static void ParseV1_0(const json& print_json, MachineObject* obj, DevFilaSystem* system, bool key_field_only); + static void ParseV1_0(const nlohmann::json& print_json, MachineObject* obj, DevFilaSystem* system, bool key_field_only); - static void ParseAgentFilament(const json& data, MachineObject* obj, DevFilaSystem* system); + static void ParseAgentFilament(const nlohmann::json& data, MachineObject* obj, DevFilaSystem* system); }; struct DevFilamentDryingPreset diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp index 16121f00d2..e7181580cd 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp @@ -2,7 +2,6 @@ #include #include "DevFilaSystem.h" -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp"// TODO: remove this include using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevFirmware.h b/src/slic3r/GUI/DeviceCore/DevFirmware.h index 1b251144e5..bc0a0f0168 100644 --- a/src/slic3r/GUI/DeviceCore/DevFirmware.h +++ b/src/slic3r/GUI/DeviceCore/DevFirmware.h @@ -1,11 +1,9 @@ #pragma once #include "DevFirmware.h" -#include "slic3r/Utils/json_diff.hpp" #include #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -51,10 +49,10 @@ public: bool isCuttingModule() const { return product_name.Contains("Cutting Module"); } bool isRotary() const { return product_name.Contains("Rotary"); }// Rotary Attachment bool isExtinguishSystem() const { return product_name.Contains("Extinguishing System"); }// Auto Fire Extinguishing System - bool isWTM() const { return name.find("wtm") != string::npos; } // nozzle + bool isWTM() const { return name.find("wtm") != std::string::npos; } // nozzle bool isExhaustFan() const { return product_name.Contains("Exhaust Fan"); } - bool isHmshub() const { return product_name.find("Filament Buffer") != string::npos; } - bool isFilaTrackSwitch() const { return product_name.find("Filament Track") != string::npos; } + bool isHmshub() const { return product_name.find("Filament Buffer") != std::string::npos; } + bool isFilaTrackSwitch() const { return product_name.find("Filament Track") != std::string::npos; } }; diff --git a/src/slic3r/GUI/DeviceCore/DevHMS.cpp b/src/slic3r/GUI/DeviceCore/DevHMS.cpp index 456e806170..b696542658 100644 --- a/src/slic3r/GUI/DeviceCore/DevHMS.cpp +++ b/src/slic3r/GUI/DeviceCore/DevHMS.cpp @@ -2,10 +2,12 @@ #include "DevHMS.h" #include #include -#include "json_diff.hpp" +#include #include #include +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevHMS.h b/src/slic3r/GUI/DeviceCore/DevHMS.h index 82022833cf..1e499f3aea 100644 --- a/src/slic3r/GUI/DeviceCore/DevHMS.h +++ b/src/slic3r/GUI/DeviceCore/DevHMS.h @@ -1,6 +1,6 @@ #pragma once -#include "slic3r/Utils/json_diff.hpp" +#include #include #include #include @@ -18,7 +18,7 @@ public: DevHMS(MachineObject* obj) : m_object(obj) {} public: - void ParseHMSItems(const json& hms_json); + void ParseHMSItems(const nlohmann::json& hms_json); const std::vector& GetHMSItems() const { return m_hms_list; }; private: @@ -69,7 +69,7 @@ public: bool has_read() const { return m_already_read; }; protected: - friend void DevHMS::ParseHMSItems(const json& hms_json); + friend void DevHMS::ParseHMSItems(const nlohmann::json& hms_json); bool parse_hms_info(unsigned attr, unsigned code); private: diff --git a/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp index 5190632b5b..fefad1479f 100644 --- a/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp @@ -3,7 +3,6 @@ #include "DevLamp.h" // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevManager.cpp b/src/slic3r/GUI/DeviceCore/DevManager.cpp index 0fd5ed2cc0..c04321e71f 100644 --- a/src/slic3r/GUI/DeviceCore/DevManager.cpp +++ b/src/slic3r/GUI/DeviceCore/DevManager.cpp @@ -23,7 +23,6 @@ #include "DevUtil.h" // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/GUI_App.hpp" diff --git a/src/slic3r/GUI/DeviceCore/DevManager.h b/src/slic3r/GUI/DeviceCore/DevManager.h index 5ab3eed01b..1a669d0aee 100644 --- a/src/slic3r/GUI/DeviceCore/DevManager.h +++ b/src/slic3r/GUI/DeviceCore/DevManager.h @@ -3,7 +3,6 @@ #include #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" #include #include #include diff --git a/src/slic3r/GUI/DeviceCore/DevMapping.cpp b/src/slic3r/GUI/DeviceCore/DevMapping.cpp index 1ad35d3ee9..906ac2345b 100644 --- a/src/slic3r/GUI/DeviceCore/DevMapping.cpp +++ b/src/slic3r/GUI/DeviceCore/DevMapping.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -21,8 +20,6 @@ #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/GuiColor.hpp" -using namespace nlohmann; - namespace Slic3r { bool DevMappingUtil::is_valid_mapping_result(const MachineObject* obj, std::vector& result, bool check_empty_slot) diff --git a/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp b/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp index ee935a58a0..95081f5382 100644 --- a/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp +++ b/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp @@ -6,7 +6,6 @@ #include "DevUtil.h" #include "DevUtilBackend.h" -#include "json_diff.hpp" #include "libslic3r/MultiNozzleUtils.hpp" #include "slic3r/GUI/DeviceManager.hpp" @@ -251,7 +250,7 @@ int DevNozzleMappingCtrl::CtrlGetAutoNozzleMappingV1(Slic3r::GUI::Plater* plater void DevNozzleMappingCtrl::ParseAutoNozzleMapping(const json& print_jj) { - if (print_jj.contains("command") && print_jj["command"].get() == "get_auto_nozzle_mapping") { + if (print_jj.contains("command") && print_jj["command"].get() == "get_auto_nozzle_mapping") { if (print_jj.contains("sequence_id") && print_jj["sequence_id"] == m_sequence_id) { Clear(); DevJsonValParser::ParseVal(print_jj, "result", m_result); diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleRack.h b/src/slic3r/GUI/DeviceCore/DevNozzleRack.h index 28c7990b78..a5388eb2f2 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleRack.h +++ b/src/slic3r/GUI/DeviceCore/DevNozzleRack.h @@ -1,7 +1,7 @@ #pragma once #include "libslic3r/CommonDefs.hpp" #include "libslic3r/MultiNozzleUtils.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include "DevNozzleSystem.h" #include "DevFirmware.h" diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp index e8d720a324..484eb77098 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp @@ -1,7 +1,7 @@ #include "DevNozzleRack.h" #include "DevExtruderSystem.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/MsgDialog.hpp" #include "slic3r/GUI/I18N.hpp" @@ -14,6 +14,8 @@ #include "slic3r/GUI/DeviceCore/DevNozzleSystem.h" +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp index 70eec0f795..14c29817ef 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp @@ -4,7 +4,7 @@ #include "DevNozzleSystem.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/I18N.hpp" @@ -28,6 +28,8 @@ #include #include +using json = nlohmann::json; + namespace Slic3r { @@ -424,7 +426,7 @@ void DevNozzleSystem::ClearNozzles() // ---- parsing ---------------------------------------------------------------------------------------- -static unordered_map _str2_nozzle_flow_type = { +static std::unordered_map _str2_nozzle_flow_type = { {"S", NozzleFlowType::S_FLOW}, {"H", NozzleFlowType::H_FLOW}, {"A", NozzleFlowType::S_FLOW}, @@ -434,7 +436,7 @@ static unordered_map _str2_nozzle_flow_type = { {"B", NozzleFlowType::E_FLOW}, // E3D High Flow -> nvtE3DHighFlow }; -static unordered_map _str2_nozzle_type = { +static std::unordered_map _str2_nozzle_type = { {"00", NozzleType::ntStainlessSteel}, {"01", NozzleType::ntHardenedSteel}, {"05", NozzleType::ntTungstenCarbide} diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h index f4fc97938b..040ecb58b4 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h @@ -4,7 +4,7 @@ #include "libslic3r/CommonDefs.hpp" #include "libslic3r/MultiNozzleUtils.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include "libslic3r/PrintConfig.hpp" #include @@ -195,6 +195,6 @@ namespace Slic3r { public: static void ParseV1_0(const nlohmann::json& nozzletype_json, const nlohmann::json& diameter_json, DevNozzleSystem* system, std::optional flag_e3d); - static void ParseV2_0(const json& device_json, DevNozzleSystem* system); + static void ParseV2_0(const nlohmann::json& device_json, DevNozzleSystem* system); }; }; diff --git a/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp b/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp index 082997e177..c80597e28b 100644 --- a/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp +++ b/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp @@ -8,9 +8,11 @@ #include #include -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevStorage.cpp b/src/slic3r/GUI/DeviceCore/DevStorage.cpp index b2bd9f06ef..04a5ff8433 100644 --- a/src/slic3r/GUI/DeviceCore/DevStorage.cpp +++ b/src/slic3r/GUI/DeviceCore/DevStorage.cpp @@ -1,8 +1,10 @@ #include "DevStorage.h" -#include "json_diff.hpp" +#include #include +using json = nlohmann::json; + namespace Slic3r { DevStorage::SdcardState Slic3r::DevStorage::set_sdcard_state(int state) diff --git a/src/slic3r/GUI/DeviceCore/DevStorage.h b/src/slic3r/GUI/DeviceCore/DevStorage.h index 58f556499b..e436bbd9ea 100644 --- a/src/slic3r/GUI/DeviceCore/DevStorage.h +++ b/src/slic3r/GUI/DeviceCore/DevStorage.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -27,7 +26,7 @@ public: SdcardState get_sdcard_state() const { return m_sdcard_state; }; SdcardState set_sdcard_state(int state); - static void ParseV1_0(const json &print_json, DevStorage *system); + static void ParseV1_0(const nlohmann::json &print_json, DevStorage *system); bool is_timelapse_storage_low(const std::string& storage) const; diff --git a/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp b/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp index c35ec8bfce..16ffbf21fb 100644 --- a/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp +++ b/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp @@ -1,7 +1,7 @@ #include "DevUpgrade.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/GUI_App.hpp" @@ -13,6 +13,8 @@ #include "slic3r/GUI/DeviceCore/DevDefs.h" #include +using json = nlohmann::json; + namespace Slic3r { int DevUpgrade::GetUpgradeProgressInt() const diff --git a/src/slic3r/GUI/DeviceCore/DevUpgrade.h b/src/slic3r/GUI/DeviceCore/DevUpgrade.h index 1593f54260..7ff06b09f0 100644 --- a/src/slic3r/GUI/DeviceCore/DevUpgrade.h +++ b/src/slic3r/GUI/DeviceCore/DevUpgrade.h @@ -4,7 +4,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" #include "DevDefs.h" #include "DevFirmware.h" @@ -47,8 +46,8 @@ public: int CtrlUpgradeModule(std::string url, std::string module_type, std::string version); // parser - void ParseUpgrade_V1_0(const json &print_jj); - void ParseUpgradeDisplayState(const json &upgrade_state_jj); + void ParseUpgrade_V1_0(const nlohmann::json &print_jj); + void ParseUpgradeDisplayState(const nlohmann::json &upgrade_state_jj); protected: DevUpgrade(MachineObject *owner) : m_owner(owner) {} @@ -90,7 +89,7 @@ public: public: int CtrlGetVersion(bool with_retry = true); - void ParseGetVersion(const json &print_jj); + void ParseGetVersion(const nlohmann::json &print_jj); private: MachineObject *m_owner; diff --git a/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp index a6d4550a2b..58aa6ce6db 100644 --- a/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp @@ -1,10 +1,12 @@ #include "DevUpgrade.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include #include "slic3r/GUI/DeviceCore/DevFirmware.h" +using json = nlohmann::json; + namespace Slic3r { int DevUpgrade::CtrlUpgradeConfirm() diff --git a/src/slic3r/GUI/DeviceErrorDialog.cpp b/src/slic3r/GUI/DeviceErrorDialog.cpp index de578f78ed..23b7f3a665 100644 --- a/src/slic3r/GUI/DeviceErrorDialog.cpp +++ b/src/slic3r/GUI/DeviceErrorDialog.cpp @@ -368,7 +368,7 @@ wxString DeviceErrorDialog::parse_error_level(int error_code) } } -static const std::unordered_set s_jump_liveview_error_codes = { "0300-8003", "0300-8002", "0300-800A"}; +static const std::unordered_set s_jump_liveview_error_codes = { "0300-8003", "0300-8002", "0300-800A"}; wxString DeviceErrorDialog::show_error_code(int error_code) { if (m_error_code == error_code) { return wxEmptyString;} diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 392ff4587b..30e7282c0e 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1,5 +1,5 @@ #include "PrinterNetworkTypes.hpp" -#include "json_diff.hpp" +#include #include "DeviceManager.hpp" #include "HMS.hpp" #include "I18N.hpp" @@ -105,9 +105,12 @@ #include "libslic3r/PresetBundle.hpp" #include "slic3r/GUI/Jobs/SendJob.hpp" +using json = nlohmann::json; + class wxWindow; namespace fs = boost::filesystem; +using namespace std::chrono_literals; #define CALI_DEBUG #define MINUTE_30 1800000 //ms @@ -115,8 +118,6 @@ namespace fs = boost::filesystem; #define ORCA_NETWORK_DEBUG -namespace pt = boost::property_tree; - float string_to_float(const std::string& str_value) { float value = 0.0; fast_float::from_chars(str_value.c_str(), str_value.c_str() + str_value.size(), value); @@ -3103,7 +3104,7 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_ DevFirmwareVersionInfo ver_info; ver_info.name = (*it)["name"].get(); if ((*it).contains("product_name")) - ver_info.product_name = wxString::FromUTF8((*it)["product_name"].get()); + ver_info.product_name = wxString::FromUTF8((*it)["product_name"].get()); if ((*it).contains("sw_ver")) ver_info.sw_ver = (*it)["sw_ver"].get(); if ((*it).contains("sw_new_ver")) diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index c4a63cb588..f41a32ada7 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -63,7 +63,6 @@ #define END_SEQ_ID 30000 #define SUBSCRIBE_RETRY_COUNT 5 -using namespace nlohmann; namespace Slic3r { namespace GUI @@ -467,7 +466,7 @@ public: std::string get_print_error_str() const { return MachineObject::get_error_code_str(this->print_error); } std::unordered_set m_command_error_code_dlgs; - void add_command_error_code_dlg(int command_err, json action_json=json{}); + void add_command_error_code_dlg(int command_err, nlohmann::json action_json=nlohmann::json{}); int curr_layer = 0; int total_layers = 0; @@ -759,9 +758,9 @@ public: int command_set_printer_nozzle2(int id, std::string nozzle_type, float diameter); int command_get_access_code(); int command_start_camera(); - int command_ack_proceed(json& proceed); + int command_ack_proceed(nlohmann::json& proceed); int command_purification_disable(); - int command_dont_remind_next_time(json& mqtt_guard_json); + int command_dont_remind_next_time(nlohmann::json& mqtt_guard_json); /* command upgrade */ int command_upgrade_confirm(); @@ -887,7 +886,7 @@ public: static bool is_in_printing_status(std::string status); void set_print_state(std::string status); - void update_print_progress(const json& value); + void update_print_progress(const nlohmann::json& value); bool is_connected(); bool is_connecting(); @@ -903,7 +902,7 @@ public: /* Msg for display MsgFn */ typedef std::function MsgFn; - int publish_json(const json& json_item, int qos = 0, int flag = 0) ; + int publish_json(const nlohmann::json& json_item, int qos = 0, int flag = 0) ; int publish_json(const std::string& json_str, int qos = 0, int flag = 0) = delete; int cloud_publish_json(std::string json_str, int qos = 0, int flag = 0); int local_publish_json(std::string json_str, int qos = 0, int flag = 0); @@ -947,16 +946,16 @@ public: * or scenarios where users want to bypass the AMS. */ std::vector vt_slot; - DevAmsTray parse_vt_tray(json vtray); + DevAmsTray parse_vt_tray(nlohmann::json vtray); /*get ams slot info*/ bool contains_tray(const std::string &ams_id, const std::string &tray_id) const; DevAmsTray get_tray(const std::string &ams_id, const std::string &tray_id) const;/*use contains_tray() check first*/ /*for parse new info*/ - bool check_enable_np(const json& print) const; - void parse_new_info(json print); - void parse_new_info2(const json& info); + bool check_enable_np(const nlohmann::json& print) const; + void parse_new_info(nlohmann::json print); + void parse_new_info2(const nlohmann::json& info); int get_flag_bits(std::string str, int start, int count = 1) const; uint32_t get_flag_bits_no_border(std::string str, int start_idx, int count = 1) const; int get_flag_bits(int num, int start, int count = 1, int base = 10) const; diff --git a/src/slic3r/GUI/EditGCodeDialog.cpp b/src/slic3r/GUI/EditGCodeDialog.cpp index 917ff56013..2ef70ab82b 100644 --- a/src/slic3r/GUI/EditGCodeDialog.cpp +++ b/src/slic3r/GUI/EditGCodeDialog.cpp @@ -294,8 +294,8 @@ wxDataViewItem EditGCodeDialog::add_presets_placeholders() // Orca: create subgroups from the pages of the tabs - auto init_from_tab = [this, full_config](wxDataViewItem parent, Tab* tab, const set& preset_keys){ - set extra_keys(preset_keys); + auto init_from_tab = [this, full_config](wxDataViewItem parent, Tab* tab, const std::set& preset_keys){ + std::set extra_keys(preset_keys); for (const auto& page : tab->m_pages) { // ORCA: Pull icons from tabs for subgroups, icons are hidden on tabs std::string icon_name = "empty"; // use empty icon if not defined @@ -549,7 +549,7 @@ void ParamsNode::RefreshSearch(const wxString& search_text) if (GetEnabledChildren().empty()) if (auto pos = text.find(search_text); IsParamNode() && pos != wxString::npos) { - m_highlight_index = make_unique>(pos, search_text.Len()); + m_highlight_index = make_unique>(pos, search_text.Len()); Enable(); } else { Disable(); diff --git a/src/slic3r/GUI/ExportPresetBundleDialog.hpp b/src/slic3r/GUI/ExportPresetBundleDialog.hpp index 2038cd7677..a2a66ddbe6 100644 --- a/src/slic3r/GUI/ExportPresetBundleDialog.hpp +++ b/src/slic3r/GUI/ExportPresetBundleDialog.hpp @@ -67,7 +67,7 @@ public: void on_script_message(const nlohmann::json& payload) override; void OnRequestPresets(); - void OnExportData(const wxString& path, const wxString& name, json data); + void OnExportData(const wxString& path, const wxString& name, nlohmann::json data); protected: bool m_seq_top_layer_only_changed{false}; diff --git a/src/slic3r/GUI/ExtraRenderers.cpp b/src/slic3r/GUI/ExtraRenderers.cpp index 92f39145f0..8f390b82e4 100644 --- a/src/slic3r/GUI/ExtraRenderers.cpp +++ b/src/slic3r/GUI/ExtraRenderers.cpp @@ -38,9 +38,6 @@ #include "wx/private/markupparser.h" #endif // wxUSE_ACCESSIBILITY -using Slic3r::GUI::from_u8; -using Slic3r::GUI::into_u8; - //----------------------------------------------------------------------------- // DataViewBitmapText diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 05ab99bae1..fda86e854d 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -702,11 +702,11 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true set_value(str, true); } } else if (m_opt.opt_key == "sparse_infill_rotate_template" || m_opt.opt_key == "solid_infill_rotate_template") { - string ustr(str.utf8_string()); + std::string ustr(str.utf8_string()); if (!ConfigOptionFloats::validate_string(ustr)) { - string v; + std::string v; std::smatch match; - string ps = (m_opt.opt_key == "sparse_infill_rotate_template") ? + std::string ps = (m_opt.opt_key == "sparse_infill_rotate_template") ? u8"[BT][!]?|[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[BT]?[!*]?" : u8"[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[!*]?"; @@ -729,7 +729,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } break; } else if (m_opt.opt_key == "extra_solid_infills") { - string ustr(str.utf8_string()); + std::string ustr(str.utf8_string()); // New rule: accept either interval form (N or N#K) or explicit list (e.g. 1,7,9), with optional quotes. const std::regex rx_interval(u8R"(^\s*['"]?\s*\d+\s*(?:#\s*\d*)?\s*['"]?\s*$)"); // List entries may be plain numbers or number with optional #K count, e.g., 5, 9#2, 18 diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index dba2546f0c..2bd2730e76 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -99,6 +99,8 @@ #include "slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp" #include "slic3r/GUI/PartPlate.hpp" +using namespace std::string_view_literals; + namespace Slic3r { class PrintBase; } @@ -3026,7 +3028,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector>>& title_columns, float extra_size = 0.0f) { + auto calculate_offsets = [max_width, window_padding](const std::vector>>& title_columns, float extra_size = 0.0f) { const ImGuiStyle& style = ImGui::GetStyle(); std::vector offsets; offsets.push_back(max_width(title_columns[0].second, title_columns[0].first, extra_size) + 3.0f * style.ItemSpacing.x + style.WindowPadding.x); @@ -3173,7 +3175,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector>> title_columns; + std::vector>> title_columns; if (displayed_columns & ColumnData::Model) { title_columns.push_back({ _u8L("Filament"), {""} }); title_columns.push_back({ _u8L("Model"), {buff} }); @@ -3405,8 +3407,8 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) for (int j = idx; j < extruder_filaments.size() && j < idx + line_capacity; ++j) { auto text_info = imgui.calculate_filament_group_text_size(get_filament_display_type(extruder_filaments[j])); auto text_size = std::get<0>(text_info); - filament_group_item_align_width = max(filament_group_item_align_width, text_size.x); - text_line_height = max(text_line_height, text_size.y); + filament_group_item_align_width = std::max(filament_group_item_align_width, text_size.x); + text_line_height = std::max(text_line_height, text_size.y); } container_height += (three_words_width * 1.3f + text_line_height ); } @@ -3799,7 +3801,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv return ret; }; - auto calculate_offsets = [max_width, this](const std::vector>>& title_columns, float extra_size = 0.0f) { + auto calculate_offsets = [max_width, this](const std::vector>>& title_columns, float extra_size = 0.0f) { const ImGuiStyle& style = ImGui::GetStyle(); std::vector offsets; // ORCA increase spacing for more readable format. Using direct number requires much less code change in here. GetTextLineHeight for additional spacing for icon_size @@ -3832,7 +3834,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv if (extruder_id + 1 != static_cast(item.extruder)) continue; - if (item.type != ColorChange) + if (item.type != CustomGCode::ColorChange) continue; if (!zs_built) { @@ -4224,7 +4226,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv total_filaments.push_back(buffer); - std::vector>> title_columns; + std::vector>> title_columns; if (displayed_columns & ColumnData::Model) { title_columns.push_back({ _u8L("Filament"), {""} }); title_columns.push_back({ _u8L("Model"), total_filaments }); @@ -4999,10 +5001,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv ImGui::SameLine(); switch (custom_gcode.type) { - case PausePrint: imgui.text(cgcode_pause_str); break; - case Template: imgui.text(cgcode_template_str); break; - case ToolChange: imgui.text(cgcode_toolchange_str); break; - case Custom: imgui.text(cgcode_custom_str); break; + case CustomGCode::PausePrint: imgui.text(cgcode_pause_str); break; + case CustomGCode::Template: imgui.text(cgcode_template_str); break; + case CustomGCode::ToolChange: imgui.text(cgcode_toolchange_str); break; + case CustomGCode::Custom: imgui.text(cgcode_custom_str); break; default: imgui.text(cgcode_unknown_str); break; } ImGui::SameLine(max_len); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 808c1831d2..95b8239387 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -177,6 +177,8 @@ extern wxPopupWindow* wxCurrentPopupWindow; #endif #endif +using namespace std::string_view_literals; + static constexpr const float TRACKBALLSIZE = 0.8f; static Slic3r::ColorRGBA DEFAULT_BG_LIGHT_COLOR = { 0.906f, 0.906f, 0.906f, 1.0f }; @@ -184,12 +186,12 @@ static Slic3r::ColorRGBA DEFAULT_BG_LIGHT_COLOR_DARK = { 0.329f, 0.329f, 0.353f, static Slic3r::ColorRGBA ERROR_BG_LIGHT_COLOR = { 0.753f, 0.192f, 0.039f, 1.0f }; static Slic3r::ColorRGBA ERROR_BG_LIGHT_COLOR_DARK = { 0.753f, 0.192f, 0.039f, 1.0f }; -void GLCanvas3D::update_render_colors() +void Slic3r::GUI::GLCanvas3D::update_render_colors() { DEFAULT_BG_LIGHT_COLOR = ImGuiWrapper::from_ImVec4(RenderColor::colors[RenderCol_3D_Background]); } -void GLCanvas3D::load_render_colors() +void Slic3r::GUI::GLCanvas3D::load_render_colors() { RenderColor::colors[RenderCol_3D_Background] = ImGuiWrapper::to_ImVec4(DEFAULT_BG_LIGHT_COLOR); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 8fe5e97c51..80129fdee2 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -311,8 +311,10 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS2)( #include #endif +namespace fs = boost::filesystem; using namespace std::literals; namespace pt = boost::property_tree; +using json = nlohmann::json; struct StaticBambuLib { @@ -9040,7 +9042,7 @@ std::map GUI_App::get_delete_cache_presets_lock() void GUI_App::process_delete_presets() { - std::map delete_cache_presets = get_delete_cache_presets_lock(); + std::map delete_cache_presets = get_delete_cache_presets_lock(); for (auto it = delete_cache_presets.begin(); it != delete_cache_presets.end();) { if (it->first.empty()) continue; std::string del_setting_id = it->first; @@ -10068,7 +10070,7 @@ bool is_soluble_filament(int extruder_id) return support_option->get_at(0); }; -bool has_filaments(const std::vector& model_filaments) { +bool has_filaments(const std::vector& model_filaments) { auto &filament_presets = Slic3r::GUI::wxGetApp().preset_bundle->filament_presets; if (!Slic3r::GUI::wxGetApp().plater()) return false; auto model_objects = Slic3r::GUI::wxGetApp().plater()->model().objects; @@ -10103,7 +10105,7 @@ bool is_support_filament(int extruder_id, bool strict_check) Slic3r::ConfigOptionBools *support_option = dynamic_cast(filament->config.option("filament_is_support")); if(!strict_check &&(filament_type == "PETG" || filament_type == "PLA")) { - std::vector model_filaments; + std::vector model_filaments; if (filament_type == "PETG") model_filaments.emplace_back("PLA"); else { diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 625b26cc0d..21210b06b7 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1108,7 +1108,7 @@ void ObjectList::update_name_column_width() const } } - GetColumn(colName)->SetWidth(max(0, client_size.x - (others_width)*em)); + GetColumn(colName)->SetWidth(std::max(0, client_size.x - (others_width)*em)); } void ObjectList::set_filament_column_hidden(const bool hide) const @@ -3970,7 +3970,7 @@ wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const D if (config->opt_float("layer_height") == object_cfg->opt_float("layer_height")) { SettingsFactory::Bundle new_cat_options; for (auto cat_opt : cat_options) { - std::vector temp; + std::vector temp; for (auto value : cat_opt.second) { if (value != "layer_height") temp.push_back(value); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 1c17a02956..3358715885 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -415,7 +415,7 @@ void Preview::sys_color_changed() // m_layers_slider->sys_color_changed(); } -void Preview::on_tick_changed(Type type) +void Preview::on_tick_changed(CustomGCode::Type type) { //if (type == Type::PausePrint) { // m_schedule_background_process(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 2800b2b146..b3fe914afa 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -3651,7 +3651,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection) // model_name failing reason std::vector> failed_models; auto plater = wxGetApp().plater(); - auto fix_and_update_progress = [keep_painting](ModelObject *model_object, const int vol_idx, const string &model_name, ProgressDialog &progress_dlg, + auto fix_and_update_progress = [keep_painting](ModelObject *model_object, const int vol_idx, const std::string &model_name, ProgressDialog &progress_dlg, std::vector &succes_models, std::vector> &failed_models) { wxString msg = _L("Repairing model object"); msg += ": " + from_u8(model_name) + "\n"; @@ -4098,8 +4098,6 @@ void GLGizmoCut3D::apply_cut_connectors(ModelObject* mo, const std::string& conn if (mo->cut_connectors.empty()) return; - using namespace Geometry; - size_t connector_id = mo->cut_id.connectors_cnt(); for (const CutConnector& connector : mo->cut_connectors) { TriangleMesh mesh = TriangleMesh(get_connector_mesh(connector.attribs)); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp deleted file mode 100644 index e74507596e..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include "GLGizmoPrimitive.hpp" -#include "slic3r/GUI/GLCanvas3D.hpp" -#include "slic3r/GUI/ImGuiWrapper.hpp" -#include "slic3r/GUI/Plater.hpp" -#include "slic3r/GUI/NotificationManager.hpp" -#include "libslic3r/Model.hpp" -#include -#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp" -#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp" -#include "libslic3r/CAD/GeometryEngine.hpp" -#include -#include -#include "slic3r/GUI/GUI_App.hpp" -#include -#include -#include - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif -#include -#include "libslic3r/TriangleMesh.hpp" -#include "slic3r/GUI/I18N.hpp" - -namespace Slic3r { -namespace GUI { - -GLGizmoPrimitive::GLGizmoPrimitive(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) - : GLGizmoBase(parent, icon_filename, sprite_id) {} - -bool GLGizmoPrimitive::on_init() { return true; } -std::string GLGizmoPrimitive::on_get_name() const { return _u8L("Primitive"); } -// Part of the experimental CAD feature: built into every CAD build, but offered in the Prepare -// toolbar only when that feature is switched on in Preferences — switched off, Prepare must be -// exactly what it is without it. -bool GLGizmoPrimitive::on_is_activable() const { return wxGetApp().is_enable_cad_feature(); } -bool GLGizmoPrimitive::on_is_selectable() const { return wxGetApp().is_enable_cad_feature(); } -void GLGizmoPrimitive::on_render() {} -void GLGizmoPrimitive::on_set_state() -{ if (m_state == EState::On) { m_params = PrimitiveParams{}; m_preview_dirty = true; } } - -bool GLGizmoPrimitive::on_mouse(const wxMouseEvent&) { return false; } - -CommonGizmosDataID GLGizmoPrimitive::on_get_requirements() const -{ return CommonGizmosDataID(int(CommonGizmosDataID::SelectionInfo) | int(CommonGizmosDataID::InstancesHider)); } - -void GLGizmoPrimitive::on_load(cereal::BinaryInputArchive& ar) -{ ar(m_params); m_preview_dirty = true; } -void GLGizmoPrimitive::on_save(cereal::BinaryOutputArchive& ar) const -{ ar(m_params); } - -void GLGizmoPrimitive::apply_preset(const char*, double w, double h, double d) -{ - m_params.type = PrimitiveType::Box; - m_params.box_w = w; m_params.box_h = h; m_params.box_d = d; - m_preview_dirty = true; -} - -static void gen_mesh_and_add(PrimitiveParams& p, const char* snap_name) -{ - TopoDS_Solid solid = GeometryEngine::make_primitive(p); - TopoDS_Shape shape = solid; - if (p.dressup_enabled) { - if (p.dressup_type == DressUpType::Fillet) - shape = GeometryEngine::apply_fillet(shape, p.dressup_radius, p.dressup_faces); - else - shape = GeometryEngine::apply_chamfer(shape, p.dressup_chamfer_dist, p.dressup_faces); - } - TriangleMesh mesh = GeometryEngine::tessellate(shape, p.linear_deflection, p.angular_deflection); - if (mesh.its.indices.empty()) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::WarningNotificationLevel, _u8L("Empty mesh generated")); - return; - } - wxGetApp().plater()->take_snapshot(snap_name); - ModelObject* mo = wxGetApp().model().add_object(); - std::string name = GeometryEngine::primitive_name(p.type); - if (p.dressup_enabled && p.dressup_type == DressUpType::Fillet) name += " (Fillet)"; - else if (p.dressup_enabled) name += " (Chamfer)"; - mo->name = name; - mo->add_volume(std::move(mesh))->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); -} - -void GLGizmoPrimitive::apply_primitive() { gen_mesh_and_add(m_params, "Add Primitive"); } - -void GLGizmoPrimitive::on_render_input_window(float x, float y, float bottom_limit) -{ - y = std::min(y, bottom_limit - ImGui::GetWindowHeight()); - const float scale = m_parent.get_scale(); - ImGuiWrapper::push_toolbar_style(scale); - GizmoImguiSetNextWIndowPos(x, y, ImGuiCond_Always, 0.0f, 0.0f); - GizmoImguiBegin("Primitive", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse - | ImGuiWindowFlags_NoTitleBar); - - if (ImGui::CollapsingHeader(_u8L("Shape").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - const std::string names_s[] = {_u8L("Box"), _u8L("Cylinder"), _u8L("Sphere"), _u8L("Cone"), _u8L("Torus")}; - const char* names[] = {names_s[0].c_str(), names_s[1].c_str(), names_s[2].c_str(), names_s[3].c_str(), names_s[4].c_str()}; - int cur = (int)m_params.type; - if (ImGui::Combo("##type", &cur, names, (int)PrimitiveType::COUNT)) { - m_params.type = (PrimitiveType)cur; - m_preview_dirty = true; - } - // TRN Primitive gizmo: label in front of the preset cube size buttons - ImGui::TextUnformatted(_u8L("Quick:").c_str()); - ImGui::SameLine(); - if (ImGui::SmallButton("10mm")) apply_preset("10mm cube", 10, 10, 10); - ImGui::SameLine(); - if (ImGui::SmallButton("20mm")) apply_preset("20mm cube", 20, 20, 20); - ImGui::SameLine(); - if (ImGui::SmallButton("50mm")) apply_preset("50mm cube", 50, 50, 50); - } - - ImGui::Separator(); - - if (ImGui::CollapsingHeader(_u8L("Dimensions").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - auto dim = [&](const char* label, double& val, double step=0.5, double fast=5.0) { - ImGui::SetNextItemWidth(130); - if (ImGui::InputDouble(label, &val, step, fast, "%.1f mm")) m_preview_dirty = true; - if (val < 0.5) val = 0.5; - }; - switch (m_params.type) { - case PrimitiveType::Box: - dim(_u8L("Width (X)").c_str(), m_params.box_w); - dim(_u8L("Depth (Y)").c_str(), m_params.box_d); - dim(_u8L("Height (Z)").c_str(), m_params.box_h); - break; - case PrimitiveType::Cylinder: - dim(_u8L("Radius").c_str(), m_params.cyl_radius); - dim(_u8L("Height").c_str(), m_params.cyl_height); - break; - case PrimitiveType::Sphere: - dim(_u8L("Radius").c_str(), m_params.sph_radius); - break; - case PrimitiveType::Cone: - // TRN Primitive gizmo: bottom radius of a cone ("Top R" is the top radius) - dim(_u8L("Bottom R").c_str(), m_params.cone_r1); - dim(_u8L("Top R").c_str(), m_params.cone_r2); - dim(_u8L("Height").c_str(), m_params.cone_height); - break; - case PrimitiveType::Torus: - // TRN Primitive gizmo: major radius of a torus ("Minor R" is the tube radius) - dim(_u8L("Major R").c_str(), m_params.torus_r1); - dim(_u8L("Minor R").c_str(), m_params.torus_r2, 0.1, 1.0); - break; - default: break; - } - } - - ImGui::Separator(); - - if (ImGui::CollapsingHeader(_u8L("Fillet / Chamfer").c_str())) { - ImGui::Checkbox(_u8L("Enable").c_str(), &m_params.dressup_enabled); - if (m_params.dressup_enabled) { - const std::string dn_s[] = {_u8L("Fillet"), _u8L("Chamfer")}; - const char* dn[] = {dn_s[0].c_str(), dn_s[1].c_str()}; - int du = (int)m_params.dressup_type; - ImGui::SetNextItemWidth(100); - if (ImGui::Combo("##dtype", &du, dn, 2)) { m_params.dressup_type = (DressUpType)du; m_preview_dirty = true; } - const std::string fn_s[] = {_u8L("All edges"), _u8L("Top edges"), _u8L("Bottom edges"), _u8L("Lateral edges")}; - const char* fn[] = {fn_s[0].c_str(), fn_s[1].c_str(), fn_s[2].c_str(), fn_s[3].c_str()}; - int fg = (int)m_params.dressup_faces; - ImGui::SetNextItemWidth(140); - if (ImGui::Combo(_u8L("Edges").c_str(), &fg, fn, 4)) { m_params.dressup_faces = (FaceGroup)fg; m_preview_dirty = true; } - if (m_params.dressup_type == DressUpType::Fillet) { - ImGui::SetNextItemWidth(100); - if (ImGui::InputDouble(_u8L("Radius").c_str(), &m_params.dressup_radius, 0.1, 1.0, "%.1f mm")) { - if (m_params.dressup_radius < 0.1) m_params.dressup_radius = 0.1; - m_preview_dirty = true; - } - } else { - ImGui::SetNextItemWidth(100); - if (ImGui::InputDouble(_u8L("Distance").c_str(), &m_params.dressup_chamfer_dist, 0.1, 1.0, "%.1f mm")) { - if (m_params.dressup_chamfer_dist < 0.1) m_params.dressup_chamfer_dist = 0.1; - m_preview_dirty = true; - } - } - } - } - - ImGui::Separator(); - - if (ImGui::CollapsingHeader(_u8L("Quality").c_str())) { - ImGui::SetNextItemWidth(130); - if (ImGui::InputDouble(_u8L("Mesh resolution").c_str(), &m_params.linear_deflection, 0.001, 0.1, "%.3f mm")) { - if (m_params.linear_deflection < 0.001) m_params.linear_deflection = 0.001; - if (m_params.linear_deflection > 1.0) m_params.linear_deflection = 1.0; - m_preview_dirty = true; - } - } - - ImGui::Separator(); - - if (ImGui::Button(_u8L("Add Shape").c_str(), {-1, 28})) - apply_primitive(); - - if (ImGui::Button(_u8L("Close").c_str(), {-1, 0})) - m_parent.reset_all_gizmos(); - - GizmoImguiEnd(); - ImGuiWrapper::pop_toolbar_style(); -} - -} // namespace GUI -} // namespace Slic3r diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp deleted file mode 100644 index eef44a64c4..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef slic3r_GLGizmoPrimitive_hpp_ -#define slic3r_GLGizmoPrimitive_hpp_ - -#include "GLGizmoBase.hpp" -#include "GLGizmosCommon.hpp" -#include "libslic3r/CAD/GeometryEngine.hpp" -#include -#include -#include -#include "libslic3r/TriangleMesh.hpp" - -namespace Slic3r { -namespace GUI { - -class GLGizmoPrimitive : public GLGizmoBase -{ -public: - GLGizmoPrimitive(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); - ~GLGizmoPrimitive() = default; - - bool on_mouse(const wxMouseEvent& mouse_event) override; - -protected: - bool on_init() override; - std::string on_get_name() const override; - bool on_is_activable() const override; - bool on_is_selectable() const override; - void on_render() override; - void on_set_state() override; - CommonGizmosDataID on_get_requirements() const override; - void on_render_input_window(float x, float y, float bottom_limit) override; - - void on_load(cereal::BinaryInputArchive& ar) override; - void on_save(cereal::BinaryOutputArchive& ar) const override; - -private: - void apply_primitive(); - void apply_preset(const char* name, double w, double h, double d); - - PrimitiveParams m_params; - TriangleMesh m_preview_mesh; - bool m_preview_dirty{true}; -}; - -} // namespace GUI -} // namespace Slic3r - -#endif // slic3r_GLGizmoPrimitive_hpp_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp index 2ab05d6179..c4d76a0315 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp @@ -77,7 +77,6 @@ #include using namespace Slic3r; -using namespace Slic3r::Emboss; using namespace Slic3r::GUI; using namespace Slic3r::GUI::Emboss; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp deleted file mode 100644 index 4561a1eac6..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp +++ /dev/null @@ -1,488 +0,0 @@ -#include "GLGizmoSketch.hpp" -#include "slic3r/GUI/GLCanvas3D.hpp" -#include "slic3r/GUI/ImGuiWrapper.hpp" -#include "slic3r/GUI/Plater.hpp" -#include "slic3r/GUI/NotificationManager.hpp" -#include "slic3r/GUI/format.hpp" -#include "libslic3r/Model.hpp" -#include -#include -#include -#include -#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp" -#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp" -#include "libslic3r/CAD/SketchEngine.hpp" -#include "libslic3r/Point.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include "libslic3r/CAD/GeometryEngine.hpp" -#include -#include "slic3r/GUI/GUI_App.hpp" -#include -#include - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif -#include -#include "libslic3r/TriangleMesh.hpp" -#include "slic3r/GUI/I18N.hpp" -#include "slic3r/GUI/Selection.hpp" - -namespace Slic3r { -namespace GUI { - -GLGizmoSketch::GLGizmoSketch(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) - : GLGizmoBase(parent, icon_filename, sprite_id) {} - -bool GLGizmoSketch::on_init() { return true; } -std::string GLGizmoSketch::on_get_name() const { return _u8L("Sketch"); } -// Part of the experimental CAD feature: built into every CAD build, but offered in the Prepare -// toolbar only when that feature is switched on in Preferences — switched off, Prepare must be -// exactly what it is without it. -bool GLGizmoSketch::on_is_activable() const { return wxGetApp().is_enable_cad_feature(); } -bool GLGizmoSketch::on_is_selectable() const { return wxGetApp().is_enable_cad_feature(); } -void GLGizmoSketch::on_render() {} -void GLGizmoSketch::on_set_state() { if (m_state == EState::On) clear_all(); } -bool GLGizmoSketch::on_mouse(const wxMouseEvent&) { return false; } - -CommonGizmosDataID GLGizmoSketch::on_get_requirements() const -{ return CommonGizmosDataID(int(CommonGizmosDataID::SelectionInfo)); } - -void GLGizmoSketch::on_load(cereal::BinaryInputArchive& ar) -{ - ar(m_tool, m_profiles, m_plane, m_sp, m_rect_w, m_rect_h, m_circle_r, m_poly_sides, m_poly_r, m_snap_grid, m_grid_step); - m_active_profile = -1; -} - -void GLGizmoSketch::on_save(cereal::BinaryOutputArchive& ar) const -{ - ar(m_tool, m_profiles, m_plane, m_sp, m_rect_w, m_rect_h, m_circle_r, m_poly_sides, m_poly_r, m_snap_grid, m_grid_step); -} - -SketchProfile& GLGizmoSketch::active_profile() -{ - if (m_active_profile < 0 || m_active_profile >= (int)m_profiles.size()) { - m_profiles.emplace_back(); - m_active_profile = (int)m_profiles.size() - 1; - } - return m_profiles[m_active_profile]; -} - -bool GLGizmoSketch::has_closed_profile() const -{ - for (auto& p : m_profiles) if (p.closed && p.points.size() >= 3) return true; - return false; -} - -void GLGizmoSketch::clear_all() -{ - m_profiles.clear(); - m_canvas_points.clear(); - m_active_profile = -1; -} - -void GLGizmoSketch::add_closed_profile() -{ - auto& ap = active_profile(); - if (ap.points.size() >= 3) { - ap.closed = true; - m_active_profile = -1; - } -} - -void GLGizmoSketch::delete_profile(int idx) -{ - if (idx >= 0 && idx < (int)m_profiles.size()) { - m_profiles.erase(m_profiles.begin() + idx); - if (m_active_profile >= (int)m_profiles.size()) m_active_profile = -1; - } -} - -Vec2d GLGizmoSketch::snap(Vec2d pt) const -{ - if (!m_snap_grid) return pt; - double gs = m_grid_step; - return {round(pt.x() / gs) * gs, round(pt.y() / gs) * gs}; -} - -void GLGizmoSketch::build_preset_profile() -{ - auto& ap = active_profile(); - ap.clear(); - auto add = [&](double x, double y) { ap.points.emplace_back(x, y); }; - switch (m_tool) { - case SketchTool::Rectangle: - add(-m_rect_w/2, -m_rect_h/2); add( m_rect_w/2, -m_rect_h/2); - add( m_rect_w/2, m_rect_h/2); add(-m_rect_w/2, m_rect_h/2); - ap.closed = true; m_active_profile = -1; break; - case SketchTool::Circle: - for (int i = 0; i <= m_circle_seg; ++i) { - double a = 2.0*M_PI*i/m_circle_seg; - add(cos(a)*m_circle_r, sin(a)*m_circle_r); - } - ap.closed = true; m_active_profile = -1; break; - case SketchTool::Polygon: - for (int i = 0; i < m_poly_sides; ++i) { - double a = 2.0*M_PI*i/m_poly_sides - M_PI/2; - add(cos(a)*m_poly_r, sin(a)*m_poly_r); - } - ap.closed = true; m_active_profile = -1; break; - default: break; - } -} - -void GLGizmoSketch::handle_canvas_click(ImVec2 pos) -{ - Vec2d pt = snap({pos.x / m_canvas_scale, -pos.y / m_canvas_scale}); - if (m_tool == SketchTool::Line) { - auto& ap = active_profile(); - if (ap.points.size() >= 3 && (pt - ap.points.front()).norm() < m_grid_step) { - ap.points.push_back(ap.points.front()); - ap.closed = true; - m_active_profile = -1; - return; - } - ap.points.push_back(pt); - } -} - -void GLGizmoSketch::draw_canvas() -{ - ImDrawList* dl = ImGui::GetWindowDrawList(); - ImVec2 pos = ImGui::GetCursorScreenPos(); - float w = 280, h = 200; - ImVec2 end(pos.x+w, pos.y+h); - float cx = pos.x+w/2, cy = pos.y+h/2; - auto tc = [&](const ImVec2& p) { return ImVec2(cx+p.x*m_canvas_scale, cy-p.y*m_canvas_scale); }; - - dl->AddRectFilled(pos, end, IM_COL32(28,28,36,255)); - dl->AddRect(pos, end, IM_COL32(55,55,68,255)); - - float gs = m_grid_step; - for (float g = 0; g < w; g += gs * m_canvas_scale) { - ImU32 gc = (int(g/(gs*m_canvas_scale)) % 5 == 0) ? IM_COL32(60,60,75,100) : IM_COL32(45,45,55,60); - dl->AddLine({pos.x+g,pos.y}, {pos.x+g,end.y}, gc); - } - for (float g = 0; g < h; g += gs * m_canvas_scale) { - ImU32 gc = (int(g/(gs*m_canvas_scale)) % 5 == 0) ? IM_COL32(60,60,75,100) : IM_COL32(45,45,55,60); - dl->AddLine({pos.x,pos.y+g}, {end.x,pos.y+g}, gc); - } - - dl->AddLine({cx,pos.y},{cx,end.y}, IM_COL32(70,70,85,180), 1.5f); - dl->AddLine({pos.x,cy},{end.x,cy}, IM_COL32(70,70,85,180), 1.5f); - dl->AddText({end.x-12, cy+2}, IM_COL32(120,120,140,200), "X"); - dl->AddText({cx+4, pos.y+2}, IM_COL32(120,120,140,200), "Y"); - - for (size_t pi = 0; pi < m_profiles.size(); ++pi) { - auto& prof = m_profiles[pi]; - if (prof.points.size() < 2) continue; - std::vector sp; - for (auto& p : prof.points) sp.push_back(tc({(float)p.x(), (float)p.y()})); - if (prof.closed && sp.size() >= 3) { - bool is_outer = (pi == 0); - ImU32 fill = is_outer ? IM_COL32(0,180,90,35) : IM_COL32(180,60,60,35); - ImU32 line = is_outer ? IM_COL32(0,220,100,255) : IM_COL32(220,80,80,255); - dl->AddConvexPolyFilled(sp.data(), (int)sp.size(), fill); - for (size_t i=0; iAddLine(sp[i], sp[(i+1)%sp.size()], line, (pi==0)?2.5f:2.0f); - for (size_t i=0; iAddCircleFilled(sp[i], 3.0f, IM_COL32(255,255,255,255)); - } - } - - auto& ap = active_profile(); - if (!ap.closed && ap.points.size() >= 1) { - std::vector sp; - for (auto& p : ap.points) sp.push_back(tc({(float)p.x(), (float)p.y()})); - for (size_t i=1; iAddLine(sp[i-1], sp[i], IM_COL32(0,200,255,200), 2.0f); - for (auto& s : sp) dl->AddCircleFilled(s, 3.5f, IM_COL32(100,200,255,255)); - ImVec2 mouse = ImGui::GetMousePos(); - if (mouse.x > pos.x && mouse.x < end.x && mouse.y > pos.y && mouse.y < end.y) - dl->AddLine(sp.back(), mouse, IM_COL32(100,160,220,120), 1.5f); - } - - ImGui::InvisibleButton("canvas", ImVec2(w,h)); - if (ImGui::IsItemHovered()) { - ImVec2 m = ImGui::GetMousePos(); - Vec2d sk({(m.x-cx)/m_canvas_scale, -(m.y-cy)/m_canvas_scale}); - if (m_snap_grid) sk = snap(sk); - auto txt = wxString::Format("X:%.1f Y:%.1f", sk.x(), sk.y()).ToStdString(); - dl->AddText({pos.x+4, end.y-16}, IM_COL32(160,160,180,200), txt.c_str()); - if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) - handle_canvas_click({(m.x-cx)/m_canvas_scale, -(m.y-cy)/m_canvas_scale}); - if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) { - auto& ap2 = active_profile(); - if (ap2.points.size() >= 3) { - ap2.points.push_back(ap2.points.front()); - ap2.closed = true; - m_active_profile = -1; - } - } - } -} - -TopoDS_Shape GLGizmoSketch::build_combined_shape() -{ - if (m_profiles.empty() || !m_profiles[0].closed) - throw std::runtime_error(_u8L("No outer profile")); - - TopoDS_Wire outer_wire = m_profiles[0].to_occt_wire(m_plane); - BRepBuilderAPI_MakeFace face_maker(outer_wire); - if (!face_maker.IsDone()) throw std::runtime_error(_u8L("Failed to make outer face")); - - for (size_t i = 1; i < m_profiles.size(); ++i) { - if (!m_profiles[i].closed) continue; - TopoDS_Wire inner = m_profiles[i].to_occt_wire(m_plane); - face_maker.Add(inner); - } - face_maker.Build(); - if (!face_maker.IsDone()) throw std::runtime_error(_u8L("Failed to build face with holes")); - - TopoDS_Face face = face_maker.Face(); - - TopoDS_Shape shape; - if (m_sp.revolve_deg < 360.0 && m_sp.revolve_deg > 0.0) { - gp_Pnt o(m_plane.origin.x(), m_plane.origin.y(), m_plane.origin.z()); - gp_Dir xd(m_plane.x_axis.x(), m_plane.x_axis.y(), m_plane.x_axis.z()); - gp_Ax1 axis(o, xd); - BRepPrimAPI_MakeRevol rev(face, axis, m_sp.revolve_deg * M_PI / 180.0); - if (!rev.IsDone()) throw std::runtime_error(_u8L("Revolve failed")); - shape = rev.Shape(); - } else { - shape = SketchEngine::make_extrude_face(face, m_plane, m_sp.extrude_len, m_sp.extrude_sym); - } - - if (m_sp.dressup_enabled) { - if (m_sp.dressup_type == DressUpType::Fillet) - shape = GeometryEngine::apply_fillet(shape, m_sp.dressup_radius, m_sp.dressup_faces); - else - shape = GeometryEngine::apply_chamfer(shape, m_sp.dressup_chamfer_dist, m_sp.dressup_faces); - } - return shape; -} - -void GLGizmoSketch::on_render_input_window(float x, float y, float bottom_limit) -{ - y = std::min(y, bottom_limit - ImGui::GetWindowHeight()); - const float scale = m_parent.get_scale(); - ImGuiWrapper::push_toolbar_style(scale); - GizmoImguiSetNextWIndowPos(x, y, ImGuiCond_Always, 0.0f, 0.0f); - GizmoImguiBegin("Sketch", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse - | ImGuiWindowFlags_NoTitleBar); - - if (ImGui::CollapsingHeader(_u8L("Profile").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - const std::string names_s[] = {_u8L("Line"), _u8L("Rectangle"), _u8L("Circle"), _u8L("Polygon")}; - const char* names[] = {names_s[0].c_str(), names_s[1].c_str(), names_s[2].c_str(), names_s[3].c_str()}; - int cur = (int)m_tool; - if (ImGui::Combo("##shape", &cur, names, (int)SketchTool::COUNT)) { - m_tool = (SketchTool)cur; - if (m_tool != SketchTool::Line) build_preset_profile(); - } - ImGui::SameLine(); - if (m_imgui->button("+##newprofile")) m_active_profile = -1; - if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _u8L("Start new profile (for holes)").c_str()); - - if (m_tool == SketchTool::Rectangle) { - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble(_u8L("Width").c_str(), &m_rect_w,1,10,"%.0f")) build_preset_profile(); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble(_u8L("Height").c_str(), &m_rect_h,1,10,"%.0f")) build_preset_profile(); - } else if (m_tool == SketchTool::Circle) { - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble(_u8L("Radius").c_str(), &m_circle_r,1,5,"%.0f")) build_preset_profile(); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); if (ImGui::SliderInt(_u8L("Segments").c_str(), &m_circle_seg,8,64)) build_preset_profile(); - } else if (m_tool == SketchTool::Polygon) { - ImGui::SetNextItemWidth(80); if (ImGui::SliderInt(_u8L("Sides").c_str(), &m_poly_sides,3,12)) build_preset_profile(); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble((_u8L("Radius") + "##poly").c_str(), &m_poly_r,1,5,"%.0f")) build_preset_profile(); - } else { - ImGui::Text("%s", _u8L("Click on canvas to draw").c_str()); - } - - ImGui::Checkbox(_u8L("Snap to grid").c_str(), &m_snap_grid); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); ImGui::InputFloat(_u8L("Grid step").c_str(), &m_grid_step, 1, 5, "%.0f mm"); - - draw_canvas(); - - if (!m_profiles.empty()) { - ImGui::Text("%s: %zu", _u8L("Profiles").c_str(), m_profiles.size()); - for (int i = 0; i < (int)m_profiles.size(); ++i) { - auto& p = m_profiles[i]; - ImGui::PushID(i); - bool outer = (i == 0); - ImVec4 col = outer ? ImVec4(0,1,0,1) : ImVec4(1,0.3f,0.3f,1); - const std::string label = outer ? _u8L("Outer") : _u8L("Hole"); - const std::string state = p.closed ? _u8L("closed") : std::string(); - // TRN Sketch gizmo profile list: "Outer" or "Hole", profile number, point count, "closed" or nothing - ImGui::TextColored(col, "%s", GUI::format(_u8L("%1% %2%: %3% points %4%"), label, i + 1, p.points.size(), state).c_str()); - ImGui::SameLine(); - if (ImGui::SmallButton("X")) delete_profile(i); - ImGui::PopID(); - } - } - } - - ImGui::Separator(); - - bool is_revolve = false; - bool has_sel = false; - - if (ImGui::CollapsingHeader(_u8L("Operation").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - static int pi = 0; - const std::string plane_names[] = {_u8L("XY (Top)"), _u8L("XZ (Front)"), _u8L("YZ (Side)")}; - const char* planes[] = {plane_names[0].c_str(), plane_names[1].c_str(), plane_names[2].c_str()}; - if (ImGui::Combo(_u8L("Plane").c_str(), &pi, planes, 3)) - m_plane = (pi==0) ? SketchPlane::XY() : (pi==1) ? SketchPlane::XZ() : SketchPlane::YZ(); - - is_revolve = (m_sp.revolve_deg > 0 && m_sp.revolve_deg < 360); - ImGui::SetNextItemWidth(100); - if (ImGui::InputDouble(_u8L("Revolve deg").c_str(), &m_sp.revolve_deg, 15, 90, "%.0f")) { - if (m_sp.revolve_deg > 360) m_sp.revolve_deg = 360; - if (m_sp.revolve_deg < 0) m_sp.revolve_deg = 0; - } - if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _u8L("Set to 0 for extrude, >0 for revolve").c_str()); - - if (!is_revolve) { - ImGui::SetNextItemWidth(100); - ImGui::InputDouble(_u8L("Length").c_str(), &m_sp.extrude_len, 0.5, 5, "%.1f mm"); - ImGui::SameLine(); - ImGui::Checkbox(_u8L("Symmetric").c_str(), &m_sp.extrude_sym); - } - - has_sel = !m_parent.get_selection().is_empty(); - if (has_sel) { - if (ImGui::Checkbox(_u8L("Pocket (cut)").c_str(), &m_sp.is_pocket)) - if (m_sp.is_pocket) m_sp.dressup_enabled = false; - } else m_sp.is_pocket = false; - } - - ImGui::Separator(); - - if (!m_sp.is_pocket && ImGui::CollapsingHeader(_u8L("Fillet / Chamfer").c_str())) { - ImGui::Checkbox(_u8L("Enable").c_str(), &m_sp.dressup_enabled); - if (m_sp.dressup_enabled) { - const std::string dn_s[] = {_u8L("Fillet"), _u8L("Chamfer")}; - const char* dn[] = {dn_s[0].c_str(), dn_s[1].c_str()}; - int du = (int)m_sp.dressup_type; - ImGui::SetNextItemWidth(100); - if (ImGui::Combo("##dtype", &du, dn, 2)) m_sp.dressup_type = (DressUpType)du; - const std::string fn_s[] = {_u8L("All edges"), _u8L("Top edges"), _u8L("Bottom edges"), _u8L("Lateral edges")}; - const char* fn[] = {fn_s[0].c_str(), fn_s[1].c_str(), fn_s[2].c_str(), fn_s[3].c_str()}; - int fg = (int)m_sp.dressup_faces; - ImGui::SetNextItemWidth(140); - ImGui::Combo(_u8L("Edges").c_str(), &fg, fn, 4); m_sp.dressup_faces = (FaceGroup)fg; - ImGui::SetNextItemWidth(100); - if (m_sp.dressup_type == DressUpType::Fillet) - ImGui::InputDouble(_u8L("Radius").c_str(), &m_sp.dressup_radius, 0.1, 1, "%.1f mm"); - else - ImGui::InputDouble(_u8L("Distance").c_str(), &m_sp.dressup_chamfer_dist, 0.1, 1, "%.1f mm"); - } - } - - ImGui::Separator(); - - bool ok = has_closed_profile(); - if (ok) ImGui::TextColored({0,1,0,1}, "%s", wxString::Format(_L_PLURAL("%zu closed profile", "%zu closed profiles", - unsigned(m_profiles.size())), m_profiles.size()).ToUTF8().data()); - else ImGui::TextColored({0.6f,0.6f,0.6f,1}, "%s", _u8L("Draw a closed profile to enable").c_str()); - - auto btn = [&](const char* label, bool enabled) { - if (!enabled) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled,true); ImGui::PushStyleColor(ImGuiCol_Button,{0.25f,0.25f,0.25f,1}); } - bool clicked = ImGui::Button(label, {-1,0}); - if (!enabled) { ImGui::PopStyleColor(); ImGui::PopItemFlag(); } - return clicked && enabled; - }; - - if (m_sp.is_pocket && has_sel) { - if (btn(_u8L("Pocket (cut)").c_str(), ok)) apply_pocket(); - } else if (is_revolve) { - if (btn(_u8L("Revolve").c_str(), ok)) apply_revolve(); - } else { - if (btn(_u8L_CONTEXT("Extrude", "Design").c_str(), ok)) apply_extrude(); - } - - if (ImGui::Button(_u8L("Clear all").c_str(), {-1,0})) clear_all(); - if (ImGui::Button(_u8L("Close").c_str(), {-1,0})) m_parent.reset_all_gizmos(); - - GizmoImguiEnd(); - ImGuiWrapper::pop_toolbar_style(); -} - -void GLGizmoSketch::apply_extrude() -{ - try { - TopoDS_Shape shape = build_combined_shape(); - TriangleMesh mesh = SketchEngine::tessellate(shape, m_sp.linear_deflection); - if (mesh.its.indices.empty()) throw std::runtime_error(_u8L("Empty result")); - wxGetApp().plater()->take_snapshot("Sketch Extrude"); - ModelObject* mo = wxGetApp().model().add_object(); - mo->name = "Extrusion"; - mo->add_volume(std::move(mesh))->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); - clear_all(); - } catch (const std::exception& e) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::ErrorNotificationLevel, GUI::format(_u8L("Extrude: %1%"), e.what())); - } -} - -void GLGizmoSketch::apply_revolve() -{ - try { - TopoDS_Shape shape = build_combined_shape(); - TriangleMesh mesh = SketchEngine::tessellate(shape, m_sp.linear_deflection); - if (mesh.its.indices.empty()) throw std::runtime_error(_u8L("Empty result")); - wxGetApp().plater()->take_snapshot("Sketch Revolve"); - ModelObject* mo = wxGetApp().model().add_object(); - mo->name = "Revolve"; - mo->add_volume(std::move(mesh))->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); - clear_all(); - } catch (const std::exception& e) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::ErrorNotificationLevel, GUI::format(_u8L("Revolve: %1%"), e.what())); - } -} - -void GLGizmoSketch::apply_pocket() -{ - try { - Selection& sel = m_parent.get_selection(); - int obj_idx = sel.get_object_idx(); - if (obj_idx < 0) throw std::runtime_error(_u8L("No object selected")); - ModelObject* mo = wxGetApp().model().objects[obj_idx]; - - TopoDS_Wire outer = m_profiles[0].to_occt_wire(m_plane); - BRepBuilderAPI_MakeFace fm(outer); - if (!fm.IsDone()) throw std::runtime_error(_u8L("Face failed")); - for (size_t i = 1; i < m_profiles.size(); ++i) - if (m_profiles[i].closed) fm.Add(m_profiles[i].to_occt_wire(m_plane)); - fm.Build(); - if (!fm.IsDone()) throw std::runtime_error(_u8L("Face with holes failed")); - - TopoDS_Shape tool = SketchEngine::make_extrude_face(fm.Face(), m_plane, m_sp.extrude_len + 5.0, false); - TriangleMesh tool_mesh = SketchEngine::tessellate(tool, m_sp.linear_deflection); - if (tool_mesh.its.indices.empty()) throw std::runtime_error(_u8L("Tool mesh empty")); - - wxGetApp().plater()->take_snapshot("Sketch Pocket"); - mo->add_volume(std::move(tool_mesh), ModelVolumeType::NEGATIVE_VOLUME)->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); - clear_all(); - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::RegularNotificationLevel, _u8L("Pocket added (negative volume)").c_str()); - } catch (const std::exception& e) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::ErrorNotificationLevel, GUI::format(_u8L("Pocket: %1%"), e.what())); - } -} - -} // namespace GUI -} // namespace Slic3r diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp deleted file mode 100644 index 257fac8c6d..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef slic3r_GLGizmoSketch_hpp_ -#define slic3r_GLGizmoSketch_hpp_ - -#include "GLGizmoBase.hpp" -#include "GLGizmosCommon.hpp" -#include "libslic3r/CAD/SketchEngine.hpp" -#include -#include -#include -#include -#include -#include -#include "libslic3r/Point.hpp" - -namespace Slic3r { -namespace GUI { - -enum class SketchTool { Line, Rectangle, Circle, Polygon, COUNT }; - -class GLGizmoSketch : public GLGizmoBase -{ -public: - GLGizmoSketch(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); - - bool on_mouse(const wxMouseEvent& mouse_event) override; - -protected: - bool on_init() override; - std::string on_get_name() const override; - bool on_is_activable() const override; - bool on_is_selectable() const override; - void on_render() override; - void on_set_state() override; - CommonGizmosDataID on_get_requirements() const override; - void on_render_input_window(float x, float y, float bottom_limit) override; - - void on_load(cereal::BinaryInputArchive& ar) override; - void on_save(cereal::BinaryOutputArchive& ar) const override; - -private: - SketchTool m_tool{SketchTool::Line}; - std::vector m_profiles; // multiple profiles (outer + holes) - SketchPlane m_plane{SketchPlane::XY()}; - SketchParams m_sp; - - // Shape presets - double m_rect_w{20}, m_rect_h{15}; - double m_circle_r{10}; int m_circle_seg{32}; - int m_poly_sides{6}; double m_poly_r{10}; - - // Canvas - std::vector m_canvas_points; - Vec2d m_canvas_center{0,0}; - float m_canvas_scale{5.0f}; - bool m_snap_grid{true}; - float m_grid_step{5.0f}; - - // Current profile being drawn - int m_active_profile{-1}; - - SketchProfile& active_profile(); - bool has_closed_profile() const; - - void build_preset_profile(); - void add_closed_profile(); - void delete_profile(int idx); - void clear_all(); - - TopoDS_Shape build_combined_shape(); // all profiles as face with holes - void apply_extrude(); - void apply_revolve(); - void apply_pocket(); - void draw_canvas(); - void handle_canvas_click(ImVec2 pos); - Vec2d snap(Vec2d pt) const; -}; - -} // namespace GUI -} // namespace Slic3r - -#endif // slic3r_GLGizmoSketch_hpp_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index f8c65e9ac9..00bdd13bcb 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -50,10 +50,6 @@ #include #include #include "libslic3r/AppConfig.hpp" -#ifdef SLIC3R_CAD -#include "slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp" -#include "slic3r/GUI/Gizmos/GLGizmoSketch.hpp" -#endif #include "libslic3r/Model.hpp" @@ -217,14 +213,6 @@ void GLGizmosManager::switch_gizmos_icon_filename() case (EType::BrimEars): gizmo->set_icon_filename(m_is_dark ? "toolbar_brimears_dark.svg" : "toolbar_brimears.svg"); break; -#ifdef SLIC3R_CAD - case (EType::Primitive): - gizmo->set_icon_filename(m_is_dark ? "toolbar_modifier_cube_dark.svg" : "toolbar_modifier_cube.svg"); - break; - case (EType::Sketch): - gizmo->set_icon_filename(m_is_dark ? "toolbar_sketch_dark.svg" : "toolbar_sketch.svg"); - break; -#endif } } @@ -270,14 +258,6 @@ bool GLGizmosManager::init() m_gizmos.emplace_back(new GLGizmoAssembly(m_parent, m_is_dark ? "toolbar_assembly_dark.svg" : "toolbar_assembly.svg", EType::Assembly)); m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify)); m_gizmos.emplace_back(new GLGizmoBrimEars(m_parent, m_is_dark ? "toolbar_brimears_dark.svg" : "toolbar_brimears.svg", EType::BrimEars)); -#ifdef SLIC3R_CAD - // Registered last: Primitive and Sketch are the final entries before Undefined, so - // omitting them leaves every preceding m_gizmos index (indexed by EType) untouched. - if (wxGetApp().is_enable_cad_feature()) { - m_gizmos.emplace_back(new GLGizmoPrimitive(m_parent, m_is_dark ? "toolbar_modifier_cube_dark.svg" : "toolbar_modifier_cube.svg", static_cast(Primitive))); - m_gizmos.emplace_back(new GLGizmoSketch(m_parent, m_is_dark ? "toolbar_sketch_dark.svg" : "toolbar_sketch.svg", static_cast(Sketch))); - } -#endif //m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++)); //m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++)); //m_gizmos.emplace_back(new GLGizmoHollow(m_parent, "hollow.svg", sprite_id++)); @@ -1375,8 +1355,7 @@ GLGizmoBase* GLGizmosManager::get_current() const GLGizmoBase* GLGizmosManager::get_gizmo(GLGizmosManager::EType type) const { - // m_gizmos ends before the enum does when the CAD gizmos are not registered. - return type < m_gizmos.size() ? m_gizmos[type].get() : nullptr; + return ((type == Undefined) || m_gizmos.empty()) ? nullptr : m_gizmos[type].get(); } GLGizmosManager::EType GLGizmosManager::get_gizmo_from_name(const std::string& gizmo_name) const diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index 855e26c102..3f53eeaa93 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -102,12 +102,6 @@ public: Assembly, Simplify, BrimEars, -#ifdef SLIC3R_CAD - // Both need the CAD kernel (GeometryEngine); keep them last so that with - // SLIC3R_CAD off the enum matches upstream's numbering exactly. - Primitive, - Sketch, -#endif //SlaSupports, // BBS //FaceRecognition, diff --git a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp index 72f08318c6..bb76a171b8 100644 --- a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp +++ b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp @@ -44,6 +44,8 @@ #define MAX_NUM 9999.99 #define MAX_SIZE std::string_view{"9999.99"} +using namespace std::string_view_literals; + namespace Slic3r { namespace GUI diff --git a/src/slic3r/GUI/HMS.cpp b/src/slic3r/GUI/HMS.cpp index a210a99656..2234d1afb4 100644 --- a/src/slic3r/GUI/HMS.cpp +++ b/src/slic3r/GUI/HMS.cpp @@ -6,7 +6,7 @@ #include "DeviceCore/DevManager.h" #include "DeviceCore/DevUtil.h" #include "Http.hpp" -#include "json_diff.hpp" +#include #include "libslic3r/AppConfig.hpp" #include @@ -26,13 +26,14 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; static const char* HMS_PATH = "hms"; static const char* HMS_LOCAL_IMG_PATH = "hms/local_image"; // the local HMS info // Orca: dev-id-type set trimmed to the devices Orca ships local HMS images for -static unordered_set package_dev_id_types {"094", "239", "093", "22E"}; +static std::unordered_set package_dev_id_types {"094", "239", "093", "22E"}; // Orca: HMS should be disabled when stealth mode is on or networking is not installed static bool should_disable_hms() @@ -344,17 +345,17 @@ wxString HMSQuery::query_hms_msg(const std::string& dev_id, const std::string& l return _query_hms_msg(dev_id.substr(0, 3), long_error_code, lang_code); } -string HMSQuery::get_dev_id_type(const MachineObject* obj) const +std::string HMSQuery::get_dev_id_type(const MachineObject* obj) const { if (obj) { return obj->get_dev_id().substr(0, 3); } - return string(); + return std::string(); } -wxString HMSQuery::_query_hms_msg(const string& dev_id_type, const string& long_error_code, const string& lang_code) +wxString HMSQuery::_query_hms_msg(const std::string& dev_id_type, const std::string& long_error_code, const std::string& lang_code) { if (long_error_code.empty()) { @@ -425,9 +426,9 @@ wxString HMSQuery::_query_hms_msg(const string& dev_id_type, const string& long_ return wxEmptyString; } -bool HMSQuery::_is_internal_error(const string &dev_id_type, - const string &error_code, - const string &lang_code) +bool HMSQuery::_is_internal_error(const std::string &dev_id_type, + const std::string &error_code, + const std::string &lang_code) { init_hms_info(dev_id_type); auto iter = m_hms_info_jsons.find(dev_id_type); diff --git a/src/slic3r/GUI/IMSlider.cpp b/src/slic3r/GUI/IMSlider.cpp index ce2aa2ecba..eab44adf76 100644 --- a/src/slic3r/GUI/IMSlider.cpp +++ b/src/slic3r/GUI/IMSlider.cpp @@ -46,6 +46,8 @@ namespace Slic3r { +using namespace CustomGCode; + namespace GUI { // equal to 25 mm2 @@ -1405,7 +1407,7 @@ void IMSlider::render_input_custom_gcode(std::string custom_gcode) } void IMSlider::do_go_to_layer(size_t layer_number) { - layer_number = clamp((int)layer_number, m_min_value, m_max_value); + layer_number = std::clamp((int)layer_number, m_min_value, m_max_value); GetSelection() == ssLower ? SetLowerValue(layer_number) : SetHigherValue(layer_number); } diff --git a/src/slic3r/GUI/IMSlider.hpp b/src/slic3r/GUI/IMSlider.hpp index 9df84a7a75..4f02167669 100644 --- a/src/slic3r/GUI/IMSlider.hpp +++ b/src/slic3r/GUI/IMSlider.hpp @@ -20,7 +20,6 @@ struct IMGUI_API ImRect; namespace Slic3r { -using namespace CustomGCode; class PrintObject; class Layer; @@ -89,8 +88,8 @@ public: void SetSliderValues(const std::vector &values); void SetSliderAlternateValues(const std::vector &values) { m_alternate_values = values; } - Info GetTicksValues() const; - void SetTicksValues(const Info &custom_gcode_per_print_z); + CustomGCode::Info GetTicksValues() const; + void SetTicksValues(const CustomGCode::Info &custom_gcode_per_print_z); void SetLayersTimes(const std::vector &layers_times, float total_time); void SetLayersTimes(const std::vector &layers_times); @@ -98,8 +97,8 @@ public: void SetDrawMode(DrawMode mode) { m_draw_mode = mode; } //BBS void SetExtraStyle(long style) { m_extra_style = style; } - void SetManipulationMode(Mode mode) { m_mode = mode; } - Mode GetManipulationMode() const { return m_mode; } + void SetManipulationMode(CustomGCode::Mode mode) { m_mode = mode; } + CustomGCode::Mode GetManipulationMode() const { return m_mode; } void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder, bool can_change_color); void SetExtruderColors(const std::vector &extruder_colors); @@ -117,8 +116,8 @@ public: void UseDefaultColors(bool def_colors_on) { m_ticks.set_default_colors(def_colors_on); } void on_mouse_wheel(wxMouseEvent& evt); - void post_ticks_changed_event(Type type = Unknown); - bool check_ticks_changed_event(Type type); + void post_ticks_changed_event(CustomGCode::Type type = CustomGCode::Unknown); + bool check_ticks_changed_event(CustomGCode::Type type); bool switch_one_layer_mode(); void show_go_to_layer(bool show) { m_show_go_to_layer_dialog = show; } @@ -130,9 +129,9 @@ public: bool is_need_post_tick_event() { return m_is_need_post_tick_changed_event; } void reset_post_tick_event(bool val = false) { m_is_need_post_tick_changed_event = val; - m_tick_change_event_type = Type::Unknown; + m_tick_change_event_type = CustomGCode::Type::Unknown; } - Type get_post_tick_event_type() { return m_tick_change_event_type; } + CustomGCode::Type get_post_tick_event_type() { return m_tick_change_event_type; } float m_scale = 1.0; void set_scale(float scale = 1.0); @@ -143,7 +142,7 @@ public: protected: void add_custom_gcode(std::string custom_gcode); - void add_code_as_tick(Type type, int selected_extruder = -1); + void add_code_as_tick(CustomGCode::Type type, int selected_extruder = -1); void delete_tick(const TickCode& tick); void do_go_to_layer(size_t layer_number); //menu void correct_lower_value(); @@ -156,7 +155,7 @@ protected: void render_edit_menu(const TickCode& tick); //menu void draw_background_and_groove(const ImRect& bg_rect, const ImRect& groove); void draw_colored_band(const ImRect& groove, const ImRect& slideable_region); - void draw_custom_label_block(const ImVec2 anchor, Type type); + void draw_custom_label_block(const ImVec2 anchor, CustomGCode::Type type); void draw_ticks(const ImRect& slideable_region); void draw_tick_on_mouse_position(const ImRect& slideable_region); void show_tooltip(const TickCode& tick); //menu @@ -217,7 +216,7 @@ private: void *m_delete_icon_id; DrawMode m_draw_mode = dmRegular; - Mode m_mode = SingleExtruder; + CustomGCode::Mode m_mode = CustomGCode::SingleExtruder; int m_only_extruder = -1; long m_style; @@ -232,7 +231,7 @@ private: bool m_can_change_color; std::string m_print_obj_idxs; bool m_is_need_post_tick_changed_event { false }; - Type m_tick_change_event_type; + CustomGCode::Type m_tick_change_event_type; std::vector m_alternate_values; diff --git a/src/slic3r/GUI/ImageDPIFrame.cpp b/src/slic3r/GUI/ImageDPIFrame.cpp index 83904fe650..2884792451 100644 --- a/src/slic3r/GUI/ImageDPIFrame.cpp +++ b/src/slic3r/GUI/ImageDPIFrame.cpp @@ -19,9 +19,6 @@ #include #include "wxExtensions.hpp" -using namespace Slic3r; -using namespace Slic3r::GUI; - namespace Slic3r { namespace GUI { #define ANIMATION_REFRESH_INTERVAL 20 ImageDPIFrame::ImageDPIFrame() diff --git a/src/slic3r/GUI/Jobs/BindJob.hpp b/src/slic3r/GUI/Jobs/BindJob.hpp index 06de566e52..f2a8cbe1c4 100644 --- a/src/slic3r/GUI/Jobs/BindJob.hpp +++ b/src/slic3r/GUI/Jobs/BindJob.hpp @@ -11,8 +11,6 @@ class wxWindow; -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp index 6159182c2b..d80873d223 100644 --- a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp +++ b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp @@ -30,7 +30,6 @@ #include "libslic3r/libslic3r.h" #include -using namespace Slic3r; using namespace Slic3r::GUI; const std::string CreateFontImageJob::default_text = "AaBbCc 123"; diff --git a/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp b/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp index ac9b11b81e..f1b545ad4c 100644 --- a/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp +++ b/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp @@ -23,9 +23,6 @@ #include #include -using namespace Slic3r; -using namespace Slic3r::Emboss; -using namespace Slic3r::GUI; using namespace Slic3r::GUI::Emboss; diff --git a/src/slic3r/GUI/Jobs/PrintJob.cpp b/src/slic3r/GUI/Jobs/PrintJob.cpp index 29f2e5b403..b6b420969f 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -19,7 +19,7 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include "slic3r/GUI/PartPlate.hpp" #include "libslic3r/PrintConfig.hpp" @@ -39,6 +39,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { @@ -334,7 +335,7 @@ void PrintJob::process(Ctl &ctl) auto origin_profile_id = model_info->metadata_items.find(BBL_DESIGNER_PROFILE_ID_TAG); if (origin_profile_id != model_info->metadata_items.end()) { try { - params.origin_profile_id = stoi(origin_profile_id->second.c_str()); + params.origin_profile_id = std::stoi(origin_profile_id->second.c_str()); } catch(...) {} } diff --git a/src/slic3r/GUI/Jobs/PrintJob.hpp b/src/slic3r/GUI/Jobs/PrintJob.hpp index 4207824471..150635cfb1 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.hpp +++ b/src/slic3r/GUI/Jobs/PrintJob.hpp @@ -12,8 +12,6 @@ #include "Job.hpp" #include "slic3r/GUI/DeviceCore/DevStorage.h" -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { @@ -26,9 +24,9 @@ class PrintPrepareData public: bool is_from_plater = true; int plate_idx; - fs::path _3mf_path; - fs::path _3mf_config_path; - fs::path _temp_path; + boost::filesystem::path _3mf_path; + boost::filesystem::path _3mf_config_path; + boost::filesystem::path _temp_path; PrintPrepareData() { plate_idx = 0; } diff --git a/src/slic3r/GUI/Jobs/SendJob.cpp b/src/slic3r/GUI/Jobs/SendJob.cpp index 0aa0dd98c6..419b03afd3 100644 --- a/src/slic3r/GUI/Jobs/SendJob.cpp +++ b/src/slic3r/GUI/Jobs/SendJob.cpp @@ -1,5 +1,5 @@ #include "SendJob.hpp" -#include "json_diff.hpp" +#include #include "bambu_networking.hpp" #include "libslic3r/LifecycleEvents.hpp" #include "slic3r/GUI/I18N.hpp" @@ -23,6 +23,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Jobs/SendJob.hpp b/src/slic3r/GUI/Jobs/SendJob.hpp index c77efe69bb..3d96a3a6dd 100644 --- a/src/slic3r/GUI/Jobs/SendJob.hpp +++ b/src/slic3r/GUI/Jobs/SendJob.hpp @@ -11,8 +11,6 @@ #include "Job.hpp" #include "PrintJob.hpp" -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp b/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp index 77a1e9544d..1b0892d0eb 100644 --- a/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp +++ b/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp @@ -12,8 +12,6 @@ class wxWindow; -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 689f9eb87c..c882667d90 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -34,7 +34,7 @@ #include "slic3r/GUI/Widgets/SideMenuPopup.hpp" #include #include "libslic3r/libslic3r.h" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -155,6 +155,8 @@ #include +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index 249db6c3d7..54ce5907fb 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -45,6 +45,8 @@ #include "../Utils/MacDarkMode.hpp" #endif +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/ModelMall.cpp b/src/slic3r/GUI/ModelMall.cpp index 66d26f1042..e8b08f7e02 100644 --- a/src/slic3r/GUI/ModelMall.cpp +++ b/src/slic3r/GUI/ModelMall.cpp @@ -13,7 +13,7 @@ #include "slic3r/GUI/Widgets/WebView.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -24,6 +24,8 @@ #include "GUI_App.hpp" #include "Plater.hpp" +using json = nlohmann::json; + namespace Slic3r::GUI { class Plater; } namespace Slic3r { diff --git a/src/slic3r/GUI/Monitor.cpp b/src/slic3r/GUI/Monitor.cpp index 2c800ecebb..b23c5ab468 100644 --- a/src/slic3r/GUI/Monitor.cpp +++ b/src/slic3r/GUI/Monitor.cpp @@ -15,7 +15,7 @@ #include "slic3r/GUI/StatusPanel.hpp" #include "slic3r/GUI/UpgradePanel.hpp" #include "slic3r/GUI/Widgets/SideTools.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -57,6 +57,8 @@ #include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/Widgets/Button.hpp" +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/MonitorBasePanel.cpp b/src/slic3r/GUI/MonitorBasePanel.cpp index d8a1f3b835..e09be6d6f9 100644 --- a/src/slic3r/GUI/MonitorBasePanel.cpp +++ b/src/slic3r/GUI/MonitorBasePanel.cpp @@ -293,7 +293,6 @@ VideoMonitoringBasePanel::~VideoMonitoringBasePanel() /////////////////////////////////////////////////////////////////////////// -using namespace Slic3r::GUI; TaskListBasePanel::TaskListBasePanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxPanel(parent, id, pos, size, style, name) { diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 7a7050429d..3e91d19cdd 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -536,12 +536,12 @@ void NotificationManager::PopNotification::count_lines() return; // handle with marks - if (pos_start == string::npos && pos_end == string::npos) { + if (pos_start == std::string::npos && pos_end == std::string::npos) { pos_start = text.find(error_start); - if (pos_start != string::npos) { + if (pos_start != std::string::npos) { text.erase(pos_start, error_start.length()); pos_end = text.find(error_end); - if (pos_end != string::npos) { + if (pos_end != std::string::npos) { text.erase(pos_end, error_end.length()); } } @@ -675,7 +675,7 @@ void NotificationManager::PopNotification::bbl_render_block_notif_text(ImGuiWrap if (m_text1.size() > m_endlines[i]) last_end += (m_text1[m_endlines[i]] == '\n' || m_text1[m_endlines[i]] == ' ' ? 1 : 0); - if (pos_start != string::npos && pos_end != string::npos && m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { + if (pos_start != std::string::npos && pos_end != std::string::npos && m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { push_style_color(ImGuiCol_Text, m_ErrorColor, m_state == EState::FadingOut, m_current_fade_opacity); imgui.text(line.c_str()); ImGui::PopStyleColor(); @@ -737,7 +737,7 @@ void NotificationManager::PopNotification::render_text(ImGuiWrapper& imgui, cons if (m_text1.size() > m_endlines[i]) last_end += (m_text1[m_endlines[i]] == '\n' || m_text1[m_endlines[i]] == ' ' ? 1 : 0); - if (pos_start != string::npos && pos_end != string::npos&& m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { + if (pos_start != std::string::npos && pos_end != std::string::npos&& m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { push_style_color(ImGuiCol_Text, m_ErrorColor, m_state == EState::FadingOut, m_current_fade_opacity); imgui.text(line.c_str()); ImGui::PopStyleColor(); diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index 2613d3da9a..2fcd872390 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -631,8 +631,8 @@ private: // Aditional text after hypertext - currently not used std::string m_text2; // mark for render operation - size_t pos_start = string::npos; - size_t pos_end = string::npos; + size_t pos_start = std::string::npos; + size_t pos_end = std::string::npos; std::string error_start = ""; std::string error_end = ""; diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 98981ed757..d4ef74f77b 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -60,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -113,9 +111,6 @@ #include "slic3r/GUI/GLModel.hpp" class wxFont; -namespace boost { template class optional; } -using boost::optional; -namespace fs = boost::filesystem; static const float GROUND_Z = -0.03f; static const float GROUND_Z_GRIDLINE = -0.26f; diff --git a/src/slic3r/GUI/PartSkipDialog.cpp b/src/slic3r/GUI/PartSkipDialog.cpp index ddf0d10965..4c0557abea 100644 --- a/src/slic3r/GUI/PartSkipDialog.cpp +++ b/src/slic3r/GUI/PartSkipDialog.cpp @@ -86,7 +86,7 @@ PartSkipDialog::PartSkipDialog(wxWindow *parent) : DPIDialog(parent, wxID_ANY, _ { std::time_t t = std::time(0); std::stringstream buf; - buf << put_time(std::localtime(&t), "%a_%b_%d_%H_%M_%S/"); + buf << std::put_time(std::localtime(&t), "%a_%b_%d_%H_%M_%S/"); m_timestamp = buf.str(); SetBackgroundColour(*wxWHITE); @@ -402,7 +402,7 @@ std::string PartSkipDialog::create_tmp_path() return tmp_path; } -bool PartSkipDialog::is_local_file_existed(const std::vector &local_paths) +bool PartSkipDialog::is_local_file_existed(const std::vector &local_paths) { for (auto path : local_paths) { if (!std::filesystem::exists(path)) { return false; } @@ -703,8 +703,8 @@ void PartSkipDialog::InitDialogUI() m_parts_state.clear(); m_parts_name.clear(); - string pick_img = m_local_paths[0]; - string slice_info = m_local_paths[2]; + std::string pick_img = m_local_paths[0]; + std::string slice_info = m_local_paths[2]; m_switch_drag_btn->SetIcon("canvas_drag"); m_switch_drag_btn->SetBackgroundColor(*wxWHITE); diff --git a/src/slic3r/GUI/PartSkipDialog.hpp b/src/slic3r/GUI/PartSkipDialog.hpp index f1aef1f022..4e4f7b6bb6 100644 --- a/src/slic3r/GUI/PartSkipDialog.hpp +++ b/src/slic3r/GUI/PartSkipDialog.hpp @@ -139,11 +139,11 @@ private: boost::shared_ptr m_file_sys; std::string m_timestamp; std::string m_tmp_path; - std::vector m_local_paths; - std::vector m_target_paths; + std::vector m_local_paths; + std::vector m_target_paths; std::string create_tmp_path(); - bool is_local_file_existed(const std::vector &local_paths); + bool is_local_file_existed(const std::vector &local_paths); void DownloadPartsFile(); void OnFileSystemEvent(wxCommandEvent &event); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3684020f8a..86ed871ed6 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -298,11 +298,7 @@ #include "DeviceCore/DevConfigUtil.h" #include "DeviceCore/DevDefs.h" -using boost::optional; namespace fs = boost::filesystem; -using Slic3r::_3DScene; -using Slic3r::Preset; -using Slic3r::GUI::format_wxstr; using namespace nlohmann; static const std::pair THUMBNAIL_SIZE_3MF = { 512, 512 }; @@ -363,7 +359,7 @@ wxDEFINE_EVENT(EVT_NOTICE_FULL_SCREEN_CHANGED, IntEvent); #define PRINTER_PANEL_RADIUS (6) // ORCA #define BTN_SYNC_SIZE (wxSize(FromDIP(96), FromDIP(98))) -static string get_diameter_string(float diameter) +static std::string get_diameter_string(float diameter) { std::ostringstream stream; // ORCA ensure 0.25 returned as 0.25. previous code returned as 0.2 because of std::setprecision(1) stream << std::fixed << std::setprecision(2) << diameter; // Use 2 decimals to capture 0.25 / 0.15 reliably @@ -6329,7 +6325,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn) } // BBS:Record consumables information before synchronization - std::vector color_before_sync; + std::vector color_before_sync; std::vector is_support_before; DynamicPrintConfig& project_config = wxGetApp().preset_bundle->project_config; ConfigOptionStrings* color_opt = project_config.option("filament_colour"); @@ -8118,13 +8114,13 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_COLLAPSE_SIDEBAR, [this](SimpleEvent&) { this->q->collapse_sidebar(!this->q->is_sidebar_collapsed()); }); preview->get_wxglcanvas()->Bind(EVT_CUSTOMEVT_TICKSCHANGED, [this](wxCommandEvent& event) { - Type tick_event_type = (Type)event.GetInt(); + CustomGCode::Type tick_event_type = (CustomGCode::Type)event.GetInt(); Model& model = wxGetApp().plater()->model(); //BBS: replace model custom gcode with current plate custom gcode model.plates_custom_gcodes[model.curr_plate_index] = preview->get_canvas3d()->get_gcode_viewer().get_layers_slider()->GetTicksValues(); // BBS set to invalid state only - if (tick_event_type == Type::ToolChange || tick_event_type == Type::Custom || tick_event_type == Type::Template || tick_event_type == Type::PausePrint) { + if (tick_event_type == CustomGCode::Type::ToolChange || tick_event_type == CustomGCode::Type::Custom || tick_event_type == CustomGCode::Type::Template || tick_event_type == CustomGCode::Type::PausePrint) { PartPlate *plate = this->q->get_partplate_list().get_curr_plate(); if (plate) { plate->update_slice_result_valid_state(false); @@ -12787,7 +12783,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt) Vec3d old_plate_pos = old_plate->get_center_origin(); // BBS: Save the model in the current platelist - std::vector > plate_object; + std::vector > plate_object; for (size_t i = 0; i < old_plate_list.get_plate_count(); ++i) { PartPlate* plate = old_plate_list.get_plate(i); std::vector obj_idxs; @@ -18387,7 +18383,7 @@ bool Plater::load_files(const wxArrayString& filenames) // Orca: Iters through given paths and imports files from zip then remove zip from paths // returns true if zip files were found - auto handle_zips = [this](vector& paths) { // NOLINT(*-no-recursion) - Recursion is intended and should be managed properly + auto handle_zips = [this](std::vector& paths) { // NOLINT(*-no-recursion) - Recursion is intended and should be managed properly bool res = false; for (auto it = paths.begin(); it != paths.end();) { if (boost::algorithm::iends_with(it->string(), ".zip")) { @@ -20952,7 +20948,7 @@ void Plater::on_filaments_delete(size_t num_filaments, size_t filament_id, int r // update customize gcode for (auto item = p->model.plates_custom_gcodes.begin(); item != p->model.plates_custom_gcodes.end(); ++item) { - auto iter = std::remove_if(item->second.gcodes.begin(), item->second.gcodes.end(), [filament_id](const Item& gcode_item) { + auto iter = std::remove_if(item->second.gcodes.begin(), item->second.gcodes.end(), [filament_id](const CustomGCode::Item& gcode_item) { return (gcode_item.type == CustomGCode::Type::ToolChange && gcode_item.extruder == filament_id + 1); }); if (replace_filament_id == -1) diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 735b02f58b..27e101745e 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -378,7 +378,7 @@ wxBoxSizer *PreferencesDialog::create_item_combobox(wxString title, wxString too auto current_setting = app_config->get(param); if (!current_setting.empty()) { - auto compare = [current_setting](string possible_setting) { return current_setting == possible_setting; }; + auto compare = [current_setting](std::string possible_setting) { return current_setting == possible_setting; }; auto iterator = find_if(config_name_index.begin(), config_name_index.end(), compare); if (iterator != config_name_index.end()) current_index = static_cast(iterator - config_name_index.begin()); @@ -1714,7 +1714,7 @@ void PreferencesDialog::create_items() g_sizer->Add(create_item_title(_L("Project")), 1, wxEXPAND); std::vector projectLoadSettingsBehaviourOptions = {_L("Load All"), _L("Ask When Relevant"), _L("Always Ask"), _L("Load Geometry Only")}; - std::vector projectLoadSettingsConfigOptions = { OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_ALL, OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT, OPTION_PROJECT_LOAD_BEHAVIOUR_ALWAYS_ASK, OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_GEOMETRY }; + std::vector projectLoadSettingsConfigOptions = { OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_ALL, OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT, OPTION_PROJECT_LOAD_BEHAVIOUR_ALWAYS_ASK, OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_GEOMETRY }; auto item_project_load = create_item_combobox(_L("Load behavior"), _L("Should printer/filament/process settings be loaded when opening a 3MF file?"), SETTING_PROJECT_LOAD_BEHAVIOUR, projectLoadSettingsBehaviourOptions, projectLoadSettingsConfigOptions); g_sizer->Add(item_project_load); diff --git a/src/slic3r/GUI/PresetBundleDialog.cpp b/src/slic3r/GUI/PresetBundleDialog.cpp index 9c11fc67aa..c067d99c28 100644 --- a/src/slic3r/GUI/PresetBundleDialog.cpp +++ b/src/slic3r/GUI/PresetBundleDialog.cpp @@ -16,7 +16,7 @@ #include #include #include "slic3r/GUI/GUI.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -32,6 +32,9 @@ #include #include #include + +using json = nlohmann::json; + namespace Slic3r { namespace GUI { PresetBundleDialog::PresetBundleDialog( diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 29e34d98a0..9611e7ec5c 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -81,8 +81,6 @@ #include #endif -using Slic3r::GUI::format_wxstr; - namespace Slic3r { namespace GUI { @@ -2177,7 +2175,7 @@ void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt) wxPostEvent(m_parent, e); } -void PlaterPresetComboBox::sys_color_changed() +void GUI::PlaterPresetComboBox::sys_color_changed() { PresetComboBox::sys_color_changed(); if (clr_picker) { diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index ee7d14552c..2e8047cf72 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -1752,8 +1752,8 @@ void ElegooPrintHostSendDialog::init() { } { - auto radioBoxA = new ::RadioBox(this); - auto radioBoxB = new ::RadioBox(this); + auto radioBoxA = new RadioBox(this); + auto radioBoxB = new RadioBox(this); if (m_BedType == BedType::btPC) radioBoxB->SetValue(true); else diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp index a74780660c..9ae746c6e0 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp @@ -58,6 +58,8 @@ //#define PRINTER_FILE_SYSTEM_TEST #endif +using json = nlohmann::json; + std::string last_system_error() { return Slic3r::decode_path(std::error_code( #ifdef _WIN32 diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.h b/src/slic3r/GUI/Printer/PrinterFileSystem.h index 2748e0ae0c..337fa6931d 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.h +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.h @@ -22,7 +22,6 @@ #include #include "nlohmann/json_fwd.hpp" -using nlohmann::json; #include #include @@ -290,17 +289,17 @@ private: static void DumpLog(void* context, int level, tchar const *msg); private: - template using Translator = std::function; + template using Translator = std::function; - typedef std::function callback_t; + typedef std::function callback_t; - typedef std::function callback_t2; + typedef std::function callback_t2; typedef std::function callback_t3; - template boost::uint32_t SendRequest(int type, json const &req, Translator const &translator, Callback const &callback, const std::string ¶m = "") + template boost::uint32_t SendRequest(int type, nlohmann::json const &req, Translator const &translator, Callback const &callback, const std::string ¶m = "") { - auto c = [translator, callback, this](int result, json const &resp, unsigned char const *data) -> int + auto c = [translator, callback, this](int result, nlohmann::json const &resp, unsigned char const *data) -> int { T t; if (result == 0 || result == CONTINUE || result == FILE_EXIST) { @@ -323,7 +322,7 @@ private: template void InstallNotify(int type, Translator const& translator, Applier const& applier) { - auto c = [translator, applier, this](int result, json const &resp, unsigned char const *data) -> int + auto c = [translator, applier, this](int result, nlohmann::json const &resp, unsigned char const *data) -> int { T t; if (result == 0 || result == CONTINUE) { @@ -345,7 +344,7 @@ private: InstallNotify(type, c); } - boost::uint32_t SendRequest(int type, json const &req, callback_t2 const &callback, const std::string ¶m = ""); + boost::uint32_t SendRequest(int type, nlohmann::json const &req, callback_t2 const &callback, const std::string ¶m = ""); void InstallNotify(int type, callback_t2 const &callback); diff --git a/src/slic3r/GUI/PrinterCloudAuthDialog.cpp b/src/slic3r/GUI/PrinterCloudAuthDialog.cpp index 3b1b15ea6b..4bb9824f99 100644 --- a/src/slic3r/GUI/PrinterCloudAuthDialog.cpp +++ b/src/slic3r/GUI/PrinterCloudAuthDialog.cpp @@ -6,7 +6,6 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" #include "slic3r/GUI/GUI.hpp" #include #include @@ -30,6 +29,9 @@ #include #include + +using json = nlohmann::json; + //------------------------------------------ // PrinterCloundAuthDialog //------------------------------------------ diff --git a/src/slic3r/GUI/ProgressStatusBar.hpp b/src/slic3r/GUI/ProgressStatusBar.hpp index e29883c63e..79343d51df 100644 --- a/src/slic3r/GUI/ProgressStatusBar.hpp +++ b/src/slic3r/GUI/ProgressStatusBar.hpp @@ -68,10 +68,6 @@ private: CancelFn m_cancel_cb; }; -namespace GUI { - using Slic3r::ProgressStatusBar; -} - } #endif // PROGRESSSTATUSBAR_HPP diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index 2ce0da582c..0680878999 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -16,7 +16,7 @@ #include #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/Auxiliary.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -54,7 +54,8 @@ #include #include "slic3r/GUI/Jobs/SendJob.hpp" #include "slic3r/GUI/Plater.hpp" -#include "slic3r/Utils/json_diff.hpp" + +using json = nlohmann::json; class wxWindow; @@ -238,7 +239,7 @@ void ProjectPanel::on_reload(wxCommandEvent& evt) } bool has_content = false; - for (const string& v : { + for (const std::string& v : { update_type, license, model_name, diff --git a/src/slic3r/GUI/Project.hpp b/src/slic3r/GUI/Project.hpp index 13d234a697..3a8460e42b 100644 --- a/src/slic3r/GUI/Project.hpp +++ b/src/slic3r/GUI/Project.hpp @@ -30,7 +30,6 @@ #include #include "nlohmann/json.hpp" -#include "slic3r/Utils/json_diff.hpp" #include #include @@ -109,7 +108,7 @@ public: void OnScriptMessage(wxWebViewEvent& evt); void RunScript(std::string content); - std::map> Reload(wxString aux_path); + std::map> Reload(wxString aux_path); std::string formatBytes(unsigned long bytes); wxString to_base64(std::string path); }; diff --git a/src/slic3r/GUI/PublishSettingsDialog.cpp b/src/slic3r/GUI/PublishSettingsDialog.cpp index 8d192cfcf0..7beb3bd9dd 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.cpp +++ b/src/slic3r/GUI/PublishSettingsDialog.cpp @@ -14,6 +14,7 @@ #include "Widgets/DialogButtons.hpp" #include "Widgets/StaticLine.hpp" #include "Widgets/StateColor.hpp" +#include "Widgets/SwitchButton.hpp" #include "libslic3r/PrintConfig.hpp" #include "libslic3r/Preset.hpp" @@ -864,34 +865,25 @@ void PublishSettingsDialog::build_option_model() }; // --- Phase 1: printer per-extruder retraction settings (first, mirroring the sidebar's - // Printer group), from the printer tab's "Extruder"/"Extruder N" pages. One inner tab per - // extruder (e.g. "Left Extruder"/"Right Extruder" via Tab::translate_category), each holding - // that extruder's Retraction and Z-Hop rows with per-extruder "#N" values. + // Printer group), from the printer tab's "Extruder" page. One inner tab per extruder (named + // as on the printer tab's switch, e.g. "Left Extruder"/"Right Extruder" via + // Tab::translate_category), each holding that extruder's Retraction and Z-Hop rows with + // per-extruder "#N" values. { size_t g = section_group_for(Section::Printer); std::set printer_added; for (Tab* tab : wxGetApp().tabs_list) { - if (tab->m_type != Preset::TYPE_PRINTER) + // The page's controls edit the extruder chosen on the printer tab's switch, so its + // option list is read once per extruder. + auto* printer_tab = dynamic_cast(tab); + const Page* page = printer_tab ? printer_tab->extruder_page() : nullptr; + if (page == nullptr) continue; - for (const PageShp& page : tab->m_pages) { - if (!page->title().StartsWith("Extruder")) - continue; - // The extruder index of this page: its options are appended with the same - // "#N" opt_index (opt.second.second), so derive the tab's index from the first - // allowlisted option; skip the page when none is found (defensive). - int extruder_idx = -1; - for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { - if (optgroup->title != "Retraction" && optgroup->title != "Z-Hop") - continue; - for (const auto& opt : optgroup->opt_map()) - if (extruder_idx < 0) - extruder_idx = opt.second.second; - if (extruder_idx >= 0) - break; - } - if (extruder_idx < 0) - continue; - const wxString page_title = Tab::translate_category(page->title(), tab->m_type); + const size_t extruders_count = printer_tab->m_extruders_count; + for (size_t extruder_idx = 0; extruder_idx < extruders_count; ++extruder_idx) { + const wxString page_title = Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type); + // Retraction and Z-Hop values are stored per variant column, not per extruder. + const int variant_index = printer_tab->extruder_variant_index(int(extruder_idx)); for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { // Allowlist on the untranslated optgroup title; the "Retraction when // switching material" group is intentionally skipped. @@ -899,17 +891,17 @@ void PublishSettingsDialog::build_option_model() continue; const wxString subcategory = _(optgroup->title); for (const auto& opt : optgroup->opt_map()) { - const std::string& opt_id = opt.first; const std::string& pure_key = opt.second.first; // Rows are keyed by the full per-extruder "#N" opt_id so each extruder // tab publishes its own value; GetPublishedKeys() emits the checked rows // as-is. + const std::string opt_id = pure_key + "#" + std::to_string(variant_index); if (!printer_added.insert(opt_id).second) continue; wxString label, value, unit; if (!option_text(opt_id, pure_key, label, value, unit)) continue; - size_t cat_index = category_index_for(page_title, Section::Printer, g, size_t(extruder_idx)); + size_t cat_index = category_index_for(page_title, Section::Printer, g, extruder_idx); size_t sub_index = subcategory_index_for(cat_index, subcategory, optgroup->icon); add_row_ui(opt_id, label, value, unit, cat_index, sub_index); } @@ -1098,6 +1090,10 @@ void PublishSettingsDialog::build_option_model() for (SectionGroup& section : m_sections) if (!section.categories.empty()) section.tabs->SelectItem(0); + // Orca: the Printer section shows its extruders on the same switch as the printer tab's Extruder page. + for (size_t s = 0; s < m_sections.size(); ++s) + if (m_sections[s].kind == Section::Printer && m_sections[s].categories.size() > 1) + setup_variant_switch(s); if (!m_sections.empty()) { m_outer_tabs->SelectItem(0); show_outer_page(0); @@ -1630,6 +1626,8 @@ void PublishSettingsDialog::show_inner_page(size_t section_index, int inner_inde section.selected_mixed = -1; } section.selected_inner = inner_index; + if (section.variant_switch != nullptr) + section.variant_switch->SetSelection(inner_index); // fires its event, which ignores the shown page Category& category = m_categories[section.categories[inner_index]]; category.page->Show(); category.scroll->FitInside(); @@ -1639,6 +1637,32 @@ void PublishSettingsDialog::show_inner_page(size_t section_index, int inner_inde section.page_host_sizer->Layout(); } +void PublishSettingsDialog::setup_variant_switch(size_t section_index) +{ + SectionGroup& section = m_sections[section_index]; + std::vector titles; + for (size_t category : section.categories) + titles.push_back(m_categories[category].title); + + section.variant_switch = new MultiSwitchButton(section.page); + section.variant_switch->SetFitToOptions(); + section.variant_switch->SetOptions(titles); + section.variant_switch->SetSelection(section.selected_inner); + section.variant_switch->Bind(wxCUSTOMEVT_MULTISWITCH_SELECTION, [this, section_index](wxCommandEvent& evt) { + evt.Skip(); + // The hidden tab strip stays the selection model; its event shows the page. + SectionGroup& sec = m_sections[section_index]; + if (evt.GetInt() != sec.selected_inner) + sec.tabs->SelectItem(evt.GetInt()); + }); + + // The switch takes the place of the tab strip, centered like on the printer tab. + wxSizer* page_sizer = section.page->GetSizer(); + page_sizer->Insert(1, section.variant_switch, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(4)); + section.tabs->Hide(); + section.page->Layout(); +} + void PublishSettingsDialog::show_mixed_page(size_t section_index, int mixed_index) { if (section_index >= m_sections.size()) @@ -2184,6 +2208,13 @@ void PublishSettingsDialog::refresh_tab_indicators() for (size_t i = 0; i < section.categories.size(); ++i) { const bool on = category_has_selection(m_categories[section.categories[i]]); section.tabs->SetItemIndicator(static_cast(i), on); + // The switch has no indicator dot; mark its option text instead. + if (section.variant_switch != nullptr) { + const wxString& title = m_categories[section.categories[i]].title; + const wxString text = on ? title + wxString(" ") + wxString(wxUniChar(0x2022)) : title; + if (section.variant_switch->GetOptionText(static_cast(i)) != text) + section.variant_switch->SetOptionText(static_cast(i), text); + } any = any || on; } if (section.mixed_tabs != nullptr) @@ -2248,6 +2279,8 @@ void PublishSettingsDialog::on_dpi_changed(const wxRect& suggested_rect) section.tabs->Rescale(); if (section.mixed_tabs != nullptr) section.mixed_tabs->Rescale(); + if (section.variant_switch != nullptr) + section.variant_switch->Rescale(); } // Refresh the per-row Color chips at the new DPI (they carry the slot number too). diff --git a/src/slic3r/GUI/PublishSettingsDialog.hpp b/src/slic3r/GUI/PublishSettingsDialog.hpp index b7f537b4a5..5e3ef48617 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.hpp +++ b/src/slic3r/GUI/PublishSettingsDialog.hpp @@ -37,6 +37,7 @@ namespace Slic3r { class DynamicPrintConfig; } class TextInput; class StaticLine; class CheckBox; +class MultiSwitchButton; namespace Slic3r { namespace GUI { @@ -195,6 +196,10 @@ private: ScalableBitmap icon_bmp; // tab icon next to the title; rescaled on DPI change wxPanel* page{nullptr}; TabCtrl* tabs{nullptr}; + // Printer section with several extruders: the extruder switch shown instead of `tabs`, the + // same MultiSwitchButton (and option names) as the printer tab's Extruder page. One option + // per entry of `categories`, named by its title; `tabs` stays as the hidden selection model. + MultiSwitchButton* variant_switch{nullptr}; // Second tab strip, below the main one, listing only the mixed-color filament slots. // Present on the Material section only (null elsewhere). TabCtrl* mixed_tabs{nullptr}; @@ -277,6 +282,8 @@ private: bool row_is_visible(const Row& row) const; void apply_visibility(); void bind_tab_events(); + // Replaces a section's inner tab strip with a variant switch (see SectionGroup::variant_switch). + void setup_variant_switch(size_t section_index); TabCtrl* m_outer_tabs{nullptr}; wxPanel* m_outer_host{nullptr}; diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 67dc80ca6d..b200473e08 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -74,9 +74,9 @@ #include "slic3r/Utils/NetworkAgent.hpp" #include -namespace Slic3r::GUI { class Plater; } +using json = nlohmann::json; -namespace fs = boost::filesystem; +namespace Slic3r::GUI { class Plater; } namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/SavePresetDialog.cpp b/src/slic3r/GUI/SavePresetDialog.cpp index 1d4c2913db..1cae6420ed 100644 --- a/src/slic3r/GUI/SavePresetDialog.cpp +++ b/src/slic3r/GUI/SavePresetDialog.cpp @@ -42,8 +42,6 @@ #include "Widgets/DialogButtons.hpp" -using Slic3r::GUI::format_wxstr; - namespace Slic3r { namespace GUI { #define BORDER_W 10 diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index dcf0573321..597f809adc 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -1,6 +1,5 @@ #include "Search.hpp" -#include #include "slic3r/GUI/GUI.hpp" #include "libslic3r/Preset.hpp" #include "libslic3r/Config.hpp" @@ -22,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -56,8 +54,6 @@ #include "LinuxDisplayBackend.hpp" #endif -using boost::optional; - namespace Slic3r { wxDEFINE_EVENT(wxCUSTOMEVT_JUMP_TO_OPTION, wxCommandEvent); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 5d51e5429f..a885dcd058 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -62,7 +62,7 @@ #include #include #include "libslic3r/Config.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -133,6 +133,8 @@ #include "slic3r/Utils/NetworkAgent.hpp" #include +using json = nlohmann::json; + namespace Slic3r { class PrintBase; } namespace fs = boost::filesystem; @@ -180,7 +182,7 @@ std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_t static int s_nozzle_mapping_last_request_time = 0; std::vector SelectMachineDialog::MACHINE_BED_TYPE_STRING; -std::vector SelectMachineDialog::MachineBedTypeString; +std::vector SelectMachineDialog::MachineBedTypeString; void SelectMachineDialog::init_machine_bed_types() { if (MACHINE_BED_TYPE_STRING.size() == 0) { @@ -2746,8 +2748,8 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) std::vector confirm_text; // check more than one using in same external spool - std::unordered_set main_external_spool_filas; - std::unordered_set deputy_external_spool_filas; + std::unordered_set main_external_spool_filas; + std::unordered_set deputy_external_spool_filas; for (const auto& mapping_info : m_ams_mapping_result) { if (mapping_info.ams_id == VIRTUAL_AMS_MAIN_ID_STR){ main_external_spool_filas.insert(mapping_info.filament_id); @@ -5237,7 +5239,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_) /*Check high temperture slicing*/ if (m_print_type == PrintFromType::FROM_NORMAL) { - std::set high_temp_filaments; + std::set high_temp_filaments; std::unordered_set known_fila_soften_extruders; std::unordered_set unknown_fila_soften_extruders; auto preset_full_config = wxGetApp().preset_bundle->full_config(); diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index a0515dd20c..31ce752a2e 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -337,7 +337,7 @@ private: wxColour m_colour_bold_color{wxColour(38, 46, 48)}; StateColor m_btn_bg_enable; - std::unordered_map m_checkbox_list; + std::unordered_map m_checkbox_list; std::list m_checkbox_list_order; std::shared_ptr m_token = std::make_shared(0); diff --git a/src/slic3r/GUI/SendMultiMachinePage.cpp b/src/slic3r/GUI/SendMultiMachinePage.cpp index c66a0f6055..acf4fe11b5 100644 --- a/src/slic3r/GUI/SendMultiMachinePage.cpp +++ b/src/slic3r/GUI/SendMultiMachinePage.cpp @@ -26,7 +26,7 @@ #include "slic3r/GUI/DeviceCore/DevDefs.h" #include "slic3r/GUI/PartPlate.hpp" #include "libslic3r/PrintConfig.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "slic3r/GUI/MsgDialog.hpp" #include "slic3r/GUI/Widgets/Label.hpp" #include "slic3r/GUI/Widgets/TextInput.hpp" @@ -77,6 +77,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index 370baf29d1..7e98fbe85e 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -126,7 +126,7 @@ void SendToPrinterDialog::stripWhiteSpace(std::string& str) { if (str == "") { return; } - string::iterator cur_it; + std::string::iterator cur_it; cur_it = str.begin(); while (cur_it != str.end()) { diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index 4a17aff571..cd297eefe8 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -23,7 +23,7 @@ #include #include "slic3r/GUI/wxMediaCtrl3.h" #include "slic3r/GUI/Widgets/StaticBox.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include "libslic3r/calib.hpp" @@ -171,7 +171,7 @@ public: std::string current_nozzle_loc = ""; wxColour m_colour; - string m_file_name; + std::string m_file_name; bool m_ams_loading{false}; void doRender(wxDC &dc); ExtruderImage(wxWindow *parent, wxWindowID id, int nozzle_num, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize); @@ -244,7 +244,7 @@ protected: { wxString local_image_url; //local image path std::string img_url_paths; // oss url path - vector image_broad; + std::vector image_broad; bool is_selected; bool is_uploaded; // load wxBoxSizer * image_tb_broad = nullptr; @@ -689,7 +689,7 @@ protected: int m_last_vcamera = -1; int m_model_mall_request_count = 0; bool m_is_load_with_temp = false; - json m_rating_result; + nlohmann::json m_rating_result; wxWebRequest web_request; bool bed_temp_input = false; diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index f4c59088bd..d6049451b9 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -15,7 +15,7 @@ #include "libslic3r/Utils.hpp" #include #include "slic3r/GUI/BBLStatusBarPrint.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include "libslic3r/PrintConfig.hpp" #include @@ -85,9 +85,7 @@ #include "slic3r/Utils/NetworkAgent.hpp" namespace fs = boost::filesystem; - -using namespace Slic3r; -using namespace Slic3r::GUI; +using json = nlohmann::json; #define OK_BUTTON_SIZE wxSize(FromDIP(90), FromDIP(24)) #define CANCEL_BUTTON_SIZE wxSize(FromDIP(58), FromDIP(24)) @@ -1578,7 +1576,7 @@ bool SyncAmsInfoDialog::is_nozzle_type_match(DevExtderSystem data, wxString &err } } - vector map_extruders = {1, 0}; + std::vector map_extruders = {1, 0}; // The default two extruders are left, right, but the order of the extruders on the machine is right, left. std::vector flow_type_of_machine; @@ -1678,7 +1676,7 @@ void SyncAmsInfoDialog::stripWhiteSpace(std::string &str) { if (str == "") { return; } - string::iterator cur_it; + std::string::iterator cur_it; cur_it = str.begin(); while (cur_it != str.end()) { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e77a09c940..bd19a62024 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -812,6 +812,12 @@ wxString Tab::translate_category(const wxString& title, Preset::Type preset_type } return _("Extruder") + title.SubString(8, title.Last()); } + // Orca: one "Extruder" page serves all extruders; name it "Extruders" when there are several. + if (preset_type == Preset::TYPE_PRINTER && title == "Extruder") { + auto preset = wxGetApp().preset_bundle; + if (preset && preset->get_printer_extruder_count() > 1) + return _("Extruders"); + } return _(title); } @@ -1154,6 +1160,38 @@ std::string Tab::options_list_storage_key(const std::string& opt_key) const return (serialized || is_plugin_field) ? opt_key : opt_key + "#0"; } +// Orca: deep_diff() flags every vector entry at or past the reference vector's length as changed, +// whatever its value (e.g. the values of an extruder added by raising the extruder count). A vector +// grows by copying its first entry (ConfigOptionVector::resize), so such an entry only counts as +// changed when it differs from the reference's first entry, as before Orca's deep_diff() change. +// The change of the count itself shows on "extruders_count". +static void drop_unchanged_added_entries(std::vector &options, const DynamicPrintConfig ¤t, const Preset *reference) +{ + if (reference == nullptr) + return; + // deep_diff() lists a key's entries one after another, so serialize each key's vectors once. + std::string serialized_key; + std::vector cur_values; + std::string ref_first; + options.erase(std::remove_if(options.begin(), options.end(), [&](const std::string &opt) { + const auto pos = opt.find('#'); + if (pos == std::string::npos) + return false; + const std::string key = opt.substr(0, pos); + const size_t idx = size_t(std::atoi(opt.c_str() + pos + 1)); + auto ref = dynamic_cast(reference->config.option(key)); + auto cur = dynamic_cast(current.option(key)); + if (ref == nullptr || cur == nullptr || idx < ref->size() || ref->size() == 0 || idx >= cur->size()) + return false; + if (key != serialized_key) { + serialized_key = key; + cur_values = cur->vserialize(); + ref_first = ref->vserialize().front(); + } + return cur_values[idx] == ref_first; + }), options.end()); +} + void Tab::update_all_extruder_options_status() { if (!m_extruder_switch && !m_variant_combo) { @@ -1184,6 +1222,8 @@ void Tab::update_all_extruder_options_status() auto dirty_options = m_presets->current_dirty_options(true); auto nonsys_options = m_presets->current_different_from_parent_options(true); + if (m_type == Preset::TYPE_PRINTER) + update_custom_dirty(dirty_options, nonsys_options); auto filter_extruder_options = [](const std::vector& options) { std::vector filtered_options; for (const auto& opt : options) { @@ -1232,7 +1272,7 @@ void Tab::update_extruder_switch_colors() if (m_active_page) { if (m_active_page->title() == "Speed" || m_active_page->title() == "Motion ability" || m_active_page->title() == "Filament" || - m_active_page->title() == "Setting Overrides" || m_active_page->title() == "Multimaterial") { + m_active_page->title() == "Setting Overrides" || m_active_page->title() == "Multimaterial" || is_printer_extruder_page(m_active_page)) { for (auto page_ptr : m_pages) { if (page_ptr.get() == m_active_page) { pages_to_check.push_back(page_ptr); @@ -1263,8 +1303,8 @@ void Tab::update_extruder_switch_colors() void Tab::check_extruder_options_status(int index, bool &sys_extruder, bool &modified_extruder, const std::vector& pages_to_check) { int config_index = index; + int extruder_id = index; if (m_type == Preset::TYPE_PRINT || m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_MODEL) { - int extruder_id; NozzleVolumeType nozzle_type; parse_extruder_selection(index, extruder_id, nozzle_type); @@ -1297,6 +1337,10 @@ void Tab::check_extruder_options_status(int index, bool &sys_extruder, bool &mod } std::string target_opt_key = base_opt_key + "#" + std::to_string(config_index * stride); + // Orca: on the printer's Extruder page only per-variant options use the variant column, + // the others (nozzle_diameter, extruder_offset, ...) are indexed by the extruder. + if (is_printer_extruder_page(page.get()) && printer_options_with_variant_1.count(base_opt_key) == 0) + target_opt_key = base_opt_key + "#" + std::to_string(extruder_id); auto status_iter = m_all_extruder_options_status.find(target_opt_key); if (status_iter != m_all_extruder_options_status.end()) { @@ -1337,18 +1381,6 @@ void TabPrinter::init_options_list() Tab::init_options_list(); if (m_printer_technology == ptFFF) m_options_list.emplace("extruders_count", m_opt_status_value); - for (size_t i = 1; i < m_extruders_count; ++i) { - wxString target_title = wxString::Format("Extruder %d", int(i + 1)); - for (auto &page : m_pages) { - if (page->title() == target_title) { - for (auto group : page->m_optgroups) { - for (auto &opt : group->opt_map()) - m_options_list.emplace(opt.first, m_opt_status_value); - } - break; - } - } - } } void TabPrinter::msw_rescale() @@ -1438,7 +1470,7 @@ void Tab::update_changed_tree_ui() get_sys_and_mod_flags("compatible_printers", sys_page, modified_page); } } - if (page->title() == "Speed" || page->title() == "Motion ability" || page->title() == "Filament" || page->title() == "Setting Overrides" || page->title() == "Multimaterial") { + if (page->title() == "Speed" || page->title() == "Motion ability" || page->title() == "Filament" || page->title() == "Setting Overrides" || page->title() == "Multimaterial" || is_printer_extruder_page(page.get())) { auto options = generate_extruder_options(); for (size_t switch_index = 0; switch_index < options.size(); ++switch_index) { std::vector pages_to_check = { page }; @@ -1541,6 +1573,10 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/) m_postpone_update_ui = false; + // Orca: the restored config may have another extruder count than the tab shows. + if (auto printer_tab = dynamic_cast(this)) + printer_tab->sync_extruders_count(); + // When all values are rolled, then we have to update whole tab in respect to the reverted values update(); if (m_active_page) @@ -1885,6 +1921,17 @@ static wxString pad_combo_value_for_config(const DynamicPrintConfig &config) return config.opt_bool("pad_enable") ? (config.opt_bool("pad_around_object") ? _("Around object") : _("Below object")) : _("None"); } +// Rebuilds the variant switch of every tab that has one, e.g. after the extruder count or a nozzle volume type changed. +static void update_all_extruder_variants(int extruder_idx = -1) +{ + for (auto tab : wxGetApp().tabs_list) + tab->update_extruder_variants(extruder_idx); + if (auto tab = wxGetApp().plate_tab) + tab->update_extruder_variants(extruder_idx); + for (auto tab : wxGetApp().model_tabs_list) + tab->update_extruder_variants(extruder_idx); +} + void Tab::on_value_change(const std::string& opt_key, const boost::any& value) { // Orca: @@ -2265,7 +2312,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) wxGetApp().plater()->update(); } - string opt_key_without_idx = opt_key.substr(0, opt_key.find('#')); + std::string opt_key_without_idx = opt_key.substr(0, opt_key.find('#')); if (opt_key_without_idx == "long_retractions_when_cut") { unsigned char activate = boost::any_cast(value); @@ -2327,15 +2374,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) if (opt_key.find("nozzle_volume_type") != std::string::npos) { int extruder_idx = std::atoi(opt_key.substr(opt_key.find_last_of('#') + 1).c_str()); - for (auto tab : wxGetApp().tabs_list) { - tab->update_extruder_variants(extruder_idx); - } - if (auto tab = wxGetApp().plate_tab) { - tab->update_extruder_variants(extruder_idx); - } - for (auto tab : wxGetApp().model_tabs_list) { - tab->update_extruder_variants(extruder_idx); - } + update_all_extruder_variants(extruder_idx); if (wxGetApp().app_config->get("auto_calculate_flush") == "all") { wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(-1,extruder_idx); } @@ -5763,9 +5802,13 @@ if (is_marlin_flavor) size_t extruders_count = size_t(boost::any_cast(v)); wxTheApp->CallAfter([this, opt_key, value, extruders_count]() { if (opt_key == "extruders_count" || opt_key == "single_extruder_multi_material") { + const size_t old_extruders_count = m_extruders_count; extruders_count_changed(extruders_count); init_options_list(); // m_options_list should be updated before UI updating update_dirty(); + // Orca: the variant switches (here, Process in the sidebar, ...) list one option per extruder. + if (m_extruders_count != old_extruders_count) + update_all_extruder_variants(); if (opt_key == "single_extruder_multi_material") { // the single_extruder_multimaterial was added to force pages on_value_change(opt_key, value); // rebuild - let's make sure the on_value_change is not skipped @@ -5775,6 +5818,7 @@ if (is_marlin_flavor) // Orca: we use a different logic here. If SEMM is enabled, we set extruder count to 1. #if 1 extruders_count_changed(1); + update_all_extruder_variants(); #else std::vector nozzle_diameters = @@ -5852,14 +5896,13 @@ if (is_marlin_flavor) m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); } - // Orca: build missed extruder pages - for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx) { - const wxString& page_name = (m_extruders_count > 1) ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString::Format("Extruder"); - - //# build page - //const wxString& page_name = wxString::Format("Extruder %d", int(extruder_idx + 1)); - auto page = add_options_page(page_name, "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders - m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page); + // Orca: a single "Extruder" page serves all extruders. Its controls are created once for extruder 0; + // switch_excluder() re-targets them to the extruder selected on the variant switch (m_extruder_switch), + // which the printer tab shows on this page too. + if (extruder_page() == nullptr && m_extruders_count > 0) { + const size_t extruder_idx = 0; + auto page = add_options_page(L("Extruder"), "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders + m_pages.insert(m_pages.begin() + n_before_extruders, page); auto optgroup = page->new_optgroup(L("Basic information"), L"param_information", -1, true); optgroup->append_single_option_line("nozzle_diameter", "printer_extruder_basic_information#nozzle-diameter", extruder_idx); @@ -5872,8 +5915,10 @@ if (is_marlin_flavor) option.opt.full_width = true; optgroup->append_single_option_line(option, "printer_extruder_basic_information#extruder-offset-position"); - optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value) + optgroup->m_on_change = [this](const t_config_option_key& opt_key, boost::any value) { + // The page edits the extruder selected on the variant switch. + const size_t extruder_idx = size_t(get_current_active_extruder()); bool is_SEMM = m_config->opt_bool("single_extruder_multi_material"); if (is_SEMM && m_extruders_count > 1 && boost::starts_with(opt_key, "nozzle_diameter")) { @@ -5968,22 +6013,22 @@ if (is_marlin_flavor) //optgroup->append_line(line); #endif } - // BBS. No extra extruder page for single physical extruder machine - // # remove extra pages - auto &first_extruder_title = const_cast(m_pages[n_before_extruders]->title()); - if (m_extruders_count < m_extruders_count_old) { - m_pages.erase( m_pages.begin() + n_before_extruders + m_extruders_count, - m_pages.begin() + n_before_extruders + m_extruders_count_old); - if (m_extruders_count == 1) - first_extruder_title = wxString::Format("Extruder"); - } else if (m_extruders_count_old == 1) { - first_extruder_title = wxString::Format("Extruder %d", 1); - } - auto & index = wxGetApp().sidebar().settings_index(); - for (auto &group : m_pages[n_before_extruders]->m_optgroups) { - group->set_config_category_and_type(first_extruder_title, m_type); - for (auto &opt : group->opt_map()) - index.add_key(opt.first + "#0", m_type, group->title, first_extruder_title, group->icon); + + // The page holds only the "#0" controls, so register every extruder's options with the search + // index under "Extruder N"; a search hit selects that extruder (TabPrinter::activate_option()). + if (Page *page = extruder_page()) { + auto &index = wxGetApp().sidebar().settings_index(); + for (auto &group : page->m_optgroups) { + group->set_config_category_and_type(page->title(), m_type); + for (auto &opt : group->opt_map()) { + if (opt.second.second < 0) + continue; + for (size_t i = 0; i < m_extruders_count; ++i) { + const wxString category = m_extruders_count > 1 ? wxString::Format("Extruder %d", int(i + 1)) : wxString("Extruder"); + index.add_key(opt.second.first + "#" + std::to_string(i), m_type, group->title, category, group->icon); + } + } + } } Thaw(); @@ -6276,12 +6321,6 @@ void TabPrinter::toggle_options() return; auto nozzle_volumes = m_preset_bundle->project_config.option("nozzle_volume_type"); - auto extruders = m_config->option("extruder_type"); - auto get_index_for_extruder = - [this, &extruders](int extruder_id, int stride = 1) { - return m_config->get_index_for_extruder(extruder_id + 1, "printer_extruder_id", - ExtruderType(extruders->values[extruder_id]), get_actual_nozzle_volume_type(extruder_id), "printer_extruder_variant", stride); - }; //BBS: whether the preset is Bambu Lab printer bool is_BBL_printer = false; @@ -6391,14 +6430,13 @@ void TabPrinter::toggle_options() toggle_option("tool_change_on_wipe_tower", !bSEMM && supports_wipe_tower_2 && extruders_count > 1); toggle_option("wait_for_temp_on_wipe_tower", !bSEMM && supports_wipe_tower_2 && extruders_count > 1); } - wxString extruder_number; - long val = 1; - if ( m_active_page->title().IsSameAs(L("Extruder")) || - (m_active_page->title().StartsWith("Extruder ", &extruder_number) && extruder_number.ToLong(&val) && - val > 0 && (size_t)val <= m_extruders_count)) + if (m_active_page->title() == L("Extruder") && m_extruders_count > 0) { - size_t i = size_t(val - 1); - int variant_index = get_index_for_extruder(i); + // Orca: the single Extruder page edits the extruder selected on the variant switch; its + // controls carry field index 0 (i), the values are read for `extruder`. + const size_t i = 0; + const size_t extruder = std::min(size_t(get_current_active_extruder()), m_extruders_count - 1); + const int variant_index = extruder_variant_index(int(extruder)); bool have_retract_length = m_config->opt_float("retraction_length", variant_index) > 0; toggle_option("extruder_printable_area", false, i); // disable @@ -6425,7 +6463,7 @@ void TabPrinter::toggle_options() vec.resize(0); vec = {"retract_lift_above", "retract_lift_below", "retract_lift_enforce"}; for (auto el : vec) - toggle_option(el, retraction && (m_config->opt_float("z_hop", i) > 0), i); + toggle_option(el, retraction && (m_config->opt_float("z_hop", variant_index) > 0), i); // some options only apply when not using firmware retraction vec.resize(0); @@ -6478,7 +6516,7 @@ void TabPrinter::toggle_options() toggle_option("long_retractions_when_cut", !use_firmware_retraction && m_config->opt_int("enable_long_retraction_when_cut"), i); toggle_line("retraction_distances_when_cut", m_config->opt_bool("long_retractions_when_cut", variant_index), i); - toggle_option("travel_slope", m_config->opt_enum("z_hop_types", i) != ZHopType::zhtNormal, i); + toggle_option("travel_slope", m_config->opt_enum("z_hop_types", variant_index) != ZHopType::zhtNormal, i); } if (m_active_page->title() == L("Motion ability")) { @@ -6552,12 +6590,16 @@ void TabPrinter::on_value_change(const std::string& opt_key, const boost::any& v return; const int pos = opt_key.find("#"); + // Orca: fields of the single Extruder page keep index 0 but edit the selected extruder. + const int data_idx = pos > 0 ? extruder_page_data_index(opt_key) : -1; if (pos > 0) { std::string temp_str = opt_key; boost::erase_head(temp_str, pos + 1); int orig_opt_idx = static_cast(atoi(temp_str.c_str())); int opt_idx = orig_opt_idx >= 0 ? orig_opt_idx : 0; + if (data_idx >= 0) + opt_idx = data_idx; std::string opt_key_pure = opt_key; boost::erase_tail(opt_key_pure, opt_key_pure.size() - pos); @@ -6592,7 +6634,12 @@ void TabPrinter::on_value_change(const std::string& opt_key, const boost::any& v } } - Tab::on_value_change(opt_key, value); + // Orca: report Extruder page changes as "key#", as the former "Extruder N" pages did, + // so per-extruder handling in Tab::on_value_change() sees the extruder that was edited. + if (data_idx >= 0) + Tab::on_value_change(opt_key.substr(0, pos) + "#" + std::to_string(get_current_active_extruder()), value); + else + Tab::on_value_change(opt_key, value); } void TabPrinter::update() @@ -7558,12 +7605,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event) // update_undo_buttons(); this->OnActivate(); m_parent->set_active_tab(this); - if (m_variant_sizer) { - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; - m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder ")); - if (m_extruder_sync) m_extruder_sync->Show(variant_ctrl->IsShown()); - GetParent()->Layout(); - } + update_variant_sizer_visibility(); m_page_view->Thaw(); return false; @@ -7574,12 +7616,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event) return false; m_active_page = page; - if (m_variant_sizer) { - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; - m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder")); - if (m_extruder_sync) m_extruder_sync->Show(variant_ctrl->IsShown()); - GetParent()->Layout(); - } + update_variant_sizer_visibility(); auto throw_if_canceled = std::function([this](){ #ifdef WIN32 @@ -8405,9 +8442,11 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) m_actual_nozzle_volumes.resize(extruder_nums, NozzleVolumeType::nvtStandard); for (int i = 0; i < extruder_nums; i++) m_actual_nozzle_volumes[i] = (NozzleVolumeType)nozzle_volumes->values[i]; - // Orca: a non-Bambu dual-nozzle printer has two extruders but a single variant column, so - // the nozzle switch and sync button have nothing to act on. Only enable with real variants. - if (extruder_nums >= 2 && m_preset_bundle->support_different_extruders()) { + // Orca: when every extruder uses the same variant (e.g. a non-Bambu dual-nozzle printer), the + // switch has no nozzle variants to select and nothing to sync. The printer tab still enables it + // to choose the extruder its Extruder and Motion ability pages edit. + m_extruder_switch_variants = extruder_nums >= 2 && m_preset_bundle->support_different_extruders(); + if (m_extruder_switch_variants || (m_type == Preset::TYPE_PRINTER && extruder_nums >= 2)) { auto options = generate_extruder_options(); m_extruder_switch->SetOptions(options); @@ -8446,12 +8485,8 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) if (m_type == Preset::TYPE_PRINT) { update_pages_with_multi_variant(); } - if (m_variant_sizer) { - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; - m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && m_active_page && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder ")); - if (m_extruder_sync) m_extruder_sync->Show(variant_ctrl->IsShown()); - GetParent()->Layout(); - } + update_extruder_switch_colors(); + update_variant_sizer_visibility(); } // The variant switch tags are the narrowest place a volume type is named, so they abbreviate it; @@ -8526,12 +8561,21 @@ std::vector Tab::generate_extruder_options() return options; } + // Orca: the printer tab has one tag per extruder, named as its former "Extruder N" pages were. + // parse_extruder_selection() counts a hybrid extruder as two tags; that still lines up because + // only the last extruder can be hybrid. + if (m_type == Preset::TYPE_PRINTER) { + for (int i = 0; i < extruder_nums; ++i) + options.push_back(translate_category(wxString::Format("Extruder %d", i + 1), m_type)); + return options; + } + std::string pt = m_preset_bundle->printers.get_edited_preset().get_printer_type(m_preset_bundle); - // Orca: the main/deputy toolhead names describe a dual-nozzle printer, where extruder 0 is the - // left (deputy) and extruder 1 the right (main) nozzle. From three extruders on the tools are - // interchangeable, so name them by index instead of repeating one side. + // Orca: the main/deputy toolhead names describe a Bambu dual-nozzle printer, where extruder 0 is + // the left (deputy) and extruder 1 the right (main) nozzle. Other printers number their tools. + const bool toolhead_names = extruder_nums == 2 && m_preset_bundle->is_bbl_vendor(); for (int i = 0; i < extruder_nums; ++i) { - wxString extruder_name = extruder_nums > 2 ? wxString::Format("T%d", i + 1) : + wxString extruder_name = !toolhead_names ? wxString::Format("T%d", i + 1) : _L(DevPrinterConfigUtil::get_toolhead_display_name( pt, (i == 0) ? DEPUTY_EXTRUDER_ID : MAIN_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase, true)); @@ -8548,6 +8592,71 @@ std::vector Tab::generate_extruder_options() return options; } +Page *TabPrinter::extruder_page() const +{ + for (const PageShp &page : m_pages) + if (page->title() == "Extruder") + return page.get(); + return nullptr; +} + +int TabPrinter::extruder_page_data_index(const std::string &field_id) const +{ + if (Page *page = extruder_page()) + for (const auto &group : page->m_optgroups) + if (auto it = group->opt_map().find(field_id); it != group->opt_map().end()) + return it->second.second; + return -1; +} + +int TabPrinter::extruder_variant_index(int extruder) +{ + const auto *extruders = m_config->option("extruder_type"); + const int index = extruder < int(extruders->size()) ? + m_config->get_index_for_extruder(extruder + 1, "printer_extruder_id", ExtruderType(extruders->values[extruder]), + get_actual_nozzle_volume_type(extruder), "printer_extruder_variant") : + -1; + return index < 0 ? extruder : index; +} + +void TabPrinter::update_custom_dirty(std::vector &dirty_options, std::vector &nonsys_options) +{ + drop_unchanged_added_entries(dirty_options, *m_config, &m_presets->get_selected_preset()); + drop_unchanged_added_entries(nonsys_options, *m_config, m_presets->get_selected_preset_parent()); +} + +void TabPrinter::sync_extruders_count() +{ + if (m_printer_technology != ptFFF) + return; + const auto *nozzle_diameter = m_config->option("nozzle_diameter"); + if (nozzle_diameter == nullptr || nozzle_diameter->size() == m_extruders_count) + return; + extruders_count_changed(nozzle_diameter->size()); + init_options_list(); + update_all_extruder_variants(); +} + +void TabPrinter::activate_option(const std::string &opt_key, const wxString &category) +{ + wxString number; + long n = 0; + const bool numbered = category.StartsWith("Extruder ", &number) && number.ToLong(&n); + if (extruder_page() == nullptr || (!numbered && category != "Extruder")) { + Tab::activate_option(opt_key, category); + return; + } + + // Selecting fires the switch's event, which re-targets the page (switch_excluder()). + const int extruder_idx = (n >= 1 && n <= long(m_extruders_count)) ? int(n - 1) : 0; + if (m_extruder_switch && m_extruder_switch->IsThisEnabled() && extruder_idx != get_current_active_extruder()) + m_extruder_switch->SetSelection(calculate_selection_index_for_extruder(extruder_idx, get_actual_nozzle_volume_type(extruder_idx))); + + // The page's controls are created for index 0. + const auto pos = opt_key.find('#'); + Tab::activate_option(pos == std::string::npos ? opt_key : opt_key.substr(0, pos) + "#0", "Extruder"); +} + NozzleVolumeType Tab::get_actual_nozzle_volume_type(int extruder_id) { int extruder_count = m_preset_bundle->get_printer_extruder_count(); @@ -8624,18 +8733,44 @@ bool Tab::get_extruder_sync_enable_state(int extruder_id) return false; } +bool Tab::variant_switch_active() const +{ + if (m_extruder_switch) + return m_extruder_switch->IsThisEnabled(); + return m_variant_combo && m_variant_combo->IsThisEnabled(); +} + +void Tab::update_variant_sizer_visibility() +{ + if (!m_variant_sizer) + return; + const bool show = variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty(); + m_main_sizer->Show(m_variant_sizer, show); + if (m_extruder_sync) { + m_extruder_sync->Show(show); + // Orca: copying between extruders is offered only between nozzle variants, and not on the Extruder page. + m_extruder_sync->Enable(m_extruder_switch_variants && !is_printer_extruder_page(m_active_page) && + get_extruder_sync_enable_state(get_current_active_extruder())); + } + GetParent()->Layout(); +} + void Tab::switch_excluder(int extruder_id, bool reload) { Preset & printer_preset = m_preset_bundle->printers.get_edited_preset(); auto nozzle_volumes = m_preset_bundle->project_config.option("nozzle_volume_type"); auto extruders = printer_preset.config.option("extruder_type"); + // Orca: the printer tab re-targets its pages to the extruder selected on the switch. Resolved before + // the range check below, which keeps the extruder_type read in get_index_for_extruder in range. + if (m_type == Preset::TYPE_PRINTER && extruder_id == -1) + extruder_id = get_current_active_extruder(); if (!m_variant_combo && (extruder_id >= (int)nozzle_volumes->size() || extruder_id >= (int)extruders->size())) extruder_id = 0; if (m_extruder_switch) { int current_extruder = get_current_active_extruder(); bool sync_enable = get_extruder_sync_enable_state(current_extruder); - m_extruder_sync->Enable(m_extruder_switch->IsThisEnabled() && sync_enable); + m_extruder_sync->Enable(m_extruder_switch_variants && sync_enable && !is_printer_extruder_page(m_active_page)); m_extruder_sync->Show(); if (m_type != Preset::TYPE_PRINTER) { if (extruder_id == -1) @@ -8662,24 +8797,26 @@ void Tab::switch_excluder(int extruder_id, bool reload) return; if (m_extruder_switch) m_extruder_switch->SetClientData(reinterpret_cast(static_cast(index))); if (m_variant_combo) m_variant_combo->SetClientData(reinterpret_cast(static_cast(index))); - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; for (auto page : m_pages) { bool is_extruder = false; + int page_index = index; if (m_type == Preset::TYPE_PRINTER) { - if (page->title().StartsWith("Extruder")) { - int extruder_id2 = std::atoi(page->title().Mid(9).ToUTF8()) - 1; - if (extruder_id >= 0 && extruder_id2 != extruder_id) - continue; - if (extruder_id2 > 0) - index = get_index_for_extruder(extruder_id2); + if (page->title() == "Extruder") is_extruder = true; - } else if (page->title().StartsWith("Motion ability")) { - index = get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id, 2); - } + else if (page->title().StartsWith("Motion ability")) + page_index = get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id, 2); } page->m_opt_id_map.clear(); for (auto group : page->m_optgroups) { for (auto &opt : group->opt_map()) { + if (is_extruder && opt.second.second >= 0) { + // Per-variant options use the variant column, the others (nozzle_diameter, + // extruder_offset, ...) are sized by the extruder count and use the extruder. + const int idx = printer_options_with_variant_1.count(opt.second.first) > 0 ? page_index : extruder_id; + const_cast(opt.second.second) = idx; + page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(idx), opt.first}); + continue; + } auto iter = std::find(printer_extruder_options.begin(), printer_extruder_options.end(), opt.second.first); if (iter != printer_extruder_options.end()) { page->m_opt_id_map.insert({opt.first, opt.first}); @@ -8687,9 +8824,9 @@ void Tab::switch_excluder(int extruder_id, bool reload) } if (opt.second.second >= 0) { - const_cast(opt.second.second) = index; - page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(index), opt.first}); - group->draw_multi_extruder = !is_extruder && variant_ctrl->IsThisEnabled(); + const_cast(opt.second.second) = page_index; + page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(page_index), opt.first}); + group->draw_multi_extruder = variant_switch_active(); } } } diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 912d6ec4c8..4bcca83f43 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -331,6 +331,10 @@ public: MultiSwitchButton * m_variant_combo = nullptr; ScalableButton *m_extruder_sync = nullptr; wxPanel * m_extruder_sync_box = nullptr; + // Orca: whether m_extruder_switch switches nozzle variants (it then offers sync between them). + // The printer tab also enables the switch for printers without variants, to choose the extruder + // its Extruder and Motion ability pages edit. + bool m_extruder_switch_variants = false; std::vector m_actual_nozzle_volumes; public: @@ -387,6 +391,13 @@ public: void update_changed_tree_ui(); void update_undo_buttons(); void update_extruder_switch_colors(); + // Whether the variant switch (m_extruder_switch / m_variant_combo) is enabled: on the printer tab for + // any multi-extruder printer, on the other tabs when it switches nozzle variants. + bool variant_switch_active() const; + // Orca: whether `page` is the printer tab's single "Extruder" page, which edits the extruder selected on the switch. + bool is_printer_extruder_page(const Page* page) const { return m_type == Preset::TYPE_PRINTER && page && page->title() == "Extruder"; } + // Shows the variant switch row on pages with options that follow it. + void update_variant_sizer_visibility(); void update_all_extruder_options_status(); void check_extruder_options_status(int index, bool &sys_extruder, bool &modified_extruder, const std::vector& pages_to_check); @@ -444,7 +455,7 @@ public: virtual void on_value_change(const std::string& opt_key, const boost::any& value); void update_wiping_button_visibility(); - void activate_option(const std::string& opt_key, const wxString& category); + virtual void activate_option(const std::string& opt_key, const wxString& category); void apply_searcher(); void cache_config_diff(const std::vector& selected_options, const DynamicPrintConfig* config = nullptr); void apply_config_from_cache(); @@ -716,6 +727,25 @@ public: void cache_extruder_cnt(const DynamicPrintConfig* config = nullptr); bool apply_extruder_cnt_from_cache(); void refresh_printer_agent_dropdown() const; + + // Orca: a single "Extruder" page for all extruders. Its controls are created once (index 0) and + // switch_excluder() re-targets them to the extruder selected on m_extruder_switch. + Page* extruder_page() const; + // Config index an "Extruder" page field (e.g. "retraction_length#0") currently edits, -1 if not on that page. + int extruder_page_data_index(const std::string& field_id) const; + // Config index of an extruder's per-variant options (Retraction, Z-Hop, ...): its variant column + // for the nozzle selected on the switch, or the extruder index on a printer without variants. + int extruder_variant_index(int extruder); + // After the config was restored (roll back): follow its extruder count, if it differs. + void sync_extruders_count(); + // Search jump to "Extruder N" / "key#N": selects extruder N on the switch, then activates the + // page's own field on the "Extruder" page. + void activate_option(const std::string& opt_key, const wxString& category) override; + +protected: + // Orca: values of extruders added by raising the extruder count have no saved / system value to + // revert to; the change is shown on "extruders_count", not on each of their parameters. + void update_custom_dirty(std::vector &dirty_options, std::vector &nonsys_options) override; }; class TabSLAMaterial : public Tab diff --git a/src/slic3r/GUI/TaskManager.cpp b/src/slic3r/GUI/TaskManager.cpp index 8170da5a34..712bfea67e 100644 --- a/src/slic3r/GUI/TaskManager.cpp +++ b/src/slic3r/GUI/TaskManager.cpp @@ -20,7 +20,6 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" using namespace nlohmann; diff --git a/src/slic3r/GUI/TickCode.cpp b/src/slic3r/GUI/TickCode.cpp index 92997095b6..c8ad170862 100644 --- a/src/slic3r/GUI/TickCode.cpp +++ b/src/slic3r/GUI/TickCode.cpp @@ -6,6 +6,9 @@ #include namespace Slic3r { + +using namespace CustomGCode; + namespace GUI { std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int extruder) { diff --git a/src/slic3r/GUI/TickCode.hpp b/src/slic3r/GUI/TickCode.hpp index e8cb848d76..e75ecc7a22 100644 --- a/src/slic3r/GUI/TickCode.hpp +++ b/src/slic3r/GUI/TickCode.hpp @@ -7,7 +7,6 @@ #include namespace Slic3r { -using namespace CustomGCode; namespace GUI { struct TickCode @@ -16,7 +15,7 @@ struct TickCode bool operator>(const TickCode& other) const { return other.tick < this->tick; } int tick = 0; - Type type = ColorChange; + CustomGCode::Type type = CustomGCode::ColorChange; int extruder = 0; std::string color; std::string extra; @@ -31,22 +30,22 @@ class TickCodeInfo std::vector* m_colors{ nullptr };// reference to IMSlider::m_extruder_colors - std::string get_color_for_tick(TickCode tick, Type type, const int extruder); + std::string get_color_for_tick(TickCode tick, CustomGCode::Type type, const int extruder); public: std::set ticks{}; - Mode mode = Undef; + CustomGCode::Mode mode = CustomGCode::Undef; bool empty() const { return ticks.empty(); } void set_pause_print_msg(const std::string& message) { pause_print_msg = message; } - bool add_tick(const int tick, Type type, int extruder, double print_z); + bool add_tick(const int tick, CustomGCode::Type type, int extruder, double print_z); bool edit_tick(std::set::iterator it, double print_z); - void switch_code(Type type_from, Type type_to); - bool switch_code_for_tick(std::set::iterator it, Type type_to, const int extruder); - void erase_all_ticks_with_code(Type type); + void switch_code(CustomGCode::Type type_from, CustomGCode::Type type_to); + bool switch_code_for_tick(std::set::iterator it, CustomGCode::Type type_to, const int extruder); + void erase_all_ticks_with_code(CustomGCode::Type type); - bool has_tick_with_code(Type type); + bool has_tick_with_code(CustomGCode::Type type); bool has_tick(int tick); void suppress_plus(bool suppress) { m_suppress_plus = suppress; } diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index dffc86a25c..b2bc818ad1 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -1,6 +1,5 @@ #include "UnsavedChangesDialog.hpp" -#include #include #include #include @@ -26,7 +25,6 @@ #include #include #include -#include #include #include @@ -66,8 +64,6 @@ #include "Widgets/DialogButtons.hpp" #include "Widgets/HyperLink.hpp" -using boost::optional; - #ifdef __linux__ #define wxLinux true #else diff --git a/src/slic3r/GUI/UserManager.cpp b/src/slic3r/GUI/UserManager.cpp index cdc2bfcaf5..44e21223a8 100644 --- a/src/slic3r/GUI/UserManager.cpp +++ b/src/slic3r/GUI/UserManager.cpp @@ -1,4 +1,4 @@ -#include "json_diff.hpp" +#include #include "UserManager.hpp" #include "BindDialog.hpp" #include "GUI_App.hpp" @@ -10,6 +10,8 @@ #include +using json = nlohmann::json; + namespace Slic3r { UserManager::UserManager(NetworkAgent* agent) diff --git a/src/slic3r/GUI/UserManager.hpp b/src/slic3r/GUI/UserManager.hpp index a7f402cbac..9e80e23bbe 100644 --- a/src/slic3r/GUI/UserManager.hpp +++ b/src/slic3r/GUI/UserManager.hpp @@ -9,12 +9,9 @@ #include #include #include "nlohmann/json.hpp" -#include "slic3r/Utils/json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" -using namespace nlohmann; - namespace Slic3r { class NetworkAgent; diff --git a/src/slic3r/GUI/WebDownPluginDlg.cpp b/src/slic3r/GUI/WebDownPluginDlg.cpp index 93c8c77d46..0bb93ef55b 100644 --- a/src/slic3r/GUI/WebDownPluginDlg.cpp +++ b/src/slic3r/GUI/WebDownPluginDlg.cpp @@ -4,7 +4,7 @@ #include "slic3r/GUI/GUI.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include "I18N.hpp" diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 665280aca9..b3e0aa7cd6 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -36,7 +36,7 @@ #include "libslic3r/PresetBundle.hpp" #include "libslic3r/PresetCacheFormat.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "libslic3r_version.h" #include @@ -78,12 +78,9 @@ #include "libslic3r/PrintConfig.hpp" #include "slic3r/Utils/NetworkAgent.hpp" #include "slic3r/Utils/PresetUpdater.hpp" -#include "slic3r/Utils/json_diff.hpp" class wxWindow; -namespace fs = boost::filesystem; - using namespace nlohmann; namespace Slic3r { namespace GUI { @@ -1685,13 +1682,13 @@ int GuideFrame::SaveProfileData() return 0; } -void StringReplace(string &strBase, string strSrc, string strDes) +void StringReplace(std::string &strBase, std::string strSrc, std::string strDes) { - string::size_type pos = 0; - string::size_type srcLen = strSrc.size(); - string::size_type desLen = strDes.size(); + std::string::size_type pos = 0; + std::string::size_type srcLen = strSrc.size(); + std::string::size_type desLen = strDes.size(); pos = strBase.find(strSrc, pos); - while ((pos != string::npos)) { + while ((pos != std::string::npos)) { strBase.replace(pos, srcLen, strDes); pos = strBase.find(strSrc, (pos + desLen)); } diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index bf7c7d9365..7f7c8c51c0 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -5,7 +5,6 @@ #include "slic3r/GUI/HttpServer.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" #include "slic3r/GUI/GUI.hpp" #include #include @@ -53,7 +52,6 @@ #include #include #include // ORCA -using namespace std; using namespace nlohmann; diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index d46615328b..f73eec6abd 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -24,7 +24,7 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -44,6 +44,7 @@ #include namespace pt = boost::property_tree; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Widgets/AMSControl.cpp b/src/slic3r/GUI/Widgets/AMSControl.cpp index c5015c9ddc..2fe4ac6014 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.cpp +++ b/src/slic3r/GUI/Widgets/AMSControl.cpp @@ -1052,7 +1052,7 @@ void AMSControl::UpdateAms(const std::string &series_name, /*update humidity popup*/ if (m_percent_humidity_dry_popup->IsShown()) { - string target_id = m_percent_humidity_dry_popup->get_owner_ams_id(); + std::string target_id = m_percent_humidity_dry_popup->get_owner_ams_id(); for (const auto& the_info : ams_info) { if (target_id == the_info.ams_id) diff --git a/src/slic3r/GUI/Widgets/AMSControl.hpp b/src/slic3r/GUI/Widgets/AMSControl.hpp index f4c83667c2..99146a01a6 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.hpp +++ b/src/slic3r/GUI/Widgets/AMSControl.hpp @@ -63,7 +63,7 @@ protected: std::string m_dev_id; std::vector> m_item_ids{ {}, {} }; - std::vector> pair_id; + std::vector> pair_id; int m_total_ext_count = 1; AMSextruder *m_extruder{nullptr}; @@ -181,7 +181,7 @@ public: std::tuple isFilaSwitchReady(); void show_switcher_status(bool show); - void UpdatePassRoad(string ams_id, AMSPassRoadType type, AMSPassRoadSTEP step); + void UpdatePassRoad(std::string ams_id, AMSPassRoadType type, AMSPassRoadSTEP step); void CreateAms(); void CreateAmsDoubleNozzle(const std::string &series_name, const std::string& printer_type); void CreateAmsSingleNozzle(const std::string &series_name, const std::string &printer_type); diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index ef3643e531..95418f79a2 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -634,7 +634,7 @@ void AMSextruderImage::doRender(wxDC &dc) } -AMSextruderImage::AMSextruderImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos) +AMSextruderImage::AMSextruderImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos) { wxWindow::Create(parent, id, pos, size); SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); @@ -823,7 +823,7 @@ void SwitcherImage::doRender(wxDC &dc) Layout(); } -SwitcherImage::SwitcherImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos) +SwitcherImage::SwitcherImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos) { wxWindow::Create(parent, id, pos, size); SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); @@ -899,7 +899,7 @@ void AMSextruder::OnAmsLoading(bool load, int nozzle_id, wxColour col /*= AMS_CO } /*return true if something is updated*/ -bool AMSextruder::updateNozzleNum(int nozzle_num, const string& series_name) +bool AMSextruder::updateNozzleNum(int nozzle_num, const std::string& series_name) { if (m_nozzle_num == nozzle_num && m_series_name == series_name) return false; m_series_name = series_name; diff --git a/src/slic3r/GUI/Widgets/AMSItem.hpp b/src/slic3r/GUI/Widgets/AMSItem.hpp index 55c0a3ca8d..c17b4ad59d 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.hpp +++ b/src/slic3r/GUI/Widgets/AMSItem.hpp @@ -393,10 +393,10 @@ public: bool m_show_state = {false}; wxColour m_colour; ScalableBitmap m_ams_extruder; - string m_file_name; + std::string m_file_name; bool m_ams_loading{ false }; void doRender(wxDC &dc); - AMSextruderImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); + AMSextruderImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); ~AMSextruderImage(); }; @@ -444,10 +444,10 @@ public: bool m_show_state = {false}; wxColour m_colour; ScalableBitmap m_switcher; - string m_file_name; + std::string m_file_name; // bool m_ams_loading{ false }; void doRender(wxDC &dc); - SwitcherImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); + SwitcherImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); ~SwitcherImage(); }; @@ -456,7 +456,7 @@ class AMSextruder : public wxWindow { private: int m_nozzle_num = -1; - string m_series_name; + std::string m_series_name; public: void TurnOn(wxColour col); @@ -466,7 +466,7 @@ public: void msw_rescale(); void has_ams(bool hams) {m_has_vams = hams; Refresh();}; void no_ams_mode(bool mode) {m_none_ams_mode = mode; Refresh();}; - bool updateNozzleNum(int nozzle_num, const std::string& series_name = string()); + bool updateNozzleNum(int nozzle_num, const std::string& series_name = std::string()); bool m_none_ams_mode{true}; bool m_has_vams{false}; diff --git a/src/slic3r/GUI/Widgets/FanControl.cpp b/src/slic3r/GUI/Widgets/FanControl.cpp index adb440d876..a6352ebd1d 100644 --- a/src/slic3r/GUI/Widgets/FanControl.cpp +++ b/src/slic3r/GUI/Widgets/FanControl.cpp @@ -3,7 +3,7 @@ #include "../I18N.hpp" #include "../GUI_App.hpp" #include "../MsgDialog.hpp" -#include "json_diff.hpp" +#include #include #include @@ -28,6 +28,8 @@ #include #include +using json = nlohmann::json; + namespace Slic3r { namespace GUI { wxDEFINE_EVENT(EVT_FAN_SWITCH_ON, wxCommandEvent); diff --git a/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp b/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp index 2fe66de8de..de863bd06d 100644 --- a/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp +++ b/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp @@ -12,7 +12,7 @@ #include "Label.hpp" #include "ComboBox.hpp" #include "StaticBox.hpp" -#include "json_diff.hpp" +#include #include "libslic3r/PresetBundle.hpp" #include "libslic3r/Utils.hpp" @@ -55,6 +55,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 8e2b0fcb9c..3aaee6b849 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -38,11 +38,12 @@ #include "Widgets/Label.hpp" #include "MainFrame.hpp" #include "libslic3r/PresetBundle.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "slic3r/GUI/Jobs/SendJob.hpp" -#include "slic3r/Utils/json_diff.hpp" #include +using json = nlohmann::json; + class wxWindow; namespace fs = boost::filesystem; diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 5babf843bc..56b58b5c57 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -453,7 +453,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in, const bool menu_bitmap/* = false*/, const bool resize/* = false*/, const bool bitmap2/* = false*/, - const vector& array_new_color/* = vector*/)//used for semi transparent material) + const std::vector& array_new_color/* = vector*/)//used for semi transparent material) { static Slic3r::GUI::BitmapCache cache; @@ -501,7 +501,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in, wxBitmap create_scaled_bitmap2(const std::string& bmp_name_in, Slic3r::GUI::BitmapCache& cache, wxWindow* win/* = nullptr*/ , const int px_cnt/* = 16*/, const bool grayscale/* = false*/ , const bool resize/* = false*/ , - const vector& array_new_color/* = vector()*/) // color witch will used instead of orange + const std::vector& array_new_color/* = vector()*/) // color witch will used instead of orange { unsigned int width = 0; // win may be nullptr; see create_scaled_bitmap() above. diff --git a/src/slic3r/Utils/3DPrinterOS.cpp b/src/slic3r/Utils/3DPrinterOS.cpp index 29b6bd63f8..f7a3387a7c 100644 --- a/src/slic3r/Utils/3DPrinterOS.cpp +++ b/src/slic3r/Utils/3DPrinterOS.cpp @@ -43,9 +43,6 @@ #include -using json = nlohmann::json; - -namespace fs = boost::filesystem; namespace pt = boost::property_tree; namespace { diff --git a/src/slic3r/Utils/AstroBox.cpp b/src/slic3r/Utils/AstroBox.cpp index 6904b56920..75976f7aa3 100644 --- a/src/slic3r/Utils/AstroBox.cpp +++ b/src/slic3r/Utils/AstroBox.cpp @@ -21,7 +21,6 @@ #include "Http.hpp" -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/BBLCloudServiceAgent.cpp b/src/slic3r/Utils/BBLCloudServiceAgent.cpp index 96525354e5..3737af2f18 100644 --- a/src/slic3r/Utils/BBLCloudServiceAgent.cpp +++ b/src/slic3r/Utils/BBLCloudServiceAgent.cpp @@ -18,8 +18,6 @@ #include #include "libslic3r/AppConfig.hpp" -using json = nlohmann::json; - namespace Slic3r { diff --git a/src/slic3r/Utils/BBLNetworkPlugin.cpp b/src/slic3r/Utils/BBLNetworkPlugin.cpp index 5cffe6468d..bae9ce85a8 100644 --- a/src/slic3r/Utils/BBLNetworkPlugin.cpp +++ b/src/slic3r/Utils/BBLNetworkPlugin.cpp @@ -596,7 +596,8 @@ PrintParams_Legacy BBLNetworkPlugin::as_legacy(PrintParams& param) } // Every PrintParams field except the four the 02.08.01 series added -// (task_timelapse_use_internal, extruder_cali_manual_mode, svc_context, slicer_uid). +// (task_timelapse_use_internal, extruder_cali_manual_mode, svc_context, slicer_uid) and the +// queue_plate_id 02.08.02 appended. PrintParams_0203 BBLNetworkPlugin::as_0203(PrintParams& param) { PrintParams_0203 p; diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index f0fcdd53e6..2a4ca8c05a 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -6,7 +6,7 @@ #include "NetworkAgent.hpp" #include "../GUI/Jobs/ProgressIndicator.hpp" #include "../GUI/PartPlate.hpp" -#include "json_diff.hpp" +#include #include "libslic3r/CutUtils.hpp" #include "libslic3r/ClipperUtils.hpp" #include "libslic3r/Utils.hpp" @@ -61,6 +61,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/Utils/CrealityPrint.cpp b/src/slic3r/Utils/CrealityPrint.cpp index 8a187ff998..081c5dd543 100644 --- a/src/slic3r/Utils/CrealityPrint.cpp +++ b/src/slic3r/Utils/CrealityPrint.cpp @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include #include #include @@ -55,7 +53,6 @@ #include #include using json = nlohmann::json; -using std::to_string; namespace beast = boost::beast; namespace http = beast::http; @@ -63,9 +60,6 @@ namespace websocket = beast::websocket; namespace net = boost::asio; using tcp = boost::asio::ip::tcp; -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { CrealityPrint::CrealityPrint(DynamicPrintConfig* config) : diff --git a/src/slic3r/Utils/CrealityPrintAgent.cpp b/src/slic3r/Utils/CrealityPrintAgent.cpp index 10f6a51c5d..a8910c2e09 100644 --- a/src/slic3r/Utils/CrealityPrintAgent.cpp +++ b/src/slic3r/Utils/CrealityPrintAgent.cpp @@ -214,7 +214,6 @@ bool CrealityPrintAgent::parse_cfs_response(const std::string& response, int& box_count, std::string& error) { - using nlohmann::json; slots.clear(); box_count = 0; diff --git a/src/slic3r/Utils/Duet.cpp b/src/slic3r/Utils/Duet.cpp index b5ad48fbae..419d795b65 100644 --- a/src/slic3r/Utils/Duet.cpp +++ b/src/slic3r/Utils/Duet.cpp @@ -3,11 +3,8 @@ #include #include #include -#include #include #include -#include -#include #include #include @@ -25,9 +22,6 @@ #include "slic3r/GUI/I18N.hpp" #include "Http.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { Duet::Duet(DynamicPrintConfig *config) : diff --git a/src/slic3r/Utils/ESP3D.cpp b/src/slic3r/Utils/ESP3D.cpp index 7f0cba2414..3890da8235 100644 --- a/src/slic3r/Utils/ESP3D.cpp +++ b/src/slic3r/Utils/ESP3D.cpp @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include #include @@ -28,9 +26,6 @@ #include "slic3r/GUI/I18N.hpp" #include "Http.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { ESP3D::ESP3D(DynamicPrintConfig* config) : m_host(config->opt_string("print_host")), m_console_port("8888") {} diff --git a/src/slic3r/Utils/ElegooLink.cpp b/src/slic3r/Utils/ElegooLink.cpp index d6b40578aa..bb83dca2f5 100644 --- a/src/slic3r/Utils/ElegooLink.cpp +++ b/src/slic3r/Utils/ElegooLink.cpp @@ -50,7 +50,6 @@ #include "slic3r/GUI/BonjourDialog.hpp" #include -namespace fs = boost::filesystem; namespace pt = boost::property_tree; #define MAX_UPLOAD_PACKAGE_LENGTH 1048576 //(1024*1024) diff --git a/src/slic3r/Utils/EmbossStyleManager.cpp b/src/slic3r/Utils/EmbossStyleManager.cpp index 5f03bd5df3..d873b40cf3 100644 --- a/src/slic3r/Utils/EmbossStyleManager.cpp +++ b/src/slic3r/Utils/EmbossStyleManager.cpp @@ -561,7 +561,6 @@ bool StyleManager::set_wx_font(const wxFont &wx_font, std::unique_ptr // StylesSerializable namespace { -using namespace Slic3r; using namespace Slic3r::GUI; using Section = std::map; diff --git a/src/slic3r/Utils/FlashAir.cpp b/src/slic3r/Utils/FlashAir.cpp index 16648c711d..0257fec556 100644 --- a/src/slic3r/Utils/FlashAir.cpp +++ b/src/slic3r/Utils/FlashAir.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -23,9 +22,6 @@ #include "slic3r/GUI/I18N.hpp" #include "Http.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { FlashAir::FlashAir(DynamicPrintConfig *config) : diff --git a/src/slic3r/Utils/Flashforge.cpp b/src/slic3r/Utils/Flashforge.cpp index b0697b80d4..fd6ad6fcf7 100644 --- a/src/slic3r/Utils/Flashforge.cpp +++ b/src/slic3r/Utils/Flashforge.cpp @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include #include @@ -55,7 +53,6 @@ #include "SerialMessageType.hpp" namespace fs = boost::filesystem; -namespace pt = boost::property_tree; using json = nlohmann::json; namespace Slic3r { diff --git a/src/slic3r/Utils/FontConfigHelp.cpp b/src/slic3r/Utils/FontConfigHelp.cpp index f3280ad83d..81f7d9784c 100644 --- a/src/slic3r/Utils/FontConfigHelp.cpp +++ b/src/slic3r/Utils/FontConfigHelp.cpp @@ -13,8 +13,6 @@ #include #include "libslic3r/Utils.hpp" -using namespace Slic3r::GUI; - // @Vojta suggest to make static variable global // Guard for finalize Font Config diff --git a/src/slic3r/Utils/MKS.cpp b/src/slic3r/Utils/MKS.cpp index 52649a667f..cac9f08110 100644 --- a/src/slic3r/Utils/MKS.cpp +++ b/src/slic3r/Utils/MKS.cpp @@ -4,11 +4,8 @@ #include #include #include -#include #include #include -#include -#include #include #include @@ -31,9 +28,6 @@ #include "SerialMessage.hpp" #include "SerialMessageType.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { MKS::MKS(DynamicPrintConfig* config) : diff --git a/src/slic3r/Utils/Obico.cpp b/src/slic3r/Utils/Obico.cpp index 37a618445a..1a86be377b 100644 --- a/src/slic3r/Utils/Obico.cpp +++ b/src/slic3r/Utils/Obico.cpp @@ -30,7 +30,6 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/BonjourDialog.hpp" -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index 63199c8781..8fb511d193 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -37,7 +37,6 @@ #include #include -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp index 2a8d3cdefb..c3e67afef1 100644 --- a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp +++ b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp @@ -82,7 +82,7 @@ using json = nlohmann::json; namespace Slic3r { namespace { -constexpr const char* ORCA_DEFAULT_API_URL = "api.orcaslicer.com"; +constexpr const char* ORCA_DEFAULT_API_URL = "https://api.orcaslicer.com"; constexpr const char* ORCA_DEFAULT_AUTH_URL = "https://auth.orcaslicer.com"; constexpr const char* ORCA_DEFAULT_CLOUD_URL = "https://cloud.orcaslicer.com"; // Orca: This is a public key with no secret, used to identify the client application to the backend. diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 90807eb723..344a5f881c 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -38,7 +38,7 @@ #include #include -#include "json_diff.hpp" +#include #include "libslic3r/format.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/PresetBundle.hpp" @@ -58,14 +58,14 @@ #include "slic3r/GUI/MarkdownTip.hpp" #include "libslic3r/miniz_extension.hpp" +using json = nlohmann::json; + namespace Slic3r::GUI::Config { class Snapshot; } namespace Slic3r::GUI::Config { class SnapshotDB; } namespace fs = boost::filesystem; using Slic3r::GUI::Config::Index; using Slic3r::GUI::Config::Version; -using Slic3r::GUI::Config::Snapshot; -using Slic3r::GUI::Config::SnapshotDB; // FIXME: Incompat bundle resolution doesn't deal with inherited user presets diff --git a/src/slic3r/Utils/PrintHost.cpp b/src/slic3r/Utils/PrintHost.cpp index 2b3c4d181d..b51dcc6af3 100644 --- a/src/slic3r/Utils/PrintHost.cpp +++ b/src/slic3r/Utils/PrintHost.cpp @@ -1,6 +1,5 @@ #include "PrintHost.hpp" -#include #include "libslic3r/Config.hpp" #include #include @@ -16,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -50,7 +48,6 @@ #include "Moonraker.hpp" namespace fs = boost::filesystem; -using boost::optional; using Slic3r::GUI::PrintHostQueueDialog; namespace Slic3r { diff --git a/src/slic3r/Utils/QidiPrinterAgent.cpp b/src/slic3r/Utils/QidiPrinterAgent.cpp index 06499e1092..c2dc4411a6 100644 --- a/src/slic3r/Utils/QidiPrinterAgent.cpp +++ b/src/slic3r/Utils/QidiPrinterAgent.cpp @@ -18,8 +18,6 @@ #include #include -using json = nlohmann::json; - namespace Slic3r { namespace { diff --git a/src/slic3r/Utils/Repetier.cpp b/src/slic3r/Utils/Repetier.cpp index ae269cac4f..1663a3570a 100644 --- a/src/slic3r/Utils/Repetier.cpp +++ b/src/slic3r/Utils/Repetier.cpp @@ -27,7 +27,6 @@ #include "Http.hpp" -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/Serial.cpp b/src/slic3r/Utils/Serial.cpp index 2b64330826..1b54125c0f 100644 --- a/src/slic3r/Utils/Serial.cpp +++ b/src/slic3r/Utils/Serial.cpp @@ -288,7 +288,6 @@ std::vector scan_serial_ports() // Class Serial namespace asio = boost::asio; -using boost::system::error_code; Serial::Serial(asio::io_service& io_service) : asio::serial_port(io_service) diff --git a/src/slic3r/Utils/SimplyPrint.cpp b/src/slic3r/Utils/SimplyPrint.cpp index 5c68878986..ff6860a244 100644 --- a/src/slic3r/Utils/SimplyPrint.cpp +++ b/src/slic3r/Utils/SimplyPrint.cpp @@ -115,7 +115,7 @@ static void set_auth(Http& http, const std::string& access_token) { http.header( static bool should_open_in_external_browser() { - const auto& app = wxGetApp(); + const auto& app = GUI::wxGetApp(); if (app.preset_bundle->use_bbl_device_tab()) { // When using bbl device tab, we always need to open external browser diff --git a/src/slic3r/Utils/SnapmakerPrinterAgent.cpp b/src/slic3r/Utils/SnapmakerPrinterAgent.cpp index a237d1b2b1..b172ebb015 100644 --- a/src/slic3r/Utils/SnapmakerPrinterAgent.cpp +++ b/src/slic3r/Utils/SnapmakerPrinterAgent.cpp @@ -13,8 +13,6 @@ #include #include -using json = nlohmann::json; - namespace Slic3r { namespace { diff --git a/src/slic3r/Utils/TCPConsole.cpp b/src/slic3r/Utils/TCPConsole.cpp index 78d4624abc..45192c2786 100644 --- a/src/slic3r/Utils/TCPConsole.cpp +++ b/src/slic3r/Utils/TCPConsole.cpp @@ -3,9 +3,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -24,9 +22,6 @@ #include "SerialMessage.hpp" #include "SerialMessageType.hpp" -using boost::asio::steady_timer; -using boost::asio::ip::tcp; - namespace Slic3r { namespace Utils { diff --git a/src/slic3r/Utils/UltiMaker.cpp b/src/slic3r/Utils/UltiMaker.cpp index 432725f0e8..9b6894034e 100644 --- a/src/slic3r/Utils/UltiMaker.cpp +++ b/src/slic3r/Utils/UltiMaker.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -34,8 +33,6 @@ #include #include #include -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; namespace Slic3r { diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 30c33c6c73..54079ee0bd 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -336,6 +336,7 @@ struct PrintParams { bool try_emmc_print; std::string svc_context; std::string slicer_uid; + std::string queue_plate_id; }; struct TaskQueryParams @@ -412,7 +413,7 @@ enum class NetworkAbi { Unsupported, // no generation in this build can call it - never dispatch through it Legacy, // 01.10.01: PrintParams_Legacy; send_message/send_message_to_printer take no flag V0203, // 02.03.00: PrintParams_0203; bind takes no dev_model - Current, // 02.08.01: the layouts and signatures this build declares directly + Current, // 02.08.04: the layouts and signatures this build declares directly }; struct NetworkLibraryVersion { @@ -425,10 +426,12 @@ struct NetworkLibraryVersion { }; // Every row names the generation that can call it, so a series can never be offered without a -// host-side ABI for it. Series with no generation - 02.01.01, 02.00.02 and older - must stay out; -// is_supported_network_version() is the gate that keeps them from loading. +// host-side ABI for it. Series with no generation - 02.08.01 (whose PrintParams lacks the +// queue_plate_id that 02.08.02 appended, and whose malformed bind table macOS 27 refuses to +// load), 02.01.01, 02.00.02 and older - must stay out; is_supported_network_version() is the +// gate that keeps them from loading. static const NetworkLibraryVersion AVAILABLE_NETWORK_VERSIONS[] = { - {"02.08.01", "02.08.01", nullptr, true, nullptr, NetworkAbi::Current}, + {"02.08.04", "02.08.04", nullptr, true, nullptr, NetworkAbi::Current}, {"02.03.00", "02.03.00", nullptr, false, "An older plug-in series. Features that need newer plug-in support, such as print-failure " "snapshots in the device error dialog, are unavailable.", NetworkAbi::V0203}, diff --git a/src/slic3r/Utils/json_diff.cpp b/src/slic3r/Utils/json_diff.cpp index 171a44c63d..37bb55f799 100644 --- a/src/slic3r/Utils/json_diff.cpp +++ b/src/slic3r/Utils/json_diff.cpp @@ -16,7 +16,6 @@ #include #include -using namespace std; using json = nlohmann::json; int json_diff::diff_objects(json const &in, json &out, json const &base) diff --git a/src/slic3r/Utils/json_diff.hpp b/src/slic3r/Utils/json_diff.hpp index 6ba5a1b8e4..df097dc78c 100644 --- a/src/slic3r/Utils/json_diff.hpp +++ b/src/slic3r/Utils/json_diff.hpp @@ -7,34 +7,30 @@ #include "nlohmann/json.hpp" - -using json = nlohmann::json; -using namespace std; - class json_diff { private: std::string printer_type; std::string printer_version = "00.00.00.00"; - json settings_base; - json full_message; + nlohmann::json settings_base; + nlohmann::json full_message; - json diff2all_base; - json all2diff_base; + nlohmann::json diff2all_base; + nlohmann::json all2diff_base; int decode_error_count = 0; - int diff_objects(json const &in, json &out, json const &base); - int restore_objects(json const &in, json &out, json const &base); - int restore_append_objects(json const &in, json &out); - void merge_objects(json const &in, json &out); + int diff_objects(nlohmann::json const &in, nlohmann::json &out, nlohmann::json const &base); + int restore_objects(nlohmann::json const &in, nlohmann::json &out, nlohmann::json const &base); + int restore_append_objects(nlohmann::json const &in, nlohmann::json &out); + void merge_objects(nlohmann::json const &in, nlohmann::json &out); public: bool load_compatible_settings(std::string const &type, std::string const &version); - int all2diff(json const &in, json &out); - int diff2all(json const &in, json &out); - int all2diff_base_reset(json const &base); - int diff2all_base_reset(json &base); - void compare_print(json &a, json &b); + int all2diff(nlohmann::json const &in, nlohmann::json &out); + int diff2all(nlohmann::json const &in, nlohmann::json &out); + int all2diff_base_reset(nlohmann::json const &base); + int diff2all_base_reset(nlohmann::json &base); + void compare_print(nlohmann::json &a, nlohmann::json &b); bool is_need_request(); }; diff --git a/src/slic3r/plugin/host/PluginHostUi.cpp b/src/slic3r/plugin/host/PluginHostUi.cpp index 54de1df0d6..46d46b402f 100644 --- a/src/slic3r/plugin/host/PluginHostUi.cpp +++ b/src/slic3r/plugin/host/PluginHostUi.cpp @@ -565,7 +565,7 @@ void progress_close(int id) }); } -void plater_notification(NotificationManager::NotificationLevel notification_level, const std::string& text, +void plater_notification(GUI::NotificationManager::NotificationLevel notification_level, const std::string& text, const std::string& hypertext, py::object on_click) { const std::string plugin_key = PluginAuditManager::instance().current_plugin(); @@ -600,7 +600,7 @@ void plater_notification(NotificationManager::NotificationLevel notification_lev } run_on_ui_blocking([notification_level, text, hypertext, callback = std::move(callback)]() mutable { - wxGetApp().plater()->get_notification_manager()->push_notification(NotificationType::CustomNotification, notification_level, text, + GUI::wxGetApp().plater()->get_notification_manager()->push_notification(GUI::NotificationType::CustomNotification, notification_level, text, hypertext, std::move(callback)); }); } @@ -713,16 +713,16 @@ void PluginHostUi::RegisterBindings(pybind11::module_& host) py::arg("maximum") = 100, py::arg("style") = wxPD_APP_MODAL | wxPD_AUTO_HIDE, "Create a native progress dialog and return a ProgressDialog handle."); - py::enum_(ui, "NotificationLevel") - .value("ProgressBarNotificationLevel", NotificationManager::NotificationLevel::ProgressBarNotificationLevel) - .value("HintNotificationLevel", NotificationManager::NotificationLevel::HintNotificationLevel) - .value("RegularNotificationLevel", NotificationManager::NotificationLevel::RegularNotificationLevel) - .value("PrintInfoNotificationLevel", NotificationManager::NotificationLevel::PrintInfoNotificationLevel) - .value("PrintInfoShortNotificationLevel", NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel) - .value("ImportantNotificationLevel", NotificationManager::NotificationLevel::ImportantNotificationLevel) - .value("WarningNotificationLevel", NotificationManager::NotificationLevel::WarningNotificationLevel) - .value("SeriousWarningNotificationLevel", NotificationManager::NotificationLevel::SeriousWarningNotificationLevel) - .value("ErrorNotificationLevel", NotificationManager::NotificationLevel::ErrorNotificationLevel) + py::enum_(ui, "NotificationLevel") + .value("ProgressBarNotificationLevel", GUI::NotificationManager::NotificationLevel::ProgressBarNotificationLevel) + .value("HintNotificationLevel", GUI::NotificationManager::NotificationLevel::HintNotificationLevel) + .value("RegularNotificationLevel", GUI::NotificationManager::NotificationLevel::RegularNotificationLevel) + .value("PrintInfoNotificationLevel", GUI::NotificationManager::NotificationLevel::PrintInfoNotificationLevel) + .value("PrintInfoShortNotificationLevel", GUI::NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel) + .value("ImportantNotificationLevel", GUI::NotificationManager::NotificationLevel::ImportantNotificationLevel) + .value("WarningNotificationLevel", GUI::NotificationManager::NotificationLevel::WarningNotificationLevel) + .value("SeriousWarningNotificationLevel", GUI::NotificationManager::NotificationLevel::SeriousWarningNotificationLevel) + .value("ErrorNotificationLevel", GUI::NotificationManager::NotificationLevel::ErrorNotificationLevel) .export_values(); ui.def("push_notification", &plater_notification, py::arg("notification_level"), py::arg("text"), diff --git a/tests/fff_print/test_flow.cpp b/tests/fff_print/test_flow.cpp index 328c610e02..f3e8abd02e 100644 --- a/tests/fff_print/test_flow.cpp +++ b/tests/fff_print/test_flow.cpp @@ -12,7 +12,6 @@ #include "libslic3r/Flow.hpp" #include "libslic3r/libslic3r.h" -using namespace Slic3r::Test; using namespace Slic3r; /// Test the expected behavior for auto-width, diff --git a/tests/fff_print/test_helpers.cpp b/tests/fff_print/test_helpers.cpp index 913641e256..15bf6ce143 100644 --- a/tests/fff_print/test_helpers.cpp +++ b/tests/fff_print/test_helpers.cpp @@ -27,8 +27,6 @@ #include "test_utils.hpp" -using namespace std; - namespace Slic3r { namespace Test { const std::unordered_map mesh_names { diff --git a/tests/fff_print/test_model.cpp b/tests/fff_print/test_model.cpp index 43041c0bdf..1ad806e455 100644 --- a/tests/fff_print/test_model.cpp +++ b/tests/fff_print/test_model.cpp @@ -19,7 +19,6 @@ #include "libslic3r/Print.hpp" using namespace Slic3r; -using namespace Slic3r::Test; SCENARIO("Model construction", "[Model]") { GIVEN("A Slic3r Model") { diff --git a/tests/fff_print/test_trianglemesh.cpp b/tests/fff_print/test_trianglemesh.cpp index b7e3b96beb..ab5c334d2e 100644 --- a/tests/fff_print/test_trianglemesh.cpp +++ b/tests/fff_print/test_trianglemesh.cpp @@ -21,7 +21,6 @@ //#include "test_options.hpp" using namespace Slic3r; -using namespace std; static inline TriangleMesh make_cube() { return make_cube(20., 20, 20); } diff --git a/tests/libslic3r/test_arachne_walls.cpp b/tests/libslic3r/test_arachne_walls.cpp index f568a0d014..9f216a0518 100644 --- a/tests/libslic3r/test_arachne_walls.cpp +++ b/tests/libslic3r/test_arachne_walls.cpp @@ -241,7 +241,6 @@ TEST_CASE("Arachne wall generation - 60% min_bead_width", "[Arachne]") { // getTransitionThickness(1) = (1 + 0.619) * 0.42 = 0.68mm. A 0.5mm-thick wall therefore sits // in the transition band: alpha produced 2 beads here, beta collapses it to 1 fat bead. TEST_CASE("Arachne widening keeps two beads in transition band (#14376)", "[Arachne]") { - using namespace Slic3r::Arachne; // Widths in mm; the scaled coord_t values and the thresholds below are both derived from // these so a width change cannot silently desync the transition-band math. diff --git a/tests/libslic3r/test_caddocument.cpp b/tests/libslic3r/test_caddocument.cpp index 84c93a39d0..4ee1de587d 100644 --- a/tests/libslic3r/test_caddocument.cpp +++ b/tests/libslic3r/test_caddocument.cpp @@ -992,7 +992,6 @@ TEST_CASE("tessellate tracks per-triangle face id", "[CadDocument]") TEST_CASE("extrude two-sided + through-all + intersect", "[CadDocument]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); // a 10x10 square wire centred on origin SketchProfile sp; @@ -1013,7 +1012,6 @@ TEST_CASE("extrude two-sided + through-all + intersect", "[CadDocument]") TEST_CASE("extrude taper + up-to-face distance", "[CadDocument]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); SketchProfile sp; sp.points = { Vec2d(-5,-5),Vec2d(5,-5),Vec2d(5,5),Vec2d(-5,5) }; sp.closed = true; TopoDS_Wire w = sp.to_occt_wire(xy); @@ -1047,7 +1045,6 @@ TEST_CASE("extrude taper + up-to-face distance", "[CadDocument]") // asserting, because that is what "the thread actually cuts" means. TEST_CASE("internal thread cuts a visible groove into the bore wall", "[CadDocument][thread]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); // 40x40x20 box centred on the origin, extruded +Z. @@ -1093,7 +1090,6 @@ TEST_CASE("internal thread cuts a visible groove into the bore wall", "[CadDocum TEST_CASE("revolve builds a solid of revolution about an in-plane axis", "[CadDocument]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); // Rectangle profile (10 wide x 10 tall, area 100) offset to +v so it lies entirely @@ -1136,7 +1132,6 @@ TEST_CASE("revolve builds a solid of revolution about an in-plane axis", "[CadDo TEST_CASE("sweep builds a solid by sweeping a profile along a path", "[CadDocument]") { - using namespace Slic3r; CadDocument doc; // Profile: circle r=5 on the XY plane at the origin (area = 25*pi). @@ -1172,7 +1167,6 @@ TEST_CASE("sweep builds a solid by sweeping a profile along a path", "[CadDocume TEST_CASE("pattern replicates a body linearly and circularly", "[CadDocument]") { - using namespace Slic3r; // Linear: a 10x10x10 box (V=1000) repeated 3x at 20mm spacing along plane X. // 20 > 10 so the copies are disjoint -> total V = 3*1000 = 3000. @@ -1221,8 +1215,6 @@ TEST_CASE("pattern replicates a body linearly and circularly", "[CadDocument]") TEST_CASE("pattern-on-curve: copies land on a line and bbox spans the curve length", "[CadDocument][pattern]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; - using namespace Slic3r; CadDocument doc; @@ -1250,7 +1242,6 @@ TEST_CASE("pattern-on-curve: copies land on a line and bbox spans the curve leng TEST_CASE("pattern-on-curve: bad refs are safe", "[CadDocument][pattern]") { - using namespace Slic3r; CadDocument doc; int s0 = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 4, 4, 0, "Seed"); @@ -1266,7 +1257,6 @@ TEST_CASE("pattern-on-curve: bad refs are safe", "[CadDocument][pattern]") TEST_CASE("pattern-on-curve: round-trip through serialize/deserialize", "[CadDocument][pattern]") { using Catch::Matchers::WithinRel; - using namespace Slic3r; CadDocument doc; int s0 = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 4, 4, 0, "Seed"); @@ -1312,7 +1302,6 @@ TEST_CASE("pattern-on-curve: round-trip through serialize/deserialize", "[CadDoc TEST_CASE("thread standards table carries correct ISO/UTS measures", "[CadDocument]") { - using namespace Slic3r; // Table is non-empty and every entry is self-consistent. const auto& table = thread_standards(); @@ -1459,7 +1448,6 @@ TEST_CASE("loft builds a solid skinning two profiles on parallel planes", "[CadD TEST_CASE("draft tapers a solid face about the body base", "[CadDocument]") { - using namespace Slic3r; // 10x10x10 box from z=0..10 (V=1000). Drafting a vertical side face by +10deg about // the bottom (neutral) plane tilts its top edge inward, removing material so V<1000. @@ -1740,7 +1728,6 @@ TEST_CASE("split by face keep upper only", "[CadDocument][cut]") TEST_CASE("split by face round-trip serialization", "[CadDocument][cut]") { - using Catch::Matchers::WithinRel; using Catch::Matchers::WithinAbs; CadDocument doc; @@ -1808,7 +1795,6 @@ TEST_CASE("split by face round-trip serialization", "[CadDocument][cut]") TEST_CASE("mirror reflects a body about a plane", "[CadDocument]") { using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; auto make_box = [](CadDocument& doc, double w, double h, double d) { int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), w, h, 0, "Box"); @@ -1939,7 +1925,6 @@ TEST_CASE("mirror reflects a body about a plane", "[CadDocument]") TEST_CASE("mirror serialization round-trip", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Box"); @@ -2453,7 +2438,6 @@ TEST_CASE("a v3 recipe is refused with a message naming the version", "[CadDocum TEST_CASE("re-edit: editing a mid-timeline feature rebuilds downstream", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), @@ -2486,7 +2470,6 @@ TEST_CASE("re-edit: editing a mid-timeline feature rebuilds downstream", "[CadDo TEST_CASE("re-edit survives serialize -> deserialize", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), @@ -2519,7 +2502,6 @@ TEST_CASE("re-edit survives serialize -> deserialize", "[CadDocument]") TEST_CASE("re-edit: multi-type timeline replays all downstream features", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), @@ -2994,7 +2976,6 @@ TEST_CASE("datum coordinate system: point_world gives world axes", "[CadDocument TEST_CASE("helix curve: arc length, bounding box, left-handed, conical", "[CadDocument]") { using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; // --- Cylindrical helix r=5, pitch=2, height=10 (5 turns) --- // One turn arc length = sqrt((2*pi*r)^2 + pitch^2) = sqrt((10*pi)^2 + 4). @@ -3386,7 +3367,6 @@ TEST_CASE("transform degenerate axis errors", "[CadDocument]") TEST_CASE("transform moved body participates in later boolean at its new position", "[CadDocument]") { - using Catch::Matchers::WithinAbs; CadDocument doc; // Two boxes that do NOT overlap @@ -3516,7 +3496,6 @@ TEST_CASE("thicken a planar face to a plate", "[CadDocument]") TEST_CASE("thicken flip offsets against face normal", "[CadDocument]") { - using Catch::Matchers::WithinAbs; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "BoxSketch"); @@ -3615,7 +3594,6 @@ TEST_CASE("thicken zero thickness returns error", "[CadDocument]") TEST_CASE("thickened plate fuses with source", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Box"); @@ -3649,7 +3627,6 @@ TEST_CASE("thickened plate fuses with source", "[CadDocument]") TEST_CASE("thicken round-trip serialization", "[CadDocument]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Box"); @@ -3833,7 +3810,6 @@ TEST_CASE("project bad face id returns error", "[CadDocument][project]") TEST_CASE("project round-trip serialization", "[CadDocument][project]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 10, "Box"); @@ -4609,8 +4585,6 @@ TEST_CASE("golden recipe v1 still deserialises", "[CadDocument]") TEST_CASE("rib adds material to a box", "[CadDocument][rib]") { - using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; CadDocument doc; @@ -4763,7 +4737,6 @@ TEST_CASE("bridge two collinear lines", "[CadDocument][bridge]") TEST_CASE("bridge closes a C profile and extrudes", "[CadDocument][bridge]") { - using Catch::Matchers::WithinAbs; using Catch::Matchers::WithinRel; CadDocument doc; @@ -4861,8 +4834,6 @@ TEST_CASE("bridge round-trip serialization", "[CadDocument][bridge]") TEST_CASE("delete_face removes a fillet face and restores volume", "[CadDocument][deleteface]") { - using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 10, "Box"); @@ -4912,7 +4883,6 @@ TEST_CASE("delete_face with bad face index fails safely", "[CadDocument][deletef TEST_CASE("delete_face round-trip serialization", "[CadDocument][deleteface]") { - using Catch::Matchers::WithinRel; using Catch::Matchers::WithinAbs; CadDocument doc; @@ -4970,7 +4940,6 @@ TEST_CASE("delete_face round-trip serialization", "[CadDocument][deleteface]") TEST_CASE("hole: counterbore removes more material than a simple bore", "[CadDocument][hole]") { - using Catch::Matchers::WithinAbs; auto make_box_hole = [](int style, double cbore_d, double cbore_depth, double csink_d, double csink_angle, const std::string& desig) { CadDocument doc; @@ -4998,7 +4967,6 @@ TEST_CASE("hole: counterbore removes more material than a simple bore", "[CadDoc TEST_CASE("hole: countersink removes more material than a simple bore", "[CadDocument][hole]") { - using Catch::Matchers::WithinAbs; auto make_box = []() { CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 30, 30, 0, "Box"); @@ -5301,7 +5269,6 @@ TEST_CASE("parametric recipe round-trips through serialize/deserialize", "[CadDo TEST_CASE("surface-extrude makes an open shell", "[CadDocument][surface]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Rect"); @@ -5324,7 +5291,6 @@ TEST_CASE("surface-extrude makes an open shell", "[CadDocument][surface]") TEST_CASE("surface-revolve makes an open shell", "[CadDocument][surface]") { - using Catch::Matchers::WithinRel; CadDocument doc; // A small rectangle offset from the axis: u=10..15, v=0..5. @@ -5395,7 +5361,6 @@ TEST_CASE("surface round-trip serialize/deserialize", "[CadDocument][surface]") TEST_CASE("thicken-surface makes a solid from a sheet", "[CadDocument][surface]") { - using Catch::Matchers::WithinRel; using Catch::Matchers::WithinAbs; CadDocument doc; @@ -5519,7 +5484,6 @@ TEST_CASE("thicken surface fills the corners of a closed-loop wall", "[CadDocume TEST_CASE("surface-offset creates another sheet shifted outward", "[CadDocument][surface]") { - using Catch::Matchers::WithinAbs; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Rect"); @@ -5568,7 +5532,6 @@ TEST_CASE("thicken-surface on non-sheet fails", "[CadDocument][surface]") TEST_CASE("thicken-surface round-trip serialize/deserialize", "[CadDocument][surface]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Rect"); @@ -5608,7 +5571,6 @@ TEST_CASE("thicken-surface round-trip serialize/deserialize", "[CadDocument][sur TEST_CASE("surface-loft makes an open shell", "[CadDocument][surface]") { - using Catch::Matchers::WithinAbs; CadDocument doc; SketchProfile bot; @@ -6315,7 +6277,6 @@ TEST_CASE("mate conflicts: a broken mate is left to apply_mate", "[CadDocument][ TEST_CASE("ordering: fillet after mate resolves face ids", "[CadDocument][mate]") { - using Catch::Matchers::WithinAbs; CadDocument doc; int sk_a = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 10, 10, 0, "BoxA"); @@ -7846,7 +7807,6 @@ TEST_CASE("plane_of_face gives a sketchable plane for a planar face only", "[Cad // that asserts a state the code cannot reach is exactly what the contract forbids. TEST_CASE("recompute on a healthy box + fillet leaves no body null and no error (positive contract)", "[CadDocument]") { - using namespace Slic3r; CadDocument doc; SketchProfile sp; sp.points.push_back(Vec2d(0, 0)); @@ -8758,7 +8718,6 @@ TEST_CASE("a body carries its own name, through recompute and the recipe", "[Cad TEST_CASE("deleting a feature remaps the references of every consumer, not just Extrude", "[CadDocument]") { - using namespace Slic3r; const SketchPlane xy = SketchPlane::XY(); // A rectangle 10x10 centred at v = 15, revolved 360 deg about the plane X axis. @@ -9098,7 +9057,6 @@ namespace { // centerline x = 0 from (0,0) to (0,20): the half-profile of a tube, drawn the usual way. Slic3r::CadFeature tube_half_profile() { - using namespace Slic3r; CadFeature sk; sk.type = CadFeatureType::Sketch; sk.plane = SketchPlane::XY(); @@ -9113,7 +9071,6 @@ Slic3r::CadFeature tube_half_profile() TEST_CASE("revolve about a line of the sketch", "[CadDocument][revolve]") { - using namespace Slic3r; SECTION("a construction centerline: the profile sweeps into a tube around it") { CadDocument doc; diff --git a/tests/libslic3r/test_config.cpp b/tests/libslic3r/test_config.cpp index e13070062f..738e8539d2 100644 --- a/tests/libslic3r/test_config.cpp +++ b/tests/libslic3r/test_config.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include "libslic3r/Config.hpp" #include @@ -32,8 +31,6 @@ #include #include -namespace fs = boost::filesystem; - using namespace Slic3r; SCENARIO("Generic config validation performs as expected.", "[Config]") { @@ -541,6 +538,110 @@ SCENARIO("update_diff_values_to_child_config keeps a child's values on variants } } +SCENARIO("update_non_diff_values_to_base_config keeps a project's changed values on variants it does not list", + "[Config][Variant]") { + std::set no_keys; + auto variants = [](std::initializer_list names) { return new Slic3r::ConfigOptionStrings(names); }; + + GIVEN("A filament base with three variants") { + Slic3r::DynamicPrintConfig base; + base.set_key_value("filament_extruder_variant", + variants({"Direct Drive Standard", "Bowden Standard", "Direct Drive High Flow"})); + base.set_deserialize_strict("nozzle_temperature", "220,220,220"); + + WHEN("the project was saved when the base had only its first variant") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("filament_extruder_variant", variants({"Direct Drive Standard"})); + project.set_deserialize_strict("nozzle_temperature", "199"); + + AND_WHEN("the project lists the value as changed") { + project.update_non_diff_values_to_base_config(base, project.keys(), {"nozzle_temperature"}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("the project's value applies to every variant") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "199,199,199"); + } + } + AND_WHEN("the project does not list the value as changed") { + project.update_non_diff_values_to_base_config(base, project.keys(), {}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("the base's values replace it") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "220,220,220"); + } + } + } + WHEN("the project lists every variant, in another order") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("filament_extruder_variant", + variants({"Bowden Standard", "Direct Drive High Flow", "Direct Drive Standard"})); + project.set_deserialize_strict("nozzle_temperature", "190,205,199"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"nozzle_temperature"}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("each variant keeps its own value") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "199,190,205"); + } + } + WHEN("the project lists no variants") { + Slic3r::DynamicPrintConfig project; + project.set_deserialize_strict("nozzle_temperature", "199"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"nozzle_temperature"}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("the project's value applies to every variant") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "199,199,199"); + } + } + } + + GIVEN("A two-extruder printer base with two variants per extruder") { + Slic3r::DynamicPrintConfig base; + base.set_key_value("printer_extruder_variant", + variants({"Direct Drive Standard", "Direct Drive High Flow", "Direct Drive Standard", "Direct Drive High Flow"})); + base.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 1, 2, 2})); + base.set_deserialize_strict("retraction_length", "0.8,0.8,0.8,0.8"); + + WHEN("the project lists only the Standard variant of each extruder") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("printer_extruder_variant", variants({"Direct Drive Standard", "Direct Drive Standard"})); + project.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2})); + project.set_deserialize_strict("retraction_length", "1.1,2.2"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"retraction_length"}, "printer_extruder_id", "printer_extruder_variant", + Slic3r::printer_options_with_variant_1, + Slic3r::printer_options_with_variant_2); + THEN("each extruder's High Flow variant takes that extruder's value") { + REQUIRE(project.opt_serialize("retraction_length") == "1.1,1.1,2.2,2.2"); + } + } + WHEN("the project lists only the Standard variant of each extruder, and the variant lists as changed") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("printer_extruder_variant", variants({"Direct Drive Standard", "Direct Drive Standard"})); + project.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2})); + project.set_deserialize_strict("machine_max_speed_x", "300,100,400,150"); + base.set_deserialize_strict("machine_max_speed_x", "500,200,500,200,500,200,500,200"); + project.update_non_diff_values_to_base_config(base, project.keys(), + {"machine_max_speed_x", "printer_extruder_id", "printer_extruder_variant"}, + "printer_extruder_id", "printer_extruder_variant", + Slic3r::printer_options_with_variant_1, + Slic3r::printer_options_with_variant_2); + THEN("the variant lists are the base's") { + REQUIRE(project.opt_serialize("printer_extruder_variant") == base.opt_serialize("printer_extruder_variant")); + REQUIRE(project.opt_serialize("printer_extruder_id") == "1,1,2,2"); + } + THEN("each extruder's High Flow variant takes that extruder's pair of limits") { + REQUIRE(project.opt_serialize("machine_max_speed_x") == "300,100,300,100,400,150,400,150"); + } + } + WHEN("the project lists no variants") { + Slic3r::DynamicPrintConfig project; + project.set_deserialize_strict("retraction_length", "1.1"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"retraction_length"}, "printer_extruder_id", "printer_extruder_variant", + Slic3r::printer_options_with_variant_1, + Slic3r::printer_options_with_variant_2); + THEN("only the first extruder's variants take the project's value") { + REQUIRE(project.opt_serialize("retraction_length") == "1.1,1.1,0.8,0.8"); + } + } + } +} + // SCENARIO("DynamicPrintConfig JSON serialization", "[Config]") { // WHEN("DynamicPrintConfig is serialized and deserialized") { // auto now = std::chrono::high_resolution_clock::now(); diff --git a/tests/libslic3r/test_config_variant_expansion.cpp b/tests/libslic3r/test_config_variant_expansion.cpp index 240a6e25fa..40fdce384a 100644 --- a/tests/libslic3r/test_config_variant_expansion.cpp +++ b/tests/libslic3r/test_config_variant_expansion.cpp @@ -799,3 +799,67 @@ TEST_CASE("A per-variant filament option read with a single value gives it to ev config.load_from_ini_string("pressure_advance = 0.021", ForwardCompatibilitySubstitutionRule::Disable); REQUIRE(config.option("pressure_advance")->values == std::vector({0.021, 0.021, 0.021})); } + +// Machine limits (printer_options_with_variant_2) hold a (normal, silent) pair per printer variant, so the +// printer Tab's Motion ability page can edit each extruder's own limits. +TEST_CASE("set_num_extruders gives every printer variant its own pair of machine limits", "[Config]") +{ + DynamicPrintConfig config = DynamicPrintConfig::full_print_config(); + auto speed_x = [&config]() { return config.option("machine_max_speed_x")->values; }; + + SECTION("a new extruder's pair is padded with the first value, like the other variant keys") { + config.option("machine_max_speed_x")->values = {500., 200.}; + config.set_num_extruders(3); + REQUIRE(config.option("printer_extruder_variant")->size() == 3); + REQUIRE(speed_x() == std::vector({500., 200., 500., 500., 500., 500.})); + } + + SECTION("per-extruder pairs are kept, and removing an extruder removes its pair") { + config.option("machine_max_speed_x")->values = {500., 200., 400., 150., 300., 100.}; + config.set_num_extruders(3); + REQUIRE(speed_x() == std::vector({500., 200., 400., 150., 300., 100.})); + config.set_num_extruders(2); + REQUIRE(speed_x() == std::vector({500., 200., 400., 150.})); + } + + SECTION("a printer with nozzle variants gets a pair per variant") { + // 2 extruders x 2 variants each = 4 variants + config.option("extruder_variant_list", true)->values = {"Direct Drive Standard,Direct Drive High Flow", + "Direct Drive Standard,Direct Drive High Flow"}; + const std::vector per_variant = {500., 200., 510., 210., 520., 220., 530., 230.}; + config.option("machine_max_speed_x")->values = per_variant; + config.set_num_extruders(2); + REQUIRE(speed_x() == per_variant); + + config.option("machine_max_speed_x")->values = {500., 200.}; + config.set_num_extruders(2); + REQUIRE(speed_x() == std::vector({500., 200., 500., 500., 500., 500., 500., 500.})); + } +} + +// The device drying options hold several values per filament, as many as each filament preset gives. +TEST_CASE("The device drying options are rebuilt as each filament's values in slot order", "[Config]") +{ + DynamicPrintConfig two_values, one_value, no_value; + two_values.option("filament_dev_ams_drying_ams_limitations", true)->values = {"1", "0"}; + two_values.option("filament_dev_ams_drying_temperature", true)->values = {45., 45., 55., 55.}; + one_value.option("filament_dev_ams_drying_ams_limitations", true)->values = {"1"}; + one_value.option("filament_dev_ams_drying_temperature", true)->values = {65., 65., 75., 75.}; + + // values a project stored for three other filaments + DynamicPrintConfig config; + config.option("filament_dev_ams_drying_ams_limitations", true)->values = {"0", "0", "0"}; + config.option("filament_dev_chamber_drying_time", true)->values = {12., 8., 12.}; + + set_filament_dev_options(config, {&two_values, &one_value, &two_values}); + REQUIRE(config.option("filament_dev_ams_drying_ams_limitations")->values == + std::vector({"1", "0", "1", "1", "0"})); + REQUIRE(config.option("filament_dev_ams_drying_temperature")->values == + std::vector({45., 45., 55., 55., 65., 65., 75., 75., 45., 45., 55., 55.})); + // an option no filament defines keeps the stored values + REQUIRE(config.option("filament_dev_chamber_drying_time")->values == std::vector({12., 8., 12.})); + + // a filament without the option takes the option's default + set_filament_dev_options(config, {&two_values, &no_value}); + REQUIRE(config.option("filament_dev_ams_drying_ams_limitations")->values == std::vector({"1", "0", ""})); +} diff --git a/tests/libslic3r/test_indexed_triangle_set.cpp b/tests/libslic3r/test_indexed_triangle_set.cpp index c65bf589a8..c6e5007c4b 100644 --- a/tests/libslic3r/test_indexed_triangle_set.cpp +++ b/tests/libslic3r/test_indexed_triangle_set.cpp @@ -19,7 +19,6 @@ using namespace Slic3r; TEST_CASE("Split empty mesh", "[its_split][its]") { - using namespace Slic3r; indexed_triangle_set its; @@ -29,7 +28,6 @@ TEST_CASE("Split empty mesh", "[its_split][its]") { } TEST_CASE("Split simple mesh consisting of one part", "[its_split][its]") { - using namespace Slic3r; auto cube = its_make_cube(10., 10., 10.); @@ -53,7 +51,6 @@ void debug_write_obj(const std::vector &res, const std::st } TEST_CASE("Split two non-watertight mesh", "[its_split][its]") { - using namespace Slic3r; auto cube1 = its_make_cube(10., 10., 10.); cube1.indices.pop_back(); @@ -76,7 +73,6 @@ TEST_CASE("Split two non-watertight mesh", "[its_split][its]") { } TEST_CASE("Split non-manifold mesh", "[its_split][its]") { - using namespace Slic3r; auto cube = its_make_cube(10., 10., 10.), cube_low = cube; @@ -96,7 +92,6 @@ TEST_CASE("Split non-manifold mesh", "[its_split][its]") { } TEST_CASE("Split two watertight meshes", "[its_split][its]") { - using namespace Slic3r; auto sphere1 = its_make_sphere(10., 2 * PI / 200.), sphere2 = sphere1; diff --git a/tests/libslic3r/test_marchingsquares.cpp b/tests/libslic3r/test_marchingsquares.cpp index dd6f5dbd97..55dac1e939 100644 --- a/tests/libslic3r/test_marchingsquares.cpp +++ b/tests/libslic3r/test_marchingsquares.cpp @@ -377,7 +377,6 @@ TEST_CASE("10x10 raster with two rings", "[MarchingSquares]") TEST_CASE("Square with hole in the middle", "[MarchingSquares]") { - using namespace Slic3r; ExPolygons inp = {square_with_hole(50.)}; @@ -434,7 +433,6 @@ TEST_CASE("Square with hole in the middle", "[MarchingSquares]") TEST_CASE("Circle with hole in the middle", "[MarchingSquares]") { - using namespace Slic3r; test_expolys(create_raster({1000, 1000}), circle_with_hole(25.), W1x1, "circle_with_hole"); } diff --git a/tests/libslic3r/test_preset_bundle_loading.cpp b/tests/libslic3r/test_preset_bundle_loading.cpp index 7dfba69cbd..e2ff2a2322 100644 --- a/tests/libslic3r/test_preset_bundle_loading.cpp +++ b/tests/libslic3r/test_preset_bundle_loading.cpp @@ -6228,8 +6228,9 @@ TEST_CASE("A per-variant project value maps onto its base preset's variant layou base_finder(&base, calls)); CHECK(config.option("print_extruder_variant")->values == std::vector{"Direct Drive Standard", "Direct Drive High Flow"}); - // The listed key keeps the project's Standard value and takes High Flow from the base. - check_double_vector(config.option("outer_wall_speed")->values, {100., 300.}); + // The listed key keeps the project's Standard value, and High Flow, which the project does not + // list, takes it too, as a user preset's value does. + check_double_vector(config.option("outer_wall_speed")->values, {100., 100.}); check_double_vector(config.option("inner_wall_speed")->values, {250., 350.}); } diff --git a/tests/libslic3r/test_timeutils.cpp b/tests/libslic3r/test_timeutils.cpp index 213b5e6788..9550740fa8 100644 --- a/tests/libslic3r/test_timeutils.cpp +++ b/tests/libslic3r/test_timeutils.cpp @@ -9,8 +9,6 @@ #include #include -using namespace Slic3r; - static void test_time_fmt(Slic3r::Utils::TimeFormat fmt) { using namespace Slic3r::Utils; time_t t = get_current_time_utc(); diff --git a/tests/libslic3r/test_voronoi.cpp b/tests/libslic3r/test_voronoi.cpp index b512fe38fe..a08b84d3eb 100644 --- a/tests/libslic3r/test_voronoi.cpp +++ b/tests/libslic3r/test_voronoi.cpp @@ -29,10 +29,6 @@ #include #endif -using boost::polygon::voronoi_builder; -using boost::polygon::voronoi_diagram; -using boost::polygon::construct_voronoi; - using namespace Slic3r; using VD = Geometry::VoronoiDiagram; diff --git a/tests/slic3rutils/test_network_versions.cpp b/tests/slic3rutils/test_network_versions.cpp index ad352e0bfa..cac2c1543e 100644 --- a/tests/slic3rutils/test_network_versions.cpp +++ b/tests/slic3rutils/test_network_versions.cpp @@ -78,31 +78,34 @@ TEST_CASE("Series and managed classification", "[NetworkVersions]") TEST_CASE_METHOD(PluginFolderFixture, "Managed builds fold into the series; customs are surfaced", "[NetworkVersions]") { - add_plugin("02.08.01.55"); // managed, same series -> folded into the 02.08.01 row + add_plugin("02.08.04.60"); // managed, same series -> folded into the 02.08.04 row add_plugin("02.09.00.10"); // managed, unknown series -> not listed + add_plugin("02.08.01.55"); // managed, series this build no longer has an ABI for -> not listed add_plugin("02.03.00.62"); // managed, older whitelisted series -> folded into 02.03.00 add_plugin("02.01.01.52"); // managed, series with no ABI in this build -> not listed - add_plugin("02.08.01_custom"); // custom, whitelisted series -> listed under it - add_plugin("02.08.01.52-dev"); // custom (dash-suffixed), whitelisted series -> listed + add_plugin("02.08.04_custom"); // custom, whitelisted series -> listed under it + add_plugin("02.08.04.52-dev"); // custom (dash-suffixed), whitelisted series -> listed auto versions = get_all_available_versions(); // The specific managed build never gets its own row - the series represents it. - REQUIRE(count_version(versions, "02.08.01.55") == 0); - REQUIRE(count_version(versions, "02.08.01") == 1); + REQUIRE(count_version(versions, "02.08.04.60") == 0); + REQUIRE(count_version(versions, "02.08.04") == 1); REQUIRE(count_version(versions, "02.09.00.10") == 0); + REQUIRE(count_version(versions, "02.08.01.55") == 0); + REQUIRE(count_version(versions, "02.08.01") == 0); REQUIRE(count_version(versions, "02.03.00.62") == 0); REQUIRE(count_version(versions, "02.03.00") == 1); REQUIRE(count_version(versions, "02.01.01.52") == 0); // Custom-named builds are distinct files kept under their own name. - REQUIRE(count_version(versions, "02.08.01_custom") == 1); - REQUIRE(count_version(versions, "02.08.01.52-dev") == 1); + REQUIRE(count_version(versions, "02.08.04_custom") == 1); + REQUIRE(count_version(versions, "02.08.04.52-dev") == 1); // Newest series first, its customs nested under it (suffix sort: "" < ".52-dev" < "_custom"), // then older series, legacy last. - REQUIRE(versions[0].version == "02.08.01"); - REQUIRE(versions[1].version == "02.08.01.52-dev"); - REQUIRE(versions[2].version == "02.08.01_custom"); + REQUIRE(versions[0].version == "02.08.04"); + REQUIRE(versions[1].version == "02.08.04.52-dev"); + REQUIRE(versions[2].version == "02.08.04_custom"); REQUIRE(versions[3].version == "02.03.00"); REQUIRE(versions.back().version == BAMBU_NETWORK_AGENT_VERSION_LEGACY); @@ -111,9 +114,9 @@ TEST_CASE_METHOD(PluginFolderFixture, "Managed builds fold into the series; cust REQUIRE_FALSE(versions[3].is_latest); // Customs sort/render nested under their series (non-empty suffix, base = the series). - REQUIRE(versions[1].base_version == "02.08.01"); + REQUIRE(versions[1].base_version == "02.08.04"); REQUIRE_FALSE(versions[1].suffix.empty()); - REQUIRE(versions[2].base_version == "02.08.01"); + REQUIRE(versions[2].base_version == "02.08.04"); REQUIRE_FALSE(versions[2].suffix.empty()); // "(Latest)" is the series row, never a nested custom build. @@ -123,20 +126,20 @@ TEST_CASE_METHOD(PluginFolderFixture, "Managed builds fold into the series; cust REQUIRE_FALSE(versions[2].is_latest); // The stored default that drives download and update-check decisions is now the series. - REQUIRE(std::string(get_latest_network_version()) == "02.08.01"); + REQUIRE(std::string(get_latest_network_version()) == "02.08.04"); } TEST_CASE_METHOD(PluginFolderFixture, "Only the loaded series is marked installed", "[NetworkVersions]") { - add_plugin("02.08.01.55"); - add_plugin("02.08.01_custom"); + add_plugin("02.08.04.60"); + add_plugin("02.08.04_custom"); - // The loaded plug-in reports its full build (02.08.01.55); the series row is what gets marked. + // The loaded plug-in reports its full build (02.08.04.60); the series row is what gets marked. { - auto versions = get_all_available_versions("02.08.01.55"); + auto versions = get_all_available_versions("02.08.04.60"); int marked = 0; for (const auto& info : versions) - if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.01"); } + if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.04"); } REQUIRE(marked == 1); } @@ -152,10 +155,10 @@ TEST_CASE_METHOD(PluginFolderFixture, "Only the loaded series is marked installe // A loaded custom build matches its own row, never the bare series. { - auto versions = get_all_available_versions("02.08.01_custom"); + auto versions = get_all_available_versions("02.08.04_custom"); int marked = 0; for (const auto& info : versions) - if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.01_custom"); } + if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.04_custom"); } REQUIRE(marked == 1); } @@ -167,11 +170,11 @@ TEST_CASE_METHOD(PluginFolderFixture, "Only the loaded series is marked installe TEST_CASE("Only whitelisted series pass the load gate", "[NetworkVersions]") { // Each whitelisted series, its builds, and custom-named builds of that series. - REQUIRE(is_supported_network_version("02.08.01")); - REQUIRE(is_supported_network_version("02.08.01.52")); - REQUIRE(is_supported_network_version("02.08.01.55")); - REQUIRE(is_supported_network_version("02.08.01_custom")); - REQUIRE(is_supported_network_version("02.08.01.52-dev")); + REQUIRE(is_supported_network_version("02.08.04")); + REQUIRE(is_supported_network_version("02.08.04.52")); + REQUIRE(is_supported_network_version("02.08.04.60")); + REQUIRE(is_supported_network_version("02.08.04_custom")); + REQUIRE(is_supported_network_version("02.08.04.52-dev")); REQUIRE(is_supported_network_version("02.03.00")); REQUIRE(is_supported_network_version("02.03.00.62")); REQUIRE(is_supported_network_version("02.03.00.70")); @@ -179,6 +182,9 @@ TEST_CASE("Only whitelisted series pass the load gate", "[NetworkVersions]") REQUIRE(is_supported_network_version(BAMBU_NETWORK_AGENT_VERSION_LEGACY)); // Series whitelisted by previous Orca releases that no generation here can call. + REQUIRE_FALSE(is_supported_network_version("02.08.01")); + REQUIRE_FALSE(is_supported_network_version("02.08.01.55")); + REQUIRE_FALSE(is_supported_network_version("02.08.01_custom")); REQUIRE_FALSE(is_supported_network_version("02.01.01.52")); REQUIRE_FALSE(is_supported_network_version("02.00.02.50")); @@ -198,9 +204,9 @@ TEST_CASE("Each version resolves to the ABI generation that can call it", "[Netw { // The generation is keyed on the series, so every build of a series - including the // custom-named ones - resolves to the same one. - CHECK(network_plugin_abi("02.08.01") == NetworkAbi::Current); - CHECK(network_plugin_abi("02.08.01.55") == NetworkAbi::Current); - CHECK(network_plugin_abi("02.08.01.52-dev") == NetworkAbi::Current); + CHECK(network_plugin_abi("02.08.04") == NetworkAbi::Current); + CHECK(network_plugin_abi("02.08.04.60") == NetworkAbi::Current); + CHECK(network_plugin_abi("02.08.04.52-dev") == NetworkAbi::Current); CHECK(network_plugin_abi("02.03.00") == NetworkAbi::V0203); CHECK(network_plugin_abi("02.03.00.62") == NetworkAbi::V0203); CHECK(network_plugin_abi("02.03.00_custom") == NetworkAbi::V0203); @@ -208,6 +214,7 @@ TEST_CASE("Each version resolves to the ABI generation that can call it", "[Netw // Anything the load gate rejects must dispatch through nothing at all, rather than // defaulting to a layout it does not share. + CHECK(network_plugin_abi("02.08.01.55") == NetworkAbi::Unsupported); CHECK(network_plugin_abi("02.01.01.52") == NetworkAbi::Unsupported); CHECK(network_plugin_abi("02.00.02.50") == NetworkAbi::Unsupported); CHECK(network_plugin_abi("02.09.00.10") == NetworkAbi::Unsupported); @@ -234,7 +241,7 @@ TEST_CASE_METHOD(PluginFolderFixture, "Legacy series never adopts discovered bui // With nothing else on disk, the series holds "(Latest)" even though its library is // not installed. for (const auto& info : versions) { - if (info.version == "02.08.01") { + if (info.version == "02.08.04") { REQUIRE(info.is_latest); REQUIRE_FALSE(info.is_loaded); } diff --git a/tests/slic3rutils/test_plugin_sort.cpp b/tests/slic3rutils/test_plugin_sort.cpp index 8af2ce3b5b..2db7911436 100644 --- a/tests/slic3rutils/test_plugin_sort.cpp +++ b/tests/slic3rutils/test_plugin_sort.cpp @@ -13,9 +13,6 @@ using Slic3r::GUI::PluginSortKey; using Slic3r::GUI::PluginSortOrder; using Slic3r::GUI::PluginSource; using Slic3r::GUI::PluginStatus; -using Slic3r::GUI::plugin_sort_key_from_string; -using Slic3r::GUI::plugin_sort_order_from_string; -using Slic3r::GUI::sort_plugin_items_for_dialog; namespace { diff --git a/tests/slic3rutils/test_slicing_pipeline_bindings.cpp b/tests/slic3rutils/test_slicing_pipeline_bindings.cpp index bb29f6d607..d05589b552 100644 --- a/tests/slic3rutils/test_slicing_pipeline_bindings.cpp +++ b/tests/slic3rutils/test_slicing_pipeline_bindings.cpp @@ -144,7 +144,6 @@ TEST_CASE("orca.slicing is workflow-only: context exposes raw print/object; view } #include "libslic3r/PrintConfig.hpp" // DynamicPrintConfig for the psGCodePostProcess context -#include #include #include #include "libslic3r/BoundingBox.hpp" @@ -157,7 +156,6 @@ TEST_CASE("orca.slicing is workflow-only: context exposes raw print/object; view // the export path handed in. Exercising the real bindings by calling the Python execute() directly // (not the C++ audit trampoline) keeps this a pure binding-surface test. TEST_CASE("orca.slicing psGCodePostProcess context: file edit in place + config fallback", "[slicing_pipeline]") { - namespace fs = boost::filesystem; ensure_python_initialized(); import_orca_module(); py::gil_scoped_acquire gil; @@ -237,7 +235,6 @@ struct TestLayerRegion : Slic3r::LayerRegion { // decomposition of an ExtrusionLoop into its contained ExtrusionPath (flatten() // does NOT decompose loops, hence the hand-rolled recursive walk). static void build_nested_perimeters(TestLayerRegion& region) { - using namespace Slic3r; ExtrusionPath pathA(erExternalPerimeter); // -> "Outer wall" pathA.mm3_per_mm = 0.05; pathA.width = 0.45f; pathA.height = 0.20f; pathA.polyline.points = { Point3(0, 0, 0), Point3(10, 0, 0), Point3(10, 10, 0) }; @@ -434,7 +431,6 @@ namespace { // Nested collection: outer -> inner -> [ ExtrusionLoop(pathA), ExtrusionPath(pathB) ]. // Exercises polymorphic downcast of .entities and loop decomposition in flatten_paths(). static Slic3r::ExtrusionEntityCollection build_nested_collection() { - using namespace Slic3r; ExtrusionPath pathA(erExternalPerimeter); // -> "Outer wall" pathA.mm3_per_mm = 0.05; pathA.width = 0.45f; pathA.height = 0.20f; pathA.polyline.points = { Point3(0, 0, 0), Point3(10, 0, 0), Point3(10, 10, 0) };