添加逻辑区段
This commit is contained in:
parent
338d7132b3
commit
5573f7ea42
63
src/drawApp/graphics/LogicSectionInteraction.ts
Normal file
63
src/drawApp/graphics/LogicSectionInteraction.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import * as pb_1 from 'google-protobuf';
|
||||
import { GraphicDataBase } from './GraphicDataBase';
|
||||
import {
|
||||
ILogicSectionData,
|
||||
LogicSection,
|
||||
} from 'src/graphics/logicSection/LogicSection';
|
||||
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||
import { IPointData } from 'pixi.js';
|
||||
|
||||
export class LogicSectionData
|
||||
extends GraphicDataBase
|
||||
implements ILogicSectionData
|
||||
{
|
||||
constructor(data?: graphicData.AxleCountingSection) {
|
||||
let logicSection;
|
||||
if (!data) {
|
||||
logicSection = new graphicData.AxleCountingSection({
|
||||
common: GraphicDataBase.defaultCommonInfo(LogicSection.Type),
|
||||
});
|
||||
} else {
|
||||
logicSection = data;
|
||||
}
|
||||
super(logicSection);
|
||||
}
|
||||
public get data(): graphicData.AxleCountingSection {
|
||||
return this.getData<graphicData.AxleCountingSection>();
|
||||
}
|
||||
get code(): string {
|
||||
return this.data.code;
|
||||
}
|
||||
set code(v: string) {
|
||||
this.data.code = v;
|
||||
}
|
||||
get points(): IPointData[] {
|
||||
return this.data.points;
|
||||
}
|
||||
set points(points: IPointData[]) {
|
||||
this.data.points = points.map(
|
||||
(p) => new graphicData.Point({ x: p.x, y: p.y })
|
||||
);
|
||||
}
|
||||
get paRef(): graphicData.RelatedRef {
|
||||
return this.data.paRef;
|
||||
}
|
||||
set paRef(ref: graphicData.RelatedRef) {
|
||||
this.data.paRef = ref;
|
||||
}
|
||||
get pbRef(): graphicData.RelatedRef {
|
||||
return this.data.pbRef;
|
||||
}
|
||||
set pbRef(ref: graphicData.RelatedRef) {
|
||||
this.data.pbRef = ref;
|
||||
}
|
||||
clone(): LogicSectionData {
|
||||
return new LogicSectionData(this.data.cloneMessage());
|
||||
}
|
||||
copyFrom(data: LogicSectionData): void {
|
||||
pb_1.Message.copyInto(data.data, this.data);
|
||||
}
|
||||
eq(other: LogicSectionData): boolean {
|
||||
return pb_1.Message.equals(this.data, other.data);
|
||||
}
|
||||
}
|
@ -71,6 +71,12 @@ import {
|
||||
} from 'src/graphics/sectionLink/SectionLink';
|
||||
import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssistant';
|
||||
import { SectionLinkData } from './graphics/SectionLinkInteraction';
|
||||
import { LogicSectionDraw } from 'src/graphics/logicSection/LogicSectionDrawAssistant';
|
||||
import {
|
||||
LogicSection,
|
||||
LogicSectionTemplate,
|
||||
} from 'src/graphics/logicSection/LogicSection';
|
||||
import { LogicSectionData } from './graphics/LogicSectionInteraction';
|
||||
|
||||
// export function fromStoragePoint(p: graphicData.Point): Point {
|
||||
// return new Point(p.x, p.y);
|
||||
@ -111,13 +117,16 @@ const RedoOptions: MenuItemOptions = {
|
||||
const SelectAllOptions: MenuItemOptions = {
|
||||
name: '全选',
|
||||
};
|
||||
const AllOptions: MenuItemOptions = {
|
||||
name: '全部图层',
|
||||
};
|
||||
const linkOptions: MenuItemOptions = {
|
||||
name: '图层-Link',
|
||||
};
|
||||
const axleCountingSectionOptions: MenuItemOptions = {
|
||||
name: '图层-计轴区段',
|
||||
};
|
||||
const threeLayerOptions: MenuItemOptions = {
|
||||
const LogicSectionOptions: MenuItemOptions = {
|
||||
name: '图层-逻辑区段',
|
||||
};
|
||||
|
||||
@ -126,7 +135,12 @@ const layerOptions: MenuItemOptions = {
|
||||
subMenu: [
|
||||
{
|
||||
name: '图层菜单',
|
||||
items: [linkOptions, axleCountingSectionOptions, threeLayerOptions],
|
||||
items: [
|
||||
AllOptions,
|
||||
linkOptions,
|
||||
axleCountingSectionOptions,
|
||||
LogicSectionOptions,
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -178,6 +192,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
| SeparatorDraw
|
||||
| SectionLinkDraw
|
||||
| AxleCountingSectionDraw
|
||||
| LogicSectionDraw
|
||||
)[] = [];
|
||||
if (draftType === 'Line') {
|
||||
drawAssistants = [
|
||||
@ -211,6 +226,10 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
app,
|
||||
new AxleCountingSectionTemplate(new AxleCountingSectionData())
|
||||
),
|
||||
new LogicSectionDraw(
|
||||
app,
|
||||
new LogicSectionTemplate(new LogicSectionData())
|
||||
),
|
||||
];
|
||||
DrawSignalInteraction.init(app);
|
||||
}
|
||||
@ -225,6 +244,9 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
RedoOptions.disabled = !app.opRecord.hasRedo;
|
||||
const axleCountingSections =
|
||||
app.queryStore.queryByType<AxleCountingSection>(AxleCountingSection.Type);
|
||||
const logicSections = app.queryStore.queryByType<LogicSection>(
|
||||
LogicSection.Type
|
||||
);
|
||||
const sections = app.queryStore.queryByType<Section>(Section.Type);
|
||||
const sectionLinks = app.queryStore.queryByType<SectionLink>(
|
||||
SectionLink.Type
|
||||
@ -235,6 +257,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
...turnouts,
|
||||
...sectionLinks,
|
||||
...axleCountingSections,
|
||||
...logicSections,
|
||||
];
|
||||
UndoOptions.handler = () => {
|
||||
app.opRecord.undo();
|
||||
@ -245,6 +268,11 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
SelectAllOptions.handler = () => {
|
||||
app.selectAllGraphics();
|
||||
};
|
||||
AllOptions.handler = () => {
|
||||
disvisibleGraphics.forEach((g) => {
|
||||
g.visible = true;
|
||||
});
|
||||
};
|
||||
linkOptions.handler = () => {
|
||||
disvisibleGraphics.forEach((g) => {
|
||||
g.visible = false;
|
||||
@ -261,8 +289,13 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
axleCountingSection.visible = true;
|
||||
});
|
||||
};
|
||||
threeLayerOptions.handler = () => {
|
||||
console.log(2222);
|
||||
LogicSectionOptions.handler = () => {
|
||||
disvisibleGraphics.forEach((g) => {
|
||||
g.visible = false;
|
||||
});
|
||||
logicSections.forEach((logicSection) => {
|
||||
logicSection.visible = true;
|
||||
});
|
||||
};
|
||||
DefaultCanvasMenu.open(e.global);
|
||||
});
|
||||
@ -346,6 +379,9 @@ export function saveDrawDatas(app: JlDrawApp) {
|
||||
storage.axleCountingSections.push(
|
||||
(axleCountingSectionData as AxleCountingSectionData).data
|
||||
);
|
||||
} else if (LogicSection.Type === g.type) {
|
||||
const logicSectionData = (g as LogicSection).saveData();
|
||||
storage.logicSections.push((logicSectionData as LogicSectionData).data);
|
||||
}
|
||||
});
|
||||
const base64 = fromUint8Array(storage.serialize());
|
||||
@ -410,6 +446,9 @@ export async function loadDrawDatas(app: GraphicApp) {
|
||||
storage.axleCountingSections.forEach((axleCountingSection) => {
|
||||
datas.push(new AxleCountingSectionData(axleCountingSection));
|
||||
});
|
||||
storage.logicSections.forEach((logicSection) => {
|
||||
datas.push(new LogicSectionData(logicSection));
|
||||
});
|
||||
await app.loadGraphic(datas);
|
||||
} else {
|
||||
app.loadGraphic([]);
|
||||
@ -427,4 +466,10 @@ export async function loadDrawDatas(app: GraphicApp) {
|
||||
sectionLinks.forEach((sectionLink) => {
|
||||
sectionLink.visible = false;
|
||||
});
|
||||
const logicSections = app.queryStore.queryByType<LogicSection>(
|
||||
LogicSection.Type
|
||||
);
|
||||
logicSections.forEach((logicSection) => {
|
||||
logicSection.visible = false;
|
||||
});
|
||||
}
|
||||
|
122
src/graphics/logicSection/LogicSection.ts
Normal file
122
src/graphics/logicSection/LogicSection.ts
Normal file
@ -0,0 +1,122 @@
|
||||
import { Graphics, IPointData } from 'pixi.js';
|
||||
import {
|
||||
GraphicData,
|
||||
GraphicRelationParam,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
VectorText,
|
||||
} from 'src/jl-graphic';
|
||||
import { IRelatedRefData, protoPort2Data } from '../CommonGraphics';
|
||||
import { SectionPort } from '../section/Section';
|
||||
|
||||
export interface ILogicSectionData extends GraphicData {
|
||||
get code(): string; // 编号
|
||||
set code(v: string);
|
||||
get points(): IPointData[]; // 线坐标点
|
||||
set points(points: IPointData[]);
|
||||
get paRef(): IRelatedRefData | undefined;
|
||||
set paRef(ref: IRelatedRefData | undefined);
|
||||
get pbRef(): IRelatedRefData | undefined;
|
||||
set pbRef(ref: IRelatedRefData | undefined);
|
||||
clone(): ILogicSectionData;
|
||||
copyFrom(data: ILogicSectionData): void;
|
||||
eq(other: ILogicSectionData): boolean;
|
||||
}
|
||||
|
||||
export const LogicSectionConsts = {
|
||||
lineColor: '0xff0000',
|
||||
lineWidth: 2,
|
||||
};
|
||||
|
||||
export class LogicSection extends JlGraphic {
|
||||
static Type = 'LogicSection';
|
||||
lineGraphic: Graphics;
|
||||
labelGraphic: VectorText;
|
||||
constructor() {
|
||||
super(LogicSection.Type);
|
||||
this.lineGraphic = new Graphics();
|
||||
this.labelGraphic = new VectorText();
|
||||
this.labelGraphic.setVectorFontSize(14);
|
||||
this.labelGraphic.anchor.set(0.5);
|
||||
this.labelGraphic.style.fill = '#0f0';
|
||||
this.labelGraphic.transformSave = true;
|
||||
this.labelGraphic.name = 'label';
|
||||
this.transformSave = true;
|
||||
this.addChild(this.lineGraphic);
|
||||
this.addChild(this.labelGraphic);
|
||||
}
|
||||
|
||||
get datas(): ILogicSectionData {
|
||||
return this.getDatas<ILogicSectionData>();
|
||||
}
|
||||
doRepaint(): void {
|
||||
if (this.datas.points.length < 2) {
|
||||
throw new Error('LogicSection坐标数据异常');
|
||||
}
|
||||
this.lineGraphic.clear();
|
||||
this.lineGraphic.lineStyle(
|
||||
LogicSectionConsts.lineWidth,
|
||||
LogicSectionConsts.lineColor
|
||||
);
|
||||
this.datas.points.forEach((p, i) => {
|
||||
if (i !== 0) {
|
||||
this.lineGraphic.lineTo(p.x, p.y);
|
||||
} else {
|
||||
this.lineGraphic.moveTo(p.x, p.y);
|
||||
}
|
||||
});
|
||||
this.labelGraphic.text = this.datas.code;
|
||||
const labelPosition = this.datas.childTransforms?.find(
|
||||
(t) => t.name === this.labelGraphic.name
|
||||
)?.transform.position;
|
||||
if (labelPosition) {
|
||||
this.labelGraphic.position.set(labelPosition.x, labelPosition.y);
|
||||
} else {
|
||||
this.labelGraphic.position.set(
|
||||
this.datas.points[0].x,
|
||||
this.datas.points[0].y + 20
|
||||
);
|
||||
}
|
||||
}
|
||||
get linePoints(): IPointData[] {
|
||||
return this.datas.points;
|
||||
}
|
||||
set linePoints(points: IPointData[]) {
|
||||
const old = this.datas.clone();
|
||||
old.points = points;
|
||||
this.updateData(old);
|
||||
}
|
||||
loadRelations() {
|
||||
if (this.datas?.paRef?.id) {
|
||||
this.relationManage.addRelation(
|
||||
new GraphicRelationParam(this, SectionPort.A),
|
||||
new GraphicRelationParam(
|
||||
this.queryStore.queryById(this.datas.paRef.id),
|
||||
protoPort2Data(this.datas.paRef.devicePort)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (this.datas?.pbRef?.id) {
|
||||
this.relationManage.addRelation(
|
||||
new GraphicRelationParam(this, SectionPort.B),
|
||||
new GraphicRelationParam(
|
||||
this.queryStore.queryById(this.datas.pbRef.id),
|
||||
protoPort2Data(this.datas.pbRef.devicePort)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class LogicSectionTemplate extends JlGraphicTemplate<LogicSection> {
|
||||
constructor(dataTemplate: ILogicSectionData) {
|
||||
super(LogicSection.Type, {
|
||||
dataTemplate,
|
||||
});
|
||||
}
|
||||
new(): LogicSection {
|
||||
const logicSection = new LogicSection();
|
||||
logicSection.loadData(this.datas);
|
||||
return logicSection;
|
||||
}
|
||||
}
|
273
src/graphics/logicSection/LogicSectionDrawAssistant.ts
Normal file
273
src/graphics/logicSection/LogicSectionDrawAssistant.ts
Normal file
@ -0,0 +1,273 @@
|
||||
import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js';
|
||||
import {
|
||||
AbsorbableLine,
|
||||
AbsorbablePosition,
|
||||
GraphicDrawAssistant,
|
||||
GraphicIdGenerator,
|
||||
GraphicInteractionPlugin,
|
||||
JlDrawApp,
|
||||
JlGraphic,
|
||||
linePoint,
|
||||
} from 'src/jl-graphic';
|
||||
|
||||
import {
|
||||
ILogicSectionData,
|
||||
LogicSection,
|
||||
LogicSectionTemplate,
|
||||
LogicSectionConsts,
|
||||
} from './LogicSection';
|
||||
import { AxleCounting } from '../axleCounting/AxleCounting';
|
||||
import { Turnout } from '../turnout/Turnout';
|
||||
import { createRelatedRefProto } from '../CommonGraphics';
|
||||
|
||||
function hasCommonElements(arr1: string[], arr2: string[]) {
|
||||
for (let i = 0; i < arr1.length; i++) {
|
||||
if (arr2.includes(arr1[i])) {
|
||||
return arr1[i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasSamePosition(point1: IPointData, point2: IPointData): boolean {
|
||||
if (
|
||||
Math.abs(point1.x - point2.x) < 20 &&
|
||||
Math.abs(point1.y - point2.y) < 20
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export interface ILogicSectionDrawOptions {
|
||||
newData: () => ILogicSectionData;
|
||||
}
|
||||
|
||||
export class LogicSectionDraw extends GraphicDrawAssistant<
|
||||
LogicSectionTemplate,
|
||||
ILogicSectionData
|
||||
> {
|
||||
codeGraph: LogicSection;
|
||||
constructor(app: JlDrawApp, template: LogicSectionTemplate) {
|
||||
super(app, template, 'sym_o_circle', '不展示');
|
||||
this.codeGraph = this.graphicTemplate.new();
|
||||
this.container.addChild(this.codeGraph);
|
||||
LogicSectionInteraction.init(app);
|
||||
}
|
||||
|
||||
bind(): void {
|
||||
super.bind();
|
||||
this.codeGraph.loadData(this.graphicTemplate.datas);
|
||||
this.codeGraph.doRepaint();
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
//this.codeGraph.destroy();
|
||||
}
|
||||
onLeftDown(e: FederatedPointerEvent): void {
|
||||
this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||
this.createAndStore(true);
|
||||
}
|
||||
|
||||
redraw(p: Point): void {
|
||||
this.container.position.copyFrom(p);
|
||||
}
|
||||
prepareData(data: ILogicSectionData): boolean {
|
||||
data.transform = this.container.saveTransform();
|
||||
return true;
|
||||
}
|
||||
draw(graphics: JlGraphic[], map: Map<string, number>) {
|
||||
if (
|
||||
map.has(`${graphics[0].id}+${graphics[1].id}`) ||
|
||||
map.has(`${graphics[1].id}+${graphics[0].id}`)
|
||||
)
|
||||
return;
|
||||
const logicSection = new LogicSection();
|
||||
logicSection.loadData(this.graphicTemplate.datas);
|
||||
logicSection.datas.points = [graphics[0].position, graphics[1].position];
|
||||
logicSection.id = GraphicIdGenerator.next();
|
||||
const paRef = createRelatedRefProto(graphics[0].type, graphics[0].id);
|
||||
const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id);
|
||||
logicSection.datas.paRef = paRef;
|
||||
logicSection.datas.pbRef = pbRef;
|
||||
this.storeGraphic(logicSection);
|
||||
logicSection.loadRelations();
|
||||
}
|
||||
|
||||
oneGenerates() {
|
||||
const map = new Map();
|
||||
const logicSections = this.app.queryStore.queryByType<LogicSection>(
|
||||
LogicSection.Type
|
||||
);
|
||||
logicSections.forEach((logicSection) => {
|
||||
map.set(
|
||||
`${logicSection.datas.paRef?.id}+${logicSection.datas.pbRef?.id}`,
|
||||
1
|
||||
);
|
||||
});
|
||||
const axleCountings = this.app.queryStore.queryByType<AxleCounting>(
|
||||
AxleCounting.Type
|
||||
);
|
||||
const hasfourTurnout: AxleCounting[][] = [];
|
||||
axleCountings.forEach((axleCounting) => {
|
||||
const refDeviceTarget = axleCounting.datas.axleCountingRef.map(
|
||||
(ref) => ref.id
|
||||
);
|
||||
for (let i = 0; i < axleCountings.length - 1; i++) {
|
||||
if (axleCountings[i].id == axleCounting.id) return;
|
||||
const refDevice = axleCountings[i].datas.axleCountingRef.map(
|
||||
(ref) => ref.id
|
||||
);
|
||||
const commonElementId = hasCommonElements(refDeviceTarget, refDevice);
|
||||
if (commonElementId) {
|
||||
const commonElement = this.app.queryStore.queryById(commonElementId);
|
||||
let draw = true;
|
||||
if (commonElement.type == 'Turnout') {
|
||||
let targetPort, port;
|
||||
axleCounting.datas.axleCountingRef.forEach((ref) => {
|
||||
if (ref.id == commonElementId) {
|
||||
targetPort = ref.devicePort;
|
||||
}
|
||||
});
|
||||
axleCountings[i].datas.axleCountingRef.forEach((ref) => {
|
||||
if (ref.id == commonElementId) {
|
||||
port = ref.devicePort;
|
||||
}
|
||||
});
|
||||
if (
|
||||
(targetPort == 1 && port == 2) ||
|
||||
(targetPort == 2 && port == 1)
|
||||
) {
|
||||
draw = false;
|
||||
}
|
||||
}
|
||||
if (draw) {
|
||||
this.draw([axleCounting, axleCountings[i]], map);
|
||||
}
|
||||
}
|
||||
if (hasSamePosition(axleCounting, axleCountings[i])) {
|
||||
hasfourTurnout.push([axleCounting, axleCountings[i]]);
|
||||
}
|
||||
}
|
||||
});
|
||||
const fourAxleCounting: AxleCounting[] = [];
|
||||
hasfourTurnout.forEach((axleCountings) => {
|
||||
axleCountings.forEach((axleCounting) => {
|
||||
//计轴关联的道岔
|
||||
const axleCountingRelations =
|
||||
axleCounting.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
axleCounting,
|
||||
Turnout.Type
|
||||
);
|
||||
axleCountingRelations.forEach((relation) => {
|
||||
const refTurnout = relation.getOtherGraphic<Turnout>(axleCounting);
|
||||
//道岔关联的计轴
|
||||
const turnoutRelations =
|
||||
refTurnout.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
refTurnout,
|
||||
AxleCounting.Type
|
||||
);
|
||||
turnoutRelations.forEach((relation) => {
|
||||
const refAxleCounting =
|
||||
relation.getOtherGraphic<AxleCounting>(refTurnout);
|
||||
if (
|
||||
refAxleCounting.id !== axleCountings[0].id &&
|
||||
refAxleCounting.id !== axleCountings[1].id
|
||||
) {
|
||||
fourAxleCounting.push(refAxleCounting);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
for (let x = 0; x < fourAxleCounting.length; x += 4) {
|
||||
const AxleCountings = fourAxleCounting.slice(x, x + 4);
|
||||
for (let y = 0; y < 4; y++) {
|
||||
if (fourAxleCounting[x].id == AxleCountings[y].id) continue;
|
||||
if (fourAxleCounting[x].y == AxleCountings[y].y) {
|
||||
this.draw([fourAxleCounting[x], AxleCountings[y]], map);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (let y = 0; y < 4; y++) {
|
||||
if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue;
|
||||
if (fourAxleCounting[x + 1].y == AxleCountings[y].y) {
|
||||
this.draw([fourAxleCounting[x + 1], AxleCountings[y]], map);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const turnouts = this.app.queryStore.queryByType<Turnout>(Turnout.Type);
|
||||
turnouts.forEach((turnout) => {
|
||||
const turnoutRelations =
|
||||
turnout.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
turnout,
|
||||
AxleCounting.Type
|
||||
);
|
||||
turnoutRelations.forEach((ref) => {
|
||||
const t = ref.getRelationParam(turnout);
|
||||
const other = ref.getOtherGraphic(turnout) as AxleCounting;
|
||||
if (t.param == 'C') {
|
||||
this.draw([turnout, other], map);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
class LogicSectionGraphicHitArea implements IHitArea {
|
||||
logicSection: LogicSection;
|
||||
constructor(logicSection: LogicSection) {
|
||||
this.logicSection = logicSection;
|
||||
}
|
||||
contains(x: number, y: number): boolean {
|
||||
for (let i = 1; i < this.logicSection.datas.points.length; i++) {
|
||||
const p1 = this.logicSection.datas.points[i - 1];
|
||||
const p2 = this.logicSection.datas.points[i];
|
||||
if (linePoint(p1, p2, { x, y }, LogicSectionConsts.lineWidth)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export class LogicSectionInteraction extends GraphicInteractionPlugin<LogicSection> {
|
||||
static Name = 'LogicSection_transform';
|
||||
constructor(app: JlDrawApp) {
|
||||
super(LogicSectionInteraction.Name, app);
|
||||
}
|
||||
static init(app: JlDrawApp) {
|
||||
return new LogicSectionInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): LogicSection[] | undefined {
|
||||
return grahpics
|
||||
.filter((g) => g.type === LogicSection.Type)
|
||||
.map((g) => g as LogicSection);
|
||||
}
|
||||
bind(g: LogicSection): void {
|
||||
g.eventMode = 'static';
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.transformSave = true;
|
||||
g.lineGraphic.eventMode = 'static';
|
||||
g.lineGraphic.cursor = 'pointer';
|
||||
g.lineGraphic.hitArea = new LogicSectionGraphicHitArea(g);
|
||||
g.labelGraphic.eventMode = 'static';
|
||||
g.labelGraphic.cursor = 'pointer';
|
||||
g.labelGraphic.selectable = true;
|
||||
g.labelGraphic.draggable = true;
|
||||
}
|
||||
unbind(g: LogicSection): void {
|
||||
g.eventMode = 'none';
|
||||
g.scalable = false;
|
||||
g.rotatable = false;
|
||||
g.lineGraphic.eventMode = 'none';
|
||||
g.lineGraphic.draggable = false;
|
||||
g.lineGraphic.selectable = false;
|
||||
g.lineGraphic.transformSave = false;
|
||||
g.labelGraphic.eventMode = 'none';
|
||||
g.labelGraphic.draggable = false;
|
||||
g.labelGraphic.selectable = false;
|
||||
g.labelGraphic.transformSave = false;
|
||||
}
|
||||
}
|
@ -34,6 +34,9 @@
|
||||
>
|
||||
<q-item-section>一键生成计轴区段</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="oneClickLogicSection">
|
||||
<q-item-section>一键生成逻辑区段</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
@ -201,6 +204,8 @@ import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssista
|
||||
import { store } from 'quasar/wrappers';
|
||||
import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection';
|
||||
import { AxleCountingSectionDraw } from 'src/graphics/axleCountingSection/AxleCountingSectionAssistant';
|
||||
import { LogicSection } from 'src/graphics/logicSection/LogicSection';
|
||||
import { LogicSectionDraw } from 'src/graphics/logicSection/LogicSectionDrawAssistant';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@ -350,6 +355,13 @@ function oneClickAxleCountingSection() {
|
||||
.getDrawAssistant(AxleCountingSection.Type) as AxleCountingSectionDraw;
|
||||
axleCountingSectionDraw.oneGenerates();
|
||||
}
|
||||
function oneClickLogicSection() {
|
||||
//一键生成逻辑区段
|
||||
const logicSectionDraw = drawStore
|
||||
.getDrawApp()
|
||||
.getDrawAssistant(LogicSection.Type) as LogicSectionDraw;
|
||||
logicSectionDraw.oneGenerates();
|
||||
}
|
||||
function oneClickLink() {
|
||||
drawStore.oneClickType = 'SectionLink';
|
||||
const linkList = drawStore
|
||||
|
@ -24,9 +24,10 @@ export namespace graphicData {
|
||||
separators?: Separator[];
|
||||
sectionLinks?: SectionLink[];
|
||||
axleCountingSections?: AxleCountingSection[];
|
||||
logicSections?: AxleCountingSection[];
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], this.#one_of_decls);
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("canvas" in data && data.canvas != undefined) {
|
||||
this.canvas = data.canvas;
|
||||
@ -76,6 +77,9 @@ export namespace graphicData {
|
||||
if ("axleCountingSections" in data && data.axleCountingSections != undefined) {
|
||||
this.axleCountingSections = data.axleCountingSections;
|
||||
}
|
||||
if ("logicSections" in data && data.logicSections != undefined) {
|
||||
this.logicSections = data.logicSections;
|
||||
}
|
||||
}
|
||||
}
|
||||
get canvas() {
|
||||
@ -177,6 +181,12 @@ export namespace graphicData {
|
||||
set axleCountingSections(value: AxleCountingSection[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 16, value);
|
||||
}
|
||||
get logicSections() {
|
||||
return pb_1.Message.getRepeatedWrapperField(this, AxleCountingSection, 17) as AxleCountingSection[];
|
||||
}
|
||||
set logicSections(value: AxleCountingSection[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 17, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
canvas?: ReturnType<typeof Canvas.prototype.toObject>;
|
||||
links?: ReturnType<typeof Link.prototype.toObject>[];
|
||||
@ -194,6 +204,7 @@ export namespace graphicData {
|
||||
separators?: ReturnType<typeof Separator.prototype.toObject>[];
|
||||
sectionLinks?: ReturnType<typeof SectionLink.prototype.toObject>[];
|
||||
axleCountingSections?: ReturnType<typeof AxleCountingSection.prototype.toObject>[];
|
||||
logicSections?: ReturnType<typeof AxleCountingSection.prototype.toObject>[];
|
||||
}): RtssGraphicStorage {
|
||||
const message = new RtssGraphicStorage({});
|
||||
if (data.canvas != null) {
|
||||
@ -244,6 +255,9 @@ export namespace graphicData {
|
||||
if (data.axleCountingSections != null) {
|
||||
message.axleCountingSections = data.axleCountingSections.map(item => AxleCountingSection.fromObject(item));
|
||||
}
|
||||
if (data.logicSections != null) {
|
||||
message.logicSections = data.logicSections.map(item => AxleCountingSection.fromObject(item));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@ -264,6 +278,7 @@ export namespace graphicData {
|
||||
separators?: ReturnType<typeof Separator.prototype.toObject>[];
|
||||
sectionLinks?: ReturnType<typeof SectionLink.prototype.toObject>[];
|
||||
axleCountingSections?: ReturnType<typeof AxleCountingSection.prototype.toObject>[];
|
||||
logicSections?: ReturnType<typeof AxleCountingSection.prototype.toObject>[];
|
||||
} = {};
|
||||
if (this.canvas != null) {
|
||||
data.canvas = this.canvas.toObject();
|
||||
@ -313,6 +328,9 @@ export namespace graphicData {
|
||||
if (this.axleCountingSections != null) {
|
||||
data.axleCountingSections = this.axleCountingSections.map((item: AxleCountingSection) => item.toObject());
|
||||
}
|
||||
if (this.logicSections != null) {
|
||||
data.logicSections = this.logicSections.map((item: AxleCountingSection) => item.toObject());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -351,6 +369,8 @@ export namespace graphicData {
|
||||
writer.writeRepeatedMessage(15, this.sectionLinks, (item: SectionLink) => item.serialize(writer));
|
||||
if (this.axleCountingSections.length)
|
||||
writer.writeRepeatedMessage(16, this.axleCountingSections, (item: AxleCountingSection) => item.serialize(writer));
|
||||
if (this.logicSections.length)
|
||||
writer.writeRepeatedMessage(17, this.logicSections, (item: AxleCountingSection) => item.serialize(writer));
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -408,6 +428,9 @@ export namespace graphicData {
|
||||
case 16:
|
||||
reader.readMessage(message.axleCountingSections, () => pb_1.Message.addToRepeatedWrapperField(message, 16, AxleCountingSection.deserialize(reader), AxleCountingSection));
|
||||
break;
|
||||
case 17:
|
||||
reader.readMessage(message.logicSections, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCountingSection.deserialize(reader), AxleCountingSection));
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user