Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
b587aff
Add Spoolman lane syncing to filament sidebar
lindnjoe Sep 23, 2025
71cfbc8
Merge pull request #2 from lindnjoe/codex/add-lane-syncing-for-loaded…
lindnjoe Sep 23, 2025
80a79e7
Improve Spoolman lane sync metadata
lindnjoe Sep 23, 2025
da0174d
Merge branch 'enh-spoolman-support' into codex/add-lane-syncing-for-l…
lindnjoe Sep 23, 2025
4e82681
Merge pull request #3 from lindnjoe/codex/add-lane-syncing-for-loaded…
lindnjoe Sep 23, 2025
d57e8e5
Guard nightly deploy steps for official repo
lindnjoe Sep 24, 2025
496ccc9
Merge pull request #4 from lindnjoe/codex/update-github-workflows-for…
lindnjoe Sep 24, 2025
821ab3e
Add Spoolman configuration to preferences
lindnjoe Sep 24, 2025
12ed4fd
Merge pull request #5 from lindnjoe/codex/update-github-workflows-for…
lindnjoe Sep 24, 2025
1dda9a1
Include Tab definition for Spoolman preferences
lindnjoe Sep 24, 2025
63ff7b5
Merge pull request #6 from lindnjoe/codex/update-github-workflows-for…
lindnjoe Sep 24, 2025
a222052
Add Spoolman sync control to sidebar
lindnjoe Sep 24, 2025
e9e96e9
Merge pull request #7 from lindnjoe/codex/update-github-workflows-for…
lindnjoe Sep 24, 2025
97c8631
Prefer user presets when syncing Spoolman lanes
lindnjoe Sep 24, 2025
3c657ff
Merge pull request #8 from lindnjoe/codex/update-github-workflows-for…
lindnjoe Sep 24, 2025
c0bbd50
Prefer Spoolman presets by spool id when syncing lanes
lindnjoe Sep 24, 2025
a94cb7f
Merge branch 'enh-spoolman-support' into codex/update-github-workflow…
lindnjoe Sep 24, 2025
c8d0571
Merge pull request #9 from lindnjoe/codex/update-github-workflows-for…
lindnjoe Sep 24, 2025
797a1cd
Include spool ID in imported preset names
lindnjoe Sep 24, 2025
69c534a
Merge branch 'enh-spoolman-support' into codex/update-github-workflow…
lindnjoe Sep 24, 2025
4b1b31b
Merge pull request #10 from lindnjoe/codex/update-github-workflows-fo…
lindnjoe Sep 24, 2025
7ccdef0
Add Spoolman import shortcut button
lindnjoe Sep 25, 2025
7f91e05
Merge branch 'enh-spoolman-support' into codex/update-github-workflow…
lindnjoe Sep 25, 2025
63ac128
Merge pull request #11 from lindnjoe/codex/update-github-workflows-fo…
lindnjoe Sep 25, 2025
649551d
Preserve AMS lanes when Spoolman lanes missing
lindnjoe Sep 26, 2025
5e3ca6d
Merge pull request #12 from lindnjoe/codex/preserve-current-filament-…
lindnjoe Sep 26, 2025
bdb7d8f
Update Spoolman lane detection to query Moonraker
lindnjoe Oct 8, 2025
429af5e
Merge pull request #13 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
1c9e022
Fix lane index allocation for multiple AFC devices
lindnjoe Oct 8, 2025
6a93027
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
710b07a
Merge pull request #14 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
2d31228
Handle Moonraker spool ids with embedded prefixes
lindnjoe Oct 8, 2025
04f49b8
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
2f00d6a
Merge pull request #15 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
2c647a7
Fix Moonraker lane lookup for dotted lane names
lindnjoe Oct 8, 2025
59c8941
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
dca2f0f
Merge pull request #16 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
59449e8
Fix Moonraker lane lookup path
lindnjoe Oct 8, 2025
268871a
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
71358b4
Merge pull request #17 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
7c6e717
Query AFC stepper data when caching Moonraker lanes
lindnjoe Oct 8, 2025
ada88ba
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
e933a6a
Merge pull request #18 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
c6629d1
Handle AFC lanes reported via AFC_stepper
lindnjoe Oct 8, 2025
2a21ff2
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
928d496
Merge pull request #19 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
dea2140
Improve Moonraker lane spool ID detection
lindnjoe Oct 8, 2025
5711711
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
2759a11
Merge pull request #20 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
77d3546
Fix Moonraker query key handling
lindnjoe Oct 8, 2025
58249e3
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 8, 2025
def919c
Merge pull request #21 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 8, 2025
2d45f9e
Query AFC lane objects when building Moonraker cache
lindnjoe Oct 9, 2025
c98d137
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 9, 2025
85665c9
Merge pull request #22 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
b2e1fce
Fix spool ID extraction recursion for MSVC
lindnjoe Oct 9, 2025
ff0adf3
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 9, 2025
955a1a1
Merge pull request #23 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
551efa9
Simplify Moonraker lane cache parsing
lindnjoe Oct 9, 2025
b495803
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 9, 2025
3bd62c6
Merge pull request #24 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
aede9b3
Improve Moonraker lane cache parsing
lindnjoe Oct 9, 2025
585873c
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 9, 2025
22da65e
Merge pull request #26 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
06bbf88
Fix lane index optional handling
lindnjoe Oct 9, 2025
b9f11da
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 9, 2025
1852236
Merge pull request #27 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
3c3498d
Document NSIS requirement for Windows installers
lindnjoe Oct 9, 2025
1656912
Merge pull request #28 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
3ae8020
Preserve Moonraker lane order when caching
lindnjoe Oct 9, 2025
638f9db
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 9, 2025
ef5d895
Merge pull request #29 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
07741b7
Sort Moonraker lanes numerically
lindnjoe Oct 9, 2025
ffb3452
Merge branch 'enh-spoolman-support' into codex/update-orcaslicer-for-…
lindnjoe Oct 9, 2025
a32ac49
Merge pull request #30 from lindnjoe/codex/update-orcaslicer-for-main…
lindnjoe Oct 9, 2025
0f2c7d0
Preserve Spoolman lane alignment when empty
lindnjoe Oct 12, 2025
6290ac6
Merge pull request #31 from lindnjoe/codex/update-filament-sync-logic
lindnjoe Oct 12, 2025
a61c2ca
Preserve AMS lanes when Spoolman omits empty slots
lindnjoe Oct 12, 2025
a63b5b2
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 12, 2025
89c8d9c
Merge pull request #32 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 12, 2025
a7f6e33
Keep AMS lane ordering by slot when syncing
lindnjoe Oct 12, 2025
36082d3
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 12, 2025
40a558b
Merge pull request #33 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 12, 2025
557fbc6
Align AMS sync slots with lane indices
lindnjoe Oct 13, 2025
f9735d2
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
a7ea3c6
Merge pull request #34 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
77afa5f
Preserve AMS lanes when Spoolman reports empty slots
lindnjoe Oct 13, 2025
632a6ff
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
141fda1
Merge pull request #35 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
bd63689
Fix Spoolman lane indexing for AMS sync
lindnjoe Oct 13, 2025
4d59273
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
1172e02
Merge pull request #36 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
71f3839
Preserve AMS lane order while keeping empty slots
lindnjoe Oct 13, 2025
826aae3
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
11dda5b
Merge pull request #37 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
eda58fd
Preserve AMS lane assignments during Spoolman sync
lindnjoe Oct 13, 2025
9a13106
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
f3ec7bf
Merge pull request #38 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
c2e39ab
Preserve AMS lane assignments during sync
lindnjoe Oct 13, 2025
52be8ac
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
a00b3f6
Merge pull request #39 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
6bc8b05
Preserve AMS lane presets when syncing Spoolman lanes
lindnjoe Oct 13, 2025
e94f9b8
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
d9caab2
Merge pull request #40 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
ed39572
Normalize Spoolman lane indices
lindnjoe Oct 13, 2025
5301702
Merge pull request #41 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
92c9289
Preserve AMS lane data during sync
lindnjoe Oct 13, 2025
257b74c
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
32357cb
Merge pull request #42 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
38dc022
Normalize Moonraker lane indices during AMS sync
lindnjoe Oct 13, 2025
35501ba
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
15ae761
Merge pull request #43 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
65fc082
Stabilize AMS lane synchronization
lindnjoe Oct 13, 2025
0913128
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
1ea2df2
Merge pull request #44 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
562685a
Keep AMS lane metadata when Spoolman omits trays
lindnjoe Oct 13, 2025
f4bf275
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
7f8a8ab
Merge pull request #45 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
a4efcd1
Preserve AMS lane order when syncing with Spoolman
lindnjoe Oct 13, 2025
1401565
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
71afc8c
Merge pull request #46 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
0ab34c9
Fix AMS lane config iteration constness
lindnjoe Oct 13, 2025
70ed209
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
f7cffa3
Merge pull request #47 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
74caa37
Preserve AMS lane assignments during sync
lindnjoe Oct 13, 2025
e2f56c7
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
a1e2eca
Merge pull request #48 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
2b0b756
Retain AMS spool IDs when syncing lanes
lindnjoe Oct 13, 2025
8432823
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
2998e8d
Merge pull request #49 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
fb9d32d
Preserve AMS lane assignments when spools missing
lindnjoe Oct 13, 2025
2141be8
Merge branch 'enh-spoolman-support' into codex/update-filament-sync-l…
lindnjoe Oct 13, 2025
e48738d
Merge pull request #50 from lindnjoe/codex/update-filament-sync-logic…
lindnjoe Oct 13, 2025
683b9c8
Revert "Sort Moonraker lane list numerically"
lindnjoe Oct 14, 2025
a0d3c06
Merge pull request #56 from lindnjoe/revert-30-codex/update-orcaslice…
lindnjoe Oct 14, 2025
3a62a0b
Preserve empty Spoolman lanes in filament sync
lindnjoe Oct 19, 2025
2b00a53
Merge pull request #58 from lindnjoe/codex/prevent-filament-reduction…
lindnjoe Oct 19, 2025
53a3491
Fix placeholder handling for unknown Spoolman lanes
lindnjoe Oct 19, 2025
cc85cd5
Merge pull request #59 from lindnjoe/codex/prevent-filament-reduction…
lindnjoe Oct 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ jobs:
with:
name: OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak
path: '/__w/OrcaSlicer/OrcaSlicer/OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak'
- name: Deploy Flatpak to nightly release
if: ${{github.ref == 'refs/heads/main'}}
- name: Deploy Flatpak to nightly release
if: ${{github.ref == 'refs/heads/main' && github.repository == 'SoftFever/OrcaSlicer'}}
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/build_orca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
if-no-files-found: ignore

