|
|
@ -3,6 +3,16 @@ import { IObservableValue } from 'mobx';
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
import * as React from 'react';
|
|
|
|
import * as React from 'react';
|
|
|
|
import { MouseKey } from '../../../Common/KeyEnum';
|
|
|
|
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
|
|
|
|
export interface IToplineListProps
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -18,6 +28,7 @@ export interface IToplineListProps
|
|
|
|
|
|
|
|
|
|
|
|
@observer
|
|
|
|
@observer
|
|
|
|
export class ToplineList extends React.Component<IToplineListProps, { isContextMenuOpen: boolean }> {
|
|
|
|
export class ToplineList extends React.Component<IToplineListProps, { isContextMenuOpen: boolean }> {
|
|
|
|
|
|
|
|
private _cameraFiler: CADFiler;
|
|
|
|
constructor(props)
|
|
|
|
constructor(props)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
@ -34,11 +45,72 @@ export class ToplineList extends React.Component<IToplineListProps, { isContextM
|
|
|
|
this.props.selectedId.set(tpline.topline_id);
|
|
|
|
this.props.selectedId.set(tpline.topline_id);
|
|
|
|
if (e.button === MouseKey.Right)
|
|
|
|
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(
|
|
|
|
ContextMenu.show(
|
|
|
|
<Menu>
|
|
|
|
<Menu>
|
|
|
@ -47,6 +119,11 @@ export class ToplineList extends React.Component<IToplineListProps, { isContextM
|
|
|
|
text="重命名"
|
|
|
|
text="重命名"
|
|
|
|
onClick={() => this.props.isRename.set(true)}
|
|
|
|
onClick={() => this.props.isRename.set(true)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
<MenuItem
|
|
|
|
|
|
|
|
icon="folder-new"
|
|
|
|
|
|
|
|
text="编辑"
|
|
|
|
|
|
|
|
onClick={() => this.startEditorTopline(tpline)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
<MenuItem
|
|
|
|
<MenuItem
|
|
|
|
icon="folder-new"
|
|
|
|
icon="folder-new"
|
|
|
|
text="重选轮廓"
|
|
|
|
text="重选轮廓"
|
|
|
|