Merged PR 308: #8224/#7571 Margins cotation and Colors
Related work items: #8224
This commit is contained in:
parent
4e8f465405
commit
a7feebdcd1
18 changed files with 425 additions and 150 deletions
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace SVGLDLibs.Models
|
namespace SVGLDLibs.Models
|
||||||
|
@ -112,26 +112,10 @@ namespace SVGLDLibs.Models
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public bool? HideChildrenInTreeview { get; set; }
|
public bool? HideChildrenInTreeview { get; set; }
|
||||||
|
|
||||||
/** if true, show the dimension of the container */
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public Position[] ShowSelfDimensions { get; set; }
|
|
||||||
|
|
||||||
/** if true show the overall dimensions of its children */
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public Position[] ShowChildrenDimensions { get; set; }
|
public Dimensions DimensionOptions { get; set; }
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, allows a parent dimension borrower to uses its x coordinate for as a reference point for a dimension
|
|
||||||
*/
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public Orientation[] MarkPosition { get; set; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, show a dimension from the edge of the container to end
|
|
||||||
* and insert dimensions mark
|
|
||||||
*/
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public Position[] ShowDimensionWithMarks { get; set; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if true, hide the entry in the sidebar (default: false)
|
* if true, hide the entry in the sidebar (default: false)
|
||||||
|
|
28
csharp/SVGLDLibs/SVGLDLibs/Models/DimensionOptions.cs
Normal file
28
csharp/SVGLDLibs/SVGLDLibs/Models/DimensionOptions.cs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SVGLDLibs.Models
|
||||||
|
{
|
||||||
|
|
||||||
|
[DataContract]
|
||||||
|
public class DimensionOptions
|
||||||
|
{
|
||||||
|
|
||||||
|
/** positions of the dimension */
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public Position[] positions;
|
||||||
|
|
||||||
|
/** color */
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public string color;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,11 +9,14 @@ namespace SVGLDLibs.Models
|
||||||
|
|
||||||
/** if true, show the dimension of the container */
|
/** if true, show the dimension of the container */
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public Position[] showSelfDimensions;
|
public DimensionOptions selfDimensions;
|
||||||
|
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public DimensionOptions selfMarginsDimensions;
|
||||||
|
|
||||||
/** if true show the overall dimensions of its children */
|
/** if true show the overall dimensions of its children */
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public Position[] showChildrenDimensions;
|
public DimensionOptions childrenDimensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if true, allows a parent dimension borrower to borrow its x coordinate
|
* if true, allows a parent dimension borrower to borrow its x coordinate
|
||||||
|
@ -27,6 +30,6 @@ namespace SVGLDLibs.Models
|
||||||
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
||||||
*/
|
*/
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public Position[] showDimensionWithMarks;
|
public DimensionOptions dimensionWithMarks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { AddMethod } from '../../Enums/AddMethod';
|
import { AddMethod } from '../../Enums/AddMethod';
|
||||||
import { Orientation } from '../../Enums/Orientation';
|
|
||||||
import { Position } from '../../Enums/Position';
|
|
||||||
import { PositionReference } from '../../Enums/PositionReference';
|
import { PositionReference } from '../../Enums/PositionReference';
|
||||||
import { IAction } from '../../Interfaces/IAction';
|
import { IAction } from '../../Interfaces/IAction';
|
||||||
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
|
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
|
||||||
|
@ -145,28 +143,25 @@ describe.concurrent('Models test suite', () => {
|
||||||
DefaultChildType: 'string',
|
DefaultChildType: 'string',
|
||||||
PositionReference: 0,
|
PositionReference: 0,
|
||||||
HideChildrenInTreeview: true,
|
HideChildrenInTreeview: true,
|
||||||
ShowSelfDimensions: [
|
DimensionOptions: {
|
||||||
Position.Down,
|
childrenDimensions: {
|
||||||
Position.Left,
|
color: '#000000',
|
||||||
Position.Right,
|
positions: []
|
||||||
Position.Up
|
},
|
||||||
],
|
selfDimensions: {
|
||||||
ShowChildrenDimensions: [
|
color: '#000000',
|
||||||
Position.Down,
|
positions: []
|
||||||
Position.Left,
|
},
|
||||||
Position.Right,
|
selfMarginsDimensions: {
|
||||||
Position.Up
|
color: '#000000',
|
||||||
],
|
positions: []
|
||||||
MarkPosition: [
|
},
|
||||||
Orientation.Horizontal,
|
markPosition: [],
|
||||||
Orientation.Vertical
|
dimensionWithMarks: {
|
||||||
],
|
color: '#000000',
|
||||||
ShowDimensionWithMarks: [
|
positions: []
|
||||||
Position.Down,
|
}
|
||||||
Position.Left,
|
},
|
||||||
Position.Right,
|
|
||||||
Position.Up
|
|
||||||
],
|
|
||||||
IsHidden: true,
|
IsHidden: true,
|
||||||
Blacklist: [
|
Blacklist: [
|
||||||
'string'
|
'string'
|
||||||
|
|
|
@ -18,11 +18,11 @@ export function AddDimensions(
|
||||||
depth: number
|
depth: number
|
||||||
): void {
|
): void {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
if (SHOW_SELF_DIMENSIONS && container.properties.dimensionOptions.showSelfDimensions.length > 0) {
|
if (SHOW_SELF_DIMENSIONS && container.properties.dimensionOptions.selfDimensions.positions.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
ctx,
|
ctx,
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.dimensionOptions.showSelfDimensions,
|
container.properties.dimensionOptions.selfDimensions.positions,
|
||||||
AddHorizontalSelfDimension,
|
AddHorizontalSelfDimension,
|
||||||
AddVerticalSelfDimension,
|
AddVerticalSelfDimension,
|
||||||
[
|
[
|
||||||
|
@ -32,11 +32,11 @@ export function AddDimensions(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_BORROWER_DIMENSIONS && container.properties.dimensionOptions.showDimensionWithMarks.length > 0) {
|
if (SHOW_BORROWER_DIMENSIONS && container.properties.dimensionOptions.dimensionWithMarks.positions.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
ctx,
|
ctx,
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.dimensionOptions.showDimensionWithMarks,
|
container.properties.dimensionOptions.dimensionWithMarks.positions,
|
||||||
AddHorizontalBorrowerDimension,
|
AddHorizontalBorrowerDimension,
|
||||||
AddVerticalBorrowerDimension,
|
AddVerticalBorrowerDimension,
|
||||||
[
|
[
|
||||||
|
@ -48,11 +48,11 @@ export function AddDimensions(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_CHILDREN_DIMENSIONS && container.properties.dimensionOptions.showChildrenDimensions.length > 0 && container.children.length >= 2) {
|
if (SHOW_CHILDREN_DIMENSIONS && container.properties.dimensionOptions.childrenDimensions.positions.length > 0 && container.children.length >= 2) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
ctx,
|
ctx,
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.dimensionOptions.showChildrenDimensions,
|
container.properties.dimensionOptions.childrenDimensions.positions,
|
||||||
AddHorizontalChildrenDimension,
|
AddHorizontalChildrenDimension,
|
||||||
AddVerticalChildrenDimension,
|
AddVerticalChildrenDimension,
|
||||||
[
|
[
|
||||||
|
|
|
@ -8,6 +8,7 @@ interface IPositionCheckboxesProps {
|
||||||
name: string
|
name: string
|
||||||
labelText: string
|
labelText: string
|
||||||
value: Position[]
|
value: Position[]
|
||||||
|
attribute: string
|
||||||
onChange: (key: string, value: number[]) => void
|
onChange: (key: string, value: number[]) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ export function PositionCheckboxes({
|
||||||
name,
|
name,
|
||||||
labelText,
|
labelText,
|
||||||
value,
|
value,
|
||||||
|
attribute,
|
||||||
onChange
|
onChange
|
||||||
}: IPositionCheckboxesProps): JSX.Element {
|
}: IPositionCheckboxesProps): JSX.Element {
|
||||||
return <CheckboxGroupButtons
|
return <CheckboxGroupButtons
|
||||||
|
@ -64,7 +66,7 @@ export function PositionCheckboxes({
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
onChange={(newSelectedValues) => {
|
onChange={(newSelectedValues) => {
|
||||||
onChange(id, newSelectedValues);
|
onChange(attribute, newSelectedValues);
|
||||||
}}
|
}}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,12 @@ import * as React from 'react';
|
||||||
import { PropertyType } from '../../Enums/PropertyType';
|
import { PropertyType } from '../../Enums/PropertyType';
|
||||||
import { IContainerProperties } from '../../Interfaces/IContainerProperties';
|
import { IContainerProperties } from '../../Interfaces/IContainerProperties';
|
||||||
import { ISymbolModel } from '../../Interfaces/ISymbolModel';
|
import { ISymbolModel } from '../../Interfaces/ISymbolModel';
|
||||||
import { SHOW_BORROWER_DIMENSIONS, SHOW_CHILDREN_DIMENSIONS, SHOW_SELF_DIMENSIONS } from '../../utils/default';
|
import {
|
||||||
|
SHOW_BORROWER_DIMENSIONS,
|
||||||
|
SHOW_CHILDREN_DIMENSIONS,
|
||||||
|
SHOW_SELF_DIMENSIONS,
|
||||||
|
SHOW_SELF_MARGINS_DIMENSIONS
|
||||||
|
} from '../../utils/default';
|
||||||
import { ApplyWidthMargin, ApplyXMargin, RemoveWidthMargin, RemoveXMargin, RestoreX, RestoreY, TransformX, TransformY } from '../../utils/svg';
|
import { ApplyWidthMargin, ApplyXMargin, RemoveWidthMargin, RemoveXMargin, RestoreX, RestoreY, TransformX, TransformY } from '../../utils/svg';
|
||||||
import { Text } from '../Text/Text';
|
import { Text } from '../Text/Text';
|
||||||
import { InputGroup } from '../InputGroup/InputGroup';
|
import { InputGroup } from '../InputGroup/InputGroup';
|
||||||
|
@ -336,24 +341,63 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
||||||
SHOW_SELF_DIMENSIONS &&
|
SHOW_SELF_DIMENSIONS &&
|
||||||
<div className='grid grid-cols-1 gap-2'>
|
<div className='grid grid-cols-1 gap-2'>
|
||||||
<PositionCheckboxes
|
<PositionCheckboxes
|
||||||
id='showSelfDimensions'
|
id='positionsSelfDimensions'
|
||||||
|
attribute='positions'
|
||||||
name='ShowSelfDimensions'
|
name='ShowSelfDimensions'
|
||||||
labelText={Text({ textId: '@ContainerShowDimension' })}
|
labelText={Text({ textId: '@ContainerShowDimension' })}
|
||||||
value={props.properties.dimensionOptions.showSelfDimensions}
|
value={props.properties.dimensionOptions.selfDimensions.positions}
|
||||||
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionOptions)}
|
onChange={(key, value) => props.onChange(key, value, PropertyType.SelfDimension)}
|
||||||
/>
|
/>
|
||||||
|
<InputGroup
|
||||||
|
labelText={Text({ textId: '@Color' })}
|
||||||
|
inputKey='color'
|
||||||
|
labelClassName=''
|
||||||
|
inputClassName=''
|
||||||
|
type='color'
|
||||||
|
value={props.properties.dimensionOptions.selfDimensions.color}
|
||||||
|
onChange={(e) => props.onChange('color', e.target.value, PropertyType.SelfDimension)}/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SHOW_SELF_MARGINS_DIMENSIONS &&
|
||||||
|
<div className='grid grid-cols-1 gap-2'>
|
||||||
|
<PositionCheckboxes
|
||||||
|
id='positionsSelfMarginsDimensions'
|
||||||
|
attribute='positions'
|
||||||
|
name='ShowSelfMarginsDimensions'
|
||||||
|
labelText={Text({ textId: '@ContainerShowMarginsDimension' })}
|
||||||
|
value={props.properties.dimensionOptions.selfMarginsDimensions.positions}
|
||||||
|
onChange={(key, value) => props.onChange(key, value, PropertyType.SelfMarginDimension)}
|
||||||
|
/>
|
||||||
|
<InputGroup
|
||||||
|
labelText={Text({ textId: '@Color' })}
|
||||||
|
inputKey='color'
|
||||||
|
labelClassName=''
|
||||||
|
inputClassName=''
|
||||||
|
type='color'
|
||||||
|
value={props.properties.dimensionOptions.selfMarginsDimensions.color}
|
||||||
|
onChange={(e) => props.onChange('color', e.target.value, PropertyType.SelfMarginDimension)}/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SHOW_CHILDREN_DIMENSIONS &&
|
SHOW_CHILDREN_DIMENSIONS &&
|
||||||
<div className='grid grid-cols-1 gap-2'>
|
<div className='grid grid-cols-1 gap-2'>
|
||||||
<PositionCheckboxes
|
<PositionCheckboxes
|
||||||
id='showChildrenDimensions'
|
id='positionsChildrenDimensions'
|
||||||
|
attribute='positions'
|
||||||
name='ShowChildrenDimensions'
|
name='ShowChildrenDimensions'
|
||||||
labelText={Text({ textId: '@ContainerShowChildrenDimension' })}
|
labelText={Text({ textId: '@ContainerShowChildrenDimension' })}
|
||||||
value={props.properties.dimensionOptions.showChildrenDimensions}
|
value={props.properties.dimensionOptions.childrenDimensions.positions}
|
||||||
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionOptions)}
|
onChange={(key, value) => props.onChange(key, value, PropertyType.ChildrenDimensions)}
|
||||||
/>
|
/>
|
||||||
|
<InputGroup
|
||||||
|
labelText={Text({ textId: '@Color' })}
|
||||||
|
inputKey='color'
|
||||||
|
labelClassName=''
|
||||||
|
inputClassName=''
|
||||||
|
type='color'
|
||||||
|
value={props.properties.dimensionOptions.childrenDimensions.color}
|
||||||
|
onChange={(e) => props.onChange('color', e.target.value, PropertyType.ChildrenDimensions)}/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -370,12 +414,21 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
<div className='grid grid-cols-1 gap-2'>
|
<div className='grid grid-cols-1 gap-2'>
|
||||||
<PositionCheckboxes
|
<PositionCheckboxes
|
||||||
id='showDimensionWithMarks'
|
id='positionsDimensionWithMarks'
|
||||||
|
attribute='positions'
|
||||||
name='ShowDimensionWithMarks'
|
name='ShowDimensionWithMarks'
|
||||||
labelText={Text({ textId: '@ContainerShowDimensionWithMarks' })}
|
labelText={Text({ textId: '@ContainerShowDimensionWithMarks' })}
|
||||||
value={props.properties.dimensionOptions.showDimensionWithMarks}
|
value={props.properties.dimensionOptions.dimensionWithMarks.positions}
|
||||||
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionOptions)}
|
onChange={(key, value) => props.onChange(key, value, PropertyType.DimensionWithMarks)}
|
||||||
/>
|
/>
|
||||||
|
<InputGroup
|
||||||
|
labelText={Text({ textId: '@Color' })}
|
||||||
|
inputKey='color'
|
||||||
|
labelClassName=''
|
||||||
|
inputClassName=''
|
||||||
|
type='color'
|
||||||
|
value={props.properties.dimensionOptions.dimensionWithMarks.color}
|
||||||
|
onChange={(e) => props.onChange('color', e.target.value, PropertyType.DimensionWithMarks)}/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,23 @@ describe.concurrent('Properties', () => {
|
||||||
warning: '',
|
warning: '',
|
||||||
hideChildrenInTreeview: false,
|
hideChildrenInTreeview: false,
|
||||||
dimensionOptions: {
|
dimensionOptions: {
|
||||||
showChildrenDimensions: [],
|
childrenDimensions: {
|
||||||
showSelfDimensions: [],
|
color: '#000000',
|
||||||
showDimensionWithMarks: [],
|
positions: []
|
||||||
markPosition: []
|
},
|
||||||
|
selfDimensions: {
|
||||||
|
color: '#000000',
|
||||||
|
positions: []
|
||||||
|
},
|
||||||
|
selfMarginsDimensions: {
|
||||||
|
color: '#000000',
|
||||||
|
positions: []
|
||||||
|
},
|
||||||
|
markPosition: [],
|
||||||
|
dimensionWithMarks: {
|
||||||
|
color: '#000000',
|
||||||
|
positions: []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,10 @@ import { Orientation } from '../../../Enums/Orientation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select a container
|
* Select a container
|
||||||
* @param container Selected container
|
|
||||||
* @returns New history
|
* @returns New history
|
||||||
|
* @param containerId
|
||||||
|
* @param fullHistory
|
||||||
|
* @param historyCurrentStep
|
||||||
*/
|
*/
|
||||||
export function SelectContainer(
|
export function SelectContainer(
|
||||||
containerId: string,
|
containerId: string,
|
||||||
|
@ -135,6 +137,7 @@ function GetSelectedContainerOnDelete(
|
||||||
/**
|
/**
|
||||||
* Unlink a container and its children to symbols
|
* Unlink a container and its children to symbols
|
||||||
* (used when deleting a container)
|
* (used when deleting a container)
|
||||||
|
* @param containers
|
||||||
* @param symbols Symbols to update
|
* @param symbols Symbols to update
|
||||||
* @param container Container to unlink
|
* @param container Container to unlink
|
||||||
*/
|
*/
|
||||||
|
@ -318,6 +321,18 @@ function AssignProperty(container: IContainerModel, key: string, value: string |
|
||||||
case PropertyType.Margin:
|
case PropertyType.Margin:
|
||||||
SetMargin();
|
SetMargin();
|
||||||
break;
|
break;
|
||||||
|
case PropertyType.SelfDimension:
|
||||||
|
(container.properties.dimensionOptions.selfDimensions as any)[key] = value;
|
||||||
|
break;
|
||||||
|
case PropertyType.SelfMarginDimension:
|
||||||
|
(container.properties.dimensionOptions.selfMarginsDimensions as any)[key] = value;
|
||||||
|
break;
|
||||||
|
case PropertyType.ChildrenDimensions:
|
||||||
|
(container.properties.dimensionOptions.childrenDimensions as any)[key] = value;
|
||||||
|
break;
|
||||||
|
case PropertyType.DimensionWithMarks:
|
||||||
|
(container.properties.dimensionOptions.dimensionWithMarks as any)[key] = value;
|
||||||
|
break;
|
||||||
case PropertyType.DimensionOptions:
|
case PropertyType.DimensionOptions:
|
||||||
(container.properties.dimensionOptions as any)[key] = value;
|
(container.properties.dimensionOptions as any)[key] = value;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,7 +24,7 @@ function GetDimensionsNodes(
|
||||||
let lastY = 0;
|
let lastY = 0;
|
||||||
for (const { container, depth } of it) {
|
for (const { container, depth } of it) {
|
||||||
if (currentDepth !== depth) {
|
if (currentDepth !== depth) {
|
||||||
AddNewDimension(currentDepth, min, max, lastY, scale, dimensions);
|
AddNewDimension(currentDepth, min, max, lastY, scale, '#000000', dimensions);
|
||||||
|
|
||||||
currentDepth = depth;
|
currentDepth = depth;
|
||||||
min = Infinity;
|
min = Infinity;
|
||||||
|
@ -43,7 +43,7 @@ function GetDimensionsNodes(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddNewDimension(currentDepth, min, max, lastY, scale, dimensions);
|
AddNewDimension(currentDepth, min, max, lastY, scale, '#000000', dimensions);
|
||||||
|
|
||||||
return dimensions;
|
return dimensions;
|
||||||
}
|
}
|
||||||
|
@ -70,12 +70,11 @@ export function DepthDimensionLayer(props: IDimensionLayerProps): JSX.Element {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddNewDimension(currentDepth: number, min: number, max: number, lastY: number, scale: number, dimensions: React.ReactNode[]): void {
|
function AddNewDimension(currentDepth: number, min: number, max: number, lastY: number, scale: number, color: string, dimensions: React.ReactNode[]): void {
|
||||||
const id = `dim-depth-${currentDepth}`;
|
const id = `dim-depth-${currentDepth}`;
|
||||||
const xStart = min;
|
const xStart = min;
|
||||||
const xEnd = max;
|
const xEnd = max;
|
||||||
const y = lastY + (DIMENSION_MARGIN * (currentDepth + 1)) / scale;
|
const y = lastY + (DIMENSION_MARGIN * (currentDepth + 1)) / scale;
|
||||||
const strokeWidth = 1;
|
|
||||||
const width = xEnd - xStart;
|
const width = xEnd - xStart;
|
||||||
const text = width
|
const text = width
|
||||||
.toFixed(0)
|
.toFixed(0)
|
||||||
|
@ -93,9 +92,9 @@ function AddNewDimension(currentDepth: number, min: number, max: number, lastY:
|
||||||
yStart={y}
|
yStart={y}
|
||||||
xEnd={xEnd}
|
xEnd={xEnd}
|
||||||
yEnd={y}
|
yEnd={y}
|
||||||
strokeWidth={strokeWidth}
|
|
||||||
text={text}
|
text={text}
|
||||||
scale={scale}
|
scale={scale}
|
||||||
|
color={color}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ interface IDimensionProps {
|
||||||
xEnd: number
|
xEnd: number
|
||||||
yEnd: number
|
yEnd: number
|
||||||
text: string
|
text: string
|
||||||
strokeWidth: number
|
color: string
|
||||||
scale?: number
|
scale?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ function ApplyParametric(x0: number, t: number, vx: number): number {
|
||||||
export function Dimension(props: IDimensionProps): JSX.Element {
|
export function Dimension(props: IDimensionProps): JSX.Element {
|
||||||
const scale = props.scale ?? 1;
|
const scale = props.scale ?? 1;
|
||||||
const style: React.CSSProperties = {
|
const style: React.CSSProperties = {
|
||||||
stroke: 'black',
|
stroke: props.color,
|
||||||
strokeWidth: 2 / scale
|
strokeWidth: 2 / scale
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,6 +56,9 @@ export function Dimension(props: IDimensionProps): JSX.Element {
|
||||||
const endBottomX = ApplyParametric(props.xEnd, -notchesLength, perpVecX);
|
const endBottomX = ApplyParametric(props.xEnd, -notchesLength, perpVecX);
|
||||||
const endBottomY = ApplyParametric(props.yEnd, -notchesLength, perpVecY);
|
const endBottomY = ApplyParametric(props.yEnd, -notchesLength, perpVecY);
|
||||||
|
|
||||||
|
const textX = ApplyParametric((props.xStart + props.xEnd) / 2, notchesLength, perpVecX);
|
||||||
|
const textY = ApplyParametric((props.yStart + props.yEnd) / 2, notchesLength, perpVecY);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<g key={props.id}>
|
<g key={props.id}>
|
||||||
<line
|
<line
|
||||||
|
@ -63,28 +66,25 @@ export function Dimension(props: IDimensionProps): JSX.Element {
|
||||||
y1={startTopY}
|
y1={startTopY}
|
||||||
x2={startBottomX}
|
x2={startBottomX}
|
||||||
y2={startBottomY}
|
y2={startBottomY}
|
||||||
strokeWidth={props.strokeWidth}
|
|
||||||
style={style}/>
|
style={style}/>
|
||||||
<line
|
<line
|
||||||
x1={props.xStart}
|
x1={props.xStart}
|
||||||
y1={props.yStart}
|
y1={props.yStart}
|
||||||
x2={props.xEnd}
|
x2={props.xEnd}
|
||||||
y2={props.yEnd}
|
y2={props.yEnd}
|
||||||
strokeWidth={props.strokeWidth}
|
|
||||||
style={style}/>
|
style={style}/>
|
||||||
<line
|
<line
|
||||||
x1={endTopX}
|
x1={endTopX}
|
||||||
y1={endTopY}
|
y1={endTopY}
|
||||||
x2={endBottomX}
|
x2={endBottomX}
|
||||||
y2={endBottomY}
|
y2={endBottomY}
|
||||||
strokeWidth={props.strokeWidth}
|
|
||||||
style={style}/>
|
style={style}/>
|
||||||
<text
|
<text textAnchor={'middle'} alignmentBaseline={'central'}
|
||||||
x={(props.xStart + props.xEnd) / 2}
|
x={textX}
|
||||||
y={(props.yStart + props.yEnd) / 2}
|
y={textY}
|
||||||
style={{
|
style={{
|
||||||
transform: `rotate(${rotation}turn) scale(${1 / scale}) translateX(-50%) translateY(-100%)`,
|
transform: `rotate(${rotation}turn) scale(${1 / scale})`,
|
||||||
transformBox: 'fill-box'
|
transformOrigin: `${textX}px ${textY}px`
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.text}
|
{props.text}
|
||||||
|
|
|
@ -2,7 +2,13 @@ import * as React from 'react';
|
||||||
import { Orientation } from '../../../Enums/Orientation';
|
import { Orientation } from '../../../Enums/Orientation';
|
||||||
import { Position } from '../../../Enums/Position';
|
import { Position } from '../../../Enums/Position';
|
||||||
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
||||||
import { DIMENSION_MARGIN, SHOW_BORROWER_DIMENSIONS, SHOW_CHILDREN_DIMENSIONS, SHOW_SELF_DIMENSIONS } from '../../../utils/default';
|
import {
|
||||||
|
DIMENSION_MARGIN,
|
||||||
|
SHOW_BORROWER_DIMENSIONS,
|
||||||
|
SHOW_CHILDREN_DIMENSIONS,
|
||||||
|
SHOW_SELF_DIMENSIONS,
|
||||||
|
SHOW_SELF_MARGINS_DIMENSIONS
|
||||||
|
} from '../../../utils/default';
|
||||||
import { FindContainerById, MakeRecursionDFSIterator, Pairwise } from '../../../utils/itertools';
|
import { FindContainerById, MakeRecursionDFSIterator, Pairwise } from '../../../utils/itertools';
|
||||||
import { TransformX, TransformY } from '../../../utils/svg';
|
import { TransformX, TransformY } from '../../../utils/svg';
|
||||||
import { Dimension } from './Dimension';
|
import { Dimension } from './Dimension';
|
||||||
|
@ -13,8 +19,6 @@ interface IDimensionLayerProps {
|
||||||
scale: number
|
scale: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const MODULE_STROKE_WIDTH = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction that call another function given the positions
|
* Fonction that call another function given the positions
|
||||||
* @param dimMapped Position mapped depending on the Position enum in order:
|
* @param dimMapped Position mapped depending on the Position enum in order:
|
||||||
|
@ -67,29 +71,46 @@ function Dimensions({ containers, root, scale }: IDimensionLayerProps): React.Re
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const { container, depth, currentTransform } of it) {
|
for (const { container, depth, currentTransform } of it) {
|
||||||
const containerLeftDim = leftDim - (DIMENSION_MARGIN * (depth + 1)) / scale;
|
const offset = (DIMENSION_MARGIN * (depth + 1)) / scale;
|
||||||
const containerTopDim = topDim - (DIMENSION_MARGIN * (depth + 1)) / scale;
|
const containerLeftDim = leftDim - offset;
|
||||||
const containerBottomDim = bottomDim + (DIMENSION_MARGIN * (depth + 1)) / scale;
|
const containerTopDim = topDim - offset;
|
||||||
const containerRightDim = rightDim + (DIMENSION_MARGIN * (depth + 1)) / scale;
|
const containerBottomDim = bottomDim + offset;
|
||||||
|
const containerRightDim = rightDim + offset;
|
||||||
const dimMapped = [containerLeftDim, containerBottomDim, containerTopDim, containerRightDim];
|
const dimMapped = [containerLeftDim, containerBottomDim, containerTopDim, containerRightDim];
|
||||||
if (SHOW_SELF_DIMENSIONS && container.properties.dimensionOptions.showSelfDimensions.length > 0) {
|
if (SHOW_SELF_DIMENSIONS && container.properties.dimensionOptions.selfDimensions.positions.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.dimensionOptions.showSelfDimensions,
|
container.properties.dimensionOptions.selfDimensions.positions,
|
||||||
AddHorizontalSelfDimension,
|
AddHorizontalSelfDimension,
|
||||||
AddVerticalSelfDimension,
|
AddVerticalSelfDimension,
|
||||||
[
|
[
|
||||||
container,
|
container,
|
||||||
currentTransform,
|
currentTransform,
|
||||||
dimensions,
|
dimensions,
|
||||||
scale]
|
scale,
|
||||||
|
container.properties.dimensionOptions.selfDimensions.color]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_BORROWER_DIMENSIONS && container.properties.dimensionOptions.showDimensionWithMarks.length > 0) {
|
if (SHOW_SELF_MARGINS_DIMENSIONS && container.properties.dimensionOptions.selfMarginsDimensions.positions.length > 0) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.dimensionOptions.showDimensionWithMarks,
|
container.properties.dimensionOptions.selfMarginsDimensions.positions,
|
||||||
|
AddHorizontalSelfMarginsDimension,
|
||||||
|
AddVerticalSelfMarginDimension,
|
||||||
|
[
|
||||||
|
container,
|
||||||
|
currentTransform,
|
||||||
|
dimensions,
|
||||||
|
scale,
|
||||||
|
container.properties.dimensionOptions.selfMarginsDimensions.color]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SHOW_BORROWER_DIMENSIONS && container.properties.dimensionOptions.dimensionWithMarks.positions.length > 0) {
|
||||||
|
ActionByPosition(
|
||||||
|
dimMapped,
|
||||||
|
container.properties.dimensionOptions.dimensionWithMarks.positions,
|
||||||
AddHorizontalBorrowerDimension,
|
AddHorizontalBorrowerDimension,
|
||||||
AddVerticalBorrowerDimension,
|
AddVerticalBorrowerDimension,
|
||||||
[
|
[
|
||||||
|
@ -98,14 +119,15 @@ function Dimensions({ containers, root, scale }: IDimensionLayerProps): React.Re
|
||||||
depth,
|
depth,
|
||||||
currentTransform,
|
currentTransform,
|
||||||
dimensions,
|
dimensions,
|
||||||
scale]
|
scale,
|
||||||
|
container.properties.dimensionOptions.dimensionWithMarks.color]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SHOW_CHILDREN_DIMENSIONS && container.properties.dimensionOptions.showChildrenDimensions.length > 0 && container.children.length >= 2) {
|
if (SHOW_CHILDREN_DIMENSIONS && container.properties.dimensionOptions.childrenDimensions.positions.length > 0 && container.children.length >= 2) {
|
||||||
ActionByPosition(
|
ActionByPosition(
|
||||||
dimMapped,
|
dimMapped,
|
||||||
container.properties.dimensionOptions.showChildrenDimensions,
|
container.properties.dimensionOptions.childrenDimensions.positions,
|
||||||
AddHorizontalChildrenDimension,
|
AddHorizontalChildrenDimension,
|
||||||
AddVerticalChildrenDimension,
|
AddVerticalChildrenDimension,
|
||||||
[
|
[
|
||||||
|
@ -113,7 +135,8 @@ function Dimensions({ containers, root, scale }: IDimensionLayerProps): React.Re
|
||||||
container,
|
container,
|
||||||
currentTransform,
|
currentTransform,
|
||||||
dimensions,
|
dimensions,
|
||||||
scale]
|
scale,
|
||||||
|
container.properties.dimensionOptions.childrenDimensions.color]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +165,8 @@ function AddHorizontalChildrenDimension(
|
||||||
container: IContainerModel,
|
container: IContainerModel,
|
||||||
currentTransform: [number, number],
|
currentTransform: [number, number],
|
||||||
dimensions: React.ReactNode[],
|
dimensions: React.ReactNode[],
|
||||||
scale: number
|
scale: number,
|
||||||
|
color: string
|
||||||
): void {
|
): void {
|
||||||
const childrenId = `dim-y${yDim.toFixed(0)}-children-${container.properties.id}`;
|
const childrenId = `dim-y${yDim.toFixed(0)}-children-${container.properties.id}`;
|
||||||
|
|
||||||
|
@ -192,9 +216,9 @@ function AddHorizontalChildrenDimension(
|
||||||
xEnd={xChildrenEnd + offset}
|
xEnd={xChildrenEnd + offset}
|
||||||
yStart={yDim}
|
yStart={yDim}
|
||||||
yEnd={yDim}
|
yEnd={yDim}
|
||||||
strokeWidth={MODULE_STROKE_WIDTH}
|
|
||||||
text={textChildren}
|
text={textChildren}
|
||||||
scale={scale} />);
|
scale={scale}
|
||||||
|
color={color}/>);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddVerticalChildrenDimension(
|
function AddVerticalChildrenDimension(
|
||||||
|
@ -204,7 +228,9 @@ function AddVerticalChildrenDimension(
|
||||||
container: IContainerModel,
|
container: IContainerModel,
|
||||||
currentTransform: [number, number],
|
currentTransform: [number, number],
|
||||||
dimensions: React.ReactNode[],
|
dimensions: React.ReactNode[],
|
||||||
scale: number
|
scale: number,
|
||||||
|
color: string
|
||||||
|
|
||||||
): void {
|
): void {
|
||||||
const childrenId = `dim-x${xDim.toFixed(0)}-children-${container.properties.id}`;
|
const childrenId = `dim-x${xDim.toFixed(0)}-children-${container.properties.id}`;
|
||||||
|
|
||||||
|
@ -259,9 +285,9 @@ function AddVerticalChildrenDimension(
|
||||||
yStart={yChildrenStart + offset}
|
yStart={yChildrenStart + offset}
|
||||||
xEnd={xDim}
|
xEnd={xDim}
|
||||||
yEnd={yChildrenEnd + offset}
|
yEnd={yChildrenEnd + offset}
|
||||||
strokeWidth={MODULE_STROKE_WIDTH}
|
|
||||||
text={textChildren}
|
text={textChildren}
|
||||||
scale={scale}
|
scale={scale}
|
||||||
|
color={color}
|
||||||
/>);
|
/>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +298,8 @@ function AddHorizontalBorrowerDimension(
|
||||||
depth: number,
|
depth: number,
|
||||||
currentTransform: [number, number],
|
currentTransform: [number, number],
|
||||||
dimensions: React.ReactNode[],
|
dimensions: React.ReactNode[],
|
||||||
scale: number
|
scale: number,
|
||||||
|
color: string
|
||||||
): void {
|
): void {
|
||||||
const it = MakeRecursionDFSIterator(container, containers, depth, currentTransform);
|
const it = MakeRecursionDFSIterator(container, containers, depth, currentTransform);
|
||||||
const marks = []; // list of vertical lines for the dimension
|
const marks = []; // list of vertical lines for the dimension
|
||||||
|
@ -316,9 +343,9 @@ function AddHorizontalBorrowerDimension(
|
||||||
xEnd={next}
|
xEnd={next}
|
||||||
yStart={yDim}
|
yStart={yDim}
|
||||||
yEnd={yDim}
|
yEnd={yDim}
|
||||||
strokeWidth={MODULE_STROKE_WIDTH}
|
|
||||||
text={value.toFixed(0)}
|
text={value.toFixed(0)}
|
||||||
scale={scale} />);
|
scale={scale}
|
||||||
|
color={color}/>);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +358,8 @@ function AddVerticalBorrowerDimension(
|
||||||
depth: number,
|
depth: number,
|
||||||
currentTransform: [number, number],
|
currentTransform: [number, number],
|
||||||
dimensions: React.ReactNode[],
|
dimensions: React.ReactNode[],
|
||||||
scale: number
|
scale: number,
|
||||||
|
color: string
|
||||||
): void {
|
): void {
|
||||||
const it = MakeRecursionDFSIterator(container, containers, depth, currentTransform);
|
const it = MakeRecursionDFSIterator(container, containers, depth, currentTransform);
|
||||||
const marks = []; // list of vertical lines for the dimension
|
const marks = []; // list of vertical lines for the dimension
|
||||||
|
@ -380,9 +408,9 @@ function AddVerticalBorrowerDimension(
|
||||||
xEnd={xDim}
|
xEnd={xDim}
|
||||||
yStart={cur}
|
yStart={cur}
|
||||||
yEnd={next}
|
yEnd={next}
|
||||||
strokeWidth={MODULE_STROKE_WIDTH}
|
|
||||||
text={value.toFixed(0)}
|
text={value.toFixed(0)}
|
||||||
scale={scale} />);
|
scale={scale}
|
||||||
|
color={color}/>);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +421,8 @@ function AddVerticalSelfDimension(
|
||||||
container: IContainerModel,
|
container: IContainerModel,
|
||||||
currentTransform: [number, number],
|
currentTransform: [number, number],
|
||||||
dimensions: React.ReactNode[],
|
dimensions: React.ReactNode[],
|
||||||
scale: number
|
scale: number,
|
||||||
|
color: string
|
||||||
): void {
|
): void {
|
||||||
const height = container.properties.height;
|
const height = container.properties.height;
|
||||||
const idVert = `dim-x${xDim.toFixed(0)}-${container.properties.id}`;
|
const idVert = `dim-x${xDim.toFixed(0)}-${container.properties.id}`;
|
||||||
|
@ -415,18 +444,20 @@ function AddVerticalSelfDimension(
|
||||||
yStart={yStart}
|
yStart={yStart}
|
||||||
xEnd={xDim}
|
xEnd={xDim}
|
||||||
yEnd={yEnd}
|
yEnd={yEnd}
|
||||||
strokeWidth={MODULE_STROKE_WIDTH}
|
|
||||||
text={textVert}
|
text={textVert}
|
||||||
scale={scale} />
|
scale={scale}
|
||||||
|
color={color}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddHorizontalSelfDimension(
|
function AddHorizontalSelfDimension(
|
||||||
|
|
||||||
yDim: number,
|
yDim: number,
|
||||||
container: IContainerModel,
|
container: IContainerModel,
|
||||||
currentTransform: [number, number],
|
currentTransform: [number, number],
|
||||||
dimensions: React.ReactNode[],
|
dimensions: React.ReactNode[],
|
||||||
scale: number
|
scale: number,
|
||||||
|
color: string
|
||||||
): void {
|
): void {
|
||||||
const width = container.properties.width;
|
const width = container.properties.width;
|
||||||
const id = `dim-y${yDim.toFixed(0)}-${container.properties.id}`;
|
const id = `dim-y${yDim.toFixed(0)}-${container.properties.id}`;
|
||||||
|
@ -443,8 +474,125 @@ function AddHorizontalSelfDimension(
|
||||||
yStart={yDim}
|
yStart={yDim}
|
||||||
xEnd={xEnd}
|
xEnd={xEnd}
|
||||||
yEnd={yDim}
|
yEnd={yDim}
|
||||||
strokeWidth={MODULE_STROKE_WIDTH}
|
|
||||||
text={text}
|
text={text}
|
||||||
scale={scale} />
|
scale={scale}
|
||||||
|
color={color}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AddHorizontalSelfMarginsDimension(
|
||||||
|
|
||||||
|
yDim: number,
|
||||||
|
container: IContainerModel,
|
||||||
|
currentTransform: [number, number],
|
||||||
|
dimensions: React.ReactNode[],
|
||||||
|
scale: number,
|
||||||
|
color: string
|
||||||
|
): void {
|
||||||
|
const left = container.properties.margin.left;
|
||||||
|
if (left != null) {
|
||||||
|
const id = `dim-y-margin-left${yDim.toFixed(0)}-${container.properties.id}`;
|
||||||
|
const xStart = container.properties.x + currentTransform[0] - left;
|
||||||
|
const xEnd = xStart + left;
|
||||||
|
const text = left
|
||||||
|
.toFixed(0)
|
||||||
|
.toString();
|
||||||
|
dimensions.push(
|
||||||
|
<Dimension
|
||||||
|
key={id}
|
||||||
|
id={id}
|
||||||
|
xStart={xStart}
|
||||||
|
yStart={yDim}
|
||||||
|
xEnd={xEnd}
|
||||||
|
yEnd={yDim}
|
||||||
|
text={text}
|
||||||
|
scale={scale}
|
||||||
|
color={color}/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const right = container.properties.margin.right;
|
||||||
|
if (right != null) {
|
||||||
|
const id = `dim-y-margin-right${yDim.toFixed(0)}-${container.properties.id}`;
|
||||||
|
const xStart = container.properties.x + container.properties.width + currentTransform[0];
|
||||||
|
const xEnd = xStart + right;
|
||||||
|
const text = right
|
||||||
|
.toFixed(0)
|
||||||
|
.toString();
|
||||||
|
dimensions.push(
|
||||||
|
<Dimension
|
||||||
|
key={id}
|
||||||
|
id={id}
|
||||||
|
xStart={xStart}
|
||||||
|
yStart={yDim}
|
||||||
|
xEnd={xEnd}
|
||||||
|
yEnd={yDim}
|
||||||
|
text={text}
|
||||||
|
scale={scale}
|
||||||
|
color={color}/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function AddVerticalSelfMarginDimension(
|
||||||
|
xDim: number,
|
||||||
|
isRight: boolean,
|
||||||
|
container: IContainerModel,
|
||||||
|
currentTransform: [number, number],
|
||||||
|
dimensions: React.ReactNode[],
|
||||||
|
scale: number,
|
||||||
|
color: string
|
||||||
|
): void {
|
||||||
|
const top = container.properties.margin.top;
|
||||||
|
if (top != null) {
|
||||||
|
const idVert = `dim-x-margin-top${xDim.toFixed(0)}-${container.properties.id}`;
|
||||||
|
let yStart = container.properties.y + currentTransform[1];
|
||||||
|
let yEnd = yStart - top;
|
||||||
|
const textVert = top
|
||||||
|
.toFixed(0)
|
||||||
|
.toString();
|
||||||
|
|
||||||
|
if (isRight) {
|
||||||
|
[yStart, yEnd] = [yEnd, yStart];
|
||||||
|
}
|
||||||
|
|
||||||
|
dimensions.push(
|
||||||
|
<Dimension
|
||||||
|
key={idVert}
|
||||||
|
id={idVert}
|
||||||
|
xStart={xDim}
|
||||||
|
yStart={yStart}
|
||||||
|
xEnd={xDim}
|
||||||
|
yEnd={yEnd}
|
||||||
|
text={textVert}
|
||||||
|
scale={scale}
|
||||||
|
color={color}/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const bottom = container.properties.margin.bottom;
|
||||||
|
if (bottom != null) {
|
||||||
|
const idVert = `dim-x-margin-bottom${xDim.toFixed(0)}-${container.properties.id}`;
|
||||||
|
let yStart = container.properties.y + container.properties.height + bottom + currentTransform[1];
|
||||||
|
let yEnd = yStart - bottom;
|
||||||
|
const textVert = bottom
|
||||||
|
.toFixed(0)
|
||||||
|
.toString();
|
||||||
|
|
||||||
|
if (isRight) {
|
||||||
|
[yStart, yEnd] = [yEnd, yStart];
|
||||||
|
}
|
||||||
|
|
||||||
|
dimensions.push(
|
||||||
|
<Dimension
|
||||||
|
key={idVert}
|
||||||
|
id={idVert}
|
||||||
|
xStart={xDim}
|
||||||
|
yStart={yStart}
|
||||||
|
xEnd={xDim}
|
||||||
|
yEnd={yEnd}
|
||||||
|
text={textVert}
|
||||||
|
scale={scale}
|
||||||
|
color={color}/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,5 +23,10 @@ export enum PropertyType {
|
||||||
/**
|
/**
|
||||||
* Dimension options
|
* Dimension options
|
||||||
*/
|
*/
|
||||||
DimensionOptions,
|
SelfDimension,
|
||||||
|
SelfMarginDimension,
|
||||||
|
ChildrenDimensions,
|
||||||
|
DimensionWithMarks,
|
||||||
|
DimensionOptions
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import { PositionReference } from '../Enums/PositionReference';
|
||||||
import { IAction } from './IAction';
|
import { IAction } from './IAction';
|
||||||
import { IMargin } from './IMargin';
|
import { IMargin } from './IMargin';
|
||||||
import { Orientation } from '../Enums/Orientation';
|
import { Orientation } from '../Enums/Orientation';
|
||||||
import { Position } from '../Enums/Position';
|
|
||||||
import { IKeyValue } from './IKeyValue';
|
import { IKeyValue } from './IKeyValue';
|
||||||
import { IStyle } from './IStyle';
|
import { IStyle } from './IStyle';
|
||||||
|
import { IDimensions } from './IDimensions';
|
||||||
|
|
||||||
/** Model of available container used in application configuration */
|
/** Model of available container used in application configuration */
|
||||||
export interface IAvailableContainer {
|
export interface IAvailableContainer {
|
||||||
|
@ -113,22 +113,8 @@ export interface IAvailableContainer {
|
||||||
/** Hide the children in the treeview */
|
/** Hide the children in the treeview */
|
||||||
HideChildrenInTreeview?: boolean
|
HideChildrenInTreeview?: boolean
|
||||||
|
|
||||||
/** if true, show the dimension of the container */
|
/** Dimensions options */
|
||||||
ShowSelfDimensions?: Position[]
|
DimensionOptions?: IDimensions
|
||||||
|
|
||||||
/** if true show the overall dimensions of its children */
|
|
||||||
ShowChildrenDimensions?: Position[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, allows a parent dimension borrower to uses its x coordinate for as a reference point for a dimension
|
|
||||||
*/
|
|
||||||
MarkPosition?: Orientation[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if true, show a dimension from the edge of the container to end
|
|
||||||
* and insert dimensions marks at lift up children (see MarkPosition)
|
|
||||||
*/
|
|
||||||
ShowDimensionWithMarks?: Position[]
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if true, hide the entry in the sidebar (default: false)
|
* if true, hide the entry in the sidebar (default: false)
|
||||||
|
|
10
src/Interfaces/IDimensionOptions.ts
Normal file
10
src/Interfaces/IDimensionOptions.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { Position } from '../Enums/Position';
|
||||||
|
|
||||||
|
export interface IDimensionOptions {
|
||||||
|
|
||||||
|
positions: Position[]
|
||||||
|
/**
|
||||||
|
* Stroke color
|
||||||
|
*/
|
||||||
|
color: string
|
||||||
|
}
|
|
@ -1,13 +1,17 @@
|
||||||
|
|
||||||
|
import { IDimensionOptions } from './IDimensionOptions';
|
||||||
import { Orientation } from '../Enums/Orientation';
|
import { Orientation } from '../Enums/Orientation';
|
||||||
import { Position } from '../Enums/Position';
|
|
||||||
|
|
||||||
export interface IDimensions {
|
export interface IDimensions {
|
||||||
// TODO: Refactor showSelf., showChildren., markPosition, showDimensionWithMarks in IDimensionOptions interface
|
|
||||||
/** if true, show the dimension of the container */
|
/** if true, show the dimension of the container */
|
||||||
showSelfDimensions: Position[]
|
selfDimensions: IDimensionOptions
|
||||||
|
|
||||||
|
/** if true, show the dimension of the container */
|
||||||
|
selfMarginsDimensions: IDimensionOptions
|
||||||
|
|
||||||
/** if true show the overall dimensions of its children */
|
/** if true show the overall dimensions of its children */
|
||||||
showChildrenDimensions: Position[]
|
childrenDimensions: IDimensionOptions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if true, allows a parent dimension borrower to borrow its x coordinate
|
* if true, allows a parent dimension borrower to borrow its x coordinate
|
||||||
|
@ -19,5 +23,6 @@ export interface IDimensions {
|
||||||
* if true, show a dimension from the edge of the container to end
|
* if true, show a dimension from the edge of the container to end
|
||||||
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
|
||||||
*/
|
*/
|
||||||
showDimensionWithMarks: Position[]
|
dimensionWithMarks: IDimensionOptions
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,9 @@
|
||||||
focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500
|
focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500
|
||||||
disabled:bg-slate-200 disabled:text-gray-500 disabled:border-slate-300 disabled:shadow-none;
|
disabled:bg-slate-200 disabled:text-gray-500 disabled:border-slate-300 disabled:shadow-none;
|
||||||
}
|
}
|
||||||
|
.input-group[type='color'] {
|
||||||
|
@apply py-0
|
||||||
|
}
|
||||||
|
|
||||||
.prop-category-body {
|
.prop-category-body {
|
||||||
@apply rounded-lg bg-slate-300 p-3
|
@apply rounded-lg bg-slate-300 p-3
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { IContainerProperties } from '../Interfaces/IContainerProperties';
|
||||||
import { IEditorState } from '../Interfaces/IEditorState';
|
import { IEditorState } from '../Interfaces/IEditorState';
|
||||||
import { ISymbolModel } from '../Interfaces/ISymbolModel';
|
import { ISymbolModel } from '../Interfaces/ISymbolModel';
|
||||||
import { Orientation } from '../Enums/Orientation';
|
import { Orientation } from '../Enums/Orientation';
|
||||||
import { Position } from '../Enums/Position';
|
|
||||||
import { AppState } from '../Enums/AppState';
|
import { AppState } from '../Enums/AppState';
|
||||||
|
|
||||||
/// EDITOR DEFAULTS ///
|
/// EDITOR DEFAULTS ///
|
||||||
|
@ -63,6 +62,7 @@ export const DEFAULTCHILDTYPE_MAX_DEPTH = 10;
|
||||||
/// DIMENSIONS DEFAULTS ///
|
/// DIMENSIONS DEFAULTS ///
|
||||||
|
|
||||||
export const SHOW_SELF_DIMENSIONS = true;
|
export const SHOW_SELF_DIMENSIONS = true;
|
||||||
|
export const SHOW_SELF_MARGINS_DIMENSIONS = true;
|
||||||
export const SHOW_CHILDREN_DIMENSIONS = true;
|
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;
|
||||||
|
@ -211,10 +211,23 @@ export const DEFAULT_MAINCONTAINER_PROPS: IContainerProperties = {
|
||||||
positionReference: PositionReference.TopLeft,
|
positionReference: PositionReference.TopLeft,
|
||||||
hideChildrenInTreeview: false,
|
hideChildrenInTreeview: false,
|
||||||
dimensionOptions: {
|
dimensionOptions: {
|
||||||
showChildrenDimensions: [Position.Up, Position.Left],
|
childrenDimensions: {
|
||||||
showSelfDimensions: [Position.Up, Position.Left],
|
color: '#000000',
|
||||||
showDimensionWithMarks: [Position.Down, Position.Right],
|
positions: []
|
||||||
markPosition: []
|
},
|
||||||
|
selfDimensions: {
|
||||||
|
color: '#000000',
|
||||||
|
positions: []
|
||||||
|
},
|
||||||
|
selfMarginsDimensions: {
|
||||||
|
color: '#000000',
|
||||||
|
positions: []
|
||||||
|
},
|
||||||
|
markPosition: [],
|
||||||
|
dimensionWithMarks: {
|
||||||
|
color: '#000000',
|
||||||
|
positions: []
|
||||||
|
}
|
||||||
},
|
},
|
||||||
warning: '',
|
warning: '',
|
||||||
style: DEFAULT_CONTAINER_STYLE
|
style: DEFAULT_CONTAINER_STYLE
|
||||||
|
@ -262,10 +275,23 @@ export function GetDefaultContainerProps(type: string,
|
||||||
maxHeight: containerConfig.MaxWidth ?? Number.MAX_SAFE_INTEGER,
|
maxHeight: containerConfig.MaxWidth ?? Number.MAX_SAFE_INTEGER,
|
||||||
hideChildrenInTreeview: containerConfig.HideChildrenInTreeview ?? false,
|
hideChildrenInTreeview: containerConfig.HideChildrenInTreeview ?? false,
|
||||||
dimensionOptions: {
|
dimensionOptions: {
|
||||||
showChildrenDimensions: containerConfig.ShowChildrenDimensions ?? [],
|
childrenDimensions: {
|
||||||
showSelfDimensions: containerConfig.ShowSelfDimensions ?? [],
|
color: containerConfig.DimensionOptions?.childrenDimensions.color ?? '#000000',
|
||||||
markPosition: containerConfig.MarkPosition ?? [],
|
positions: containerConfig.DimensionOptions?.childrenDimensions.positions ?? []
|
||||||
showDimensionWithMarks: containerConfig.ShowDimensionWithMarks ?? []
|
},
|
||||||
|
selfDimensions: {
|
||||||
|
color: containerConfig.DimensionOptions?.selfDimensions.color ?? '#000000',
|
||||||
|
positions: containerConfig.DimensionOptions?.selfDimensions.positions ?? []
|
||||||
|
},
|
||||||
|
selfMarginsDimensions: {
|
||||||
|
color: containerConfig.DimensionOptions?.selfMarginsDimensions.color ?? '#000000',
|
||||||
|
positions: containerConfig.DimensionOptions?.selfMarginsDimensions.positions ?? []
|
||||||
|
},
|
||||||
|
markPosition: containerConfig.DimensionOptions?.markPosition ?? [],
|
||||||
|
dimensionWithMarks: {
|
||||||
|
color: containerConfig.DimensionOptions?.dimensionWithMarks.color ?? '#000000',
|
||||||
|
positions: containerConfig.DimensionOptions?.dimensionWithMarks.positions ?? []
|
||||||
|
}
|
||||||
},
|
},
|
||||||
warning: '',
|
warning: '',
|
||||||
customSVG: containerConfig.CustomSVG,
|
customSVG: containerConfig.CustomSVG,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue