!362 <test>fixes #IXXSW

Merge pull request !362 from ZoeLeeFZ/editorTopline
pull/362/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent aad76e9079
commit df8b80d448

@ -30,10 +30,11 @@ export class TempEditor
this.EditorIng = true;
this.viewerScene = app.Viewer.Scene;
app.Viewer.Scene = this.editorScene;
this.editorScene.add(app.Viewer.GripScene);
//备份
this.hmIndex = app.Database.hm.curIndex;
app.Database.hm.lockIndex = this.hmIndex;
app.Viewer.UpdateRender();
}
/**
@ -46,8 +47,8 @@ export class TempEditor
{
this.EditorIng = false;
app.Viewer.Scene = this.viewerScene;
app.Viewer.Scene.add(app.Viewer.GripScene);
app.Viewer.OutlinePass.selectedObjects.length = 0;
//@ts-ignore
app.Viewer.OutlinePass.renderObjects.length = 0;
DisposeThreeObj(this.editorScene);

@ -3,6 +3,16 @@ import { IObservableValue } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { MouseKey } from '../../../Common/KeyEnum';
import { TempEditor } from '../../../Editor/TempEditor';
import { app } from '../../../ApplicationServices/Application';
import { Polyline } from '../../../DatabaseServices/Entity/Polyline';
import { PostJson, RequestStatus } from '../../../Common/Request';
import { ToplineUrls } from '../../../Common/HostUrl';
import { inflate, toplineFileIn, getPolylineSVG, deflate } from '../../../Common/SerializeMaterial';
import { CADFiler } from '../../../DatabaseServices/CADFiler';
import { ZoomToEntity } from '../../Store/RightPanelStore/BoardEdgesEditor';
import { commandMachine } from '../../../Editor/CommandMachine';
import { AppToaster } from '../Toaster';
export interface IToplineListProps
{
@ -18,6 +28,7 @@ export interface IToplineListProps
@observer
export class ToplineList extends React.Component<IToplineListProps, { isContextMenuOpen: boolean }> {
private _cameraFiler: CADFiler;
constructor(props)
{
super(props);
@ -34,11 +45,72 @@ export class ToplineList extends React.Component<IToplineListProps, { isContextM
this.props.selectedId.set(tpline.topline_id);
if (e.button === MouseKey.Right)
{
this.showContextMenu(e);
this.showContextMenu(e, tpline);
}
}
private exitEditor = () =>
{
app.Viewer.CameraCtrl.ReadFile(this._cameraFiler);
TempEditor.End();
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.ShowMask();
this._cameraFiler = undefined;
app.Editor.SelectCtrl.Cancel();
}
private startEditorTopline = async (tpline) =>
{
TempEditor.Start();
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.Clear();
let data = await PostJson(ToplineUrls.detail, { topline_id: tpline.topline_id });
if (data.err_code === RequestStatus.Ok)
{
let file = inflate(data.toplines.file);
let pl = toplineFileIn(file);
app.Database.ModelSpace.Append(pl);
app.Database.hm.lockIndex++;//禁止初始化动作被撤销
this._cameraFiler = new CADFiler;
app.Viewer.CameraCtrl.WriteFile(this._cameraFiler);
ZoomToEntity(pl);
commandMachine.ExecCommand('fs');
AppToaster.show({
message: " 正在编辑顶线...",
timeout: 0,
action: {
text: "保存",
intent: Intent.PRIMARY,
onClick: this.handleUpdateTopline,
},
onDismiss: this.exitEditor
})
}
}
private handleUpdateTopline = async () =>
{
let pl = app.Viewer.VisibleEntitys.find(en => en instanceof Polyline && en.IsClose) as Polyline;
if (pl)
{
let topline_id = this.props.selectedId.get();
let vf = new CADFiler();
pl.WriteFile(vf);
let fileJson = JSON.stringify(vf.Data);
let logo = getPolylineSVG(pl);
let data = await PostJson(ToplineUrls.update, {
topline_id,
logo,
file: deflate(fileJson),
zip_type: "gzip",
});
if (data.err_code === RequestStatus.Ok)
{
await this.props.getData()
}
}
}
//展示右键菜单
private showContextMenu = (e: React.MouseEvent<HTMLElement>) =>
private showContextMenu = (e: React.MouseEvent<HTMLElement>, tpline) =>
{
ContextMenu.show(
<Menu>
@ -47,6 +119,11 @@ export class ToplineList extends React.Component<IToplineListProps, { isContextM
text="重命名"
onClick={() => this.props.isRename.set(true)}
/>
<MenuItem
icon="folder-new"
text="编辑"
onClick={() => this.startEditorTopline(tpline)}
/>
<MenuItem
icon="folder-new"
text="重选轮廓"

@ -7,6 +7,7 @@ import { CheckoutValid } from "../../Common/CheckoutVaildValue";
export const AppToaster = Toaster.create({
className: "recipe-toaster",
position: Position.TOP,
canEscapeKeyClear: false,
});
interface IToasterInputProps extends ISetItemOption
{

Loading…
Cancel
Save