- name: Deploy Mac release
if: github.ref == 'refs/heads/main' && inputs.os == 'macos-14'
if: github.ref == 'refs/heads/main' && inputs.os == 'macos-14' && github.repository == 'SoftFever/OrcaSlicer'
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label}
Expand All @@ -191,7 +191,7 @@ jobs:
max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted

- name: Deploy Mac OrcaSlicer_profile_validator DMG release
if: github.ref == 'refs/heads/main' && inputs.os == 'macos-14'
if: github.ref == 'refs/heads/main' && inputs.os == 'macos-14' && github.repository == 'SoftFever/OrcaSlicer'
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label}
Expand Down Expand Up @@ -267,7 +267,7 @@ jobs:
path: ${{ github.workspace }}/build/src/Release/OrcaSlicer_profile_validator.exe

- name: Deploy Windows release portable
if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest'
if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' && github.repository == 'SoftFever/OrcaSlicer'
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label}
Expand All @@ -278,7 +278,7 @@ jobs:
max_releases: 1

- name: Deploy Windows release installer
if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest'
if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' && github.repository == 'SoftFever/OrcaSlicer'
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label}
Expand All @@ -289,7 +289,7 @@ jobs:
max_releases: 1

- name: Deploy Windows OrcaSlicer_profile_validator release
if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest'
if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' && github.repository == 'SoftFever/OrcaSlicer'
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label}
Expand Down Expand Up @@ -363,7 +363,7 @@ jobs:
path: './build/src/Release/OrcaSlicer_profile_validator'

