|
@@ -45,6 +45,13 @@ export class EditScence extends SGraphScene {
|
|
|
this.view.update();
|
|
|
}
|
|
|
};
|
|
|
+ /** 绘制区域时 是否为点选 */
|
|
|
+ isSelecting: boolean = false;
|
|
|
+
|
|
|
+ /** 是否开启吸附 */
|
|
|
+ isAbsorbing: boolean = false;
|
|
|
+ /** 吸附展示item */
|
|
|
+ highLight: HighlightItem | null = null;
|
|
|
|
|
|
/** 当前选中焦点Item */
|
|
|
focusItem: SGraphItem | null = null;
|
|
@@ -55,10 +62,23 @@ export class EditScence extends SGraphScene {
|
|
|
Markers: any = [];
|
|
|
/** 管线对象 */
|
|
|
Relations: any = [];
|
|
|
+ _isEditStatus: Boolean = true; // 是否可编辑
|
|
|
+ set isEditStatus(bol: Boolean): void {
|
|
|
+ this._isEditStatus = bol;
|
|
|
+ }
|
|
|
+ get isEditStatus(): Boolean {
|
|
|
+ return this._isEditStatus
|
|
|
+ }
|
|
|
constructor() {
|
|
|
super();
|
|
|
// // 选择绑定选额item事件
|
|
|
this.selectContainer.connect("listChange", this, this.listChange);
|
|
|
+ ItemColor.spaceColor = new SColor("#A4ABB22B")
|
|
|
+ ItemColor.wallColor = new SColor("#A7AEB3FF")
|
|
|
+ ItemColor.columnColor = new SColor("#A7AEB3FF")
|
|
|
+ ItemColor.virtualWallColor = new SColor("#A7AEB3FF")
|
|
|
+ ItemColor.selectColor = new SColor("#84A0BB2B")
|
|
|
+ ItemColor.spaceBorderColor = new SColor("#A7AEB3FF")
|
|
|
}
|
|
|
/** 绘制图例样式 */
|
|
|
_legend: any | null = null;
|
|
@@ -69,6 +89,9 @@ export class EditScence extends SGraphScene {
|
|
|
this._legend = obj;
|
|
|
console.log('aaaaaa', obj)
|
|
|
}
|
|
|
+ /** fid=>item映射,由解析器存入 */
|
|
|
+ fidToItem = {}
|
|
|
+
|
|
|
/**
|
|
|
* 监听变化
|
|
|
* @param obj 变化后的对象
|
|
@@ -92,6 +115,9 @@ export class EditScence extends SGraphScene {
|
|
|
itemType = 'Image'
|
|
|
} else if (obj.itemList[0] instanceof TipelineItem) {
|
|
|
itemType = 'Line'
|
|
|
+ } else if (obj.itemList[0] instanceof SSpaceItem) { // 点选
|
|
|
+ this.clickToAddArea(obj.itemList[0]);
|
|
|
+ return
|
|
|
} else {
|
|
|
itemType = ''
|
|
|
};
|
|
@@ -113,6 +139,13 @@ export class EditScence extends SGraphScene {
|
|
|
* 增加线段item
|
|
|
*/
|
|
|
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 = {
|
|
|
/** ID */
|
|
|
ID: uuid(),
|
|
@@ -124,7 +157,9 @@ export class EditScence extends SGraphScene {
|
|
|
Pos: { X: 0, Y: 0 },
|
|
|
/** 由应用自己定义 */
|
|
|
Properties: {
|
|
|
- Line: [{ X: event.x, Y: event.y }]
|
|
|
+ IconUrl: require("../../assets/images/t-line-hover.png"),
|
|
|
+ Line: [{ X: event.x, Y: event.y }],
|
|
|
+ LineWidth: 2
|
|
|
}
|
|
|
}
|
|
|
const item = new SLineMarkerItem(null, data);
|
|
@@ -132,9 +167,11 @@ export class EditScence extends SGraphScene {
|
|
|
item.zOrder = ItemOrder.lineOrder;
|
|
|
item.selectable = true;
|
|
|
this.addItem(item);
|
|
|
+ this.Markers.push(item);
|
|
|
item.connect("finishCreated", this, this.finishCreated);
|
|
|
this.grabItem = item;
|
|
|
- this.Markers.push(item)
|
|
|
+ this.focusItem = item;
|
|
|
+ this.scenceUpdate(this);
|
|
|
// this.undoStack.push(new SGraphAddCommand(this, item));
|
|
|
// item.connect("onMove", this, this.onItemMove.bind(this));
|
|
|
return true
|
|
@@ -162,17 +199,21 @@ export class EditScence extends SGraphScene {
|
|
|
* 增加管道 lenged
|
|
|
*/
|
|
|
addTipelineItem(event: SMouseEvent): boolean {
|
|
|
+ const anc = this.clickIsAnchor(event);
|
|
|
+ if (anc) {
|
|
|
+ const p = anc.mapToScene(0, 0)
|
|
|
+ anc.isConnected = true;
|
|
|
+ event.x = p.x;
|
|
|
+ event.y = p.y;
|
|
|
+ }
|
|
|
const LegendData: Relation = {
|
|
|
ID: uuid(),
|
|
|
Name: this._legend.Name,
|
|
|
- GraphElementType: this._legend.Type,
|
|
|
- Num: 1,
|
|
|
GraphElementId: this._legend.Id,
|
|
|
- AttachObjectIds: [],
|
|
|
- Type: "Line",
|
|
|
PointList: [{ X: event.x, Y: event.y }],
|
|
|
- LineType: 0,
|
|
|
+ LineType: "Line",
|
|
|
Properties: {
|
|
|
+ IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
|
|
|
LineDash: this._legend.LineDash,
|
|
|
LineWidth: this._legend.LineWidth,
|
|
|
Color: this._legend.Color,
|
|
@@ -190,6 +231,14 @@ export class EditScence extends SGraphScene {
|
|
|
// this.undoStack.push(new SGraphAddCommand(this, item));
|
|
|
this.grabItem = item;
|
|
|
this.focusItem = item;
|
|
|
+ // 起始锚点
|
|
|
+ item.startAnchor = anc;
|
|
|
+ if (anc) {
|
|
|
+ anc.parent ?.connect('changePos', item, item.changePos)
|
|
|
+ item.anchor1ID = anc.id;
|
|
|
+ item.node1Id = anc.parent.id;
|
|
|
+ }
|
|
|
+ this.scenceUpdate(this);
|
|
|
return true
|
|
|
}
|
|
|
|
|
@@ -197,8 +246,7 @@ export class EditScence extends SGraphScene {
|
|
|
* 增加多边形item lenged
|
|
|
*/
|
|
|
addPolygonItem(event: SMouseEvent): void {
|
|
|
-
|
|
|
- const SubType = this._legend.SubType ? this._legend.SubType : ''
|
|
|
+ const SubType = this._legend.SubType ? this._legend.SubType : '';
|
|
|
const LegendData: Legend = {
|
|
|
ID: uuid(),
|
|
|
Name: this._legend.Name,
|
|
@@ -211,6 +259,7 @@ export class EditScence extends SGraphScene {
|
|
|
OutLine: [{ X: event.x, Y: event.y }],
|
|
|
SubType: SubType,
|
|
|
Properties: {
|
|
|
+ IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
|
|
|
StrokeColor: this._legend.Color,
|
|
|
FillColor: this._legend.FillColor,
|
|
|
LineDash: this._legend.LineDash,
|
|
@@ -234,10 +283,65 @@ export class EditScence extends SGraphScene {
|
|
|
Polylines.zOrder = ItemOrder.polygonOrder;
|
|
|
// Polylines.moveable = true;
|
|
|
this.addItem(Polylines);
|
|
|
+ this.Nodes.push(Polylines);
|
|
|
Polylines.connect("finishCreated", this, this.finishCreated);
|
|
|
this.grabItem = Polylines;
|
|
|
this.focusItem = Polylines;
|
|
|
- this.Nodes.push(Polylines);
|
|
|
+ this.scenceUpdate(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 点选创建区域
|
|
|
+ */
|
|
|
+ clickToAddArea(item: SSpaceItem): void {
|
|
|
+ if (this.cmd != 'Zone') {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.isSelecting && this._legend) {
|
|
|
+ //@ts-ignore
|
|
|
+ item.isExtracted = true
|
|
|
+ const SubType = this._legend.SubType ? this._legend.SubType : '';
|
|
|
+ const LegendData: Legend = {
|
|
|
+ ID: uuid(),
|
|
|
+ Name: this._legend.Name,
|
|
|
+ GraphElementType: this._legend.Type,
|
|
|
+ Num: 1,
|
|
|
+ GraphElementId: this._legend.Id,
|
|
|
+ AttachObjectIds: [],
|
|
|
+ Type: "Zone",
|
|
|
+ Pos: { X: item.x, Y: item.y },
|
|
|
+ OutLine: item.pointArr[0],
|
|
|
+ SubType: SubType,
|
|
|
+ Properties: {
|
|
|
+ IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
|
|
|
+ StrokeColor: this._legend.Color,
|
|
|
+ FillColor: this._legend.FillColor,
|
|
|
+ LineDash: this._legend.LineDash,
|
|
|
+ LineWidth: this._legend.LineWidth,
|
|
|
+ font: 12,
|
|
|
+ color: '',
|
|
|
+ FID: item.data.SourceId,
|
|
|
+ TextPos: { X: item.data.Location.Points[0].X, Y: -item.data.Location.Points[0].Y }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ let Polylines = null;
|
|
|
+ if (SubType == "SCPZ") {
|
|
|
+ Polylines = new SSCPZZoneLegendItem(null, LegendData);
|
|
|
+ } else if (SubType == "FHFQ") {
|
|
|
+ Polylines = new SFHFQZoneLegendItem(null, LegendData);
|
|
|
+ } else {
|
|
|
+ Polylines = new SZoneLegendItem(null, LegendData);
|
|
|
+ }
|
|
|
+ Polylines.selectable = true;
|
|
|
+ //设置状态
|
|
|
+ Polylines.status = SItemStatus.Normal;
|
|
|
+ this.addItem(Polylines);
|
|
|
+ this.Nodes.push(Polylines);
|
|
|
+ Polylines.connect("finishCreated", this, this.finishCreated);
|
|
|
+ this.finishCreated(Polylines)
|
|
|
+ this.focusItem = Polylines;
|
|
|
+ this.scenceUpdate(this);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -256,6 +360,7 @@ export class EditScence extends SGraphScene {
|
|
|
Pos: { X: event.x, Y: event.y },
|
|
|
/** 由应用自己定义 */
|
|
|
Properties: {
|
|
|
+ IconUrl: require(`../../assets/images/t-img-hover.png`),
|
|
|
Url: '',
|
|
|
}
|
|
|
}
|
|
@@ -264,10 +369,11 @@ export class EditScence extends SGraphScene {
|
|
|
item.selectable = true;
|
|
|
item.moveable = true;
|
|
|
this.addItem(item);
|
|
|
+ this.Markers.push(item);
|
|
|
this.grabItem == null;
|
|
|
this.focusItem = item;
|
|
|
this.cmd = 'choice';
|
|
|
- this.Markers.push(item)
|
|
|
+ this.scenceUpdate(this);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -285,9 +391,10 @@ export class EditScence extends SGraphScene {
|
|
|
Pos: { X: event.x, Y: event.y },
|
|
|
/** 由应用自己定义 */
|
|
|
Properties: {
|
|
|
+ IconUrl: require(`../../assets/images/t-text-hover.png`),
|
|
|
Text: '请在右侧属性栏输入文字!',
|
|
|
Color: '',
|
|
|
- Font: 0,
|
|
|
+ Font: 12,
|
|
|
BackgroundColor: ''
|
|
|
}
|
|
|
}
|
|
@@ -297,15 +404,18 @@ export class EditScence extends SGraphScene {
|
|
|
item.moveable = true;
|
|
|
item.zOrder = ItemOrder.textOrder;
|
|
|
this.addItem(item);
|
|
|
- this.grabItem == null
|
|
|
+ this.Markers.push(item);
|
|
|
+ this.grabItem = item;
|
|
|
+ this.focusItem = item;
|
|
|
this.cmd = 'choice';
|
|
|
- this.Markers.push(item)
|
|
|
+ this.scenceUpdate(this);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 增加图标lenged图标
|
|
|
*/
|
|
|
addIconItem(event: SMouseEvent): void {
|
|
|
+ //获取信息工程化相关参数
|
|
|
const LegendData: Legend = {
|
|
|
ID: uuid(),
|
|
|
Name: this._legend.Name,
|
|
@@ -318,23 +428,26 @@ export class EditScence extends SGraphScene {
|
|
|
Rolate: { X: 0, Y: 0, Z: 0 },
|
|
|
Size: { Width: 0, Height: 0 }, // 大小
|
|
|
Properties: {
|
|
|
+ IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
|
|
|
Url: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
|
|
|
Num: 1, // 此num与信息工程化得num无关
|
|
|
- sWidth: 0, //icon 的宽
|
|
|
- sHeight: 0, //icon 的高
|
|
|
- font: 0, //font
|
|
|
- color: '' //字体颜色
|
|
|
+ sWidth: 24, //icon 的宽
|
|
|
+ sHeight: 24, //icon 的高
|
|
|
+ font: 12, //font
|
|
|
+ color: '', //字体颜色
|
|
|
+ GraphCategoryId: this._legend.GraphCategoryId
|
|
|
},
|
|
|
}
|
|
|
const item = new SImageLegendItem(null, LegendData);
|
|
|
- this.grabItem == null
|
|
|
this.cmd = 'choice';
|
|
|
item.selectable = true;
|
|
|
item.moveable = true;
|
|
|
item.zOrder = ItemOrder.markOrder;
|
|
|
- // item.moveTo(event.x, event.y);
|
|
|
this.addItem(item);
|
|
|
this.Nodes.push(item);
|
|
|
+ this.grabItem = item;
|
|
|
+ this.focusItem = item;
|
|
|
+ this.scenceUpdate(this);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -352,6 +465,7 @@ export class EditScence extends SGraphScene {
|
|
|
if (this.focusItem) {
|
|
|
const old = this.focusItem.text;
|
|
|
this.focusItem.text = str;
|
|
|
+ this.scenceUpdate(this);
|
|
|
// this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "text", old, str));
|
|
|
}
|
|
|
}
|
|
@@ -392,7 +506,7 @@ export class EditScence extends SGraphScene {
|
|
|
updatedFontColor(color: string): void {
|
|
|
if (this.focusItem) {
|
|
|
let old = this.focusItem.color;
|
|
|
- this.focusItem.color = color;
|
|
|
+ this.focusItem.color = new SColor(color);
|
|
|
// this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", old, color));
|
|
|
}
|
|
|
}
|
|
@@ -404,10 +518,10 @@ export class EditScence extends SGraphScene {
|
|
|
updatedBorderColor(color: string): void {
|
|
|
if (this.focusItem) {
|
|
|
if (this.focusItem instanceof SZoneLegendItem || this.focusItem instanceof SSCPZZoneLegendItem || this.focusItem instanceof SFHFQZoneLegendItem) {
|
|
|
- this.focusItem.strokeColor = new SColor(color)
|
|
|
+ this.focusItem.strokeColor = new SColor(color);
|
|
|
} else {
|
|
|
// let old = this.focusItem.strokeColor;
|
|
|
- this.focusItem.strokeColor = color;
|
|
|
+ this.focusItem.strokeColor = new SColor(color);
|
|
|
}
|
|
|
// this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", old, color));
|
|
|
}
|
|
@@ -469,7 +583,7 @@ export class EditScence extends SGraphScene {
|
|
|
*/
|
|
|
updatedbackColor(color: string): void {
|
|
|
if (this.focusItem) {
|
|
|
- this.focusItem.backgroundColor = color;
|
|
|
+ this.focusItem.backgroundColor = new SColor(color);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -495,7 +609,7 @@ export class EditScence extends SGraphScene {
|
|
|
} else if (val == 'dotted') {
|
|
|
borderStyle = SLineStyle.Dotted
|
|
|
} else if (val == 'solid') {
|
|
|
- borderStyle = SLineStyle.Soild
|
|
|
+ borderStyle = SLineStyle.Solid
|
|
|
}
|
|
|
this.focusItem.lineStyle = borderStyle;
|
|
|
}
|
|
@@ -507,7 +621,8 @@ export class EditScence extends SGraphScene {
|
|
|
*/
|
|
|
upadataLengedName(val: string): void {
|
|
|
if (this.focusItem && this.focusItem.data) {
|
|
|
- this.focusItem.text = val
|
|
|
+ this.focusItem.text = val;
|
|
|
+ this.scenceUpdate(this);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -517,7 +632,7 @@ export class EditScence extends SGraphScene {
|
|
|
*/
|
|
|
upadatImageNum(num: number): void {
|
|
|
if (this.focusItem && this.focusItem.num) {
|
|
|
- this.focusItem.num = num
|
|
|
+ this.focusItem.num = num;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -527,16 +642,26 @@ export class EditScence extends SGraphScene {
|
|
|
*/
|
|
|
upadatfillColor(fillColor: string): void {
|
|
|
if (this.focusItem && this.focusItem.fillColor) {
|
|
|
- this.focusItem.fillColor = new SColor(fillColor)
|
|
|
+ this.focusItem.fillColor = new SColor(fillColor);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
- * 更改图例说明数量
|
|
|
- * @param num number item数量 (只对icon设备类)
|
|
|
+ * 更改图例说
|
|
|
+ * @param num number
|
|
|
*/
|
|
|
- upadatitemExplain(itemExplain: string): void {
|
|
|
+ upadatitemExplain(ItemExplain: string): void {
|
|
|
+ if (this.focusItem) {
|
|
|
+ this.focusItem.data.Properties.ItemExplain = ItemExplain;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新工程信息化的相关数据
|
|
|
+ * @param AttachObjectIds Array
|
|
|
+ */
|
|
|
+ upadatAttachObjectIds(AttachObjectIds: []): void {
|
|
|
if (this.focusItem) {
|
|
|
- this.focusItem.itemExplain = itemExplain
|
|
|
+ this.focusItem.data.AttachObjectIds = AttachObjectIds;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -545,34 +670,51 @@ export class EditScence extends SGraphScene {
|
|
|
*/
|
|
|
deleiteItem(): void {
|
|
|
if (this.focusItem) {
|
|
|
- this.removeItem(this.focusItem);
|
|
|
- let a = -1
|
|
|
- this.Nodes.forEach((item: any, index: number) => {
|
|
|
- if (item.id == this.focusItem.id) {
|
|
|
- a = index
|
|
|
+ if ((this.focusItem instanceof SZoneLegendItem ||
|
|
|
+ this.focusItem instanceof SSCPZZoneLegendItem ||
|
|
|
+ this.focusItem instanceof SFHFQZoneLegendItem ||
|
|
|
+ this.focusItem instanceof TipelineItem) &&
|
|
|
+ this.focusItem.curIndex != -1
|
|
|
+ ) {
|
|
|
+ this.focusItem.deletePoint(this.focusItem.curIndex);
|
|
|
+ } else {
|
|
|
+ this.removeItem(this.focusItem);
|
|
|
+ let a = -1
|
|
|
+ this.Nodes.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == this.focusItem.id) {
|
|
|
+ a = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (a > -1) {
|
|
|
+ this.Nodes.splice(a, 1);
|
|
|
}
|
|
|
- });
|
|
|
- this.Nodes.splice(a, 1);
|
|
|
- let b = -1;
|
|
|
- this.Markers.forEach((item: any, index: number) => {
|
|
|
- if (item.id == this.focusItem.id) {
|
|
|
- b = index
|
|
|
+ let b = -1;
|
|
|
+ this.Markers.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == this.focusItem.id) {
|
|
|
+ b = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (b > -1) {
|
|
|
+ this.Markers.splice(b, 1);
|
|
|
}
|
|
|
- });
|
|
|
- this.Markers.splice(b, 1);
|
|
|
- let c = -1;
|
|
|
- this.Relations.forEach((item: any, index: number) => {
|
|
|
- if (item.id == this.focusItem.id) {
|
|
|
- c = index
|
|
|
+ let c = -1;
|
|
|
+ this.Relations.forEach((item: any, index: number) => {
|
|
|
+ if (item.id == this.focusItem.id) {
|
|
|
+ c = index
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (c > -1) {
|
|
|
+ this.Relations.splice(c, 1);
|
|
|
}
|
|
|
- });
|
|
|
- this.Relations.splice(c, 1);
|
|
|
- this.focusItem = null;
|
|
|
- }
|
|
|
- if (this.view) {
|
|
|
- this.view.update();
|
|
|
+ this.focusItem = null;
|
|
|
+ if (this.view) {
|
|
|
+ this.view.update();
|
|
|
+ }
|
|
|
+ this.scenceUpdate(this);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ scenceUpdate(scence: any) { }
|
|
|
|
|
|
/**
|
|
|
* 对齐指定item
|
|
@@ -640,7 +782,23 @@ export class EditScence extends SGraphScene {
|
|
|
////////////////////////
|
|
|
// 以下为鼠标键盘操作事件
|
|
|
onMouseDown(event: SMouseEvent): any {
|
|
|
+ if (!this.isEditStatus) {
|
|
|
+ return super.onMouseDown(event);
|
|
|
+ }
|
|
|
+ // 判断是否开启吸附,并且有吸附的点
|
|
|
+ if (
|
|
|
+ this.isAbsorbing &&
|
|
|
+ this.highLight &&
|
|
|
+ this.highLight.visible
|
|
|
+ ) {
|
|
|
+ event.x = this.highLight.point.x;
|
|
|
+ event.y = this.highLight.point.y;
|
|
|
+ }
|
|
|
if (this.grabItem) {
|
|
|
+ if (this.grabItem instanceof TipelineItem) {
|
|
|
+ this.setTipeEndanchor(event)
|
|
|
+ return true;
|
|
|
+ }
|
|
|
return this.grabItem.onMouseDown(event);
|
|
|
}
|
|
|
switch (this.cmd) {
|
|
@@ -654,7 +812,12 @@ export class EditScence extends SGraphScene {
|
|
|
this.addImgItem(event)
|
|
|
break;
|
|
|
case 'Zone':
|
|
|
- this.addPolygonItem(event);
|
|
|
+ if (!this.isSelecting) {
|
|
|
+ this.addPolygonItem(event);
|
|
|
+ } else {
|
|
|
+ // 点选创建区域
|
|
|
+ return super.onMouseDown(event)
|
|
|
+ }
|
|
|
break;
|
|
|
case 'Image':
|
|
|
this.addIconItem(event);
|
|
@@ -667,6 +830,21 @@ export class EditScence extends SGraphScene {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ onMouseMove(event: SMouseEvent): boolean {
|
|
|
+ if (!this.isEditStatus) {
|
|
|
+ return super.onMouseMove(event);
|
|
|
+ }
|
|
|
+ if (this.isAbsorbing) {
|
|
|
+ if (!this.highLight) {
|
|
|
+ this.highLight = new HighlightItem(null);
|
|
|
+ this.addItem(this.highLight);
|
|
|
+ }
|
|
|
+ this.highLight.visible = false;
|
|
|
+ this.absorbSpace(event);
|
|
|
+ }
|
|
|
+ return super.onMouseMove(event)
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 键盘事件
|
|
|
*
|
|
@@ -674,12 +852,292 @@ export class EditScence extends SGraphScene {
|
|
|
* @return boolean
|
|
|
*/
|
|
|
onKeyDown(event: KeyboardEvent): any {
|
|
|
+ if (!this.isEditStatus) {
|
|
|
+ return super.onKeyDown(event);
|
|
|
+ }
|
|
|
if (this.grabItem) {
|
|
|
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") {
|
|
|
// this.cmd = 0
|
|
|
// }
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 鼠标双击事件
|
|
|
+ *
|
|
|
+ * @param event 事件参数
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
+ onDoubleClick(event: SMouseEvent): boolean {
|
|
|
+ if (!this.isEditStatus) {
|
|
|
+ return true
|
|
|
+ }else{
|
|
|
+ return super.onDoubleClick(event);
|
|
|
+ }
|
|
|
+
|
|
|
+ } // Function onDoubleClick()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置结束锚点
|
|
|
+ *
|
|
|
+ */
|
|
|
+ setTipeEndanchor(event: SMouseEvent): void {
|
|
|
+ if (this.grabItem instanceof TipelineItem) {
|
|
|
+ if (this.grabItem.status == SItemStatus.Create) {
|
|
|
+ const anc = this.clickIsAnchor(event);
|
|
|
+ if (anc) {
|
|
|
+ const p = anc.mapToScene(0, 0)
|
|
|
+ anc.isConnected = true;
|
|
|
+ event.x = p.x;
|
|
|
+ event.y = p.y;
|
|
|
+ if (this.grabItem.pointList.length) {
|
|
|
+ this.grabItem.endAnchor = anc;
|
|
|
+ anc.parent ?.connect('changePos', this.grabItem, this.grabItem.changePos)
|
|
|
+ }
|
|
|
+ this.grabItem.anchor2ID = anc.id
|
|
|
+ this.grabItem.node2Id = anc.parent.id
|
|
|
+ this.grabItem.onMouseDown(event)
|
|
|
+ this.grabItem.status = SItemStatus.Normal;
|
|
|
+ this.finishCreated(this.grabItem)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.grabItem.onMouseDown(event)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 划线时点击位置是否是锚点
|
|
|
+ *
|
|
|
+ * @param event 事件
|
|
|
+ * @param len 限制距离
|
|
|
+ * @return 点击的锚点
|
|
|
+ * */
|
|
|
+ clickIsAnchor(event: SMouseEvent): SAnchorItem | null {
|
|
|
+ let minAnchor = null;
|
|
|
+ let len: number = -1;
|
|
|
+ this.Nodes.forEach(image => {
|
|
|
+ if (image.anchorList && image.anchorList.length) {
|
|
|
+ image.anchorList.forEach(anchor => {
|
|
|
+ let anchorPoint = anchor.mapToScene(0, 0);
|
|
|
+ let dis = SMathUtil.pointDistance(
|
|
|
+ event.x,
|
|
|
+ event.y,
|
|
|
+ anchorPoint.x,
|
|
|
+ anchorPoint.y
|
|
|
+ );
|
|
|
+ if (len < 0) {
|
|
|
+ len = anchor.sceneDis;
|
|
|
+ }
|
|
|
+ if (dis < len) {
|
|
|
+ minAnchor = anchor;
|
|
|
+ len = dis;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log('-----------------------')
|
|
|
+ console.log(minAnchor)
|
|
|
+ console.log('-----------------------')
|
|
|
+ return minAnchor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 划线时点击位置是在文本,图片,,区域内
|
|
|
+ *
|
|
|
+ * @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 minX 空间区域
|
|
|
+ * @param minY 空间区域
|
|
|
+ * @param maxX 空间区域
|
|
|
+ * @param maxY 空间区域
|
|
|
+ */
|
|
|
+ static isPointInAbsorbArea(
|
|
|
+ p: SPoint,
|
|
|
+ minX: number,
|
|
|
+ maxX: number,
|
|
|
+ minY: number,
|
|
|
+ maxY: number
|
|
|
+ ): boolean {
|
|
|
+ let rect = new SRect(
|
|
|
+ minX - 1000,
|
|
|
+ minY - 1000,
|
|
|
+ maxX - minX + 2000,
|
|
|
+ maxY - minY + 2000
|
|
|
+ );
|
|
|
+ return rect.contains(p.x, p.y);
|
|
|
+ } // Function isPointInAbsorbArea()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 吸附空间
|
|
|
+ *
|
|
|
+ * @param event 鼠标事件对象
|
|
|
+ * @return boolean 是否找到吸附的对象
|
|
|
+ */
|
|
|
+ absorbSpace(event: SMouseEvent): boolean {
|
|
|
+ if (!this.highLight) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let absorbLen = 1000;
|
|
|
+ if (this.view) {
|
|
|
+ absorbLen = 10 / this.view.scale;
|
|
|
+ }
|
|
|
+ let P = this.absorbSpacePoint(event, absorbLen);
|
|
|
+ if (P.Point) {
|
|
|
+ this.highLight.distance = P.MinDis;
|
|
|
+ this.highLight.point = new SPoint(P.Point.X, -P.Point.Y);
|
|
|
+ this.highLight.visible = true;
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ let L = this.absorbSpaceLine(event, absorbLen);
|
|
|
+ if (L.Line && L.Point) {
|
|
|
+ this.highLight.distance = L.MinDis;
|
|
|
+ this.highLight.point = L.Point;
|
|
|
+ this.highLight.line = L.Line;
|
|
|
+ this.highLight.visible = true;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } // Function absorbSpace()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 吸附空间点
|
|
|
+ *
|
|
|
+ * @param event 鼠标事件对象
|
|
|
+ * @param absorbLen 吸附距离
|
|
|
+ * @return MinDis 吸附的点
|
|
|
+ */
|
|
|
+ absorbSpacePoint(event: SMouseEvent, absorbLen: number): MinDis {
|
|
|
+ let minPointDis = Number.MAX_SAFE_INTEGER;
|
|
|
+ let Point;
|
|
|
+ this.spaceList.map((space): void => {
|
|
|
+ if (
|
|
|
+ EditScence.isPointInAbsorbArea(
|
|
|
+ new SPoint(event.x, event.y),
|
|
|
+ space.minX,
|
|
|
+ space.maxX,
|
|
|
+ space.minY,
|
|
|
+ space.maxY
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ space.data.OutLine.forEach((item): void => {
|
|
|
+ let minDis = SMathUtil.getMinDisPoint(
|
|
|
+ new SPoint(event.x, event.y),
|
|
|
+ item
|
|
|
+ );
|
|
|
+ if (
|
|
|
+ minDis &&
|
|
|
+ minDis.MinDis < absorbLen &&
|
|
|
+ minDis.MinDis < minPointDis
|
|
|
+ ) {
|
|
|
+ minPointDis = minDis.MinDis;
|
|
|
+ Point = minDis.Point;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ MinDis: minPointDis,
|
|
|
+ Point: Point
|
|
|
+ };
|
|
|
+ } // Function absorbSpacePoint()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 吸附空间线
|
|
|
+ *
|
|
|
+ * @param event 鼠标事件对象
|
|
|
+ * @param absorbLen 吸附距离
|
|
|
+ * @return PointToLine 吸附的线
|
|
|
+ */
|
|
|
+ absorbSpaceLine(event: SMouseEvent, absorbLen: number): PointToLine {
|
|
|
+ let minPointDis = Number.MAX_SAFE_INTEGER;
|
|
|
+ let Point, Line;
|
|
|
+ this.spaceList.forEach((space): void => {
|
|
|
+ if (
|
|
|
+ EditScence.isPointInAbsorbArea(
|
|
|
+ new SPoint(event.x, event.y),
|
|
|
+ space.minX,
|
|
|
+ space.maxX,
|
|
|
+ space.minY,
|
|
|
+ space.maxY
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ space.data.OutLine.forEach((item): void => {
|
|
|
+ let minDisLine = SMathUtil.getMinDisLine(
|
|
|
+ new SPoint(event.x, event.y),
|
|
|
+ item
|
|
|
+ );
|
|
|
+ if (
|
|
|
+ minDisLine &&
|
|
|
+ minDisLine.MinDis < absorbLen &&
|
|
|
+ minDisLine.MinDis < minPointDis
|
|
|
+ ) {
|
|
|
+ minPointDis = minDisLine.MinDis;
|
|
|
+ Point = minDisLine.Point;
|
|
|
+ Line = minDisLine.Line;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ MinDis: minPointDis,
|
|
|
+ Point: Point,
|
|
|
+ Line: Line
|
|
|
+ };
|
|
|
+ } // Function absorbSpaceLine()
|
|
|
}
|