-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-components): Update fit view so it uses only visual object (#…
…4734) * Initial commit * Initial commit * Update ToggleAllModelsVisibleCommand.ts * Upgrade * Bump version to 0.55.10
- Loading branch information
1 parent
82ad448
commit ed730ce
Showing
13 changed files
with
150 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
react-components/src/architecture/base/concreteCommands/ToggleAllModelsVisibleCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { RenderTargetCommand } from '../commands/RenderTargetCommand'; | ||
import { type TranslateKey } from '../utilities/TranslateKey'; | ||
|
||
export class ToggleAllModelsVisibleCommand extends RenderTargetCommand { | ||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { fallback: 'Show or hide all models' }; | ||
} | ||
|
||
public override get icon(): string { | ||
return 'EyeShow'; | ||
} | ||
|
||
public override get isToggle(): boolean { | ||
return true; | ||
} | ||
|
||
public override get isChecked(): boolean { | ||
return this.isAnyVisible(); | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this.renderTarget.viewer.models.length > 0; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
const isVisible = this.isAnyVisible(); | ||
for (const model of this.renderTarget.viewer.models) { | ||
model.visible = !isVisible; | ||
} | ||
this.renderTarget.invalidate(); | ||
return true; | ||
} | ||
|
||
// ================================================== | ||
// INSTANCE METHODS | ||
// ================================================== | ||
|
||
private isAnyVisible(): boolean { | ||
for (const model of this.renderTarget.viewer.models) { | ||
if (model.visible) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.