|
|
|
@ -1,12 +1,16 @@
|
|
|
|
|
import { Button, Menu, MenuItem, Popover, MenuDivider } from "@blueprintjs/core";
|
|
|
|
|
import { Button, Menu, MenuDivider, MenuItem, Popover } from "@blueprintjs/core";
|
|
|
|
|
import { observable } from "mobx";
|
|
|
|
|
import { observer } from "mobx-react";
|
|
|
|
|
import * as React from "react";
|
|
|
|
|
import { OrthographicCamera } from "three";
|
|
|
|
|
import { begin, end } from "xaop";
|
|
|
|
|
import { app } from "../../../ApplicationServices/Application";
|
|
|
|
|
import { KeyBoard } from "../../../Common/KeyEnum";
|
|
|
|
|
import { commandMachine } from "../../../Editor/CommandMachine";
|
|
|
|
|
import { end, begin } from "xaop";
|
|
|
|
|
import { userConfig } from "../../../Editor/UserConfig";
|
|
|
|
|
import { RenderType } from "../../../GraphicsSystem/RenderType";
|
|
|
|
|
import { DownPanelStore } from "../../Store/DownPanelStore";
|
|
|
|
|
import { VisualStyleData } from "./IVisualType";
|
|
|
|
|
|
|
|
|
|
enum MenuType
|
|
|
|
|
{
|
|
|
|
@ -14,111 +18,87 @@ enum MenuType
|
|
|
|
|
ViewMenu = 1,
|
|
|
|
|
VisualStyleMenu = 2,
|
|
|
|
|
}
|
|
|
|
|
export interface IViewData
|
|
|
|
|
interface IViewData
|
|
|
|
|
{
|
|
|
|
|
command: string;
|
|
|
|
|
name: string;
|
|
|
|
|
enable: boolean;
|
|
|
|
|
}
|
|
|
|
|
export let viewData: IViewData[] = observable([
|
|
|
|
|
let viewData: IViewData[] = [
|
|
|
|
|
{
|
|
|
|
|
command: "FS",
|
|
|
|
|
name: "俯视",
|
|
|
|
|
enable: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "YS",
|
|
|
|
|
name: "右视",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "ZS",
|
|
|
|
|
name: "左视",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "QS",
|
|
|
|
|
name: "前视",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "BOTTOMVIEW",
|
|
|
|
|
name: "仰视",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "SWISO",
|
|
|
|
|
name: "西南等轴测",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
export let visualStyleData: IViewData[] = observable([
|
|
|
|
|
{
|
|
|
|
|
command: "",
|
|
|
|
|
name: "二维线框",
|
|
|
|
|
enable: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "",
|
|
|
|
|
name: "概念",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "",
|
|
|
|
|
name: "隐藏",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "",
|
|
|
|
|
name: "带边缘着色",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "",
|
|
|
|
|
name: "X射线",
|
|
|
|
|
enable: false
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
export let cameraStyle: IViewData[] = observable([
|
|
|
|
|
{
|
|
|
|
|
command: "perspective",
|
|
|
|
|
name: "平行",
|
|
|
|
|
enable: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "orthographic",
|
|
|
|
|
name: "正交",
|
|
|
|
|
enable: false,
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
@observer
|
|
|
|
|
export class CameraControlBtn extends React.Component<{}, {}>
|
|
|
|
|
{
|
|
|
|
|
@observable private m_isMenuShow: number = -1;
|
|
|
|
|
@observable private m_ViewMenuTitle: string = "俯视";
|
|
|
|
|
@observable private m_VisualStyleMenuTitle: string = "二维线框";
|
|
|
|
|
@observable private m_CameraStyle: string = "平行";
|
|
|
|
|
@observable private m_CameraType: string = "平行";
|
|
|
|
|
@observable private _RenderType: RenderType;
|
|
|
|
|
|
|
|
|
|
constructor(p)
|
|
|
|
|
constructor(p, s)
|
|
|
|
|
{
|
|
|
|
|
super(p);
|
|
|
|
|
super(p, s);
|
|
|
|
|
begin(commandMachine, commandMachine.CommandStart, (cmdName: string) =>
|
|
|
|
|
{
|
|
|
|
|
if (cmdName)
|
|
|
|
|
{
|
|
|
|
|
if (viewData.findIndex((i) => { return i.command === cmdName; }) !== -1)
|
|
|
|
|
this.m_ViewMenuTitle = this.SingleSelection(viewData, cmdName);
|
|
|
|
|
for (let d of viewData)
|
|
|
|
|
{
|
|
|
|
|
if (d.command === cmdName)
|
|
|
|
|
{
|
|
|
|
|
this.m_ViewMenuTitle = d.name;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const updateRenderType = () =>
|
|
|
|
|
{
|
|
|
|
|
this._RenderType = userConfig.RenderType;
|
|
|
|
|
this.m_VisualStyleMenuTitle = VisualStyleData.find(v => v.type === this._RenderType).title;
|
|
|
|
|
}
|
|
|
|
|
updateRenderType();
|
|
|
|
|
begin(userConfig, userConfig.SetRenderTypeEvent, updateRenderType);
|
|
|
|
|
|
|
|
|
|
end(app.m_Viewer.m_CameraCtrl, app.m_Viewer.m_CameraCtrl.Rotate, () =>
|
|
|
|
|
{
|
|
|
|
|
this.m_ViewMenuTitle = "自定义视图";
|
|
|
|
|
this.SingleSelection(viewData, "");
|
|
|
|
|
});
|
|
|
|
|
end(app.m_Viewer.m_CameraCtrl, app.m_Viewer.m_CameraCtrl.SwitchCamera, () =>
|
|
|
|
|
|
|
|
|
|
const updateCameraType = () =>
|
|
|
|
|
{
|
|
|
|
|
this.m_CameraStyle = this.SingleSelection(cameraStyle, this.m_CameraStyle === "平行" ? "正交" : "平行");
|
|
|
|
|
});
|
|
|
|
|
if (app.m_Viewer.m_CameraCtrl.Camera instanceof OrthographicCamera)
|
|
|
|
|
this.m_CameraType = "正交";
|
|
|
|
|
else
|
|
|
|
|
this.m_CameraType = "透视";
|
|
|
|
|
}
|
|
|
|
|
updateCameraType();
|
|
|
|
|
end(app.m_Viewer.m_CameraCtrl, app.m_Viewer.m_CameraCtrl.SwitchCamera, updateCameraType);
|
|
|
|
|
}
|
|
|
|
|
render()
|
|
|
|
|
{
|
|
|
|
@ -194,7 +174,7 @@ export class CameraControlBtn extends React.Component<{}, {}>
|
|
|
|
|
/>
|
|
|
|
|
</Popover >
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderControlsMenu = () =>
|
|
|
|
@ -229,7 +209,7 @@ export class CameraControlBtn extends React.Component<{}, {}>
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
</Menu>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderViewMenu = () =>
|
|
|
|
@ -257,33 +237,37 @@ export class CameraControlBtn extends React.Component<{}, {}>
|
|
|
|
|
(data) =>
|
|
|
|
|
<MenuItem
|
|
|
|
|
text={data.name}
|
|
|
|
|
icon={data.enable ? "tick" : "blank"}
|
|
|
|
|
icon={data.name === this.m_ViewMenuTitle ? "tick" : "blank"}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
{
|
|
|
|
|
data.enable = !data.enable;
|
|
|
|
|
this.m_ViewMenuTitle = this.SingleSelection(viewData, data.name);
|
|
|
|
|
commandMachine.ExecCommand(data.command);
|
|
|
|
|
this.HideMenu();
|
|
|
|
|
this.m_ViewMenuTitle = data.name;
|
|
|
|
|
commandMachine.ExecCommand(data.command);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
<MenuDivider />
|
|
|
|
|
{
|
|
|
|
|
cameraStyle.map(
|
|
|
|
|
(data) =>
|
|
|
|
|
<MenuItem
|
|
|
|
|
text={data.name}
|
|
|
|
|
icon={data.enable ? "tick" : "blank"}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
{
|
|
|
|
|
if (data.name !== this.m_CameraStyle)
|
|
|
|
|
app.m_Viewer.m_CameraCtrl.SwitchCamera();
|
|
|
|
|
this.HideMenu();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
<MenuItem
|
|
|
|
|
text={"正交"}
|
|
|
|
|
icon={this.m_CameraType === "正交" ? "tick" : "blank"}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
{
|
|
|
|
|
this.HideMenu();
|
|
|
|
|
if (this.m_CameraType !== "正交")
|
|
|
|
|
app.m_Viewer.m_CameraCtrl.SwitchCamera();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<MenuItem
|
|
|
|
|
text={"透视"}
|
|
|
|
|
icon={this.m_CameraType === "透视" ? "tick" : "blank"}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
{
|
|
|
|
|
this.HideMenu();
|
|
|
|
|
if (this.m_CameraType !== "透视")
|
|
|
|
|
app.m_Viewer.m_CameraCtrl.SwitchCamera();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Menu>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
@ -309,15 +293,16 @@ export class CameraControlBtn extends React.Component<{}, {}>
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
visualStyleData.map(
|
|
|
|
|
VisualStyleData.map(
|
|
|
|
|
(data) =>
|
|
|
|
|
<MenuItem
|
|
|
|
|
text={data.name}
|
|
|
|
|
icon={data.enable ? "tick" : "blank"}
|
|
|
|
|
text={data.title}
|
|
|
|
|
icon={userConfig.RenderType === data.type ? "tick" : "blank"}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
{
|
|
|
|
|
this.m_VisualStyleMenuTitle = this.SingleSelection(visualStyleData, data.name);
|
|
|
|
|
this.HideMenu();
|
|
|
|
|
this.m_VisualStyleMenuTitle = data.title;
|
|
|
|
|
userConfig.RenderType = data.type;
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
@ -337,21 +322,4 @@ export class CameraControlBtn extends React.Component<{}, {}>
|
|
|
|
|
this.m_isMenuShow = -1;
|
|
|
|
|
app.m_Editor.m_MaskManage.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//单选 并返回选中项的name
|
|
|
|
|
SingleSelection = (data: any[], checkedParam: string) =>
|
|
|
|
|
{
|
|
|
|
|
let title: string = "";
|
|
|
|
|
for (let i of data)
|
|
|
|
|
{
|
|
|
|
|
if (i.name === checkedParam || i.command === checkedParam)
|
|
|
|
|
{
|
|
|
|
|
i.enable = true;
|
|
|
|
|
title = i.name;
|
|
|
|
|
}
|
|
|
|
|
else if (i.enable === true)
|
|
|
|
|
i.enable = false;
|
|
|
|
|
}
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|