WIP
This commit is contained in:
parent
579422653b
commit
79caa5e9ab
8 changed files with 35 additions and 25 deletions
|
@ -36,7 +36,7 @@ function DrawImage(
|
||||||
ctx.fillStyle = '#000000';
|
ctx.fillStyle = '#000000';
|
||||||
ctx.drawImage(
|
ctx.drawImage(
|
||||||
image,
|
image,
|
||||||
symbol.x,
|
symbol.offset,
|
||||||
-DIMENSION_MARGIN,
|
-DIMENSION_MARGIN,
|
||||||
symbol.width,
|
symbol.width,
|
||||||
symbol.height
|
symbol.height
|
||||||
|
|
|
@ -169,7 +169,7 @@ function AddHorizontalSymbolDimension(symbol: ISymbolModel,
|
||||||
color: string,
|
color: string,
|
||||||
depth: number
|
depth: number
|
||||||
): void {
|
): void {
|
||||||
const width = symbol.x + (symbol.width / 2);
|
const width = symbol.offset + (symbol.width / 2);
|
||||||
if (width != null && width > 0) {
|
if (width != null && width > 0) {
|
||||||
const id = `dim-y-margin-left${symbol.width.toFixed(0)}-${symbol.id}`;
|
const id = `dim-y-margin-left${symbol.width.toFixed(0)}-${symbol.id}`;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ export function SelectorSymbol(props: ISelectorSymbolProps): JSX.Element {
|
||||||
props.selected.height / scale
|
props.selected.height / scale
|
||||||
];
|
];
|
||||||
|
|
||||||
const [x, y] = [props.selected.x, -SYMBOL_MARGIN - height];
|
const [x, y] = [props.selected.offset, -SYMBOL_MARGIN - height];
|
||||||
|
|
||||||
const xText = x + width / 2;
|
const xText = x + width / 2;
|
||||||
const yText = y + height / 2;
|
const yText = y + height / 2;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Interweave } from 'interweave';
|
import { Interweave } from 'interweave';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
import { type ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
||||||
import { DIMENSION_MARGIN, SYMBOL_MARGIN } from '../../../utils/default';
|
import { DIMENSION_MARGIN, SYMBOL_MARGIN } from '../../../utils/default';
|
||||||
|
|
||||||
interface ISymbolProps {
|
interface ISymbolProps {
|
||||||
|
@ -12,10 +12,11 @@ export function Symbol(props: ISymbolProps): JSX.Element {
|
||||||
const href = props.model.config.Image.Base64Image ?? props.model.config.Image.Url;
|
const href = props.model.config.Image.Base64Image ?? props.model.config.Image.Url;
|
||||||
const hasSVG = props.model.config.Image.Svg !== undefined &&
|
const hasSVG = props.model.config.Image.Svg !== undefined &&
|
||||||
props.model.config.Image.Svg !== null;
|
props.model.config.Image.Svg !== null;
|
||||||
|
|
||||||
if (hasSVG) {
|
if (hasSVG) {
|
||||||
return (
|
return (
|
||||||
<g
|
<g
|
||||||
x={props.model.x}
|
x={props.model.offset}
|
||||||
y={-DIMENSION_MARGIN / props.scale}
|
y={-DIMENSION_MARGIN / props.scale}
|
||||||
>
|
>
|
||||||
<Interweave
|
<Interweave
|
||||||
|
@ -36,7 +37,7 @@ export function Symbol(props: ISymbolProps): JSX.Element {
|
||||||
transform: 'translateY(-100%) translateX(-50%)',
|
transform: 'translateY(-100%) translateX(-50%)',
|
||||||
transformBox: 'fill-box'
|
transformBox: 'fill-box'
|
||||||
}}
|
}}
|
||||||
x={props.model.x + props.model.width / 2}
|
x={props.model.offset + props.model.width / 2}
|
||||||
y={-SYMBOL_MARGIN}
|
y={-SYMBOL_MARGIN}
|
||||||
height={props.model.height / props.scale}
|
height={props.model.height / props.scale}
|
||||||
width={props.model.width / props.scale} />
|
width={props.model.width / props.scale} />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ISymbolModel } from '../../Interfaces/ISymbolModel';
|
import { type ISymbolModel } from '../../Interfaces/ISymbolModel';
|
||||||
import { RestoreX, TransformX } from '../../utils/svg';
|
import { RestoreX, RestoreY, TransformX, TransformY } from '../../utils/svg';
|
||||||
import { InputGroup } from '../InputGroup/InputGroup';
|
import { InputGroup } from '../InputGroup/InputGroup';
|
||||||
import { TextInputGroup } from '../InputGroup/TextInputGroup';
|
import { TextInputGroup } from '../InputGroup/TextInputGroup';
|
||||||
import { Text } from '../Text/Text';
|
import { Text } from '../Text/Text';
|
||||||
|
@ -32,16 +32,23 @@ export function SymbolForm(props: ISymbolFormProps): JSX.Element {
|
||||||
inputClassName=''
|
inputClassName=''
|
||||||
type='string'
|
type='string'
|
||||||
value={props.symbol.displayedText}
|
value={props.symbol.displayedText}
|
||||||
onChange={(value) => props.onChange('displayedText', value)} />
|
onChange={(value) => { props.onChange('displayedText', value); }} />
|
||||||
<TextInputGroup
|
<TextInputGroup
|
||||||
id='x'
|
id='x'
|
||||||
labelText={Text({ textId: '@SymbolX' })}
|
labelText={Text({ textId: '@SymbolOffset' })}
|
||||||
inputKey='x'
|
inputKey='x'
|
||||||
labelClassName=''
|
labelClassName=''
|
||||||
inputClassName=''
|
inputClassName=''
|
||||||
type='number'
|
type='number'
|
||||||
value={TransformX(props.symbol.x, props.symbol.width, props.symbol.config.PositionReference).toString()}
|
value={TransformX(props.symbol.offset, props.symbol.width, props.symbol.config.PositionReference).toString()}
|
||||||
onChange={(value) => props.onChange('x', RestoreX(Number(value), props.symbol.width, props.symbol.config.PositionReference))} />
|
onChange={(value) => { props.onChange('offset', RestoreX(Number(value), props.symbol.width, props.symbol.config.PositionReference)); }} />
|
||||||
|
<ToggleButton
|
||||||
|
labelText={Text({ textId: '@isVertical' })}
|
||||||
|
inputKey='isVertical'
|
||||||
|
labelClassName=''
|
||||||
|
inputClassName=''
|
||||||
|
checked={props.symbol.isVertical}
|
||||||
|
onChange={(e) => { props.onChange('isVertical', e.target.checked); }}/>
|
||||||
<TextInputGroup
|
<TextInputGroup
|
||||||
id='height'
|
id='height'
|
||||||
labelText={Text({ textId: '@SymbolHeight' })}
|
labelText={Text({ textId: '@SymbolHeight' })}
|
||||||
|
@ -51,7 +58,7 @@ 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={(value) => props.onChange('height', Number(value))} />
|
onChange={(value) => { props.onChange('height', Number(value)); }} />
|
||||||
<TextInputGroup
|
<TextInputGroup
|
||||||
id='width'
|
id='width'
|
||||||
labelText={Text({ textId: '@SymbolWidth' })}
|
labelText={Text({ textId: '@SymbolWidth' })}
|
||||||
|
@ -61,14 +68,14 @@ 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={(value) => props.onChange('width', Number(value))} />
|
onChange={(value) => { props.onChange('width', Number(value)); }} />
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
labelText={Text({ textId: '@ShowDimension' })}
|
labelText={Text({ textId: '@ShowDimension' })}
|
||||||
inputKey='showDimension'
|
inputKey='showDimension'
|
||||||
labelClassName=''
|
labelClassName=''
|
||||||
inputClassName=''
|
inputClassName=''
|
||||||
checked={props.symbol.showDimension}
|
checked={props.symbol.showDimension}
|
||||||
onChange={(e) => props.onChange('showDimension', e.target.checked)}/>
|
onChange={(e) => { props.onChange('showDimension', e.target.checked); }}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import { PositionReference } from '../Enums/PositionReference';
|
import { type PositionReference } from '../Enums/PositionReference';
|
||||||
import { IAvailableContainer } from './IAvailableContainer';
|
import { type IAvailableContainer } from './IAvailableContainer';
|
||||||
import { IImage } from './IImage';
|
import { type IImage } from './IImage';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model of available symbol to configure the application */
|
* Model of available symbol to configure the application */
|
||||||
|
@ -13,9 +13,9 @@ export interface IAvailableSymbol {
|
||||||
/** displayed text */
|
/** displayed text */
|
||||||
DisplayedText?: string
|
DisplayedText?: string
|
||||||
|
|
||||||
X?: number
|
isVertical?: boolean
|
||||||
|
|
||||||
Y?: number
|
offset?: number
|
||||||
|
|
||||||
Width?: number
|
Width?: number
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { IAvailableSymbol } from './IAvailableSymbol';
|
import { type IAvailableSymbol } from './IAvailableSymbol';
|
||||||
|
|
||||||
export interface ISymbolModel {
|
export interface ISymbolModel {
|
||||||
/** Identifier */
|
/** Identifier */
|
||||||
|
@ -13,10 +13,10 @@ export interface ISymbolModel {
|
||||||
/** Configuration of the symbol */
|
/** Configuration of the symbol */
|
||||||
config: IAvailableSymbol
|
config: IAvailableSymbol
|
||||||
|
|
||||||
/** Horizontal offset */
|
isVertical: boolean
|
||||||
x: number
|
|
||||||
|
|
||||||
// TODO: Implement Y and verticality
|
/** offset */
|
||||||
|
offset: number
|
||||||
|
|
||||||
/** Width */
|
/** Width */
|
||||||
width: number
|
width: number
|
||||||
|
|
|
@ -73,6 +73,7 @@ export const NOTCHES_LENGTH = 10;
|
||||||
/// SYMBOL DEFAULTS ///
|
/// SYMBOL DEFAULTS ///
|
||||||
|
|
||||||
export const DEFAULT_SYMBOL_WIDTH = 32;
|
export const DEFAULT_SYMBOL_WIDTH = 32;
|
||||||
|
export const DEFAULT_SYMBOL_IS_VERTICAL = false;
|
||||||
export const DEFAULT_SYMBOL_HEIGHT = 32;
|
export const DEFAULT_SYMBOL_HEIGHT = 32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -310,7 +311,8 @@ export function GetDefaultSymbolModel(name: string,
|
||||||
displayedText: symbolConfig.DisplayedText ?? id,
|
displayedText: symbolConfig.DisplayedText ?? id,
|
||||||
type: name,
|
type: name,
|
||||||
config: structuredClone(symbolConfig),
|
config: structuredClone(symbolConfig),
|
||||||
x: 0,
|
offset: 0,
|
||||||
|
isVertical : symbolConfig.isVertical ?? DEFAULT_SYMBOL_IS_VERTICAL,
|
||||||
width: symbolConfig.Width ?? DEFAULT_SYMBOL_WIDTH,
|
width: symbolConfig.Width ?? DEFAULT_SYMBOL_WIDTH,
|
||||||
height: symbolConfig.Height ?? DEFAULT_SYMBOL_HEIGHT,
|
height: symbolConfig.Height ?? DEFAULT_SYMBOL_HEIGHT,
|
||||||
linkedContainers: new Set(),
|
linkedContainers: new Set(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue