mirror of https://gitee.com/cf-fz/WebCAD.git
parent
2df1358343
commit
0c7f3c7eb1
@ -1,43 +0,0 @@
|
||||
import { Singleton } from "../../Common/Singleton";
|
||||
import { Board } from "../../DatabaseServices/Entity/Board";
|
||||
import { Scene } from "three";
|
||||
import { app } from "../../ApplicationServices/Application";
|
||||
import { DisposeThreeObj } from "../../Common/Dispose";
|
||||
|
||||
/**
|
||||
* 对于板件的每条边,设置不同的属性.
|
||||
* 这个编辑器提供了一个初始状态和一个结束状态.
|
||||
*
|
||||
* 开始后,viewer将只渲染板件的面(可以考虑渲染板件的二维线框,但是不能被选择.)
|
||||
* 结束后,viewer将回归原始的渲染空间
|
||||
*/
|
||||
export class BoardEdgesEditor extends Singleton
|
||||
{
|
||||
private EditorIng = false;
|
||||
private editorScene = new Scene;
|
||||
//还原旧的视图厂家
|
||||
private viewerScene: Scene;
|
||||
|
||||
/**
|
||||
* 开始
|
||||
* @param brs
|
||||
* @param [showPositiveandNegative=false] 显示正反面
|
||||
*/
|
||||
Start(brs: Board[], showPositiveandNegative = false)
|
||||
{
|
||||
if (this.EditorIng)
|
||||
throw "上一个板件边属性编辑器正在编辑中!";
|
||||
|
||||
this.EditorIng = true;
|
||||
this.viewerScene = app.Viewer.Scene;
|
||||
app.Viewer.Scene = this.editorScene;
|
||||
|
||||
//TODO: SHOW
|
||||
}
|
||||
End()
|
||||
{
|
||||
this.EditorIng = false;
|
||||
app.Viewer.Scene = this.viewerScene;
|
||||
DisposeThreeObj(this.editorScene);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
import { Scene } from "three";
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { DisposeThreeObj } from "../Common/Dispose";
|
||||
import { HostApplicationServices } from "../ApplicationServices/HostApplicationServices";
|
||||
|
||||
/**
|
||||
* 临时编辑器,类似ACAD的块编辑器.
|
||||
*/
|
||||
export class TempEditor
|
||||
{
|
||||
private constructor() { }
|
||||
private static EditorIng = false;
|
||||
private static editorScene = new Scene;
|
||||
//还原旧的视图厂家
|
||||
private static viewerScene: Scene;
|
||||
|
||||
//缓存历史记录
|
||||
private static hmIndex: number;
|
||||
|
||||
/**
|
||||
* 开始进入临时编辑模式.
|
||||
* 将记录当前命令位置,并且禁止往后撤销.
|
||||
* 将Viewer.Scene切换成this.editorScene(临时场景)
|
||||
*/
|
||||
static Start()
|
||||
{
|
||||
if (this.EditorIng)
|
||||
throw "重复进入临时编辑模式!";
|
||||
|
||||
this.EditorIng = true;
|
||||
this.viewerScene = app.Viewer.Scene;
|
||||
app.Viewer.Scene = this.editorScene;
|
||||
|
||||
//备份
|
||||
this.hmIndex = app.Database.hm.curIndex;
|
||||
app.Database.hm.lockIndex = this.hmIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束临时编辑状态
|
||||
* 请提取所需的数据后调用这个.(因为期间造成的编辑记录将被还原.)
|
||||
* Viewer.Scene还原
|
||||
* 历史记录将还原和移除
|
||||
*/
|
||||
static End()
|
||||
{
|
||||
this.EditorIng = false;
|
||||
app.Viewer.Scene = this.viewerScene;
|
||||
DisposeThreeObj(this.editorScene);
|
||||
|
||||
let showLog = HostApplicationServices.ShowHistoryLog;
|
||||
HostApplicationServices.ShowHistoryLog = false;
|
||||
app.Database.hm.lockIndex = -1;
|
||||
while (app.Database.hm.curIndex !== this.hmIndex)
|
||||
app.Database.hm.Undo();
|
||||
|
||||
app.Database.hm.StartCmd("");
|
||||
app.Database.hm.EndCmd();
|
||||
HostApplicationServices.ShowHistoryLog = showLog;
|
||||
app.Viewer.UpdateRender();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,90 @@
|
||||
import { Matrix4 } from "three";
|
||||
import { app } from "../../../ApplicationServices/Application";
|
||||
import { Board } from "../../../DatabaseServices/Entity/Board";
|
||||
import { Curve } from "../../../DatabaseServices/Entity/Curve";
|
||||
import { Entity } from "../../../DatabaseServices/Entity/Entity";
|
||||
import { commandMachine } from "../../../Editor/CommandMachine";
|
||||
import { TempEditor } from "../../../Editor/TempEditor";
|
||||
import { AppToaster } from "../../Components/Toaster";
|
||||
|
||||
export function ZoomToEntity(en: Entity)
|
||||
{
|
||||
app.Viewer.CameraCtrl.LookAt(en.Normal.negate());
|
||||
app.Editor.UCSMatrix = new Matrix4().extractRotation(en.OCS);
|
||||
app.Viewer.ZoomAll();
|
||||
app.Editor.UpdateScreen();
|
||||
}
|
||||
|
||||
export class BoardEdgesEditor
|
||||
{
|
||||
Board: Board;
|
||||
CurveList: Curve[] = [];
|
||||
Editoring = false;
|
||||
|
||||
//@重载
|
||||
protected async InitData()
|
||||
{
|
||||
}
|
||||
|
||||
//@重载
|
||||
protected InitCurve()
|
||||
{
|
||||
}
|
||||
|
||||
//@重载
|
||||
protected ParseData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//@重载
|
||||
protected WriteData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
async StartEditor(br: Board)
|
||||
{
|
||||
if (this.Editoring)
|
||||
throw "重复进入编辑模式!";
|
||||
|
||||
this.Board = br;
|
||||
await this.InitData();
|
||||
this.InitCurve();
|
||||
this.Start();
|
||||
this.Editoring = true;
|
||||
}
|
||||
|
||||
EndEditor(cancel = false)
|
||||
{
|
||||
if (!this.Editoring)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.ParseData();
|
||||
TempEditor.End();
|
||||
if (!cancel)
|
||||
this.WriteData();
|
||||
|
||||
AppToaster.clear();
|
||||
this.CurveList.length = 0;
|
||||
this.Editoring = false;
|
||||
this.Board = undefined;
|
||||
}
|
||||
|
||||
private Start()
|
||||
{
|
||||
TempEditor.Start();
|
||||
commandMachine.CommandStart("");
|
||||
for (let i = 0; i < this.CurveList.length; i++)
|
||||
{
|
||||
let cu = this.CurveList[i];
|
||||
cu.ApplyMatrix(this.Board.OCS);
|
||||
app.Database.ModelSpace.Append(cu);
|
||||
}
|
||||
commandMachine.CommandEnd();
|
||||
app.Database.hm.lockIndex++;//禁止初始化动作被撤销
|
||||
|
||||
ZoomToEntity(this.Board);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
import { Matrix4 } from "three";
|
||||
import { app } from "../../../ApplicationServices/Application";
|
||||
import { Board } from "../../../DatabaseServices/Entity/Board";
|
||||
import { Curve } from "../../../DatabaseServices/Entity/Curve";
|
||||
import { Entity } from "../../../DatabaseServices/Entity/Entity";
|
||||
import { JigUtils } from "../../../Editor/JigUtils";
|
||||
import { AppToaster } from "../../Components/Toaster";
|
||||
|
||||
export function toggleObject3DVisible(visible = false, en?: Entity)
|
||||
{
|
||||
app.Database.ModelSpace.Entitys.forEach(e =>
|
||||
{
|
||||
if (e !== en)
|
||||
e.Visible = visible;
|
||||
})
|
||||
}
|
||||
export function ZoomToEntity(en: Entity)
|
||||
{
|
||||
app.Viewer.CameraCtrl.LookAt(en.Normal.negate());
|
||||
app.Editor.UCSMatrix = new Matrix4().extractRotation(en.OCS);
|
||||
app.Viewer.ZoomAll();
|
||||
app.Editor.UpdateScreen();
|
||||
}
|
||||
|
||||
export class RightStoreEditorStore
|
||||
{
|
||||
currentBoard: Board;
|
||||
cuList: Curve[] = [];
|
||||
ShowCurve()
|
||||
{
|
||||
for (let i = 0; i < this.cuList.length; i++)
|
||||
{
|
||||
let cu = this.cuList[i];
|
||||
cu.ApplyMatrix(this.currentBoard.OCS);
|
||||
app.Database.ModelSpace.Append(cu);
|
||||
}
|
||||
app.Editor.UpdateScreen();
|
||||
}
|
||||
ExitEditor()
|
||||
{
|
||||
toggleObject3DVisible(true);
|
||||
for (let c of this.cuList)
|
||||
{
|
||||
!c.IsErase && app.Database.ModelSpace.Remove(c);
|
||||
}
|
||||
this.cuList.length = 0;
|
||||
JigUtils.Destroy();
|
||||
AppToaster.clear();
|
||||
this.currentBoard = null;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue