Skip to content

Commit

Permalink
Merge branch 'master' into np/filter-button
Browse files Browse the repository at this point in the history
  • Loading branch information
nilscognite authored Aug 29, 2024
2 parents d5e8df9 + 5be4f0e commit 4d6b4ca
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { DeleteDomainObjectCommand } from '../concreteCommands/DeleteDomainObjec
import { CopyToClipboardCommand } from '../concreteCommands/CopyToClipboardCommand';
import { type BaseCommand } from '../commands/BaseCommand';
import { type Transaction } from '../undo/Transaction';
import { ToggleMetricUnitsCommand } from '../concreteCommands/ToggleMetricUnitsCommand';

/**
* Represents an abstract base class for domain objects.
Expand Down Expand Up @@ -369,7 +370,11 @@ export abstract class DomainObject {
}

public getPanelToolbar(): BaseCommand[] {
return [new DeleteDomainObjectCommand(this), new CopyToClipboardCommand()];
return [
new DeleteDomainObjectCommand(this),
new CopyToClipboardCommand(),
new ToggleMetricUnitsCommand()
];
}

// ==================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { type BaseCreator } from '../../base/domainObjectsHelpers/BaseCreator';
import { ShowMeasurementsOnTopCommand } from './commands/ShowMeasurementsOnTopCommand';
import { SetMeasurementTypeCommand } from './commands/SetMeasurementTypeCommand';
import { type TranslateKey } from '../../base/utilities/TranslateKey';
import { ToggleMetricUnitsCommand } from '../../base/concreteCommands/ToggleMetricUnitsCommand';
import { PrimitiveEditTool } from '../primitives/PrimitiveEditTool';
import { MeasureLineDomainObject } from './MeasureLineDomainObject';
import { MeasureBoxDomainObject } from './MeasureBoxDomainObject';
Expand Down Expand Up @@ -49,7 +48,6 @@ export class MeasurementTool extends PrimitiveEditTool {
new SetMeasurementTypeCommand(PrimitiveType.Box),
undefined, // Separator
new UndoCommand(),
new ToggleMetricUnitsCommand(),
new ShowMeasurementsOnTopCommand()
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { PanelInfo } from '../../base/domainObjectsHelpers/PanelInfo';
import { type Observation, ObservationStatus } from './types';
import { partition, remove } from 'lodash';
import { type ObservationProperties } from './models';
import { Quantity } from '../../base/domainObjectsHelpers/Quantity';

export class ObservationsDomainObject extends VisualDomainObject {
private _selectedObservation: Observation | undefined;
Expand Down Expand Up @@ -54,10 +55,12 @@ export class ObservationsDomainObject extends VisualDomainObject {
const header = { fallback: 'Observation' };
info.setHeader(header);

info.add({ fallback: 'X', value: this._selectedObservation?.properties.positionX });
info.add({ fallback: 'Y', value: this._selectedObservation?.properties.positionY });
info.add({ fallback: 'Z', value: this._selectedObservation?.properties.positionZ });

if (this._selectedObservation !== undefined) {
const properties = this._selectedObservation.properties;
info.add({ fallback: 'X', value: properties.positionX, quantity: Quantity.Length });
info.add({ fallback: 'Y', value: properties.positionY, quantity: Quantity.Length });
info.add({ fallback: 'Z', value: properties.positionZ, quantity: Quantity.Length });
}
return info;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ export const DomainObjectPanel = (): ReactElement => {
useEffect(() => {
DomainObjectPanelUpdater.setDomainObjectDelegate(setCurrentDomainObjectInfo);

if (commands === undefined || info === undefined) {
return;
}

// Set in the get string on the copy command if any
}, [setCurrentDomainObjectInfo, commands]);

// Fore the getString to be updated
if (commands !== undefined && info !== undefined) {
for (const command of commands) {
if (command instanceof CopyToClipboardCommand)
command.getString = () => toString(info, t, unitSystem);
}
}, [setCurrentDomainObjectInfo, commands]);
}

const { t } = useTranslation();

Expand Down

0 comments on commit 4d6b4ca

Please sign in to comment.