This commit is contained in:
fan 2023-07-12 16:40:31 +08:00
commit 1619eb05b6
9 changed files with 49 additions and 26 deletions

View File

@ -84,9 +84,15 @@ function onUpdate() {
const logicSectionRelations = computed(() => { const logicSectionRelations = computed(() => {
const logicSection = drawStore.selectedGraphic as LogicSection; const logicSection = drawStore.selectedGraphic as LogicSection;
const axleCountingSection = logicSection.queryStore.queryById( let arr: string[] = [];
logicSection.datas.axleSectionId if (logicSection.datas.axleSectionId) {
) as AxleCountingSection; const axleCountingSection = logicSection.queryStore.queryById(
return [axleCountingSection.datas.code]; logicSection.datas.axleSectionId
) as AxleCountingSection;
if (axleCountingSection) {
arr = [axleCountingSection.datas.code];
}
}
return arr;
}); });
</script> </script>

View File

@ -14,7 +14,7 @@ export class LogicSectionData
constructor(data?: graphicData.LogicSection) { constructor(data?: graphicData.LogicSection) {
let logicSection; let logicSection;
if (!data) { if (!data) {
logicSection = new graphicData.AxleCountingSection({ logicSection = new graphicData.LogicSection({
common: GraphicDataBase.defaultCommonInfo(LogicSection.Type), common: GraphicDataBase.defaultCommonInfo(LogicSection.Type),
}); });
} else { } else {

View File

@ -458,9 +458,9 @@ export async function loadDrawDatas(app: GraphicApp) {
storage.axleCountingSections.forEach((axleCountingSection) => { storage.axleCountingSections.forEach((axleCountingSection) => {
datas.push(new AxleCountingSectionData(axleCountingSection)); datas.push(new AxleCountingSectionData(axleCountingSection));
}); });
// storage.logicSections.forEach((logicSection) => { storage.logicSections.forEach((logicSection) => {
// datas.push(new LogicSectionData(logicSection)); datas.push(new LogicSectionData(logicSection));
// }); });
await app.loadGraphic(datas); await app.loadGraphic(datas);
} else { } else {
app.loadGraphic([]); app.loadGraphic([]);

View File

@ -15,7 +15,7 @@ import {
AxleCounting, AxleCounting,
AxleCountingTemplate, AxleCountingTemplate,
} from './AxleCounting'; } from './AxleCounting';
import { Section, SectionPort, SectionType } from '../section/Section'; import { Section, SectionPort } from '../section/Section';
import { Turnout, TurnoutPort } from '../turnout/Turnout'; import { Turnout, TurnoutPort } from '../turnout/Turnout';
import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics'; import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics';
import { Signal } from '../signal/Signal'; import { Signal } from '../signal/Signal';

View File

@ -5,6 +5,7 @@ import {
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
VectorText, VectorText,
calculateLineMidpoint,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; import { IRelatedRefData, protoPort2Data } from '../CommonGraphics';
import { SectionPort } from '../section/Section'; import { SectionPort } from '../section/Section';
@ -49,7 +50,7 @@ export class AxleCountingSection extends JlGraphic {
this.labelGraphic = new VectorText(); this.labelGraphic = new VectorText();
this.labelGraphic.setVectorFontSize(14); this.labelGraphic.setVectorFontSize(14);
this.labelGraphic.anchor.set(0.5); this.labelGraphic.anchor.set(0.5);
this.labelGraphic.style.fill = '#0f0'; this.labelGraphic.style.fill = '0xff0000';
this.labelGraphic.transformSave = true; this.labelGraphic.transformSave = true;
this.labelGraphic.name = 'label'; this.labelGraphic.name = 'label';
this.transformSave = true; this.transformSave = true;
@ -83,10 +84,11 @@ export class AxleCountingSection extends JlGraphic {
if (labelPosition) { if (labelPosition) {
this.labelGraphic.position.set(labelPosition.x, labelPosition.y); this.labelGraphic.position.set(labelPosition.x, labelPosition.y);
} else { } else {
this.labelGraphic.position.set( const centerPos = calculateLineMidpoint(
this.datas.points[0].x, this.datas.points[0],
this.datas.points[0].y + 20 this.datas.points[this.datas.points.length - 1]
); );
this.labelGraphic.position.set(centerPos.x, centerPos.y + 40);
} }
} }
get linePoints(): IPointData[] { get linePoints(): IPointData[] {

View File

@ -394,7 +394,6 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin<Axl
), ),
num num
); );
// let codeAppend = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.slice(0, num);
if ( if (
(dir === 'ltr' && (dir === 'ltr' &&
axleCountingSectionData.points[0].x > axleCountingSectionData.points[0].x >
@ -407,9 +406,8 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin<Axl
axleCountingSectionData.points.length - 1 axleCountingSectionData.points.length - 1
].x) ].x)
) { ) {
// codeAppend = codeAppend.split('').reverse().join('');
} }
points.forEach((ps, i) => { points.forEach((ps) => {
const data = new LogicSectionData(); const data = new LogicSectionData();
data.id = GraphicIdGenerator.next(); data.id = GraphicIdGenerator.next();
data.axleSectionId = axleCountingSection.id; data.axleSectionId = axleCountingSection.id;

View File

@ -71,18 +71,28 @@ export class LogicSectionDraw extends GraphicDrawAssistant<
// this.app.deleteGraphics(...logicSections); // this.app.deleteGraphics(...logicSections);
// return; // return;
logicSections.forEach((logicSection) => { logicSections.forEach((logicSection) => {
map.set(`${logicSection.datas.axleSectionId}`, 1); const ac = this.app.queryStore.queryById(
logicSection.datas.axleSectionId
) as AxleCountingSection;
if (ac) {
map.set(`${logicSection.datas.axleSectionId}`, 1);
} else {
this.app.deleteGraphics(logicSection);
}
}); });
const axleCountingSections = const axleCountingSections =
this.app.queryStore.queryByType<AxleCountingSection>( this.app.queryStore.queryByType<AxleCountingSection>(
AxleCountingSection.Type AxleCountingSection.Type
); );
axleCountingSections.forEach((axleCountingSection) => { axleCountingSections.forEach((axleCountingSection) => {
if (map.has(`${axleCountingSection.id}`)) {
return;
}
map.set(`${axleCountingSection.id}`, 1);
const turnoutPosRef = axleCountingSection.datas.turnoutPosRef; const turnoutPosRef = axleCountingSection.datas.turnoutPosRef;
if (turnoutPosRef.length > 0) { if (turnoutPosRef.length > 0) {
turnoutPosRef.forEach((turnout) => { turnoutPosRef.forEach((turnout) => {
if (turnout.position == 1 && !map.has(`${turnout.id}`)) { if (turnout.position == 1) {
map.set(`${turnout.id}`, 1);
const t = this.app.queryStore.queryById(turnout.id) as Turnout; const t = this.app.queryStore.queryById(turnout.id) as Turnout;
const data = new LogicSectionData(); const data = new LogicSectionData();
data.points = [ data.points = [
@ -94,13 +104,10 @@ export class LogicSectionDraw extends GraphicDrawAssistant<
} }
}); });
} }
if (!map.has(`${axleCountingSection.id}`)) { const data = new LogicSectionData();
map.set(`${axleCountingSection.id}`, 1); data.points = axleCountingSection.datas.points;
const data = new LogicSectionData(); data.axleSectionId = axleCountingSection.id;
data.points = axleCountingSection.datas.points; this.draw(data);
data.axleSectionId = axleCountingSection.id;
this.draw(data);
}
}); });
} }
} }

View File

@ -302,6 +302,11 @@ class SectionPolylineEditPlugin extends PolylineEditPlugin {
relation.getRelationParam(this.graphic).param === SectionPort.B relation.getRelationParam(this.graphic).param === SectionPort.B
); );
} }
relations = relations.filter(
(relation) =>
relation.getOtherGraphic(this.graphic) instanceof Turnout ||
relation.getOtherGraphic(this.graphic) instanceof Section
);
if (!relations.length) return; if (!relations.length) return;
const points: IPointData[] = []; const points: IPointData[] = [];
const otherGraphics = relations.map((relation) => const otherGraphics = relations.map((relation) =>

View File

@ -410,6 +410,11 @@ export class TurnoutEditPlugin extends GraphicEditPlugin<Turnout> {
relation.getRelationParam(this.graphic).param === TurnoutPort.C relation.getRelationParam(this.graphic).param === TurnoutPort.C
); );
} }
relations = relations.filter(
(relation) =>
relation.getOtherGraphic(this.graphic) instanceof Turnout ||
relation.getOtherGraphic(this.graphic) instanceof Section
);
if (!relations.length) return; if (!relations.length) return;
const otherGraphics = relations.map((relation) => const otherGraphics = relations.map((relation) =>
relation.getOtherGraphic(this.graphic) relation.getOtherGraphic(this.graphic)