[Update] Positions/calcs finitions

This commit is contained in:
Carl Fuchs 2023-02-20 17:17:32 +01:00
parent 387e103501
commit 174767f22c
4 changed files with 36 additions and 34 deletions

View file

@ -45,12 +45,15 @@ function ActionByPosition(
switch (position) {
case Position.Left:
incrementVerticalDepthSymbols = true;
verticalAction(dim, false, ...params);
break;
case Position.Right: {
const isRight = position === Position.Right;
verticalAction(dim, isRight, ...params);
verticalAction(dim, true, ...params);
break;
}
case Position.Down:
horizontalAction(dim, ...params);
break;
case Position.Up:
incrementHorizontalDepthSymbols = true;
horizontalAction(dim, ...params);
@ -102,7 +105,8 @@ function Dimensions({ containers, symbols, root, scale }: IDimensionLayerProps):
if (incrementVerticalDepthSymbol) { startDepthVerticalSymbols++; }
}
if (SHOW_SELF_MARGINS_DIMENSIONS && container.properties.dimensionOptions.selfMarginsDimensions.positions.length > 0) {
if (SHOW_SELF_MARGINS_DIMENSIONS &&
container.properties.dimensionOptions.selfMarginsDimensions.positions.length > 0) {
const [incrementHorizontalDepthSymbol, incrementVerticalDepthSymbol] = ActionByPosition(
dimMapped,
container.properties.dimensionOptions.selfMarginsDimensions.positions,
@ -139,7 +143,9 @@ function Dimensions({ containers, symbols, root, scale }: IDimensionLayerProps):
if (incrementVerticalDepthSymbol) { startDepthVerticalSymbols++; }
}
if (SHOW_CHILDREN_DIMENSIONS && container.properties.dimensionOptions.childrenDimensions.positions.length > 0 && container.children.length >= 2) {
if (SHOW_CHILDREN_DIMENSIONS &&
container.properties.dimensionOptions.childrenDimensions.positions.length > 0 &&
container.children.length >= 2) {
const [incrementHorizontalDepthSymbol, incrementVerticalDepthSymbol] = ActionByPosition(
dimMapped,
container.properties.dimensionOptions.childrenDimensions.positions,
@ -162,11 +168,11 @@ function Dimensions({ containers, symbols, root, scale }: IDimensionLayerProps):
for (const symbol of symbols) {
if (symbol[1].showDimension) {
startDepthHorizontalSymbols++;
startDepthVerticalSymbols++;
if (symbol[1].isVertical) {
AddVerticalSymbolDimension(symbol[1], dimensions, scale, 'black', startDepthVerticalSymbols);
AddVerticalSymbolDimension(symbol[1], dimensions, scale, startDepthVerticalSymbols);
} else {
AddHorizontalSymbolDimension(symbol[1], dimensions, scale, 'black', startDepthHorizontalSymbols);
AddHorizontalSymbolDimension(symbol[1], dimensions, scale, startDepthHorizontalSymbols);
}
}
}
@ -177,7 +183,6 @@ function Dimensions({ containers, symbols, root, scale }: IDimensionLayerProps):
function AddHorizontalSymbolDimension(symbol: ISymbolModel,
dimensions: React.ReactNode[],
scale: number,
color: string,
depth: number
): void {
const width = symbol.offset + (symbol.width / 2);
@ -206,7 +211,6 @@ function AddHorizontalSymbolDimension(symbol: ISymbolModel,
function AddVerticalSymbolDimension(symbol: ISymbolModel,
dimensions: React.ReactNode[],
scale: number,
color: string,
depth: number
): void {
const height = symbol.offset + (symbol.height / 2);
@ -265,8 +269,12 @@ function AddHorizontalChildrenDimension(
return;
}
let xChildrenStart = TransformX(lastChild.properties.x, lastChild.properties.width, lastChild.properties.positionReference);
let xChildrenEnd = TransformX(lastChild.properties.x, lastChild.properties.width, lastChild.properties.positionReference);
let xChildrenStart = TransformX(lastChild.properties.x,
lastChild.properties.width,
lastChild.properties.positionReference);
let xChildrenEnd = TransformX(lastChild.properties.x,
lastChild.properties.width,
lastChild.properties.positionReference);
// Find the min and max
for (let i = container.children.length - 2; i >= 0; i--) {
@ -328,8 +336,12 @@ function AddVerticalChildrenDimension(
return;
}
let yChildrenStart = TransformY(lastChild.properties.y, lastChild.properties.height, lastChild.properties.positionReference);
let yChildrenEnd = TransformY(lastChild.properties.y, lastChild.properties.height, lastChild.properties.positionReference);
let yChildrenStart = TransformY(lastChild.properties.y,
lastChild.properties.height,
lastChild.properties.positionReference);
let yChildrenEnd = TransformY(lastChild.properties.y,
lastChild.properties.height,
lastChild.properties.positionReference);
// Find the min and max
for (let i = container.children.length - 2; i >= 0; i--) {