Sfoglia il codice sorgente

修改坐标问题

haojianlong 4 anni fa
parent
commit
b45199e223
1 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 6 3
      src/components/mapClass/EditScence.ts

+ 6 - 3
src/components/mapClass/EditScence.ts

@@ -1,6 +1,6 @@
 import { SMouseEvent, SUndoStack } from "@saga-web/base";
 import { SGraphScene, SGraphLayoutType, SAnchorItem } from '@saga-web/graph/lib';
-import { SFloorParser, SLineItem, SPolylineItem, SItemStatus, ItemOrder, STooltipItem, ItemColor,Transparency } from "@saga-web/big";
+import { SFloorParser, SLineItem, SPolylineItem, SItemStatus, ItemOrder, STooltipItem, ItemColor,Transparency, SPolygonItem } from "@saga-web/big";
 import { SGraphItem, SLineStyle, SGraphPropertyCommand, SImageItem, STextItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate, SGraphAddCommand } from "@saga-web/graph/lib";
 import { SGraphAddListCommand } from "./SGraphAddListCommand"
 import { SGraphDeleteCommand } from "./SGraphDeleteCommand"
@@ -598,8 +598,11 @@ export class EditScence extends SGraphScene {
             let p = this.focusItem.mapFromScene(x, y)
             // newx - oldx = newleft - oldleft
             // 要求的值(新的x坐标) - 旧的x坐标 = 新的左边界(用户输入的值) - 旧的左边界
-            this.focusItem.x = p.x - this.focusItem.boundingRect().left + this.focusItem.x;
-            this.focusItem.y = p.y - this.focusItem.boundingRect().top + this.focusItem.y;
+            this.focusItem.x = (p.x - this.focusItem.boundingRect().left)*this.focusItem.inverseScale + this.focusItem.x;
+            this.focusItem.y = (p.y - this.focusItem.boundingRect().top)*this.focusItem.inverseScale + this.focusItem.y;
+            if(this.focusItem instanceof SPolylineItem || this.focusItem instanceof SPolygonItem || this.focusItem instanceof SLineItem){
+                this.focusItem.moveToOrigin(this.focusItem.x, this.focusItem.y)
+            }
         }
     }