From a848924f21358372967f18a3145da8976166677e Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Tue, 12 Nov 2024 08:41:18 +0100 Subject: [PATCH 01/23] Add annotations polygons --- .../base/concreteCommands/NavigationTool.ts | 2 +- .../base/domainObjectsHelpers/BaseCreator.ts | 6 +- .../base/renderTarget/RevealRenderTarget.ts | 7 +- .../primitives}/getIconByPrimitiveType.ts | 6 +- .../annotation360/AnnotationPolygonCreator.ts | 47 ++++++ .../AnnotationPolygonDomainObject.ts | 61 ++++++++ .../annotation360/AnnotationPolygonTool.ts | 143 ++++++++++++++++++ .../AnnotationPolygonTypeCommand.ts | 95 ++++++++++++ .../commands/AnnotationsCreateTool.ts | 2 +- .../clipping/commands/SetClipTypeCommand.ts | 2 +- .../concrete/config/StoryBookConfig.ts | 2 + .../commands/SetMeasurementTypeCommand.ts | 2 +- .../primitives/box/BoxDomainObject.ts | 2 +- .../primitives/common/SolidDomainObject.ts | 2 +- .../cylinder/CylinderDomainObject.ts | 2 +- .../concrete/primitives/line/LineCreator.ts | 34 +++-- .../primitives/line/LineDomainObject.ts | 2 +- .../primitives/plane/PlaneDomainObject.ts | 2 +- .../primitives/tools/PrimitiveEditTool.ts | 8 +- 19 files changed, 394 insertions(+), 33 deletions(-) rename react-components/src/architecture/{concrete/measurements => base/utilities/primitives}/getIconByPrimitiveType.ts (86%) create mode 100644 react-components/src/architecture/concrete/annotation360/AnnotationPolygonCreator.ts create mode 100644 react-components/src/architecture/concrete/annotation360/AnnotationPolygonDomainObject.ts create mode 100644 react-components/src/architecture/concrete/annotation360/AnnotationPolygonTool.ts create mode 100644 react-components/src/architecture/concrete/annotation360/AnnotationPolygonTypeCommand.ts diff --git a/react-components/src/architecture/base/concreteCommands/NavigationTool.ts b/react-components/src/architecture/base/concreteCommands/NavigationTool.ts index a741c009e06..5d545e1b234 100644 --- a/react-components/src/architecture/base/concreteCommands/NavigationTool.ts +++ b/react-components/src/architecture/base/concreteCommands/NavigationTool.ts @@ -88,7 +88,7 @@ export class NavigationTool extends BaseTool { } public override onEscapeKey(): void { - if (this.renderTarget.viewer.canDoImage360Action(Image360Action.Exit)) { + if (this.renderTarget.isInside360Image) { void this.renderTarget.viewer.image360Action(Image360Action.Exit).then(() => { CommandsUpdater.update(this.renderTarget); }); diff --git a/react-components/src/architecture/base/domainObjectsHelpers/BaseCreator.ts b/react-components/src/architecture/base/domainObjectsHelpers/BaseCreator.ts index e2e47bf77ad..056e6c5db35 100644 --- a/react-components/src/architecture/base/domainObjectsHelpers/BaseCreator.ts +++ b/react-components/src/architecture/base/domainObjectsHelpers/BaseCreator.ts @@ -136,11 +136,7 @@ export abstract class BaseCreator { return this.notPendingPointCount >= this.maximumPointCount; } - public addPoint( - ray: Ray, - intersection: AnyIntersection | undefined, - isPending: boolean = false - ): boolean { + public addPoint(ray: Ray, intersection?: AnyIntersection, isPending: boolean = false): boolean { const point = intersection?.point.clone(); this.convertToCdfCoords(ray, point); return this.addPointCore(ray, point, isPending); diff --git a/react-components/src/architecture/base/renderTarget/RevealRenderTarget.ts b/react-components/src/architecture/base/renderTarget/RevealRenderTarget.ts index 8cbbbae3ce7..7a7fc36ea26 100644 --- a/react-components/src/architecture/base/renderTarget/RevealRenderTarget.ts +++ b/react-components/src/architecture/base/renderTarget/RevealRenderTarget.ts @@ -11,7 +11,8 @@ import { CDF_TO_VIEWER_TRANSFORMATION, CognitePointCloudModel, CogniteCadModel, - type Image360Collection + type Image360Collection, + Image360Action } from '@cognite/reveal'; import { Vector3, @@ -85,6 +86,10 @@ export class RevealRenderTarget { return this._viewer; } + public get isInside360Image(): boolean { + return this._viewer.canDoImage360Action(Image360Action.Exit); + } + public get config(): BaseRevealConfig | undefined { return this._config; } diff --git a/react-components/src/architecture/concrete/measurements/getIconByPrimitiveType.ts b/react-components/src/architecture/base/utilities/primitives/getIconByPrimitiveType.ts similarity index 86% rename from react-components/src/architecture/concrete/measurements/getIconByPrimitiveType.ts rename to react-components/src/architecture/base/utilities/primitives/getIconByPrimitiveType.ts index 2d65bffff96..40f778ce757 100644 --- a/react-components/src/architecture/concrete/measurements/getIconByPrimitiveType.ts +++ b/react-components/src/architecture/base/utilities/primitives/getIconByPrimitiveType.ts @@ -2,8 +2,8 @@ * Copyright 2024 Cognite AS */ -import { type IconName } from '../../base/utilities/IconName'; -import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; +import { type IconName } from '../IconName'; +import { PrimitiveType } from './PrimitiveType'; export function getIconByPrimitiveType(primitiveType: PrimitiveType): IconName { switch (primitiveType) { @@ -34,7 +34,7 @@ export function getIconByPrimitiveType(primitiveType: PrimitiveType): IconName { case PrimitiveType.HorizontalCylinder: return 'CylinderHorizontal'; case PrimitiveType.None: - return 'Edit'; + return 'Cursor'; default: throw new Error('Unrecognized PrimitiveType'); } diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonCreator.ts b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonCreator.ts new file mode 100644 index 00000000000..de2a313e005 --- /dev/null +++ b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonCreator.ts @@ -0,0 +1,47 @@ +/*! + * Copyright 2024 Cognite AS + */ + +import { type Ray, type Vector3 } from 'three'; +import { AnnotationPolygonDomainObject } from './AnnotationPolygonDomainObject'; +import { type BaseTool } from '../../base/commands/BaseTool'; +import { LineCreator } from '../primitives/line/LineCreator'; + +/** + * Helper class for generate a LineDomainObject by clicking around + */ +export class AnnotationPolygonCreator extends LineCreator { + // ================================================== + // CONSTRUCTOR + // ================================================== + + public constructor(tool: BaseTool) { + super(tool, new AnnotationPolygonDomainObject()); + } + + // ================================================== + // OVERRIDES + // ================================================== + + public override get preferIntersection(): boolean { + return false; + } + + public override get minimumPointCount(): number { + return 3; + } + + public override get maximumPointCount(): number { + return Number.MAX_SAFE_INTEGER; + } + + protected override transformInputPoint( + ray: Ray, + point: Vector3 | undefined, + _isPending: boolean + ): Vector3 | undefined { + point = ray.origin.clone(); + point.addScaledVector(ray.direction, 5); + return point; + } +} diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonDomainObject.ts b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonDomainObject.ts new file mode 100644 index 00000000000..3fc84488f0e --- /dev/null +++ b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonDomainObject.ts @@ -0,0 +1,61 @@ +/*! + * Copyright 2024 Cognite AS + */ + +import { type DomainObject } from '../../base/domainObjects/DomainObject'; +import { FocusType } from '../../base/domainObjectsHelpers/FocusType'; +import { PanelInfo } from '../../base/domainObjectsHelpers/PanelInfo'; +import { type RenderStyle } from '../../base/renderStyles/RenderStyle'; +import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; +import { type TranslateKey } from '../../base/utilities/TranslateKey'; +import { LineDomainObject } from '../primitives/line/LineDomainObject'; +import { Color } from 'three'; +import { LineRenderStyle } from '../primitives/line/LineRenderStyle'; + +export class AnnotationPolygonDomainObject extends LineDomainObject { + // ================================================== + // CONSTRUCTOR + // ================================================== + + public constructor() { + super(PrimitiveType.Polygon); + this.color = new Color(Color.NAMES.red); + } + + // ================================================== + // OVERRIDES + // ================================================== + + public override get typeName(): TranslateKey { + return { fallback: 'Annotation polygon' }; + } + + public override clone(what?: symbol): DomainObject { + const clone = new AnnotationPolygonDomainObject(); + clone.copyFrom(this, what); + return clone; + } + + public override get hasPanelInfo(): boolean { + return false; + } + + public override getPanelInfo(): PanelInfo | undefined { + if (this.focusType === FocusType.Pending && this.points.length <= 1) { + return undefined; + } + const info = new PanelInfo(); + info.setHeader(this.typeName); + return info; + } + + public override createRenderStyle(): RenderStyle | undefined { + const style = new LineRenderStyle(); + style.showLabel = false; + // style.lineWidth = 4; + // style.selectedLineWidth = style.lineWidth * 2; + style.pipeRadius = 0.01; + style.selectedPipeRadius = 2 * style.pipeRadius; + return style; + } +} diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTool.ts b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTool.ts new file mode 100644 index 00000000000..c4a1781a220 --- /dev/null +++ b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTool.ts @@ -0,0 +1,143 @@ +/*! + * Copyright 2024 Cognite AS + */ + +import { type BaseCreator } from '../../base/domainObjectsHelpers/BaseCreator'; +import { type TranslateKey } from '../../base/utilities/TranslateKey'; +import { PrimitiveEditTool } from '../primitives/tools/PrimitiveEditTool'; +import { AnnotationPolygonDomainObject } from './AnnotationPolygonDomainObject'; +import { type VisualDomainObject } from '../../base/domainObjects/VisualDomainObject'; +import { type IconName } from '../../base/utilities/IconName'; +import { AnnotationPolygonCreator } from './AnnotationPolygonCreator'; +import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; +import { AnnotationPolygonTypeCommand } from './AnnotationPolygonTypeCommand'; +import { UndoCommand } from '../../base/concreteCommands/UndoCommand'; +import { type BaseCommand } from '../../base/commands/BaseCommand'; +import { Changes } from '../../base/domainObjectsHelpers/Changes'; + +export class AnnotationPolygonTool extends PrimitiveEditTool { + // ================================================== + // CONSTRUCTOR + // ================================================== + + public constructor() { + super(); + this.primitiveType = PrimitiveType.Polygon; + } + + // ================================================== + // OVERRIDES of BaseCommand + // ================================================== + + public override get icon(): IconName { + return 'Polygon'; + } + + public override get tooltip(): TranslateKey { + return { fallback: 'Create or delete annotation polygon' }; + } + + public override get isEnabled(): boolean { + return true; // this.renderTarget.isInside360Image; + } + + public override getToolbar(): Array { + return [ + new AnnotationPolygonTypeCommand(PrimitiveType.None), + new AnnotationPolygonTypeCommand(PrimitiveType.Polygon), + undefined, // Separator + new UndoCommand() + ]; + } + + public override update(): void { + super.update(); + if (this.isChecked && !this.isEnabled) { + this.renderTarget.commandsController.activateDefaultTool(); + } + } + + // ================================================== + // OVERRIDES of BaseTool + // ================================================== + + public override onActivate(): void { + super.onActivate(); + + for (const domainObject of this.getSelectable()) { + // Get the image and set it visible + domainObject.setVisibleInteractive(true, this.renderTarget); + } + } + + public override onDeactivate(): void { + super.onDeactivate(); + this.setAllVisible(false); + } + + public override async onHoverByDebounce(event: PointerEvent): Promise { + if (!this.isEdit) { + const creator = this._creator; + if (creator === undefined) { + this.setDefaultCursor(); + return; + } + // Hover in the "air" + const ray = this.getRay(event); + if (creator.addPoint(ray, undefined, true)) { + this.setDefaultCursor(); + return; + } + } + await super.onHoverByDebounce(event); + } + + public override async onClick(event: PointerEvent): Promise { + if (!this.isEdit) { + let creator = this._creator; + if (creator !== undefined) { + const ray = this.getRay(event); + if (creator.addPoint(ray)) { + this.endCreatorIfFinished(creator); + } + return; + } else { + creator = this.createCreator(); + if (creator === undefined) { + await super.onClick(event); + return; + } + const ray = this.getRay(event); + if (!creator.addPoint(ray)) { + return; + } + const { domainObject } = creator; + this.deselectAll(); + + const parent = this.getOrCreateParent(); + parent.addChildInteractive(domainObject); + domainObject.setSelectedInteractive(true); + domainObject.setVisibleInteractive(true); + this.addTransaction(domainObject.createTransaction(Changes.added)); + this._creator = creator; + } + } + await super.onClick(event); + } + + // ================================================== + // OVERRIDES of BaseEditTool + // ================================================== + + protected override canBeSelected(domainObject: VisualDomainObject): boolean { + return domainObject instanceof AnnotationPolygonDomainObject; + } + + // ================================================== + // OVERRIDES of PrimitiveEditTool + // ================================================== + + protected override createCreator(): BaseCreator | undefined { + return new AnnotationPolygonCreator(this); + } +} diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTypeCommand.ts b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTypeCommand.ts new file mode 100644 index 00000000000..e6573610d37 --- /dev/null +++ b/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTypeCommand.ts @@ -0,0 +1,95 @@ +/*! + * Copyright 2024 Cognite AS + */ + +import { type BaseCommand } from '../../base/commands/BaseCommand'; +import { RenderTargetCommand } from '../../base/commands/RenderTargetCommand'; +import { type IconName } from '../../base/utilities/IconName'; +import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; +import { type TranslateKey } from '../../base/utilities/TranslateKey'; +import { getIconByPrimitiveType } from '../../base/utilities/primitives/getIconByPrimitiveType'; +import { AnnotationPolygonTool } from './AnnotationPolygonTool'; + +export class AnnotationPolygonTypeCommand extends RenderTargetCommand { + private readonly _primitiveType: PrimitiveType; + + // ================================================== + // CONSTRUCTOR + // ================================================== + + public constructor(primitiveType: PrimitiveType) { + super(); + this._primitiveType = primitiveType; + } + + // ================================================== + // OVERRIDES of BaseCommand + // ================================================== + + public override get icon(): IconName { + return getIconByPrimitiveType(this._primitiveType); + } + + public override get tooltip(): TranslateKey { + return getTooltipByPrimitiveType(this._primitiveType); + } + + public override get isEnabled(): boolean { + return this.tool !== undefined; + } + + public override get isChecked(): boolean { + const { tool } = this; + if (tool === undefined) { + return false; + } + return tool.primitiveType === this._primitiveType; + } + + protected override invokeCore(): boolean { + const { tool } = this; + if (tool === undefined) { + return false; + } + tool.onEscapeKey(); + tool.clearDragging(); + if (tool.primitiveType === this._primitiveType) { + tool.primitiveType = PrimitiveType.None; + } else { + tool.primitiveType = this._primitiveType; + } + return true; + } + + public override equals(other: BaseCommand): boolean { + if (!(other instanceof AnnotationPolygonTypeCommand)) { + return false; + } + return this._primitiveType === other._primitiveType; + } + + // ================================================== + // INSTANCE METHODS + // ================================================== + + private get tool(): AnnotationPolygonTool | undefined { + return this.getActiveTool(AnnotationPolygonTool); + } +} + +// ================================================== +// PRIMATE FUNCTIONS +// ================================================== + +function getTooltipByPrimitiveType(primitiveType: PrimitiveType): TranslateKey { + switch (primitiveType) { + case PrimitiveType.Polygon: + return { + fallback: 'Create polygon. Click at least 3 points and end with Esc.' + }; + default: + return { + fallback: 'Select polygon.' + }; + } +} diff --git a/react-components/src/architecture/concrete/annotations/commands/AnnotationsCreateTool.ts b/react-components/src/architecture/concrete/annotations/commands/AnnotationsCreateTool.ts index b3eda1ac6de..d82b8e0b595 100644 --- a/react-components/src/architecture/concrete/annotations/commands/AnnotationsCreateTool.ts +++ b/react-components/src/architecture/concrete/annotations/commands/AnnotationsCreateTool.ts @@ -135,7 +135,7 @@ export class AnnotationsCreateTool extends NavigationTool { // Click in the "air" if (creator !== undefined) { const ray = this.getRay(event); - if (creator.addPoint(ray, undefined)) { + if (creator.addPoint(ray)) { this.endCreatorIfFinished(creator); return; } diff --git a/react-components/src/architecture/concrete/clipping/commands/SetClipTypeCommand.ts b/react-components/src/architecture/concrete/clipping/commands/SetClipTypeCommand.ts index 6c81b570a6d..643085c9e4a 100644 --- a/react-components/src/architecture/concrete/clipping/commands/SetClipTypeCommand.ts +++ b/react-components/src/architecture/concrete/clipping/commands/SetClipTypeCommand.ts @@ -7,7 +7,7 @@ import { type BaseCommand } from '../../../base/commands/BaseCommand'; import { PrimitiveType } from '../../../base/utilities/primitives/PrimitiveType'; import { type TranslateKey } from '../../../base/utilities/TranslateKey'; import { ClipTool } from '../ClipTool'; -import { getIconByPrimitiveType } from '../../measurements/getIconByPrimitiveType'; +import { getIconByPrimitiveType } from '../../../base/utilities/primitives/getIconByPrimitiveType'; import { SliceDomainObject } from '../SliceDomainObject'; import { type IconName } from '../../../base/utilities/IconName'; diff --git a/react-components/src/architecture/concrete/config/StoryBookConfig.ts b/react-components/src/architecture/concrete/config/StoryBookConfig.ts index 84c3fef723e..141bd8536d7 100644 --- a/react-components/src/architecture/concrete/config/StoryBookConfig.ts +++ b/react-components/src/architecture/concrete/config/StoryBookConfig.ts @@ -31,6 +31,7 @@ import { type DmsUniqueIdentifier } from '../../../data-providers'; import { PointsOfInterestTool } from '../pointsOfInterest/PointsOfInterestTool'; import { Image360ActionCommand } from '../../base/concreteCommands/image360Collection/Image360ActionCommand'; import { Image360Action } from '@cognite/reveal'; +import { AnnotationPolygonTool } from '../annotation360/AnnotationPolygonTool'; export class StoryBookConfig extends BaseRevealConfig { // ================================================== @@ -60,6 +61,7 @@ export class StoryBookConfig extends BaseRevealConfig { new ToggleAllModelsVisibleCommand(), new ToggleMetricUnitsCommand(), new SettingsCommand(), + new AnnotationPolygonTool(), undefined, new MeasurementTool(), new ClipTool(), diff --git a/react-components/src/architecture/concrete/measurements/commands/SetMeasurementTypeCommand.ts b/react-components/src/architecture/concrete/measurements/commands/SetMeasurementTypeCommand.ts index 53fd461aa7c..222afe295d8 100644 --- a/react-components/src/architecture/concrete/measurements/commands/SetMeasurementTypeCommand.ts +++ b/react-components/src/architecture/concrete/measurements/commands/SetMeasurementTypeCommand.ts @@ -5,7 +5,7 @@ import { RenderTargetCommand } from '../../../base/commands/RenderTargetCommand'; import { type BaseCommand } from '../../../base/commands/BaseCommand'; import { PrimitiveType } from '../../../base/utilities/primitives/PrimitiveType'; -import { getIconByPrimitiveType } from '../getIconByPrimitiveType'; +import { getIconByPrimitiveType } from '../../../base/utilities/primitives/getIconByPrimitiveType'; import { type TranslateKey } from '../../../base/utilities/TranslateKey'; import { MeasurementTool } from '../MeasurementTool'; import { type IconName } from '../../../base/utilities/IconName'; diff --git a/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts b/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts index 56a40f6fd44..863bd786cca 100644 --- a/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts @@ -12,7 +12,7 @@ import { type PrimitivePickInfo } from '../common/PrimitivePickInfo'; import { type BaseDragger } from '../../../base/domainObjectsHelpers/BaseDragger'; import { BoxDragger } from './BoxDragger'; import { type CreateDraggerProps } from '../../../base/domainObjects/VisualDomainObject'; -import { getIconByPrimitiveType } from '../../measurements/getIconByPrimitiveType'; +import { getIconByPrimitiveType } from '../../../base/utilities/primitives/getIconByPrimitiveType'; import { type TranslateKey } from '../../../base/utilities/TranslateKey'; import { Quantity } from '../../../base/domainObjectsHelpers/Quantity'; import { PanelInfo } from '../../../base/domainObjectsHelpers/PanelInfo'; diff --git a/react-components/src/architecture/concrete/primitives/common/SolidDomainObject.ts b/react-components/src/architecture/concrete/primitives/common/SolidDomainObject.ts index 3e9752099ae..bdc5ba963e1 100644 --- a/react-components/src/architecture/concrete/primitives/common/SolidDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/common/SolidDomainObject.ts @@ -8,7 +8,7 @@ import { BoxFace } from './BoxFace'; import { FocusType } from '../../../base/domainObjectsHelpers/FocusType'; import { type PrimitiveType } from '../../../base/utilities/primitives/PrimitiveType'; import { VisualDomainObject } from '../../../base/domainObjects/VisualDomainObject'; -import { getIconByPrimitiveType } from '../../measurements/getIconByPrimitiveType'; +import { getIconByPrimitiveType } from '../../../base/utilities/primitives/getIconByPrimitiveType'; import { DomainObjectTransaction } from '../../../base/undo/DomainObjectTransaction'; import { type Transaction } from '../../../base/undo/Transaction'; import { type IconName } from '../../../base/utilities/IconName'; diff --git a/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts b/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts index 660227154c1..94e9412e154 100644 --- a/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts @@ -12,7 +12,7 @@ import { type PrimitivePickInfo } from '../common/PrimitivePickInfo'; import { type BaseDragger } from '../../../base/domainObjectsHelpers/BaseDragger'; import { CylinderDragger } from './CylinderDragger'; import { type CreateDraggerProps } from '../../../base/domainObjects/VisualDomainObject'; -import { getIconByPrimitiveType } from '../../measurements/getIconByPrimitiveType'; +import { getIconByPrimitiveType } from '../../../base/utilities/primitives/getIconByPrimitiveType'; import { type TranslateKey } from '../../../base/utilities/TranslateKey'; import { Quantity } from '../../../base/domainObjectsHelpers/Quantity'; import { PanelInfo } from '../../../base/domainObjectsHelpers/PanelInfo'; diff --git a/react-components/src/architecture/concrete/primitives/line/LineCreator.ts b/react-components/src/architecture/concrete/primitives/line/LineCreator.ts index 0e84ad4715a..5e44cb1fa67 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineCreator.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineCreator.ts @@ -65,17 +65,7 @@ export class LineCreator extends BaseCreator { point: Vector3 | undefined, isPending: boolean ): boolean { - // Figure out where the point should be if no intersection - - if (isPending && this.notPendingPointCount >= 1 && point === undefined) { - const lastPoint = this.lastNotPendingPoint; - const plane = new Plane().setFromNormalAndCoplanarPoint(ray.direction, lastPoint); - const newPoint = ray.intersectPlane(plane, new Vector3()); - if (newPoint === null) { - return false; - } - point = newPoint; - } + point = this.transformInputPoint(ray, point, isPending); if (point === undefined) { return false; } @@ -118,4 +108,26 @@ export class LineCreator extends BaseCreator { } return true; // Successfully } + + // ================================================== + // VIRTUAL METHODS + // ================================================== + + protected transformInputPoint( + ray: Ray, + point: Vector3 | undefined, + isPending: boolean + ): Vector3 | undefined { + if (!isPending || this.notPendingPointCount === 1 || point !== undefined) { + return point; + } + // Figure out where the point should be if no intersection + const lastPoint = this.lastNotPendingPoint; + const plane = new Plane().setFromNormalAndCoplanarPoint(ray.direction, lastPoint); + const newPoint = ray.intersectPlane(plane, new Vector3()); + if (newPoint === null) { + return undefined; + } + return newPoint; + } } diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index 3c1189f19df..8bdd5cf0ad2 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -18,7 +18,7 @@ import { Changes } from '../../../base/domainObjectsHelpers/Changes'; import { FocusType } from '../../../base/domainObjectsHelpers/FocusType'; import { Quantity } from '../../../base/domainObjectsHelpers/Quantity'; import { VisualDomainObject } from '../../../base/domainObjects/VisualDomainObject'; -import { getIconByPrimitiveType } from '../../measurements/getIconByPrimitiveType'; +import { getIconByPrimitiveType } from '../../../base/utilities/primitives/getIconByPrimitiveType'; import { type TranslateKey } from '../../../base/utilities/TranslateKey'; import { clear } from '../../../base/utilities/extensions/arrayExtensions'; import { type Transaction } from '../../../base/undo/Transaction'; diff --git a/react-components/src/architecture/concrete/primitives/plane/PlaneDomainObject.ts b/react-components/src/architecture/concrete/primitives/plane/PlaneDomainObject.ts index f7312412c31..545727a0c6a 100644 --- a/react-components/src/architecture/concrete/primitives/plane/PlaneDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/plane/PlaneDomainObject.ts @@ -14,7 +14,7 @@ import { type CreateDraggerProps } from '../../../base/domainObjects/VisualDomainObject'; import { PlaneDragger } from './PlaneDragger'; -import { getIconByPrimitiveType } from '../../measurements/getIconByPrimitiveType'; +import { getIconByPrimitiveType } from '../../../base/utilities/primitives/getIconByPrimitiveType'; import { getComplementary } from '../../../base/utilities/colors/colorExtensions'; import { horizontalAngle, diff --git a/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts b/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts index 557e7582579..684bf3d77e6 100644 --- a/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts +++ b/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts @@ -21,7 +21,7 @@ export abstract class PrimitiveEditTool extends BaseEditTool { // INSTANCE FIELDS // ================================================== - private _creator: BaseCreator | undefined = undefined; + protected _creator: BaseCreator | undefined = undefined; public primitiveType: PrimitiveType; public readonly defaultPrimitiveType: PrimitiveType; @@ -135,7 +135,7 @@ export abstract class PrimitiveEditTool extends BaseEditTool { // Click in the "air" if (creator !== undefined && !creator.preferIntersection) { const ray = this.getRay(event); - if (creator.addPoint(ray, undefined)) { + if (creator.addPoint(ray)) { this.endCreatorIfFinished(creator); return; } @@ -273,7 +273,7 @@ export abstract class PrimitiveEditTool extends BaseEditTool { return undefined; } - private setDefaultPrimitiveType(): void { + protected setDefaultPrimitiveType(): void { if (this.primitiveType === this.defaultPrimitiveType) { return; } @@ -281,7 +281,7 @@ export abstract class PrimitiveEditTool extends BaseEditTool { CommandsUpdater.update(this.renderTarget); } - private endCreatorIfFinished(creator: BaseCreator, force = false): void { + protected endCreatorIfFinished(creator: BaseCreator, force = false): void { if (force || creator.isFinished) { this.setDefaultPrimitiveType(); this._creator = undefined; From 73c5bd784568359ffe09d91b4153cb53d6169afe Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:26:13 +0100 Subject: [PATCH 02/23] Renaming --- .../base/commands/InstanceCommand.ts | 8 ++++ ...DeleteSelectedImage360AnnotationCommand.ts | 43 +++++++++++++++++++ ...reator.ts => Image360AnnotationCreator.ts} | 9 ++-- ...t.ts => Image360AnnotationDomainObject.ts} | 15 +------ ...s => Image360AnnotationEditTypeCommand.ts} | 12 +++--- ...lygonTool.ts => Image360AnnotationTool.ts} | 21 +++++---- .../concrete/config/StoryBookConfig.ts | 4 +- 7 files changed, 76 insertions(+), 36 deletions(-) create mode 100644 react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts rename react-components/src/architecture/concrete/annotation360/{AnnotationPolygonCreator.ts => Image360AnnotationCreator.ts} (78%) rename react-components/src/architecture/concrete/annotation360/{AnnotationPolygonDomainObject.ts => Image360AnnotationDomainObject.ts} (73%) rename react-components/src/architecture/concrete/annotation360/{AnnotationPolygonTypeCommand.ts => Image360AnnotationEditTypeCommand.ts} (87%) rename react-components/src/architecture/concrete/annotation360/{AnnotationPolygonTool.ts => Image360AnnotationTool.ts} (83%) diff --git a/react-components/src/architecture/base/commands/InstanceCommand.ts b/react-components/src/architecture/base/commands/InstanceCommand.ts index 8fcb73c98fd..11f9e78ea60 100644 --- a/react-components/src/architecture/base/commands/InstanceCommand.ts +++ b/react-components/src/architecture/base/commands/InstanceCommand.ts @@ -39,4 +39,12 @@ export abstract class InstanceCommand extends RenderTargetCommand { } } } + + protected *getSelectedInstances(): Generator { + for (const domainObject of this.getInstances()) { + if (domainObject.isSelected) { + yield domainObject; + } + } + } } diff --git a/react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts b/react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts new file mode 100644 index 00000000000..028b086a84d --- /dev/null +++ b/react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts @@ -0,0 +1,43 @@ +/*! + * Copyright 2024 Cognite AS + */ + +import { InstanceCommand } from '../../base/commands/InstanceCommand'; +import { type DomainObject } from '../../base/domainObjects/DomainObject'; +import { Changes } from '../../base/domainObjectsHelpers/Changes'; +import { type IconName } from '../../base/utilities/IconName'; +import { type TranslateKey } from '../../base/utilities/TranslateKey'; +import { Image360AnnotationDomainObject } from './Image360AnnotationDomainObject'; + +export class DeleteSelectedImage360AnnotationCommand extends InstanceCommand { + public override get tooltip(): TranslateKey { + return { fallback: 'Remove selected polygon' }; + } + + public override get icon(): IconName { + return 'Delete'; + } + + public override get buttonType(): string { + return 'ghost-destructive'; + } + + public override get isEnabled(): boolean { + const first = this.getSelectedInstances().next().value; + return first !== undefined && first.canBeRemoved; + } + + protected override invokeCore(): boolean { + const array = Array.from(this.getSelectedInstances()); + array.reverse(); + for (const domainObject of array) { + this.addTransaction(domainObject.createTransaction(Changes.deleted)); + domainObject.removeInteractive(); + } + return true; + } + + protected override isInstance(domainObject: DomainObject): boolean { + return domainObject instanceof Image360AnnotationDomainObject; + } +} diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonCreator.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts similarity index 78% rename from react-components/src/architecture/concrete/annotation360/AnnotationPolygonCreator.ts rename to react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts index de2a313e005..c2abad9d3c5 100644 --- a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonCreator.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts @@ -3,20 +3,17 @@ */ import { type Ray, type Vector3 } from 'three'; -import { AnnotationPolygonDomainObject } from './AnnotationPolygonDomainObject'; +import { Image360AnnotationDomainObject } from './Image360AnnotationDomainObject'; import { type BaseTool } from '../../base/commands/BaseTool'; import { LineCreator } from '../primitives/line/LineCreator'; -/** - * Helper class for generate a LineDomainObject by clicking around - */ -export class AnnotationPolygonCreator extends LineCreator { +export class Image360AnnotationCreator extends LineCreator { // ================================================== // CONSTRUCTOR // ================================================== public constructor(tool: BaseTool) { - super(tool, new AnnotationPolygonDomainObject()); + super(tool, new Image360AnnotationDomainObject()); } // ================================================== diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts similarity index 73% rename from react-components/src/architecture/concrete/annotation360/AnnotationPolygonDomainObject.ts rename to react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index 3fc84488f0e..3c5bda45207 100644 --- a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -3,8 +3,6 @@ */ import { type DomainObject } from '../../base/domainObjects/DomainObject'; -import { FocusType } from '../../base/domainObjectsHelpers/FocusType'; -import { PanelInfo } from '../../base/domainObjectsHelpers/PanelInfo'; import { type RenderStyle } from '../../base/renderStyles/RenderStyle'; import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; import { type TranslateKey } from '../../base/utilities/TranslateKey'; @@ -12,7 +10,7 @@ import { LineDomainObject } from '../primitives/line/LineDomainObject'; import { Color } from 'three'; import { LineRenderStyle } from '../primitives/line/LineRenderStyle'; -export class AnnotationPolygonDomainObject extends LineDomainObject { +export class Image360AnnotationDomainObject extends LineDomainObject { // ================================================== // CONSTRUCTOR // ================================================== @@ -31,7 +29,7 @@ export class AnnotationPolygonDomainObject extends LineDomainObject { } public override clone(what?: symbol): DomainObject { - const clone = new AnnotationPolygonDomainObject(); + const clone = new Image360AnnotationDomainObject(); clone.copyFrom(this, what); return clone; } @@ -40,15 +38,6 @@ export class AnnotationPolygonDomainObject extends LineDomainObject { return false; } - public override getPanelInfo(): PanelInfo | undefined { - if (this.focusType === FocusType.Pending && this.points.length <= 1) { - return undefined; - } - const info = new PanelInfo(); - info.setHeader(this.typeName); - return info; - } - public override createRenderStyle(): RenderStyle | undefined { const style = new LineRenderStyle(); style.showLabel = false; diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTypeCommand.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationEditTypeCommand.ts similarity index 87% rename from react-components/src/architecture/concrete/annotation360/AnnotationPolygonTypeCommand.ts rename to react-components/src/architecture/concrete/annotation360/Image360AnnotationEditTypeCommand.ts index e6573610d37..7e2c48169b1 100644 --- a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTypeCommand.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationEditTypeCommand.ts @@ -8,9 +8,9 @@ import { type IconName } from '../../base/utilities/IconName'; import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; import { type TranslateKey } from '../../base/utilities/TranslateKey'; import { getIconByPrimitiveType } from '../../base/utilities/primitives/getIconByPrimitiveType'; -import { AnnotationPolygonTool } from './AnnotationPolygonTool'; +import { Image360AnnotationTool } from './Image360AnnotationTool'; -export class AnnotationPolygonTypeCommand extends RenderTargetCommand { +export class Image360AnnotationEditTypeCommand extends RenderTargetCommand { private readonly _primitiveType: PrimitiveType; // ================================================== @@ -62,7 +62,7 @@ export class AnnotationPolygonTypeCommand extends RenderTargetCommand { } public override equals(other: BaseCommand): boolean { - if (!(other instanceof AnnotationPolygonTypeCommand)) { + if (!(other instanceof Image360AnnotationEditTypeCommand)) { return false; } return this._primitiveType === other._primitiveType; @@ -72,13 +72,13 @@ export class AnnotationPolygonTypeCommand extends RenderTargetCommand { // INSTANCE METHODS // ================================================== - private get tool(): AnnotationPolygonTool | undefined { - return this.getActiveTool(AnnotationPolygonTool); + private get tool(): Image360AnnotationTool | undefined { + return this.getActiveTool(Image360AnnotationTool); } } // ================================================== -// PRIMATE FUNCTIONS +// PRIVATE FUNCTIONS // ================================================== function getTooltipByPrimitiveType(primitiveType: PrimitiveType): TranslateKey { diff --git a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTool.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts similarity index 83% rename from react-components/src/architecture/concrete/annotation360/AnnotationPolygonTool.ts rename to react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts index c4a1781a220..de72d64b9f6 100644 --- a/react-components/src/architecture/concrete/annotation360/AnnotationPolygonTool.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts @@ -5,17 +5,18 @@ import { type BaseCreator } from '../../base/domainObjectsHelpers/BaseCreator'; import { type TranslateKey } from '../../base/utilities/TranslateKey'; import { PrimitiveEditTool } from '../primitives/tools/PrimitiveEditTool'; -import { AnnotationPolygonDomainObject } from './AnnotationPolygonDomainObject'; +import { Image360AnnotationDomainObject } from './Image360AnnotationDomainObject'; import { type VisualDomainObject } from '../../base/domainObjects/VisualDomainObject'; import { type IconName } from '../../base/utilities/IconName'; -import { AnnotationPolygonCreator } from './AnnotationPolygonCreator'; +import { Image360AnnotationCreator } from './Image360AnnotationCreator'; import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; -import { AnnotationPolygonTypeCommand } from './AnnotationPolygonTypeCommand'; +import { Image360AnnotationEditTypeCommand } from './Image360AnnotationEditTypeCommand'; import { UndoCommand } from '../../base/concreteCommands/UndoCommand'; import { type BaseCommand } from '../../base/commands/BaseCommand'; import { Changes } from '../../base/domainObjectsHelpers/Changes'; +import { DeleteSelectedImage360AnnotationCommand } from './DeleteSelectedImage360AnnotationCommand'; -export class AnnotationPolygonTool extends PrimitiveEditTool { +export class Image360AnnotationTool extends PrimitiveEditTool { // ================================================== // CONSTRUCTOR // ================================================== @@ -38,14 +39,16 @@ export class AnnotationPolygonTool extends PrimitiveEditTool { } public override get isEnabled(): boolean { + // ANDERS: Now it works for all states return true; // this.renderTarget.isInside360Image; } public override getToolbar(): Array { return [ - new AnnotationPolygonTypeCommand(PrimitiveType.None), - new AnnotationPolygonTypeCommand(PrimitiveType.Polygon), + new Image360AnnotationEditTypeCommand(PrimitiveType.None), + new Image360AnnotationEditTypeCommand(PrimitiveType.Polygon), undefined, // Separator + new DeleteSelectedImage360AnnotationCommand(), new UndoCommand() ]; } @@ -65,7 +68,7 @@ export class AnnotationPolygonTool extends PrimitiveEditTool { super.onActivate(); for (const domainObject of this.getSelectable()) { - // Get the image and set it visible + // ANDERS: Get the image and set it visible domainObject.setVisibleInteractive(true, this.renderTarget); } } @@ -130,7 +133,7 @@ export class AnnotationPolygonTool extends PrimitiveEditTool { // ================================================== protected override canBeSelected(domainObject: VisualDomainObject): boolean { - return domainObject instanceof AnnotationPolygonDomainObject; + return domainObject instanceof Image360AnnotationDomainObject; } // ================================================== @@ -138,6 +141,6 @@ export class AnnotationPolygonTool extends PrimitiveEditTool { // ================================================== protected override createCreator(): BaseCreator | undefined { - return new AnnotationPolygonCreator(this); + return new Image360AnnotationCreator(this); } } diff --git a/react-components/src/architecture/concrete/config/StoryBookConfig.ts b/react-components/src/architecture/concrete/config/StoryBookConfig.ts index 141bd8536d7..b5c151c46f3 100644 --- a/react-components/src/architecture/concrete/config/StoryBookConfig.ts +++ b/react-components/src/architecture/concrete/config/StoryBookConfig.ts @@ -31,7 +31,7 @@ import { type DmsUniqueIdentifier } from '../../../data-providers'; import { PointsOfInterestTool } from '../pointsOfInterest/PointsOfInterestTool'; import { Image360ActionCommand } from '../../base/concreteCommands/image360Collection/Image360ActionCommand'; import { Image360Action } from '@cognite/reveal'; -import { AnnotationPolygonTool } from '../annotation360/AnnotationPolygonTool'; +import { Image360AnnotationTool } from '../annotation360/Image360AnnotationTool'; export class StoryBookConfig extends BaseRevealConfig { // ================================================== @@ -61,7 +61,7 @@ export class StoryBookConfig extends BaseRevealConfig { new ToggleAllModelsVisibleCommand(), new ToggleMetricUnitsCommand(), new SettingsCommand(), - new AnnotationPolygonTool(), + new Image360AnnotationTool(), undefined, new MeasurementTool(), new ClipTool(), From 66554cf86d9543ad5b9143fff948ff45a64ce6b8 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:41:55 +0100 Subject: [PATCH 03/23] Fixes --- .../base/commands/InstanceCommand.ts | 8 -------- .../DeleteSelectedImage360AnnotationCommand.ts | 16 ++++++++++++---- .../annotation360/Image360AnnotationTool.ts | 5 ++--- .../primitives/tools/PrimitiveEditTool.ts | 9 +++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/react-components/src/architecture/base/commands/InstanceCommand.ts b/react-components/src/architecture/base/commands/InstanceCommand.ts index 11f9e78ea60..8fcb73c98fd 100644 --- a/react-components/src/architecture/base/commands/InstanceCommand.ts +++ b/react-components/src/architecture/base/commands/InstanceCommand.ts @@ -39,12 +39,4 @@ export abstract class InstanceCommand extends RenderTargetCommand { } } } - - protected *getSelectedInstances(): Generator { - for (const domainObject of this.getInstances()) { - if (domainObject.isSelected) { - yield domainObject; - } - } - } } diff --git a/react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts b/react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts index 028b086a84d..1a2a235c4eb 100644 --- a/react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts +++ b/react-components/src/architecture/concrete/annotation360/DeleteSelectedImage360AnnotationCommand.ts @@ -5,6 +5,7 @@ import { InstanceCommand } from '../../base/commands/InstanceCommand'; import { type DomainObject } from '../../base/domainObjects/DomainObject'; import { Changes } from '../../base/domainObjectsHelpers/Changes'; +import { FocusType } from '../../base/domainObjectsHelpers/FocusType'; import { type IconName } from '../../base/utilities/IconName'; import { type TranslateKey } from '../../base/utilities/TranslateKey'; import { Image360AnnotationDomainObject } from './Image360AnnotationDomainObject'; @@ -22,13 +23,16 @@ export class DeleteSelectedImage360AnnotationCommand extends InstanceCommand { return 'ghost-destructive'; } + public override get shortCutKey(): string { + return 'DEL'; + } + public override get isEnabled(): boolean { - const first = this.getSelectedInstances().next().value; - return first !== undefined && first.canBeRemoved; + return this.getFirstInstance() !== undefined; } protected override invokeCore(): boolean { - const array = Array.from(this.getSelectedInstances()); + const array = Array.from(this.getInstances()); array.reverse(); for (const domainObject of array) { this.addTransaction(domainObject.createTransaction(Changes.deleted)); @@ -38,6 +42,10 @@ export class DeleteSelectedImage360AnnotationCommand extends InstanceCommand { } protected override isInstance(domainObject: DomainObject): boolean { - return domainObject instanceof Image360AnnotationDomainObject; + return ( + domainObject instanceof Image360AnnotationDomainObject && + domainObject.isSelected && + domainObject.focusType !== FocusType.Pending + ); } } diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts index de72d64b9f6..00a3a37a518 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts @@ -65,17 +65,16 @@ export class Image360AnnotationTool extends PrimitiveEditTool { // ================================================== public override onActivate(): void { - super.onActivate(); - for (const domainObject of this.getSelectable()) { // ANDERS: Get the image and set it visible domainObject.setVisibleInteractive(true, this.renderTarget); } + super.onActivate(); } public override onDeactivate(): void { - super.onDeactivate(); this.setAllVisible(false); + super.onDeactivate(); } public override async onHoverByDebounce(event: PointerEvent): Promise { diff --git a/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts b/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts index 684bf3d77e6..1954e61e488 100644 --- a/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts +++ b/react-components/src/architecture/concrete/primitives/tools/PrimitiveEditTool.ts @@ -23,7 +23,7 @@ export abstract class PrimitiveEditTool extends BaseEditTool { protected _creator: BaseCreator | undefined = undefined; public primitiveType: PrimitiveType; - public readonly defaultPrimitiveType: PrimitiveType; + private readonly _defaultPrimitiveType: PrimitiveType; public get isEdit(): boolean { return this.primitiveType === PrimitiveType.None; @@ -36,7 +36,7 @@ export abstract class PrimitiveEditTool extends BaseEditTool { public constructor(primitiveType: PrimitiveType = PrimitiveType.None) { super(); this.primitiveType = primitiveType; - this.defaultPrimitiveType = primitiveType; + this._defaultPrimitiveType = primitiveType; } // ================================================== @@ -69,6 +69,7 @@ export abstract class PrimitiveEditTool extends BaseEditTool { this.setDefaultPrimitiveType(); this._creator = undefined; } + CommandsUpdater.update(this.renderTarget); } public override async onHoverByDebounce(event: PointerEvent): Promise { @@ -274,10 +275,10 @@ export abstract class PrimitiveEditTool extends BaseEditTool { } protected setDefaultPrimitiveType(): void { - if (this.primitiveType === this.defaultPrimitiveType) { + if (this.primitiveType === this._defaultPrimitiveType) { return; } - this.primitiveType = this.defaultPrimitiveType; + this.primitiveType = this._defaultPrimitiveType; CommandsUpdater.update(this.renderTarget); } From 8f954c0139fcfb71b5e79701aa0a1948ceff370a Mon Sep 17 00:00:00 2001 From: anders-hopland Date: Tue, 12 Nov 2024 11:09:38 +0100 Subject: [PATCH 04/23] Fix render on top of 360 Image --- .../src/architecture/base/renderStyles/CommonRenderStyle.ts | 2 ++ .../annotation360/Image360AnnotationDomainObject.ts | 6 +++--- .../src/architecture/concrete/primitives/line/LineView.ts | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts b/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts index 176c67adea8..81f96bf1b99 100644 --- a/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts +++ b/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts @@ -10,4 +10,6 @@ export abstract class CommonRenderStyle extends RenderStyle { // ================================================== public depthTest = true; + + public transparent = false; } diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index 3c5bda45207..d715075f9fa 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -41,10 +41,10 @@ export class Image360AnnotationDomainObject extends LineDomainObject { public override createRenderStyle(): RenderStyle | undefined { const style = new LineRenderStyle(); style.showLabel = false; - // style.lineWidth = 4; - // style.selectedLineWidth = style.lineWidth * 2; - style.pipeRadius = 0.01; + style.pipeRadius = 0; style.selectedPipeRadius = 2 * style.pipeRadius; + style.depthTest = false; + style.transparent = true; // Needed to make the line visible through other objects return style; } } diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index 0b87696b4a6..6e57c87ff3e 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -201,7 +201,8 @@ export class LineView extends GroupThreeView { const material = new LineBasicMaterial({ linewidth, color, - depthTest: style.depthTest + depthTest: style.depthTest, + transparent: style.transparent }); const result = new Line(geometry, material); result.renderOrder = RENDER_ORDER; From dfa780752e74529b2e31136cd2fe26ae172dd117 Mon Sep 17 00:00:00 2001 From: anders-hopland Date: Tue, 12 Nov 2024 13:57:13 +0100 Subject: [PATCH 05/23] Connect annotations to their respective 360 images --- .../annotation360/Image360AnnotationCreator.ts | 5 ++++- .../Image360AnnotationDomainObject.ts | 8 ++++++-- .../annotation360/Image360AnnotationTool.ts | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts index c2abad9d3c5..a5c726d6adc 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts @@ -6,6 +6,7 @@ import { type Ray, type Vector3 } from 'three'; import { Image360AnnotationDomainObject } from './Image360AnnotationDomainObject'; import { type BaseTool } from '../../base/commands/BaseTool'; import { LineCreator } from '../primitives/line/LineCreator'; +import assert from 'assert'; export class Image360AnnotationCreator extends LineCreator { // ================================================== @@ -13,7 +14,9 @@ export class Image360AnnotationCreator extends LineCreator { // ================================================== public constructor(tool: BaseTool) { - super(tool, new Image360AnnotationDomainObject()); + const image360Id = tool.renderTarget.viewer.getActive360ImageInfo()?.image360.id; + assert(image360Id !== undefined, 'Image360AnnotationCreator: image360Id is undefined'); + super(tool, new Image360AnnotationDomainObject(image360Id)); } // ================================================== diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index d715075f9fa..818d3fc7f86 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -9,15 +9,19 @@ import { type TranslateKey } from '../../base/utilities/TranslateKey'; import { LineDomainObject } from '../primitives/line/LineDomainObject'; import { Color } from 'three'; import { LineRenderStyle } from '../primitives/line/LineRenderStyle'; +import { type DirectRelationReference } from '@cognite/sdk'; export class Image360AnnotationDomainObject extends LineDomainObject { // ================================================== // CONSTRUCTOR // ================================================== - public constructor() { + public connectedImageId: string | DirectRelationReference; + + public constructor(connectedImageId: string | DirectRelationReference) { super(PrimitiveType.Polygon); this.color = new Color(Color.NAMES.red); + this.connectedImageId = connectedImageId; } // ================================================== @@ -29,7 +33,7 @@ export class Image360AnnotationDomainObject extends LineDomainObject { } public override clone(what?: symbol): DomainObject { - const clone = new Image360AnnotationDomainObject(); + const clone = new Image360AnnotationDomainObject(this.connectedImageId); clone.copyFrom(this, what); return clone; } diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts index 00a3a37a518..914c6b9ba0f 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts @@ -39,8 +39,7 @@ export class Image360AnnotationTool extends PrimitiveEditTool { } public override get isEnabled(): boolean { - // ANDERS: Now it works for all states - return true; // this.renderTarget.isInside360Image; + return this.renderTarget.isInside360Image; } public override getToolbar(): Array { @@ -65,9 +64,18 @@ export class Image360AnnotationTool extends PrimitiveEditTool { // ================================================== public override onActivate(): void { + const selected360ImageId = this.renderTarget.viewer.getActive360ImageInfo()?.image360.id; + if (selected360ImageId === undefined) { + return; + } + for (const domainObject of this.getSelectable()) { - // ANDERS: Get the image and set it visible - domainObject.setVisibleInteractive(true, this.renderTarget); + if ( + domainObject instanceof Image360AnnotationDomainObject && + domainObject.connectedImageId === selected360ImageId + ) { + domainObject.setVisibleInteractive(true, this.renderTarget); + } } super.onActivate(); } From bf698f6db7669f1fe80723535004fa498f94533f Mon Sep 17 00:00:00 2001 From: anders-hopland Date: Tue, 12 Nov 2024 15:58:32 +0100 Subject: [PATCH 06/23] Export image360Annotation objects --- react-components/src/architecture/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/react-components/src/architecture/index.ts b/react-components/src/architecture/index.ts index 688208f51aa..8ce95bff889 100644 --- a/react-components/src/architecture/index.ts +++ b/react-components/src/architecture/index.ts @@ -101,6 +101,11 @@ export { AnnotationsSelectTool } from './concrete/annotations/commands/Annotatio export { AnnotationsCreateTool } from './concrete/annotations/commands/AnnotationsCreateTool'; export { getGlobalMatrix } from './concrete/annotations/helpers/getMatrixUtils'; +export { Image360AnnotationDomainObject } from './concrete/annotation360/Image360AnnotationDomainObject'; +export { Image360AnnotationTool } from './concrete/annotation360/Image360AnnotationTool'; +export { Image360AnnotationCreator } from './concrete/annotation360/Image360AnnotationCreator'; +export { Image360AnnotationEditTypeCommand } from './concrete/annotation360/Image360AnnotationEditTypeCommand'; + // New architecture: tree view nodes export type { ITreeNode } from './base/treeView/ITreeNode'; export type { IconColor } from './base/treeView/types'; From 1ed4a8fae45e02945c0d17eb4685b3f53bce8ff3 Mon Sep 17 00:00:00 2001 From: anders-hopland Date: Tue, 12 Nov 2024 15:59:01 +0100 Subject: [PATCH 07/23] Increase cylinder radius and change pipe render order to render on top of image360 --- .../concrete/annotation360/Image360AnnotationDomainObject.ts | 2 +- .../src/architecture/concrete/primitives/line/LineView.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index 818d3fc7f86..c5fd30d5e71 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -45,7 +45,7 @@ export class Image360AnnotationDomainObject extends LineDomainObject { public override createRenderStyle(): RenderStyle | undefined { const style = new LineRenderStyle(); style.showLabel = false; - style.pipeRadius = 0; + style.pipeRadius = 0.01; style.selectedPipeRadius = 2 * style.pipeRadius; style.depthTest = false; style.transparent = true; // Needed to make the line visible through other objects diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index 6e57c87ff3e..61a0c1cb4da 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -186,7 +186,9 @@ export class LineView extends GroupThreeView { } const material = new MeshPhongMaterial(); updateSolidMaterial(material, domainObject, style); - return new Mesh(mergeGeometries(geometries, false), material); + const pipeMesh = new Mesh(mergeGeometries(geometries, false), material); + pipeMesh.renderOrder = RENDER_ORDER; + return pipeMesh; } private createLines(): Object3D | undefined { From 9cb3f5ff7ea243d68a55f5c28ae81699f5ec8dbc Mon Sep 17 00:00:00 2001 From: anders-hopland Date: Thu, 14 Nov 2024 08:40:40 +0100 Subject: [PATCH 08/23] Cleanup and export Image360Annotations button in Revealbuttons --- .../src/architecture/base/renderStyles/CommonRenderStyle.ts | 2 -- .../architecture/concrete/primitives/line/LineRenderStyle.ts | 2 ++ .../src/architecture/concrete/primitives/line/LineView.ts | 4 +++- react-components/src/architecture/index.ts | 1 + .../src/components/Architecture/RevealButtons.tsx | 5 ++++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts b/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts index 81f96bf1b99..176c67adea8 100644 --- a/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts +++ b/react-components/src/architecture/base/renderStyles/CommonRenderStyle.ts @@ -10,6 +10,4 @@ export abstract class CommonRenderStyle extends RenderStyle { // ================================================== public depthTest = true; - - public transparent = false; } diff --git a/react-components/src/architecture/concrete/primitives/line/LineRenderStyle.ts b/react-components/src/architecture/concrete/primitives/line/LineRenderStyle.ts index f9e97a21cbd..38187bad819 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineRenderStyle.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineRenderStyle.ts @@ -15,6 +15,8 @@ export class LineRenderStyle extends PrimitiveRenderStyle { public selectedPipeRadius = this.pipeRadius * 2; public lineWidth = 1; public selectedLineWidth = this.lineWidth * 2; + public transparent = false; + public renderOrder?: number = undefined; // ================================================== // OVERRIDES of BaseStyle diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index 61a0c1cb4da..38a5449695d 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -187,7 +187,9 @@ export class LineView extends GroupThreeView { const material = new MeshPhongMaterial(); updateSolidMaterial(material, domainObject, style); const pipeMesh = new Mesh(mergeGeometries(geometries, false), material); - pipeMesh.renderOrder = RENDER_ORDER; + if (style.renderOrder !== undefined) { + pipeMesh.renderOrder = style.renderOrder; + } return pipeMesh; } diff --git a/react-components/src/architecture/index.ts b/react-components/src/architecture/index.ts index 8ce95bff889..3bb148ef4ed 100644 --- a/react-components/src/architecture/index.ts +++ b/react-components/src/architecture/index.ts @@ -105,6 +105,7 @@ export { Image360AnnotationDomainObject } from './concrete/annotation360/Image36 export { Image360AnnotationTool } from './concrete/annotation360/Image360AnnotationTool'; export { Image360AnnotationCreator } from './concrete/annotation360/Image360AnnotationCreator'; export { Image360AnnotationEditTypeCommand } from './concrete/annotation360/Image360AnnotationEditTypeCommand'; +export { DeleteSelectedImage360AnnotationCommand } from './concrete/annotation360/DeleteSelectedImage360AnnotationCommand'; // New architecture: tree view nodes export type { ITreeNode } from './base/treeView/ITreeNode'; diff --git a/react-components/src/components/Architecture/RevealButtons.tsx b/react-components/src/components/Architecture/RevealButtons.tsx index 356b1482d79..7f2bc43dc38 100644 --- a/react-components/src/components/Architecture/RevealButtons.tsx +++ b/react-components/src/components/Architecture/RevealButtons.tsx @@ -14,7 +14,7 @@ import { KeyboardSpeedCommand } from '../../architecture/base/concreteCommands/K import { PointsOfInterestTool } from '../../architecture/concrete/pointsOfInterest/PointsOfInterestTool'; import { createButtonFromCommandConstructor } from './CommandButtons'; import { SettingsCommand } from '../../architecture/base/concreteCommands/SettingsCommand'; -import { PointCloudFilterCommand } from '../../architecture'; +import { Image360AnnotationTool, PointCloudFilterCommand } from '../../architecture'; import { SetOrbitOrFirstPersonModeCommand } from '../../architecture/base/concreteCommands/SetOrbitOrFirstPersonModeCommand'; import { AnnotationsShowCommand } from '../../architecture/concrete/annotations/commands/AnnotationsShowCommand'; @@ -85,6 +85,9 @@ export class RevealButtons { ); }; + static Image360AnnotationsButton = (prop: ButtonProp): ReactElement => + createButtonFromCommandConstructor(() => new Image360AnnotationTool(), prop); + // Annotations static AnnotationsSelect = (prop: ButtonProp): ReactElement => createButtonFromCommandConstructor(() => new AnnotationsSelectTool(), prop); From 9c28604384dab284cc5fa1034e0bb4a3884ab503 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 10:05:56 +0100 Subject: [PATCH 09/23] Adding point count --- .../concrete/primitives/line/LineCreator.ts | 2 +- .../primitives/line/LineDomainObject.ts | 41 +++++++++++++------ .../concrete/primitives/line/LineView.ts | 38 ++++++++--------- 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/react-components/src/architecture/concrete/primitives/line/LineCreator.ts b/react-components/src/architecture/concrete/primitives/line/LineCreator.ts index 5e44cb1fa67..3d15357c302 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineCreator.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineCreator.ts @@ -74,7 +74,7 @@ export class LineCreator extends BaseCreator { domainObject.points.pop(); } - if (this.pointCount !== domainObject.points.length) { + if (this.pointCount !== domainObject.pointCount) { // In case of undo is done copy(this.points, domainObject.points); this.lastIsPending = false; diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index 8bdd5cf0ad2..f4d66bbe1db 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -37,6 +37,22 @@ export abstract class LineDomainObject extends VisualDomainObject { // INSTANCE PROPERTIES // ================================================== + public get pointCount(): number { + return this.points.length; + } + + public get loopLength(): number { + return this.primitiveType === PrimitiveType.Polygon ? this.pointCount + 1 : this.pointCount; + } + + public getTransformedPoint(point: Vector3): Vector3 { + return point; + } + + // ================================================== + // INSTANCE PROPERTIES + // ================================================== + public get renderStyle(): LineRenderStyle { return this.getRenderStyle() as LineRenderStyle; } @@ -81,11 +97,11 @@ export abstract class LineDomainObject extends VisualDomainObject { } switch (this.primitiveType) { case PrimitiveType.Line: - return this.points.length === 2; + return this.pointCount === 2; case PrimitiveType.Polyline: - return this.points.length >= 2; + return this.pointCount >= 2; case PrimitiveType.Polygon: - return this.points.length >= 3; + return this.pointCount >= 3; default: throw new Error('Unknown PrimitiveType'); } @@ -100,7 +116,7 @@ export abstract class LineDomainObject extends VisualDomainObject { } public override getPanelInfo(): PanelInfo | undefined { - if (this.focusType === FocusType.Pending && this.points.length <= 1) { + if (this.focusType === FocusType.Pending && this.pointCount <= 1) { return undefined; } const info = new PanelInfo(); @@ -118,7 +134,7 @@ export abstract class LineDomainObject extends VisualDomainObject { break; case PrimitiveType.Polygon: add('MEASUREMENTS_TOTAL_LENGTH', 'Total length', this.getTotalLength()); - if (this.points.length > 2) { + if (this.pointCount > 2) { add( 'MEASUREMENTS_HORIZONTAL_AREA', 'Horizontal area', @@ -177,11 +193,11 @@ export abstract class LineDomainObject extends VisualDomainObject { } public getAverageLength(): number { - const count = this.points.length; - if (count <= 1) { + const { pointCount } = this; + if (pointCount <= 1) { return 0; } - return this.getTotalLength() / (count - 1); + return this.getTotalLength() / (pointCount - 1); } public getHorizontalLength(): number { @@ -211,9 +227,8 @@ export abstract class LineDomainObject extends VisualDomainObject { } public getHorizontalArea(): number { - const { points } = this; - const count = points.length; - if (count <= 2) { + const { points, pointCount } = this; + if (pointCount <= 2) { return 0; } let sum = 0.0; @@ -221,8 +236,8 @@ export abstract class LineDomainObject extends VisualDomainObject { const p0 = new Vector3(); const p1 = new Vector3(); - for (let index = 1; index <= count; index++) { - p1.copy(points[index % count]); + for (let index = 1; index <= pointCount; index++) { + p1.copy(points[index % pointCount]); p1.sub(first); // Translate down to first point, to increase accuracy sum += getHorizontalCrossProduct(p0, p1); p0.copy(p1); diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index 38a5449695d..dd271701935 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -94,9 +94,8 @@ export class LineView extends GroupThreeView { if (radius <= 0) { return; } - const { points } = domainObject; - const { length } = points; - if (length < 2) { + const { points, pointCount } = domainObject; + if (pointCount < 2) { return undefined; } // Just allocate all needed objects once @@ -111,9 +110,9 @@ export class LineView extends GroupThreeView { if (closestDistance !== undefined) { closestFinder.minDistance = closestDistance; } - const loopLength = domainObject.primitiveType === PrimitiveType.Polygon ? length + 1 : length; + const loopLength = domainObject.loopLength; for (let i = 0; i < loopLength; i++) { - thisPoint.copy(points[i % length]); + thisPoint.copy(points[i % pointCount]); thisPoint.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); if (i === 0) { @@ -148,13 +147,12 @@ export class LineView extends GroupThreeView { if (radius <= 0) { return; } - const { points } = domainObject; - const { length } = points; - if (length < 2) { + const { points, pointCount } = domainObject; + if (pointCount < 2) { return undefined; } const geometries: CylinderGeometry[] = []; - const loopLength = domainObject.primitiveType === PrimitiveType.Polygon ? length + 1 : length; + const loopLength = domainObject.loopLength; // Just allocate all needed objects once const prevPoint = new Vector3(); @@ -164,7 +162,7 @@ export class LineView extends GroupThreeView { const direction = new Vector3(); for (let i = 0; i < loopLength; i++) { - thisPoint.copy(points[i % length]); + thisPoint.copy(points[i % pointCount]); thisPoint.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); if (i > 0) { @@ -218,23 +216,22 @@ export class LineView extends GroupThreeView { if (!style.showLabel) { return; } - const { points, rootDomainObject } = domainObject; + const { points, pointCount, rootDomainObject } = domainObject; if (rootDomainObject === undefined) { return; } - const { length } = points; - if (length < 2) { + if (pointCount < 2) { return; } const spriteHeight = this.getTextHeight(style.relativeTextSize); if (spriteHeight <= 0) { return; } - const loopLength = domainObject.primitiveType === PrimitiveType.Polygon ? length : length - 1; + const loopLength = domainObject.loopLength - 1; const center = new Vector3(); for (let i = 0; i < loopLength; i++) { - const point1 = points[i % length]; - const point2 = points[(i + 1) % length]; + const point1 = points[i % pointCount]; + const point2 = points[(i + 1) % pointCount]; const distance = point1.distanceTo(point2); center.copy(point1).add(point2).divideScalar(2); @@ -261,16 +258,15 @@ export class LineView extends GroupThreeView { // ================================================== function createPositions(domainObject: LineDomainObject): number[] | undefined { - const { points } = domainObject; - const { length } = points; - if (length < 2) { + const { points, pointCount } = domainObject; + if (pointCount < 2) { return undefined; } const positions: number[] = []; - const loopLength = domainObject.primitiveType === PrimitiveType.Polygon ? length + 1 : length; + const loopLength = domainObject.loopLength; for (let i = 0; i < loopLength; i++) { - const point = points[i % length].clone(); + const point = points[i % pointCount].clone(); point.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); positions.push(...point); if (i > 0 && i < loopLength - 1) { From e032e1dc176931c4a2d18aeeb7a0f99cb12357de Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:24:22 +0100 Subject: [PATCH 10/23] Implement fast hover --- react-components/package.json | 4 ++-- .../src/architecture/base/commands/BaseTool.ts | 2 +- .../base/concreteCommands/NavigationTool.ts | 4 ++-- .../base/renderTarget/CommandsController.ts | 6 +++--- .../annotation360/Image360AnnotationDomainObject.ts | 13 ++++++++++++- .../annotation360/Image360AnnotationTool.ts | 9 ++++++++- .../concrete/primitives/line/LineDomainObject.ts | 4 ++++ react-components/yarn.lock | 12 ++++++------ 8 files changed, 38 insertions(+), 16 deletions(-) diff --git a/react-components/package.json b/react-components/package.json index 490be54155a..42a918afa9c 100644 --- a/react-components/package.json +++ b/react-components/package.json @@ -30,7 +30,7 @@ }, "peerDependencies": { "@cognite/cogs-lab": "^9.0.0-alpha.111", - "@cognite/reveal": "4.20.1", + "@cognite/reveal": "4.21.1", "react": ">=18", "react-dom": ">=18", "styled-components": ">=5" @@ -46,7 +46,7 @@ "@cognite/cdf-utilities": "^3.6.0", "@cognite/cogs-lab": "^9.0.0-alpha.113", "@cognite/cogs.js": "^10.25.0", - "@cognite/reveal": "^4.20.1", + "@cognite/reveal": "^4.21.1", "@cognite/sdk": "^9.13.0", "@playwright/test": "1.48.2", "@storybook/addon-essentials": "8.4.2", diff --git a/react-components/src/architecture/base/commands/BaseTool.ts b/react-components/src/architecture/base/commands/BaseTool.ts index 6a8b9c19c22..bbf95a769c0 100644 --- a/react-components/src/architecture/base/commands/BaseTool.ts +++ b/react-components/src/architecture/base/commands/BaseTool.ts @@ -85,7 +85,7 @@ export abstract class BaseTool extends RenderTargetCommand { // Override this to clear any temporary objects in the tool, like the dragger } - public onHover(_event: MouseEvent): void { + public onHover(_event: PointerEvent): void { // Fast. Use this for hover effects when not // doing intersection with CAD models and other large models } diff --git a/react-components/src/architecture/base/concreteCommands/NavigationTool.ts b/react-components/src/architecture/base/concreteCommands/NavigationTool.ts index 5d545e1b234..9643871c6ec 100644 --- a/react-components/src/architecture/base/concreteCommands/NavigationTool.ts +++ b/react-components/src/architecture/base/concreteCommands/NavigationTool.ts @@ -35,8 +35,8 @@ export class NavigationTool extends BaseTool { public override onHoverByDebounce(_event: PointerEvent): void {} - public override onHover(event: MouseEvent): void { - this.renderTarget.viewer.onHover360Images(event as PointerEvent); + public override onHover(event: PointerEvent): void { + this.renderTarget.viewer.onHover360Images(event); } public override async onClick(event: PointerEvent): Promise { diff --git a/react-components/src/architecture/base/renderTarget/CommandsController.ts b/react-components/src/architecture/base/renderTarget/CommandsController.ts index 27edb4766d5..ee62ba3aa88 100644 --- a/react-components/src/architecture/base/renderTarget/CommandsController.ts +++ b/react-components/src/architecture/base/renderTarget/CommandsController.ts @@ -207,7 +207,7 @@ export class CommandsController extends PointerEvents { public addEventListeners(): void { // https://www.w3schools.com/jsref/obj_mouseevent.asp const domElement = this._domElement; - domElement.addEventListener('mousemove', this._onMouseMove); + domElement.addEventListener('pointermove', this._onPointerMove); domElement.addEventListener('keydown', this._onKeyDown); domElement.addEventListener('keyup', this._onKeyUp); domElement.addEventListener('wheel', this._onWheel); @@ -219,7 +219,7 @@ export class CommandsController extends PointerEvents { public removeEventListeners(): void { const domElement = this._domElement; - domElement.removeEventListener('mousemove', this._onMouseMove); + domElement.removeEventListener('pointermove', this._onPointerMove); domElement.removeEventListener('keydown', this._onKeyDown); domElement.removeEventListener('keyup', this._onKeyUp); domElement.removeEventListener('wheel', this._onWheel); @@ -236,7 +236,7 @@ export class CommandsController extends PointerEvents { // INSTANCE METHODS: Events // ================================================== - private readonly _onMouseMove = (event: MouseEvent): void => { + private readonly _onPointerMove = (event: PointerEvent): void => { if (event.buttons === 0) { this.activeTool?.onHover(event); } diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index c5fd30d5e71..d455c08b2c4 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -7,7 +7,7 @@ import { type RenderStyle } from '../../base/renderStyles/RenderStyle'; import { PrimitiveType } from '../../base/utilities/primitives/PrimitiveType'; import { type TranslateKey } from '../../base/utilities/TranslateKey'; import { LineDomainObject } from '../primitives/line/LineDomainObject'; -import { Color } from 'three'; +import { Color, Vector3 } from 'three'; import { LineRenderStyle } from '../primitives/line/LineRenderStyle'; import { type DirectRelationReference } from '@cognite/sdk'; @@ -17,6 +17,7 @@ export class Image360AnnotationDomainObject extends LineDomainObject { // ================================================== public connectedImageId: string | DirectRelationReference; + public readonly center = new Vector3(); // The points are unit vectors from the center public constructor(connectedImageId: string | DirectRelationReference) { super(PrimitiveType.Polygon); @@ -24,6 +25,16 @@ export class Image360AnnotationDomainObject extends LineDomainObject { this.connectedImageId = connectedImageId; } + public override getTransformedPoint(point: Vector3): Vector3 { + return this.getCopyOfTransformedPoint(point); + } + + public override getCopyOfTransformedPoint(point: Vector3): Vector3 { + const clone = this.center.clone(); + clone.addScaledVector(point, 5); + return point; + } + // ================================================== // OVERRIDES // ================================================== diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts index 914c6b9ba0f..d6ff071edda 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationTool.ts @@ -85,7 +85,7 @@ export class Image360AnnotationTool extends PrimitiveEditTool { super.onDeactivate(); } - public override async onHoverByDebounce(event: PointerEvent): Promise { + public override async onHover(event: PointerEvent): Promise { if (!this.isEdit) { const creator = this._creator; if (creator === undefined) { @@ -99,6 +99,13 @@ export class Image360AnnotationTool extends PrimitiveEditTool { return; } } + super.onHover(event); + } + + public override async onHoverByDebounce(event: PointerEvent): Promise { + if (!this.isEdit) { + return; // Used by onHover + } await super.onHoverByDebounce(event); } diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index f4d66bbe1db..7c9c8c17693 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -49,6 +49,10 @@ export abstract class LineDomainObject extends VisualDomainObject { return point; } + public getCopyOfTransformedPoint(point: Vector3): Vector3 { + return point; + } + // ================================================== // INSTANCE PROPERTIES // ================================================== diff --git a/react-components/yarn.lock b/react-components/yarn.lock index b9103a29d99..146b6ae185c 100644 --- a/react-components/yarn.lock +++ b/react-components/yarn.lock @@ -600,7 +600,7 @@ __metadata: "@cognite/cdf-utilities": "npm:^3.6.0" "@cognite/cogs-lab": "npm:^9.0.0-alpha.113" "@cognite/cogs.js": "npm:^10.25.0" - "@cognite/reveal": "npm:^4.20.1" + "@cognite/reveal": "npm:^4.21.1" "@cognite/sdk": "npm:^9.13.0" "@playwright/test": "npm:1.48.2" "@storybook/addon-essentials": "npm:8.4.2" @@ -657,16 +657,16 @@ __metadata: vitest: "npm:^1.5.3" peerDependencies: "@cognite/cogs-lab": ^9.0.0-alpha.111 - "@cognite/reveal": 4.20.1 + "@cognite/reveal": 4.21.1 react: ">=18" react-dom: ">=18" styled-components: ">=5" languageName: unknown linkType: soft -"@cognite/reveal@npm:^4.20.1": - version: 4.20.1 - resolution: "@cognite/reveal@npm:4.20.1" +"@cognite/reveal@npm:^4.21.1": + version: 4.21.1 + resolution: "@cognite/reveal@npm:4.21.1" dependencies: "@rajesh896/broprint.js": "npm:^2.1.1" "@tweenjs/tween.js": "npm:^25.0.0" @@ -686,7 +686,7 @@ __metadata: peerDependencies: "@cognite/sdk": ^7.16.0 || ^8.0.0 three: 0.166.1 - checksum: 10/ab5e3b65b5167ad10b9a71486d8bead696a4a4258dd43dd52e17521bdba0553eea2c0490574c1442bda1d393df5b572b9668253677d2882417436939cc4d37c2 + checksum: 10/18a9296d8424159e06e37600ade5b8e474f96d37c64c6662d82581f4f5d6ec39dc130d7fb4e7128cb7a0a2f30fb9625d079038fa3a44a3e963381a1f5d734d14 languageName: node linkType: hard From b6c5cce55ab807d6ac0a487adb4e8af5a13e1684 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:04:48 +0100 Subject: [PATCH 11/23] Add transformation on the points --- .../Image360AnnotationCreator.ts | 19 +++++++++---- .../Image360AnnotationDomainObject.ts | 10 +++---- .../primitives/line/LineDomainObject.ts | 27 +++++++++++-------- .../concrete/primitives/line/LineView.ts | 10 +++---- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts index a5c726d6adc..015c4f09767 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationCreator.ts @@ -16,7 +16,18 @@ export class Image360AnnotationCreator extends LineCreator { public constructor(tool: BaseTool) { const image360Id = tool.renderTarget.viewer.getActive360ImageInfo()?.image360.id; assert(image360Id !== undefined, 'Image360AnnotationCreator: image360Id is undefined'); - super(tool, new Image360AnnotationDomainObject(image360Id)); + + // Get the camera position in CDF coordinates + const { position } = tool.renderTarget.cameraManager.getCameraState(); + assert(position !== undefined, 'Camera position unknown'); + + const center = position.clone(); + center.applyMatrix4(tool.renderTarget.fromViewerMatrix); + + const domainObject = new Image360AnnotationDomainObject(image360Id); + domainObject.center.copy(center); + + super(tool, domainObject); } // ================================================== @@ -37,11 +48,9 @@ export class Image360AnnotationCreator extends LineCreator { protected override transformInputPoint( ray: Ray, - point: Vector3 | undefined, + _point: Vector3 | undefined, _isPending: boolean ): Vector3 | undefined { - point = ray.origin.clone(); - point.addScaledVector(ray.direction, 5); - return point; + return ray.direction.clone(); } } diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index d455c08b2c4..63997c26654 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -26,13 +26,13 @@ export class Image360AnnotationDomainObject extends LineDomainObject { } public override getTransformedPoint(point: Vector3): Vector3 { - return this.getCopyOfTransformedPoint(point); + return this.getCopyOfTransformedPoint(point, new Vector3()); } - public override getCopyOfTransformedPoint(point: Vector3): Vector3 { - const clone = this.center.clone(); - clone.addScaledVector(point, 5); - return point; + public override getCopyOfTransformedPoint(point: Vector3, target: Vector3): Vector3 { + target.copy(this.center); + target.addScaledVector(point, 5); + return target; } // ================================================== diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index 7c9c8c17693..20a3489f932 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -49,8 +49,9 @@ export abstract class LineDomainObject extends VisualDomainObject { return point; } - public getCopyOfTransformedPoint(point: Vector3): Vector3 { - return point; + public getCopyOfTransformedPoint(point: Vector3, target: Vector3): Vector3 { + target.copy(point); + return target; } // ================================================== @@ -188,10 +189,11 @@ export abstract class LineDomainObject extends VisualDomainObject { let prevPoint: Vector3 | undefined; let sum = 0.0; for (const point of this.points) { + const transformedPoint = this.getTransformedPoint(point); if (prevPoint !== undefined) { - sum += point.distanceTo(prevPoint); + sum += transformedPoint.distanceTo(prevPoint); } - prevPoint = point; + prevPoint = transformedPoint; } return sum; } @@ -208,11 +210,12 @@ export abstract class LineDomainObject extends VisualDomainObject { let prevPoint: Vector3 | undefined; let sum = 0.0; for (const point of this.points) { + const transformedPoint = this.getTransformedPoint(point); if (prevPoint !== undefined) { - sum += horizontalDistanceTo(point, prevPoint); + sum += horizontalDistanceTo(transformedPoint, prevPoint); continue; } - prevPoint = point; + prevPoint = transformedPoint; } return sum; } @@ -221,11 +224,12 @@ export abstract class LineDomainObject extends VisualDomainObject { let prevPoint: Vector3 | undefined; let sum = 0.0; for (const point of this.points) { + const transformedPoint = this.getTransformedPoint(point); if (prevPoint !== undefined) { - sum += verticalDistanceTo(point, prevPoint); + sum += verticalDistanceTo(transformedPoint, prevPoint); continue; } - prevPoint = point; + prevPoint = transformedPoint; } return sum; } @@ -236,12 +240,12 @@ export abstract class LineDomainObject extends VisualDomainObject { return 0; } let sum = 0.0; - const first = points[0]; + const first = this.getTransformedPoint(points[0]); const p0 = new Vector3(); const p1 = new Vector3(); for (let index = 1; index <= pointCount; index++) { - p1.copy(points[index % pointCount]); + this.getCopyOfTransformedPoint(points[index % pointCount], p1); p1.sub(first); // Translate down to first point, to increase accuracy sum += getHorizontalCrossProduct(p0, p1); p0.copy(p1); @@ -251,7 +255,8 @@ export abstract class LineDomainObject extends VisualDomainObject { public expandBoundingBox(boundingBox: Box3): void { for (const point of this.points) { - boundingBox.expandByPoint(point); + const transformedPoint = this.getTransformedPoint(point); + boundingBox.expandByPoint(transformedPoint); } } } diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index dd271701935..448a4d858d9 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -112,7 +112,7 @@ export class LineView extends GroupThreeView { } const loopLength = domainObject.loopLength; for (let i = 0; i < loopLength; i++) { - thisPoint.copy(points[i % pointCount]); + domainObject.getCopyOfTransformedPoint(points[i % pointCount], thisPoint); thisPoint.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); if (i === 0) { @@ -162,7 +162,7 @@ export class LineView extends GroupThreeView { const direction = new Vector3(); for (let i = 0; i < loopLength; i++) { - thisPoint.copy(points[i % pointCount]); + domainObject.getCopyOfTransformedPoint(points[i % pointCount], thisPoint); thisPoint.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); if (i > 0) { @@ -230,8 +230,8 @@ export class LineView extends GroupThreeView { const loopLength = domainObject.loopLength - 1; const center = new Vector3(); for (let i = 0; i < loopLength; i++) { - const point1 = points[i % pointCount]; - const point2 = points[(i + 1) % pointCount]; + const point1 = domainObject.getTransformedPoint(points[i % pointCount]); + const point2 = domainObject.getTransformedPoint(points[(i + 1) % pointCount]); const distance = point1.distanceTo(point2); center.copy(point1).add(point2).divideScalar(2); @@ -266,7 +266,7 @@ function createPositions(domainObject: LineDomainObject): number[] | undefined { const loopLength = domainObject.loopLength; for (let i = 0; i < loopLength; i++) { - const point = points[i % pointCount].clone(); + const point = domainObject.getCopyOfTransformedPoint(points[i % pointCount], new Vector3()); point.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); positions.push(...point); if (i > 0 && i < loopLength - 1) { From 5b2c9774c6a9b4c548afb7e274ec22ea5075edff Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:12:32 +0100 Subject: [PATCH 12/23] Tuning --- .../Image360AnnotationDomainObject.ts | 20 ++++----- .../primitives/line/LineDomainObject.ts | 42 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index 63997c26654..f66e0562487 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -25,16 +25,6 @@ export class Image360AnnotationDomainObject extends LineDomainObject { this.connectedImageId = connectedImageId; } - public override getTransformedPoint(point: Vector3): Vector3 { - return this.getCopyOfTransformedPoint(point, new Vector3()); - } - - public override getCopyOfTransformedPoint(point: Vector3, target: Vector3): Vector3 { - target.copy(this.center); - target.addScaledVector(point, 5); - return target; - } - // ================================================== // OVERRIDES // ================================================== @@ -62,4 +52,14 @@ export class Image360AnnotationDomainObject extends LineDomainObject { style.transparent = true; // Needed to make the line visible through other objects return style; } + + public override getTransformedPoint(point: Vector3): Vector3 { + return this.getCopyOfTransformedPoint(point, new Vector3()); + } + + public override getCopyOfTransformedPoint(point: Vector3, target: Vector3): Vector3 { + target.copy(this.center); + target.addScaledVector(point, 5); + return target; + } } diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index 20a3489f932..56d01932257 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -37,27 +37,6 @@ export abstract class LineDomainObject extends VisualDomainObject { // INSTANCE PROPERTIES // ================================================== - public get pointCount(): number { - return this.points.length; - } - - public get loopLength(): number { - return this.primitiveType === PrimitiveType.Polygon ? this.pointCount + 1 : this.pointCount; - } - - public getTransformedPoint(point: Vector3): Vector3 { - return point; - } - - public getCopyOfTransformedPoint(point: Vector3, target: Vector3): Vector3 { - target.copy(point); - return target; - } - - // ================================================== - // INSTANCE PROPERTIES - // ================================================== - public get renderStyle(): LineRenderStyle { return this.getRenderStyle() as LineRenderStyle; } @@ -66,6 +45,14 @@ export abstract class LineDomainObject extends VisualDomainObject { return this._primitiveType; } + public get pointCount(): number { + return this.points.length; + } + + public get loopLength(): number { + return this.primitiveType === PrimitiveType.Polygon ? this.pointCount + 1 : this.pointCount; + } + // ================================================== // CONSTRUCTOR // ================================================== @@ -181,6 +168,19 @@ export abstract class LineDomainObject extends VisualDomainObject { return new LineView(); } + // ================================================== + // VIRTUAL METHODS: To be overridden + // ================================================== + + public getTransformedPoint(point: Vector3): Vector3 { + return point; + } + + public getCopyOfTransformedPoint(point: Vector3, target: Vector3): Vector3 { + target.copy(point); + return target; + } + // ================================================== // INSTANCE METHODS // ================================================== From 277faa46f598abd62138ea51f29fc9819e3dadd1 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:16:39 +0100 Subject: [PATCH 13/23] Update Image360AnnotationDomainObject.ts --- .../concrete/annotation360/Image360AnnotationDomainObject.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index f66e0562487..3af0edc4736 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -11,6 +11,7 @@ import { Color, Vector3 } from 'three'; import { LineRenderStyle } from '../primitives/line/LineRenderStyle'; import { type DirectRelationReference } from '@cognite/sdk'; +const DEFAULT_VECTOR_LENGTH = 5; export class Image360AnnotationDomainObject extends LineDomainObject { // ================================================== // CONSTRUCTOR @@ -18,6 +19,7 @@ export class Image360AnnotationDomainObject extends LineDomainObject { public connectedImageId: string | DirectRelationReference; public readonly center = new Vector3(); // The points are unit vectors from the center + public vectorLength = DEFAULT_VECTOR_LENGTH; public constructor(connectedImageId: string | DirectRelationReference) { super(PrimitiveType.Polygon); @@ -59,7 +61,7 @@ export class Image360AnnotationDomainObject extends LineDomainObject { public override getCopyOfTransformedPoint(point: Vector3, target: Vector3): Vector3 { target.copy(this.center); - target.addScaledVector(point, 5); + target.addScaledVector(point, this.vectorLength); return target; } } From aad919fc4b7ea6695527aa098b0d18b33b5dfe01 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:29:08 +0100 Subject: [PATCH 14/23] Update DomainObjectPanelUpdater.ts --- .../architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts b/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts index 47e14b1632b..a091b103913 100644 --- a/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts +++ b/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts @@ -28,7 +28,7 @@ export class DomainObjectPanelUpdater { if (this._setDomainObject === undefined) { return; } - if (domainObject !== undefined) { + if (domainObject !== undefined && domainObject.hasPanelInfo) { this._setDomainObject({ domainObject }); } else { this.hide(); From b7bc45eeb2082e44428c3cb3556c5f6750913fe0 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:33:06 +0100 Subject: [PATCH 15/23] Update DomainObjectPanelUpdater.ts --- .../base/reactUpdaters/DomainObjectPanelUpdater.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts b/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts index a091b103913..091a27d9fa5 100644 --- a/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts +++ b/react-components/src/architecture/base/reactUpdaters/DomainObjectPanelUpdater.ts @@ -28,7 +28,10 @@ export class DomainObjectPanelUpdater { if (this._setDomainObject === undefined) { return; } - if (domainObject !== undefined && domainObject.hasPanelInfo) { + if (domainObject !== undefined) { + if (!domainObject.hasPanelInfo) { + return; + } this._setDomainObject({ domainObject }); } else { this.hide(); @@ -43,6 +46,9 @@ export class DomainObjectPanelUpdater { } public static notify(domainObject: DomainObject, change: DomainObjectChange): void { + if (!domainObject.hasPanelInfo) { + return; + } if (this._setDomainObject === undefined) { return; } From 5d006af3f3a1c2f424df19eb0c20abf0a74dbe51 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:35:01 +0100 Subject: [PATCH 16/23] Update Image360AnnotationDomainObject.ts --- .../concrete/annotation360/Image360AnnotationDomainObject.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index 3af0edc4736..011eb00f013 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -32,7 +32,7 @@ export class Image360AnnotationDomainObject extends LineDomainObject { // ================================================== public override get typeName(): TranslateKey { - return { fallback: 'Annotation polygon' }; + return { fallback: '360 annotation' }; } public override clone(what?: symbol): DomainObject { From 510517a9b4e79ebf87594b9338fdea65900ed003 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:35:50 +0100 Subject: [PATCH 17/23] Update Image360AnnotationDomainObject.ts --- .../concrete/annotation360/Image360AnnotationDomainObject.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts index 011eb00f013..46cde98753d 100644 --- a/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts +++ b/react-components/src/architecture/concrete/annotation360/Image360AnnotationDomainObject.ts @@ -32,7 +32,7 @@ export class Image360AnnotationDomainObject extends LineDomainObject { // ================================================== public override get typeName(): TranslateKey { - return { fallback: '360 annotation' }; + return { fallback: '360 image annotation' }; } public override clone(what?: symbol): DomainObject { From ecd3b21b86151b302ef8f9af92c91a825a625cb9 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:29:42 +0100 Subject: [PATCH 18/23] Update RevealButtons.tsx --- react-components/src/components/Architecture/RevealButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-components/src/components/Architecture/RevealButtons.tsx b/react-components/src/components/Architecture/RevealButtons.tsx index 7f2bc43dc38..6bd7653ad84 100644 --- a/react-components/src/components/Architecture/RevealButtons.tsx +++ b/react-components/src/components/Architecture/RevealButtons.tsx @@ -85,7 +85,7 @@ export class RevealButtons { ); }; - static Image360AnnotationsButton = (prop: ButtonProp): ReactElement => + static Image360AnnotationTool = (prop: ButtonProp): ReactElement => createButtonFromCommandConstructor(() => new Image360AnnotationTool(), prop); // Annotations From 423f4ceb283eae9cf5437578c24ba9e4f92acc06 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Fri, 15 Nov 2024 07:42:37 +0100 Subject: [PATCH 19/23] Make it easier to read --- .../base/utilities/geometry/Points.ts | 48 ------------- .../base/utilities/geometry/Polyline.ts | 69 ------------------- .../primitives/line/LineDomainObject.ts | 34 +++++---- .../concrete/primitives/line/LineView.ts | 18 ++--- 4 files changed, 31 insertions(+), 138 deletions(-) delete mode 100644 react-components/src/architecture/base/utilities/geometry/Points.ts delete mode 100644 react-components/src/architecture/base/utilities/geometry/Polyline.ts diff --git a/react-components/src/architecture/base/utilities/geometry/Points.ts b/react-components/src/architecture/base/utilities/geometry/Points.ts deleted file mode 100644 index e490507213a..00000000000 --- a/react-components/src/architecture/base/utilities/geometry/Points.ts +++ /dev/null @@ -1,48 +0,0 @@ -/*! - * Copyright 2024 Cognite AS - */ - -import { clear } from '../extensions/arrayExtensions'; -import { type Range3 } from './Range3'; -import { Shape } from './Shape'; -import { type Vector3 } from 'three'; - -export class Points extends Shape { - // ================================================== - // INSTANCE FIELDS - // ================================================== - - public list: Vector3[] = []; - - public get length(): number { - return this.list.length; - } - - // ================================================== - // OVERRIDES of Shape: - // ================================================== - - public override clone(): Shape { - const result = new Points(); - result.list = [...this.list]; - return result; - } - - public override expandBoundingBox(boundingBox: Range3): void { - for (const point of this.list) { - boundingBox.add(point); - } - } - - // ================================================== - // INSTANCE METHODS: Operations - // ================================================== - - public add(point: Vector3): void { - this.list.push(point); - } - - public clear(): void { - clear(this.list); - } -} diff --git a/react-components/src/architecture/base/utilities/geometry/Polyline.ts b/react-components/src/architecture/base/utilities/geometry/Polyline.ts deleted file mode 100644 index 6fc712a9a97..00000000000 --- a/react-components/src/architecture/base/utilities/geometry/Polyline.ts +++ /dev/null @@ -1,69 +0,0 @@ -/*! - * Copyright 2024 Cognite AS - */ - -import { getHorizontalCrossProduct, horizontalDistanceTo } from '../extensions/vectorExtensions'; -import { Points } from './Points'; -import { type Shape } from './Shape'; -import { Vector3 } from 'three'; - -export class Polyline extends Points { - // ================================================== - // INSTANCE FIELDS - // ================================================== - - public isClosed: boolean = false; - - // ================================================== - // OVERRIDES of Shape: - // ================================================== - - public override clone(): Shape { - const result = new Polyline(); - result.list = [...this.list]; - return result; - } - - // ================================================== - // INSTANCE METHODS: Getters - // ================================================== - - public getLength(dimension: number = 3): number { - let length = 0; - const maxIndex = this.list.length - 1; - for (let i = 1; i <= maxIndex; i++) { - const p0 = this.list[i - 1]; - const p1 = this.list[i]; - length += dimension === 3 ? p0.distanceTo(p1) : horizontalDistanceTo(p0, p1); - } - if (this.isClosed) { - const p0 = this.list[maxIndex]; - const p1 = this.list[0]; - length += dimension === 3 ? p0.distanceTo(p1) : horizontalDistanceTo(p0, p1); - } - return length; - } - - public getArea(): number { - return Math.abs(this.getSignedArea()); - } - - public getSignedArea(): number { - const n = this.length; - if (n === 2) { - return 0; - } - let area = 0; - const first = this.list[0]; - const p0 = new Vector3(); - const p1 = new Vector3(); - - for (let index = 1; index <= n; index++) { - p1.copy(this.list[index % n]); - p1.sub(first); // Translate down to first point, to increase accuracy - area += getHorizontalCrossProduct(p0, p1); - p0.copy(p1); - } - return area * 0.5; - } -} diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index 56d01932257..295ac1fb631 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -49,10 +49,22 @@ export abstract class LineDomainObject extends VisualDomainObject { return this.points.length; } - public get loopLength(): number { + public get lineSegmentCount(): number { return this.primitiveType === PrimitiveType.Polygon ? this.pointCount + 1 : this.pointCount; } + public get firstPoint(): Vector3 { + return this.points[0]; + } + + public get lastPoint(): Vector3 { + return this.points[this.pointCount - 1]; + } + + public get isClosed(): boolean { + return this.primitiveType === PrimitiveType.Polygon && this.pointCount >= 3; + } + // ================================================== // CONSTRUCTOR // ================================================== @@ -126,7 +138,7 @@ export abstract class LineDomainObject extends VisualDomainObject { break; case PrimitiveType.Polygon: add('MEASUREMENTS_TOTAL_LENGTH', 'Total length', this.getTotalLength()); - if (this.pointCount > 2) { + if (this.isClosed) { add( 'MEASUREMENTS_HORIZONTAL_AREA', 'Horizontal area', @@ -186,7 +198,7 @@ export abstract class LineDomainObject extends VisualDomainObject { // ================================================== public getTotalLength(): number { - let prevPoint: Vector3 | undefined; + let prevPoint = this.isClosed ? this.getTransformedPoint(this.lastPoint) : undefined; let sum = 0.0; for (const point of this.points) { const transformedPoint = this.getTransformedPoint(point); @@ -199,21 +211,20 @@ export abstract class LineDomainObject extends VisualDomainObject { } public getAverageLength(): number { - const { pointCount } = this; - if (pointCount <= 1) { + const { lineSegmentCount } = this; + if (lineSegmentCount <= 1) { return 0; } - return this.getTotalLength() / (pointCount - 1); + return this.getTotalLength() / lineSegmentCount; } public getHorizontalLength(): number { - let prevPoint: Vector3 | undefined; + let prevPoint = this.isClosed ? this.getTransformedPoint(this.lastPoint) : undefined; let sum = 0.0; for (const point of this.points) { const transformedPoint = this.getTransformedPoint(point); if (prevPoint !== undefined) { sum += horizontalDistanceTo(transformedPoint, prevPoint); - continue; } prevPoint = transformedPoint; } @@ -221,13 +232,12 @@ export abstract class LineDomainObject extends VisualDomainObject { } public getVerticalLength(): number { - let prevPoint: Vector3 | undefined; + let prevPoint = this.isClosed ? this.getTransformedPoint(this.lastPoint) : undefined; let sum = 0.0; for (const point of this.points) { const transformedPoint = this.getTransformedPoint(point); if (prevPoint !== undefined) { sum += verticalDistanceTo(transformedPoint, prevPoint); - continue; } prevPoint = transformedPoint; } @@ -236,11 +246,11 @@ export abstract class LineDomainObject extends VisualDomainObject { public getHorizontalArea(): number { const { points, pointCount } = this; - if (pointCount <= 2) { + if (!this.isClosed) { return 0; } let sum = 0.0; - const first = this.getTransformedPoint(points[0]); + const first = this.getTransformedPoint(this.firstPoint); const p0 = new Vector3(); const p1 = new Vector3(); diff --git a/react-components/src/architecture/concrete/primitives/line/LineView.ts b/react-components/src/architecture/concrete/primitives/line/LineView.ts index 448a4d858d9..2668d5c3b7e 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineView.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineView.ts @@ -110,8 +110,8 @@ export class LineView extends GroupThreeView { if (closestDistance !== undefined) { closestFinder.minDistance = closestDistance; } - const loopLength = domainObject.loopLength; - for (let i = 0; i < loopLength; i++) { + const segmentCount = domainObject.lineSegmentCount; + for (let i = 0; i < segmentCount; i++) { domainObject.getCopyOfTransformedPoint(points[i % pointCount], thisPoint); thisPoint.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); @@ -152,7 +152,7 @@ export class LineView extends GroupThreeView { return undefined; } const geometries: CylinderGeometry[] = []; - const loopLength = domainObject.loopLength; + const segmentCount = domainObject.lineSegmentCount; // Just allocate all needed objects once const prevPoint = new Vector3(); @@ -161,7 +161,7 @@ export class LineView extends GroupThreeView { const center = new Vector3(); const direction = new Vector3(); - for (let i = 0; i < loopLength; i++) { + for (let i = 0; i < segmentCount; i++) { domainObject.getCopyOfTransformedPoint(points[i % pointCount], thisPoint); thisPoint.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); @@ -227,9 +227,9 @@ export class LineView extends GroupThreeView { if (spriteHeight <= 0) { return; } - const loopLength = domainObject.loopLength - 1; + const segmentCount = domainObject.lineSegmentCount - 1; const center = new Vector3(); - for (let i = 0; i < loopLength; i++) { + for (let i = 0; i < segmentCount; i++) { const point1 = domainObject.getTransformedPoint(points[i % pointCount]); const point2 = domainObject.getTransformedPoint(points[(i + 1) % pointCount]); const distance = point1.distanceTo(point2); @@ -263,13 +263,13 @@ function createPositions(domainObject: LineDomainObject): number[] | undefined { return undefined; } const positions: number[] = []; - const loopLength = domainObject.loopLength; + const segmentCount = domainObject.lineSegmentCount; - for (let i = 0; i < loopLength; i++) { + for (let i = 0; i < segmentCount; i++) { const point = domainObject.getCopyOfTransformedPoint(points[i % pointCount], new Vector3()); point.applyMatrix4(CDF_TO_VIEWER_TRANSFORMATION); positions.push(...point); - if (i > 0 && i < loopLength - 1) { + if (i > 0 && i < segmentCount - 1) { positions.push(...point); } } From f4e7a1218a7985ffdceee866c39eacfe35e2d97a Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Fri, 15 Nov 2024 07:48:07 +0100 Subject: [PATCH 20/23] Update LineDomainObject.ts --- .../concrete/primitives/line/LineDomainObject.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index 295ac1fb631..e7ac45b9e17 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -245,18 +245,19 @@ export abstract class LineDomainObject extends VisualDomainObject { } public getHorizontalArea(): number { - const { points, pointCount } = this; if (!this.isClosed) { return 0; } + const { points, pointCount } = this; let sum = 0.0; - const first = this.getTransformedPoint(this.firstPoint); + const firstPoint = this.getTransformedPoint(this.firstPoint); const p0 = new Vector3(); const p1 = new Vector3(); + // This applies "Greens theorem" to calculate the area of a polygon for (let index = 1; index <= pointCount; index++) { this.getCopyOfTransformedPoint(points[index % pointCount], p1); - p1.sub(first); // Translate down to first point, to increase accuracy + p1.sub(firstPoint); // Translate down to first point, to increase accuracy sum += getHorizontalCrossProduct(p0, p1); p0.copy(p1); } From a88c4583d580b626d6f179f280b747eeeeed8c95 Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:58:26 +0100 Subject: [PATCH 21/23] Update package.json --- react-components/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-components/package.json b/react-components/package.json index f50e87035f1..36285627cce 100644 --- a/react-components/package.json +++ b/react-components/package.json @@ -1,6 +1,6 @@ { "name": "@cognite/reveal-react-components", - "version": "0.65.5", + "version": "0.65.6", "exports": { ".": { "import": "./dist/index.js", @@ -30,7 +30,7 @@ }, "peerDependencies": { "@cognite/cogs-lab": "^9.0.0-alpha.111", - "@cognite/reveal": "4.21.1", + "@cognite/reveal": "4.21.1", "react": ">=18", "react-dom": ">=18", "styled-components": ">=5" From 6e84a626fe5a2585e324e1ce7ce99e1939dd603c Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:04:40 +0100 Subject: [PATCH 22/23] Fixes --- react-components/package.json | 2 +- .../architecture/concrete/primitives/line/LineDomainObject.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/react-components/package.json b/react-components/package.json index 36285627cce..ac74184a9c5 100644 --- a/react-components/package.json +++ b/react-components/package.json @@ -30,7 +30,7 @@ }, "peerDependencies": { "@cognite/cogs-lab": "^9.0.0-alpha.111", - "@cognite/reveal": "4.21.1", + "@cognite/reveal": "4.21.1", "react": ">=18", "react-dom": ">=18", "styled-components": ">=5" diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index e7ac45b9e17..111516c2564 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -135,9 +135,11 @@ export abstract class LineDomainObject extends VisualDomainObject { case PrimitiveType.Polyline: add('MEASUREMENTS_TOTAL_LENGTH', 'Total length', this.getTotalLength()); + add('MEASUREMENTS_HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); break; case PrimitiveType.Polygon: add('MEASUREMENTS_TOTAL_LENGTH', 'Total length', this.getTotalLength()); + add('MEASUREMENTS_HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); if (this.isClosed) { add( 'MEASUREMENTS_HORIZONTAL_AREA', From 7be22873d09ba08c9785ac0a046c9d91b0b5fb8f Mon Sep 17 00:00:00 2001 From: Nils Petter Fremming <35219649+nilscognite@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:15:41 +0100 Subject: [PATCH 23/23] Changing key strings --- .../pointCloud/SetPointColorTypeCommand.ts | 4 +-- .../primitives/box/BoxDomainObject.ts | 18 ++++++------- .../cylinder/CylinderDomainObject.ts | 6 ++--- .../primitives/line/LineDomainObject.ts | 27 ++++++++----------- .../i18n/de/reveal-react-components.json | 26 +++++++++--------- .../i18n/en/reveal-react-components.json | 26 +++++++++--------- .../i18n/es/reveal-react-components.json | 26 +++++++++--------- .../i18n/fr/reveal-react-components.json | 26 +++++++++--------- .../i18n/it/reveal-react-components.json | 26 +++++++++--------- .../i18n/ja/reveal-react-components.json | 26 +++++++++--------- .../i18n/ko/reveal-react-components.json | 26 +++++++++--------- .../i18n/lv/reveal-react-components.json | 26 +++++++++--------- .../i18n/nl/reveal-react-components.json | 26 +++++++++--------- .../i18n/pt/reveal-react-components.json | 26 +++++++++--------- .../i18n/sv/reveal-react-components.json | 26 +++++++++--------- .../i18n/zh/reveal-react-components.json | 26 +++++++++--------- 16 files changed, 181 insertions(+), 186 deletions(-) diff --git a/react-components/src/architecture/base/concreteCommands/pointCloud/SetPointColorTypeCommand.ts b/react-components/src/architecture/base/concreteCommands/pointCloud/SetPointColorTypeCommand.ts index 790b6a1ebdd..a8c1747cb6b 100644 --- a/react-components/src/architecture/base/concreteCommands/pointCloud/SetPointColorTypeCommand.ts +++ b/react-components/src/architecture/base/concreteCommands/pointCloud/SetPointColorTypeCommand.ts @@ -80,9 +80,9 @@ function getTranslateKey(type: PointColorType): TranslateKey { case PointColorType.Rgb: return { key: 'RGB', fallback: 'RGB' }; case PointColorType.Depth: - return { key: 'MEASUREMENTS_DEPTH', fallback: 'Depth' }; + return { key: 'DEPTH', fallback: 'Depth' }; case PointColorType.Height: - return { key: 'MEASUREMENTS_HEIGHT', fallback: 'Height' }; + return { key: 'HEIGHT', fallback: 'Height' }; case PointColorType.Classification: return { key: 'CLASSIFICATION', fallback: 'Classification' }; case PointColorType.Intensity: diff --git a/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts b/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts index 863bd786cca..b84a3616b78 100644 --- a/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/box/BoxDomainObject.ts @@ -51,11 +51,11 @@ export abstract class BoxDomainObject extends SolidDomainObject { public override get typeName(): TranslateKey { switch (this.primitiveType) { case PrimitiveType.HorizontalArea: - return { key: 'MEASUREMENTS_HORIZONTAL_AREA', fallback: 'Horizontal area' }; + return { key: 'HORIZONTAL_AREA', fallback: 'Horizontal area' }; case PrimitiveType.VerticalArea: - return { key: 'MEASUREMENTS_VERTICAL_AREA', fallback: 'Vertical area' }; + return { key: 'VERTICAL_AREA', fallback: 'Vertical area' }; case PrimitiveType.Box: - return { key: 'MEASUREMENTS_VOLUME', fallback: 'Volume' }; + return { key: 'VOLUME', fallback: 'Volume' }; default: throw new Error('Unknown PrimitiveType'); } @@ -91,22 +91,22 @@ export abstract class BoxDomainObject extends SolidDomainObject { const hasZ = Box.isValidSize(size.z); if (isFinished || hasX) { - add('MEASUREMENTS_LENGTH', 'Length', size.x, Quantity.Length); + add('LENGTH', 'Length', size.x, Quantity.Length); } if (primitiveType !== PrimitiveType.VerticalArea && (isFinished || hasY)) { - add('MEASUREMENTS_DEPTH', 'Depth', size.y, Quantity.Length); + add('DEPTH', 'Depth', size.y, Quantity.Length); } if (primitiveType !== PrimitiveType.HorizontalArea && (isFinished || hasZ)) { - add('MEASUREMENTS_HEIGHT', 'Height', size.z, Quantity.Length); + add('HEIGHT', 'Height', size.z, Quantity.Length); } if (primitiveType !== PrimitiveType.Box && (isFinished || box.hasArea)) { - add('MEASUREMENTS_AREA', 'Area', this.area, Quantity.Area); + add('AREA', 'Area', this.area, Quantity.Area); } if (primitiveType === PrimitiveType.Box && (isFinished || box.hasHorizontalArea)) { - add('MEASUREMENTS_HORIZONTAL_AREA', 'Horizontal area', box.horizontalArea, Quantity.Area); + add('HORIZONTAL_AREA', 'Horizontal area', box.horizontalArea, Quantity.Area); } if (primitiveType === PrimitiveType.Box && (isFinished || box.hasVolume)) { - add('MEASUREMENTS_VOLUME', 'Volume', box.volume, Quantity.Volume); + add('VOLUME', 'Volume', box.volume, Quantity.Volume); } // I forgot to add text for rotation angle before the deadline, so I used a icon instead. if (box.rotation.z !== 0 && isFinished) { diff --git a/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts b/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts index 94e9412e154..e7652af3f10 100644 --- a/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/cylinder/CylinderDomainObject.ts @@ -72,11 +72,11 @@ export abstract class CylinderDomainObject extends SolidDomainObject { add('RADIUS', 'Radius', cylinder.radius, Quantity.Length); } if (isFinished || hasHeight) { - add('MEASUREMENTS_HEIGHT', 'Height', cylinder.height, Quantity.Length); + add('HEIGHT', 'Height', cylinder.height, Quantity.Length); } if (isFinished || (hasRadius && hasHeight)) { - add('MEASUREMENTS_AREA', 'Area', cylinder.area, Quantity.Area); - add('MEASUREMENTS_VOLUME', 'Volume', cylinder.volume, Quantity.Volume); + add('AREA', 'Area', cylinder.area, Quantity.Area); + add('VOLUME', 'Volume', cylinder.volume, Quantity.Volume); } return info; diff --git a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts index 111516c2564..272f2e9087c 100644 --- a/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts +++ b/react-components/src/architecture/concrete/primitives/line/LineDomainObject.ts @@ -85,11 +85,11 @@ export abstract class LineDomainObject extends VisualDomainObject { public override get typeName(): TranslateKey { switch (this.primitiveType) { case PrimitiveType.Line: - return { key: 'MEASUREMENTS_LINE', fallback: 'Line' }; + return { key: 'LINE', fallback: 'Line' }; case PrimitiveType.Polyline: - return { key: 'MEASUREMENTS_POLYLINE', fallback: 'Polyline' }; + return { key: 'POLYLINE', fallback: 'Polyline' }; case PrimitiveType.Polygon: - return { key: 'MEASUREMENTS_POLYGON', fallback: 'Polygon' }; + return { key: 'POLYGON', fallback: 'Polygon' }; default: throw new Error('Unknown PrimitiveType'); } @@ -128,25 +128,20 @@ export abstract class LineDomainObject extends VisualDomainObject { switch (this.primitiveType) { case PrimitiveType.Line: - add('MEASUREMENTS_LENGTH', 'Length', this.getTotalLength()); - add('MEASUREMENTS_HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); - add('MEASUREMENTS_VERTICAL_LENGTH', 'Vertical length', this.getVerticalLength()); + add('LENGTH', 'Length', this.getTotalLength()); + add('HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); + add('VERTICAL_LENGTH', 'Vertical length', this.getVerticalLength()); break; case PrimitiveType.Polyline: - add('MEASUREMENTS_TOTAL_LENGTH', 'Total length', this.getTotalLength()); - add('MEASUREMENTS_HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); + add('TOTAL_LENGTH', 'Total length', this.getTotalLength()); + add('HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); break; case PrimitiveType.Polygon: - add('MEASUREMENTS_TOTAL_LENGTH', 'Total length', this.getTotalLength()); - add('MEASUREMENTS_HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); + add('TOTAL_LENGTH', 'Total length', this.getTotalLength()); + add('HORIZONTAL_LENGTH', 'Horizontal length', this.getHorizontalLength()); if (this.isClosed) { - add( - 'MEASUREMENTS_HORIZONTAL_AREA', - 'Horizontal area', - this.getHorizontalArea(), - Quantity.Area - ); + add('HORIZONTAL_AREA', 'Horizontal area', this.getHorizontalArea(), Quantity.Area); } break; diff --git a/react-components/src/common/i18n/de/reveal-react-components.json b/react-components/src/common/i18n/de/reveal-react-components.json index 40cbfd9cedd..545d877eda1 100644 --- a/react-components/src/common/i18n/de/reveal-react-components.json +++ b/react-components/src/common/i18n/de/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Messen Sie die Länge einer durchgehenden Polylinie. Klicken Sie auf eine beliebige Anzahl von Punkten und beenden Sie mit ESC.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Messen Sie die rechteckige vertikale Fläche. Klicken Sie in einer vertikalen Ebene auf zwei Punkte.", "MEASUREMENTS_ADD_VOLUME": "Messen Sie das Volumen eines Kastens. Klicken Sie auf drei Punkte in einer horizontalen Ebene und auf den vierten, um ihr Höhe zu geben.", - "MEASUREMENTS_AREA": "Fläche", - "MEASUREMENTS_DEPTH": "Tiefe", - "MEASUREMENTS_HEIGHT": "Höhe", - "MEASUREMENTS_HORIZONTAL_AREA": "Horizontale Fläche", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Horizontale Länge", - "MEASUREMENTS_LENGTH": "Länge", - "MEASUREMENTS_LINE": "Linie", - "MEASUREMENTS_POLYGON": "Polygon", - "MEASUREMENTS_POLYLINE": "Polylinie", + "AREA": "Fläche", + "DEPTH": "Tiefe", + "HEIGHT": "Höhe", + "HORIZONTAL_AREA": "Horizontale Fläche", + "HORIZONTAL_LENGTH": "Horizontale Länge", + "LENGTH": "Länge", + "LINE": "Linie", + "POLYGON": "Polygon", + "POLYLINE": "Polylinie", "MEASUREMENTS_SHOW_ON_TOP": "Alle Messwerte oben anzeigen", "MEASUREMENTS_TOOLTIP": "Tool zur Entfernungsmessung", - "MEASUREMENTS_TOTAL_LENGTH": "Gesamtlänge", - "MEASUREMENTS_VERTICAL_AREA": "Vertikale Fläche", - "MEASUREMENTS_VERTICAL_LENGTH": "Vertikale Länge", - "MEASUREMENTS_VOLUME": "Volumen", + "TOTAL_LENGTH": "Gesamtlänge", + "VERTICAL_AREA": "Vertikale Fläche", + "VERTICAL_LENGTH": "Vertikale Länge", + "VOLUME": "Volumen", "MOUSE_INSTRUCTIONS": "Klicken und ziehen", "MOUSE_NAVIGATION_DESCRIPTION": "Zum Drehen und Panoramieren der Ansicht klicken und ziehen. Ansicht mit Mausrad vergrößern oder verkleinern. Linke Maustaste zum Auswählen", "MOUSE_NAVIGATION_TITLE": "Maus", diff --git a/react-components/src/common/i18n/en/reveal-react-components.json b/react-components/src/common/i18n/en/reveal-react-components.json index 1cacea9adc0..651463ee6ec 100644 --- a/react-components/src/common/i18n/en/reveal-react-components.json +++ b/react-components/src/common/i18n/en/reveal-react-components.json @@ -54,21 +54,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Measure the length of a continuous polyline. Click at any number of points and end with Esc.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Measure rectangular vertical Area. Click at two points in a vertical plan.", "MEASUREMENTS_ADD_VOLUME": "Measure volume of a box. Click at three points in a horizontal plan and the fourth to give it height.", - "MEASUREMENTS_AREA": "Area", - "MEASUREMENTS_DEPTH": "Depth", - "MEASUREMENTS_HEIGHT": "Height", - "MEASUREMENTS_HORIZONTAL_AREA": "Horizontal area", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Horizontal length", - "MEASUREMENTS_LENGTH": "Length", - "MEASUREMENTS_LINE": "Line", - "MEASUREMENTS_POLYGON": "Polygon", - "MEASUREMENTS_POLYLINE": "Polyline", + "AREA": "Area", + "DEPTH": "Depth", + "HEIGHT": "Height", + "HORIZONTAL_AREA": "Horizontal area", + "HORIZONTAL_LENGTH": "Horizontal length", + "LENGTH": "Length", + "LINE": "Line", + "POLYGON": "Polygon", + "POLYLINE": "Polyline", "MEASUREMENTS_SHOW_ON_TOP": "Show all measurements on top", "MEASUREMENTS_TOOLTIP": "Distance measuring tool", - "MEASUREMENTS_TOTAL_LENGTH": "Total length", - "MEASUREMENTS_VERTICAL_AREA": "Vertical area", - "MEASUREMENTS_VERTICAL_LENGTH": "Vertical length", - "MEASUREMENTS_VOLUME": "Volume", + "TOTAL_LENGTH": "Total length", + "VERTICAL_AREA": "Vertical area", + "VERTICAL_LENGTH": "Vertical length", + "VOLUME": "Volume", "MOUSE_INSTRUCTIONS": "Click+drag", "MOUSE_NAVIGATION_DESCRIPTION": "Click and drag to rotate, and pan the view. Use mouse wheel to zoom the view. Left click to select", "MOUSE_NAVIGATION_TITLE": "Mouse", diff --git a/react-components/src/common/i18n/es/reveal-react-components.json b/react-components/src/common/i18n/es/reveal-react-components.json index 5a9a2febcc7..c7dc7a4756a 100644 --- a/react-components/src/common/i18n/es/reveal-react-components.json +++ b/react-components/src/common/i18n/es/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Medir la longitud de una polilínea continua. Haga clic en cualquier cantidad de puntos y finalice con Esc.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Medir el área vertical rectangular. Haga clic en dos puntos en un plano vertical.", "MEASUREMENTS_ADD_VOLUME": "Medir el volumen de una caja. Haga clic en tres puntos de un plano horizontal y en el cuarto para darle altura.", - "MEASUREMENTS_AREA": "Área", - "MEASUREMENTS_DEPTH": "Profundidad", - "MEASUREMENTS_HEIGHT": "Altura", - "MEASUREMENTS_HORIZONTAL_AREA": "Área horizontal", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Longitud horizontal", - "MEASUREMENTS_LENGTH": "Longitud", - "MEASUREMENTS_LINE": "Línea", - "MEASUREMENTS_POLYGON": "Polígono", - "MEASUREMENTS_POLYLINE": "Polilínea", + "AREA": "Área", + "DEPTH": "Profundidad", + "HEIGHT": "Altura", + "HORIZONTAL_AREA": "Área horizontal", + "HORIZONTAL_LENGTH": "Longitud horizontal", + "LENGTH": "Longitud", + "LINE": "Línea", + "POLYGON": "Polígono", + "POLYLINE": "Polilínea", "MEASUREMENTS_SHOW_ON_TOP": "Mostrar todas las medidas en la parte superior", "MEASUREMENTS_TOOLTIP": "Herramienta de medición de distancia", - "MEASUREMENTS_TOTAL_LENGTH": "Longitud total", - "MEASUREMENTS_VERTICAL_AREA": "Área vertical", - "MEASUREMENTS_VERTICAL_LENGTH": "Longitud vertical", - "MEASUREMENTS_VOLUME": "Volumen", + "TOTAL_LENGTH": "Longitud total", + "VERTICAL_AREA": "Área vertical", + "VERTICAL_LENGTH": "Longitud vertical", + "VOLUME": "Volumen", "MOUSE_INSTRUCTIONS": "Hacer clic + arrastrar", "MOUSE_NAVIGATION_DESCRIPTION": "Hacer clic y arrastrar para rotar y desplazar la vista. Use la rueda del mouse para ampliar la vista. Haga clic izquierdo para seleccionar", "MOUSE_NAVIGATION_TITLE": "Mouse", diff --git a/react-components/src/common/i18n/fr/reveal-react-components.json b/react-components/src/common/i18n/fr/reveal-react-components.json index cab8aa057fa..f8e87a782ab 100644 --- a/react-components/src/common/i18n/fr/reveal-react-components.json +++ b/react-components/src/common/i18n/fr/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Mesurez la longueur d'une polyligne continue. Cliquez sur autant de points que nécessaire, puis terminez avec Echap.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Mesurez l'aire d'un rectangle vertical. Cliquez sur deux points sur un plan vertical.", "MEASUREMENTS_ADD_VOLUME": "Mesurez le volume d'une boîte. Cliquez sur trois points sur un plan horizontal, puis sur un quatrième point pour désigner la hauteur.", - "MEASUREMENTS_AREA": "Aire", - "MEASUREMENTS_DEPTH": "Profondeur", - "MEASUREMENTS_HEIGHT": "Hauteur", - "MEASUREMENTS_HORIZONTAL_AREA": "Surface horizontale", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Longueur horizontale", - "MEASUREMENTS_LENGTH": "Longueur", - "MEASUREMENTS_LINE": "Ligne", - "MEASUREMENTS_POLYGON": "Polygone", - "MEASUREMENTS_POLYLINE": "Polyligne", + "AREA": "Aire", + "DEPTH": "Profondeur", + "HEIGHT": "Hauteur", + "HORIZONTAL_AREA": "Surface horizontale", + "HORIZONTAL_LENGTH": "Longueur horizontale", + "LENGTH": "Longueur", + "LINE": "Ligne", + "POLYGON": "Polygone", + "POLYLINE": "Polyligne", "MEASUREMENTS_SHOW_ON_TOP": "Afficher toutes les mesures au-dessus", "MEASUREMENTS_TOOLTIP": "Outil de mesure de distance", - "MEASUREMENTS_TOTAL_LENGTH": "Longueur totale", - "MEASUREMENTS_VERTICAL_AREA": "Surface verticale", - "MEASUREMENTS_VERTICAL_LENGTH": "Longueur verticale", - "MEASUREMENTS_VOLUME": "Volume", + "TOTAL_LENGTH": "Longueur totale", + "VERTICAL_AREA": "Surface verticale", + "VERTICAL_LENGTH": "Longueur verticale", + "VOLUME": "Volume", "MOUSE_INSTRUCTIONS": "Cliquer+faire glisser", "MOUSE_NAVIGATION_DESCRIPTION": "Cliquez et faites glisser pour faire une rotation et un panoramique. Utilisez la molette de la souris pour faire un zoom. Clic gauche pour sélectionner", "MOUSE_NAVIGATION_TITLE": "Souris", diff --git a/react-components/src/common/i18n/it/reveal-react-components.json b/react-components/src/common/i18n/it/reveal-react-components.json index 733e2684417..ad0eab56b37 100644 --- a/react-components/src/common/i18n/it/reveal-react-components.json +++ b/react-components/src/common/i18n/it/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Misurare la lunghezza di una polilinea continua. Fare clic su un numero qualsiasi di punti e terminare con Esc.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Misurare l'area verticale rettangolare. Fare clic su due punti in un piano verticale.", "MEASUREMENTS_ADD_VOLUME": "Misurare il volume di una scatola. Fare clic su tre punti in un piano orizzontale e sul quarto per ottenere l'altezza.", - "MEASUREMENTS_AREA": "Area", - "MEASUREMENTS_DEPTH": "Profondità", - "MEASUREMENTS_HEIGHT": "Altezza", - "MEASUREMENTS_HORIZONTAL_AREA": "Area orizzontale", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Lunghezza orizzontale", - "MEASUREMENTS_LENGTH": "Lunghezza", - "MEASUREMENTS_LINE": "Linea", - "MEASUREMENTS_POLYGON": "Poligono", - "MEASUREMENTS_POLYLINE": "Polilinea", + "AREA": "Area", + "DEPTH": "Profondità", + "HEIGHT": "Altezza", + "HORIZONTAL_AREA": "Area orizzontale", + "HORIZONTAL_LENGTH": "Lunghezza orizzontale", + "LENGTH": "Lunghezza", + "LINE": "Linea", + "POLYGON": "Poligono", + "POLYLINE": "Polilinea", "MEASUREMENTS_SHOW_ON_TOP": "Mostra tutte le misurazioni in alto", "MEASUREMENTS_TOOLTIP": "Strumento di misurazione distanza", - "MEASUREMENTS_TOTAL_LENGTH": "Lunghezza totale", - "MEASUREMENTS_VERTICAL_AREA": "Area verticale", - "MEASUREMENTS_VERTICAL_LENGTH": "Lunghezza verticale", - "MEASUREMENTS_VOLUME": "Volume", + "TOTAL_LENGTH": "Lunghezza totale", + "VERTICAL_AREA": "Area verticale", + "VERTICAL_LENGTH": "Lunghezza verticale", + "VOLUME": "Volume", "MOUSE_INSTRUCTIONS": "Clic+trascina", "MOUSE_NAVIGATION_DESCRIPTION": "Fare clic e trascinare per ruotare e visualizzare una panoramica della visualizzazione. Utilizzare la rotellina del mouse per eseguire lo zoom della visualizzazione. Fare clic con il pulsante sinistro del mouse per selezionare", "MOUSE_NAVIGATION_TITLE": "Mouse", diff --git a/react-components/src/common/i18n/ja/reveal-react-components.json b/react-components/src/common/i18n/ja/reveal-react-components.json index 388b2a61ed1..c3a84f9a0dd 100644 --- a/react-components/src/common/i18n/ja/reveal-react-components.json +++ b/react-components/src/common/i18n/ja/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "連続するポリラインの長さを測定します。任意の数のポイントをクリックし、Esc で終了します。", "MEASUREMENTS_ADD_VERTICAL_AREA": "長方形の垂直領域を測定します。垂直プランの 2 つのポイントをクリックします。", "MEASUREMENTS_ADD_VOLUME": "ボックスの体積を測定します。水平プランの 3 つのポイントと、高さを与える 4 つ目のポイントをクリックします。", - "MEASUREMENTS_AREA": "領域", - "MEASUREMENTS_DEPTH": "深さ", - "MEASUREMENTS_HEIGHT": "高さ", - "MEASUREMENTS_HORIZONTAL_AREA": "水平領域", - "MEASUREMENTS_HORIZONTAL_LENGTH": "水平の長さ", - "MEASUREMENTS_LENGTH": "長さ", - "MEASUREMENTS_LINE": "ライン", - "MEASUREMENTS_POLYGON": "ポリゴン", - "MEASUREMENTS_POLYLINE": "ポリライン", + "AREA": "領域", + "DEPTH": "深さ", + "HEIGHT": "高さ", + "HORIZONTAL_AREA": "水平領域", + "HORIZONTAL_LENGTH": "水平の長さ", + "LENGTH": "長さ", + "LINE": "ライン", + "POLYGON": "ポリゴン", + "POLYLINE": "ポリライン", "MEASUREMENTS_SHOW_ON_TOP": "すべての測定値を上に表示", "MEASUREMENTS_TOOLTIP": "距離測定ツール", - "MEASUREMENTS_TOTAL_LENGTH": "全長", - "MEASUREMENTS_VERTICAL_AREA": "垂直領域", - "MEASUREMENTS_VERTICAL_LENGTH": "垂直の長さ", - "MEASUREMENTS_VOLUME": "体積 ", + "TOTAL_LENGTH": "全長", + "VERTICAL_AREA": "垂直領域", + "VERTICAL_LENGTH": "垂直の長さ", + "VOLUME": "体積 ", "MOUSE_INSTRUCTIONS": "クリック + ドラッグ", "MOUSE_NAVIGATION_DESCRIPTION": "クリック + ドラッグで表示を回転し、パンします。マウス ホイールを使って表示をズームします。左クリックして選択", "MOUSE_NAVIGATION_TITLE": "マウス", diff --git a/react-components/src/common/i18n/ko/reveal-react-components.json b/react-components/src/common/i18n/ko/reveal-react-components.json index 16f96a6480f..fb32af2bf1c 100644 --- a/react-components/src/common/i18n/ko/reveal-react-components.json +++ b/react-components/src/common/i18n/ko/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "연속적인 폴리라인의 길이를 측정합니다. 원하는 수의 점을 클릭하고 Esc 키를 눌러 끝냅니다.", "MEASUREMENTS_ADD_VERTICAL_AREA": "직사각형 수직 면적을 측정합니다. 수직면에서 점 두 개를 클릭합니다.", "MEASUREMENTS_ADD_VOLUME": "상자의 체적을 측정합니다. 수평면에서 점 세 개를 클릭한 다음 높이를 지정하는 네 번째 점을 클릭합니다.", - "MEASUREMENTS_AREA": "면적", - "MEASUREMENTS_DEPTH": "깊이", - "MEASUREMENTS_HEIGHT": "높이", - "MEASUREMENTS_HORIZONTAL_AREA": "수평 면적", - "MEASUREMENTS_HORIZONTAL_LENGTH": "수평 길이", - "MEASUREMENTS_LENGTH": "길이", - "MEASUREMENTS_LINE": "선", - "MEASUREMENTS_POLYGON": "다각형", - "MEASUREMENTS_POLYLINE": "폴리라인", + "AREA": "면적", + "DEPTH": "깊이", + "HEIGHT": "높이", + "HORIZONTAL_AREA": "수평 면적", + "HORIZONTAL_LENGTH": "수평 길이", + "LENGTH": "길이", + "LINE": "선", + "POLYGON": "다각형", + "POLYLINE": "폴리라인", "MEASUREMENTS_SHOW_ON_TOP": "모든 측정을 맨 위에 표시", "MEASUREMENTS_TOOLTIP": "거리 측정 도구", - "MEASUREMENTS_TOTAL_LENGTH": "총 길이", - "MEASUREMENTS_VERTICAL_AREA": "수직 면적", - "MEASUREMENTS_VERTICAL_LENGTH": "수직 길이", - "MEASUREMENTS_VOLUME": "체적", + "TOTAL_LENGTH": "총 길이", + "VERTICAL_AREA": "수직 면적", + "VERTICAL_LENGTH": "수직 길이", + "VOLUME": "체적", "MOUSE_INSTRUCTIONS": "클릭+끌기", "MOUSE_NAVIGATION_DESCRIPTION": "클릭하고 끌어 회전하고 보기를 이동합니다. 마우스 휠을 사용하여 보기를 확대/축소합니다. 마우스 왼쪽 버튼을 클릭하여 선택", "MOUSE_NAVIGATION_TITLE": "마우스", diff --git a/react-components/src/common/i18n/lv/reveal-react-components.json b/react-components/src/common/i18n/lv/reveal-react-components.json index f7566c861c9..eef58be72ca 100644 --- a/react-components/src/common/i18n/lv/reveal-react-components.json +++ b/react-components/src/common/i18n/lv/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Izmēriet nepārtrauktas lauztas līnijas garumu. Noklikšķiniet uz jebkura punktu skaita un pabeidziet ar Esc.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Izmēriet taisnstūra vertikālo laukumu. Noklikšķiniet uz diviem punktiem vertikālā plānā.", "MEASUREMENTS_ADD_VOLUME": "Izmēriet kastes tilpumu. Noklikšķiniet uz trim punktiem horizontālā plānā un uz ceturtā, lai piešķirtu augstumu.", - "MEASUREMENTS_AREA": "Apgabals", - "MEASUREMENTS_DEPTH": "Dziļums", - "MEASUREMENTS_HEIGHT": "Augstums", - "MEASUREMENTS_HORIZONTAL_AREA": "Horizontāls laukums", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Horizontāls garums", - "MEASUREMENTS_LENGTH": "Garums", - "MEASUREMENTS_LINE": "Līnija", - "MEASUREMENTS_POLYGON": "Daudzstūris", - "MEASUREMENTS_POLYLINE": "Lauzta līnija", + "AREA": "Apgabals", + "DEPTH": "Dziļums", + "HEIGHT": "Augstums", + "HORIZONTAL_AREA": "Horizontāls laukums", + "HORIZONTAL_LENGTH": "Horizontāls garums", + "LENGTH": "Garums", + "LINE": "Līnija", + "POLYGON": "Daudzstūris", + "POLYLINE": "Lauzta līnija", "MEASUREMENTS_SHOW_ON_TOP": "Rādīt visus mērījumus augšpusē", "MEASUREMENTS_TOOLTIP": "Attāluma mērīšanas rīks", - "MEASUREMENTS_TOTAL_LENGTH": "Kopējais garums", - "MEASUREMENTS_VERTICAL_AREA": "Vertikāls laukums", - "MEASUREMENTS_VERTICAL_LENGTH": "Vertikāls garums", - "MEASUREMENTS_VOLUME": "Skaļums", + "TOTAL_LENGTH": "Kopējais garums", + "VERTICAL_AREA": "Vertikāls laukums", + "VERTICAL_LENGTH": "Vertikāls garums", + "VOLUME": "Skaļums", "MOUSE_INSTRUCTIONS": "Noklikšķiniet + velciet", "MOUSE_NAVIGATION_DESCRIPTION": "Noklikšķiniet un velciet, lai pagrieztu un panoramētu skatu. Izmantojiet peles ritenīti, lai tālummainītu skatu. Noklikšķiniet ar peles kreiso pogu, lai atlasītu", "MOUSE_NAVIGATION_TITLE": "Pele", diff --git a/react-components/src/common/i18n/nl/reveal-react-components.json b/react-components/src/common/i18n/nl/reveal-react-components.json index 89a7ac3eab3..0a9871f3c10 100644 --- a/react-components/src/common/i18n/nl/reveal-react-components.json +++ b/react-components/src/common/i18n/nl/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Meet de lengte van een doorlopende polylijn. Klik op een willekeurig aantal punten en eindig met Esc.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Meet rechthoekige verticale oppervlakte. Klik op twee punten in een verticaal vlak.", "MEASUREMENTS_ADD_VOLUME": "Meet het volume van een doos. Klik op drie punten in een horizontaal vlak en op het vierde punt voor de hoogte.", - "MEASUREMENTS_AREA": "Oppervlakte", - "MEASUREMENTS_DEPTH": "Diepte", - "MEASUREMENTS_HEIGHT": "Hoogte", - "MEASUREMENTS_HORIZONTAL_AREA": "Horizontale oppervlakte", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Horizontale lengte", - "MEASUREMENTS_LENGTH": "Lengte", - "MEASUREMENTS_LINE": "Lijn", - "MEASUREMENTS_POLYGON": "Veelhoek", - "MEASUREMENTS_POLYLINE": "Polylijn", + "AREA": "Oppervlakte", + "DEPTH": "Diepte", + "HEIGHT": "Hoogte", + "HORIZONTAL_AREA": "Horizontale oppervlakte", + "HORIZONTAL_LENGTH": "Horizontale lengte", + "LENGTH": "Lengte", + "LINE": "Lijn", + "POLYGON": "Veelhoek", + "POLYLINE": "Polylijn", "MEASUREMENTS_SHOW_ON_TOP": "Alle meetwaarden bovenaan weergeven", "MEASUREMENTS_TOOLTIP": "Tool voor afstandsmetingen", - "MEASUREMENTS_TOTAL_LENGTH": "Totale lengte", - "MEASUREMENTS_VERTICAL_AREA": "Verticale oppervlakte", - "MEASUREMENTS_VERTICAL_LENGTH": "Verticale lengte", - "MEASUREMENTS_VOLUME": "Volume", + "TOTAL_LENGTH": "Totale lengte", + "VERTICAL_AREA": "Verticale oppervlakte", + "VERTICAL_LENGTH": "Verticale lengte", + "VOLUME": "Volume", "MOUSE_INSTRUCTIONS": "Klikken+slepen", "MOUSE_NAVIGATION_DESCRIPTION": "Klik en sleep om te draaien en de weergave te pannen. Gebruik het muiswiel om in te zoomen op de weergave. Klik met de linkermuisknop om te selecteren", "MOUSE_NAVIGATION_TITLE": "Muis", diff --git a/react-components/src/common/i18n/pt/reveal-react-components.json b/react-components/src/common/i18n/pt/reveal-react-components.json index 4e8e3d2514c..eebef20bf2f 100644 --- a/react-components/src/common/i18n/pt/reveal-react-components.json +++ b/react-components/src/common/i18n/pt/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Meça o comprimento de uma polilinha contínua. Clique em qualquer número de pontos e finalize com Esc.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Meça a área vertical retangular. Clique em dois pontos em um plano vertical.", "MEASUREMENTS_ADD_VOLUME": "Meça o volume de uma caixa Clique em três pontos em um plano horizontal e no quarto para atribuir a altura.", - "MEASUREMENTS_AREA": "Área", - "MEASUREMENTS_DEPTH": "Profundidade", - "MEASUREMENTS_HEIGHT": "Altura", - "MEASUREMENTS_HORIZONTAL_AREA": "Área horizontal", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Comprimento horizontal", - "MEASUREMENTS_LENGTH": "Comprimento", - "MEASUREMENTS_LINE": "Linha", - "MEASUREMENTS_POLYGON": "Polígono", - "MEASUREMENTS_POLYLINE": "Polilinha", + "AREA": "Área", + "DEPTH": "Profundidade", + "HEIGHT": "Altura", + "HORIZONTAL_AREA": "Área horizontal", + "HORIZONTAL_LENGTH": "Comprimento horizontal", + "LENGTH": "Comprimento", + "LINE": "Linha", + "POLYGON": "Polígono", + "POLYLINE": "Polilinha", "MEASUREMENTS_SHOW_ON_TOP": "Mostrar todas as medidas no topo", "MEASUREMENTS_TOOLTIP": "Ferramenta de medição de distância", - "MEASUREMENTS_TOTAL_LENGTH": "Comprimento total", - "MEASUREMENTS_VERTICAL_AREA": "Área vertical", - "MEASUREMENTS_VERTICAL_LENGTH": "Comprimento vertical", - "MEASUREMENTS_VOLUME": "Volume", + "TOTAL_LENGTH": "Comprimento total", + "VERTICAL_AREA": "Área vertical", + "VERTICAL_LENGTH": "Comprimento vertical", + "VOLUME": "Volume", "MOUSE_INSTRUCTIONS": "Clicar e arrastar", "MOUSE_NAVIGATION_DESCRIPTION": "Clique e arraste para girar e obter visão panorâmica. Use a rolagem do mouse para ampliar a visualização. Clique com o botão esquerdo do mouse para selecionar", "MOUSE_NAVIGATION_TITLE": "Mouse", diff --git a/react-components/src/common/i18n/sv/reveal-react-components.json b/react-components/src/common/i18n/sv/reveal-react-components.json index d4ae3ad9cbe..15134d10fba 100644 --- a/react-components/src/common/i18n/sv/reveal-react-components.json +++ b/react-components/src/common/i18n/sv/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "Mät längden för en kontinuerlig polylinje. Klicka på valfritt antal punkter och avsluta med Esc.", "MEASUREMENTS_ADD_VERTICAL_AREA": "Mät rektangulär vertikal area. Klicka på två punkter i ett vertikalt plan.", "MEASUREMENTS_ADD_VOLUME": "Mät volymen för en ruta. Klicka på tre punkter i ett horisontellt plan och den fjärde för att ange höjd.", - "MEASUREMENTS_AREA": "Area", - "MEASUREMENTS_DEPTH": "Djup", - "MEASUREMENTS_HEIGHT": "Höjd", - "MEASUREMENTS_HORIZONTAL_AREA": "Horisontell area", - "MEASUREMENTS_HORIZONTAL_LENGTH": "Horisontell längd", - "MEASUREMENTS_LENGTH": "Längd", - "MEASUREMENTS_LINE": "Linje", - "MEASUREMENTS_POLYGON": "Polygon", - "MEASUREMENTS_POLYLINE": "Polylinje", + "AREA": "Area", + "DEPTH": "Djup", + "HEIGHT": "Höjd", + "HORIZONTAL_AREA": "Horisontell area", + "HORIZONTAL_LENGTH": "Horisontell längd", + "LENGTH": "Längd", + "LINE": "Linje", + "POLYGON": "Polygon", + "POLYLINE": "Polylinje", "MEASUREMENTS_SHOW_ON_TOP": "Visa alla mått överst", "MEASUREMENTS_TOOLTIP": "Avståndsmätningsverktyg", - "MEASUREMENTS_TOTAL_LENGTH": "Total längd", - "MEASUREMENTS_VERTICAL_AREA": "Vertikal area", - "MEASUREMENTS_VERTICAL_LENGTH": "Vertikal längd", - "MEASUREMENTS_VOLUME": "Volym", + "TOTAL_LENGTH": "Total längd", + "VERTICAL_AREA": "Vertikal area", + "VERTICAL_LENGTH": "Vertikal längd", + "VOLUME": "Volym", "MOUSE_INSTRUCTIONS": "Klicka+dra", "MOUSE_NAVIGATION_DESCRIPTION": "Klicka och dra för att rotera och panorera vyn. Använd mushjulet för att zooma visningen. Klicka vänster för att välja", "MOUSE_NAVIGATION_TITLE": "Mus", diff --git a/react-components/src/common/i18n/zh/reveal-react-components.json b/react-components/src/common/i18n/zh/reveal-react-components.json index caba6670ad1..d74735f0b08 100644 --- a/react-components/src/common/i18n/zh/reveal-react-components.json +++ b/react-components/src/common/i18n/zh/reveal-react-components.json @@ -53,21 +53,21 @@ "MEASUREMENTS_ADD_POLYLINE": "测量连续折线的长度。单击任意数量的点,并按 Esc 键结束。", "MEASUREMENTS_ADD_VERTICAL_AREA": "测量矩形垂直区域。单击垂直平面中的两个点。", "MEASUREMENTS_ADD_VOLUME": "测量箱子的体积。单击水平平面中的三个点,然后单击第四个点获得高度。", - "MEASUREMENTS_AREA": "面积", - "MEASUREMENTS_DEPTH": "深度", - "MEASUREMENTS_HEIGHT": "高度", - "MEASUREMENTS_HORIZONTAL_AREA": "水平区域", - "MEASUREMENTS_HORIZONTAL_LENGTH": "水平长度", - "MEASUREMENTS_LENGTH": "长度", - "MEASUREMENTS_LINE": "线条", - "MEASUREMENTS_POLYGON": "多边形", - "MEASUREMENTS_POLYLINE": "折线", + "AREA": "面积", + "DEPTH": "深度", + "HEIGHT": "高度", + "HORIZONTAL_AREA": "水平区域", + "HORIZONTAL_LENGTH": "水平长度", + "LENGTH": "长度", + "LINE": "线条", + "POLYGON": "多边形", + "POLYLINE": "折线", "MEASUREMENTS_SHOW_ON_TOP": "在顶部显示所有测量值", "MEASUREMENTS_TOOLTIP": "测距工具", - "MEASUREMENTS_TOTAL_LENGTH": "总长度", - "MEASUREMENTS_VERTICAL_AREA": "垂直区域", - "MEASUREMENTS_VERTICAL_LENGTH": "垂直长度", - "MEASUREMENTS_VOLUME": "体积", + "TOTAL_LENGTH": "总长度", + "VERTICAL_AREA": "垂直区域", + "VERTICAL_LENGTH": "垂直长度", + "VOLUME": "体积", "MOUSE_INSTRUCTIONS": "单击+拖动", "MOUSE_NAVIGATION_DESCRIPTION": "单击并拖动以旋转,并平移视图。使用鼠标滚轮缩放视图。单击左键选择", "MOUSE_NAVIGATION_TITLE": "鼠标",