|
@@ -36,6 +36,8 @@ export class EditScence extends SGraphScene {
|
|
|
undoStack = new SUndoStack();
|
|
|
/** 判断是否为苹果电脑 */
|
|
|
public isMac = /macintosh|mac os x/i.test(navigator.userAgent);
|
|
|
+ /** 是否为复制状态 */
|
|
|
+ public isCopy = "false"
|
|
|
/** 命令 1 绘制直线 */
|
|
|
private cmd = 'choice';
|
|
|
/** 获取当前状态 */
|
|
@@ -65,10 +67,10 @@ export class EditScence extends SGraphScene {
|
|
|
isAbsorbing: boolean = false;
|
|
|
/** 吸附展示item */
|
|
|
highLight: HighlightItem | null = null;
|
|
|
- /** 矩形选择区域 */
|
|
|
- rectSelectItem: SRectSelectItem | null = null;
|
|
|
- /** 框选 */
|
|
|
- isRectSelection: number = 0;
|
|
|
+ // /** 矩形选择区域 */
|
|
|
+ // rectSelectItem: SRectSelectItem | null = null;
|
|
|
+ // /** 框选 */
|
|
|
+ // isRectSelection: number = 0;
|
|
|
/** 当前选中焦点Item */
|
|
|
focusItem: SGraphItem | null = null;
|
|
|
/** 当前选中焦点ItemList */
|
|
@@ -104,7 +106,6 @@ export class EditScence extends SGraphScene {
|
|
|
ItemColor.virtualWallColor = new SColor("#d4d4d4")
|
|
|
ItemColor.selectColor = new SColor("#f0f0f0")
|
|
|
ItemColor.spaceBorderColor = new SColor("#d4d4d4");
|
|
|
- console.log('isMac',this.isMac)
|
|
|
}
|
|
|
/** 绘制图例样式 */
|
|
|
_legend: any | null = null;
|
|
@@ -261,7 +262,7 @@ export class EditScence extends SGraphScene {
|
|
|
// 起始锚点
|
|
|
item.startAnchor = anc;
|
|
|
if (anc) {
|
|
|
- anc.parent ?.connect('changePos', item, item.changePos)
|
|
|
+ anc.parent?.connect('changePos', item, item.changePos)
|
|
|
item.anchor1ID = anc.id;
|
|
|
item.node1Id = anc.parent.id;
|
|
|
}
|
|
@@ -295,7 +296,8 @@ export class EditScence extends SGraphScene {
|
|
|
TextPos: { X: 0, Y: 0 },
|
|
|
InfoTypeId: this._legend.InfoTypeId.length ? this._legend.InfoTypeId : [],
|
|
|
InfoSystemId: this._legend.InfoSystemId ? this._legend.InfoSystemId : '',
|
|
|
- InfoLocal: this._legend.InfoLocal.length ? this._legend.InfoLocal : []
|
|
|
+ InfoLocal: this._legend.InfoLocal.length ? this._legend.InfoLocal : [],
|
|
|
+ lengendName: this._legend.Name, //图例名称
|
|
|
},
|
|
|
}
|
|
|
let Polylines = null;
|
|
@@ -352,7 +354,8 @@ export class EditScence extends SGraphScene {
|
|
|
TextPos: { X: item.data.Location.Points[0].X, Y: -item.data.Location.Points[0].Y },
|
|
|
InfoTypeId: this._legend.InfoTypeId.length ? this._legend.InfoTypeId : [],
|
|
|
InfoSystemId: this._legend.InfoSystemId ? this._legend.InfoSystemId : '',
|
|
|
- InfoLocal: this._legend.InfoLocal.length ? this._legend.InfoLocal : []
|
|
|
+ InfoLocal: this._legend.InfoLocal.length ? this._legend.InfoLocal : [],
|
|
|
+ lengendName: this._legend.Name, //图例名称
|
|
|
},
|
|
|
}
|
|
|
let Polylines = null;
|
|
@@ -402,6 +405,7 @@ export class EditScence extends SGraphScene {
|
|
|
this.Markers.push(item);
|
|
|
this.grabItem == null;
|
|
|
this.focusItem = item;
|
|
|
+ this.undoStack.push(new SGraphAddCommand(this, item));
|
|
|
this.finishCreated(item);
|
|
|
this.scenceUpdate(this);
|
|
|
}
|
|
@@ -438,6 +442,7 @@ export class EditScence extends SGraphScene {
|
|
|
this.focusItem = item;
|
|
|
this.cmd = 'choice';
|
|
|
this.finishCreated(item);
|
|
|
+ this.undoStack.push(new SGraphAddCommand(this, item));
|
|
|
this.scenceUpdate(this);
|
|
|
}
|
|
|
|
|
@@ -463,8 +468,8 @@ export class EditScence extends SGraphScene {
|
|
|
Url: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
|
|
|
Num: 1, // 此num与信息工程化得num无关
|
|
|
Size: {
|
|
|
- Width: this._legend.Size?this._legend.Size.Width?this._legend.Size.Width:32:32, //icon 的宽
|
|
|
- Height: this._legend.Size?this._legend.Size.Height?this._legend.Size.Height:32:32, //icon 的高
|
|
|
+ Width: this._legend.Size ? this._legend.Size.Width ? this._legend.Size.Width : 32 : 32, //icon 的宽
|
|
|
+ Height: this._legend.Size ? this._legend.Size.Height ? this._legend.Size.Height : 32 : 32, //icon 的高
|
|
|
},
|
|
|
font: 16, //font
|
|
|
color: "#1F2429", //字体颜色
|
|
@@ -485,6 +490,7 @@ export class EditScence extends SGraphScene {
|
|
|
this.grabItem = null;
|
|
|
this.focusItem = item;
|
|
|
this.finishCreated(item);
|
|
|
+ this.undoStack.push(new SGraphAddCommand(this, item));
|
|
|
this.scenceUpdate(this);
|
|
|
if (event.ctrlKey) {
|
|
|
this.cmd = cmd;
|
|
@@ -713,7 +719,7 @@ export class EditScence extends SGraphScene {
|
|
|
fillColorT = fillColor + Transparency[15];
|
|
|
if (this.focusItem instanceof SSCPZZoneLegendItem || this.focusItem instanceof SFHFQZoneLegendItem) {
|
|
|
const sc = new SColor(this.focusItem.fillColor);
|
|
|
- const alp = ((sc.alpha/255)*100).toFixed()
|
|
|
+ const alp = ((sc.alpha / 255) * 100).toFixed()
|
|
|
fillColorT = fillColor + Transparency[alp];
|
|
|
// fillColorT = fillColor + Transparency[80];
|
|
|
}
|
|
@@ -740,7 +746,7 @@ export class EditScence extends SGraphScene {
|
|
|
* 更新工程信息化的相关数据
|
|
|
* @param AttachObjectIds Array
|
|
|
*/
|
|
|
- upadatAttachObjectIds(AttachObjectIds: []): void {
|
|
|
+ upadatAttachObjectIds(AttachObjectIds: [], flag: boolean): void {
|
|
|
if (this.focusItem) {
|
|
|
this.focusItem.data.AttachObjectIds = AttachObjectIds;
|
|
|
// 重新选中focusitem
|
|
@@ -754,15 +760,18 @@ export class EditScence extends SGraphScene {
|
|
|
item instanceof SFHFQZoneLegendItem
|
|
|
) {
|
|
|
let arr = item.data.AttachObjectIds;
|
|
|
- if (arr && arr.length && arr[arr.length - 1].name) {
|
|
|
+ if (arr && arr.length && arr[arr.length - 1].name && flag) {
|
|
|
let name = item.name;
|
|
|
- if (name) {
|
|
|
- item.name = name + `\n${arr[arr.length - 1].name}`;
|
|
|
- item.text = name + `\n${arr[arr.length - 1].name}`;
|
|
|
- } else {
|
|
|
- item.name = arr[arr.length - 1].name;
|
|
|
- item.text = arr[arr.length - 1].name;
|
|
|
- }
|
|
|
+ let nameArr = name.split("\n");
|
|
|
+ // if (nameArr[nameArr.length - 1] != arr[arr.length - 1].name) //最后一行的名称和将要添加的名称如果不同(增加)
|
|
|
+ if (nameArr.indexOf(arr[arr.length - 1].name) == -1) //将要添加的名称和每一行的名称都不同(新增)
|
|
|
+ if (name) {
|
|
|
+ item.name = name + `\n${arr[arr.length - 1].name}`;
|
|
|
+ item.text = name + `\n${arr[arr.length - 1].name}`;
|
|
|
+ } else {
|
|
|
+ item.name = arr[arr.length - 1].name;
|
|
|
+ item.text = arr[arr.length - 1].name;
|
|
|
+ }
|
|
|
}
|
|
|
// 绑定工程信息化数据后设置状态
|
|
|
if (item.data.AttachObjectIds && item.data.AttachObjectIds.length) {
|
|
@@ -777,7 +786,7 @@ export class EditScence extends SGraphScene {
|
|
|
/**
|
|
|
* 自定义多边形修改背景色
|
|
|
*/
|
|
|
- updateCustomBgColor(val: string):void{
|
|
|
+ updateCustomBgColor(val: string): void {
|
|
|
if (this.focusItem) {
|
|
|
const newMsg = new SColor(val);
|
|
|
const oldMsg = this.focusItem.fillColor;
|
|
@@ -789,7 +798,7 @@ export class EditScence extends SGraphScene {
|
|
|
/**
|
|
|
* 自定义多边形修改边框色
|
|
|
*/
|
|
|
- updateCustomBdColor(val: string):void{
|
|
|
+ updateCustomBdColor(val: string): void {
|
|
|
if (this.focusItem) {
|
|
|
const newMsg = new SColor(val);
|
|
|
const oldMsg = this.focusItem.strokeColor;
|
|
@@ -801,6 +810,10 @@ export class EditScence extends SGraphScene {
|
|
|
* 删除指定item
|
|
|
*/
|
|
|
deleiteItem(): void {
|
|
|
+ // 如果为复制状态则删除失效
|
|
|
+ if (this.isCopy == "true") {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (this.focusItem) {
|
|
|
if ((this.focusItem instanceof SZoneLegendItem ||
|
|
|
this.focusItem instanceof SSCPZZoneLegendItem ||
|
|
@@ -949,10 +962,23 @@ export class EditScence extends SGraphScene {
|
|
|
} else {
|
|
|
this.undoStack.redo();
|
|
|
this.scenceUpdate(this);
|
|
|
+ const command = this.undoStack.command(this.undoStack.index);
|
|
|
+ // 如果为删除命令,重做需要讲数据数组中的item重新删去
|
|
|
+ if (command && command.command == "DeleteCommand") {
|
|
|
+ this.clearDataItem(command.item)
|
|
|
+ } else if (command && command.command == "DeleteCommandList") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.clearDataItem(element)
|
|
|
+ });
|
|
|
+ } else if (command && command.command == "SGraphAddCommand") {
|
|
|
+ this.addDataItem(command.item)
|
|
|
+ } else if (command && command.command == "AddListCommand") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.addDataItem(element)
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 执行重做操作执行
|
|
|
*/
|
|
@@ -960,11 +986,75 @@ export class EditScence extends SGraphScene {
|
|
|
if (this.grabItem && this.grabItem.undo) {
|
|
|
this.grabItem.undo()
|
|
|
} else {
|
|
|
+ const command = this.undoStack.command(this.undoStack.index);
|
|
|
+ // 如果为删除命令,重做需要讲数据数组中的item重新放回data中
|
|
|
+ if (command && command.command == "DeleteCommand") {
|
|
|
+ this.addDataItem(command.item)
|
|
|
+ } else if (command && command.command == "DeleteCommandList") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.addDataItem(element)
|
|
|
+ });
|
|
|
+ } else if (command && command.command == "SGraphAddCommand") {
|
|
|
+ this.clearDataItem(command.item)
|
|
|
+ } else if (command && command.command == "AddListCommand") {
|
|
|
+ command.itemList.forEach(element => {
|
|
|
+ this.clearDataItem(element)
|
|
|
+ });
|
|
|
+ }
|
|
|
this.undoStack.undo();
|
|
|
this.scenceUpdate(this);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
+ * 清除data数据中指定的item
|
|
|
+ */
|
|
|
+ clearDataItem(commanditem: any) {
|
|
|
+ let a = -1
|
|
|
+ this.Nodes.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == commanditem.id) {
|
|
|
+ a = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (a > -1) {
|
|
|
+ this.Nodes.splice(a, 1);
|
|
|
+ }
|
|
|
+ let b = -1;
|
|
|
+ this.Markers.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == commanditem.id) {
|
|
|
+ b = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (b > -1) {
|
|
|
+ this.Markers.splice(b, 1);
|
|
|
+ }
|
|
|
+ let c = -1;
|
|
|
+ this.Relations.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == commanditem.id) {
|
|
|
+ c = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (c > -1) {
|
|
|
+ this.Relations.splice(c, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增加指定Item到data数据中
|
|
|
+ */
|
|
|
+
|
|
|
+ addDataItem(item: any) {
|
|
|
+ //清空指定的item
|
|
|
+ this.clearDataItem(item);
|
|
|
+ // 重新填入
|
|
|
+ if (item instanceof STextMarkerItem || item instanceof SImageMarkerItem || item instanceof SLineMarkerItem || item instanceof SCustomLegendItem) {
|
|
|
+ this.Markers.push(item)
|
|
|
+ } else if (item instanceof SFHFQZoneLegendItem || item instanceof SSCPZZoneLegendItem || item instanceof SImageLegendItem || item instanceof SZoneLegendItem) {
|
|
|
+ this.Nodes.push(item)
|
|
|
+ } else if (item instanceof TipelineItem) {
|
|
|
+ this.Relations.push(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 完成事件创建的回调函数
|
|
|
*/
|
|
|
finishCreated(item: any) {
|
|
@@ -1044,6 +1134,11 @@ export class EditScence extends SGraphScene {
|
|
|
return this.grabItem.onMouseDown(event);
|
|
|
}
|
|
|
switch (this.cmd) {
|
|
|
+ case 'choice':
|
|
|
+ if (!super.onMouseDown(event)) {
|
|
|
+ this.addRectSelect(event);
|
|
|
+ }
|
|
|
+ break
|
|
|
case 'baseLine':
|
|
|
this.addLine(event);
|
|
|
break;
|
|
@@ -1084,7 +1179,7 @@ export class EditScence extends SGraphScene {
|
|
|
this.highLight.visible = false;
|
|
|
this.absorbSpace(event);
|
|
|
}
|
|
|
- if (this.grabItem){
|
|
|
+ if (this.grabItem) {
|
|
|
if (this.grabItem instanceof TipelineItem) {
|
|
|
const anc = this.clickIsAnchor(event);
|
|
|
if (anc) {
|
|
@@ -1093,6 +1188,8 @@ export class EditScence extends SGraphScene {
|
|
|
event.y = p.y;
|
|
|
return this.grabItem.onMouseMove(event);
|
|
|
}
|
|
|
+ } else if (this.grabItem instanceof SRectSelectItem) {
|
|
|
+ return this.grabItem.onMouseMove(event);
|
|
|
}
|
|
|
}
|
|
|
return super.onMouseMove(event)
|
|
@@ -1109,6 +1206,14 @@ export class EditScence extends SGraphScene {
|
|
|
} else if (this.grabItem instanceof TipelineItem) {
|
|
|
this.updateTipeAnc(event);
|
|
|
return true;
|
|
|
+ } else if (this.grabItem instanceof SRectSelectItem) {
|
|
|
+ this.groupSelect(event.ctrlKey);
|
|
|
+ this.removeItem(this.grabItem);
|
|
|
+ this.grabItem = null;
|
|
|
+ if (this.view) {
|
|
|
+ this.view.update()
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
return this.grabItem.onMouseUp(event);
|
|
|
}
|
|
@@ -1142,7 +1247,7 @@ export class EditScence extends SGraphScene {
|
|
|
this.deleiteItem()
|
|
|
}
|
|
|
// 删除键功能--兼容苹果mac
|
|
|
- if (event.code == 'Backspace' && this.isMac){
|
|
|
+ if (event.code == 'Backspace' && this.isMac) {
|
|
|
this.deleiteItem()
|
|
|
}
|
|
|
// 复制粘贴
|
|
@@ -1152,7 +1257,7 @@ export class EditScence extends SGraphScene {
|
|
|
this.copy()
|
|
|
} else if (event.code == 'KeyV') {
|
|
|
console.log('ctrl v')
|
|
|
- this.paste()
|
|
|
+ // this.paste()
|
|
|
}
|
|
|
}
|
|
|
return false
|
|
@@ -1162,7 +1267,7 @@ export class EditScence extends SGraphScene {
|
|
|
* 复制
|
|
|
*
|
|
|
*/
|
|
|
- copy(){
|
|
|
+ copy() {
|
|
|
if (this.selectContainer.itemList.length) {
|
|
|
this.copyString = {
|
|
|
Nodes: [],
|
|
@@ -1182,15 +1287,15 @@ export class EditScence extends SGraphScene {
|
|
|
})
|
|
|
// 生成复制字符串
|
|
|
console.log(this.copyString)
|
|
|
- return
|
|
|
// 获取input dom
|
|
|
const input = document.createElement('input');
|
|
|
input.setAttribute('id', 'COPYINPUT')
|
|
|
input.value = JSON.stringify(this.copyString)
|
|
|
+ sessionStorage.setItem("copyString", input.value);
|
|
|
document.body.appendChild(input);
|
|
|
input.select()
|
|
|
document.execCommand('copy');
|
|
|
- input.style.display='none';
|
|
|
+ input.style.display = 'none';
|
|
|
console.log(input.value, Date.now());
|
|
|
document.body.removeChild(input)
|
|
|
}
|
|
@@ -1200,25 +1305,27 @@ export class EditScence extends SGraphScene {
|
|
|
* 粘贴
|
|
|
*
|
|
|
*/
|
|
|
- paste(){
|
|
|
+ paste() {
|
|
|
const parserData = new STopologyParser(null);
|
|
|
// 需要深拷贝
|
|
|
parserData.parseData(JSON.parse(JSON.stringify(this.copyString)))
|
|
|
- // 不需要复制区域
|
|
|
- // parserData.zoneLegendList.forEach(t => {
|
|
|
- // if (t instanceof SCustomLegendItem) {
|
|
|
- // if (this.view) {
|
|
|
- // t.pos.x += 10 / this.view.scale
|
|
|
- // t.pos.y += 10 / this.view.scale
|
|
|
- // }
|
|
|
- // this.addItem(t)
|
|
|
- // this.Nodes.push(t);
|
|
|
- // graphItemList.push(t)
|
|
|
- // }
|
|
|
- // // 加到node
|
|
|
- // // 加命令
|
|
|
- // })
|
|
|
const graphItemList = [];
|
|
|
+ // 不需要复制区域
|
|
|
+ parserData.zoneLegendList.forEach(t => {
|
|
|
+ // if (t instanceof SCustomLegendItem) {
|
|
|
+ if (this.view) {
|
|
|
+ t.pos.x += 10 / this.view.scale
|
|
|
+ t.pos.y += 10 / this.view.scale
|
|
|
+ }
|
|
|
+ t.moveable = true;
|
|
|
+ this.addItem(t)
|
|
|
+ this.Nodes.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
+ graphItemList.push(t)
|
|
|
+ // }
|
|
|
+ // 加到node
|
|
|
+ // 加命令
|
|
|
+ })
|
|
|
parserData.imageLegendList.forEach(t => {
|
|
|
if (this.view) {
|
|
|
t.pos.x += 10 / this.view.scale
|
|
@@ -1227,6 +1334,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Nodes.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.imageMarkerList.forEach(t => {
|
|
@@ -1237,6 +1345,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Markers.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.lineMarkerList.forEach(t => {
|
|
@@ -1247,6 +1356,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Markers.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.textMarkerList.forEach(t => {
|
|
@@ -1257,6 +1367,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Markers.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.relationList.forEach(t => {
|
|
@@ -1268,6 +1379,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Relations.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
this.scenceUpdate(this);
|
|
@@ -1280,29 +1392,30 @@ export class EditScence extends SGraphScene {
|
|
|
* 跨页面粘贴
|
|
|
*
|
|
|
*/
|
|
|
- crossPagePaste(crossPageString: string){
|
|
|
+ crossPagePaste(crossPageString: string) {
|
|
|
try {
|
|
|
console.log(crossPageString);
|
|
|
const pageObj = JSON.parse(crossPageString)
|
|
|
-
|
|
|
const parserData = new STopologyParser(null);
|
|
|
+ const graphItemList = [];
|
|
|
// 需要深拷贝
|
|
|
parserData.parseData(JSON.parse(JSON.stringify(pageObj)))
|
|
|
// 不需要复制区域
|
|
|
- // parserData.zoneLegendList.forEach(t => {
|
|
|
- // if (t instanceof SCustomLegendItem) {
|
|
|
- // if (this.view) {
|
|
|
- // t.pos.x += 10 / this.view.scale
|
|
|
- // t.pos.y += 10 / this.view.scale
|
|
|
- // }
|
|
|
- // this.addItem(t)
|
|
|
- // this.Nodes.push(t);
|
|
|
- // graphItemList.push(t)
|
|
|
- // }
|
|
|
- // // 加到node
|
|
|
- // // 加命令
|
|
|
- // })
|
|
|
- const graphItemList = [];
|
|
|
+ parserData.zoneLegendList.forEach(t => {
|
|
|
+ // if (t instanceof SCustomLegendItem) {
|
|
|
+ if (this.view) {
|
|
|
+ t.pos.x += 10 / this.view.scale
|
|
|
+ t.pos.y += 10 / this.view.scale
|
|
|
+ }
|
|
|
+ t.moveable = true;
|
|
|
+ this.addItem(t)
|
|
|
+ this.Nodes.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
+ graphItemList.push(t)
|
|
|
+ // }
|
|
|
+ // 加到node
|
|
|
+ // 加命令
|
|
|
+ })
|
|
|
parserData.imageLegendList.forEach(t => {
|
|
|
if (this.view) {
|
|
|
t.pos.x += 10 / this.view.scale
|
|
@@ -1311,6 +1424,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Nodes.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.imageMarkerList.forEach(t => {
|
|
@@ -1321,6 +1435,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Markers.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.lineMarkerList.forEach(t => {
|
|
@@ -1331,6 +1446,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Markers.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.textMarkerList.forEach(t => {
|
|
@@ -1341,6 +1457,7 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Markers.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
parserData.relationList.forEach(t => {
|
|
@@ -1352,19 +1469,35 @@ export class EditScence extends SGraphScene {
|
|
|
t.moveable = true;
|
|
|
this.addItem(t)
|
|
|
this.Relations.push(t);
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
graphItemList.push(t)
|
|
|
})
|
|
|
this.scenceUpdate(this);
|
|
|
if (graphItemList.length) {
|
|
|
- this.AddListCommand(graphItemList)
|
|
|
+ this.AddListCommand(graphItemList);
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /** 同类选中 */
|
|
|
+ selectSimilar() {
|
|
|
+ let typeList = [...new Set(this.selectContainer.itemList.map(item => { return item.data.GraphElementId }).filter(d => { return d }))];
|
|
|
+ this.selectContainer.clear();
|
|
|
+ this.Nodes.forEach(item => {
|
|
|
+ if (typeList.indexOf(item.data.GraphElementId) != -1)
|
|
|
+ this.selectContainer.toggleItem(item);
|
|
|
+ });
|
|
|
+ this.Relations.forEach(item => {
|
|
|
+ if (typeList.indexOf(item.data.GraphElementId) != -1)
|
|
|
+ this.selectContainer.toggleItem(item);
|
|
|
+ });
|
|
|
+ document.getElementById(`canvas`).focus();
|
|
|
+ }
|
|
|
+
|
|
|
/** 类型转换 */
|
|
|
- itemToType(obj:SGraphItem):String{
|
|
|
+ itemToType(obj: SGraphItem): String {
|
|
|
if (obj instanceof STextMarkerItem) {
|
|
|
return 'Markers'
|
|
|
} else if (obj instanceof SImageMarkerItem) {
|
|
@@ -1393,6 +1526,10 @@ export class EditScence extends SGraphScene {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
onDoubleClick(event: SMouseEvent): boolean {
|
|
|
+ // 如果为复制状态则双击失效
|
|
|
+ if (this.isCopy == "true") {
|
|
|
+ return true
|
|
|
+ }
|
|
|
if (!this.isEditStatus) {
|
|
|
return true
|
|
|
} else {
|
|
@@ -1416,7 +1553,7 @@ export class EditScence extends SGraphScene {
|
|
|
if (this.grabItem.status == SItemStatus.Create) {
|
|
|
if (this.grabItem.pointList.length) {
|
|
|
this.grabItem.endAnchor = anc;
|
|
|
- anc.parent ?.connect('changePos', this.grabItem, this.grabItem.changePos)
|
|
|
+ anc.parent?.connect('changePos', this.grabItem, this.grabItem.changePos)
|
|
|
}
|
|
|
this.grabItem.anchor2ID = anc.id
|
|
|
this.grabItem.node2Id = anc.parent.id
|
|
@@ -1510,7 +1647,7 @@ export class EditScence extends SGraphScene {
|
|
|
if (this.grabItem.status == SItemStatus.Create) {
|
|
|
// 点击在item内、创建状态且端点列表不为空时将直线结束端点和item绑定
|
|
|
if (this.grabItem.line.length) {
|
|
|
- if (this.grabItem.startItem ?.id == item.id) {
|
|
|
+ if (this.grabItem.startItem?.id == item.id) {
|
|
|
this.grabItem.endItem = null;
|
|
|
} else {
|
|
|
this.grabItem.endItem = item;
|
|
@@ -1524,7 +1661,7 @@ export class EditScence extends SGraphScene {
|
|
|
// 点击在item内、编辑状态且点击的为结束端点时
|
|
|
if (this.grabItem.curIndex == 1) {
|
|
|
// 直线关联的起始item是直线结束端点所在的item时,不吸附在点击item中心并将直线关联的结束item置为null
|
|
|
- if (this.grabItem.startItem ?.id == item.id) {
|
|
|
+ if (this.grabItem.startItem?.id == item.id) {
|
|
|
this.grabItem.endItem = null;
|
|
|
} else {// 反正吸附,关联
|
|
|
this.grabItem.endItem = item;
|
|
@@ -1532,7 +1669,7 @@ export class EditScence extends SGraphScene {
|
|
|
item.connect('onMove', this.grabItem, this.grabItem.changePos);
|
|
|
}
|
|
|
} else if (this.grabItem.curIndex == 0) {
|
|
|
- if (this.grabItem.endItem ?.id == item.id) {
|
|
|
+ if (this.grabItem.endItem?.id == item.id) {
|
|
|
this.grabItem.startItem = null;
|
|
|
} else {
|
|
|
this.grabItem.startItem = item;
|
|
@@ -1606,7 +1743,7 @@ export class EditScence extends SGraphScene {
|
|
|
this.Nodes.forEach(image => {
|
|
|
// image.showAnchor = false;
|
|
|
if (image.anchorList && image.anchorList.length) {
|
|
|
- if(image.img && image.img instanceof SImageItem) {
|
|
|
+ if (image.img && image.img instanceof SImageItem) {
|
|
|
let scenePoint = image.img.mapFromScene(event.x, event.y);
|
|
|
if (image.img.contains(scenePoint.x, scenePoint.y)) {
|
|
|
let anchor = image.anchorList[0]
|
|
@@ -1627,8 +1764,8 @@ export class EditScence extends SGraphScene {
|
|
|
len = dis;
|
|
|
}
|
|
|
}
|
|
|
- // let scenePoint = image.mapFromScene(event.x, event.y);
|
|
|
- // if (image.contains(scenePoint.x, scenePoint.y)) {
|
|
|
+ // let scenePoint = image.mapFromScene(event.x, event.y);
|
|
|
+ // if (image.contains(scenePoint.x, scenePoint.y)) {
|
|
|
// image.anchorList.forEach(anchor => {
|
|
|
// let anchorPoint = anchor.mapToScene(0, 0);
|
|
|
// let dis = SMathUtil.pointDistance(
|
|
@@ -1637,13 +1774,13 @@ export class EditScence extends SGraphScene {
|
|
|
// anchorPoint.x,
|
|
|
// anchorPoint.y
|
|
|
// );
|
|
|
- // if (len < 0) {
|
|
|
- // len = anchor.sceneDis;
|
|
|
- // }
|
|
|
- // if (dis < len) {
|
|
|
- // minAnchor = anchor;
|
|
|
- // len = dis;
|
|
|
- // }
|
|
|
+ // if (len < 0) {
|
|
|
+ // len = anchor.sceneDis;
|
|
|
+ // }
|
|
|
+ // if (dis < len) {
|
|
|
+ // minAnchor = anchor;
|
|
|
+ // len = dis;
|
|
|
+ // }
|
|
|
// })
|
|
|
}
|
|
|
}
|
|
@@ -1863,10 +2000,10 @@ export class EditScence extends SGraphScene {
|
|
|
|
|
|
/**
|
|
|
* 图标旋转更新角度
|
|
|
- *
|
|
|
+ *
|
|
|
* @param ang 旋转角度
|
|
|
*/
|
|
|
- updateItemAng(ang: number) :void{
|
|
|
+ updateItemAng(ang: number): void {
|
|
|
if (this.focusItem) {
|
|
|
if (this.focusItem instanceof SImageLegendItem) {
|
|
|
const oldMsg = this.focusItem.img.rotate;
|
|
@@ -1878,13 +2015,125 @@ export class EditScence extends SGraphScene {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 框选
|
|
|
*/
|
|
|
addRectSelect(event: SMouseEvent) {
|
|
|
let point = new SPoint(event.x, event.y);
|
|
|
let rect = new SRectSelectItem(null, point);
|
|
|
this.addItem(rect);
|
|
|
- this.rectSelectItem = rect;
|
|
|
+ this.grabItem = rect;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算框选交集
|
|
|
+ */
|
|
|
+ groupSelect(ctrl: boolean) {
|
|
|
+ if (!ctrl) {
|
|
|
+ this.selectContainer.clear()
|
|
|
+ }
|
|
|
+ if (this.grabItem instanceof SRectSelectItem) {
|
|
|
+ let left,top,w,h;
|
|
|
+ if(this.grabItem.startPoint.x < this.grabItem.endPoint.x) {
|
|
|
+ left = this.grabItem.startPoint.x;
|
|
|
+ w = this.grabItem.endPoint.x - this.grabItem.startPoint.x
|
|
|
+ } else {
|
|
|
+ left = this.grabItem.endPoint.x
|
|
|
+ w = this.grabItem.startPoint.x - this.grabItem.endPoint.x
|
|
|
+ }
|
|
|
+ if (this.grabItem.startPoint.y < this.grabItem.endPoint.y) {
|
|
|
+ top = this.grabItem.startPoint.y;
|
|
|
+ h = this.grabItem.endPoint.y - this.grabItem.startPoint.y
|
|
|
+ } else {
|
|
|
+ top = this.grabItem.endPoint.y;
|
|
|
+ h = this.grabItem.startPoint.y - this.grabItem.endPoint.y
|
|
|
+ }
|
|
|
+ const rect = new SRect(left,top,w,h);
|
|
|
+ this.arrToSelect(this.Nodes, rect)
|
|
|
+ this.arrToSelect(this.Markers, rect)
|
|
|
+ this.arrToSelect(this.Relations, rect)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 选中item:框选
|
|
|
+ */
|
|
|
+ private arrToSelect(arr: SGraphItem[], rect: SRect) {
|
|
|
+ if (Array.isArray(arr) && arr.length) {
|
|
|
+ arr.forEach(t => {
|
|
|
+ if (t.parent) {
|
|
|
+ let temp = t.boundingRect();
|
|
|
+ let lefttop = t.mapToScene(temp.left, temp.top)
|
|
|
+ let rightbottom = t.mapToScene(temp.right, temp.bottom)
|
|
|
+ let r = new SRect(lefttop, rightbottom)
|
|
|
+ if (rect.isIn(r)) {
|
|
|
+ this.selectContainer.toggleItem(t)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 修改item样式
|
|
|
+ */
|
|
|
+ changeLengendItem(legend: any) {
|
|
|
+ if (this.focusItem) {
|
|
|
+ // 如果更改得item类相同,则不需要
|
|
|
+ if (this.focusItem.data.GraphElementId == legend.Id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const OutLine: any = []
|
|
|
+ if (this.focusItem.pointList) {
|
|
|
+ this.focusItem.pointList.forEach(item => {
|
|
|
+ OutLine.push({ X: item.x, Y: item.y })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ const SubType = legend.SubType ? legend.SubType : '';
|
|
|
+ const LegendData: Legend = {
|
|
|
+ ID: uuid(),
|
|
|
+ Name: this.focusItem.name,
|
|
|
+ GraphElementType: legend.Type,
|
|
|
+ Num: 1,
|
|
|
+ GraphElementId: legend.Id,
|
|
|
+ AttachObjectIds: this.focusItem.data.AttachObjectIds,
|
|
|
+ Type: "Zone",
|
|
|
+ Pos: { X: this.focusItem.data.Pos.X, Y: this.focusItem.data.Pos.Y },
|
|
|
+ OutLine: OutLine,
|
|
|
+ SubType: SubType,
|
|
|
+ Properties: {
|
|
|
+ IconUrl: '/serve/topology-wanda/Picture/query/' + legend.Url,
|
|
|
+ StrokeColor: legend.Color,
|
|
|
+ FillColor: legend.FillColor,
|
|
|
+ LineDash: legend.LineDash,
|
|
|
+ LineWidth: legend.LineWidth,
|
|
|
+ font: 14,
|
|
|
+ color: "#1F2429",
|
|
|
+ TextPos: { X: this.focusItem.data.Properties.TextPos.X, Y: this.focusItem.data.Properties.TextPos.Y },
|
|
|
+ InfoTypeId: legend.InfoTypeId.length ? legend.InfoTypeId : [],
|
|
|
+ InfoSystemId: legend.InfoSystemId ? legend.InfoSystemId : '',
|
|
|
+ InfoLocal: legend.InfoLocal.length ? legend.InfoLocal : [],
|
|
|
+ lengendName: legend.Name, //图例名称
|
|
|
+ },
|
|
|
+ }
|
|
|
+ let Polylines = null;
|
|
|
+ if (SubType == "SCPZ") {
|
|
|
+ Polylines = new SSCPZZoneLegendItem(null, LegendData);
|
|
|
+ } else if (SubType == "FHFQ") {
|
|
|
+ Polylines = new SFHFQZoneLegendItem(null, LegendData);
|
|
|
+ } else if (SubType == "CUSTOM") {
|
|
|
+ Polylines = new SCustomLegendItem(null, LegendData);
|
|
|
+ } else {
|
|
|
+ Polylines = new SZoneLegendItem(null, LegendData);
|
|
|
+ }
|
|
|
+ Polylines.selectable = true;
|
|
|
+ //设置状态
|
|
|
+ Polylines.status = SItemStatus.Normal;
|
|
|
+ // Polylines.moveable = true;
|
|
|
+ this.addItem(Polylines);
|
|
|
+ Polylines.connect("finishCreated", this, this.finishCreated);
|
|
|
+ // 删除item
|
|
|
+ this.deleiteItem();
|
|
|
+ this.grabItem = Polylines;
|
|
|
+ this.focusItem = Polylines;
|
|
|
+ }
|
|
|
}
|
|
|
}
|