Merge branch 'master' of https://git.code.tencent.com/jl-framework/rt-graphic-component
This commit is contained in:
commit
0567dadd3e
|
@ -1,10 +1,13 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { JlPlatform } from './JlPlatform';
|
||||
export interface IBeiJingPlatformState extends GraphicState {
|
||||
import { JlPlatform } from './common/JlPlatform';
|
||||
export interface IGPPlatformState extends GraphicState {
|
||||
id?: number;
|
||||
}
|
||||
export declare class GPPlatform extends JlPlatform {
|
||||
constructor();
|
||||
get states(): IBeiJingPlatformState;
|
||||
get states(): IGPPlatformState;
|
||||
doRepaint(): void;
|
||||
buildRelation(): void;
|
||||
saveRelations(): void;
|
||||
loadRelations(): void;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { GPConsts } from './PlatformConfig.js';
|
||||
import { JlPlatform } from './JlPlatform.js';
|
||||
import { GPConsts } from './common/PlatformConfig.js';
|
||||
import { JlPlatform } from './common/JlPlatform.js';
|
||||
|
||||
class GPPlatform extends JlPlatform {
|
||||
constructor() {
|
||||
|
@ -12,6 +12,15 @@ class GPPlatform extends JlPlatform {
|
|||
this.rectGraphic.stateFillColor = GPConsts.noTrainStop;
|
||||
super.draw();
|
||||
}
|
||||
buildRelation() {
|
||||
super.buildCommonRelation();
|
||||
}
|
||||
saveRelations() {
|
||||
super.saveCommonRelations();
|
||||
}
|
||||
loadRelations() {
|
||||
super.loadCommonRelations();
|
||||
}
|
||||
}
|
||||
|
||||
export { GPPlatform };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { JlPlatform, DoorCodeLozenge } from './JlPlatform';
|
||||
import { JlPlatform, DoorCodeLozenge } from './common/JlPlatform';
|
||||
export interface ITHPlatformState extends GraphicState {
|
||||
get emergstop(): boolean;
|
||||
set emergstop(v: boolean);
|
||||
|
@ -41,4 +41,7 @@ export declare class THPlatform extends JlPlatform {
|
|||
constructor();
|
||||
get states(): ITHPlatformState;
|
||||
doRepaint(): void;
|
||||
buildRelation(): void;
|
||||
saveRelations(): void;
|
||||
loadRelations(): void;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { THConsts } from './PlatformConfig.js';
|
||||
import { JlPlatform, DoorCodeLozenge } from './JlPlatform.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
import { THConsts } from './common/PlatformConfig.js';
|
||||
import { JlPlatform, DoorCodeLozenge } from './common/JlPlatform.js';
|
||||
import { THStation } from '../Station/THStation.js';
|
||||
|
||||
class THPlatform extends JlPlatform {
|
||||
doorCodeLozenge;
|
||||
constructor() {
|
||||
super(THConsts);
|
||||
this.doorCodeLozenge = new DoorCodeLozenge(StyleType.TH);
|
||||
this.doorCodeLozenge = new DoorCodeLozenge(THConsts);
|
||||
this.addChild(this.doorCodeLozenge);
|
||||
}
|
||||
get states() {
|
||||
|
@ -20,15 +20,15 @@ class THPlatform extends JlPlatform {
|
|||
if (this.states.upSkipstop || this.states.downSkipstop) {
|
||||
this.rectGraphic.stateFillColor = THConsts.trainJump;
|
||||
}
|
||||
/* const station = this.getGraphicApp().queryStore.queryByCodeAndType<Station>(
|
||||
this.states.rtuId > 9 ? '' + this.states.rtuId : '0' + this.states.rtuId,
|
||||
Station.Type
|
||||
); */
|
||||
const station = this.getGraphicApp().queryStore.queryByCodeAndType(this.states.rtuId > 9
|
||||
? '' + this.states.rtuId
|
||||
: '0' + this.states.rtuId, THStation.Type);
|
||||
const doorGraphic = this.doorCodeLozenge.doorGraphic;
|
||||
doorGraphic.stateFillColor = THConsts.doorGraphic.doorGreen;
|
||||
/* if (!!station?.states.ipRtuStusDown) {
|
||||
if (!!station?.states.ipRtuStusDown) {
|
||||
doorGraphic.stateFillColor = THConsts.doorGraphic.doorBlue;
|
||||
} */ if (this.states.psdCut) {
|
||||
}
|
||||
else if (this.states.psdCut) {
|
||||
doorGraphic.stateFillColor = THConsts.doorGraphic.doorRed;
|
||||
}
|
||||
super.draw();
|
||||
|
@ -94,6 +94,15 @@ class THPlatform extends JlPlatform {
|
|||
codeGraphic.stopTime.text = this.states.stopTime;
|
||||
}
|
||||
}
|
||||
buildRelation() {
|
||||
super.buildCommonRelation();
|
||||
}
|
||||
saveRelations() {
|
||||
super.saveCommonRelations();
|
||||
}
|
||||
loadRelations() {
|
||||
super.loadCommonRelations();
|
||||
}
|
||||
}
|
||||
|
||||
export { THPlatform };
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { JlGraphic, VectorText } from 'jl-graphic';
|
||||
import { Container, Graphics } from 'pixi.js';
|
||||
import { IPlatformData, PlatformConstsConfig } from './PlatformConfig';
|
||||
import { StyleType } from 'common/common';
|
||||
declare class RectGraphic extends Container {
|
||||
rect: Graphics;
|
||||
stateFillColor?: string;
|
||||
|
@ -34,12 +33,11 @@ declare class LozengeGraphic extends Container {
|
|||
clear(): void;
|
||||
}
|
||||
export declare class DoorCodeLozenge extends Container {
|
||||
private styleType;
|
||||
private platformConsts;
|
||||
doorGraphic: DoorGraphic;
|
||||
lozengeGraphic: LozengeGraphic;
|
||||
codeGraphic: CodeGraphic;
|
||||
constructor(styleType: StyleType);
|
||||
constructor(platformConsts: PlatformConstsConfig);
|
||||
draw(hasDoor: boolean, direction: string): void;
|
||||
}
|
||||
export declare abstract class JlPlatform extends JlGraphic {
|
||||
|
@ -50,5 +48,8 @@ export declare abstract class JlPlatform extends JlGraphic {
|
|||
get datas(): IPlatformData;
|
||||
get code(): string;
|
||||
draw(): void;
|
||||
buildCommonRelation(): void;
|
||||
saveCommonRelations(): void;
|
||||
loadCommonRelations(): void;
|
||||
}
|
||||
export {};
|
|
@ -1,6 +1,7 @@
|
|||
import { calculateMirrorPoint, JlGraphic, getRectangleCenter, VectorText } from 'jl-graphic';
|
||||
import { calculateMirrorPoint, JlGraphic, distance2, getRectangleCenter, VectorText } from 'jl-graphic';
|
||||
import { Container, Point, Graphics, Color, Rectangle } from 'pixi.js';
|
||||
import { platformConstsMap } from './PlatformConfig.js';
|
||||
import { JlSection } from '../../Section/common/Section.js';
|
||||
import { JlStation } from '../../Station/common/JlStation.js';
|
||||
|
||||
//子元素--矩形
|
||||
class RectGraphic extends Container {
|
||||
|
@ -157,15 +158,13 @@ class LozengeGraphic extends Container {
|
|||
}
|
||||
}
|
||||
class DoorCodeLozenge extends Container {
|
||||
styleType;
|
||||
platformConsts;
|
||||
doorGraphic;
|
||||
lozengeGraphic;
|
||||
codeGraphic;
|
||||
constructor(styleType) {
|
||||
constructor(platformConsts) {
|
||||
super();
|
||||
this.styleType = styleType;
|
||||
this.platformConsts = platformConstsMap.get(this.styleType);
|
||||
this.platformConsts = platformConsts;
|
||||
this.doorGraphic = new DoorGraphic();
|
||||
this.addChild(this.doorGraphic);
|
||||
this.lozengeGraphic = new LozengeGraphic();
|
||||
|
@ -228,6 +227,56 @@ class JlPlatform extends JlGraphic {
|
|||
draw() {
|
||||
this.rectGraphic.draw(this.platformConsts);
|
||||
}
|
||||
buildCommonRelation() {
|
||||
const stationas = this.queryStore.queryByType(JlStation.Type);
|
||||
for (let i = 0; i < stationas.length; i++) {
|
||||
const sP = stationas[i].localBoundsToCanvasPoints();
|
||||
if (this.x > sP[0].x && this.x < sP[1].x) {
|
||||
this.relationManage.addRelation(this, stationas[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const sections = this.queryStore.queryByType(JlSection.Type);
|
||||
const minDistanceRefSections = [];
|
||||
sections.forEach((section) => {
|
||||
const sP = section.localBoundsToCanvasPoints();
|
||||
if (this.x > sP[0].x && this.x < sP[1].x) {
|
||||
minDistanceRefSections.push(section);
|
||||
}
|
||||
});
|
||||
if (minDistanceRefSections) {
|
||||
const refSection = minDistanceRefSections.reduce((prev, cur) => {
|
||||
return distance2(prev.localToCanvasPoint(getRectangleCenter(prev.getLocalBounds())), this.position) >
|
||||
distance2(cur.localToCanvasPoint(getRectangleCenter(cur.getLocalBounds())), this.position)
|
||||
? cur
|
||||
: prev;
|
||||
});
|
||||
this.relationManage.deleteRelationOfGraphicAndOtherType(this, JlSection.Type);
|
||||
this.relationManage.addRelation(this, refSection);
|
||||
}
|
||||
}
|
||||
saveCommonRelations() {
|
||||
const refStation = this.relationManage
|
||||
.getRelationsOfGraphicAndOtherType(this, JlStation.Type)
|
||||
.map((relation) => relation.getOtherGraphic(this).datas.id);
|
||||
if (refStation.length) {
|
||||
this.datas.refStation = refStation[0];
|
||||
}
|
||||
const refSection = this.relationManage
|
||||
.getRelationsOfGraphicAndOtherType(this, JlSection.Type)
|
||||
.map((relation) => relation.getOtherGraphic(this).datas.id);
|
||||
if (refSection.length) {
|
||||
this.datas.refSection = refSection[0];
|
||||
}
|
||||
}
|
||||
loadCommonRelations() {
|
||||
if (this.datas.refStation) {
|
||||
this.relationManage.addRelation(this, this.queryStore.queryById(this.datas.refStation));
|
||||
}
|
||||
if (this.datas.refSection) {
|
||||
this.relationManage.addRelation(this, this.queryStore.queryById(this.datas.refSection));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { DoorCodeLozenge, JlPlatform };
|
|
@ -1,4 +1,3 @@
|
|||
import { StyleType } from 'common/common';
|
||||
import { GraphicData } from 'jl-graphic';
|
||||
export interface PlatformConstsConfig {
|
||||
width: number;
|
||||
|
@ -69,7 +68,6 @@ export declare const THConsts: {
|
|||
doorPlatformSpacing: number;
|
||||
};
|
||||
};
|
||||
export declare const platformConstsMap: Map<StyleType, PlatformConstsConfig>;
|
||||
declare enum TypeOfPlatform {
|
||||
Unknown = 0,
|
||||
up = 1,
|
|
@ -1,5 +1,3 @@
|
|||
import { StyleType } from '../../common/common.js';
|
||||
|
||||
const GPConsts = {
|
||||
width: 90,
|
||||
height: 20,
|
||||
|
@ -37,10 +35,6 @@ const THConsts = {
|
|||
doorPlatformSpacing: 10,
|
||||
},
|
||||
};
|
||||
const platformConstsMap = new Map([
|
||||
[StyleType.GP, GPConsts],
|
||||
[StyleType.TH, THConsts],
|
||||
]);
|
||||
var TypeOfPlatform;
|
||||
(function (TypeOfPlatform) {
|
||||
TypeOfPlatform[TypeOfPlatform["Unknown"] = 0] = "Unknown";
|
||||
|
@ -48,4 +42,4 @@ var TypeOfPlatform;
|
|||
TypeOfPlatform[TypeOfPlatform["down"] = 2] = "down";
|
||||
})(TypeOfPlatform || (TypeOfPlatform = {}));
|
||||
|
||||
export { GPConsts, THConsts, platformConstsMap };
|
||||
export { GPConsts, THConsts };
|
|
@ -1,6 +1,6 @@
|
|||
import { GraphicDrawAssistant, GraphicInteractionPlugin, AbsorbableLine } from 'jl-graphic';
|
||||
import { JlPlatform } from './JlPlatform.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
import { StyleType } from '../../../common/common.js';
|
||||
|
||||
class PlatformDraw extends GraphicDrawAssistant {
|
||||
platformGraphic;
|
|
@ -1,13 +1,13 @@
|
|||
import { JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlPlatform } from './JlPlatform';
|
||||
import { IPlatformData } from './PlatformConfig';
|
||||
import { ITHPlatformState } from './THPlatform';
|
||||
import { IBeiJingPlatformState } from './GPPlatform';
|
||||
import { ITHPlatformState } from '../THPlatform';
|
||||
import { IGPPlatformState } from '../GPPlatform';
|
||||
import { StyleType } from 'common/common';
|
||||
export declare class PlatformTemplate extends JlGraphicTemplate<JlPlatform> {
|
||||
hasdoor?: boolean;
|
||||
direction?: string;
|
||||
styleType: StyleType;
|
||||
constructor(dataTemplate: IPlatformData, stateTemplate: ITHPlatformState | IBeiJingPlatformState, styleType: StyleType);
|
||||
constructor(dataTemplate: IPlatformData, stateTemplate: ITHPlatformState | IGPPlatformState, styleType: StyleType);
|
||||
new(): JlPlatform;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
import { JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlPlatform } from './JlPlatform.js';
|
||||
import { THPlatform } from './THPlatform.js';
|
||||
import { GPPlatform } from './GPPlatform.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
import { THPlatform } from '../THPlatform.js';
|
||||
import { GPPlatform } from '../GPPlatform.js';
|
||||
import { StyleType } from '../../../common/common.js';
|
||||
|
||||
class PlatformTemplate extends JlGraphicTemplate {
|
||||
hasdoor;
|
|
@ -0,0 +1,5 @@
|
|||
import { JlSection as SectionBase } from './common/Section';
|
||||
export declare class Section extends SectionBase {
|
||||
constructor();
|
||||
}
|
||||
export { SectionTemplate } from './common/Section';
|
|
@ -1,12 +1,12 @@
|
|||
import { Section as Section$1 } from '../common/Section.js';
|
||||
export { SectionTemplate } from '../common/Section.js';
|
||||
import { JlSection } from './common/Section.js';
|
||||
export { SectionTemplate } from './common/Section.js';
|
||||
|
||||
const displayConfig = {
|
||||
lineColor: '#5578b6',
|
||||
occupiedColor: '#f00',
|
||||
lineWidth: 5,
|
||||
};
|
||||
class Section extends Section$1 {
|
||||
class Section extends JlSection {
|
||||
constructor() {
|
||||
super();
|
||||
this.setDisplayConfig(displayConfig);
|
|
@ -1,5 +0,0 @@
|
|||
import { Section as SectionBase } from '../common/Section';
|
||||
export declare class Section extends SectionBase {
|
||||
constructor();
|
||||
}
|
||||
export { SectionTemplate } from '../common/Section';
|
|
@ -35,7 +35,7 @@ export interface SectionDisplayConfig {
|
|||
lineWidth: number;
|
||||
}
|
||||
export declare const defaultDisplayConfig: SectionDisplayConfig;
|
||||
export declare class Section extends JlGraphic {
|
||||
export declare class JlSection extends JlGraphic {
|
||||
static Type: string;
|
||||
lineGraphic: SectionGraphic;
|
||||
labelGraphic: VectorText;
|
||||
|
@ -51,7 +51,7 @@ export declare class Section extends JlGraphic {
|
|||
get linePoints(): IPointData[];
|
||||
set linePoints(points: IPointData[]);
|
||||
getConnectElement(port: DevicePort): {
|
||||
g: Turnout | Section;
|
||||
g: Turnout | JlSection;
|
||||
port: DevicePort;
|
||||
} | undefined;
|
||||
/** 获取拆分逻辑区段数据 */
|
||||
|
@ -65,9 +65,9 @@ export declare class Section extends JlGraphic {
|
|||
saveRelations(): void;
|
||||
loadRelations(): void;
|
||||
}
|
||||
export declare class SectionTemplate extends JlGraphicTemplate<Section> {
|
||||
export declare class SectionTemplate extends JlGraphicTemplate<JlSection> {
|
||||
isCurve: boolean;
|
||||
segmentsCount: number;
|
||||
constructor(dataTemplate: ISectionData, stateTemplate?: ISectionState);
|
||||
new(): Section;
|
||||
new(): JlSection;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ const defaultDisplayConfig = {
|
|||
occupiedColor: '#f00',
|
||||
lineWidth: 5,
|
||||
};
|
||||
let Section$1 = class Section extends JlGraphic {
|
||||
class JlSection extends JlGraphic {
|
||||
static Type = 'Section';
|
||||
lineGraphic;
|
||||
labelGraphic;
|
||||
displayConfig = defaultDisplayConfig;
|
||||
constructor() {
|
||||
super(Section.Type);
|
||||
super(JlSection.Type);
|
||||
this.lineGraphic = new SectionGraphic();
|
||||
this.labelGraphic = new VectorText('');
|
||||
this.labelGraphic.setVectorFontSize(14);
|
||||
|
@ -96,7 +96,7 @@ let Section$1 = class Section extends JlGraphic {
|
|||
const relation = this.relationManage
|
||||
.getRelationsOfGraphic(this)
|
||||
.find((relation) => relation.getRelationParam(this).getParam() === port &&
|
||||
(relation.getOtherGraphic(this) instanceof Section ||
|
||||
(relation.getOtherGraphic(this) instanceof JlSection ||
|
||||
relation.getOtherGraphic(this) instanceof Turnout));
|
||||
if (!relation) {
|
||||
return;
|
||||
|
@ -146,9 +146,9 @@ let Section$1 = class Section extends JlGraphic {
|
|||
*
|
||||
*/
|
||||
buildRelation() {
|
||||
this.relationManage.deleteRelationOfGraphicAndOtherType(this, Section.Type);
|
||||
this.relationManage.deleteRelationOfGraphicAndOtherType(this, JlSection.Type);
|
||||
if (this.datas.sectionType === SectionType.Physical) {
|
||||
this.queryStore.queryByType(Section.Type).forEach((section) => {
|
||||
this.queryStore.queryByType(JlSection.Type).forEach((section) => {
|
||||
if (section.id === this.id)
|
||||
return;
|
||||
let param = [];
|
||||
|
@ -174,7 +174,7 @@ let Section$1 = class Section extends JlGraphic {
|
|||
const paRelation = this.relationManage
|
||||
.getRelationsOfGraphic(this)
|
||||
.find((relation) => relation.getRelationParam(this).param === DevicePort.A &&
|
||||
(relation.getOtherGraphic(this) instanceof Section ||
|
||||
(relation.getOtherGraphic(this) instanceof JlSection ||
|
||||
relation.getOtherGraphic(this) instanceof Turnout));
|
||||
const paDevice = paRelation?.getOtherGraphic(this);
|
||||
if (paDevice) {
|
||||
|
@ -186,7 +186,7 @@ let Section$1 = class Section extends JlGraphic {
|
|||
const pbRelation = this.relationManage
|
||||
.getRelationsOfGraphic(this)
|
||||
.find((relation) => relation.getRelationParam(this).param === DevicePort.B &&
|
||||
(relation.getOtherGraphic(this) instanceof Section ||
|
||||
(relation.getOtherGraphic(this) instanceof JlSection ||
|
||||
relation.getOtherGraphic(this) instanceof Turnout));
|
||||
const pbDevice = pbRelation?.getOtherGraphic(this);
|
||||
if (pbDevice) {
|
||||
|
@ -217,22 +217,22 @@ let Section$1 = class Section extends JlGraphic {
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
class SectionTemplate extends JlGraphicTemplate {
|
||||
isCurve = false;
|
||||
segmentsCount = 10;
|
||||
constructor(dataTemplate, stateTemplate) {
|
||||
super(Section$1.Type, {
|
||||
super(JlSection.Type, {
|
||||
dataTemplate,
|
||||
stateTemplate,
|
||||
});
|
||||
}
|
||||
new() {
|
||||
const section = new Section$1();
|
||||
const section = new JlSection();
|
||||
section.loadData(this.datas);
|
||||
section.loadState(this.states);
|
||||
return section;
|
||||
}
|
||||
}
|
||||
|
||||
export { Section$1 as Section, SectionTemplate, SectionType, defaultDisplayConfig };
|
||||
export { JlSection, SectionTemplate, SectionType, defaultDisplayConfig };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { GraphicDrawAssistant, GraphicInteractionPlugin, IDrawApp, IGraphicApp, JlGraphic, KeyListener, MenuItemOptions } from 'jl-graphic';
|
||||
import { ISectionData, SectionTemplate } from './Section';
|
||||
import { Point, Graphics, type FederatedMouseEvent, type IHitArea, type DisplayObject } from 'pixi.js';
|
||||
import { Section } from '../bjrtss/Section';
|
||||
import { Section } from '../GPSection';
|
||||
export declare class SectionDraw extends GraphicDrawAssistant<SectionTemplate, ISectionData> {
|
||||
points: Point[];
|
||||
graphic: Graphics;
|
||||
|
|
|
@ -2,7 +2,7 @@ import { ContextMenu, GraphicDrawAssistant, KeyListener, calculateMirrorPoint, c
|
|||
import { SectionType, defaultDisplayConfig } from './Section.js';
|
||||
import { Graphics, Point } from 'pixi.js';
|
||||
import { Turnout } from '../../Turnout/Turnout.js';
|
||||
import { Section } from '../bjrtss/Section.js';
|
||||
import { Section } from '../GPSection.js';
|
||||
|
||||
class SectionDraw extends GraphicDrawAssistant {
|
||||
points = [];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { JlStation } from './JlStation';
|
||||
import { JlStation } from './common/JlStation';
|
||||
export interface IGPStationState extends GraphicState {
|
||||
id: number;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { JlStation } from './JlStation.js';
|
||||
import { JlStation } from './common/JlStation.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
|
||||
class GPStation extends JlStation {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { ConstrolGraphic, JlStation } from './JlStation';
|
||||
import { ConstrolGraphic, JlStation } from './common/JlStation';
|
||||
export interface ITHStationState extends GraphicState {
|
||||
get ipRtuStusDown(): boolean;
|
||||
set ipRtuStusDown(v: boolean);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { JlStation, ConstrolGraphic } from './JlStation.js';
|
||||
import { THConsts } from './StationConfig.js';
|
||||
import { JlStation, ConstrolGraphic } from './common/JlStation.js';
|
||||
import { THConsts } from './common/StationConfig.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
|
||||
class THStation extends JlStation {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Container, Point, Graphics, Color } from 'pixi.js';
|
||||
import { VectorText, JlGraphic } from 'jl-graphic';
|
||||
import { stationConstsMap } from './StationConfig.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
import { StyleType } from '../../../common/common.js';
|
||||
|
||||
class ConstrolGraphic extends Container {
|
||||
constrolConfig;
|
|
@ -1,4 +1,4 @@
|
|||
import { StyleType } from '../../common/common.js';
|
||||
import { StyleType } from '../../../common/common.js';
|
||||
|
||||
const GPConsts = {
|
||||
codeColor: '0xF48815',
|
|
@ -1,6 +1,6 @@
|
|||
import { GraphicDrawAssistant, GraphicInteractionPlugin, AbsorbableLine } from 'jl-graphic';
|
||||
import { JlStation } from './JlStation.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
import { StyleType } from '../../../common/common.js';
|
||||
|
||||
class StationDraw extends GraphicDrawAssistant {
|
||||
codeGraph;
|
|
@ -1,8 +1,8 @@
|
|||
import { JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlStation } from './JlStation';
|
||||
import { IStationData } from './StationConfig';
|
||||
import { ITHStationState } from './THStation';
|
||||
import { IGPStationState } from './GPStation';
|
||||
import { ITHStationState } from '../THStation';
|
||||
import { IGPStationState } from '../GPStation';
|
||||
import { StyleType } from 'common/common';
|
||||
export declare class StationTemplate extends JlGraphicTemplate<JlStation> {
|
||||
hasControl?: boolean;
|
|
@ -1,8 +1,8 @@
|
|||
import { JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlStation } from './JlStation.js';
|
||||
import { THStation } from './THStation.js';
|
||||
import { GPStation } from './GPStation.js';
|
||||
import { StyleType } from '../../common/common.js';
|
||||
import { THStation } from '../THStation.js';
|
||||
import { GPStation } from '../GPStation.js';
|
||||
import { StyleType } from '../../../common/common.js';
|
||||
|
||||
class StationTemplate extends JlGraphicTemplate {
|
||||
hasControl;
|
|
@ -1,8 +1,8 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { GPConsts } from './PlatformConfig';
|
||||
import { JlPlatform } from './JlPlatform';
|
||||
import { GPConsts } from './common/PlatformConfig';
|
||||
import { JlPlatform } from './common/JlPlatform';
|
||||
|
||||
export interface IBeiJingPlatformState extends GraphicState {
|
||||
export interface IGPPlatformState extends GraphicState {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,20 @@ export class GPPlatform extends JlPlatform {
|
|||
constructor() {
|
||||
super(GPConsts);
|
||||
}
|
||||
get states(): IBeiJingPlatformState {
|
||||
return this.getStates<IBeiJingPlatformState>();
|
||||
get states(): IGPPlatformState {
|
||||
return this.getStates<IGPPlatformState>();
|
||||
}
|
||||
doRepaint(): void {
|
||||
this.rectGraphic.stateFillColor = GPConsts.noTrainStop;
|
||||
super.draw();
|
||||
}
|
||||
buildRelation() {
|
||||
super.buildCommonRelation();
|
||||
}
|
||||
saveRelations() {
|
||||
super.saveCommonRelations();
|
||||
}
|
||||
loadRelations() {
|
||||
super.loadCommonRelations();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { THConsts } from './PlatformConfig';
|
||||
import { JlPlatform, DoorCodeLozenge } from './JlPlatform';
|
||||
import { StyleType } from 'common/common';
|
||||
import { THConsts } from './common/PlatformConfig';
|
||||
import { JlPlatform, DoorCodeLozenge } from './common/JlPlatform';
|
||||
import { THStation } from '../Station/THStation';
|
||||
|
||||
export interface ITHPlatformState extends GraphicState {
|
||||
get emergstop(): boolean; //紧急关闭
|
||||
|
@ -44,7 +44,7 @@ export class THPlatform extends JlPlatform {
|
|||
doorCodeLozenge: DoorCodeLozenge;
|
||||
constructor() {
|
||||
super(THConsts);
|
||||
this.doorCodeLozenge = new DoorCodeLozenge(StyleType.TH);
|
||||
this.doorCodeLozenge = new DoorCodeLozenge(THConsts);
|
||||
this.addChild(this.doorCodeLozenge);
|
||||
}
|
||||
get states(): ITHPlatformState {
|
||||
|
@ -58,15 +58,18 @@ export class THPlatform extends JlPlatform {
|
|||
if (this.states.upSkipstop || this.states.downSkipstop) {
|
||||
this.rectGraphic.stateFillColor = THConsts.trainJump;
|
||||
}
|
||||
/* const station = this.getGraphicApp().queryStore.queryByCodeAndType<Station>(
|
||||
this.states.rtuId > 9 ? '' + this.states.rtuId : '0' + this.states.rtuId,
|
||||
Station.Type
|
||||
); */
|
||||
const station =
|
||||
this.getGraphicApp().queryStore.queryByCodeAndType<THStation>(
|
||||
this.states.rtuId > 9
|
||||
? '' + this.states.rtuId
|
||||
: '0' + this.states.rtuId,
|
||||
THStation.Type,
|
||||
);
|
||||
const doorGraphic = this.doorCodeLozenge.doorGraphic;
|
||||
doorGraphic.stateFillColor = THConsts.doorGraphic.doorGreen;
|
||||
/* if (!!station?.states.ipRtuStusDown) {
|
||||
doorGraphic.stateFillColor = THConsts.doorGraphic.doorBlue;
|
||||
} */ if (this.states.psdCut) {
|
||||
if (!!station?.states.ipRtuStusDown) {
|
||||
doorGraphic.stateFillColor = THConsts.doorGraphic.doorBlue;
|
||||
} else if (this.states.psdCut) {
|
||||
doorGraphic.stateFillColor = THConsts.doorGraphic.doorRed;
|
||||
}
|
||||
super.draw();
|
||||
|
@ -135,4 +138,13 @@ export class THPlatform extends JlPlatform {
|
|||
codeGraphic.stopTime.text = this.states.stopTime;
|
||||
}
|
||||
}
|
||||
buildRelation() {
|
||||
super.buildCommonRelation();
|
||||
}
|
||||
saveRelations() {
|
||||
super.saveCommonRelations();
|
||||
}
|
||||
loadRelations() {
|
||||
super.loadCommonRelations();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import {
|
|||
JlGraphic,
|
||||
VectorText,
|
||||
calculateMirrorPoint,
|
||||
distance2,
|
||||
getRectangleCenter,
|
||||
} from 'jl-graphic';
|
||||
import { Container, Graphics, Rectangle, Color, Point } from 'pixi.js';
|
||||
|
@ -11,9 +12,9 @@ import {
|
|||
IPlatformData,
|
||||
LozengeConstsConfig,
|
||||
PlatformConstsConfig,
|
||||
platformConstsMap,
|
||||
} from './PlatformConfig';
|
||||
import { StyleType } from 'common/common';
|
||||
import { JlSection } from '../../Section/common/Section';
|
||||
import { JlStation } from '../../Station/common/JlStation';
|
||||
|
||||
//子元素--矩形
|
||||
class RectGraphic extends Container {
|
||||
|
@ -193,17 +194,13 @@ class LozengeGraphic extends Container {
|
|||
}
|
||||
|
||||
export class DoorCodeLozenge extends Container {
|
||||
private styleType: StyleType;
|
||||
private platformConsts: PlatformConstsConfig;
|
||||
doorGraphic: DoorGraphic;
|
||||
lozengeGraphic: LozengeGraphic;
|
||||
codeGraphic: CodeGraphic;
|
||||
constructor(styleType: StyleType) {
|
||||
constructor(platformConsts: PlatformConstsConfig) {
|
||||
super();
|
||||
this.styleType = styleType;
|
||||
this.platformConsts = platformConstsMap.get(
|
||||
this.styleType,
|
||||
) as PlatformConstsConfig;
|
||||
this.platformConsts = platformConsts;
|
||||
this.doorGraphic = new DoorGraphic();
|
||||
this.addChild(this.doorGraphic);
|
||||
this.lozengeGraphic = new LozengeGraphic();
|
||||
|
@ -282,4 +279,69 @@ export abstract class JlPlatform extends JlGraphic {
|
|||
draw(): void {
|
||||
this.rectGraphic.draw(this.platformConsts);
|
||||
}
|
||||
buildCommonRelation() {
|
||||
const stationas = this.queryStore.queryByType<JlStation>(JlStation.Type);
|
||||
for (let i = 0; i < stationas.length; i++) {
|
||||
const sP = stationas[i].localBoundsToCanvasPoints();
|
||||
if (this.x > sP[0].x && this.x < sP[1].x) {
|
||||
this.relationManage.addRelation(this, stationas[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const sections = this.queryStore.queryByType<JlSection>(JlSection.Type);
|
||||
const minDistanceRefSections: JlSection[] = [];
|
||||
sections.forEach((section) => {
|
||||
const sP = section.localBoundsToCanvasPoints();
|
||||
if (this.x > sP[0].x && this.x < sP[1].x) {
|
||||
minDistanceRefSections.push(section);
|
||||
}
|
||||
});
|
||||
if (minDistanceRefSections) {
|
||||
const refSection = minDistanceRefSections.reduce((prev, cur) => {
|
||||
return distance2(
|
||||
prev.localToCanvasPoint(getRectangleCenter(prev.getLocalBounds())),
|
||||
this.position,
|
||||
) >
|
||||
distance2(
|
||||
cur.localToCanvasPoint(getRectangleCenter(cur.getLocalBounds())),
|
||||
this.position,
|
||||
)
|
||||
? cur
|
||||
: prev;
|
||||
});
|
||||
this.relationManage.deleteRelationOfGraphicAndOtherType(
|
||||
this,
|
||||
JlSection.Type,
|
||||
);
|
||||
this.relationManage.addRelation(this, refSection);
|
||||
}
|
||||
}
|
||||
saveCommonRelations() {
|
||||
const refStation = this.relationManage
|
||||
.getRelationsOfGraphicAndOtherType(this, JlStation.Type)
|
||||
.map((relation) => relation.getOtherGraphic<JlStation>(this).datas.id);
|
||||
if (refStation.length) {
|
||||
this.datas.refStation = refStation[0];
|
||||
}
|
||||
const refSection = this.relationManage
|
||||
.getRelationsOfGraphicAndOtherType(this, JlSection.Type)
|
||||
.map((relation) => relation.getOtherGraphic<JlSection>(this).datas.id);
|
||||
if (refSection.length) {
|
||||
this.datas.refSection = refSection[0];
|
||||
}
|
||||
}
|
||||
loadCommonRelations() {
|
||||
if (this.datas.refStation) {
|
||||
this.relationManage.addRelation(
|
||||
this,
|
||||
this.queryStore.queryById<JlStation>(this.datas.refStation),
|
||||
);
|
||||
}
|
||||
if (this.datas.refSection) {
|
||||
this.relationManage.addRelation(
|
||||
this,
|
||||
this.queryStore.queryById<JlSection>(this.datas.refSection),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
import { StyleType } from 'common/common';
|
||||
import { GraphicData } from 'jl-graphic';
|
||||
|
||||
export interface PlatformConstsConfig {
|
||||
|
@ -76,11 +75,6 @@ export const THConsts = {
|
|||
},
|
||||
};
|
||||
|
||||
export const platformConstsMap = new Map<StyleType, PlatformConstsConfig>([
|
||||
[StyleType.GP, GPConsts],
|
||||
[StyleType.TH, THConsts],
|
||||
]);
|
||||
|
||||
enum TypeOfPlatform {
|
||||
Unknown = 0,
|
||||
up = 1,
|
|
@ -1,8 +1,8 @@
|
|||
import { JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlPlatform } from './JlPlatform';
|
||||
import { IPlatformData } from './PlatformConfig';
|
||||
import { ITHPlatformState, THPlatform } from './THPlatform';
|
||||
import { GPPlatform, IBeiJingPlatformState } from './GPPlatform';
|
||||
import { ITHPlatformState, THPlatform } from '../THPlatform';
|
||||
import { GPPlatform, IGPPlatformState } from '../GPPlatform';
|
||||
import { StyleType } from 'common/common';
|
||||
|
||||
export class PlatformTemplate extends JlGraphicTemplate<JlPlatform> {
|
||||
|
@ -11,7 +11,7 @@ export class PlatformTemplate extends JlGraphicTemplate<JlPlatform> {
|
|||
styleType: StyleType;
|
||||
constructor(
|
||||
dataTemplate: IPlatformData,
|
||||
stateTemplate: ITHPlatformState | IBeiJingPlatformState,
|
||||
stateTemplate: ITHPlatformState | IGPPlatformState,
|
||||
styleType: StyleType,
|
||||
) {
|
||||
super(JlPlatform.Type, { dataTemplate, stateTemplate });
|
|
@ -1,7 +1,7 @@
|
|||
import {
|
||||
Section as SectionBase,
|
||||
JlSection as SectionBase,
|
||||
SectionDisplayConfig,
|
||||
} from '../common/Section';
|
||||
} from './common/Section';
|
||||
|
||||
const displayConfig: SectionDisplayConfig = {
|
||||
lineColor: '#5578b6',
|
||||
|
@ -16,4 +16,4 @@ export class Section extends SectionBase {
|
|||
}
|
||||
}
|
||||
|
||||
export { SectionTemplate } from '../common/Section';
|
||||
export { SectionTemplate } from './common/Section';
|
|
@ -59,14 +59,14 @@ export const defaultDisplayConfig: SectionDisplayConfig = {
|
|||
lineWidth: 5,
|
||||
};
|
||||
|
||||
export class Section extends JlGraphic {
|
||||
export class JlSection extends JlGraphic {
|
||||
static Type = 'Section';
|
||||
lineGraphic: SectionGraphic;
|
||||
labelGraphic: VectorText;
|
||||
displayConfig = defaultDisplayConfig;
|
||||
|
||||
constructor() {
|
||||
super(Section.Type);
|
||||
super(JlSection.Type);
|
||||
this.lineGraphic = new SectionGraphic();
|
||||
this.labelGraphic = new VectorText('');
|
||||
this.labelGraphic.setVectorFontSize(14);
|
||||
|
@ -150,14 +150,14 @@ export class Section extends JlGraphic {
|
|||
.find(
|
||||
(relation) =>
|
||||
relation.getRelationParam(this).getParam<DevicePort>() === port &&
|
||||
(relation.getOtherGraphic(this) instanceof Section ||
|
||||
(relation.getOtherGraphic(this) instanceof JlSection ||
|
||||
relation.getOtherGraphic(this) instanceof Turnout),
|
||||
);
|
||||
if (!relation) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
g: relation?.getOtherGraphic(this) as Section | Turnout,
|
||||
g: relation?.getOtherGraphic(this) as JlSection | Turnout,
|
||||
port: relation?.getOtherRelationParam(this).getParam<DevicePort>(),
|
||||
};
|
||||
}
|
||||
|
@ -217,10 +217,10 @@ export class Section extends JlGraphic {
|
|||
*/
|
||||
|
||||
buildRelation() {
|
||||
this.relationManage.deleteRelationOfGraphicAndOtherType(this, Section.Type);
|
||||
this.relationManage.deleteRelationOfGraphicAndOtherType(this, JlSection.Type);
|
||||
|
||||
if (this.datas.sectionType === SectionType.Physical) {
|
||||
this.queryStore.queryByType<Section>(Section.Type).forEach((section) => {
|
||||
this.queryStore.queryByType<JlSection>(JlSection.Type).forEach((section) => {
|
||||
if (section.id === this.id) return;
|
||||
|
||||
let param: DevicePort[] = [];
|
||||
|
@ -272,10 +272,10 @@ export class Section extends JlGraphic {
|
|||
.find(
|
||||
(relation) =>
|
||||
relation.getRelationParam(this).param === DevicePort.A &&
|
||||
(relation.getOtherGraphic(this) instanceof Section ||
|
||||
(relation.getOtherGraphic(this) instanceof JlSection ||
|
||||
relation.getOtherGraphic(this) instanceof Turnout),
|
||||
);
|
||||
const paDevice = paRelation?.getOtherGraphic<Section | Turnout>(this);
|
||||
const paDevice = paRelation?.getOtherGraphic<JlSection | Turnout>(this);
|
||||
if (paDevice) {
|
||||
this.datas.paRef = IRelatedRef.create(
|
||||
paDevice.type,
|
||||
|
@ -290,10 +290,10 @@ export class Section extends JlGraphic {
|
|||
.find(
|
||||
(relation) =>
|
||||
relation.getRelationParam(this).param === DevicePort.B &&
|
||||
(relation.getOtherGraphic(this) instanceof Section ||
|
||||
(relation.getOtherGraphic(this) instanceof JlSection ||
|
||||
relation.getOtherGraphic(this) instanceof Turnout),
|
||||
);
|
||||
const pbDevice = pbRelation?.getOtherGraphic<Section | Turnout>(this);
|
||||
const pbDevice = pbRelation?.getOtherGraphic<JlSection | Turnout>(this);
|
||||
if (pbDevice) {
|
||||
this.datas.pbRef = IRelatedRef.create(
|
||||
pbDevice.type,
|
||||
|
@ -330,7 +330,7 @@ export class Section extends JlGraphic {
|
|||
if (this.datas.trackSectionId) {
|
||||
this.relationManage.addRelation(
|
||||
this,
|
||||
this.queryStore.queryById<Section>(this.datas.trackSectionId),
|
||||
this.queryStore.queryById<JlSection>(this.datas.trackSectionId),
|
||||
);
|
||||
}
|
||||
if (this.datas.sectionType === SectionType.TurnoutPhysical) {
|
||||
|
@ -346,17 +346,17 @@ export class Section extends JlGraphic {
|
|||
}
|
||||
}
|
||||
|
||||
export class SectionTemplate extends JlGraphicTemplate<Section> {
|
||||
export class SectionTemplate extends JlGraphicTemplate<JlSection> {
|
||||
isCurve = false;
|
||||
segmentsCount = 10;
|
||||
constructor(dataTemplate: ISectionData, stateTemplate?: ISectionState) {
|
||||
super(Section.Type, {
|
||||
super(JlSection.Type, {
|
||||
dataTemplate,
|
||||
stateTemplate,
|
||||
});
|
||||
}
|
||||
new(): Section {
|
||||
const section = new Section();
|
||||
new(): JlSection {
|
||||
const section = new JlSection();
|
||||
section.loadData(this.datas);
|
||||
section.loadState(this.states);
|
||||
return section;
|
||||
|
|
|
@ -46,7 +46,7 @@ import {
|
|||
import { Turnout } from 'src/packages/Turnout/Turnout';
|
||||
import { AxleCounting } from 'src/packages/AxleCounting/AxleCounting';
|
||||
import { DevicePort } from 'common/common';
|
||||
import { Section } from '../bjrtss/Section';
|
||||
import { Section } from '../GPSection';
|
||||
|
||||
export class SectionDraw extends GraphicDrawAssistant<
|
||||
SectionTemplate,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { JlStation } from './JlStation';
|
||||
import { JlStation } from './common/JlStation';
|
||||
import { StyleType } from 'common/common';
|
||||
|
||||
export interface IGPStationState extends GraphicState {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GraphicState } from 'jl-graphic';
|
||||
import { ConstrolGraphic, JlStation } from './JlStation';
|
||||
import { THConsts } from './StationConfig';
|
||||
import { ConstrolGraphic, JlStation } from './common/JlStation';
|
||||
import { THConsts } from './common/StationConfig';
|
||||
import { StyleType } from 'common/common';
|
||||
|
||||
export interface ITHStationState extends GraphicState {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlStation } from './JlStation';
|
||||
import { IStationData } from './StationConfig';
|
||||
import { THStation, ITHStationState } from './THStation';
|
||||
import { GPStation, IGPStationState } from './GPStation';
|
||||
import { THStation, ITHStationState } from '../THStation';
|
||||
import { GPStation, IGPStationState } from '../GPStation';
|
||||
import { StyleType } from 'common/common';
|
||||
|
||||
export class StationTemplate extends JlGraphicTemplate<JlStation> {
|
Loading…
Reference in New Issue