mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-03 15:44:34 +03:00
Compare commits
20 Commits
fix/profil
...
fix/log-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
331ac6adf7 | ||
|
|
adc8763099 | ||
|
|
036bd7bcec | ||
|
|
d24e7f75ef | ||
|
|
0f88b88f3b | ||
|
|
464a81d585 | ||
|
|
4c58d0adf8 | ||
|
|
ce6c2ec7ce | ||
|
|
dbe99d0d6f | ||
|
|
66b9a9b830 | ||
|
|
f3c3f6861b | ||
|
|
5bccc25705 | ||
|
|
a6ccbced03 | ||
|
|
c7b28565ef | ||
|
|
66b3e27af3 | ||
|
|
3bc2c51fe9 | ||
|
|
187beb68c3 | ||
|
|
7d62ded630 | ||
|
|
43a83397d4 | ||
|
|
ced980e6a8 |
2
.github/workflows/auto-close-duplicates.yml
vendored
2
.github/workflows/auto-close-duplicates.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
|
||||
8
.github/workflows/build_all.yml
vendored
8
.github/workflows/build_all.yml
vendored
@@ -131,7 +131,7 @@ jobs:
|
||||
if: ${{ !cancelled() && success() }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
sparse-checkout: |
|
||||
.github
|
||||
@@ -204,7 +204,7 @@ jobs:
|
||||
- name: "Remove unneeded stuff to free disk space"
|
||||
run:
|
||||
rm -rf /usr/local/lib/android/* /usr/share/dotnet/* /opt/ghc1/* "/usr/local/share/boost1/*" /opt/hostedtoolcache1/*
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
- name: Get the version and date
|
||||
run: |
|
||||
ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2)
|
||||
@@ -223,14 +223,14 @@ jobs:
|
||||
# Manage flatpak-builder cache externally so PRs restore but never upload
|
||||
- name: Restore flatpak-builder cache
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/cache/restore@v5
|
||||
uses: actions/cache/restore@v6
|
||||
with:
|
||||
path: .flatpak-builder
|
||||
key: flatpak-builder-${{ matrix.variant.arch }}-${{ github.event.pull_request.base.sha }}
|
||||
restore-keys: flatpak-builder-${{ matrix.variant.arch }}-
|
||||
- name: Save/restore flatpak-builder cache
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: .flatpak-builder
|
||||
key: flatpak-builder-${{ matrix.variant.arch }}-${{ github.sha }}
|
||||
|
||||
4
.github/workflows/build_check_cache.yml
vendored
4
.github/workflows/build_check_cache.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
valid-cache: ${{ steps.cache_deps.outputs.cache-hit }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
lfs: 'false'
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
|
||||
- name: load cache
|
||||
id: cache_deps
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: ${{ steps.set_outputs.outputs.cache-path }}
|
||||
key: ${{ steps.set_outputs.outputs.cache-key }}
|
||||
|
||||
4
.github/workflows/build_deps.yml
vendored
4
.github/workflows/build_deps.yml
vendored
@@ -34,12 +34,12 @@ jobs:
|
||||
|
||||
# Setup the environment
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
lfs: 'false'
|
||||
|
||||
- name: load cached deps
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: ${{ inputs.cache-path }}
|
||||
key: ${{ inputs.cache-key }}
|
||||
|
||||
4
.github/workflows/build_orca.yml
vendored
4
.github/workflows/build_orca.yml
vendored
@@ -37,13 +37,13 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
lfs: 'false'
|
||||
|
||||
- name: load cached deps
|
||||
if: ${{ !(runner.os == 'macOS' && inputs.macos-combine-only) }}
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: ${{ inputs.cache-path }}
|
||||
key: ${{ inputs.cache-key }}
|
||||
|
||||
2
.github/workflows/check_locale.yml
vendored
2
.github/workflows/check_locale.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Install gettext
|
||||
run: |
|
||||
|
||||
102
.github/workflows/check_profiles.yml
vendored
102
.github/workflows/check_profiles.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Run extra JSON check
|
||||
id: extra_json_check
|
||||
@@ -77,11 +77,101 @@ jobs:
|
||||
continue-on-error: true
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: |
|
||||
set +e
|
||||
curl -LJO https://github.com/OrcaSlicer/OrcaSlicer/releases/download/nightly-builds/orca_custom_preset_tests.zip
|
||||
unzip -q ./orca_custom_preset_tests.zip -d ${{ github.workspace }}/resources/profiles
|
||||
./OrcaSlicer_profile_validator -p ${{ github.workspace }}/resources/profiles -l 2 2>&1 | tee ${{ runner.temp }}/validate_custom.log
|
||||
exit ${PIPESTATUS[0]}
|
||||
fixtures_dir="${{ runner.temp }}/profile-fixtures"
|
||||
output_dir="${{ runner.temp }}/custom-preset-validation"
|
||||
combined_log="${{ runner.temp }}/validate_custom.log"
|
||||
summary="${output_dir}/summary.md"
|
||||
release_url="https://github.com/OrcaSlicer/OrcaSlicer-profile-validator/releases/download/fixture-archive"
|
||||
|
||||
rm -rf "${fixtures_dir}" "${output_dir}"
|
||||
mkdir -p "${fixtures_dir}" "${output_dir}"
|
||||
|
||||
curl -fsSL -o "${fixtures_dir}/manifest.json" "${release_url}/manifest.json"
|
||||
|
||||
MANIFEST_PATH="${fixtures_dir}/manifest.json" python3 <<'PY' > "${fixtures_dir}/fixtures.tsv"
|
||||
import json
|
||||
import os
|
||||
|
||||
with open(os.environ["MANIFEST_PATH"], encoding="utf-8") as fh:
|
||||
manifest = json.load(fh)
|
||||
|
||||
if isinstance(manifest, dict):
|
||||
entries = manifest.get("fixtures", [])
|
||||
else:
|
||||
entries = manifest
|
||||
|
||||
for entry in entries:
|
||||
version = entry.get("version", "")
|
||||
asset = entry.get("asset", "")
|
||||
sha256 = entry.get("asset_sha256", "")
|
||||
if not version or not asset:
|
||||
continue
|
||||
print(f"{version}\t{asset}\t{sha256}")
|
||||
PY
|
||||
|
||||
if [ ! -s "${fixtures_dir}/fixtures.tsv" ]; then
|
||||
echo "No custom preset fixtures found in ${release_url}/manifest.json" | tee "${combined_log}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
{
|
||||
echo "## Custom Preset Fixture Validation"
|
||||
echo ""
|
||||
echo "| Version | Status | Log |"
|
||||
echo "| --- | --- | --- |"
|
||||
} > "${summary}"
|
||||
|
||||
status=0
|
||||
failed_logs=()
|
||||
|
||||
while IFS=$'\t' read -r version asset expected_sha256; do
|
||||
fixture_zip="${fixtures_dir}/${asset}"
|
||||
asset_url_name="$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "${asset}")"
|
||||
profile_tree="${output_dir}/profiles-${version}"
|
||||
log_path="${output_dir}/${version}.log"
|
||||
|
||||
curl -fsSL -o "${fixture_zip}" "${release_url}/${asset_url_name}"
|
||||
|
||||
if [ -n "${expected_sha256}" ] && [ "${expected_sha256}" != "<sha256>" ]; then
|
||||
echo "${expected_sha256} ${fixture_zip}" | sha256sum -c -
|
||||
fi
|
||||
|
||||
rm -rf "${profile_tree}"
|
||||
mkdir -p "${profile_tree}"
|
||||
cp -a "${{ github.workspace }}/resources/profiles/." "${profile_tree}/"
|
||||
rm -rf "${profile_tree}/user"
|
||||
unzip -q "${fixture_zip}" -d "${profile_tree}"
|
||||
|
||||
set +e
|
||||
./OrcaSlicer_profile_validator -p "${profile_tree}" -l 2 > "${log_path}" 2>&1
|
||||
result=$?
|
||||
set -e
|
||||
|
||||
if [ "${result}" -eq 0 ]; then
|
||||
echo "| ${version} | PASS | ${version}.log |" >> "${summary}"
|
||||
else
|
||||
echo "| ${version} | FAIL | ${version}.log |" >> "${summary}"
|
||||
failed_logs+=("${log_path}")
|
||||
status=1
|
||||
fi
|
||||
done < "${fixtures_dir}/fixtures.tsv"
|
||||
|
||||
{
|
||||
cat "${summary}"
|
||||
if [ "${#failed_logs[@]}" -gt 0 ]; then
|
||||
echo ""
|
||||
echo "## Failed Fixture Logs"
|
||||
for log_path in "${failed_logs[@]}"; do
|
||||
echo ""
|
||||
echo "### $(basename "${log_path}" .log)"
|
||||
echo '```'
|
||||
head -c 12000 "${log_path}" || echo "No output captured"
|
||||
echo '```'
|
||||
done
|
||||
fi
|
||||
} | tee "${combined_log}"
|
||||
|
||||
exit "${status}"
|
||||
|
||||
- name: Prepare PR number for comment workflow
|
||||
if: ${{ always() && github.event_name == 'pull_request' }}
|
||||
|
||||
2
.github/workflows/dedupe-issues.yml
vendored
2
.github/workflows/dedupe-issues.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Run Claude Code slash command
|
||||
uses: anthropics/claude-code-base-action@beta
|
||||
|
||||
2
.github/workflows/doxygen-docs.yml
vendored
2
.github/workflows/doxygen-docs.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
remove-existing-swap-files: true
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Install Doxygen and Graphviz
|
||||
run: |
|
||||
|
||||
4
.github/workflows/shellcheck.yml
vendored
4
.github/workflows/shellcheck.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
steps:
|
||||
- name: Cache shellcheck download
|
||||
id: cache-shellcheck-v0_11
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: ~/shellcheck
|
||||
key: ${{ runner.os }}-shellcheck-v0_11
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
tar -xvf ~/sc.tar.xz -C ~
|
||||
mv ~/shellcheck-"${INPUT_VERSION}"/shellcheck ~/shellcheck
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
|
||||
2
.github/workflows/update-translation.yml
vendored
2
.github/workflows/update-translation.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v6
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.20mm Optimal 0.6 nozzle @Anker",
|
||||
"renamed_from": "0.20mm Optimal 0.6 nozzle @Anker.json",
|
||||
"inherits": "fdm_process_anker_common_0_6",
|
||||
"from": "system",
|
||||
"setting_id": "re5qmcOFJ1OJP3Ip",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Bambu PLA Tough @BBL X1C",
|
||||
"renamed_from": "Bambu PLA Impact @BBL X1C",
|
||||
"inherits": "Bambu PLA Tough @base",
|
||||
"from": "system",
|
||||
"setting_id": "GFSA09_02",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Panchroma PLA Satin @BBL A1",
|
||||
"renamed_from": "Panchroma PLA Stain @BBL A1",
|
||||
"inherits": "Panchroma PLA Satin @base",
|
||||
"from": "system",
|
||||
"setting_id": "GFSPM005_00",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Panchroma PLA Satin @BBL A1M",
|
||||
"renamed_from": "Panchroma PLA Stain @BBL A1M",
|
||||
"inherits": "Panchroma PLA Satin @base",
|
||||
"from": "system",
|
||||
"setting_id": "GFSPM005_02",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Panchroma PLA Satin @BBL P1P",
|
||||
"renamed_from": "Panchroma PLA Stain @BBL P1P",
|
||||
"inherits": "Panchroma PLA Satin @base",
|
||||
"from": "system",
|
||||
"setting_id": "GFSPM005_04",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Panchroma PLA Satin @BBL X1",
|
||||
"renamed_from": "Panchroma PLA Stain @BBL X1",
|
||||
"inherits": "Panchroma PLA Satin @base",
|
||||
"from": "system",
|
||||
"setting_id": "GFSPM005_06",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.20mm Standard @BBL X1C",
|
||||
"renamed_from": "0.20mm Bambu Support W @BBL X1C",
|
||||
"inherits": "fdm_process_single_0.20",
|
||||
"from": "system",
|
||||
"setting_id": "GP004",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.12mm Fine @Creality Ender3V3SE 0.4",
|
||||
"renamed_from": "0.12mm Fine @Creality Ender3V3SE",
|
||||
"inherits": "fdm_process_creality_common",
|
||||
"from": "system",
|
||||
"setting_id": "W68mSPdmat2rCXuD",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.16mm Optimal @Creality Ender3V3SE 0.4",
|
||||
"renamed_from": "0.16mm Optimal @Creality Ender3V3SE",
|
||||
"inherits": "fdm_process_creality_common",
|
||||
"from": "system",
|
||||
"setting_id": "jvnrh3jh6Btbs1Ja",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.20mm Standard @Creality Ender3V3SE 0.4",
|
||||
"renamed_from": "0.20mm Standard @Creality Ender3V3SE",
|
||||
"inherits": "fdm_process_creality_common",
|
||||
"from": "system",
|
||||
"setting_id": "YLkw9eyyK7cm97ek",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.20mm Standard @Creality K1 SE",
|
||||
"renamed_from": "0.20mm Fast @Creality K1 SE 0.4",
|
||||
"inherits": "fdm_process_creality_common",
|
||||
"from": "system",
|
||||
"setting_id": "eR9pRC1qPENNx8U9",
|
||||
@@ -264,4 +265,4 @@
|
||||
"wipe_tower_extra_spacing": "100%",
|
||||
"wipe_tower_rotation_angle": "0",
|
||||
"wiping_volumes_extruders": "70,70,70,70,70,70,70,70,70,70"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.24mm Draft @Creality Ender3V3SE 0.4",
|
||||
"renamed_from": "0.24mm Draft @Creality Ender3V3SE",
|
||||
"inherits": "fdm_process_creality_common",
|
||||
"from": "system",
|
||||
"setting_id": "Hg10EUNCLMEYYBN1",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.48mm Draft @Creality K1C",
|
||||
"renamed_from": "0.48mm Draft @Creality K1C (0.8 nozzle)",
|
||||
"inherits": "fdm_process_common_klipper",
|
||||
"from": "system",
|
||||
"setting_id": "qaiff3f8gSQ1GVj1",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"type": "filament",
|
||||
"setting_id": "pKzSR8XeyyUDbrNW",
|
||||
"name": "Generic PETG PRO @Elegoo",
|
||||
"renamed_from": "Elegoo Generic PETG PRO",
|
||||
"from": "system",
|
||||
"instantiation": "true",
|
||||
"inherits": "Generic PETG @base",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Ginger Generic PETG",
|
||||
"renamed_from": "Ginger Generic rPETG",
|
||||
"inherits": "fdm_filament_common",
|
||||
"from": "system",
|
||||
"setting_id": "ue95N2e65rdp5K6c",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Ginger Generic PLA",
|
||||
"renamed_from": "Ginger Generic rPLA",
|
||||
"inherits": "fdm_filament_common",
|
||||
"from": "system",
|
||||
"setting_id": "Z1scjKDBFoDaTa2C",
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
"5"
|
||||
],
|
||||
"compatible_printers": [],
|
||||
"renamed_from": "Elegoo PETG PRO"
|
||||
"renamed_from": "Elegoo PETG PRO;Elegoo PETG Pro @System"
|
||||
}
|
||||
|
||||
@@ -33,5 +33,5 @@
|
||||
"250"
|
||||
],
|
||||
"compatible_printers": [],
|
||||
"renamed_from": "Elegoo Rapid PETG;Elegoo Rapid PETG+"
|
||||
"renamed_from": "Elegoo Rapid PETG;Elegoo Rapid PETG+;Elegoo RAPID PETG;Elegoo RAPID PETG+"
|
||||
}
|
||||
|
||||
@@ -45,5 +45,5 @@
|
||||
"; filament start gcode\n{if (bed_temperature[current_extruder] >55)||(bed_temperature_initial_layer[current_extruder] >55)}M106 P3 S200\n{elsif(bed_temperature[current_extruder] >50)||(bed_temperature_initial_layer[current_extruder] >50)}M106 P3 S150\n{elsif(bed_temperature[current_extruder] >45)||(bed_temperature_initial_layer[current_extruder] >45)}M106 P3 S50\n{endif}\n\n{if activate_air_filtration[current_extruder] && support_air_filtration}\nM106 P3 S{during_print_exhaust_fan_speed_num[current_extruder]} \n{endif}"
|
||||
],
|
||||
"compatible_printers": [],
|
||||
"renamed_from": "Elegoo Rapid PLA+"
|
||||
"renamed_from": "Elegoo Rapid PLA+;Elegoo RAPID PLA+"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Peopoly Generic PLA",
|
||||
"renamed_from": "Peopoly Generic PLA 0.8 nozzle",
|
||||
"inherits": "fdm_filament_pla",
|
||||
"from": "system",
|
||||
"setting_id": "KNsVV4dvEWAAkzDE",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"type": "filament",
|
||||
"name": "Snapmaker PLA",
|
||||
"renamed_from": "PolyLite PLA",
|
||||
"inherits": "Snapmaker PLA @base",
|
||||
"from": "system",
|
||||
"setting_id": "cW1b4nGxE9yXIXJP",
|
||||
|
||||
@@ -206,6 +206,10 @@
|
||||
"name": "0.24mm Fine 0.8 nozzle @Voron",
|
||||
"sub_path": "process/0.24mm Fine 0.8 nozzle @Voron.json"
|
||||
},
|
||||
{
|
||||
"name": "0.32mm Optimal 0.8 nozzle @Voron",
|
||||
"sub_path": "process/0.32mm Optimal 0.8 nozzle @Voron.json"
|
||||
},
|
||||
{
|
||||
"name": "0.40mm Standard 0.8 nozzle @Voron",
|
||||
"sub_path": "process/0.40mm Standard 0.8 nozzle @Voron.json"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": "process",
|
||||
"name": "0.32mm Optimal 0.8 nozzle @Voron",
|
||||
"inherits": "fdm_process_voron_common_0_8",
|
||||
"from": "system",
|
||||
"setting_id": "ivS6U4AuIoj1cJhZ",
|
||||
"instantiation": "true",
|
||||
"bottom_shell_layers": "3",
|
||||
"top_shell_layers": "3",
|
||||
"layer_height": "0.32"
|
||||
}
|
||||
@@ -184,9 +184,12 @@ if (WIN32)
|
||||
if(MSVC)
|
||||
target_link_options(OrcaSlicer_app_gui PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
|
||||
endif()
|
||||
target_compile_definitions(OrcaSlicer_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE)
|
||||
target_compile_definitions(OrcaSlicer_app_gui PRIVATE "$<$<NOT:$<CONFIG:RelWithDebInfo>>:SLIC3R_WRAPPER_NOCONSOLE>")
|
||||
add_dependencies(OrcaSlicer_app_gui OrcaSlicer)
|
||||
set_target_properties(OrcaSlicer_app_gui PROPERTIES OUTPUT_NAME "orca-slicer")
|
||||
set_target_properties(OrcaSlicer_app_gui PROPERTIES
|
||||
OUTPUT_NAME "orca-slicer"
|
||||
WIN32_EXECUTABLE "$<NOT:$<CONFIG:RelWithDebInfo>>"
|
||||
)
|
||||
target_link_libraries(OrcaSlicer_app_gui PRIVATE boost_headeronly)
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -534,6 +534,7 @@ endif ()
|
||||
encoding_check(libslic3r)
|
||||
|
||||
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB -DTBB_USE_CAPTURED_EXCEPTION=0)
|
||||
target_compile_definitions(libslic3r PRIVATE $<$<CONFIG:RelWithDebInfo>:SLIC3R_CONSOLE_LOG>)
|
||||
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(libslic3r SYSTEM PUBLIC ${EXPAT_INCLUDE_DIRS})
|
||||
|
||||
|
||||
@@ -836,9 +836,11 @@ namespace client
|
||||
static std::map<std::string, std::string> tag_to_error_message;
|
||||
|
||||
size_t get_extruder_id() const {
|
||||
const ConfigOptionInts * filament_map_opt = external_config->option<ConfigOptionInts>("filament_map");
|
||||
if (filament_map_opt && current_extruder_id < filament_map_opt->values.size()) {
|
||||
return filament_map_opt->values[current_extruder_id];
|
||||
if (external_config != nullptr) {
|
||||
const ConfigOptionInts * filament_map_opt = external_config->option<ConfigOptionInts>("filament_map");
|
||||
if (filament_map_opt && current_extruder_id < filament_map_opt->values.size()) {
|
||||
return filament_map_opt->values[current_extruder_id];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1096,27 +1098,109 @@ namespace client
|
||||
const ConfigOptionVectorBase* vec = static_cast<const ConfigOptionVectorBase*>(opt.opt);
|
||||
if (vec->empty())
|
||||
ctx->throw_exception("Indexing an empty vector variable", opt.it_range);
|
||||
|
||||
// Helper to resolve a FloatOrPercent value (handles ratio_over chain for percent values).
|
||||
// elem_index: the element index used to access this vector element, so that
|
||||
// parent vectors (via ratio_over) use the same index rather than the current extruder.
|
||||
auto resolve_float_or_percent = [ctx, &opt, &output](const FloatOrPercent &fop, size_t elem_index) {
|
||||
std::string opt_key(opt.it_range.begin(), opt.it_range.end());
|
||||
if (boost::ends_with(opt_key, "line_width")) {
|
||||
// Line width supports defaults and a complex graph of dependencies.
|
||||
output.set_d(Flow::extrusion_width(opt_key, *ctx, static_cast<unsigned int>(ctx->current_extruder_id)));
|
||||
} else if (! fop.percent) {
|
||||
// Not a percent, just return the value.
|
||||
output.set_d(fop.value);
|
||||
} else {
|
||||
// Resolve dependencies using the "ratio_over" link to a parent value.
|
||||
const ConfigOptionDef *opt_def = print_config_def.get(opt_key);
|
||||
assert(opt_def != nullptr);
|
||||
double v = fop.value * 0.01; // percent to ratio
|
||||
for (;;) {
|
||||
const ConfigOption *opt_parent = opt_def->ratio_over.empty() ? nullptr : ctx->resolve_symbol(opt_def->ratio_over);
|
||||
if (opt_parent == nullptr)
|
||||
ctx->throw_exception("FloatOrPercent variable failed to resolve the \"ratio_over\" dependencies", opt.it_range);
|
||||
if (boost::ends_with(opt_def->ratio_over, "line_width")) {
|
||||
// Line width supports defaults and a complex graph of dependencies.
|
||||
assert(opt_parent->type() == coFloatOrPercent);
|
||||
v *= Flow::extrusion_width(opt_def->ratio_over, static_cast<const ConfigOptionFloatOrPercent*>(opt_parent), *ctx, static_cast<unsigned int>(ctx->current_extruder_id));
|
||||
break;
|
||||
}
|
||||
if (opt_parent->type() == coFloat || opt_parent->type() == coFloatOrPercent) {
|
||||
v *= opt_parent->getFloat();
|
||||
if (opt_parent->type() == coFloat || ! static_cast<const ConfigOptionFloatOrPercent*>(opt_parent)->percent)
|
||||
break;
|
||||
v *= 0.01; // percent to ratio
|
||||
} else if (opt_parent->type() == coFloats) {
|
||||
// Vector parent: extract the value for the current extruder.
|
||||
const ConfigOptionFloatsNullable *parent_nullable = dynamic_cast<const ConfigOptionFloatsNullable *>(opt_parent);
|
||||
if (parent_nullable) {
|
||||
v *= (parent_nullable->size() == 1) ? parent_nullable->get_at(0) : parent_nullable->get_at(elem_index);
|
||||
} else {
|
||||
const ConfigOptionFloats *parent_vec = static_cast<const ConfigOptionFloats *>(opt_parent);
|
||||
v *= (parent_vec->size() == 1) ? parent_vec->get_at(0) : parent_vec->get_at(elem_index);
|
||||
}
|
||||
break;
|
||||
} else if (opt_parent->type() == coFloatsOrPercents) {
|
||||
// Vector parent with percent support: extract the FloatOrPercent for the current extruder.
|
||||
const ConfigOptionFloatsOrPercentsNullable *parent_nullable = dynamic_cast<const ConfigOptionFloatsOrPercentsNullable *>(opt_parent);
|
||||
if (parent_nullable) {
|
||||
const FloatOrPercent &parent_fop = (parent_nullable->size() == 1) ? parent_nullable->get_at(0) : parent_nullable->get_at(elem_index);
|
||||
if (! parent_fop.percent) {
|
||||
v *= parent_fop.value;
|
||||
break;
|
||||
}
|
||||
v *= parent_fop.value * 0.01; // percent to ratio
|
||||
} else {
|
||||
const ConfigOptionFloatsOrPercents *parent_vec = static_cast<const ConfigOptionFloatsOrPercents *>(opt_parent);
|
||||
const FloatOrPercent &parent_fop = (parent_vec->size() == 1) ? parent_vec->get_at(0) : parent_vec->get_at(elem_index);
|
||||
if (! parent_fop.percent) {
|
||||
v *= parent_fop.value;
|
||||
break;
|
||||
}
|
||||
v *= parent_fop.value * 0.01; // percent to ratio
|
||||
}
|
||||
}
|
||||
// Continue one level up in the "ratio_over" hierarchy.
|
||||
opt_def = print_config_def.get(opt_def->ratio_over);
|
||||
assert(opt_def != nullptr);
|
||||
}
|
||||
output.set_d(v);
|
||||
}
|
||||
};
|
||||
|
||||
if (!opt.has_index()) {
|
||||
// Allow omitting extruder id when referencing vectors
|
||||
switch (opt.opt->type()) {
|
||||
case coFloats: {
|
||||
const ConfigOptionFloatsNullable* opt_floatsnullable = static_cast<const ConfigOptionFloatsNullable *>(opt.opt);
|
||||
const ConfigOptionFloatsNullable* opt_floatsnullable = dynamic_cast<const ConfigOptionFloatsNullable *>(opt.opt);
|
||||
if (opt_floatsnullable) {
|
||||
if (opt_floatsnullable->size() == 1) { // old version
|
||||
output.set_d(static_cast<const ConfigOptionFloatsNullable*>(opt.opt)->get_at(0));
|
||||
output.set_d(opt_floatsnullable->get_at(0));
|
||||
} else {
|
||||
output.set_d(static_cast<const ConfigOptionFloatsNullable*>(opt.opt)->get_at(ctx->get_extruder_id()));
|
||||
output.set_d(opt_floatsnullable->get_at(ctx->get_extruder_id()));
|
||||
}
|
||||
} else {
|
||||
const ConfigOptionFloats* opt_floats = static_cast<const ConfigOptionFloats*>(opt.opt);
|
||||
if (opt_floats->size() == 1) { // old version
|
||||
output.set_d(static_cast<const ConfigOptionFloats*>(opt.opt)->get_at(0));
|
||||
output.set_d(opt_floats->get_at(0));
|
||||
} else {
|
||||
output.set_d(static_cast<const ConfigOptionFloats*>(opt.opt)->get_at(ctx->get_extruder_id()));
|
||||
output.set_d(opt_floats->get_at(ctx->get_extruder_id()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case coFloatsOrPercents: {
|
||||
const ConfigOptionFloatsOrPercentsNullable *opt_vec_nullable = dynamic_cast<const ConfigOptionFloatsOrPercentsNullable *>(opt.opt);
|
||||
if (opt_vec_nullable) {
|
||||
size_t elem_index = (opt_vec_nullable->size() == 1) ? 0 : ctx->get_extruder_id();
|
||||
resolve_float_or_percent(opt_vec_nullable->get_at(elem_index), elem_index);
|
||||
} else {
|
||||
const ConfigOptionFloatsOrPercents *opt_vec = static_cast<const ConfigOptionFloatsOrPercents *>(opt.opt);
|
||||
size_t elem_index = (opt_vec->size() == 1) ? 0 : ctx->get_extruder_id();
|
||||
resolve_float_or_percent(opt_vec->get_at(elem_index), elem_index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: ctx->throw_exception("Referencing a vector variable when scalar is expected", opt.it_range);
|
||||
}
|
||||
} else {
|
||||
@@ -1131,6 +1215,15 @@ namespace client
|
||||
case coPoints: output.set_s(to_string(static_cast<const ConfigOptionPoints*>(opt.opt)->values[idx])); break;
|
||||
case coBools: output.set_b(static_cast<const ConfigOptionBools*>(opt.opt)->values[idx] != 0); break;
|
||||
case coEnums: output.set_i(static_cast<const ConfigOptionInts *>(opt.opt)->values[idx]); break;
|
||||
case coFloatsOrPercents: {
|
||||
const ConfigOptionFloatsOrPercentsNullable *opt_vec_nullable = dynamic_cast<const ConfigOptionFloatsOrPercentsNullable *>(opt.opt);
|
||||
if (opt_vec_nullable) {
|
||||
resolve_float_or_percent(opt_vec_nullable->values[idx], idx);
|
||||
} else {
|
||||
resolve_float_or_percent(static_cast<const ConfigOptionFloatsOrPercents *>(opt.opt)->values[idx], idx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ctx->throw_exception("Unsupported vector variable type", opt.it_range);
|
||||
}
|
||||
|
||||
@@ -21,11 +21,12 @@ void PrintTryCancel::operator()()
|
||||
|
||||
size_t PrintStateBase::g_last_timestamp = 0;
|
||||
|
||||
// Update "scale", "input_filename", "input_filename_base" placeholders from the current m_objects.
|
||||
// Update "scale", "input_filename", "input_filename_base", "first_object_name" placeholders from the current m_objects.
|
||||
void PrintBase::update_object_placeholders(DynamicConfig &config, const std::string &default_ext) const
|
||||
{
|
||||
// get the first input file name
|
||||
std::string input_file;
|
||||
std::string first_object_name;
|
||||
std::vector<std::string> v_scale;
|
||||
int num_objects = 0;
|
||||
int num_instances = 0;
|
||||
@@ -38,6 +39,8 @@ void PrintBase::update_object_placeholders(DynamicConfig &config, const std::str
|
||||
}
|
||||
if (printable) {
|
||||
++ num_objects;
|
||||
if (num_objects == 1)
|
||||
first_object_name = model_object->name;
|
||||
// CHECK_ME -> Is the following correct ?
|
||||
v_scale.push_back("x:" + boost::lexical_cast<std::string>(printable->get_scaling_factor(X) * 100) +
|
||||
"% y:" + boost::lexical_cast<std::string>(printable->get_scaling_factor(Y) * 100) +
|
||||
@@ -51,6 +54,7 @@ void PrintBase::update_object_placeholders(DynamicConfig &config, const std::str
|
||||
config.set_key_value("num_instances", new ConfigOptionInt(num_instances));
|
||||
|
||||
config.set_key_value("scale", new ConfigOptionStrings(v_scale));
|
||||
config.set_key_value("first_object_name", new ConfigOptionString(first_object_name));
|
||||
if (! input_file.empty()) {
|
||||
// get basename with and without suffix
|
||||
const std::string input_filename = boost::filesystem::path(input_file).filename().string();
|
||||
|
||||
@@ -194,6 +194,7 @@ std::string debug_out_path(const char *name, ...);
|
||||
// smaller level means less log. level=5 means saving all logs.
|
||||
void set_log_path_and_level(const std::string& file, unsigned int level);
|
||||
void flush_logs();
|
||||
void shutdown_console_logging();
|
||||
boost::filesystem::path get_log_file_name();
|
||||
|
||||
// A special type for strings encoded in the local Windows 8-bit code page.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <locale>
|
||||
#include <ctime>
|
||||
#include <cstdarg>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <filesystem>
|
||||
|
||||
@@ -46,14 +47,19 @@
|
||||
#include <boost/log/core.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/sinks/async_frontend.hpp>
|
||||
#include <boost/log/sinks/text_file_backend.hpp>
|
||||
#include <boost/log/sinks/text_ostream_backend.hpp>
|
||||
#include <boost/log/utility/setup/file.hpp>
|
||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||
#include <boost/log/sources/severity_logger.hpp>
|
||||
#include <boost/log/sources/record_ostream.hpp>
|
||||
#include <boost/log/support/date_time.hpp>
|
||||
|
||||
#include <boost/core/null_deleter.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -174,6 +180,7 @@ unsigned get_logging_level()
|
||||
}
|
||||
|
||||
boost::shared_ptr<boost::log::sinks::synchronous_sink<boost::log::sinks::text_file_backend>> g_log_sink;
|
||||
boost::shared_ptr<boost::log::sinks::asynchronous_sink<boost::log::sinks::text_ostream_backend>> g_console_log_sink;
|
||||
|
||||
// Force set_logging_level(<=error) after loading of the DLL.
|
||||
// This is currently only needed if libslic3r is loaded as a shared library into Perl interpreter
|
||||
@@ -346,6 +353,19 @@ namespace src = boost::log::sources;
|
||||
namespace expr = boost::log::expressions;
|
||||
namespace keywords = boost::log::keywords;
|
||||
namespace attrs = boost::log::attributes;
|
||||
namespace sinks = boost::log::sinks;
|
||||
|
||||
void shutdown_console_logging()
|
||||
{
|
||||
if (!g_console_log_sink)
|
||||
return;
|
||||
|
||||
auto console_sink = g_console_log_sink;
|
||||
boost::log::core::get()->remove_sink(console_sink);
|
||||
console_sink->stop();
|
||||
g_console_log_sink.reset();
|
||||
}
|
||||
|
||||
void set_log_path_and_level(const std::string& file, unsigned int level)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
@@ -377,6 +397,24 @@ void set_log_path_and_level(const std::string& file, unsigned int level)
|
||||
keywords::auto_flush = true
|
||||
);
|
||||
|
||||
shutdown_console_logging();
|
||||
|
||||
#ifdef SLIC3R_CONSOLE_LOG
|
||||
auto console_backend = boost::make_shared<sinks::text_ostream_backend>();
|
||||
console_backend->add_stream(boost::shared_ptr<std::ostream>(&std::cout, boost::null_deleter()));
|
||||
console_backend->auto_flush(true);
|
||||
|
||||
g_console_log_sink = boost::make_shared<sinks::asynchronous_sink<sinks::text_ostream_backend>>(console_backend);
|
||||
g_console_log_sink->set_formatter(
|
||||
expr::stream
|
||||
<< "[" << expr::attr< logging::trivial::severity_level >("Severity") << "]\t"
|
||||
<< expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S.%f") << " "
|
||||
<<"[Thread " << expr::attr<attrs::current_thread_id::value_type>("ThreadID") << "]"
|
||||
<< ": " << expr::smessage
|
||||
);
|
||||
boost::log::core::get()->add_sink(g_console_log_sink);
|
||||
#endif
|
||||
|
||||
logging::add_common_attributes();
|
||||
|
||||
set_logging_level(level);
|
||||
|
||||
@@ -1458,8 +1458,32 @@ int GUI_App::install_plugin(std::string name, std::string package_name, InstallP
|
||||
boost::filesystem::create_directories(dest_path.parent_path());
|
||||
std::string dest_zip_file = encode_path(dest_path.string().c_str());
|
||||
try {
|
||||
if (fs::exists(dest_path))
|
||||
fs::remove(dest_path);
|
||||
if (fs::exists(dest_path)) {
|
||||
boost::system::error_code ec;
|
||||
fs::remove(dest_path, ec);
|
||||
if (ec) {
|
||||
// On Windows a currently-loaded DLL (e.g. BambuSource.dll, or the
|
||||
// networking library in legacy mode) cannot be deleted or overwritten
|
||||
// in place, which failed the whole install with "The plug-in file may
|
||||
// be in use" (issue #14373). It CAN however be renamed aside: the
|
||||
// running module keeps mapping the renamed file while we write the new
|
||||
// one. The stale ".old" copy is cleared on the next install/launch.
|
||||
boost::filesystem::path aside = dest_path;
|
||||
aside += ".old";
|
||||
boost::system::error_code ec2;
|
||||
fs::remove(aside, ec2);
|
||||
fs::rename(dest_path, aside, ec2);
|
||||
if (ec2) {
|
||||
close_zip_reader(&archive);
|
||||
BOOST_LOG_TRIVIAL(error) << "[install_plugin] cannot replace in-use file "
|
||||
<< dest_path.string() << ": " << ec2.message();
|
||||
if (pro_fn) { pro_fn(InstallStatusUnzipFailed, 0, cancel); }
|
||||
return InstallStatusUnzipFailed;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(warning) << "[install_plugin] " << dest_path.filename().string()
|
||||
<< " was in use, renamed aside to .old";
|
||||
}
|
||||
}
|
||||
mz_bool res = 0;
|
||||
#ifndef WIN32
|
||||
if (S_ISLNK(stat.m_external_attr >> 16)) {
|
||||
@@ -2237,6 +2261,7 @@ GUI_App::~GUI_App()
|
||||
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": exit");
|
||||
shutdown_console_logging();
|
||||
}
|
||||
|
||||
bool GUI_App::is_blocking_printing(MachineObject *obj_)
|
||||
@@ -3345,6 +3370,26 @@ void GUI_App::copy_network_if_available()
|
||||
|
||||
bool GUI_App::on_init_network(bool try_backup)
|
||||
{
|
||||
// Clean up stale ".old" files left by install_plugin() when it had to rename an in-use
|
||||
// DLL aside (see the rename-aside path in install_plugin). This runs before the plug-in
|
||||
// is (re)loaded - at startup nothing is mapped yet, and on a hot reload the previous
|
||||
// module has already been unloaded - so the previously locked files can now be removed.
|
||||
{
|
||||
boost::filesystem::path plugin_folder = boost::filesystem::path(data_dir()) / "plugins";
|
||||
boost::system::error_code ec;
|
||||
if (boost::filesystem::is_directory(plugin_folder, ec)) {
|
||||
for (boost::filesystem::directory_iterator it(plugin_folder, ec), end; !ec && it != end; it.increment(ec)) {
|
||||
if (it->path().extension() == ".old") {
|
||||
boost::system::error_code rm_ec;
|
||||
boost::filesystem::remove(it->path(), rm_ec);
|
||||
if (rm_ec)
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": could not remove stale " << it->path().filename().string()
|
||||
<< " (" << rm_ec.message() << "), will retry next launch";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto should_load_networking_plugin = app_config->get_bool("installed_networking");
|
||||
|
||||
std::string config_version = app_config->get_network_plugin_version();
|
||||
|
||||
@@ -91,9 +91,14 @@ Vec3d GLGizmoMeasure::get_feature_offset(const Measure::SurfaceFeature &feature)
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Edge:
|
||||
{
|
||||
std::optional<Vec3d> p = feature.get_extra_point();
|
||||
assert(p.has_value());
|
||||
ret = *p;
|
||||
// Only polygon edges store an extra point (the polygon centre); plain edges have none.
|
||||
const std::optional<Vec3d> extra = feature.get_extra_point();
|
||||
if (extra.has_value())
|
||||
ret = *extra;
|
||||
else {
|
||||
const auto [pt1, pt2] = feature.get_edge();
|
||||
ret = 0.5 * (pt1 + pt2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Measure::SurfaceFeatureType::Point:
|
||||
@@ -1065,7 +1070,7 @@ void GLGizmoMeasure::on_render()
|
||||
|
||||
if (requires_raycaster_update) {
|
||||
if (m_gripper_id_raycast_map.find(GripperType::SPHERE_2) != m_gripper_id_raycast_map.end()) {
|
||||
m_gripper_id_raycast_map[GripperType::SPHERE_2]->set_transform(Geometry::translation_transform(get_feature_offset(*m_selected_features.first.feature)) *
|
||||
m_gripper_id_raycast_map[GripperType::SPHERE_2]->set_transform(Geometry::translation_transform(get_feature_offset(*m_selected_features.second.feature)) *
|
||||
Geometry::scale_transform(inv_zoom));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,6 +535,9 @@ void Selection::drop()
|
||||
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume& volume = *(*m_volumes)[i];
|
||||
// Skip the wipe tower: its synthetic id (>= 1000) is not an index into m_model->objects.
|
||||
if (volume.object_idx() >= 1000)
|
||||
continue;
|
||||
ModelObject* model_object = m_model->objects[volume.object_idx()];
|
||||
|
||||
if (model_object != nullptr) {
|
||||
@@ -1848,6 +1851,9 @@ void Selection::notify_instance_update(int object_idx, int instance_idx)
|
||||
for (unsigned int i : m_list)
|
||||
{
|
||||
int obj_index = (*m_volumes)[i]->object_idx();
|
||||
// Skip the wipe tower: its synthetic id (>= 1000) is not an index into m_model->objects.
|
||||
if (obj_index >= 1000)
|
||||
continue;
|
||||
//-1 means all the instance in this object
|
||||
if (instance_idx == -1)
|
||||
{
|
||||
|
||||
@@ -38,8 +38,13 @@
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <uuid/uuid.h>
|
||||
#endif
|
||||
|
||||
@@ -76,6 +81,60 @@ constexpr const char* SECRET_STORE_SERVICE = "OrcaSlicer/Auth";
|
||||
constexpr const char* SECRET_STORE_USER = "orca_refresh_token";
|
||||
constexpr std::chrono::seconds TOKEN_REFRESH_SKEW{900}; // 15 minutes
|
||||
|
||||
// Cross-process advisory lock serializing refresh-token rotation between Orca instances on
|
||||
// this machine. The Supabase refresh token rotates on every use, so read -> spend -> write-back
|
||||
// of the rotated successor must be one critical section across processes; otherwise a second
|
||||
// instance can re-spend a token a peer already rotated, triggering `refresh_token_already_used`.
|
||||
// Blocks until acquired (kernel sleep, no CPU spin). It cannot deadlock permanently because the
|
||||
// refresh POST is bounded (http_post_token uses timeout_max) and both back-ends release
|
||||
// automatically if the holder dies. Same machine only; cross-device concurrency is still
|
||||
// governed by the server's reuse-detection grace window.
|
||||
class InterProcessRefreshTokenLock
|
||||
{
|
||||
public:
|
||||
explicit InterProcessRefreshTokenLock(const std::string& path)
|
||||
{
|
||||
if (path.empty()) { m_locked = true; return; } // no path -> proceed unsynchronized
|
||||
#if defined(_WIN32)
|
||||
const std::wstring name = L"Local\\OrcaTokenRefresh_" + std::to_wstring(std::hash<std::string>{}(path));
|
||||
m_handle = ::CreateMutexW(nullptr, FALSE, name.c_str());
|
||||
if (!m_handle) { m_locked = true; return; } // can't create -> don't block
|
||||
const DWORD r = ::WaitForSingleObject(m_handle, INFINITE); // blocks, no spin
|
||||
m_locked = (r == WAIT_OBJECT_0 || r == WAIT_ABANDONED); // ABANDONED: prior holder crashed
|
||||
#else
|
||||
m_fd = ::open(path.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0600);
|
||||
if (m_fd == -1) { m_locked = true; return; } // can't open -> don't block
|
||||
struct flock fl{};
|
||||
fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0;
|
||||
int rc;
|
||||
do { rc = ::fcntl(m_fd, F_SETLKW, &fl); } while (rc == -1 && errno == EINTR); // blocks in kernel
|
||||
m_locked = (rc != -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
~InterProcessRefreshTokenLock()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
if (m_handle) { if (m_locked) ::ReleaseMutex(m_handle); ::CloseHandle(m_handle); }
|
||||
#else
|
||||
if (m_fd != -1) ::close(m_fd); // closing the fd releases the lock we hold
|
||||
#endif
|
||||
}
|
||||
|
||||
bool locked() const { return m_locked; }
|
||||
|
||||
InterProcessRefreshTokenLock(const InterProcessRefreshTokenLock&) = delete;
|
||||
InterProcessRefreshTokenLock& operator=(const InterProcessRefreshTokenLock&) = delete;
|
||||
|
||||
private:
|
||||
bool m_locked = false;
|
||||
#if defined(_WIN32)
|
||||
HANDLE m_handle = nullptr;
|
||||
#else
|
||||
int m_fd = -1;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Return a JSON field only when it is present as a string. Missing or non-string values normalize to empty.
|
||||
std::string get_json_string_field(const json& j, const std::string& key)
|
||||
{
|
||||
@@ -1649,8 +1708,7 @@ RefreshResult OrcaCloudServiceAgent::refresh_now(const std::string& refresh_toke
|
||||
}
|
||||
|
||||
auto worker = [this, refresh_token, reason]() {
|
||||
(void) reason;
|
||||
RefreshResult r = refresh_session_with_token(refresh_token);
|
||||
RefreshResult r = refresh_session_with_token(refresh_token, reason);
|
||||
refresh_running.store(false);
|
||||
return r;
|
||||
};
|
||||
@@ -1670,20 +1728,39 @@ RefreshResult OrcaCloudServiceAgent::refresh_now(const std::string& refresh_toke
|
||||
|
||||
RefreshResult OrcaCloudServiceAgent::refresh_from_storage(const std::string& reason, bool async)
|
||||
{
|
||||
std::string refresh_token = get_refresh_token();
|
||||
if (refresh_token.empty()) {
|
||||
std::string user_secret;
|
||||
if (load_user_secret(user_secret) && !user_secret.empty()) {
|
||||
SessionInfo stored_session;
|
||||
parse_stored_secret(user_secret, refresh_token, stored_session);
|
||||
}
|
||||
(void) async; // currently all callers are calling this function synchronous anyway
|
||||
|
||||
// Blocks until we own the lock (kernel sleep, no spin). Cannot deadlock permanently:
|
||||
// the refresh POST is bounded (http_post_token timeout_max) and the lock auto-releases
|
||||
// on process death, so no holder can keep it longer than that bound.
|
||||
InterProcessRefreshTokenLock lock(token_lock_path());
|
||||
if (!lock.locked()) {
|
||||
// Lock syscall genuinely failed (rare). Proceed best-effort rather than give up.
|
||||
BOOST_LOG_TRIVIAL(warning) << "OrcaCloudServiceAgent: token refresh lock unavailable, "
|
||||
"proceeding unsynchronized (reason=" << reason << ")";
|
||||
}
|
||||
|
||||
std::string refresh_token;
|
||||
std::string user_secret;
|
||||
|
||||
// We read the refresh token from the OS keychain as the source of truth
|
||||
if (load_user_secret(user_secret) && !user_secret.empty()) {
|
||||
SessionInfo stored_session;
|
||||
parse_stored_secret(user_secret, refresh_token, stored_session);
|
||||
}
|
||||
|
||||
// We only read from memory if the read from OS keychain fails
|
||||
if (refresh_token.empty())
|
||||
refresh_token = get_refresh_token();
|
||||
|
||||
if (refresh_token.empty()) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "OrcaCloudServiceAgent: no refresh token available for refresh (reason=" << reason << ")";
|
||||
return RefreshResult::AuthRejected; // no persisted token: nothing to preserve
|
||||
}
|
||||
|
||||
return refresh_now(refresh_token, reason, async);
|
||||
// Synchronous: hold the lock across the network round-trip AND the write-back that
|
||||
// set_user_session performs, so the rotation is atomic w.r.t. other instances.
|
||||
return refresh_now(refresh_token, reason, /*async=*/false);
|
||||
}
|
||||
|
||||
bool OrcaCloudServiceAgent::refresh_if_expiring(std::chrono::seconds skew, const std::string& reason)
|
||||
@@ -1696,8 +1773,14 @@ bool OrcaCloudServiceAgent::refresh_if_expiring(std::chrono::seconds skew, const
|
||||
|
||||
if (!needs_refresh) return true;
|
||||
|
||||
if (refresh_from_storage(reason, false) == RefreshResult::Success) return true;
|
||||
// First attempt. refresh_from_storage blocks on the cross-process lock and reads the
|
||||
// freshest token from the store, so cross-instance contention is already resolved here.
|
||||
RefreshResult r = refresh_from_storage(reason, false);
|
||||
if (r == RefreshResult::Success) return true;
|
||||
if (r == RefreshResult::AuthRejected) return false; // definitive: retrying the same token can't help
|
||||
|
||||
// One retry, only for a transient network failure of the refresh POST (lost response,
|
||||
// timeout, 429/5xx -> Transient). The retry re-acquires the lock and re-reads the store.
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(750));
|
||||
return refresh_from_storage(reason + "_retry", false) == RefreshResult::Success;
|
||||
}
|
||||
@@ -1716,7 +1799,23 @@ static RefreshResult classify_refresh_result(unsigned http_code, bool session_es
|
||||
: RefreshResult::Transient; // 2xx but unusable body
|
||||
}
|
||||
|
||||
RefreshResult OrcaCloudServiceAgent::refresh_session_with_token(const std::string& refresh_token)
|
||||
// Best-effort extraction of GoTrue's "error_code" field (e.g. "refresh_token_already_used").
|
||||
// Returns "" if the body is not a JSON object or lacks the field.
|
||||
static std::string extract_error_code(const std::string& body)
|
||||
{
|
||||
const json j = json::parse(body, nullptr, false);
|
||||
if (j.is_object())
|
||||
return get_json_string_field(j, "error_code");
|
||||
return "";
|
||||
}
|
||||
|
||||
static long long now_epoch_seconds()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
RefreshResult OrcaCloudServiceAgent::refresh_session_with_token(const std::string& refresh_token, const std::string& reason)
|
||||
{
|
||||
std::string body = "{\"refresh_token\":\"" + refresh_token + "\"}";
|
||||
std::string url = auth_base_url + auth_constants::TOKEN_PATH + "?grant_type=refresh_token";
|
||||
@@ -1725,6 +1824,12 @@ RefreshResult OrcaCloudServiceAgent::refresh_session_with_token(const std::strin
|
||||
// http_post_token sets http_code to 0 when the server could not be reached.
|
||||
http_post_token(body, &response, &http_code, url);
|
||||
|
||||
const long long now_s = now_epoch_seconds();
|
||||
const long long last_ok = last_refresh_success_epoch.load(std::memory_order_relaxed);
|
||||
const long long since_last_ok = (last_ok == 0) ? -1 : (now_s - last_ok); // -1 = no success yet this process
|
||||
const long long since_start = now_s - agent_start_epoch;
|
||||
const std::string log_reason = reason.empty() ? "-" : reason;
|
||||
|
||||
bool established = false;
|
||||
if (http_code >= 200 && http_code < 300) {
|
||||
if (session_handler) {
|
||||
@@ -1738,10 +1843,47 @@ RefreshResult OrcaCloudServiceAgent::refresh_session_with_token(const std::strin
|
||||
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: token refresh parse exception - " << e.what();
|
||||
}
|
||||
}
|
||||
if (established) {
|
||||
last_refresh_success_epoch.store(now_s, std::memory_order_relaxed);
|
||||
BOOST_LOG_TRIVIAL(info) << "[auth] event=refresh_ok reason=" << log_reason
|
||||
<< " secs_since_last_success=" << since_last_ok;
|
||||
}
|
||||
} else {
|
||||
// Diagnostics to classify a future refresh_token_already_used incident from logs alone
|
||||
// - secs_since_last_success large (or -1 = none this process) => stale token beyond the
|
||||
// reuse-grace window (the ">1h gap" residual).
|
||||
// - stored_differs=true => another instance/device already rotated the token in the
|
||||
// shared secret store (the multi-session residual).
|
||||
const std::string error_code = extract_error_code(response);
|
||||
|
||||
// Only meaningful when the server actually rejected us (not a bare transport failure).
|
||||
bool stored_present = false, stored_differs = false;
|
||||
if (http_code >= 400) {
|
||||
std::string stored_secret, stored_token;
|
||||
SessionInfo ignored;
|
||||
if (load_user_secret(stored_secret) && !stored_secret.empty()
|
||||
&& parse_stored_secret(stored_secret, stored_token, ignored) && !stored_token.empty()) {
|
||||
stored_present = true;
|
||||
stored_differs = (stored_token != refresh_token);
|
||||
}
|
||||
}
|
||||
|
||||
std::string user_id_copy;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(session_mutex);
|
||||
user_id_copy = session.user_id;
|
||||
}
|
||||
|
||||
std::string truncated_response = response.size() > 200 ? response.substr(0, 200) + "..." : response;
|
||||
BOOST_LOG_TRIVIAL(warning) << "OrcaCloudServiceAgent: token refresh failed - http_code=" << http_code
|
||||
<< ", response_body=" << truncated_response;
|
||||
BOOST_LOG_TRIVIAL(warning) << "[auth] event=refresh_rejected http_code=" << http_code
|
||||
<< " error_code=" << (error_code.empty() ? "-" : error_code)
|
||||
<< " reason=" << log_reason
|
||||
<< " stored_present=" << (stored_present ? "true" : "false")
|
||||
<< " stored_differs=" << (stored_differs ? "true" : "false")
|
||||
<< " secs_since_last_success=" << since_last_ok
|
||||
<< " secs_since_start=" << since_start
|
||||
<< " user_id=" << (user_id_copy.empty() ? "-" : user_id_copy)
|
||||
<< " response_body=" << truncated_response;
|
||||
}
|
||||
|
||||
return classify_refresh_result(http_code, established);
|
||||
@@ -2206,6 +2348,9 @@ bool OrcaCloudServiceAgent::http_post_token(const std::string& body, std::string
|
||||
resp_body = body;
|
||||
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error;
|
||||
})
|
||||
// Keep this timeout finite: refresh_from_storage holds a cross-process lock across
|
||||
// this call, so an unbounded refresh POST would let one instance wedge token refresh
|
||||
// for every other Orca instance on the machine.
|
||||
.timeout_max(30)
|
||||
.perform_sync();
|
||||
|
||||
@@ -2843,4 +2988,13 @@ int OrcaCloudServiceAgent::get_shared_bundle(const std::string& bundle_id, std::
|
||||
}
|
||||
}
|
||||
|
||||
std::string OrcaCloudServiceAgent::token_lock_path() const
|
||||
{
|
||||
if (config_dir.empty())
|
||||
return {};
|
||||
wxFileName lock(wxString::FromUTF8(config_dir.c_str()), "orca_refresh_token.lock");
|
||||
lock.Normalize();
|
||||
return lock.GetFullPath().ToStdString();
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
bool refresh_if_expiring(std::chrono::seconds skew, const std::string& reason);
|
||||
RefreshResult refresh_from_storage(const std::string& reason, bool async = false);
|
||||
RefreshResult refresh_now(const std::string& refresh_token, const std::string& reason, bool async = false);
|
||||
RefreshResult refresh_session_with_token(const std::string& refresh_token);
|
||||
RefreshResult refresh_session_with_token(const std::string& refresh_token, const std::string& reason = "");
|
||||
|
||||
// Session state helpers. nickname is the human-facing UI label after provider fallback resolution.
|
||||
bool set_user_session(const std::string& token,
|
||||
@@ -350,6 +350,9 @@ private:
|
||||
std::string map_to_json(const std::map<std::string, std::string>& map);
|
||||
void json_to_map(const std::string& json, std::map<std::string, std::string>& map);
|
||||
|
||||
// Refresh token lock
|
||||
std::string token_lock_path() const;
|
||||
|
||||
// Member variables - configuration
|
||||
std::string log_dir;
|
||||
std::string config_dir;
|
||||
@@ -370,6 +373,12 @@ private:
|
||||
SessionInfo session;
|
||||
mutable std::mutex session_mutex;
|
||||
|
||||
// Refresh diagnostics (see docs/analysis/refresh_token_already_used.md). Epoch seconds so the
|
||||
// refresh-failure log can report token staleness without holding a lock or logging any token.
|
||||
std::atomic<long long> last_refresh_success_epoch{0}; // 0 = no success yet this process
|
||||
const long long agent_start_epoch{std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count()};
|
||||
|
||||
// Member variables - connection state
|
||||
bool is_connected{false};
|
||||
bool enable_track{false};
|
||||
|
||||
@@ -183,6 +183,74 @@ void trigger_precise_wall_warning(DynamicPrintConfig& c)
|
||||
|
||||
} // namespace
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// {first_object_name} filename placeholder
|
||||
// ---------------------------------------------------------------------------
|
||||
namespace {
|
||||
|
||||
// Add a printable 20mm cube named `name` to `model`; returns it so the caller can tweak it.
|
||||
ModelObject* add_named_cube(Model& model, const std::string& name)
|
||||
{
|
||||
ModelObject* obj = model.add_object();
|
||||
obj->name = name;
|
||||
obj->add_volume(make_cube(20.0, 20.0, 20.0));
|
||||
obj->add_instance();
|
||||
obj->ensure_on_bed();
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Resolve `format` to an output file name for a print of `model`. `filename_base`, when set,
|
||||
// is the saved-project name passed to output_filename().
|
||||
std::string resolved_output_name(Model& model, const std::string& format, const std::string& filename_base = {})
|
||||
{
|
||||
DynamicPrintConfig config = DynamicPrintConfig::full_print_config();
|
||||
config.set_key_value("filename_format", new ConfigOptionString(format));
|
||||
|
||||
Print print;
|
||||
for (ModelObject* obj : model.objects)
|
||||
print.auto_assign_extruders(obj);
|
||||
print.apply(model, config);
|
||||
return print.output_filename(filename_base);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Print: {first_object_name} names the first printable object on the plate", "[Print]")
|
||||
{
|
||||
Model model;
|
||||
|
||||
SECTION("uses the object's name") {
|
||||
add_named_cube(model, "WidgetPart");
|
||||
CHECK(resolved_output_name(model, "{first_object_name}") == "WidgetPart.gcode");
|
||||
}
|
||||
|
||||
SECTION("picks the first when several objects are printable") {
|
||||
add_named_cube(model, "FirstPart");
|
||||
add_named_cube(model, "SecondPart");
|
||||
CHECK(resolved_output_name(model, "{first_object_name}") == "FirstPart.gcode");
|
||||
}
|
||||
|
||||
SECTION("skips objects outside the print volume (e.g. on another plate)") {
|
||||
// First in model order, but not on the current plate, so is_printable() is false.
|
||||
add_named_cube(model, "OtherPlatePart")->instances.front()->print_volume_state = ModelInstancePVS_Fully_Outside;
|
||||
add_named_cube(model, "OnPlatePart");
|
||||
CHECK(resolved_output_name(model, "{first_object_name}") == "OnPlatePart.gcode");
|
||||
}
|
||||
|
||||
SECTION("is empty when the object has no name") {
|
||||
add_named_cube(model, "");
|
||||
CHECK(resolved_output_name(model, "part_{first_object_name}") == "part_.gcode");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Print: {first_object_name} is not replaced by the saved-project file name", "[Print]")
|
||||
{
|
||||
// Passing a saved-project file name as the filename_base must not change {first_object_name}.
|
||||
Model model;
|
||||
add_named_cube(model, "WidgetPart");
|
||||
CHECK(resolved_output_name(model, "{first_object_name}", "SavedProject") == "WidgetPart.gcode");
|
||||
}
|
||||
|
||||
TEST_CASE("Print::validate stacks independent warnings", "[Print][validate]")
|
||||
{
|
||||
// Two unrelated checks (region precise-wall + machine acceleration) must each
|
||||
|
||||
@@ -11,8 +11,8 @@ SCENARIO("Placeholder parser scripting", "[PlaceholderParser]") {
|
||||
|
||||
config.set_deserialize_strict( {
|
||||
{ "printer_notes", " PRINTER_VENDOR_PRUSA3D PRINTER_MODEL_MK2 " },
|
||||
{ "nozzle_diameter", "0.6;0.6;0.6;0.6" },
|
||||
{ "nozzle_temperature", "357;359;363;378" }
|
||||
{ "nozzle_diameter", "0.6,0.6,0.6,0.6" },
|
||||
{ "nozzle_temperature", "357,359,363,378" }
|
||||
});
|
||||
// To test the "min_width_top_surface" over "inner_wall_line_width".
|
||||
config.option<ConfigOptionFloatOrPercent>("inner_wall_line_width")->value = 150.;
|
||||
@@ -121,8 +121,8 @@ SCENARIO("Placeholder parser variables", "[PlaceholderParser]") {
|
||||
config.set_deserialize_strict({
|
||||
{ "filament_notes", "testnotes" },
|
||||
{ "enable_pressure_advance", "1" },
|
||||
{ "nozzle_diameter", "0.6;0.6;0.6;0.6" },
|
||||
{ "nozzle_temperature", "357;359;363;378" }
|
||||
{ "nozzle_diameter", "0.6,0.6,0.6,0.6" },
|
||||
{ "nozzle_temperature", "357,359,363,378" }
|
||||
});
|
||||
|
||||
PlaceholderParser::ContextData context_with_global_dict;
|
||||
@@ -241,3 +241,97 @@ SCENARIO("Placeholder parser variables", "[PlaceholderParser]") {
|
||||
}
|
||||
SECTION("if else completely empty") { REQUIRE(parser.process("{if false then elsif false then else endif}", 0, nullptr, nullptr, nullptr) == ""); }
|
||||
}
|
||||
|
||||
SCENARIO("Placeholder parser coFloatsOrPercents vector access", "[PlaceholderParser]") {
|
||||
PlaceholderParser parser;
|
||||
auto config = DynamicPrintConfig::full_print_config();
|
||||
|
||||
// outer_wall_speed is the ratio_over target for small_perimeter_speed.
|
||||
// Different values per extruder to verify parent resolves at the same element index.
|
||||
config.set_deserialize_strict({
|
||||
{ "outer_wall_speed", "60,70,80,90" },
|
||||
{ "nozzle_diameter", "0.4,0.4,0.4,0.4" },
|
||||
{ "pressure_advance", "1.5,2.0,3.0,4.0" } // coFloats non-nullable
|
||||
});
|
||||
// small_perimeter_speed:
|
||||
// [0] = 50% of outer_wall_speed[0] (= 60) → 30
|
||||
// [1] = 80% of outer_wall_speed[1] (= 70) → 56
|
||||
// [2] = 0 absolute
|
||||
// [3] = 50% of outer_wall_speed[3] (= 90) → 45
|
||||
config.option<ConfigOptionFloatsOrPercentsNullable>("small_perimeter_speed")->values = {
|
||||
FloatOrPercent{50.0, true}, // 50% of outer_wall_speed[0] (60) = 30
|
||||
FloatOrPercent{80.0, true}, // 80% of outer_wall_speed[1] (70) = 56
|
||||
FloatOrPercent{0.0, false}, // absolute: 0
|
||||
FloatOrPercent{50.0, true}, // 50% of outer_wall_speed[3] (90) = 45
|
||||
};
|
||||
|
||||
parser.apply_config(config);
|
||||
parser.set("foo", 0);
|
||||
parser.set("bar", 1);
|
||||
parser.set("baz", 3);
|
||||
parser.set("num_extruders", 4);
|
||||
|
||||
SECTION("Indexed access - percent resolved against parent at same index [0]") {
|
||||
// 50% of outer_wall_speed[0] (60) = 30
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[0]}")) == Catch::Approx(30.0));
|
||||
}
|
||||
|
||||
SECTION("Indexed access - percent resolved against parent at same index [1]") {
|
||||
// 80% of outer_wall_speed[1] (70) = 56
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[1]}")) == Catch::Approx(56.0));
|
||||
}
|
||||
|
||||
SECTION("Indexed access - percent resolved against parent at same index [3]") {
|
||||
// 50% of outer_wall_speed[3] (90) = 45
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[3]}")) == Catch::Approx(45.0));
|
||||
}
|
||||
|
||||
SECTION("Variable-indexed access via foo (=0) - percent value") {
|
||||
// 50% of outer_wall_speed[0] (60) = 30
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[foo]}")) == Catch::Approx(30.0));
|
||||
}
|
||||
|
||||
SECTION("Variable-indexed access via bar (=1) - percent value") {
|
||||
// 80% of outer_wall_speed[1] (70) = 56
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[bar]}")) == Catch::Approx(56.0));
|
||||
}
|
||||
|
||||
SECTION("Variable-indexed access via baz (=3) - percent value") {
|
||||
// 50% of outer_wall_speed[3] (90) = 45
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[baz]}")) == Catch::Approx(45.0));
|
||||
}
|
||||
|
||||
SECTION("Literal-indexed access - absolute value") {
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[2]}")) == Catch::Approx(0.0));
|
||||
}
|
||||
|
||||
SECTION("No-index (extruder-based) access - percent resolved via current extruder") {
|
||||
// Extruder 0 = 50% of outer_wall_speed[0] (60) = 30
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed}")) == Catch::Approx(30.0));
|
||||
}
|
||||
|
||||
SECTION("Out-of-range index clamps to index 0") {
|
||||
// Index 99 is out of range, clamps to 0: 50% of outer_wall_speed[0] (60) = 30
|
||||
REQUIRE(std::stod(parser.process("{small_perimeter_speed[99]}")) == Catch::Approx(30.0));
|
||||
}
|
||||
|
||||
SECTION("coFloats no-index access - nullable (outer_wall_speed)") {
|
||||
// outer_wall_speed is ConfigOptionFloatsNullable, exercises the 'if' branch
|
||||
REQUIRE(std::stod(parser.process("{outer_wall_speed}")) == Catch::Approx(60.0));
|
||||
}
|
||||
|
||||
SECTION("coFloats indexed access - nullable") {
|
||||
// outer_wall_speed[2] = 80
|
||||
REQUIRE(std::stod(parser.process("{outer_wall_speed[2]}")) == Catch::Approx(80.0));
|
||||
}
|
||||
|
||||
SECTION("coFloats no-index access - non-nullable (pressure_advance)") {
|
||||
// pressure_advance is ConfigOptionFloats (non-nullable), exercises the 'else' branch
|
||||
REQUIRE(std::stod(parser.process("{pressure_advance}")) == Catch::Approx(1.5));
|
||||
}
|
||||
|
||||
SECTION("coFloats indexed access - non-nullable") {
|
||||
// pressure_advance[2] = 3.0
|
||||
REQUIRE(std::stod(parser.process("{pressure_advance[2]}")) == Catch::Approx(3.0));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user