Remove usage of scale for symbols + Remove shenanigans with multipliers
This commit is contained in:
parent
a476017d99
commit
1c8cebf0f5
4 changed files with 25 additions and 85 deletions
|
@ -8,7 +8,7 @@ export function ApplySymbol(containers: Map<string, IContainerModel>,
|
||||||
symbol: ISymbolModel): IContainerModel {
|
symbol: ISymbolModel): IContainerModel {
|
||||||
if (symbol.isVertical) {
|
if (symbol.isVertical) {
|
||||||
container.properties.y = TransformY(symbol.offset,
|
container.properties.y = TransformY(symbol.offset,
|
||||||
symbol.height * 2,
|
symbol.height,
|
||||||
symbol.config.PositionReference);
|
symbol.config.PositionReference);
|
||||||
container.properties.y = RestoreY(container.properties.y,
|
container.properties.y = RestoreY(container.properties.y,
|
||||||
container.properties.height,
|
container.properties.height,
|
||||||
|
@ -21,7 +21,10 @@ export function ApplySymbol(containers: Map<string, IContainerModel>,
|
||||||
container.properties.y = y;
|
container.properties.y = y;
|
||||||
return container;
|
return container;
|
||||||
} else {
|
} else {
|
||||||
container.properties.x = TransformX(symbol.offset, symbol.width * 2, symbol.config.PositionReference);
|
container.properties.x = TransformX(
|
||||||
|
symbol.offset,
|
||||||
|
symbol.width,
|
||||||
|
symbol.config.PositionReference);
|
||||||
container.properties.x = RestoreX(container.properties.x,
|
container.properties.x = RestoreX(container.properties.x,
|
||||||
container.properties.width,
|
container.properties.width,
|
||||||
container.properties.positionReference);
|
container.properties.positionReference);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import '../Selector.scss';
|
import '../Selector.scss';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { SYMBOL_MARGIN } from '../../../../utils/default';
|
import { DIMENSION_MARGIN, SYMBOL_MARGIN } from '../../../../utils/default';
|
||||||
import { type ISymbolModel } from '../../../../Interfaces/ISymbolModel';
|
import { type ISymbolModel } from '../../../../Interfaces/ISymbolModel';
|
||||||
import { Selector } from '../Selector/Selector';
|
import { Selector } from '../Selector/Selector';
|
||||||
import { TransformX, TransformY } from '../../../../utils/svg';
|
import { TransformX, TransformY } from '../../../../utils/svg';
|
||||||
|
@ -9,7 +9,6 @@ import { PositionReference } from '../../../../Enums/PositionReference';
|
||||||
interface ISelectorSymbolProps {
|
interface ISelectorSymbolProps {
|
||||||
symbols: Map<string, ISymbolModel>
|
symbols: Map<string, ISymbolModel>
|
||||||
selected?: ISymbolModel
|
selected?: ISymbolModel
|
||||||
scale?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
|
export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
|
||||||
|
@ -20,45 +19,17 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const scale = (props.scale ?? 1);
|
|
||||||
|
|
||||||
let x, y: number;
|
let x, y: number;
|
||||||
|
|
||||||
const scaledHeight = props.selected.height / scale;
|
const scaledHeight = props.selected.height;
|
||||||
const scaledWidth = props.selected.width / scale;
|
const scaledWidth = props.selected.width;
|
||||||
|
|
||||||
if (props.selected.isVertical) {
|
if (props.selected.isVertical) {
|
||||||
x = (-SYMBOL_MARGIN - props.selected.width) / scale;
|
x = -DIMENSION_MARGIN;
|
||||||
y = TransformY(props.selected.offset, props.selected.height * 2, props.selected.config.PositionReference);
|
y = props.selected.offset;
|
||||||
|
|
||||||
switch (props.selected.config.PositionReference) {
|
|
||||||
case PositionReference.CenterLeft:
|
|
||||||
case PositionReference.CenterCenter:
|
|
||||||
case PositionReference.CenterRight:
|
|
||||||
y -= scaledHeight / 2;
|
|
||||||
break;
|
|
||||||
case PositionReference.BottomLeft:
|
|
||||||
case PositionReference.BottomCenter:
|
|
||||||
case PositionReference.BottomRight:
|
|
||||||
y -= scaledHeight;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
x = TransformX(props.selected.offset, props.selected.width * 2, props.selected.config.PositionReference);
|
x = props.selected.offset;
|
||||||
|
y = -DIMENSION_MARGIN;
|
||||||
switch (props.selected.config.PositionReference) {
|
|
||||||
case PositionReference.TopCenter:
|
|
||||||
case PositionReference.CenterCenter:
|
|
||||||
case PositionReference.BottomCenter:
|
|
||||||
x -= scaledWidth / 2;
|
|
||||||
break;
|
|
||||||
case PositionReference.TopRight:
|
|
||||||
case PositionReference.CenterRight:
|
|
||||||
case PositionReference.BottomRight:
|
|
||||||
x -= scaledWidth;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
y = (-SYMBOL_MARGIN - props.selected.height) / scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -68,7 +39,7 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
|
||||||
y={y}
|
y={y}
|
||||||
width={scaledWidth}
|
width={scaledWidth}
|
||||||
height={scaledHeight}
|
height={scaledHeight}
|
||||||
scale={scale}
|
scale={1}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import { Interweave } from 'interweave';
|
import { Interweave } from 'interweave';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { type ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
import { type ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
||||||
import { DIMENSION_MARGIN, SYMBOL_MARGIN } from '../../../utils/default';
|
import { DIMENSION_MARGIN } from '../../../utils/default';
|
||||||
import { TransformX, TransformY } from '../../../utils/svg';
|
|
||||||
import { PositionReference } from '../../../Enums/PositionReference';
|
|
||||||
|
|
||||||
interface ISymbolProps {
|
interface ISymbolProps {
|
||||||
model: ISymbolModel
|
model: ISymbolModel
|
||||||
|
@ -17,14 +15,15 @@ export function Symbol(props: ISymbolProps): JSX.Element {
|
||||||
|
|
||||||
let x, y: number;
|
let x, y: number;
|
||||||
|
|
||||||
if (hasSVG) {
|
|
||||||
if (props.model.isVertical) {
|
if (props.model.isVertical) {
|
||||||
x = -DIMENSION_MARGIN / props.scale;
|
x = -DIMENSION_MARGIN;
|
||||||
y = props.model.offset;
|
y = props.model.offset;
|
||||||
} else {
|
} else {
|
||||||
x = props.model.offset;
|
x = props.model.offset;
|
||||||
y = -DIMENSION_MARGIN / props.scale;
|
y = -DIMENSION_MARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasSVG) {
|
||||||
return (
|
return (
|
||||||
<g
|
<g
|
||||||
x={x}
|
x={x}
|
||||||
|
@ -38,47 +37,14 @@ export function Symbol(props: ISymbolProps): JSX.Element {
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (props.model.isVertical) {
|
|
||||||
x = (-SYMBOL_MARGIN - props.model.width) / props.scale;
|
|
||||||
y = TransformY(props.model.offset, props.model.height * 2, props.model.config.PositionReference);
|
|
||||||
|
|
||||||
switch (props.model.config.PositionReference) {
|
|
||||||
case PositionReference.CenterLeft:
|
|
||||||
case PositionReference.CenterCenter:
|
|
||||||
case PositionReference.CenterRight:
|
|
||||||
y -= props.model.height / props.scale / 2;
|
|
||||||
break;
|
|
||||||
case PositionReference.BottomLeft:
|
|
||||||
case PositionReference.BottomCenter:
|
|
||||||
case PositionReference.BottomRight:
|
|
||||||
y -= props.model.height / props.scale;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
x = TransformX(props.model.offset, props.model.width * 2, props.model.config.PositionReference);
|
|
||||||
|
|
||||||
switch (props.model.config.PositionReference) {
|
|
||||||
case PositionReference.TopCenter:
|
|
||||||
case PositionReference.CenterCenter:
|
|
||||||
case PositionReference.BottomCenter:
|
|
||||||
x -= props.model.width / props.scale / 2;
|
|
||||||
break;
|
|
||||||
case PositionReference.TopRight:
|
|
||||||
case PositionReference.CenterRight:
|
|
||||||
case PositionReference.BottomRight:
|
|
||||||
x -= props.model.width / props.scale;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
y = (-SYMBOL_MARGIN - props.model.height) / props.scale;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<image
|
<image
|
||||||
href={href}
|
href={href}
|
||||||
preserveAspectRatio="none"
|
preserveAspectRatio="none"
|
||||||
x={x}
|
x={x}
|
||||||
y={y}
|
y={y}
|
||||||
height={props.model.height / props.scale}
|
height={props.model.height}
|
||||||
width={props.model.width / props.scale} />
|
width={props.model.width} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ const GetSVGLayoutConfiguration = () => {
|
||||||
Url: 'https://www.manutan.fr/img/S/GRP/ST/AIG3930272.jpg'
|
Url: 'https://www.manutan.fr/img/S/GRP/ST/AIG3930272.jpg'
|
||||||
},
|
},
|
||||||
Name: 'Poteau CenterCenter',
|
Name: 'Poteau CenterCenter',
|
||||||
PositionReference: 1,
|
PositionReference: 4,
|
||||||
AssociatedContainer: {
|
AssociatedContainer: {
|
||||||
Type: 'Montant'
|
Type: 'Montant'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue