Remove usage of ContainerModel rather than IContainerModel
This commit is contained in:
parent
1116185b9f
commit
a8723ffd27
6 changed files with 23 additions and 25 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, { Dispatch, SetStateAction, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
import React, { Dispatch, SetStateAction, useContext, useEffect, useRef, useState } from 'react';
|
||||||
import { UseCustomEvents } from '../../Events/AppEvents';
|
import { UseCustomEvents } from '../../Events/AppEvents';
|
||||||
import { MainMenu } from '../MainMenu/MainMenu';
|
import { MainMenu } from '../MainMenu/MainMenu';
|
||||||
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
|
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import { AddMethod } from '../../../Enums/AddMethod';
|
import { AddMethod } from '../../../Enums/AddMethod';
|
||||||
import { IAvailableContainer } from '../../../Interfaces/IAvailableContainer';
|
import { IAvailableContainer } from '../../../Interfaces/IAvailableContainer';
|
||||||
import { IConfiguration } from '../../../Interfaces/IConfiguration';
|
import { IConfiguration } from '../../../Interfaces/IConfiguration';
|
||||||
import { IContainerModel, ContainerModel } from '../../../Interfaces/IContainerModel';
|
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
||||||
import { IHistoryState } from '../../../Interfaces/IHistoryState';
|
import { IHistoryState } from '../../../Interfaces/IHistoryState';
|
||||||
import { IPattern, GetPattern, ContainerOrPattern } from '../../../Interfaces/IPattern';
|
import { IPattern, GetPattern, ContainerOrPattern } from '../../../Interfaces/IPattern';
|
||||||
import { ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
import { ISymbolModel } from '../../../Interfaces/ISymbolModel';
|
||||||
|
@ -125,7 +125,7 @@ function AddNewContainerToParent(
|
||||||
newCounters: Record<string, number>,
|
newCounters: Record<string, number>,
|
||||||
symbols: Map<string, ISymbolModel>,
|
symbols: Map<string, ISymbolModel>,
|
||||||
initChilds: boolean = true
|
initChilds: boolean = true
|
||||||
): ContainerModel {
|
): IContainerModel {
|
||||||
const type = availableContainer.Type;
|
const type = availableContainer.Type;
|
||||||
|
|
||||||
const defaultConfig = configuration.AvailableContainers
|
const defaultConfig = configuration.AvailableContainers
|
||||||
|
@ -170,13 +170,11 @@ function AddNewContainerToParent(
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the container
|
// Create the container
|
||||||
const newContainer = new ContainerModel(
|
const newContainer: IContainerModel = {
|
||||||
defaultProperties,
|
properties: defaultProperties,
|
||||||
[],
|
children: [],
|
||||||
{
|
userData: {}
|
||||||
type
|
};
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Register the container in the hashmap
|
// Register the container in the hashmap
|
||||||
containers.set(newContainer.properties.id, newContainer);
|
containers.set(newContainer.properties.id, newContainer);
|
||||||
|
@ -266,7 +264,7 @@ export function AddContainer(
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function InitializeDefaultChild(
|
function InitializeDefaultChild(
|
||||||
newContainer: ContainerModel,
|
newContainer: IContainerModel,
|
||||||
configuration: IConfiguration,
|
configuration: IConfiguration,
|
||||||
containerConfig: IAvailableContainer,
|
containerConfig: IAvailableContainer,
|
||||||
containers: Map<string, IContainerModel>,
|
containers: Map<string, IContainerModel>,
|
||||||
|
@ -297,7 +295,7 @@ function InitializeDefaultChild(
|
||||||
}
|
}
|
||||||
|
|
||||||
function InitializeChildrenWithPattern(
|
function InitializeChildrenWithPattern(
|
||||||
newContainer: ContainerModel,
|
newContainer: IContainerModel,
|
||||||
configuration: IConfiguration,
|
configuration: IConfiguration,
|
||||||
containers: Map<string, IContainerModel>,
|
containers: Map<string, IContainerModel>,
|
||||||
containerConfig: IAvailableContainer,
|
containerConfig: IAvailableContainer,
|
||||||
|
@ -338,7 +336,7 @@ function InitializeChildrenWithPattern(
|
||||||
*/
|
*/
|
||||||
function BuildPatterns(
|
function BuildPatterns(
|
||||||
rootPattern: ContainerOrPattern,
|
rootPattern: ContainerOrPattern,
|
||||||
newContainer: ContainerModel,
|
newContainer: IContainerModel,
|
||||||
configuration: IConfiguration,
|
configuration: IConfiguration,
|
||||||
containers: Map<string, IContainerModel>,
|
containers: Map<string, IContainerModel>,
|
||||||
newCounters: Record<string, number>,
|
newCounters: Record<string, number>,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { IHistoryState } from '../../../Interfaces/IHistoryState';
|
import { IHistoryState } from '../../../Interfaces/IHistoryState';
|
||||||
import { ContainerModel, IContainerModel } from '../../../Interfaces/IContainerModel';
|
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
||||||
import { FindContainerById, MakeDFSIterator } from '../../../utils/itertools';
|
import { FindContainerById, MakeDFSIterator } from '../../../utils/itertools';
|
||||||
import { GetCurrentHistory } from '../Editor';
|
import { GetCurrentHistory } from '../Editor';
|
||||||
import { ApplyBehaviors, ApplyBehaviorsOnSiblings, ApplyBehaviorsOnSiblingsChildren } from '../Behaviors/Behaviors';
|
import { ApplyBehaviors, ApplyBehaviorsOnSiblings, ApplyBehaviorsOnSiblingsChildren } from '../Behaviors/Behaviors';
|
||||||
|
@ -176,7 +176,7 @@ export function OnPropertyChange(
|
||||||
}
|
}
|
||||||
|
|
||||||
const containers = structuredClone(current.containers);
|
const containers = structuredClone(current.containers);
|
||||||
const container: ContainerModel | undefined = FindContainerById(containers, selected.properties.id);
|
const container: IContainerModel | undefined = FindContainerById(containers, selected.properties.id);
|
||||||
|
|
||||||
if (container === null || container === undefined) {
|
if (container === null || container === undefined) {
|
||||||
throw new Error('[OnPropertyChange] Container model was not found among children of the main container!');
|
throw new Error('[OnPropertyChange] Container model was not found among children of the main container!');
|
||||||
|
@ -270,7 +270,7 @@ export function SortChildren(
|
||||||
*/
|
*/
|
||||||
function SetContainer(
|
function SetContainer(
|
||||||
containers: Map<string, IContainerModel>,
|
containers: Map<string, IContainerModel>,
|
||||||
container: ContainerModel,
|
container: IContainerModel,
|
||||||
key: string, value: string | number | boolean | number[],
|
key: string, value: string | number | boolean | number[],
|
||||||
type: PropertyType,
|
type: PropertyType,
|
||||||
symbols: Map<string, ISymbolModel>
|
symbols: Map<string, ISymbolModel>
|
||||||
|
@ -310,7 +310,7 @@ function SetContainer(
|
||||||
* @param value Value of the property
|
* @param value Value of the property
|
||||||
* @param type Type of the property
|
* @param type Type of the property
|
||||||
*/
|
*/
|
||||||
function AssignProperty(container: ContainerModel, key: string, value: string | number | boolean | number[], type: PropertyType): void {
|
function AssignProperty(container: IContainerModel, key: string, value: string | number | boolean | number[], type: PropertyType): void {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PropertyType.Style:
|
case PropertyType.Style:
|
||||||
(container.properties.style as any)[key] = value;
|
(container.properties.style as any)[key] = value;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ContainerModel, IContainerModel } from '../../../Interfaces/IContainerModel';
|
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
||||||
import { DIMENSION_MARGIN } from '../../../utils/default';
|
import { DIMENSION_MARGIN } from '../../../utils/default';
|
||||||
import { GetAbsolutePosition, MakeBFSIterator } from '../../../utils/itertools';
|
import { GetAbsolutePosition, MakeBFSIterator } from '../../../utils/itertools';
|
||||||
import { TransformX } from '../../../utils/svg';
|
import { TransformX } from '../../../utils/svg';
|
||||||
|
@ -7,13 +7,13 @@ import { Dimension } from './Dimension';
|
||||||
|
|
||||||
interface IDimensionLayerProps {
|
interface IDimensionLayerProps {
|
||||||
containers: Map<string, IContainerModel>
|
containers: Map<string, IContainerModel>
|
||||||
roots: ContainerModel | ContainerModel[] | null
|
roots: IContainerModel | IContainerModel[] | null
|
||||||
scale?: number
|
scale?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetDimensionsNodes(
|
function GetDimensionsNodes(
|
||||||
containers: Map<string, IContainerModel>,
|
containers: Map<string, IContainerModel>,
|
||||||
root: ContainerModel,
|
root: IContainerModel,
|
||||||
scale: number
|
scale: number
|
||||||
): React.ReactNode[] {
|
): React.ReactNode[] {
|
||||||
const it = MakeBFSIterator(root, containers);
|
const it = MakeBFSIterator(root, containers);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as React from 'react';
|
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 { ContainerModel, 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 } 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';
|
||||||
|
@ -9,7 +9,7 @@ import { Dimension } from './Dimension';
|
||||||
|
|
||||||
interface IDimensionLayerProps {
|
interface IDimensionLayerProps {
|
||||||
containers: Map<string, IContainerModel>
|
containers: Map<string, IContainerModel>
|
||||||
root: ContainerModel
|
root: IContainerModel
|
||||||
scale: number
|
scale: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ReactSVGPanZoom, Tool, TOOL_PAN, Value } from 'react-svg-pan-zoom';
|
import { ReactSVGPanZoom, Tool, TOOL_PAN, Value } from 'react-svg-pan-zoom';
|
||||||
import { Container } from './Elements/Container';
|
import { Container } from './Elements/Container';
|
||||||
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
|
import { IContainerModel } from '../../Interfaces/IContainerModel';
|
||||||
import { Selector } from './Elements/Selector/Selector';
|
import { Selector } from './Elements/Selector/Selector';
|
||||||
import { DepthDimensionLayer } from './Elements/DepthDimensionLayer';
|
import { DepthDimensionLayer } from './Elements/DepthDimensionLayer';
|
||||||
import { MAX_FRAMERATE, SHOW_DIMENSIONS_PER_DEPTH } from '../../utils/default';
|
import { MAX_FRAMERATE, SHOW_DIMENSIONS_PER_DEPTH } from '../../utils/default';
|
||||||
|
@ -16,8 +16,8 @@ interface ISVGProps {
|
||||||
width: number
|
width: number
|
||||||
height: number
|
height: number
|
||||||
containers: Map<string, IContainerModel>
|
containers: Map<string, IContainerModel>
|
||||||
children: ContainerModel
|
children: IContainerModel
|
||||||
selected?: ContainerModel
|
selected?: IContainerModel
|
||||||
symbols: Map<string, ISymbolModel>
|
symbols: Map<string, ISymbolModel>
|
||||||
selectContainer: (containerId: string) => void
|
selectContainer: (containerId: string) => void
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue