-
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.
react-component(feat): Add crop box, slicing and tool, generalize box…
… concept (#4594) * First commit * Generalized box and lines * More generalize * Further work * Fix crop box * Some fixes * Move files again * Move files * Reuse code * adjustments * After add constrains * Fixing cropping * Fix typename * Working good now * Update PlaneDomainObject.ts * Fix updating * Fix updating * Make a general bounding box * Fixes * make flipping consistent * Change name * Reorganization * Fixing * more fixes * Fix icon * Fixing bounding box * Smaller fixing * Fix flaes * Update RevealButtons.tsx * Fix updating of pending * Update CropBoxDomainObject.ts * Update comments * Example uses ClipPlane, differentiate Left/Right button, contrained resizing * Update BoxDragger.ts * Fixes according to review * Fix unit in box dragging
- Loading branch information
1 parent
1a98967
commit 14f2d90
Showing
95 changed files
with
3,106 additions
and
1,231 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
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
31 changes: 31 additions & 0 deletions
31
react-components/src/architecture/base/commands/DomainObjectCommand.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,31 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type DomainObject } from '../domainObjects/DomainObject'; | ||
import { BaseCommand } from './BaseCommand'; | ||
|
||
export abstract class DomainObjectCommand<Type extends DomainObject> extends BaseCommand { | ||
// ================================================== | ||
// INSTANCE FIELDS | ||
// ================================================== | ||
|
||
protected readonly _domainObject: Type; | ||
|
||
// ================================================== | ||
// CONSTRUCTOR | ||
// ================================================== | ||
|
||
public constructor(domainObject: Type) { | ||
super(); | ||
this._domainObject = domainObject; | ||
} | ||
|
||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get hasData(): boolean { | ||
return true; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
react-components/src/architecture/base/commands/InstanceCommand.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,42 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { RenderTargetCommand } from './RenderTargetCommand'; | ||
import { type DomainObject } from '../domainObjects/DomainObject'; | ||
|
||
export abstract class InstanceCommand extends RenderTargetCommand { | ||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get isEnabled(): boolean { | ||
return this.anyInstances; | ||
} | ||
|
||
// ================================================== | ||
// VIRTUAL METHODS | ||
// ================================================== | ||
|
||
protected abstract isInstance(domainObject: DomainObject): boolean; | ||
|
||
// ================================================== | ||
// INSTANCE METHODS | ||
// ================================================== | ||
|
||
protected get anyInstances(): boolean { | ||
return this.getFirstInstance() !== undefined; | ||
} | ||
|
||
protected getFirstInstance(): DomainObject | undefined { | ||
return this.getInstances().next().value; | ||
} | ||
|
||
protected *getInstances(): Generator<DomainObject> { | ||
for (const domainObject of this.rootDomainObject.getDescendants()) { | ||
if (this.isInstance(domainObject)) { | ||
yield domainObject; | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
react-components/src/architecture/base/commands/ShowAllDomainObjectsCommand.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,45 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type TranslateKey } from '../utilities/TranslateKey'; | ||
import { InstanceCommand } from './InstanceCommand'; | ||
|
||
export abstract class ShowAllDomainObjectsCommand extends InstanceCommand { | ||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { fallback: 'Show or hide' }; | ||
} | ||
|
||
public override get icon(): string { | ||
return 'EyeShow'; | ||
} | ||
|
||
public override get isChecked(): boolean { | ||
return this.isAnyVisible(); | ||
} | ||
|
||
protected override invokeCore(): boolean { | ||
const isVisible = this.isAnyVisible(); | ||
for (const domainObject of this.getInstances()) { | ||
domainObject.setVisibleInteractive(!isVisible, this.renderTarget); | ||
} | ||
return true; | ||
} | ||
|
||
// ================================================== | ||
// INSTANCE METHODS | ||
// ================================================== | ||
|
||
private isAnyVisible(): boolean { | ||
for (const domainObject of this.getInstances()) { | ||
if (domainObject.isVisible(this.renderTarget)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.