|
@@ -60,13 +60,21 @@ export class EditScence extends SGraphScene {
|
|
|
|
|
|
/** 当前选中焦点Item */
|
|
/** 当前选中焦点Item */
|
|
focusItem: SGraphItem | null = null;
|
|
focusItem: SGraphItem | null = null;
|
|
-
|
|
|
|
|
|
+ /** 当前选中焦点ItemList */
|
|
|
|
+ focusItemList:SGraphItem[] | null = null;
|
|
/**图例节点 */
|
|
/**图例节点 */
|
|
Nodes: any = []; // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
|
|
Nodes: any = []; // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
|
|
/**图例节点 */ // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
|
|
/**图例节点 */ // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
|
|
Markers: any = [];
|
|
Markers: any = [];
|
|
/** 管线对象 */
|
|
/** 管线对象 */
|
|
Relations: any = [];
|
|
Relations: any = [];
|
|
|
|
+ _isEditStatus: Boolean = true; // 是否可编辑
|
|
|
|
+ set isEditStatus(bol: Boolean): void {
|
|
|
|
+ this._isEditStatus = bol;
|
|
|
|
+ }
|
|
|
|
+ get isEditStatus(): Boolean {
|
|
|
|
+ return this._isEditStatus
|
|
|
|
+ }
|
|
constructor() {
|
|
constructor() {
|
|
super();
|
|
super();
|
|
// // 选择绑定选额item事件
|
|
// // 选择绑定选额item事件
|
|
@@ -96,7 +104,7 @@ export class EditScence extends SGraphScene {
|
|
*/
|
|
*/
|
|
listChange(obj: any) {
|
|
listChange(obj: any) {
|
|
let itemType: string = 'equipment';
|
|
let itemType: string = 'equipment';
|
|
-
|
|
|
|
|
|
+ this.focusItemList = obj.itemList;
|
|
if (obj.itemList[0] instanceof STextMarkerItem) {
|
|
if (obj.itemList[0] instanceof STextMarkerItem) {
|
|
itemType = 'baseText'
|
|
itemType = 'baseText'
|
|
} else if (obj.itemList[0] instanceof SImageMarkerItem) {
|
|
} else if (obj.itemList[0] instanceof SImageMarkerItem) {
|
|
@@ -122,6 +130,8 @@ export class EditScence extends SGraphScene {
|
|
if (obj.itemList.length == 1) {
|
|
if (obj.itemList.length == 1) {
|
|
// 获取聚焦item
|
|
// 获取聚焦item
|
|
this.focusItem = obj.itemList[0]
|
|
this.focusItem = obj.itemList[0]
|
|
|
|
+ }else{
|
|
|
|
+ this.focusItem = null
|
|
}
|
|
}
|
|
let msg = {
|
|
let msg = {
|
|
itemList: obj.itemList,
|
|
itemList: obj.itemList,
|
|
@@ -137,6 +147,13 @@ export class EditScence extends SGraphScene {
|
|
* 增加线段item
|
|
* 增加线段item
|
|
*/
|
|
*/
|
|
addLine(event: SMouseEvent): boolean {
|
|
addLine(event: SMouseEvent): boolean {
|
|
|
|
+ const clickItem = this.clickIsItem(event);
|
|
|
|
+ if (clickItem) {
|
|
|
|
+ let centerPoint = clickItem.boundingRect().center();
|
|
|
|
+ const p = clickItem.mapToScene(centerPoint.x, centerPoint.y);
|
|
|
|
+ event.x = p.x;
|
|
|
|
+ event.y = p.y;
|
|
|
|
+ }
|
|
const data = {
|
|
const data = {
|
|
/** ID */
|
|
/** ID */
|
|
ID: uuid(),
|
|
ID: uuid(),
|
|
@@ -225,7 +242,7 @@ export class EditScence extends SGraphScene {
|
|
// 起始锚点
|
|
// 起始锚点
|
|
item.startAnchor = anc;
|
|
item.startAnchor = anc;
|
|
if (anc) {
|
|
if (anc) {
|
|
- anc.parent?.connect('changePos', item, item.changePos)
|
|
|
|
|
|
+ anc.parent ?.connect('changePos', item, item.changePos)
|
|
item.anchor1ID = anc.id;
|
|
item.anchor1ID = anc.id;
|
|
item.node1Id = anc.parent.id;
|
|
item.node1Id = anc.parent.id;
|
|
}
|
|
}
|
|
@@ -238,15 +255,13 @@ export class EditScence extends SGraphScene {
|
|
*/
|
|
*/
|
|
addPolygonItem(event: SMouseEvent): void {
|
|
addPolygonItem(event: SMouseEvent): void {
|
|
const SubType = this._legend.SubType ? this._legend.SubType : '';
|
|
const SubType = this._legend.SubType ? this._legend.SubType : '';
|
|
- //获取信息工程化相关参数
|
|
|
|
- const AttachObjectIds = this._legend.InfoLocal ? this._legend.InfoLocal : [];
|
|
|
|
const LegendData: Legend = {
|
|
const LegendData: Legend = {
|
|
ID: uuid(),
|
|
ID: uuid(),
|
|
Name: this._legend.Name,
|
|
Name: this._legend.Name,
|
|
GraphElementType: this._legend.Type,
|
|
GraphElementType: this._legend.Type,
|
|
Num: 1,
|
|
Num: 1,
|
|
GraphElementId: this._legend.Id,
|
|
GraphElementId: this._legend.Id,
|
|
- AttachObjectIds: AttachObjectIds,
|
|
|
|
|
|
+ AttachObjectIds: [],
|
|
Type: "Zone",
|
|
Type: "Zone",
|
|
Pos: { X: event.x, Y: event.y },
|
|
Pos: { X: event.x, Y: event.y },
|
|
OutLine: [{ X: event.x, Y: event.y }],
|
|
OutLine: [{ X: event.x, Y: event.y }],
|
|
@@ -294,14 +309,13 @@ export class EditScence extends SGraphScene {
|
|
//@ts-ignore
|
|
//@ts-ignore
|
|
item.isExtracted = true
|
|
item.isExtracted = true
|
|
const SubType = this._legend.SubType ? this._legend.SubType : '';
|
|
const SubType = this._legend.SubType ? this._legend.SubType : '';
|
|
- const AttachObjectIds = this._legend.InfoLocal ? this._legend.InfoLocal : [];
|
|
|
|
const LegendData: Legend = {
|
|
const LegendData: Legend = {
|
|
ID: uuid(),
|
|
ID: uuid(),
|
|
Name: this._legend.Name,
|
|
Name: this._legend.Name,
|
|
GraphElementType: this._legend.Type,
|
|
GraphElementType: this._legend.Type,
|
|
Num: 1,
|
|
Num: 1,
|
|
GraphElementId: this._legend.Id,
|
|
GraphElementId: this._legend.Id,
|
|
- AttachObjectIds: AttachObjectIds,
|
|
|
|
|
|
+ AttachObjectIds: [],
|
|
Type: "Zone",
|
|
Type: "Zone",
|
|
Pos: { X: item.x, Y: item.y },
|
|
Pos: { X: item.x, Y: item.y },
|
|
OutLine: item.pointArr[0],
|
|
OutLine: item.pointArr[0],
|
|
@@ -409,15 +423,14 @@ export class EditScence extends SGraphScene {
|
|
* 增加图标lenged图标
|
|
* 增加图标lenged图标
|
|
*/
|
|
*/
|
|
addIconItem(event: SMouseEvent): void {
|
|
addIconItem(event: SMouseEvent): void {
|
|
- //获取信息工程化相关参数
|
|
|
|
- const AttachObjectIds = this._legend.InfoLocal ? this._legend.InfoLocal : [];
|
|
|
|
|
|
+ //获取信息工程化相关参数
|
|
const LegendData: Legend = {
|
|
const LegendData: Legend = {
|
|
ID: uuid(),
|
|
ID: uuid(),
|
|
Name: this._legend.Name,
|
|
Name: this._legend.Name,
|
|
GraphElementType: this._legend.Type,
|
|
GraphElementType: this._legend.Type,
|
|
Num: 1,
|
|
Num: 1,
|
|
GraphElementId: this._legend.Id,
|
|
GraphElementId: this._legend.Id,
|
|
- AttachObjectIds: AttachObjectIds,
|
|
|
|
|
|
+ AttachObjectIds: [],
|
|
Pos: { X: event.x, Y: event.y },
|
|
Pos: { X: event.x, Y: event.y },
|
|
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 },
|
|
@@ -430,6 +443,7 @@ export class EditScence extends SGraphScene {
|
|
sHeight: 24, //icon 的高
|
|
sHeight: 24, //icon 的高
|
|
font: 12, //font
|
|
font: 12, //font
|
|
color: '', //字体颜色
|
|
color: '', //字体颜色
|
|
|
|
+ GraphCategoryId: this._legend.GraphCategoryId
|
|
},
|
|
},
|
|
}
|
|
}
|
|
const item = new SImageLegendItem(null, LegendData);
|
|
const item = new SImageLegendItem(null, LegendData);
|
|
@@ -649,10 +663,10 @@ export class EditScence extends SGraphScene {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 更新工程信息化的相关数据
|
|
|
|
- * @param AttachObjectIds Array
|
|
|
|
- */
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 更新工程信息化的相关数据
|
|
|
|
+ * @param AttachObjectIds Array
|
|
|
|
+ */
|
|
upadatAttachObjectIds(AttachObjectIds: []): void {
|
|
upadatAttachObjectIds(AttachObjectIds: []): void {
|
|
if (this.focusItem) {
|
|
if (this.focusItem) {
|
|
this.focusItem.data.AttachObjectIds = AttachObjectIds;
|
|
this.focusItem.data.AttachObjectIds = AttachObjectIds;
|
|
@@ -706,6 +720,46 @@ export class EditScence extends SGraphScene {
|
|
}
|
|
}
|
|
this.scenceUpdate(this);
|
|
this.scenceUpdate(this);
|
|
}
|
|
}
|
|
|
|
+ }else{
|
|
|
|
+ //批量删除
|
|
|
|
+ if(!this.focusItemList){
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.focusItemList.forEach((focusItem)=>{
|
|
|
|
+ this.removeItem(focusItem);
|
|
|
|
+ let a = -1
|
|
|
|
+ this.Nodes.forEach((item: any, index: number) => {
|
|
|
|
+ if (item.id == focusItem.id) {
|
|
|
|
+ a = index
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (a > -1) {
|
|
|
|
+ this.Nodes.splice(a, 1);
|
|
|
|
+ }
|
|
|
|
+ let b = -1;
|
|
|
|
+ this.Markers.forEach((item: any, index: number) => {
|
|
|
|
+ if (item.id == focusItem.id) {
|
|
|
|
+ b = index
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (b > -1) {
|
|
|
|
+ this.Markers.splice(b, 1);
|
|
|
|
+ }
|
|
|
|
+ let c = -1;
|
|
|
|
+ this.Relations.forEach((item: any, index: number) => {
|
|
|
|
+ if (item.id == focusItem.id) {
|
|
|
|
+ c = index
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (c > -1) {
|
|
|
|
+ this.Relations.splice(c, 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.focusItemList = [];
|
|
|
|
+ if (this.view) {
|
|
|
|
+ this.view.update();
|
|
|
|
+ }
|
|
|
|
+ this.scenceUpdate(this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
scenceUpdate(scence: any) { }
|
|
scenceUpdate(scence: any) { }
|
|
@@ -776,6 +830,9 @@ export class EditScence extends SGraphScene {
|
|
////////////////////////
|
|
////////////////////////
|
|
// 以下为鼠标键盘操作事件
|
|
// 以下为鼠标键盘操作事件
|
|
onMouseDown(event: SMouseEvent): any {
|
|
onMouseDown(event: SMouseEvent): any {
|
|
|
|
+ if (!this.isEditStatus) {
|
|
|
|
+ return super.onMouseDown(event);
|
|
|
|
+ }
|
|
// 判断是否开启吸附,并且有吸附的点
|
|
// 判断是否开启吸附,并且有吸附的点
|
|
if (
|
|
if (
|
|
this.isAbsorbing &&
|
|
this.isAbsorbing &&
|
|
@@ -822,6 +879,9 @@ export class EditScence extends SGraphScene {
|
|
}
|
|
}
|
|
|
|
|
|
onMouseMove(event: SMouseEvent): boolean {
|
|
onMouseMove(event: SMouseEvent): boolean {
|
|
|
|
+ if (!this.isEditStatus) {
|
|
|
|
+ return super.onMouseMove(event);
|
|
|
|
+ }
|
|
if (this.isAbsorbing) {
|
|
if (this.isAbsorbing) {
|
|
if (!this.highLight) {
|
|
if (!this.highLight) {
|
|
this.highLight = new HighlightItem(null);
|
|
this.highLight = new HighlightItem(null);
|
|
@@ -840,8 +900,20 @@ export class EditScence extends SGraphScene {
|
|
* @return boolean
|
|
* @return boolean
|
|
*/
|
|
*/
|
|
onKeyDown(event: KeyboardEvent): any {
|
|
onKeyDown(event: KeyboardEvent): any {
|
|
|
|
+ if (!this.isEditStatus) {
|
|
|
|
+ return super.onKeyDown(event);
|
|
|
|
+ }
|
|
if (this.grabItem) {
|
|
if (this.grabItem) {
|
|
this.grabItem.onKeyDown(event);
|
|
this.grabItem.onKeyDown(event);
|
|
|
|
+ if (event.code == "Escape") {
|
|
|
|
+ const item = this.grabItem;
|
|
|
|
+ this.grabItem = null
|
|
|
|
+ this.removeItem(item);
|
|
|
|
+ if (this.view) {
|
|
|
|
+ this.view.update()
|
|
|
|
+ }
|
|
|
|
+ this.setCmd = 'choice'
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// if (event.key == "Enter") {
|
|
// if (event.key == "Enter") {
|
|
// this.cmd = 0
|
|
// this.cmd = 0
|
|
@@ -849,6 +921,22 @@ export class EditScence extends SGraphScene {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 鼠标双击事件
|
|
|
|
+ *
|
|
|
|
+ * @param event 事件参数
|
|
|
|
+ * @return boolean
|
|
|
|
+ */
|
|
|
|
+ onDoubleClick(event: SMouseEvent): boolean {
|
|
|
|
+ if (!this.isEditStatus) {
|
|
|
|
+ return true
|
|
|
|
+ }else{
|
|
|
|
+ return super.onDoubleClick(event);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } // Function onDoubleClick()
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 设置结束锚点
|
|
* 设置结束锚点
|
|
*
|
|
*
|
|
@@ -864,7 +952,7 @@ export class EditScence extends SGraphScene {
|
|
event.y = p.y;
|
|
event.y = p.y;
|
|
if (this.grabItem.pointList.length) {
|
|
if (this.grabItem.pointList.length) {
|
|
this.grabItem.endAnchor = anc;
|
|
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.anchor2ID = anc.id
|
|
this.grabItem.node2Id = anc.parent.id
|
|
this.grabItem.node2Id = anc.parent.id
|
|
@@ -915,6 +1003,49 @@ export class EditScence extends SGraphScene {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 划线时点击位置是在文本,图片,,区域内
|
|
|
|
+ *
|
|
|
|
+ * @param event 事件
|
|
|
|
+ * @return 点击的item
|
|
|
|
+ * */
|
|
|
|
+ clickIsItem(event: SMouseEvent): SGraphItem | null {
|
|
|
|
+ let minIten = null;
|
|
|
|
+ let len: number = -1;
|
|
|
|
+ let itemList = this.Nodes.concat(this.Markers);
|
|
|
|
+ itemList.forEach(item => {
|
|
|
|
+ if (
|
|
|
|
+ item instanceof STextMarkerItem ||
|
|
|
|
+ item instanceof SImageMarkerItem ||
|
|
|
|
+ item instanceof SZoneLegendItem ||
|
|
|
|
+ item instanceof SFHFQZoneLegendItem ||
|
|
|
|
+ item instanceof SSCPZZoneLegendItem
|
|
|
|
+ ) {
|
|
|
|
+ let scenePoint = item.mapFromScene(event.x, event.y);
|
|
|
|
+ if (item.contains(scenePoint.x, scenePoint.y)) {
|
|
|
|
+ let dis = SMathUtil.pointDistance(
|
|
|
|
+ scenePoint.x,
|
|
|
|
+ scenePoint.y,
|
|
|
|
+ item.boundingRect().center().x,
|
|
|
|
+ item.boundingRect().center().y
|
|
|
|
+ );
|
|
|
|
+ if (len < 0) {
|
|
|
|
+ minIten = item;
|
|
|
|
+ len = dis;
|
|
|
|
+ }
|
|
|
|
+ if (dis < len) {
|
|
|
|
+ minIten = item;
|
|
|
|
+ len = dis;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ console.log('-----------------------')
|
|
|
|
+ console.log(minIten)
|
|
|
|
+ console.log('-----------------------')
|
|
|
|
+ return minIten;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 点是否在吸附区域内
|
|
* 点是否在吸附区域内
|
|
*
|
|
*
|
|
* @param p 要判断的点
|
|
* @param p 要判断的点
|