Skip to content

Machine Filament combo: create-and-link a proper preset for unmatched entries - #823

Open
studiofuga wants to merge 3 commits into
Snapmaker:mainfrom
studiofuga:feature/unmatched-machine-filament
Open

Machine Filament combo: create-and-link a proper preset for unmatched entries#823
studiofuga wants to merge 3 commits into
Snapmaker:mainfrom
studiofuga:feature/unmatched-machine-filament

Conversation

@studiofuga

Copy link
Copy Markdown

What

When the remote printer reports a filament for which no local preset matches by name, the "Machine Filament" combo used to either silently hide the entry, or (in an earlier iteration of this work) show it greyed-out but load a wrong/guessed preset when clicked. This PR makes that click actually useful:

  • Clicking a muted "Machine Filament" entry now opens the "Create Filament" wizard, pre-filled with vendor/type/serial parsed from the machine's reported string and the closest known filament family — instead of silently applying a wrong preset.
  • Matching a machine-reported filament to a local preset now goes through an explicit persisted link (recorded when the wizard successfully creates a preset from that exact machine reading) before falling back to name-based heuristics, and only ever returns a preset that's actually compatible with the current printer/nozzle.
  • Unmatched entries are shown muted (light grey) but remain fully clickable, instead of being hidden or disabled outright.

Commits

  1. Machine Filament combo: disable name-match filter, show unmatched entries greyed out — stop silently dropping machine filaments whose reported name doesn't exactly match a local preset; show them muted instead.
  2. Machine Filament combo: make unmatched entries clickable, muted grey — add a per-item muted/light-grey rendering to the ComboBox/DropDown widgets, keep unmatched entries clickable.
  3. Machine Filament combo: create-and-link a proper preset for unmatched entries — clicking an unmatched entry opens "Create Filament" pre-filled from the machine reading; successful creation is persisted as an explicit machine→preset link; matching is nozzle/printer-compatibility aware.

Testing

Built and manually tested against a Snapmaker U1 printer reporting filaments with no matching local preset, across several rounds of iteration (vendor/type/serial prefill, nozzle-diameter matching, family selection, printer visibility).

…ries greyed out

The name-matching filter in the "Machine Filament" section of the
filament combo box silently dropped entries reported by the remote
printer whenever their name didn't exactly match a local preset name
(and required is_compatible on top of that). Comment it out for now
and, when no matching local preset is found, still show the entry
using the machine's own filament name, rendered greyed out and
non-selectable via the existing LABEL_ITEM_DISABLED marker, instead of
hiding it outright.
Add a per-item 'muted' text colour to the custom ComboBox/DropDown
widgets (the actual base of PresetComboBox — not wxBitmapComboBox),
kept in sync alongside texts/icons/clientData through
Append/DoClear/DoDeleteOneItem/DoInsertItems, with a public
SetItemMuted()/IsItemMuted() API. DropDown's row renderer now paints
muted rows in a light grey (dark-mode aware via
StateColor::darkModeColorFor) instead of the normal text colour.

'Machine Filament' entries in PlaterPresetComboBox/TabPresetComboBox
with no matching local preset now use the same indexed clientData as
matched entries (so they're fully clickable through the normal
update_ams_color()/on_select_preset() flow) and are marked muted
instead of being hidden or disabled.
… entries

Clicking a muted "Machine Filament" entry (no local preset match) now
opens the "Create Filament" wizard instead of guessing/loading a
possibly-wrong preset:

- Plater.cpp: on_select_unmatched_machine_filament() reverts the combo
  to whatever was actually active (nothing was applied by the click),
  parses vendor/type/serial back out of the machine's reported
  "<vendor> <type>[ <sub_type>]" string, and opens
  CreateFilamentPresetDialog pre-filled with that plus the closest
  known filament family. On success, persists a vendor+type ->
  created-preset-name link in AppConfig ("machine_filament_presets"
  section) so future readings of the same filament resolve to it
  directly.

- PresetComboBoxes.cpp: ResolveMachineFilamentPreset()/-ForSlot() now
  matches machine filaments to local presets via (in order) the
  persisted link above, an exact historical name match, then a
  "<vendor> <type>" prefix match — all gated on the resolved preset
  actually being is_compatible with the current printer/nozzle, so a
  preset that exists for the wrong nozzle no longer shows as a dead,
  unselectable match; it stays muted so re-clicking can add the
  missing nozzle variant instead.

- CreatePresetsDialog.cpp/.hpp: prefill_from_machine_filament() fills
  in vendor/type/serial, selects the "Generic <type>" family
  deterministically (previously could land on an unrelated family like
  "... High Speed" due to unordered_map iteration order), and
  auto-checks the printer/nozzle-diameter entry matching the current
  printer. get_all_visible_printer_name() also includes every
  nozzle-size variant of the printer *model* currently active for the
  project, not just printer presets explicitly marked visible.
  get_all_filament_presets() no longer skips filament presets that
  aren't marked is_visible — that flag tracks the user's main filament
  picker and doesn't apply here; it was hiding brand-new system
  presets (e.g. a nozzle size just added to the vendor pack) from this
  dialog's grid entirely. Added an "All nozzle" checkbox to
  bulk (de)select every entry in the grid at once, and made the dialog
  resizable (wxRESIZE_BORDER) since the grid can now list every
  compatible nozzle instead of just one.

- Widgets/DropDown.cpp: drop a stale assert in SetSelection() that the
  very next line already handles gracefully (index gets clamped to -1
  instead of crashing a Debug build).
@studiofuga

Copy link
Copy Markdown
Author

This is particularly useful when using OpenSpool RFIDs with new filaments.
Suppose you have a new tag. You put it in your snapmaker, launch SnOrca.
Sync the filaments.
The new filament may not have a profile. In this case without this patch the filament is not visibile.
With this patch instead you see a grayed out filament. You can click on it and the system propose to create a new filament. You select the base filament, and create it.

If you already have a suitable filament profile, but they don't match (based on name, serial or other issues), you can simply use the suitable profile as a base. Match done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant