|
@@ -1,18 +1,14 @@
|
|
|
-import { SBaseEditScene, SBaseLineEdit, SBaseTextEdit, SBaseExpainEdit, SBaseRectEdit, SBaseEquipment } from "./../big-edit";
|
|
|
-import { SPersagyImageEdit } from "./"
|
|
|
-
|
|
|
-import { SGraphEdit } from "./../edit"
|
|
|
+import { SBaseEditScene, SBaseExpainEdit, SBaseEquipment } from "./../big-edit";
|
|
|
+import { SBaseRectEdit, SBaseLineEdit, SBaseTextEdit, SGraphEdit, SBaseArrowEdit ,SBaseCircleEdit,SBaseTriangleEdit} 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 { uuid, rgbaNum } from "./../big-edit/until";
|
|
|
+import { rgbaNum } from "./../big-edit/until";
|
|
|
|
|
|
|
|
|
import { SGraphAddCommand } from "./../edit/commands/SGraphAddCommand"
|
|
|
import { SColor } from '@persagy-web/draw/lib';
|
|
|
-import { SBaseTriangelEdit } from '../big-edit/items/SBaseTriangleEdit';
|
|
|
-import { SBaseArrowEdit } from '../big-edit/items/SBaseArrowEdit';
|
|
|
-import { SBaseCircleEdit } from '../big-edit/items/SBaseCircleEdit';
|
|
|
export class PTopoScene extends SBaseEditScene {
|
|
|
constructor() {
|
|
|
super()
|
|
@@ -26,7 +22,13 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
* @param event 鼠标事件参数
|
|
|
*/
|
|
|
listChange(list: any): void {
|
|
|
- this.emitChoice(list.itemList);
|
|
|
+ const itemList: any = []
|
|
|
+ list.itemList.forEach((item: any) => {
|
|
|
+ if ((item instanceof SGraphEdit) && !(item instanceof SGraphSelectContainer)) {
|
|
|
+ itemList.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.emitChoice(itemList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -45,35 +47,37 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
onMouseDown(event: SMouseEvent): any {
|
|
|
this.vueOnMouseDown(event)
|
|
|
if (this.editCmd == "EditBaseLine") {
|
|
|
- this.addLine(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") {
|
|
|
- console.log('编辑多边形')
|
|
|
- } 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.addArrowsItem(event)
|
|
|
- this.clearCmdStatus();
|
|
|
- } else if (this.editCmd == "EditEuqipment") {
|
|
|
- this.addEuqipment(event)
|
|
|
- this.clearCmdStatus();
|
|
|
- } else if (this.editCmd == "") {
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ else if (this.editCmd == "") {
|
|
|
super.onMouseDown(event);
|
|
|
}
|
|
|
}
|
|
@@ -98,22 +102,22 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
addLine(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
|
|
|
- Name: '基础直线',
|
|
|
+ name: '基础直线',
|
|
|
|
|
|
- Type: "Line",
|
|
|
+ type: "Line",
|
|
|
|
|
|
- Scale: { X: 1, Y: 1, Z: 1 },
|
|
|
+ scale: { x: 1, y: 1, z: 1 },
|
|
|
|
|
|
- Rolate: { X: 0, Y: 0, Z: 0 },
|
|
|
+ rolate: { x: 0, y: 0, z: 0 },
|
|
|
|
|
|
- Pos: { X: 0, Y: 0 },
|
|
|
+ pos: { x: 0, y: 0 },
|
|
|
|
|
|
- Properties: {
|
|
|
- Type: "BaseLine"
|
|
|
+ properties: {
|
|
|
+ type: "BaseLine"
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- Line: [{ X: event.x, Y: event.y }],
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ line: [{ x: event.x, y: event.y }],
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -139,22 +143,22 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
addTextItem(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
|
|
|
- Name: '基础文本',
|
|
|
+ name: '基础文本',
|
|
|
|
|
|
- Type: "Text",
|
|
|
+ type: "Text",
|
|
|
|
|
|
- Pos: { X: event.x, Y: event.y },
|
|
|
- Size: { Width: 0, Height: 0 },
|
|
|
+ pos: { x: event.x, y: event.y },
|
|
|
+ size: { width: 0, height: 0 },
|
|
|
|
|
|
- Properties: {
|
|
|
- Type: "BaseText"
|
|
|
+ properties: {
|
|
|
+ type: "BaseText"
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- Text: '请在右侧属性栏输入文字!',
|
|
|
- Color: "#646c73",
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ text: '请在右侧属性栏输入文字!',
|
|
|
+ color: "#646c73",
|
|
|
Font: 14,
|
|
|
- BackgroundColor: "#f7f9facc",
|
|
|
+ Backgroundcolor: "#f7f9facc",
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -176,21 +180,21 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
addExplainItem(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
|
|
|
- Name: '基础注释文本',
|
|
|
+ name: '基础注释文本',
|
|
|
|
|
|
- Type: "Text",
|
|
|
+ type: "Text",
|
|
|
|
|
|
- Pos: { X: event.x, Y: event.y },
|
|
|
+ pos: { x: event.x, y: event.y },
|
|
|
|
|
|
- Properties: {
|
|
|
- Type: "BaseExplain",
|
|
|
+ properties: {
|
|
|
+ type: "BaseExplain",
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- Text: '请在右侧属性栏输入文字!',
|
|
|
- Color: "#646c73",
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ text: '请在右侧属性栏输入文字!',
|
|
|
+ color: "#646c73",
|
|
|
Font: 14,
|
|
|
- BackgroundColor: "#f7f9facc",
|
|
|
+ Backgroundcolor: "#f7f9facc",
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -215,24 +219,24 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
addImageItem(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
|
|
|
- Name: '基础图片',
|
|
|
- Num: 1,
|
|
|
+ name: '基础图片',
|
|
|
+ num: 1,
|
|
|
|
|
|
- Type: "Image",
|
|
|
+ type: "Image",
|
|
|
|
|
|
- Pos: { X: event.x, Y: event.y },
|
|
|
+ pos: { x: event.x, y: event.y },
|
|
|
|
|
|
- Properties: {
|
|
|
- Type: "BaseImage",
|
|
|
+ properties: {
|
|
|
+ type: "BaseImage",
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- StrokeColor: "#c0ccda",
|
|
|
- Url: '',
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ strokecolor: "#c0ccda",
|
|
|
+ url: '',
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- const item = new SPersagyImageEdit(null, data);
|
|
|
+
|
|
|
item.selectable = true;
|
|
|
item.moveable = true;
|
|
|
this.addItem(item);
|
|
@@ -246,18 +250,17 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
*/
|
|
|
addRectItem(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
- ID: uuid(),
|
|
|
- Name: '基础矩形',
|
|
|
+ name: '基础矩形',
|
|
|
|
|
|
- Type: "Zone",
|
|
|
+ type: "Zone",
|
|
|
|
|
|
- Pos: { X: 0, Y: 0 },
|
|
|
- Properties: {
|
|
|
- Type: "BaseRect",
|
|
|
+ pos: { x: 0, y: 0 },
|
|
|
+ properties: {
|
|
|
+ type: "BaseRect",
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- Line: [{ X: event.x, Y: event.y }],
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ line: [{ x: event.x, y: event.y }],
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -266,7 +269,9 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
this.addItem(rectItem);
|
|
|
this.undoStack.push(new SGraphAddCommand(this, rectItem));
|
|
|
rectItem.selectable = true;
|
|
|
+ rectItem.moveable = true;
|
|
|
this.grabItem = rectItem;
|
|
|
+ rectItem.isTransform = true
|
|
|
rectItem.connect("finishCreated", this, this.finishCreated);
|
|
|
rectItem.connect("onContextMenu", this, this.getItem);
|
|
|
if (this.view) {
|
|
@@ -279,24 +284,24 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
*/
|
|
|
addTriangleItem(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
- ID: uuid(),
|
|
|
- Name: '基础三角形',
|
|
|
- Type: "Zone",
|
|
|
- Pos: { X: 0, Y: 0 },
|
|
|
- Properties: {
|
|
|
- Type: "BaseTriangle",
|
|
|
+ name: '基础三角形',
|
|
|
+ type: "Zone",
|
|
|
+ pos: { x: 0, y: 0 },
|
|
|
+ properties: {
|
|
|
+ type: "BaseTriangle",
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- Line: [{ X: event.x, Y: event.y }],
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ line: [{ x: event.x, y: event.y }],
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- const triangleItem = new SBaseTriangelEdit(null, data);
|
|
|
+ const triangleItem = new SBaseTriangleEdit(null, data);
|
|
|
triangleItem.status = SItemStatus.Create;
|
|
|
this.addItem(triangleItem);
|
|
|
this.undoStack.push(new SGraphAddCommand(this, triangleItem));
|
|
|
triangleItem.selectable = true;
|
|
|
+ triangleItem.moveable = true;
|
|
|
this.grabItem = triangleItem;
|
|
|
triangleItem.connect("finishCreated", this, this.finishCreated);
|
|
|
triangleItem.connect("onContextMenu", this, this.getItem);
|
|
@@ -310,21 +315,21 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
*/
|
|
|
addArrowsItem(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
- ID: uuid(),
|
|
|
- Name: '基础箭头',
|
|
|
- Type: "Zone",
|
|
|
- Pos: { X: 0, Y: 0 },
|
|
|
- Properties: {
|
|
|
- Type: "BaseArrow",
|
|
|
+ name: '基础箭头',
|
|
|
+ type: "Zone",
|
|
|
+ pos: { x: 0, y: 0 },
|
|
|
+ properties: {
|
|
|
+ type: "BaseArrow",
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- Line: [{ X: event.x, Y: event.y }],
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ line: [{ x: event.x, y: event.y }],
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
const arrowItem = new SBaseArrowEdit(null, data);
|
|
|
arrowItem.status = SItemStatus.Create;
|
|
|
+ arrowItem.moveable = true;
|
|
|
this.addItem(arrowItem);
|
|
|
this.undoStack.push(new SGraphAddCommand(this, arrowItem));
|
|
|
arrowItem.selectable = true;
|
|
@@ -337,19 +342,19 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
}
|
|
|
|
|
|
|
|
|
- * 添加基本箭头item
|
|
|
+ * 添加基本圆
|
|
|
*/
|
|
|
addCircleItem(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
- ID: uuid(),
|
|
|
- Name: '基础圆形',
|
|
|
- Type: "BaseCircle",
|
|
|
- Pos: { X: 0, Y: 0 },
|
|
|
- Properties: {
|
|
|
+ name: '基础圆形',
|
|
|
+ type: "Zone",
|
|
|
+ pos: { x: 0, y: 0 },
|
|
|
+ properties: {
|
|
|
+ type: "BaseCircle",
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- Line: [{ X: event.x, Y: event.y }],
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ line: [{ x: event.x, y: event.y }],
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -371,21 +376,21 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
addEuqipment(event: SMouseEvent): void {
|
|
|
const data = {
|
|
|
|
|
|
- Name: '基础设备',
|
|
|
- Num: 1,
|
|
|
- Size: { Width: 50, Height: 50 },
|
|
|
+ name: '基础设备',
|
|
|
+ num: 1,
|
|
|
+ size: { width: 50, height: 50 },
|
|
|
|
|
|
- Type: "Image",
|
|
|
+ type: "Image",
|
|
|
|
|
|
- Pos: { X: event.x, Y: event.y },
|
|
|
+ pos: { x: event.x, y: event.y },
|
|
|
|
|
|
- Properties: {
|
|
|
- Type: "baseEquipment",
|
|
|
+ properties: {
|
|
|
+ type: "baseEquipment",
|
|
|
},
|
|
|
- Style: {
|
|
|
- Default: {
|
|
|
- StrokeColor: "#c0ccda",
|
|
|
- Url: require('./../../../assets/images/svg.svg'),
|
|
|
+ style: {
|
|
|
+ default: {
|
|
|
+ strokecolor: "#c0ccda",
|
|
|
+ url: require('./../../../assets/images/svg.svg'),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -403,17 +408,12 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
}
|
|
|
|
|
|
* 修改 item 样式,数据等方法
|
|
|
- * @param styleType string 修改样式类型
|
|
|
+ * @param styletype string 修改样式类型
|
|
|
* @param changeStyle 更改样式数据
|
|
|
* @param itemList? SGraphEdit[] 如果不传入默认使用选择器中选中得item
|
|
|
*/
|
|
|
- updateStyle(styleType: string, changeStyle: any, itemList?: SGraphEdit[]): void {
|
|
|
- console.log('------------>');
|
|
|
- console.log(styleType);
|
|
|
- console.log(changeStyle);
|
|
|
- console.log(itemList);
|
|
|
- console.log('------------>');
|
|
|
-
|
|
|
+ updateStyle(styletype: string, changestyle: any, itemList?: SGraphEdit[]): void {
|
|
|
+
|
|
|
|
|
|
let List = null;
|
|
|
if (itemList && itemList.length) {
|
|
@@ -422,19 +422,20 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
List = this.selectContainer.itemList;
|
|
|
};
|
|
|
let styleValue: any
|
|
|
- if (styleType == "strokeColor" || styleType == "backgroundColor") {
|
|
|
- const colorlist = rgbaNum(changeStyle)
|
|
|
+ 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 == "lineStyle") {
|
|
|
+ styleValue = SLineStyle[changestyle]
|
|
|
} else {
|
|
|
- styleValue = changeStyle
|
|
|
+ styleValue = changestyle
|
|
|
}
|
|
|
List.forEach((item: SGraphEdit, index: number) => {
|
|
|
if (item instanceof SGraphSelectContainer) {
|
|
|
return
|
|
|
}
|
|
|
- item[styleType] = styleValue;
|
|
|
+ console.log('xxxx', item)
|
|
|
+ item[styletype] = styleValue;
|
|
|
})
|
|
|
|
|
|
}
|
|
@@ -477,19 +478,19 @@ export class PTopoScene extends SBaseEditScene {
|
|
|
*/
|
|
|
save() {
|
|
|
if (!this.view) return;
|
|
|
- const MarkType: string[] = ['BaseLine', 'BaseText', 'BaseExplain', 'BaseImage'];
|
|
|
- const Markers: any = [];
|
|
|
- const Nodes: any = [];
|
|
|
- const Relations: any = [];
|
|
|
+ const Marktype: string[] = ['BaseLine', 'BaseText', 'BaseExplain', 'BaseImage'];
|
|
|
+ const markers: any = [];
|
|
|
+ const nodes: any = [];
|
|
|
+ const relations: any = [];
|
|
|
this.root.children.forEach(item => {
|
|
|
- if ((item instanceof SGraphEdit) && !(item instanceof SGraphSelectContainer) && MarkType.includes(item.data.Properties.Type)) {
|
|
|
+ if ((item instanceof SGraphEdit) && !(item instanceof SGraphSelectContainer) && Marktype.includes(item.data.Properties.type)) {
|
|
|
Markers.push(item.toData())
|
|
|
}
|
|
|
});
|
|
|
return {
|
|
|
- Markers,
|
|
|
- Nodes,
|
|
|
- Relations
|
|
|
+ markers,
|
|
|
+ nodes,
|
|
|
+ relations
|
|
|
}
|
|
|
}
|
|
|
}
|