|
@@ -144,6 +144,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(),
|
|
@@ -928,6 +935,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 要判断的点
|