Skip to content

Commit

Permalink
feat(front): allow to apply filter to highlight clear
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 23, 2024
1 parent 918342c commit 23bd49f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/front/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components-front",
"description": "Collection of frontend tools to author BIM apps.",
"version": "2.4.0-alpha.7",
"version": "2.4.0-alpha.8",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
26 changes: 19 additions & 7 deletions packages/front/src/fragments/Highlighter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,10 @@ export class Highlighter
* Clears the selection for the given name or all selections if no name is provided.
*
* @param name - The name of the selection to clear. If not provided, clears all selections.
* @param filter - The only items to unselect. If not provided, all items will be unselected.
*
* @throws Will throw an error if the FragmentsManager is not found.
* @throws Will throw an error if the fragment or its geometry is not found.
* @throws Will throw an error if the item ID is not found.
* @throws Will throw an error if the fragment does not belong to a FragmentsGroup.
*/
clear(name?: string) {
clear(name?: string, filter?: FRAGS.FragmentIdMap) {
const names = name ? [name] : Object.keys(this.selection);

for (const name of names) {
Expand All @@ -464,14 +461,29 @@ export class Highlighter

for (const fragID in this.selection[name]) {
const fragment = fragments.list.get(fragID);

if (!fragment) {
continue;
}
const ids = selected[fragID];

let ids = selected[fragID];
if (!ids) {
continue;
}

if (filter) {
const selected = filter[fragID];
if (!selected) {
continue;
}
const filtered = new Set<number>();
for (const id of ids) {
if (selected.has(id)) {
filtered.add(id);
}
}
ids = filtered;
}

if (this.backupColor) {
fragment.setColor(this.backupColor, ids);
} else {
Expand Down

0 comments on commit 23bd49f

Please sign in to comment.