|
@@ -29,6 +29,7 @@ import { HighlightItem } from "./items/HighlightItem";
|
|
import { SMathUtil } from "./utils/SMathUtil";
|
|
import { SMathUtil } from "./utils/SMathUtil";
|
|
import { MinDis } from "./types/MinDis";
|
|
import { MinDis } from "./types/MinDis";
|
|
import { PointToLine } from "./types/PointToLine";
|
|
import { PointToLine } from "./types/PointToLine";
|
|
|
|
+import { RectSelectItem } from "./items/RectSelectItem";
|
|
|
|
|
|
/**
|
|
/**
|
|
* 划分业务空间
|
|
* 划分业务空间
|
|
@@ -53,7 +54,7 @@ export class DivideFloorScene extends FloorScene {
|
|
/** 业务空间list */
|
|
/** 业务空间list */
|
|
zoneList: ZoneItem[] = [];
|
|
zoneList: ZoneItem[] = [];
|
|
|
|
|
|
- /** 业务空间是否可选 */
|
|
|
|
|
|
+ /** 业务空间是否可选 */
|
|
_isZoneSelectable: boolean = true;
|
|
_isZoneSelectable: boolean = true;
|
|
get isZoneSelectable(): boolean {
|
|
get isZoneSelectable(): boolean {
|
|
return this._isZoneSelectable;
|
|
return this._isZoneSelectable;
|
|
@@ -65,12 +66,15 @@ export class DivideFloorScene extends FloorScene {
|
|
this._isZoneSelectable = v;
|
|
this._isZoneSelectable = v;
|
|
this.zoneList.map((t: ZoneItem) => {
|
|
this.zoneList.map((t: ZoneItem) => {
|
|
t.selectable = this._isZoneSelectable;
|
|
t.selectable = this._isZoneSelectable;
|
|
|
|
+ if (!t.selectable) {
|
|
|
|
+ t.selected = false;
|
|
|
|
+ }
|
|
return t;
|
|
return t;
|
|
});
|
|
});
|
|
} // Set isZoneSelectable
|
|
} // Set isZoneSelectable
|
|
|
|
|
|
/** 高亮item */
|
|
/** 高亮item */
|
|
- hightLight: HighlightItem = new HighlightItem(null);
|
|
|
|
|
|
+ highLight: HighlightItem = new HighlightItem(null);
|
|
/** 是否开启吸附 */
|
|
/** 是否开启吸附 */
|
|
private _isAbsorbing: boolean = false;
|
|
private _isAbsorbing: boolean = false;
|
|
get isAbsorbing(): boolean {
|
|
get isAbsorbing(): boolean {
|
|
@@ -79,6 +83,18 @@ export class DivideFloorScene extends FloorScene {
|
|
set isAbsorbing(v: boolean) {
|
|
set isAbsorbing(v: boolean) {
|
|
this._isAbsorbing = v;
|
|
this._isAbsorbing = v;
|
|
} // Set isAbsorbing
|
|
} // Set isAbsorbing
|
|
|
|
+
|
|
|
|
+ /** 矩形选择区域 */
|
|
|
|
+ rectSelectItem: RectSelectItem | null = null;
|
|
|
|
+ /** 是否开启用户选择 */
|
|
|
|
+ _isRectSelection: boolean = false;
|
|
|
|
+ get isRectSelection(): boolean {
|
|
|
|
+ return this._isRectSelection;
|
|
|
|
+ } // Get isRectSelection
|
|
|
|
+ set isRectSelection(v: boolean) {
|
|
|
|
+ this._isRectSelection = v;
|
|
|
|
+ } // Set isRectSelection
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 构造函数
|
|
* 构造函数
|
|
*
|
|
*
|
|
@@ -86,7 +102,7 @@ export class DivideFloorScene extends FloorScene {
|
|
*/
|
|
*/
|
|
constructor() {
|
|
constructor() {
|
|
super();
|
|
super();
|
|
- this.addItem(this.hightLight);
|
|
|
|
|
|
+ this.addItem(this.highLight);
|
|
} // Constructor
|
|
} // Constructor
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -122,20 +138,35 @@ export class DivideFloorScene extends FloorScene {
|
|
* @return boolean
|
|
* @return boolean
|
|
*/
|
|
*/
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
- if (this.isMarking && event.buttons == 1) {
|
|
|
|
- // 判断是否开启吸附,并且有吸附的点
|
|
|
|
- if (this.isAbsorbing && this.hightLight.visible) {
|
|
|
|
- event.x = this.hightLight.point.x;
|
|
|
|
- event.y = this.hightLight.point.y;
|
|
|
|
- }
|
|
|
|
- if (this.sceneMark) {
|
|
|
|
- this.sceneMark.onMouseDown(event);
|
|
|
|
|
|
+ if (event.buttons == 1) {
|
|
|
|
+ if (this.isMarking) {
|
|
|
|
+ // 判断是否开启吸附,并且有吸附的点
|
|
|
|
+ if (this.isAbsorbing && this.highLight.visible) {
|
|
|
|
+ event.x = this.highLight.point.x;
|
|
|
|
+ event.y = this.highLight.point.y;
|
|
|
|
+ }
|
|
|
|
+ if (this.sceneMark) {
|
|
|
|
+ this.sceneMark.onMouseDown(event);
|
|
|
|
+ } else {
|
|
|
|
+ let point = new SPoint(event.x, event.y);
|
|
|
|
+ let sceneMark = new SceneMarkItem(null, point);
|
|
|
|
+ this.addItem(sceneMark);
|
|
|
|
+ this.sceneMark = sceneMark;
|
|
|
|
+ this.grabItem = sceneMark;
|
|
|
|
+ }
|
|
|
|
+ } else if (this.isRectSelection) {
|
|
|
|
+ if (this.rectSelectItem) {
|
|
|
|
+ this.isRectSelection = false;
|
|
|
|
+ this.removeItem(this.rectSelectItem);
|
|
|
|
+ this.rectSelectItem = null;
|
|
|
|
+ } else {
|
|
|
|
+ let point = new SPoint(event.x, event.y);
|
|
|
|
+ let rect = new RectSelectItem(null, point);
|
|
|
|
+ this.addItem(rect);
|
|
|
|
+ this.rectSelectItem = rect;
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- let point = new SPoint(event.x, event.y);
|
|
|
|
- let sceneMark = new SceneMarkItem(null, point);
|
|
|
|
- this.addItem(sceneMark);
|
|
|
|
- this.sceneMark = sceneMark;
|
|
|
|
- this.grabItem = sceneMark;
|
|
|
|
|
|
+ super.onMouseDown(event);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
super.onMouseDown(event);
|
|
super.onMouseDown(event);
|
|
@@ -150,9 +181,32 @@ export class DivideFloorScene extends FloorScene {
|
|
* @return boolean
|
|
* @return boolean
|
|
*/
|
|
*/
|
|
onMouseUp(event: SMouseEvent): boolean {
|
|
onMouseUp(event: SMouseEvent): boolean {
|
|
|
|
+ if (this.rectSelectItem) {
|
|
|
|
+ this.isRectSelection = false;
|
|
|
|
+ this.removeItem(this.rectSelectItem);
|
|
|
|
+ this.rectSelectItem = null;
|
|
|
|
+ }
|
|
return false;
|
|
return false;
|
|
} // Function onMouseUp()
|
|
} // Function onMouseUp()
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 吸附空间
|
|
|
|
+ *
|
|
|
|
+ * @param event 鼠标事件对象
|
|
|
|
+ */
|
|
|
|
+ onMouseMove(event: SMouseEvent): boolean {
|
|
|
|
+ if (this.rectSelectItem) {
|
|
|
|
+ this.rectSelectItem.onMouseMove(event);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ super.onMouseMove(event);
|
|
|
|
+ this.highLight.visible = false;
|
|
|
|
+ if (this.isAbsorbing) {
|
|
|
|
+ this.absorbSpace(event);
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ } // Function onMouseMove
|
|
|
|
+
|
|
/***
|
|
/***
|
|
* 键盘按下事件
|
|
* 键盘按下事件
|
|
*
|
|
*
|
|
@@ -229,34 +283,6 @@ export class DivideFloorScene extends FloorScene {
|
|
} // Function clearZoneSelection
|
|
} // Function clearZoneSelection
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 切换业务空间
|
|
|
|
- *
|
|
|
|
- * @param zoneitem 需要隐藏的业务空间
|
|
|
|
- */
|
|
|
|
- changeSelectZone(zoneitem: ZoneItem): void {
|
|
|
|
- this.zoneList.map(zone => {
|
|
|
|
- zone.selected = false;
|
|
|
|
- zone.unselectFlag = true;
|
|
|
|
- return zone;
|
|
|
|
- });
|
|
|
|
- zoneitem.visible = false;
|
|
|
|
- } // Function changeSelectZone
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 吸附空间
|
|
|
|
- *
|
|
|
|
- * @param event 鼠标事件对象
|
|
|
|
- */
|
|
|
|
- onMouseMove(event: SMouseEvent): boolean {
|
|
|
|
- super.onMouseMove(event);
|
|
|
|
- this.hightLight.visible = false;
|
|
|
|
- if (this.isAbsorbing) {
|
|
|
|
- this.absorbSpace(event);
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- } // Function onMouseMove
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
* 吸附空间
|
|
* 吸附空间
|
|
*
|
|
*
|
|
* @param event 鼠标事件对象
|
|
* @param event 鼠标事件对象
|
|
@@ -268,16 +294,16 @@ export class DivideFloorScene extends FloorScene {
|
|
}
|
|
}
|
|
let P = this.absorbPoint(event, absorbLen);
|
|
let P = this.absorbPoint(event, absorbLen);
|
|
if (P.Point) {
|
|
if (P.Point) {
|
|
- this.hightLight.distance = P.MinDis;
|
|
|
|
- this.hightLight.point = new SPoint(P.Point.X, -P.Point.Y);
|
|
|
|
- this.hightLight.visible = true;
|
|
|
|
|
|
+ this.highLight.distance = P.MinDis;
|
|
|
|
+ this.highLight.point = new SPoint(P.Point.X, -P.Point.Y);
|
|
|
|
+ this.highLight.visible = true;
|
|
} else {
|
|
} else {
|
|
let L = this.absorbLine(event, absorbLen);
|
|
let L = this.absorbLine(event, absorbLen);
|
|
if (L.Line && L.Point) {
|
|
if (L.Line && L.Point) {
|
|
- this.hightLight.distance = L.MinDis;
|
|
|
|
- this.hightLight.point = L.Point;
|
|
|
|
- this.hightLight.line = L.Line;
|
|
|
|
- this.hightLight.visible = true;
|
|
|
|
|
|
+ this.highLight.distance = L.MinDis;
|
|
|
|
+ this.highLight.point = L.Point;
|
|
|
|
+ this.highLight.line = L.Line;
|
|
|
|
+ this.highLight.visible = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} // Function absorbSpace
|
|
} // Function absorbSpace
|
|
@@ -394,4 +420,6 @@ export class DivideFloorScene extends FloorScene {
|
|
};
|
|
};
|
|
return minPointLine;
|
|
return minPointLine;
|
|
} // Function absorbLine
|
|
} // Function absorbLine
|
|
|
|
+
|
|
|
|
+ /** */
|
|
} // Class DivideFloorScene
|
|
} // Class DivideFloorScene
|