Merge branch 'master' of https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-client
This commit is contained in:
commit
632371b64c
@ -39,11 +39,11 @@ import { SectionData } from 'src/drawApp/graphics/SectionInteraction';
|
||||
import { Section } from 'src/graphics/section/Section';
|
||||
import { Turnout } from 'src/graphics/turnout/Turnout';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { computed, shallowReactive, watchEffect } from 'vue';
|
||||
import { computed, shallowRef, watchEffect } from 'vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
|
||||
const sectionModel = shallowReactive(new SectionData());
|
||||
const sectionModel = shallowRef(new SectionData());
|
||||
|
||||
const sectionRelations = computed(() => {
|
||||
const section = drawStore.selectedGraphic as Section;
|
||||
@ -80,14 +80,14 @@ const turnoutRelations = computed(() => {
|
||||
watchEffect(() => {
|
||||
const section = drawStore.selectedGraphic;
|
||||
if (section && section instanceof Section) {
|
||||
sectionModel.copyFrom(section.saveData());
|
||||
sectionModel.value = section.saveData();
|
||||
}
|
||||
});
|
||||
|
||||
const onUpdate = () => {
|
||||
const section = drawStore.selectedGraphic as Section;
|
||||
if (section) {
|
||||
drawStore.getDrawApp().updateGraphicAndRecord(section, sectionModel);
|
||||
drawStore.getDrawApp().updateGraphicAndRecord(section, sectionModel.value);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -39,11 +39,11 @@ import { TurnoutData } from 'src/drawApp/graphics/TurnoutInteraction';
|
||||
import { Section } from 'src/graphics/section/Section';
|
||||
import { Turnout } from 'src/graphics/turnout/Turnout';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { computed, shallowReactive, watchEffect } from 'vue';
|
||||
import { computed, shallowRef, watchEffect } from 'vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
|
||||
const turnoutModel = shallowReactive(new TurnoutData());
|
||||
const turnoutModel = shallowRef(new TurnoutData());
|
||||
|
||||
const sectionRelations = computed(() => {
|
||||
const turnout = drawStore.selectedGraphic as Turnout;
|
||||
@ -80,14 +80,14 @@ const turnoutRelations = computed(() => {
|
||||
watchEffect(() => {
|
||||
const turnout = drawStore.selectedGraphic;
|
||||
if (turnout && turnout instanceof Turnout) {
|
||||
turnoutModel.copyFrom(turnout.saveData());
|
||||
turnoutModel.value = turnout.saveData();
|
||||
}
|
||||
});
|
||||
|
||||
const onUpdate = () => {
|
||||
const turnout = drawStore.selectedGraphic as Turnout;
|
||||
if (turnout) {
|
||||
drawStore.getDrawApp().updateGraphicAndRecord(turnout, turnoutModel);
|
||||
drawStore.getDrawApp().updateGraphicAndRecord(turnout, turnoutModel.value);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { Color, Container, Graphics } from 'pixi.js';
|
||||
import { Color, Container, Graphics, Point } from 'pixi.js';
|
||||
import {
|
||||
GraphicData,
|
||||
GraphicRelationParam,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
VectorText,
|
||||
distance2,
|
||||
} from 'src/jl-graphic';
|
||||
import { Section, SectionPort } from '../section/Section';
|
||||
import {
|
||||
@ -96,17 +97,15 @@ export class AxleCounting extends JlGraphic {
|
||||
this.queryStore.queryByType<Section>(Section.Type).forEach((section) => {
|
||||
const ps = section.localToCanvasPoint(section.getStartPoint());
|
||||
const pe = section.localToCanvasPoint(section.getEndPoint());
|
||||
const AxleCountingPs = new Point(
|
||||
this.x,
|
||||
this.y + AxleCountingConsts.offsetSection * this.direction
|
||||
);
|
||||
let param = '';
|
||||
if (
|
||||
ps.x == this.x &&
|
||||
ps.y == this.y + AxleCountingConsts.offsetSection * this.direction
|
||||
) {
|
||||
if (distance2(AxleCountingPs, ps) < 20) {
|
||||
param = SectionPort.A;
|
||||
}
|
||||
if (
|
||||
pe.x == this.x &&
|
||||
pe.y == this.y + AxleCountingConsts.offsetSection * this.direction
|
||||
) {
|
||||
if (distance2(AxleCountingPs, pe) < 20) {
|
||||
param = SectionPort.B;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { FederatedPointerEvent, IPointData, Point } from 'pixi.js';
|
||||
import { FederatedPointerEvent, IPoint, IPointData, Point } from 'pixi.js';
|
||||
import {
|
||||
AbsorbableLine,
|
||||
AbsorbablePosition,
|
||||
@ -7,6 +7,7 @@ import {
|
||||
GraphicInteractionPlugin,
|
||||
JlDrawApp,
|
||||
JlGraphic,
|
||||
distance2,
|
||||
} from 'src/jl-graphic';
|
||||
|
||||
import {
|
||||
@ -55,7 +56,18 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
|
||||
data.transform = this.container.saveTransform();
|
||||
return true;
|
||||
}
|
||||
draw(ps: IPoint, direction: number) {
|
||||
const axleCounting = new AxleCounting(direction);
|
||||
axleCounting.loadData(this.graphicTemplate.datas);
|
||||
axleCounting.position.set(
|
||||
ps.x,
|
||||
ps.y - AxleCountingConsts.offsetSection * direction
|
||||
);
|
||||
axleCounting.id = GraphicIdGenerator.next();
|
||||
this.storeGraphic(axleCounting);
|
||||
}
|
||||
oneGenerates(height: Point) {
|
||||
//由区段生成计轴
|
||||
const sections = this.app.queryStore
|
||||
.queryByType<Section>(Section.Type)
|
||||
.filter((section) => {
|
||||
@ -66,22 +78,19 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
|
||||
).length == 0
|
||||
);
|
||||
});
|
||||
const turnouts = this.app.queryStore.queryByType<Turnout>(Turnout.Type);
|
||||
sections.forEach((section) => {
|
||||
const ps = section.localToCanvasPoint(section.getStartPoint());
|
||||
const pe = section.localToCanvasPoint(section.getEndPoint());
|
||||
let direction = 1;
|
||||
if (ps.y > height.y) {
|
||||
direction = -1;
|
||||
}
|
||||
const axleCounting = new AxleCounting(direction);
|
||||
axleCounting.loadData(this.graphicTemplate.datas);
|
||||
axleCounting.position.set(
|
||||
ps.x,
|
||||
ps.y - AxleCountingConsts.offsetSection * direction
|
||||
);
|
||||
axleCounting.id = GraphicIdGenerator.next();
|
||||
this.storeGraphic(axleCounting);
|
||||
this.draw(ps, direction);
|
||||
this.draw(pe, direction);
|
||||
});
|
||||
|
||||
//由道岔生成计轴
|
||||
/* const turnouts = this.app.queryStore.queryByType<Turnout>(Turnout.Type);
|
||||
turnouts.forEach((turnout) => {
|
||||
const points = turnout.datas.pointA;
|
||||
const transPos = turnout.datas.transform.position;
|
||||
@ -94,6 +103,20 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
|
||||
axleCounting.position.set(ps[0].x, ps[0].y);
|
||||
axleCounting.id = GraphicIdGenerator.next();
|
||||
this.storeGraphic(axleCounting);
|
||||
}); */
|
||||
|
||||
//删除重叠
|
||||
const axleCountings = this.app.queryStore.queryByType<AxleCounting>(
|
||||
AxleCounting.Type
|
||||
);
|
||||
axleCountings.forEach((axleCounting) => {
|
||||
for (let i = 0; i < axleCountings.length; i++) {
|
||||
if (axleCounting.id == axleCountings[i].id) break;
|
||||
const d1 = distance2(axleCounting, axleCountings[i]);
|
||||
if (d1 < 20) {
|
||||
this.app.deleteGraphics(axleCounting);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user