Implement borrower dimension

This commit is contained in:
Eric NGUYEN 2022-08-30 17:36:48 +02:00
parent 57e6c9a156
commit 5fa9db931f
7 changed files with 117 additions and 14 deletions

View file

@ -16,9 +16,10 @@ export const DEFAULTCHILDTYPE_MAX_DEPTH = 10;
/// DIMENSIONS DEFAULTS ///
export const SHOW_PARENT_DIMENSION = true;
export const SHOW_SELF_DIMENSIONS = true;
export const SHOW_CHILDREN_DIMENSIONS = false;
export const SHOW_DIMENSIONS_PER_DEPTH = true;
export const SHOW_BORROWER_DIMENSIONS = true;
export const SHOW_DIMENSIONS_PER_DEPTH = false;
export const DIMENSION_MARGIN = 50;
export const NOTCHES_LENGTH = 4;
@ -51,7 +52,7 @@ export function GetDefaultEditorState(configuration: IConfiguration): IEditorSta
history: [
{
lastAction: '',
mainContainer: mainContainer,
mainContainer,
selectedContainerId: mainContainer.properties.id,
typeCounters: {},
symbols: new Map(),
@ -110,6 +111,10 @@ export const DEFAULT_MAINCONTAINER_PROPS: IContainerProperties = {
isAnchor: false,
isFlex: false,
xPositionReference: XPositionReference.Left,
showChildrenDimensions: true, // TODO: put the dimension at the top (see pdf)
showSelfDimensions: true, // TODO: put the dimension at the bottom (see pdf)
isDimensionBorrower: true, // second dimensions from the bottom
markPositionToDimensionBorrower: false,
style: {
stroke: 'black',
fillOpacity: 0
@ -150,6 +155,10 @@ export function GetDefaultContainerProps(type: string,
xPositionReference: containerConfig.XPositionReference ?? XPositionReference.Left,
minWidth: containerConfig.MinWidth ?? 1,
maxWidth: containerConfig.MaxWidth ?? Number.MAX_SAFE_INTEGER,
showChildrenDimensions: containerConfig.ShowChildrenDimensions ?? false,
showSelfDimensions: containerConfig.ShowSelfDimensions ?? false,
markPositionToDimensionBorrower: containerConfig.MarkPositionToDimensionBorrower ?? false,
isDimensionBorrower: containerConfig.IsDimensionBorrower ?? false,
customSVG: containerConfig.CustomSVG,
style: structuredClone(containerConfig.Style),
userData: structuredClone(containerConfig.UserData)

View file

@ -83,9 +83,14 @@ export function GetAbsolutePosition(container: IContainerModel): [number, number
* @param y value to be restored
* @returns x and y such that the transformations of the parent are cancelled
*/
export function CancelParentTransform(parent: IContainerModel | null, x: number, y: number): [number, number] {
export function CancelParentTransform(
parent: IContainerModel | null,
x: number,
y: number,
stop?: IContainerModel
): [number, number] {
let current = parent;
while (current != null) {
while (current !== stop && current != null) {
x += current.properties.x;
y += current.properties.y;
current = current.parent;