[Fix] SymbolDimension (Canvas/Svg) => DEFAULT_DIMENSION_SYMBOL_STYLE in default.ts

This commit is contained in:
Carl Fuchs 2023-02-20 14:46:22 +01:00
parent 6b6175a521
commit 869cd2a7c4
3 changed files with 11 additions and 14 deletions

View file

@ -7,11 +7,10 @@ import {
SHOW_BORROWER_DIMENSIONS,
SHOW_CHILDREN_DIMENSIONS,
DIMENSION_MARGIN,
SHOW_SELF_MARGINS_DIMENSIONS
SHOW_SELF_MARGINS_DIMENSIONS, DEFAULT_DIMENSION_SYMBOL_STYLE
} from '../../utils/default';
import { FindContainerById, MakeRecursionDFSIterator, Pairwise } from '../../utils/itertools';
import { TransformX, TransformY } from '../../utils/svg';
import { type IDimensionStyle } from '../SVG/Elements/Dimension';
import { RenderDimension } from './Dimension';
export function AddContainerDimensions(
@ -589,11 +588,6 @@ function AddHorizontalSymbolDimension(
.toFixed(0)
.toString();
// TODO: Put this in default.ts
const defaultDimensionSymbolStyle: IDimensionStyle = {
color: 'black'
};
RenderDimension(ctx, {
id,
xStart: 0,
@ -602,6 +596,6 @@ function AddHorizontalSymbolDimension(
yEnd: -offset,
text,
scale,
style: defaultDimensionSymbolStyle
style: DEFAULT_DIMENSION_SYMBOL_STYLE
});
}

View file

@ -2,6 +2,7 @@ import * as React from 'react';
import { Orientation } from '../../../Enums/Orientation';
import { Position } from '../../../Enums/Position';
import {
DEFAULT_DIMENSION_SYMBOL_STYLE,
DIMENSION_MARGIN,
SHOW_BORROWER_DIMENSIONS,
SHOW_CHILDREN_DIMENSIONS,
@ -10,7 +11,7 @@ import {
} from '../../../utils/default';
import { FindContainerById, MakeRecursionDFSIterator, Pairwise } from '../../../utils/itertools';
import { TransformX, TransformY } from '../../../utils/svg';
import { Dimension, type IDimensionStyle } from './Dimension';
import { Dimension } from './Dimension';
import { type IContainerModel } from '../../../Interfaces/IContainerModel';
import { type ISymbolModel } from '../../../Interfaces/ISymbolModel';
@ -182,7 +183,6 @@ function AddHorizontalSymbolDimension(symbol: ISymbolModel,
const width = symbol.offset + (symbol.width / 2);
if (width != null && width > 0) {
const id = `dim-y-margin-left${symbol.width.toFixed(0)}-${symbol.id}`;
const style = symbol.linkedContainers.values().next().value.dimensionOptions;
const offset = (DIMENSION_MARGIN * (depth + 1)) / scale;
const text = width
@ -198,7 +198,7 @@ function AddHorizontalSymbolDimension(symbol: ISymbolModel,
yEnd={-offset}
text={text}
scale={scale}
style={style}/>
style={DEFAULT_DIMENSION_SYMBOL_STYLE}/>
);
}
}
@ -212,7 +212,6 @@ function AddVerticalSymbolDimension(symbol: ISymbolModel,
const height = symbol.offset + (symbol.height / 2);
if (height != null && height > 0) {
const id = `dim-x-margin-left${symbol.height.toFixed(0)}-${symbol.id}`;
const style = symbol.linkedContainers.values().next().value.dimensionOptions;
const offset = (DIMENSION_MARGIN * (depth + 1)) / scale;
const text = height
@ -228,7 +227,7 @@ function AddVerticalSymbolDimension(symbol: ISymbolModel,
yEnd={0}
text={text}
scale={scale}
style={style}/>
style={DEFAULT_DIMENSION_SYMBOL_STYLE}/>
);
}
}

View file

@ -9,6 +9,7 @@ import { type ISymbolModel } from '../Interfaces/ISymbolModel';
import { Orientation } from '../Enums/Orientation';
import { AppState } from '../Enums/AppState';
import { type IDimensionOptions } from '../Interfaces/IDimensionOptions';
import { type IDimensionStyle } from '../Components/SVG/Elements/Dimension';
/// EDITOR DEFAULTS ///
@ -69,6 +70,9 @@ export const SHOW_BORROWER_DIMENSIONS = true;
export const DIMENSION_MARGIN = 50;
export const SYMBOL_MARGIN = 25;
export const NOTCHES_LENGTH = 10;
export const DEFAULT_DIMENSION_SYMBOL_STYLE: IDimensionStyle = {
color: '#000000'
};
/// SYMBOL DEFAULTS ///
@ -306,7 +310,7 @@ export function GetDefaultSymbolModel(name: string,
type: name,
config: structuredClone(symbolConfig),
offset: 0,
isVertical : symbolConfig.isVertical ?? DEFAULT_SYMBOL_IS_VERTICAL,
isVertical: symbolConfig.isVertical ?? DEFAULT_SYMBOL_IS_VERTICAL,
width: symbolConfig.Width ?? DEFAULT_SYMBOL_WIDTH,
height: symbolConfig.Height ?? DEFAULT_SYMBOL_HEIGHT,
linkedContainers: new Set(),