|
@@ -169,6 +169,9 @@ export class SPolylineItem extends SGraphItem {
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
this.curIndex = -1;
|
|
this.curIndex = -1;
|
|
this.curPoint = null;
|
|
this.curPoint = null;
|
|
|
|
+ if (event.shiftKey) {
|
|
|
|
+ event = this.compare(event);
|
|
|
|
+ }
|
|
if (event.buttons == 1) {
|
|
if (event.buttons == 1) {
|
|
if (this.status == SItemStatus.Create) {
|
|
if (this.status == SItemStatus.Create) {
|
|
this.addPoint(new SPoint(event.x, event.y));
|
|
this.addPoint(new SPoint(event.x, event.y));
|
|
@@ -200,6 +203,9 @@ export class SPolylineItem extends SGraphItem {
|
|
* @return boolean 是否处理事件
|
|
* @return boolean 是否处理事件
|
|
* */
|
|
* */
|
|
onMouseMove(event: SMouseEvent): boolean {
|
|
onMouseMove(event: SMouseEvent): boolean {
|
|
|
|
+ if (event.shiftKey) {
|
|
|
|
+ event = this.compare(event);
|
|
|
|
+ }
|
|
if (this.status == SItemStatus.Create) {
|
|
if (this.status == SItemStatus.Create) {
|
|
if (this.lastPoint) {
|
|
if (this.lastPoint) {
|
|
this.lastPoint.x = event.x;
|
|
this.lastPoint.x = event.x;
|
|
@@ -371,6 +377,32 @@ export class SPolylineItem extends SGraphItem {
|
|
} // Function findAddPos()
|
|
} // Function findAddPos()
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * shift垂直水平创建或编辑
|
|
|
|
+ *
|
|
|
|
+ * @param event 事件
|
|
|
|
+ * */
|
|
|
|
+ compare(event: SMouseEvent): SMouseEvent {
|
|
|
|
+ if (this.pointList.length) {
|
|
|
|
+ let last = new SPoint(event.x, event.y);
|
|
|
|
+ if (this.status == SItemStatus.Create) {
|
|
|
|
+ last = this.pointList[this.pointList.length - 1];
|
|
|
|
+ } else if (this.status == SItemStatus.Edit) {
|
|
|
|
+ if (this.curIndex > 1) {
|
|
|
|
+ last = this.pointList[this.curIndex - 1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const dx = Math.abs(event.x - last.x);
|
|
|
|
+ const dy = Math.abs(event.y - last.y);
|
|
|
|
+ if (dy > dx) {
|
|
|
|
+ event.x = last.x;
|
|
|
|
+ } else {
|
|
|
|
+ event.y = last.y;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return event;
|
|
|
|
+ } // Function compare()
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 记录相关动作并推入栈中
|
|
* 记录相关动作并推入栈中
|
|
*
|
|
*
|
|
* @param SGraphCommand 相关命令类
|
|
* @param SGraphCommand 相关命令类
|