Skip to content

Commit

Permalink
🐞 fix: Fix the selection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangechen committed Dec 29, 2023
1 parent 3593646 commit fc14480
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/chili/src/commands/boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export abstract class BooleanOperate extends CreateCommand {
protected override getSteps(): IStep[] {
return [
new SelectModelStep("prompt.select.shape", false),
new SelectModelStep("prompt.select.shape", false),
new SelectModelStep("prompt.select.shape", false, {
allow: (shape) => {
return !this.stepDatas[0].models?.map((x) => x.shape()).includes(shape);
},
}),
];
}
}
Expand Down
8 changes: 8 additions & 0 deletions packages/chili/src/commands/create/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export class ConvertToWire extends CreateCommand {
return new GeometryModel(this.document, `Wire ${count++}`, wireBody);
}

protected override shouldClearSelectedBeforeExcute() {
return false;
}

protected override getSteps(): IStep[] {
return [
new SelectModelStep("prompt.select.edges", true, {
Expand All @@ -47,6 +51,10 @@ export class ConvertToFace extends CreateCommand {
return new GeometryModel(this.document, `Face ${count++}`, wireBody);
}

protected override shouldClearSelectedBeforeExcute() {
return false;
}

protected override getSteps(): IStep[] {
return [
new SelectModelStep("prompt.select.edges", true, {
Expand Down
8 changes: 7 additions & 1 deletion packages/chili/src/commands/create/createCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ export abstract class CreateCommand extends MultistepCommand {

protected abstract create(): GeometryModel;

protected shouldClearSelectedBeforeExcute() {
return true;
}

protected override beforeExecute(): Promise<boolean> {
this.document.selection.clearSelected();
if (this.shouldClearSelectedBeforeExcute()) {
this.document.selection.clearSelected();
}
return super.beforeExecute();
}
}
Expand Down

0 comments on commit fc14480

Please sign in to comment.