mirror of https://gitee.com/cf-fz/WebCAD.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.3 KiB
94 lines
3.3 KiB
import { Matrix4, Vector3 } from 'three';
|
|
import { app } from '../ApplicationServices/Application';
|
|
import { Log, LogType } from '../Common/Log';
|
|
import { CylinderHole, GangDrillType } from '../DatabaseServices/3DSolid/CylinderHole';
|
|
import { ExtrudeHole } from '../DatabaseServices/3DSolid/ExtrudeHole';
|
|
import { Hole } from '../DatabaseServices/3DSolid/Hole';
|
|
import { Board } from '../DatabaseServices/Entity/Board';
|
|
import { Command } from '../Editor/CommandMachine';
|
|
import { JigUtils } from '../Editor/JigUtils';
|
|
import { PromptStatus } from '../Editor/PromptResult';
|
|
import { AdjustUCS } from './AdjustUCS';
|
|
|
|
export class Command_Move implements Command
|
|
{
|
|
async exec()
|
|
{
|
|
if (app.Viewer.CurrentViewport)
|
|
{
|
|
Log("暂不支持视口内移动实体", LogType.Error);
|
|
return;
|
|
}
|
|
|
|
let ssRes = await app.Editor.GetSelection({ UseSelect: true });
|
|
if (ssRes.Status != PromptStatus.OK) return;
|
|
|
|
AdjustUCS();
|
|
|
|
let ptRes = await app.Editor.GetPoint({ Msg: "请点击移动基点:", NotSnapZ: true });
|
|
if (ptRes.Status != PromptStatus.OK)
|
|
return;
|
|
|
|
let ens = ssRes.SelectSet.SelectEntityList;
|
|
|
|
let ensClone = ens.map(e => JigUtils.Draw(e));
|
|
|
|
let ptBase = ptRes.Point;
|
|
let ptLast = ptBase.clone();
|
|
let moveMatrix = new Matrix4();
|
|
ptRes = await app.Editor.GetPoint(
|
|
{
|
|
Msg: "请点击移动终点:",
|
|
NotSnapZ: true,
|
|
Callback: (p: Vector3) =>
|
|
{
|
|
moveMatrix.setPosition(p.clone().sub(ptLast));
|
|
for (let ent of ensClone)
|
|
ent.ApplyMatrix(moveMatrix);
|
|
ptLast.copy(p);
|
|
|
|
// //对调试实体进行移动
|
|
// for (let obj of ssRes.SelectSet.SelectObjectList)
|
|
// {
|
|
// if (!IsEntity(obj))
|
|
// obj.applyMatrix(moveMatrix);
|
|
// }
|
|
},
|
|
BasePoint: ptBase,
|
|
AllowDrawRubberBand: true
|
|
});
|
|
|
|
|
|
if (ptRes.Status === PromptStatus.OK)
|
|
{
|
|
moveMatrix.setPosition(ptRes.Point.clone().sub(ptBase));
|
|
|
|
let hasBoard = ens.some(en => en instanceof Board);
|
|
|
|
for (let en of ens)
|
|
{
|
|
if (!hasBoard && en instanceof Hole && en.OtherHalfTongKong)
|
|
{
|
|
if (!ens.some(e => e.Id === (<Hole>en).OtherHalfTongKong))
|
|
{
|
|
let otherHole = en.OtherHalfTongKong.Object as Hole;
|
|
if (en instanceof CylinderHole)
|
|
{
|
|
en.Type = GangDrillType.Ymj;
|
|
(<CylinderHole>otherHole).Type = GangDrillType.Ymj;
|
|
}
|
|
else
|
|
{
|
|
(en as ExtrudeHole).isThrough = false;
|
|
(<ExtrudeHole>otherHole).isThrough = false;
|
|
}
|
|
en.OtherHalfTongKong = null;
|
|
otherHole.OtherHalfTongKong = null;
|
|
}
|
|
}
|
|
en.ApplyMatrix(moveMatrix);
|
|
}
|
|
}
|
|
}
|
|
}
|