mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-11 18:01:14 +00:00
refactor(imex): route three inline tool-state parsers through parse_imex_active_tools
PartPlate::calc_imex_zones, GCodeViewer::render, and Plater::collect_imex_warnings each hand-rolled their own "phys:P/C/M" tokenizer with subtly different error handling. Replace the three inline loops with parse_imex_active_tools + imex_primary_tool_for_mode so the Primary/Copy/Mirror classification agrees across zones, the G-code viewer legend, and slice warnings. No behavior change: the shared helpers preserve the 1=Primary / 2=Copy / 3=Mirror encoding already consumed downstream and continue to accept the legacy bare-index form as Primary. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
77c32a2e15
commit
b2128cc330
@@ -9964,17 +9964,10 @@ static std::vector<wxString> collect_imex_warnings(PartPlate* plate)
|
||||
if (i >= tools_opt->values.size() || mode_names_opt->values[i] != mode) continue;
|
||||
const std::string& entry = tools_opt->values[i];
|
||||
primary_tool = imex_primary_tool_for_mode(entry);
|
||||
std::istringstream ss(entry);
|
||||
std::string token;
|
||||
while (std::getline(ss, token, ',')) {
|
||||
token.erase(std::remove_if(token.begin(), token.end(), ::isspace), token.end());
|
||||
if (token.empty()) continue;
|
||||
// std::stoi parses the leading integer and ignores any ":P/:C/:M" suffix.
|
||||
try {
|
||||
int idx = std::stoi(token);
|
||||
if (idx >= 0 && (max_tool == 0 || (size_t)idx < max_tool))
|
||||
active_tools.push_back(idx);
|
||||
} catch (...) {}
|
||||
for (const auto& [phys_idx, role] : parse_imex_active_tools(entry)) {
|
||||
(void)role;
|
||||
if (phys_idx >= 0 && (max_tool == 0 || (size_t)phys_idx < max_tool))
|
||||
active_tools.push_back(phys_idx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user