|
@@ -152,7 +152,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 构造体
|
|
|
- */
|
|
|
+ */
|
|
|
constructor() {
|
|
|
super();
|
|
|
this.zOrder = 9999999;
|
|
@@ -164,7 +164,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* 添加 item 到 list
|
|
|
*
|
|
|
* @param item 当前选中的 item
|
|
|
- */
|
|
|
+ */
|
|
|
addItem(item: SGraphItem): void {
|
|
|
for (let i = 0; i < this.itemList.length; i++) {
|
|
|
if (this.itemList[i] == item) {
|
|
@@ -180,7 +180,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* 清空再添加(事件+复制数组)
|
|
|
*
|
|
|
* @param item 当前选中的 item
|
|
|
- */
|
|
|
+ */
|
|
|
setItem(item: SGraphItem): void {
|
|
|
this.itemList.forEach((t: SGraphItem): void => {
|
|
|
t.selected = false;
|
|
@@ -193,7 +193,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 清空选择对象
|
|
|
- */
|
|
|
+ */
|
|
|
clear(): void {
|
|
|
this.itemList.forEach((t: SGraphItem): void => {
|
|
|
t.selected = false;
|
|
@@ -206,7 +206,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* 切换选择对象
|
|
|
*
|
|
|
* @param item 当前选中的 item
|
|
|
- */
|
|
|
+ */
|
|
|
toggleItem(item: SGraphItem): void {
|
|
|
for (let i = 0; i < this.itemList.length; i++) {
|
|
|
if (this.itemList[i] == item) {
|
|
@@ -231,7 +231,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* 对齐
|
|
|
*
|
|
|
* @param type 对齐方式
|
|
|
- */
|
|
|
+ */
|
|
|
layout(type: SGraphLayoutType): void {
|
|
|
if (this.itemList.length < 2) {
|
|
|
return;
|
|
@@ -271,7 +271,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* 图层操作
|
|
|
*
|
|
|
* @param type 操作类型
|
|
|
- */
|
|
|
+ */
|
|
|
setOrder(type: SOrderSetType): void {
|
|
|
if (this.itemList.length < 1) {
|
|
|
return;
|
|
@@ -297,7 +297,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 左对齐
|
|
|
- */
|
|
|
+ */
|
|
|
private alignLeft(): void {
|
|
|
let standardItem = this.itemList[0];
|
|
|
// 计算第一个外接矩阵左上角坐标在场景中的坐标
|
|
@@ -320,7 +320,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 顶对齐
|
|
|
- */
|
|
|
+ */
|
|
|
private alignTop(): void {
|
|
|
let standardItem = this.itemList[0];
|
|
|
let p = standardItem.mapToScene(
|
|
@@ -340,7 +340,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 右对齐
|
|
|
- */
|
|
|
+ */
|
|
|
private alignRight(): void {
|
|
|
let standardItem = this.itemList[0];
|
|
|
let p = standardItem.mapToScene(
|
|
@@ -361,7 +361,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 底对齐
|
|
|
- */
|
|
|
+ */
|
|
|
private alignBottom(): void {
|
|
|
let standardItem = this.itemList[0];
|
|
|
let p = standardItem.mapToScene(
|
|
@@ -382,7 +382,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 水平居中对齐
|
|
|
- */
|
|
|
+ */
|
|
|
private alignCenter(): void {
|
|
|
// 第一个选中的 item 即为基准对象
|
|
|
let standardItem = this.itemList[0];
|
|
@@ -405,7 +405,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 垂直居中对齐
|
|
|
- */
|
|
|
+ */
|
|
|
private alignMiddle(): void {
|
|
|
// 第一个选中的 item 即为基准对象
|
|
|
let standardItem = this.itemList[0];
|
|
@@ -427,7 +427,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 垂直分布
|
|
|
- */
|
|
|
+ */
|
|
|
private alignVertical(): void {
|
|
|
if (this.itemList.length < 3) {
|
|
|
return;
|
|
@@ -483,7 +483,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 水平分布
|
|
|
- */
|
|
|
+ */
|
|
|
private alignHorizontal(): void {
|
|
|
if (this.itemList.length < 3) {
|
|
|
return;
|
|
@@ -544,7 +544,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
// 然后再取最大值
|
|
|
/**
|
|
|
* 置顶
|
|
|
- */
|
|
|
+ */
|
|
|
private setTop(): void {
|
|
|
const arr: SGraphItem[] = this.sortItemList(this.itemList, true);
|
|
|
// 按顺序 zOrder 增加
|
|
@@ -567,7 +567,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 置底
|
|
|
- */
|
|
|
+ */
|
|
|
private setBottom(): void {
|
|
|
const arr: SGraphItem[] = this.sortItemList(this.itemList, false);
|
|
|
// 按顺序 zOrder 增加
|
|
@@ -590,7 +590,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 下移一层 zOrder 减小
|
|
|
- */
|
|
|
+ */
|
|
|
private setBefore(): void {
|
|
|
const arr: SGraphItem[] = this.sortItemList(this.itemList, false);
|
|
|
arr.forEach(it => {
|
|
@@ -624,7 +624,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 上移一层 zOrder 增加
|
|
|
- */
|
|
|
+ */
|
|
|
private setAfter(): void {
|
|
|
const arr: SGraphItem[] = this.sortItemList(this.itemList, false);
|
|
|
arr.forEach(it => {
|
|
@@ -662,7 +662,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* @param arr 排序前的数组
|
|
|
* @param flag 正序 or 逆序
|
|
|
* @return 排序后的数组
|
|
|
- */
|
|
|
+ */
|
|
|
sortItemList(arr: SGraphItem[], flag: boolean = true): SGraphItem[] {
|
|
|
const list: SGraphItem[] = arr.map(t => t);
|
|
|
list.sort(this.compare("zOrder", flag));
|
|
@@ -674,7 +674,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
*
|
|
|
* @param prop 属性
|
|
|
* @param flag 默认正序
|
|
|
- */
|
|
|
+ */
|
|
|
private compare(prop: string, flag: boolean): any {
|
|
|
const f = flag ? 1 : -1;
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
@@ -693,7 +693,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 防抖-防止快速多次触发 itemChange; 只执行最后一次
|
|
|
- */
|
|
|
+ */
|
|
|
throttle(fn: Function, wait: number): void {
|
|
|
if (this.timer) clearTimeout(this.timer);
|
|
|
this.timer = setTimeout((): void => {
|
|
@@ -703,7 +703,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 选中的 item 更新时更新自身边界
|
|
|
- */
|
|
|
+ */
|
|
|
selectChange(): void {
|
|
|
// 抛出事件
|
|
|
this.$emit("listChange", this.itemList);
|
|
@@ -728,7 +728,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* 计算选中 item 的外接矩形和
|
|
|
*
|
|
|
* @return 外接矩形的和
|
|
|
- */
|
|
|
+ */
|
|
|
calItemBounding(): SRect {
|
|
|
if (this.itemList.length) {
|
|
|
const fir = this.itemList[0];
|
|
@@ -747,7 +747,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 根据矩阵得到宽高,并将自己移动至矩阵左上角
|
|
|
- */
|
|
|
+ */
|
|
|
getSize(): void {
|
|
|
const r = this.calItemBounding();
|
|
|
this.width = r.width;
|
|
@@ -757,7 +757,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 计算外接矩形 8 个端点
|
|
|
- */
|
|
|
+ */
|
|
|
calExtreme(): void {
|
|
|
this.pointList = [];
|
|
|
this.pointList.push(new SPoint(0, 0));
|
|
@@ -772,7 +772,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
|
|
|
/**
|
|
|
* 计算点到哪个点
|
|
|
- */
|
|
|
+ */
|
|
|
getNearestPoint(p: SPoint): void {
|
|
|
let len = this.sceneDis;
|
|
|
this.curIndex = -1;
|
|
@@ -794,7 +794,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* Item 对象边界区域
|
|
|
*
|
|
|
* @return 对象边界区域
|
|
|
- */
|
|
|
+ */
|
|
|
boundingRect(): SRect {
|
|
|
if (this.visible) {
|
|
|
return new SRect(
|
|
@@ -813,7 +813,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
*
|
|
|
* @param oldSize 改之前的大小
|
|
|
* @param newSize 改之后大小
|
|
|
- */
|
|
|
+ */
|
|
|
protected resize(oldSize: SSize, newSize: SSize): void {
|
|
|
for (let v of this.itemList) {
|
|
|
// @ts-ignore
|
|
@@ -829,7 +829,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
*
|
|
|
* @param event 保存事件参数
|
|
|
* @return 是否处理事件
|
|
|
- */
|
|
|
+ */
|
|
|
onMouseDown(event: SMouseEvent): boolean {
|
|
|
if (event.buttons == 1) {
|
|
|
this.getNearestPoint(new SPoint(event.x, event.y));
|
|
@@ -854,7 +854,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
*
|
|
|
* @param event 保存事件参数
|
|
|
* @return 是否处理事件
|
|
|
- */
|
|
|
+ */
|
|
|
onMouseMove(event: SMouseEvent): boolean {
|
|
|
this.setCursor(9);
|
|
|
if (
|
|
@@ -975,7 +975,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* 设置鼠标样式
|
|
|
*
|
|
|
* @param n 样式的索引
|
|
|
- */
|
|
|
+ */
|
|
|
private setCursor(n: number): void {
|
|
|
this.cursor = SGraphSelectContainer.cursorList[n] || "default";
|
|
|
if (this.scene && this.scene.view) {
|
|
@@ -988,13 +988,13 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
*
|
|
|
* @param event 保存事件参数
|
|
|
* @return 是否处理事件
|
|
|
- */
|
|
|
+ */
|
|
|
onMouseUp(event: SMouseEvent): boolean {
|
|
|
this.curIndex = -1;
|
|
|
super.onMouseUp(event);
|
|
|
- this.itemList.forEach(t => {
|
|
|
- t.moveToOrigin(t.x, t.y);
|
|
|
- });
|
|
|
+ // this.itemList.forEach(t => {
|
|
|
+ // t.moveToOrigin(t.x, t.y);
|
|
|
+ // });
|
|
|
return true;
|
|
|
} // Function onMouseUp()
|
|
|
|
|
@@ -1002,7 +1002,7 @@ export class SGraphSelectContainer extends SGraphItem {
|
|
|
* Item 绘制操作
|
|
|
*
|
|
|
* @param painter 绘制对象
|
|
|
- */
|
|
|
+ */
|
|
|
onDraw(painter: SPainter): void {
|
|
|
// 缓存场景长度
|
|
|
this.sceneDis = painter.toPx(this.dis);
|