- name: Deploy Ubuntu release
if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }}
if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') && github.repository == 'SoftFever/OrcaSlicer' }}
env:
ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }}
uses: WebFreak001/[email protected]
Expand All @@ -384,7 +384,7 @@ jobs:
message: "nightly-builds"

- name: Deploy Ubuntu OrcaSlicer_profile_validator release
if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }}
if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') && github.repository == 'SoftFever/OrcaSlicer' }}
env:
ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }}
uses: WebFreak001/[email protected]
Expand All @@ -397,7 +397,7 @@ jobs:
max_releases: 1

- name: Deploy orca_custom_preset_tests
if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-24.04' }}
if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-24.04' && github.repository == 'SoftFever/OrcaSlicer' }}
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label}
Expand Down
4 changes: 4 additions & 0 deletions doc/developer-reference/How-to-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ How to building with Visual Studio 2022 on Windows 64-bit.
```shell
winget install --id=GitHub.GitLFS -e
```
- [NSIS](https://nsis.sourceforge.io/) (required to create the Windows installer with `cpack -G NSIS`)
```shell
winget install --id=NSIS.NSIS -e
```

> [!TIP]
> GitHub Desktop (optional): A GUI for Git and Git LFS, which already includes both tools.
Expand Down
10 changes: 10 additions & 0 deletions resources/images/spoolman_import.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions resources/images/spoolman_sync.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
187 changes: 152 additions & 35 deletions src/libslic3r/PresetBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,63 +1880,180 @@ void PresetBundle::set_num_filaments(unsigned int n, std::string new_color)

unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns)
{
std::vector<std::string> filament_presets;
std::vector<std::string> filament_colors;
ams_multi_color_filment.clear();
for (auto &entry : filament_ams_list) {
auto & ams = entry.second;
auto filament_id = ams.opt_string("filament_id", 0u);
auto filament_color = ams.opt_string("filament_colour", 0u);
auto filament_changed = !ams.has("filament_changed") || ams.opt_bool("filament_changed");
auto filament_multi_color = ams.opt<ConfigOptionStrings>("filament_multi_colors")->values;
if (filament_id.empty()) continue;
if (!filament_changed && this->filament_presets.size() > filament_presets.size()) {
filament_presets.push_back(this->filament_presets[filament_presets.size()]);
filament_colors.push_back(filament_color);
ams_multi_color_filment.push_back(filament_multi_color);
const std::vector<std::string> previous_presets = this->filament_presets;
ConfigOptionStrings *filament_color_opt = project_config.option<ConfigOptionStrings>("filament_colour");
std::vector<std::string> previous_colors = filament_color_opt ? filament_color_opt->values : std::vector<std::string>();
std::vector<std::vector<std::string>> previous_multi = ams_multi_color_filment;
ConfigOptionInts *spool_id_opt = project_config.option<ConfigOptionInts>("spoolman_spool_id", true);
std::vector<int> previous_spool_ids = spool_id_opt ? spool_id_opt->values : std::vector<int>();

if (previous_colors.size() < previous_presets.size())
previous_colors.resize(previous_presets.size());
if (previous_multi.size() < previous_presets.size())
previous_multi.resize(previous_presets.size());
if (previous_spool_ids.size() < previous_presets.size())
previous_spool_ids.resize(previous_presets.size());

size_t lane_count = previous_presets.size();
int max_lane = -1;
for (const auto &entry : filament_ams_list) {
const int lane_key = entry.first;
if (lane_key < 0)
continue;
const auto tray_name = entry.second.opt_string("tray_name", 0u);
if (tray_name == "Ext")
continue;
max_lane = std::max(max_lane, lane_key);
}

if (max_lane >= 0)
lane_count = std::max(lane_count, static_cast<size_t>(max_lane) + 1);

if (lane_count == 0) {
this->filament_presets.clear();
ams_multi_color_filment.clear();
if (filament_color_opt)
filament_color_opt->values.clear();
if (spool_id_opt)
spool_id_opt->values.clear();
update_multi_material_filament_presets();
return 0;
}

std::vector<std::string> filament_presets = previous_presets;
filament_presets.resize(lane_count);
std::vector<std::string> filament_colors = previous_colors;
filament_colors.resize(lane_count);
std::vector<std::vector<std::string>> lane_multi_colors = previous_multi;
lane_multi_colors.resize(lane_count);
std::vector<int> lane_spool_ids = previous_spool_ids;
lane_spool_ids.resize(lane_count);

auto restore_previous = [&](size_t lane_index) {
if (lane_index < previous_presets.size())
filament_presets[lane_index] = previous_presets[lane_index];
if (lane_index < previous_colors.size())
filament_colors[lane_index] = previous_colors[lane_index];
if (lane_index < previous_multi.size())
lane_multi_colors[lane_index] = previous_multi[lane_index];
if (lane_index < previous_spool_ids.size())
lane_spool_ids[lane_index] = previous_spool_ids[lane_index];
};

for (const auto &entry : filament_ams_list) {
const int lane_key = entry.first;
if (lane_key < 0)
continue;

const size_t lane_index = static_cast<size_t>(lane_key);
if (lane_index >= lane_count)
continue;

const auto tray_name = entry.second.opt_string("tray_name", 0u);
if (tray_name == "Ext")
continue;

const DynamicPrintConfig &lane_cfg = entry.second;
std::string filament_id = lane_cfg.opt_string("filament_id", 0u);
bool filament_exists = !filament_id.empty();
if (lane_cfg.has("filament_exist"))
filament_exists = filament_exists && lane_cfg.opt_bool("filament_exist");

if (!filament_exists) {
restore_previous(lane_index);
continue;
}
auto iter = std::find_if(filaments.begin(), filaments.end(), [this, &filament_id](auto &f) {
return f.is_compatible && filaments.get_preset_base(f) == &f && f.filament_id == filament_id; });

const std::string filament_color = lane_cfg.opt_string("filament_colour", 0u);
if (!filament_color.empty())
filament_colors[lane_index] = filament_color;

const auto *multi_color_opt = lane_cfg.opt<ConfigOptionStrings>("filament_multi_colors");
const std::vector<std::string> filament_multi_color = multi_color_opt ? multi_color_opt->values : std::vector<std::string>();
if (multi_color_opt != nullptr)
lane_multi_colors[lane_index] = filament_multi_color;

const int spoolman_spool_id = lane_cfg.opt_int("spoolman_spool_id", 0u);
if (lane_index < lane_spool_ids.size())
lane_spool_ids[lane_index] = spoolman_spool_id;

const bool filament_changed = !lane_cfg.has("filament_changed") || lane_cfg.opt_bool("filament_changed");
if (!filament_changed) {
restore_previous(lane_index);
continue;
}

auto find_preset = [&](bool user_only, bool by_spool_id) {
return std::find_if(filaments.begin(), filaments.end(), [&](auto &f) {
if (!f.is_compatible)
return false;
if (user_only && !f.is_user())
return false;

if (by_spool_id)
return spoolman_spool_id > 0 && f.config.opt_int("spoolman_spool_id", 0) == spoolman_spool_id;

return f.filament_id == filament_id;
});
};

auto iter = filaments.end();
if (spoolman_spool_id > 0) {
iter = find_preset(true, true);
if (iter == filaments.end())
iter = find_preset(false, true);
}
if (iter == filaments.end()) {
iter = find_preset(true, false);
if (iter == filaments.end())
iter = find_preset(false, false);
}

if (iter == filaments.end()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;
auto filament_type = ams.opt_string("filament_type", 0u);
auto filament_type = lane_cfg.opt_string("filament_type", 0u);
if (!filament_type.empty()) {
filament_type = "Generic " + filament_type;
iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) {
return f.is_compatible && f.is_system
&& boost::algorithm::starts_with(f.name, filament_type);
iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) {
return f.is_compatible && f.is_system && boost::algorithm::starts_with(f.name, filament_type);
});
}
if (iter == filaments.end()) {
// Prefer old selection
if (filament_presets.size() < this->filament_presets.size()) {
filament_presets.push_back(this->filament_presets[filament_presets.size()]);
filament_colors.push_back(filament_color);
restore_previous(lane_index);
if (lane_index < previous_presets.size() && !previous_presets[lane_index].empty()) {
++unknowns;
if (!filament_color.empty())
filament_colors[lane_index] = filament_color;
if (multi_color_opt != nullptr)
lane_multi_colors[lane_index] = filament_multi_color;
continue;
}
iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) {
return f.is_compatible && f.is_system;
return f.is_compatible && f.is_system;
});
if (iter == filaments.end())
if (iter == filaments.end()) {
continue;
}
}
++unknowns;
filament_id = iter->filament_id;
}
filament_presets.push_back(iter->name);
filament_colors.push_back(filament_color);
ams_multi_color_filment.push_back(filament_multi_color);

filament_presets[lane_index] = iter->name;
}
if (filament_presets.empty())
return 0;

this->filament_presets = filament_presets;
ConfigOptionStrings *filament_color = project_config.option<ConfigOptionStrings>("filament_colour");
filament_color->resize(filament_presets.size());
filament_color->values = filament_colors;
if (filament_color_opt) {
filament_color_opt->resize(filament_presets.size());
filament_color_opt->values = filament_colors;
}
if (spool_id_opt) {
spool_id_opt->resize(filament_presets.size());
spool_id_opt->values = lane_spool_ids;
}
ams_multi_color_filment = std::move(lane_multi_colors);
update_multi_material_filament_presets();
return filament_presets.size();
return this->filament_presets.size();
}

void PresetBundle::set_calibrate_printer(std::string name)
Expand Down
Loading