123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- import { SBaseEditScene, SBasePipe, SBaseEquipment } from "./../big-edit";
- import { SGraphEdit, SGraphPropertyCommand, } from "./../edit";
- import { SMouseEvent } from "@persagy-web/base/lib";
- import { SGraphSelectContainer, SLineStyle } from "@persagy-web/graph";
- import { SItemStatus } from "@persagy-web/big/lib/enums/SItemStatus";
- import { rgbaNum } from "./../big-edit/until";
- import { SGraphAddCommand } from "./../edit/commands/SGraphAddCommand"
- import { SColor, SFont, SArrowStyleType } from '@persagy-web/draw/lib';
- export class PTopoScene extends SBaseEditScene {
-
- legendObj: any = null;
- constructor() {
- super()
-
- this.selectContainer.connect("listChange", this, this.listChange);
- }
-
- listChange(list: any): void {
- const itemList: any = []
- list.itemList.forEach((item: any) => {
- if ((item instanceof SGraphEdit) && !(item instanceof SGraphSelectContainer)) {
- itemList.push(item)
- }
- })
- this.emitChoice(itemList);
- }
-
- emitChoice(list: any) {
- }
-
- onMouseDown(event: SMouseEvent): any {
- this.vueOnMouseDown(event)
- if (this.grabItem) {
- if (this.grabItem instanceof SBasePipe) {
- this.setTipeEndanchor(event)
- return true;
- }
- return this.grabItem.onMouseDown(event);
- }
- if (this.editCmd == "EditBaseLine") {
- this.addPolyLineArrow(event);
- this.clearCmdStatus();
- } else if (this.editCmd == "EditBasePolyLine") {
- this.addPolyLine(event);
- this.clearCmdStatus();
- } else if (this.editCmd == "EditBasetext") {
- this.addTextItem(event);
- this.clearCmdStatus();
- }
- else if (this.editCmd == "BaseExplain") {
- this.addExplainItem(event);
- this.clearCmdStatus();
- } else if (this.editCmd == "EditBaseImage") {
- this.addImageItem(event)
- this.clearCmdStatus();
- }
- else if (this.editCmd == "EditBasePolygon") {
- this.addPolygonItem(event);
- this.clearCmdStatus();
- } else if (this.editCmd == "EditBaseRect") {
- this.addRectItem(event)
- this.clearCmdStatus();
- } else if (this.editCmd == "EditBaseTriangle") {
- this.addTriangleItem(event)
- this.clearCmdStatus();
- } else if (this.editCmd == "EditBaseCircle") {
- this.addCircleItem(event)
- this.clearCmdStatus();
- }
- else if (this.editCmd == "EditBaseArrows") {
- this.addPolygonArrow(event)
- this.clearCmdStatus();
- }
- else if (this.editCmd == "wantou" || this.editCmd == "santong" || this.editCmd == "sitong") {
- this.addPipeUninTool(event, this.editCmd)
- this.clearCmdStatus();
- }
- else if (this.editCmd == "EditBasePipe") {
- this.addBasePipe(event, this.legendObj);
- this.clearCmdStatus();
- }
- else if (this.editCmd == "") {
- super.onMouseDown(event);
- }
- }
-
- onContextMenu(event: SMouseEvent): boolean {
- if (!super.onContextMenu(event)) {
- this.getItem(null, [event])
- }
- return true
- }
-
- updateStyle(styletype: string, changestyle: any, itemList?: SGraphEdit[]): void {
-
- let List = null;
- if (itemList && itemList.length) {
- List = itemList;
- } else {
- List = this.selectContainer.itemList;
- };
- let styleValue: any
- if (styletype == "strokeColor" || styletype == "backgroundColor" || styletype == "fillColor") {
- const colorlist = rgbaNum(changestyle)
- styleValue = new SColor(Number(colorlist[0]), Number(colorlist[1]), Number(colorlist[2]), colorlist[3] * 255);
- } else if (styletype == "lineStyle") {
- styleValue = SLineStyle[changestyle]
- } else if (styletype == "begin" || styletype == "end") {
- styleValue = SArrowStyleType[changestyle]
- } else if (styletype == "font") {
- styleValue = new SFont("sans-serif", changestyle)
- } else {
- styleValue = changestyle
- }
- List.forEach((item: SGraphEdit, index: number) => {
- if (item instanceof SGraphSelectContainer) {
- return
- }
- const oldMsg = item[styletype];
- const newMsg = styleValue;
- this.undoStack.push(new SGraphPropertyCommand(this, item, styletype, oldMsg, newMsg));
- item[styletype] = styleValue;
- })
- }
-
- changeEquipMsgPoint(obj: any): void {
- const List = this.selectContainer.itemList.length ? this.selectContainer.itemList[0] : null;
- if (List && List instanceof SBaseEquipment) {
- List.setMsgPoint(obj);
- }
- }
-
- finishCreated(item: SGraphEdit): void {
- this.grabItem = null;
- item.status = SItemStatus.Normal;
- this.undoStack.push(new SGraphAddCommand(this, item));
- this.selectContainer.clear();
- this.selectContainer.toggleItem(item);
- }
-
- clearCmdStatus() {
-
- }
-
- getItem(item: SGraphEdit | null, event: SMouseEvent[]): void {
-
- }
-
- vueOnMouseDown(event: SMouseEvent) {
-
- }
-
- setItemStatus() {
- const List = this.selectContainer.itemList[0];
- if (List && List instanceof SGraphEdit) {
- if (List.status == SItemStatus.Normal) {
- List.status = SItemStatus.Edit;
- this.grabItem = List;
- } else {
- List.status = SItemStatus.Normal;
- this.grabItem = null
- }
- }
- }
-
- save(isAll: boolean = true) {
- if (!this.view) return;
- const Marktype: string[] = ['BasePolygon', 'BaseLine', 'BaseText', 'BaseExplain', 'BaseImage', 'BaseCircle', 'BaseArrow', 'BaseTriangle', 'BaseRect', 'BaseArrowPolygon'];
- const NodeType: string[] = ['BaseEquipment'];
- const RelationType: string[] = ["BasePipe"];
- const markers: any = [];
- const nodes: any = [];
- const relations: any = [];
- let nodeList;
- if (isAll) {
- nodeList = this.root.children;
- } else {
- nodeList = this.selectContainer.itemList;
- };
- nodeList.forEach(item => {
- if ((item instanceof SGraphEdit) && !(item instanceof SGraphSelectContainer)) {
-
- if (item.data && Marktype.includes(item.data.properties.type)) {
- markers.push(item.toData())
- }
- if (item.legendData && NodeType.includes(item.legendData.properties.type)) {
- nodes.push(item.toData())
- }
- if (item.relationData && RelationType.includes(item.relationData.properties.type)) {
- relations.push(item.toData())
- }
- }
- });
- return {
- markers,
- nodes,
- relations
- }
- }
- }
|