Merged PR 208: Fix scaling and position of symbols

This commit is contained in:
Eric Nguyen 2022-10-04 09:25:03 +00:00
parent 32684a725b
commit ec7ee7891e
6 changed files with 38 additions and 10 deletions

View file

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25L12 21m0 0l-3.75-3.75M12 21V3" />
</svg>

After

Width:  |  Height:  |  Size: 246 B

View file

@ -1,7 +1,7 @@
import { Interweave } from 'interweave'; import { Interweave } from 'interweave';
import * as React from 'react'; import * as React from 'react';
import { ISymbolModel } from '../../../Interfaces/ISymbolModel'; import { ISymbolModel } from '../../../Interfaces/ISymbolModel';
import { DIMENSION_MARGIN } from '../../../utils/default'; import { DIMENSION_MARGIN, SYMBOL_MARGIN } from '../../../utils/default';
interface ISymbolProps { interface ISymbolProps {
model: ISymbolModel model: ISymbolModel
@ -30,8 +30,14 @@ export function Symbol(props: ISymbolProps): JSX.Element {
return ( return (
<image <image
href={href} href={href}
preserveAspectRatio="none"
style={{
fill: 'none',
transform: `scale(${1 / props.scale}) translateX(-50%) translateY(-50%)`,
transformBox: 'fill-box'
}}
x={props.model.x} x={props.model.x}
y={-DIMENSION_MARGIN / props.scale} y={-SYMBOL_MARGIN / props.scale}
height={props.model.height} height={props.model.height}
width={props.model.width} /> width={props.model.width} />
); );

View file

@ -2,6 +2,8 @@ import * as React from 'react';
import { ISymbolModel } from '../../Interfaces/ISymbolModel'; import { ISymbolModel } from '../../Interfaces/ISymbolModel';
import { RestoreX, TransformX } from '../../utils/svg'; import { RestoreX, TransformX } from '../../utils/svg';
import { InputGroup } from '../InputGroup/InputGroup'; import { InputGroup } from '../InputGroup/InputGroup';
import { TextInputGroup } from '../InputGroup/TextInputGroup';
import { PositionReferenceSelector } from '../RadioGroupButtons/PositionReferenceSelector';
interface ISymbolFormProps { interface ISymbolFormProps {
symbol: ISymbolModel symbol: ISymbolModel
@ -20,15 +22,17 @@ export function SymbolForm(props: ISymbolFormProps): JSX.Element {
type='string' type='string'
value={props.symbol.id.toString()} value={props.symbol.id.toString()}
isDisabled={true} /> isDisabled={true} />
<InputGroup <TextInputGroup
id='x'
labelText='x' labelText='x'
inputKey='x' inputKey='x'
labelClassName='' labelClassName=''
inputClassName='' inputClassName=''
type='number' type='number'
value={TransformX(props.symbol.x, props.symbol.width, props.symbol.config.XPositionReference).toString()} value={TransformX(props.symbol.x, props.symbol.width, props.symbol.config.PositionReference).toString()}
onChange={(event) => props.onChange('x', RestoreX(Number(event.target.value), props.symbol.width, props.symbol.config.XPositionReference))} /> onChange={(value) => props.onChange('x', RestoreX(Number(value), props.symbol.width, props.symbol.config.PositionReference))} />
<InputGroup <TextInputGroup
id='height'
labelText='Height' labelText='Height'
inputKey='height' inputKey='height'
labelClassName='' labelClassName=''
@ -36,8 +40,9 @@ export function SymbolForm(props: ISymbolFormProps): JSX.Element {
type='number' type='number'
min={0} min={0}
value={props.symbol.height.toString()} value={props.symbol.height.toString()}
onChange={(event) => props.onChange('height', Number(event.target.value))} /> onChange={(value) => props.onChange('height', Number(value))} />
<InputGroup <TextInputGroup
id='width'
labelText='Width' labelText='Width'
inputKey='width' inputKey='width'
labelClassName='' labelClassName=''
@ -45,7 +50,7 @@ export function SymbolForm(props: ISymbolFormProps): JSX.Element {
type='number' type='number'
min={0} min={0}
value={props.symbol.width.toString()} value={props.symbol.width.toString()}
onChange={(event) => props.onChange('width', Number(event.target.value))} /> onChange={(value) => props.onChange('width', Number(value))} />
</div> </div>
); );
} }

View file

@ -9,5 +9,5 @@ export interface IAvailableSymbol {
Image: IImage Image: IImage
Width?: number Width?: number
Height?: number Height?: number
XPositionReference?: PositionReference PositionReference?: PositionReference
} }

View file

@ -63,6 +63,7 @@ export const SHOW_CHILDREN_DIMENSIONS = true;
export const SHOW_BORROWER_DIMENSIONS = true; export const SHOW_BORROWER_DIMENSIONS = true;
export const SHOW_DIMENSIONS_PER_DEPTH = false; export const SHOW_DIMENSIONS_PER_DEPTH = false;
export const DIMENSION_MARGIN = 50; export const DIMENSION_MARGIN = 50;
export const SYMBOL_MARGIN = 25;
export const NOTCHES_LENGTH = 10; export const NOTCHES_LENGTH = 10;
/// SYMBOL DEFAULTS /// /// SYMBOL DEFAULTS ///

View file

@ -241,6 +241,18 @@ const GetSVGLayoutConfiguration = () => {
Name: 'Poteau structure', Name: 'Poteau structure',
PositionReference: 1 PositionReference: 1
}, },
{
Width: 32,
Height: 32,
Image: {
Base64Image: null,
Name: 'Arrow',
Svg: null,
Url: './images/arrow-down.svg'
},
Name: 'Arrow',
PositionReference: 1
},
{ {
Width: 32, Width: 32,
Height: 32, Height: 32,