|
@@ -1,4 +1,4 @@
|
|
|
-import { SColor, SLine, SPainter, SPoint } from "@saga-web/draw/lib";
|
|
|
+import { SColor, SLine, SPainter, SPoint, SRect } from "@saga-web/draw";
|
|
|
import { SMouseEvent, SUndoStack } from "@saga-web/base";
|
|
|
import { SItemStatus } from "..";
|
|
|
import { SMathUtil } from "../utils/SMathUtil";
|
|
@@ -15,6 +15,14 @@ import {
|
|
|
* */
|
|
|
|
|
|
export class SPolylineItem extends SGraphItem {
|
|
|
+ /** X坐标最小值 */
|
|
|
+ private minX = Number.MAX_SAFE_INTEGER;
|
|
|
+ /** X坐标最大值 */
|
|
|
+ private maxX = Number.MIN_SAFE_INTEGER;
|
|
|
+ /** Y坐标最小值 */
|
|
|
+ private minY = Number.MAX_SAFE_INTEGER;
|
|
|
+ /** Y坐标最大值 */
|
|
|
+ private maxY = Number.MIN_SAFE_INTEGER;
|
|
|
/** 折点信息 */
|
|
|
pointList: SPoint[] = [];
|
|
|
/** 是否绘制完成 */
|
|
@@ -341,6 +349,42 @@ export class SPolylineItem extends SGraphItem {
|
|
|
} // Function recordAction()
|
|
|
|
|
|
/**
|
|
|
+ * Item对象边界区域
|
|
|
+ *
|
|
|
+ * @return SRect 外接矩阵
|
|
|
+ * */
|
|
|
+ boundingRect(): SRect {
|
|
|
+ if (this.pointList.length) {
|
|
|
+ this.minX = this.pointList[0].x;
|
|
|
+ this.maxX = this.pointList[0].x;
|
|
|
+ this.minY = this.pointList[0].y;
|
|
|
+ this.maxY = this.pointList[0].y;
|
|
|
+ this.pointList.forEach(it => {
|
|
|
+ let x = it.x,
|
|
|
+ y = it.y;
|
|
|
+ if (x < this.minX) {
|
|
|
+ this.minX = x;
|
|
|
+ }
|
|
|
+ if (y < this.minY) {
|
|
|
+ this.minY = y;
|
|
|
+ }
|
|
|
+ if (x > this.maxX) {
|
|
|
+ this.maxX = x;
|
|
|
+ }
|
|
|
+ if (y > this.maxY) {
|
|
|
+ this.maxY = y;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return new SRect(
|
|
|
+ this.minX,
|
|
|
+ this.minY,
|
|
|
+ this.maxX - this.minX,
|
|
|
+ this.maxY - this.minY
|
|
|
+ );
|
|
|
+ } // Function boundingRect()
|
|
|
+
|
|
|
+ /**
|
|
|
* 判断点是否在区域内
|
|
|
*
|
|
|
* @param x
|