-
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.
Merge branch 'master' into hflatval/expected-resource-count-hook
- Loading branch information
Showing
32 changed files
with
392 additions
and
70 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
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
9 changes: 9 additions & 0 deletions
9
react-components/src/architecture/base/commands/DividerCommand.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 |
---|---|---|
@@ -1,10 +1,19 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { type BaseCommand } from './BaseCommand'; | ||
import { RenderTargetCommand } from './RenderTargetCommand'; | ||
|
||
export class DividerCommand extends RenderTargetCommand { | ||
public override get isVisible(): boolean { | ||
return true; | ||
} | ||
|
||
public override equals(other: BaseCommand): boolean { | ||
return this === other; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
throw Error('invoke should never be called on a divider.'); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
react-components/src/architecture/base/commands/FractionSliderCommand.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,26 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { BaseSliderCommand } from './BaseSliderCommand'; | ||
|
||
const MIN_VALUE = 0; | ||
const MAX_VALUE = 1; | ||
const STEP_VALUE = 1; | ||
export abstract class FractionSliderCommand extends BaseSliderCommand { | ||
// ================================================== | ||
// CONSTRUCTOR | ||
// ================================================== | ||
|
||
public constructor() { | ||
super(MIN_VALUE, MAX_VALUE, STEP_VALUE); | ||
} | ||
|
||
// ================================================== | ||
// OVERRIDES | ||
// ================================================= | ||
|
||
public override getValueLabel(): string { | ||
return Math.round(100 * this.value) + '%'; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
react-components/src/architecture/base/commands/SectionCommand.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,19 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { type BaseCommand } from './BaseCommand'; | ||
import { RenderTargetCommand } from './RenderTargetCommand'; | ||
|
||
export class SectionCommand extends RenderTargetCommand { | ||
public override get isVisible(): boolean { | ||
return true; | ||
} | ||
|
||
public override equals(other: BaseCommand): boolean { | ||
return this === other; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
throw Error('invoke should never be called on a section.'); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
react-components/src/architecture/base/commands/mocks/MockSectionCommand.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,11 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { type TranslateKey } from '../../utilities/TranslateKey'; | ||
import { SectionCommand } from '../SectionCommand'; | ||
|
||
export class MockSectionCommand extends SectionCommand { | ||
public override get tooltip(): TranslateKey { | ||
return { fallback: 'Slider section' }; | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
...architecture/base/concreteCommands/image360Collection/Image360CollectionDividerCommand.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,10 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { DividerCommand } from '../../commands/DividerCommand'; | ||
|
||
export class Image360CollectionDividerCommand extends DividerCommand { | ||
public override get isVisible(): boolean { | ||
return this.renderTarget.get360ImageCollections().next().value !== undefined; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...rchitecture/base/concreteCommands/image360Collection/Set360IconsOccludedVisibleCommand.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,41 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type Image360Collection } from '@cognite/reveal'; | ||
import { RenderTargetCommand } from '../../commands/RenderTargetCommand'; | ||
import { type TranslateKey } from '../../utilities/TranslateKey'; | ||
|
||
export class Set360IconsOccludedVisibleCommand extends RenderTargetCommand { | ||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { fallback: 'X-ray' }; // @need-translation | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this.firstCollection?.getIconsVisibility() ?? false; | ||
} | ||
|
||
public override get isToggle(): boolean { | ||
return true; | ||
} | ||
|
||
public override get isChecked(): boolean { | ||
return this.firstCollection?.isOccludedIconsVisible() ?? true; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
const visible = !this.isChecked; | ||
for (const collection of this.renderTarget.get360ImageCollections()) { | ||
collection.setOccludedIconsVisible(visible); | ||
} | ||
return true; | ||
} | ||
|
||
private get firstCollection(): Image360Collection | undefined { | ||
return this.renderTarget.get360ImageCollections().next().value; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ts/src/architecture/base/concreteCommands/image360Collection/Set360IconsOpacityCommand.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,35 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type TranslateKey } from '../../utilities/TranslateKey'; | ||
import { FractionSliderCommand } from '../../commands/FractionSliderCommand'; | ||
import { type Image360Collection } from '@cognite/reveal'; | ||
|
||
export class Set360IconsOpacityCommand extends FractionSliderCommand { | ||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { fallback: 'Marker transparency' }; // @need-translation | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this.firstCollection?.getIconsVisibility() ?? false; | ||
} | ||
|
||
public override get value(): number { | ||
return this.firstCollection?.getIconsOpacity() ?? 1; | ||
} | ||
|
||
public override set value(value: number) { | ||
for (const collection of this.renderTarget.get360ImageCollections()) { | ||
collection.setIconsOpacity(value); | ||
} | ||
} | ||
|
||
private get firstCollection(): Image360Collection | undefined { | ||
return this.renderTarget.get360ImageCollections().next().value; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ts/src/architecture/base/concreteCommands/image360Collection/Set360IconsSectionCommand.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,15 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { SectionCommand } from '../../commands/SectionCommand'; | ||
import { type TranslateKey } from '../../utilities/TranslateKey'; | ||
|
||
export class Set360IconsSectionCommand extends SectionCommand { | ||
public override get isVisible(): boolean { | ||
return this.renderTarget.get360ImageCollections().next().value !== undefined; | ||
} | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { fallback: '360 Markers' }; // @need-translation | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ts/src/architecture/base/concreteCommands/image360Collection/Set360IconsVisibleCommand.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,41 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type Image360Collection } from '@cognite/reveal'; | ||
import { RenderTargetCommand } from '../../commands/RenderTargetCommand'; | ||
import { type TranslateKey } from '../../utilities/TranslateKey'; | ||
|
||
export class Set360IconsVisibleCommand extends RenderTargetCommand { | ||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { fallback: 'Visible' }; // @need-translation | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this.firstCollection !== undefined; | ||
} | ||
|
||
public override get isToggle(): boolean { | ||
return true; | ||
} | ||
|
||
public override get isChecked(): boolean { | ||
return this.firstCollection?.getIconsVisibility() ?? true; | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
const visible = !this.isChecked; | ||
for (const collection of this.renderTarget.get360ImageCollections()) { | ||
collection.setIconsVisibility(visible); | ||
} | ||
return true; | ||
} | ||
|
||
private get firstCollection(): Image360Collection | undefined { | ||
return this.renderTarget.get360ImageCollections().next().value; | ||
} | ||
} |
Oops, something went wrong.