Browse Source

绘制矩形 点是反的不绘制; path绘制多边形bug修改; 选择器样式调整

haojianlong 4 years ago
parent
commit
f5b4ab1e3a

+ 8 - 2
persagy-web-draw/src/SPainter.ts

@@ -334,9 +334,15 @@ export class SPainter extends SObject {
         h?: number
     ): void {
         if (x instanceof SRect) {
-            this.engine.drawRect(x);
+            // 判断2点是否有效
+            if (x.x < x.right && x.y < x.bottom) {
+                this.engine.drawRect(x);
+            }
         } else if (x instanceof SPoint && y instanceof SPoint) {
-            this.engine.drawRect(new SRect(x, y));
+            // 判断2点是否有效
+            if (x.x < y.x && x.y < y.y) {
+                this.engine.drawRect(new SRect(x, y));
+            }
         } else if (x instanceof SPoint && y instanceof SSize) {
             this.engine.drawRect(new SRect(x, y));
         } else {

+ 1 - 1
persagy-web-draw/src/SPath.ts

@@ -197,7 +197,7 @@ export class SPath {
      * @param   pList   点集数组
      */
     polygon(pList: SPoint[]): void {
-        if (pList.length > 3) {
+        if (pList.length > 2) {
             this.addCommand("M", pList[0].x, pList[0].y);
             for (let i = 1; i < pList.length; i++) {
                 this.addCommand("L", pList[i].x, pList[i].y);

+ 12 - 2
persagy-web-graph/src/SGraphSelectContainer.ts

@@ -86,7 +86,17 @@ export class SGraphSelectContainer extends SGraphItem {
     /** 灵敏度转换为场景长度 */
     private sceneDis: number = 10;
     /** 当前点索引 */
-    private curIndex: number = -1;
+    private _curIndex: number = -1;
+    get curIndex(): number {
+        return this._curIndex;
+    } // get curIndex
+    set curIndex(v: number) {
+        if (v === this._curIndex) {
+            return;
+        }
+        this._curIndex = v;
+        this.update();
+    } // set curIndex
     /** 当前点索引 */
     private curPoint: SPoint | undefined;
 
@@ -723,6 +733,7 @@ export class SGraphSelectContainer extends SGraphItem {
      */
     getNearestPoint(p: SPoint): void {
         let len = this.sceneDis;
+        this.curIndex = -1;
         for (let i = 0; i < this.pointList.length; i++) {
             let dis = SMathUtil.pointDistance(
                 p.x,
@@ -774,7 +785,6 @@ export class SGraphSelectContainer extends SGraphItem {
      * @return  boolean
      */
     onMouseDown(event: SMouseEvent): boolean {
-        this.curIndex = -1;
         if (event.buttons == 1) {
             this.getNearestPoint(new SPoint(event.x, event.y));
             if (this.curIndex < 0) {