!792 功能:V型刀,走刀造型

pull/792/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent 6d3e1d52e5
commit e66b6d1c14

@ -0,0 +1,12 @@
import { Command } from './../../Editor/CommandMachine';
import { app } from './../../ApplicationServices/Application';
import { KnifeManage } from '../../UI/Components/RightPanel/Modeling/KnifeManage';
export class ShowKinfeManageModal implements Command
{
async exec()
{
app.Editor.ModalManage.RenderModeless(KnifeManage);
}
}

@ -14,6 +14,7 @@ export enum DirectoryId
ToplineDir = "4", //材质根目录 ToplineDir = "4", //材质根目录
TemplateDir = "5", //材质根目录 TemplateDir = "5", //材质根目录
DrillingDir = "6", //排钻目录 DrillingDir = "6", //排钻目录
KnifePathDir = "7", //刀路目录
} }
export enum RequestStatus export enum RequestStatus

@ -163,6 +163,7 @@ import { Command_ShowProcessingGroupModal2 } from "../Add-on/ShowProcessingGroup
import { Command_TestTape } from "../Add-on/test/TestTape"; import { Command_TestTape } from "../Add-on/test/TestTape";
import { KjlExport } from "../Add-on/KJL/KjlExport"; import { KjlExport } from "../Add-on/KJL/KjlExport";
import { Command_SetBRXAxis } from "../Add-on/Command_SetBRXAxis"; import { Command_SetBRXAxis } from "../Add-on/Command_SetBRXAxis";
import { ShowKinfeManageModal } from './../Add-on/showModal/ShowKnifeManageModal';
export function registerCommand() export function registerCommand()
{ {
@ -451,6 +452,7 @@ export function registerCommand()
commandMachine.RegisterCommand("interfere", new Interfere()); commandMachine.RegisterCommand("interfere", new Interfere());
commandMachine.RegisterCommand("testw", new Command_TestTape()); commandMachine.RegisterCommand("testw", new Command_TestTape());
commandMachine.RegisterCommand("showknifeMg", new ShowKinfeManageModal());
RegistCustomCommand(); RegistCustomCommand();
} }

@ -6,7 +6,6 @@ import { Matrix4 } from "three";
import { ExtrudeApplyContour, SelectExtrudeContour, selectOutlinePosition } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool"; import { ExtrudeApplyContour, SelectExtrudeContour, selectOutlinePosition } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool";
import { app } from "../../../ApplicationServices/Application"; import { app } from "../../../ApplicationServices/Application";
import { CheckObjectType } from "../../../Common/CheckoutVaildValue"; import { CheckObjectType } from "../../../Common/CheckoutVaildValue";
import { DataAdapter } from "../../../Common/DataAdapter";
import { Board } from "../../../DatabaseServices/Entity/Board"; import { Board } from "../../../DatabaseServices/Entity/Board";
import { Contour } from "../../../DatabaseServices/Contour"; import { Contour } from "../../../DatabaseServices/Contour";
import { ExtrudeSolid } from "../../../DatabaseServices/Entity/Extrude"; import { ExtrudeSolid } from "../../../DatabaseServices/Entity/Extrude";
@ -21,6 +20,7 @@ import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon";
import { RightTabId } from "../RightPanel/RightPanel"; import { RightTabId } from "../RightPanel/RightPanel";
import { Region } from "../../../DatabaseServices/Entity/Region"; import { Region } from "../../../DatabaseServices/Entity/Region";
import { FixedNotZero } from "../../../Common/Utils"; import { FixedNotZero } from "../../../Common/Utils";
import { TempEditor } from './../../../Editor/TempEditor';
interface BoardConfigProps interface BoardConfigProps
{ {
@ -33,6 +33,13 @@ interface BoardConfigProps
uiBoardConfig: IUiOption<BoardConfigOption>; uiBoardConfig: IUiOption<BoardConfigOption>;
} }
enum EModelingType
{
V1 = 1,
V2 = 2,
V3 = 3,
}
@observer @observer
export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
private pars = [["height", "显示高"], ["width", "显示宽"], ["thickness", "显示厚"], private pars = [["height", "显示高"], ["width", "显示宽"], ["thickness", "显示厚"],
@ -46,10 +53,209 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
private rotatePars = [ private rotatePars = [
["rotateX", "旋转X"], ["rotateY", "旋转Y"], ["rotateZ", "旋转Z"] ["rotateX", "旋转X"], ["rotateY", "旋转Y"], ["rotateZ", "旋转Z"]
]; ];
private modeingType = EModelingType.V1;
constructor(props) constructor(props)
{ {
super(props); super(props);
} }
componentWillUnmount()
{
if (TempEditor.EditorIng)
{
TempEditor.End();
}
}
render()
{
const {
boardConfig,
boardProcess,
grooveOption,
canDrawSpeical,
canModeling,
} = this.props;
return (
<div>
<BoardTypeComponent opt={boardConfig} className="long-select" />
<ItemName title="板名称" opt={boardConfig} className="br-name" />
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.pars}
option={boardConfig}
uiOption={this.props.uiBoardConfig}
/>
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.rotatePars}
option={boardConfig}
uiOption={this.props.uiBoardConfig}
/>
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.processPars}
option={boardProcess}
/>
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.groovePars}
option={grooveOption}
/>
<div>
<Checkbox
style={{
marginRight: 10
}}
checked={canDrawSpeical.get()}
label="异型"
inline={true}
onChange={() => canDrawSpeical.set(!canDrawSpeical.get())}
/>
<Checkbox
style={{
marginRight: 10
}}
checked={canModeling.get()}
label="造型"
inline={true}
onChange={() => canModeling.set(!canModeling.get())}
/>
<Button
intent={Intent.PRIMARY}
text="提取"
onClick={this.PickUpModelingOutline}
/>
<Button
intent={Intent.PRIMARY}
onClick={this.ApplyModeing}
text="修改" />
</div>
{/* <div>
<Button
intent={Intent.PRIMARY}
text="V型刀"
onClick={this.PickUpModelingOutline2}
/>
</div>
<div>
<Button
intent={Intent.PRIMARY}
text="造型刀路"
onClick={this.PickUpModelingOutline3}
/>
</div> */}
</div>
);
}
/**
*
*/
private PickUpModelingOutline = async () =>
{
await app.Editor.ModalManage.EndExecingCmd();
if (!commandMachine.CommandStart("_pick"))
return;
app.Editor.SelectCtrl.Cancel();
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.Clear();
let br = this.props.br;
app.Viewer.CameraCtrl.LookAt(br.Normal.negate());
app.Viewer.CameraCtrl.ZoomExtensBox3(br.BoundingBox.expandByScalar(1000));
app.Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
let cu = JigUtils.Draw(br.ContourCurve.Clone().ApplyMatrix(br.OCS));
let moveCus = [cu];
let store = RightPanelStore.GetInstance() as RightPanelStore;
//初始化造型数据,提取出形状
store.modelingStore.InitModelingItems();
let colorIndex = 1;
let dataMap = new Map<string, number>();
for (let data of br.BoardModeling)
{
let str = [data.thickness, data.dir, data.knifeRadius, data.addLen].join("-");
let color: number;
if (dataMap.has(str))
color = dataMap.get(str);
else
{
color = colorIndex;
dataMap.set(str, color);
colorIndex++;
store.modelingStore.ChangeModelingValue(color - 1, data);
}
let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().ApplyMatrix(br.OCS));
cu.ColorIndex = color;
moveCus.push(cu);
for (let c of data.shape.Holes)
{
cu = JigUtils.Draw(c.Curve.Clone().ApplyMatrix(br.OCS));
cu.ColorIndex = color;
moveCus.push(cu);
}
}
let isOk = await selectOutlinePosition(moveCus);
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.ShowMask();
if (isOk)
{
//显示右侧状态栏
store.modelingStore.isUpdate = false;
store.modelingStore.configName = "";
store.m_IsShow = true;
if (this.modeingType === EModelingType.V1)
store.m_TabId = RightTabId.Model;
else
{
store.m_TabId = RightTabId.Model2;
}
app.Editor.MaskManage.OnFocusEvent();
store.modelingStore.isUpdate = true;
}
commandMachine.CommandEnd();
};
PickUpModelingOutline2 = async () =>
{
this.modeingType = EModelingType.V2;
await this.PickUpModelingOutline();
};
PickUpModelingOutline3 = async () =>
{
this.modeingType = EModelingType.V3;
TempEditor.Start();
app.Database.hm.lockIndex++;//禁止初始化动作被撤销
let con = this.props.br.ContourCurve.Clone();
let c2 = con.Clone();
c2.Position = c2.Position.setZ(this.props.br.Thickness);
app.Database.ModelSpace.Append(con);
app.Database.ModelSpace.Append(c2);
app.Editor.MaskManage.OnFocusEvent();
};
private ApplyModeing = async () =>
{
switch (this.modeingType)
{
case EModelingType.V1:
case EModelingType.V2:
await this.ChangeModeling();
break;
case EModelingType.V3:
await this.ChangeModeling3();
default:
break;
}
};
private ChangeModeling = async () => private ChangeModeling = async () =>
{ {
await app.Editor.ModalManage.EndExecingCmd(); await app.Editor.ModalManage.EndExecingCmd();
@ -121,9 +327,35 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
} }
} }
} }
if (this.modeingType === EModelingType.V1)
this.AddModeling(contourMap, applyMatrix);
else
this.AddModeling2(contourMap, applyMatrix);
}
};
await exec();
this.props.canDrawSpeical.set(this.props.br.IsSpecialShape);
this.props.canModeling.set(this.props.br.BoardModeling.length > 0);
//更新板件的尺寸信息
this.props.uiBoardConfig.height = FixedNotZero(this.props.br.Height, 2);
this.props.uiBoardConfig.width = FixedNotZero(this.props.br.Width, 2);
this.props.boardConfig.width = this.props.br.Width;
this.props.boardConfig.height = this.props.br.Height;
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.OnFocusEvent();
commandMachine.CommandEnd();
return;
};
private AddModeling = (contourMap: Map<number, Contour[]>, applyMatrix: Matrix4) =>
{
if (contourMap.size > 0) if (contourMap.size > 0)
{ {
let br = this.props.br;
const rightStore = RightPanelStore.GetInstance() as RightPanelStore;
for (let [color, contours] of contourMap) for (let [color, contours] of contourMap)
{ {
for (let con of contours) for (let con of contours)
@ -163,166 +395,20 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
br.Update(); br.Update();
} }
}
}; };
private AddModeling2 = (contourMap: Map<number, Contour[]>, applyMatrix: Matrix4) =>
await exec();
this.props.canDrawSpeical.set(this.props.br.IsSpecialShape);
this.props.canModeling.set(this.props.br.BoardModeling.length > 0);
//更新板件的尺寸信息
this.props.uiBoardConfig.height = FixedNotZero(this.props.br.Height, 2);
this.props.uiBoardConfig.width = FixedNotZero(this.props.br.Width, 2);
this.props.boardConfig.width = this.props.br.Width;
this.props.boardConfig.height = this.props.br.Height;
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.OnFocusEvent();
commandMachine.CommandEnd();
return;
};
/**
*
*/
private PickUpModelingOutline = async () =>
{
await app.Editor.ModalManage.EndExecingCmd();
if (!commandMachine.CommandStart("_pick"))
return;
app.Editor.SelectCtrl.Cancel();
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.Clear();
let br = this.props.br;
app.Viewer.CameraCtrl.LookAt(br.Normal.negate());
app.Viewer.CameraCtrl.ZoomExtensBox3(br.BoundingBox.expandByScalar(1000));
app.Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
let cu = JigUtils.Draw(br.ContourCurve.Clone().ApplyMatrix(br.OCS));
let moveCus = [cu];
let store = RightPanelStore.GetInstance() as RightPanelStore;
//初始化造型数据,提取出形状
store.modelingStore.InitModelingItems();
let colorIndex = 1;
let dataMap = new Map<string, number>();
for (let data of br.BoardModeling)
{ {
let str = [data.thickness, data.dir, data.knifeRadius, data.addLen].join("-"); if (contourMap.size > 0)
let color: number;
if (dataMap.has(str))
color = dataMap.get(str);
else
{
color = colorIndex;
dataMap.set(str, color);
colorIndex++;
store.modelingStore.ChangeModelingValue(color - 1, data);
}
let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().ApplyMatrix(br.OCS));
cu.ColorIndex = color;
moveCus.push(cu);
for (let c of data.shape.Holes)
{
cu = JigUtils.Draw(c.Curve.Clone().ApplyMatrix(br.OCS));
cu.ColorIndex = color;
moveCus.push(cu);
}
}
let isOk = await selectOutlinePosition(moveCus);
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.ShowMask();
if (isOk)
{ {
//显示右侧状态栏 let br = this.props.br;
store.modelingStore.isUpdate = false; const rightStore = RightPanelStore.GetInstance() as RightPanelStore;
store.modelingStore.configName = ""; //TODO:造型2 写入板件
store.m_IsShow = true;
store.m_TabId = RightTabId.Model;
app.Editor.MaskManage.OnFocusEvent();
store.modelingStore.isUpdate = true;
} }
commandMachine.CommandEnd();
}; };
render() private ChangeModeling3 = async () =>
{ {
const { if (TempEditor.EditorIng)
boardConfig, TempEditor.End();
boardProcess, this.modeingType = EModelingType.V1;
grooveOption, };
canDrawSpeical,
canModeling,
} = this.props;
return (
<div>
<BoardTypeComponent opt={boardConfig} className="long-select" />
<ItemName title="板名称" opt={boardConfig} className="br-name" />
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.pars}
option={boardConfig}
uiOption={this.props.uiBoardConfig}
/>
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.rotatePars}
option={boardConfig}
uiOption={this.props.uiBoardConfig}
/>
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.processPars}
option={boardProcess}
/>
<SetBoardDataBlock
type={CheckObjectType.BR}
className="flexWrap"
pars={this.groovePars}
option={grooveOption}
/>
<div>
<Checkbox
style={{
marginRight: 10
}}
checked={canDrawSpeical.get()}
label="异型"
inline={true}
onChange={() => canDrawSpeical.set(!canDrawSpeical.get())}
/>
<Checkbox
style={{
marginRight: 10
}}
checked={canModeling.get()}
label="造型"
inline={true}
onChange={() => canModeling.set(!canModeling.get())}
/>
<Button
className={Intent.PRIMARY}
text="提取"
onClick={this.PickUpModelingOutline}
/>
<Button
className={Intent.PRIMARY}
onClick={this.ChangeModeling}
text="修改" />
</div>
</div>
);
}
} }

@ -120,7 +120,7 @@ export class ModalManage
onKeyUp(e: KeyboardEvent) onKeyUp(e: KeyboardEvent)
{ {
} }
RenderModeless(Component: any, props: { [key: string]: any; }, option: IModalProps = {}) RenderModeless(Component: any, props: { [key: string]: any; } = {}, option: IModalProps = {})
{ {
app.Editor.MaskManage.ShowMask(); app.Editor.MaskManage.ShowMask();
this.RestoreZIndex(); this.RestoreZIndex();

@ -1,67 +1,100 @@
// #RightPanel .bp3-tabs{ // #RightPanel .bp3-tabs{
// height: 90%; // height: 90%;
// } // }
#RightPanel .bp3-card{ #RightPanel .bp3-card {
padding: 0; padding: 0;
border-radius: 0px; border-radius: 0px;
} }
#RightPanel .bp3-tab-panel{
#RightPanel .bp3-tab-panel {
width: 100%; width: 100%;
overflow: auto; overflow: auto;
padding: 10px; padding: 10px;
} }
#RightPanel .bp3-tab-panel.tab-unstyle { #RightPanel .bp3-tab-panel.tab-unstyle {
.bp3-tab.tab-unstyle{ .bp3-tab.tab-unstyle {
width: calc(100% * 0.33333); width: calc(100% * 0.33333);
// border-width: 0; // border-width: 0;
outline: none; outline: none;
// background: #293742;//背景色待更改 且可随主题变化 // background: #293742;//背景色待更改 且可随主题变化
} }
&#bp3-tab-panel_undefined_scenes,&#bp3-tab-panel_undefined_modeling{
&#bp3-tab-panel_undefined_scenes,
&#bp3-tab-panel_undefined_modeling {
padding: 10px; padding: 10px;
} }
} }
.modeling{
.modeling {
margin-bottom: 2rem; margin-bottom: 2rem;
width: 100%; width: 100%;
&>li>label{
&>li>label {
text-align: center; text-align: center;
flex:1; flex: 1;
box-shadow: 0 0 0 0 rgba(19, 124, 189, 0), box-shadow: 0 0 0 0 rgba(19, 124, 189, 0),
0 0 0 0 rgba(19, 124, 189, 0), 0 0 0 0 rgba(19, 124, 189, 0),
0 0 0 0 rgba(19, 124, 189, 0), 0 0 0 0 rgba(19, 124, 189, 0),
inset 0 0 0 1px rgba(16, 22, 26, 0.3), inset 0 0 0 1px rgba(16, 22, 26, 0.3),
inset 0 1px 1px rgba(16, 22, 26, 0); inset 0 1px 1px rgba(16, 22, 26, 0);
} }
&>li{
&>li {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
&:first-child>label{
&:first-child>label {
padding: 5px 0; padding: 5px 0;
} }
label,span,input,&>div {
label,
span,
input,
&>div {
width: 20%; width: 20%;
margin: 0; margin: 0;
} }
} }
} }
.drilling{
&>li{ .drilling {
&>div{ &>li {
&>div {
width: 50%; width: 50%;
} }
} }
} }
.modeling2 {
&>li {
label,
span,
input,
&>div {
width: 33.333333%;
}
}
}
/* 滚动条 */ /* 滚动条 */
::-webkit-scrollbar-track-piece { ::-webkit-scrollbar-track-piece {
background-color: #fff; /*滚动条的背景颜色*/ background-color: #fff;
border-radius: 0; /*滚动条的圆角宽度*/ /*滚动条的背景颜色*/
border-radius: 0;
/*滚动条的圆角宽度*/
} }
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 10px; /*滚动条的宽度*/ width: 10px;
height: 8px; /*滚动条的高度*/ /*滚动条的宽度*/
height: 8px;
/*滚动条的高度*/
} }
::-webkit-scrollbar-thumb:vertical { /*垂直滚动条的样式*/
::-webkit-scrollbar-thumb:vertical {
/*垂直滚动条的样式*/
height: 50px; height: 50px;
background-color: #999; background-color: #999;
border-radius: 4px; border-radius: 4px;
@ -69,7 +102,9 @@
outline-offset: -2px; outline-offset: -2px;
border: 2px solid #fff; border: 2px solid #fff;
} }
::-webkit-scrollbar-thumb:hover { /*滚动条的hover样式*/
::-webkit-scrollbar-thumb:hover {
/*滚动条的hover样式*/
height: 50px; height: 50px;
background-color: #9f9f9f; background-color: #9f9f9f;
border-radius: 4px; border-radius: 4px;

@ -0,0 +1,239 @@
import { Button, Card, Checkbox, Classes, Intent, Popover, Position, ContextMenu, Menu, MenuItem } from '@blueprintjs/core';
import { IObservableValue } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
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 { commandMachine } from '../../../../Editor/CommandMachine';
import { AppToaster } from '../../Toaster';
import { ModalPosition } from '../../Modal/ModalInterface';
import { IDirectoryProps } from '../../SourceManage/CommonPanel';
import { ZoomToEntity } from '../../../Store/RightPanelStore/BoardEdgesEditor';
import { MouseKey } from '../../../../Common/KeyEnum';
import { KnifeManage } from './KnifeManage';
export interface IKnifeListProps
{
deleteFun?: (topline: { topline_id; }) => void;
dataList?: any[];
select?: (e: React.FormEvent<HTMLInputElement>, data: any) => void;
draw: (id: string) => void;
isRename: IObservableValue<boolean>;
updata: (name: string, dir: IDirectoryProps, call: Function) => void;
getData?: () => void;
info: { id: string, name: string; };
}
@observer
export class KnifeList extends React.Component<IKnifeListProps, { isContextMenuOpen: boolean; }> {
private _cameraFiler: CADFiler;
constructor(props)
{
super(props);
this.state = {
isContextMenuOpen: false
};
}
private handleDbClick = async (tpdata: { topline_id: string; }) =>
{
this.props.draw(tpdata.topline_id);
};
private handleMounseDown = (e: React.MouseEvent<HTMLElement>, tpline: any) =>
{
this.props.info.id = tpline.topline_id;
this.props.info.name = tpline.name;
if (e.button === MouseKey.Right)
{
this.showContextMenu(e, tpline);
}
};
private exitEditor = () =>
{
if (!this._cameraFiler) return;
app.Viewer.CameraCtrl.ReadFile(this._cameraFiler);
TempEditor.End();
this._cameraFiler = undefined;
app.Editor.SelectCtrl.Cancel();
app.Editor.ModalManage.RenderModal(KnifeManage, {}, { position: ModalPosition.Old });
};
private renderToasterMessage = () =>
{
return (
<div className="flex-between toaster-message">
<span></span>
<div>
<Button text="保存" minimal onClick={this.handleUpdateTopline} />
<Button text="取消" minimal onClick={() =>
{
AppToaster.clear();
}} />
</div>
</div>
);
};
private startEditorTopline = async (tpline) =>
{
TempEditor.Start();
app.Editor.ModalManage.Destory();
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: this.renderToasterMessage(),
intent: Intent.PRIMARY,
timeout: 0,
onDismiss: this.exitEditor
});
}
};
private handleUpdateTopline = async () =>
{
await app.Editor.ModalManage.EndExecingCmd();
let pl = app.Viewer.VisibleEntitys.find(en => en instanceof Polyline) as Polyline;
if (pl)
{
let topline_id = this.props.info.id;
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",
});
AppToaster.clear();
if (data.err_code === RequestStatus.Ok)
{
this.props.getData();
AppToaster.show({
message: "刀路保存成功",
timeout: 1000,
intent: Intent.SUCCESS,
});
}
}
else
{
AppToaster.clear();
AppToaster.show({
message: "顶线轮廓错误,保存失败",
timeout: 1000,
intent: Intent.DANGER,
});
}
};
//展示右键菜单
private showContextMenu = (e: React.MouseEvent<HTMLElement>, tpline) =>
{
ContextMenu.show(
<Menu>
<MenuItem
icon="folder-new"
text="重命名"
onClick={() => this.props.isRename.set(true)}
/>
<MenuItem
icon="folder-new"
text="编辑"
onClick={() => this.startEditorTopline(tpline)}
/>
</Menu>,
{ left: e.clientX, top: e.clientY },
() => this.setState({ isContextMenuOpen: false }),
);
this.setState({ isContextMenuOpen: true });
e.stopPropagation();
e.preventDefault();
};
public render()
{
return (
<ul
className="mat-list"
>
{
this.props.dataList.map(tpline =>
{
return (
<li
key={tpline.topline_id}
data-id={tpline.topline_id}
onMouseDown={(e) => this.handleMounseDown(e, tpline)}
style={{
background: this.props.info.id === tpline.topline_id && "rgba(162, 186, 197, 0.34)",
}}
>
<div
draggable
onDoubleClick={() => this.handleDbClick(tpline)}
>
<svg
width="100px"
height="100px"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
>
<path d={tpline.logo} fill="transparent" stroke="black" stroke-width="1" />
</svg>
</div>
<p title={tpline.name}>{tpline.name}</p>
<Popover
position={Position.RIGHT}
onOpening={node => node.parentElement.parentElement.style.zIndex = "33"}
content={
<Card>
<p></p>
<div>
<Button style={{ marginRight: 10 }}
className={Classes.POPOVER_DISMISS}
text="取消" />
<Button
className={Classes.POPOVER_DISMISS}
intent={Intent.PRIMARY}
onClick={() => this.props.deleteFun(tpline)}
text="确定" />
</div>
</Card>
}
target={<Button
icon="cross"
minimal
/>}
/>
<Checkbox
className={tpline.isChecked && "selected"}
inline={true}
checked={tpline.isChecked}
onChange={e =>
{
this.props.select(e, tpline);
}}
/>
</li>
);
})
}
</ul>
);
}
}

@ -0,0 +1,266 @@
import React, { Component } from 'react';
import { CommonModal } from '../../Modal/ModalContainer';
import { app } from '../../../../ApplicationServices/Application';
import { CommonPanel } from '../../SourceManage/CommonPanel';
import { DirectoryId, PostJson, RequestStatus } from '../../../../Common/Request';
import { ToplineUrls } from '../../../../Common/HostUrl';
import { KnifeList } from './KnifeList';
import { Button } from '@blueprintjs/core';
import { Intent } from '@blueprintjs/core';
import { observable } from 'mobx';
import { HandleDirComponent } from '../../SourceManage/HandleDirComponent';
import { AppToaster } from '../../Toaster';
import { IDirectoryProps } from '../../SourceManage/CommonPanel';
import { PromptStatus } from '../../../../Editor/PromptResult';
import { Polyline } from '../../../../DatabaseServices/Entity/Polyline';
import { inflate, toplineFileIn, deflate, getPolylineSVG } from '../../../../Common/SerializeMaterial';
import { commandMachine, CommandWrap } from '../../../../Editor/CommandMachine';
import { buildTopline } from '../../../../Add-on/DrawTopline';
import { CADFiler } from '../../../../DatabaseServices/CADFiler';
import { observer } from 'mobx-react';
import { hot } from 'react-hot-loader/root';
import { GetCloseContour } from '../../../../Add-on/Sweep';
import { MoveMatrix } from '../../../../Geometry/GeUtils';
import { Matrix4 } from 'three';
interface IKnifeManageProps
{
}
interface IKnifeManageState
{
}
@hot
@observer
export class KnifeManage extends Component<IKnifeManageProps, IKnifeManageState> {
private canAddPath = observable.box(false);
@observable private currentInfo = { id: "", name: "" };
renderNav = () =>
{
return (
<Button
icon="cloud-upload"
style={{
marginRight: 10
}}
text="添加刀具"
intent={Intent.SUCCESS}
onClick={this.startAddKinfePath}
/>
);
};
renderMenuItems = () =>
{
return null;
};
render()
{
return (
<CommonModal
title="刀具管理"
className="topline"
icon="bold"
close={this.close}
hasConfig={false}
footerStyle={{ width: "100%" }}
footerChildren={
<>
<Button
disabled={!this.currentInfo.id}
text="预览"
intent={Intent.SUCCESS}
onClick={this.show}
/>
<Button
text="确定"
onClick={this.close}
/>
</>
}
>
<CommonPanel
maxDirLength={0}
defaultDirId={DirectoryId.KnifePathDir}
renderNav={this.renderNav}
renderMenuItems={this.renderMenuItems}
getUrl={ToplineUrls.get}
deleteUrl={ToplineUrls.delete}
clickTree={() => this.currentInfo.id = ""}
>
<KnifeList
draw={this.drawTopline}
isRename={this.canAddPath}
updata={this.handleCreateTopline}
info={this.currentInfo}
/>
{
this.canAddPath.get() && <HandleDirComponent
defualtValue={this.currentInfo.name}
isReset={false}
isOpen={this.canAddPath}
handleFunc={this.handleKnifePath}
title="输入刀路名称"
/>
}
</CommonPanel>
</CommonModal>
);
}
handleKnifePath = async (name: string, currentDir, callback: Function) =>
{
if (!name.trim())
{
AppToaster.show({
message: "名称不能为空",
intent: Intent.DANGER,
timeout: 1000
});
return;
}
if (this.currentInfo.id)
{
await this.handleRenameKP(name);
await callback();
}
else
{
if (!currentDir)
{
AppToaster.show({
message: "未知错误,请重试",
timeout: 1000
});
return;
}
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.Clear();
await this.handleCreateTopline(name, currentDir, callback);
app.Editor.ModalManage.ToggleShow();
this.canAddPath.set(false);
}
};
private handleCreateTopline = async (name: string, currentDir: IDirectoryProps, callback: Function) =>
{
let plRes = await app.Editor.GetSelection({
Once: true,
AllowNone: false,
Msg: "选择闭合轮廓",
Filter: {
filterTypes: [Polyline],
},
});
if (plRes.Status !== PromptStatus.OK)
{
return;
};
let pl = GetCloseContour(plRes.SelectSet.SelectEntityList[0] as Polyline);
if (!pl)
{
return;
}
if (!pl) return;
let ptRes = await app.Editor.GetPoint({
Msg: "指定基点"
});
//基点移动到基点
pl.ApplyMatrix(MoveMatrix(ptRes.Point.negate()))
.ApplyMatrix(new Matrix4().extractRotation(pl.OCSInv));
let vf = new CADFiler();
pl.WriteFile(vf);
pl.Erase();
let fileJson = JSON.stringify(vf.Data);
let logo = getPolylineSVG(pl);
let data: { err_code: RequestStatus; };
if (this.currentInfo.id)
{
data = await PostJson(ToplineUrls.update, {
topline_id: this.currentInfo.id,
logo,
file: deflate(fileJson),
zip_type: "gzip",
});
}
else
{
data = await PostJson(ToplineUrls.create, {
dir_id: currentDir.id,
name,
logo,
file: deflate(fileJson),
zip_type: "gzip",
});
}
if (data.err_code === RequestStatus.Ok)
{
await callback();
}
};
handleRenameKP = async (name: string) =>
{
let data = await PostJson(ToplineUrls.update, {
topline_id: this.currentInfo.id,
name
});
if (data.code === RequestStatus.Ok)
{
AppToaster.show({
message: "重命名成功",
timeout: 1000
});
}
this.canAddPath.set(false);
};
private drawTopline = async (topline_id: string) =>
{
app.Editor.ModalManage.Destory();
let data = await PostJson(ToplineUrls.detail, { topline_id });
if (data.err_code === RequestStatus.Ok)
{
let file = inflate(data.toplines.file);
let polyline = toplineFileIn(file);
if (!commandMachine.CommandStart("_drawtopline"))
return;
await buildTopline(polyline, data.toplines.name);
commandMachine.CommandEnd();
}
};
private startAddKinfePath = () =>
{
this.currentInfo.id = "";
this.currentInfo.name = "";
this.canAddPath.set(true);
};
private show = async () =>
{
app.Editor.ModalManage.Destory();
let data = await PostJson(ToplineUrls.detail, { topline_id: this.currentInfo.id });
if (data.err_code === RequestStatus.Ok)
{
let file = inflate(data.toplines.file);
let polyline = toplineFileIn(file);
CommandWrap(() =>
{
app.Database.ModelSpace.Append(polyline);
}, "_showPath");
}
};
private close()
{
app.Editor.ModalManage.Destory();
}
}

@ -0,0 +1,85 @@
import { Classes, HTMLSelect, Label, IOptionProps } from '@blueprintjs/core';
import { observer } from 'mobx-react';
import * as React from 'react';
import { ColorMaterial } from '../../../../Common/ColorPalette';
import { FaceDirection } from '../../../Store/BoardInterface';
import { safeEval } from '../../../../Common/eval';
import { PostJson, DirectoryId, RequestStatus } from '../../../../Common/Request';
import { ToplineUrls } from '../../../../Common/HostUrl';
import { observable } from 'mobx';
import { Modeling2Store } from '../../../Store/RightPanelStore/Modeling2Store';
@observer
export class ModelingComponent2 extends React.Component<{ store?: Modeling2Store; }>
{
@observable private knifeData: IOptionProps[] = [];
UNSAFE_componentWillMount()
{
this.getKnifeList();
}
render()
{
const data = this.props.store.modelingItems;
return (
<>
<ul className={"modeling modeling2 " + Classes.LIST_UNSTYLED}>
<li>
<Label></Label>
<Label></Label>
<Label></Label>
</li>
{
data.map((item, index) =>
{
return (
<li>
<span
className={Classes.INPUT}
style={{
background: ColorMaterial.GetColor(item.color).getStyle()
}}
>{item.color}</span>
<HTMLSelect
options={
[{
label: "正", value: FaceDirection.Front
},
{
label: "反", value: FaceDirection.Back
}]
}
value={item.dir}
onChange={e =>
{
data[index].dir = safeEval(e.target.value) as FaceDirection;
item.dir = safeEval(e.target.value);
}}
/>
<HTMLSelect
options={this.knifeData.slice()}
value={item.knife.id}
onChange={e =>
{
item.knife.id = e.target.value;
item.knife.name = this.knifeData[e.target.selectedIndex].label;
}}
/>
</li>
);
})
}
</ul>
{/* <UserConfig type={BoardModalType.Zx} store={this.props.store.modelingStore} isUpdate={this.props.store.modelingStore.isUpdate} /> */}
</>
);
}
private getKnifeList = async () =>
{
let data = await PostJson(ToplineUrls.get, { dir_id: DirectoryId.KnifePathDir });
console.log('data: ', data);
if (data.err_code === RequestStatus.Ok)
{
observable(this.knifeData).replace(data.toplines.map(t => { return { value: t.topline_id, label: t.name }; }));
}
};
}

@ -16,6 +16,7 @@ import { DrillingComponent } from './DrillComponent';
import { BoardPropsComponent } from './BoardPropsComponent'; import { BoardPropsComponent } from './BoardPropsComponent';
import { TemplateParamPanel } from './TemplateParamPanel'; import { TemplateParamPanel } from './TemplateParamPanel';
import { MatalPanel } from './MatalsPanel'; import { MatalPanel } from './MatalsPanel';
import { ModelingComponent2 } from './Modeling/ModelingComponent2';
export enum RightTabId export enum RightTabId
{ {
@ -28,6 +29,8 @@ export enum RightTabId
Template = "template", Template = "template",
TemplateParam = "templateparam", TemplateParam = "templateparam",
Matals = "matals", Matals = "matals",
Model2 = "modeing2",
Model3 = "modeing3",
} }
@inject('store') @inject('store')
@ -80,6 +83,8 @@ export class RightPanel extends React.Component<{ store?: RightPanelStore; }>
> >
<Tab className="tab-unstyle" id={RightTabId.BoardProps} title="板件属性" panel={< BoardPropsComponent board={store.currentBoard} />} /> <Tab className="tab-unstyle" id={RightTabId.BoardProps} title="板件属性" panel={< BoardPropsComponent board={store.currentBoard} />} />
<Tab className="tab-unstyle" id={RightTabId.Model} title="造 型" panel={< ModelingComponent />} /> <Tab className="tab-unstyle" id={RightTabId.Model} title="造 型" panel={< ModelingComponent />} />
{/* <Tab className="tab-unstyle" id={RightTabId.Model2} title="V型刀" panel={< ModelingComponent2 store={store.modeling2Store} />} />
<Tab className="tab-unstyle" id={RightTabId.Model3} title="造型刀路" panel={< ModelingComponent2 store={store.modeling3Store} />} /> */}
<Tab className="tab-unstyle" id={RightTabId.Seal} title="封 边" panel={<SealingComponent />} /> <Tab className="tab-unstyle" id={RightTabId.Seal} title="封 边" panel={<SealingComponent />} />
<Tab className="tab-unstyle" id={RightTabId.Drill} title="排 钻" panel={<DrillingComponent />} /> <Tab className="tab-unstyle" id={RightTabId.Drill} title="排 钻" panel={<DrillingComponent />} />
<Tab className="tab-unstyle" id={RightTabId.Scene} title="场 景" panel={<ScenePanel />} /> <Tab className="tab-unstyle" id={RightTabId.Scene} title="场 景" panel={<ScenePanel />} />

@ -197,6 +197,7 @@ export class CommonPanel extends React.Component<ICommonPanelProps, ICommonPanel
Object.assign(this.currentDir, { id: this.props.defaultDirId, path: "", pathNum: [] }); Object.assign(this.currentDir, { id: this.props.defaultDirId, path: "", pathNum: [] });
} }
if (!this.props.renderMenuItems) return; if (!this.props.renderMenuItems) return;
if (this.props.maxDirLength === 0 && !_nodePath) return;
ContextMenu.show( ContextMenu.show(
<Menu> <Menu>
{ {

@ -20,6 +20,7 @@ import { GetRoomCabName } from './GetRoomCabName';
import { ToplineList } from './ToplineList'; import { ToplineList } from './ToplineList';
import { Circle } from './../../../DatabaseServices/Entity/Circle'; import { Circle } from './../../../DatabaseServices/Entity/Circle';
import { GetCloseContour } from '../../../Add-on/Sweep'; import { GetCloseContour } from '../../../Add-on/Sweep';
import { ModalHeader, ModalContainer } from '../Modal/ModalContainer';
interface ITopllineManageProps interface ITopllineManageProps
{ {
@ -99,7 +100,7 @@ export class TopllineManage extends React.Component<ITopllineManageProps, ITopll
return; return;
}; };
let pl = GetCloseContour(plRes.SelectSet.SelectEntityList[0] as Polyline as Circle | Polyline); let pl = GetCloseContour(plRes.SelectSet.SelectEntityList[0] as Circle | Polyline);
if (!pl) if (!pl)
{ {
reset(); reset();
@ -221,25 +222,12 @@ export class TopllineManage extends React.Component<ITopllineManageProps, ITopll
{ {
return ( return (
<div <ModalContainer className="topline">
className={Classes.DIALOG_CONTAINER} <ModalHeader
id="commonModal" title="顶线"
> icon="bold"
<div className={Classes.DIALOG + " topline"}> close={() => app.Editor.ModalManage.Destory()}
<div
className={Classes.DIALOG_HEADER}
data-id="dragArea"
>
<Icon icon="bold" iconSize={18} />
<h4 className="bp3-heading">线</h4>
<Button
aria-label="Close"
minimal
icon="cross"
className={Classes.DIALOG_CLOSE_BUTTON}
onClick={() => app.Editor.ModalManage.Destory()}
/> />
</div>
<div <div
className={Classes.DIALOG_BODY} className={Classes.DIALOG_BODY}
> >
@ -289,8 +277,7 @@ export class TopllineManage extends React.Component<ITopllineManageProps, ITopll
/> />
</div> </div>
</div> </div>
</div> </ModalContainer >
</div >
); );
} }
} }

@ -0,0 +1,50 @@
import { observable } from "mobx";
import { FaceDirection } from "../BoardInterface";
import { IConfigOption } from "../../Components/Board/UserConfig";
import { IConfigStore } from "../BoardStore";
export interface IModeling2Item
{
readonly color: number;
dir: FaceDirection;
knife: { id: string; name: string; };
}
export class Modeling2Store implements IConfigStore
{
@observable configName = "默认";
@observable configsNames: string[] = [];
@observable modelingItems: IModeling2Item[] = [];
isUpdate = true;
constructor()
{
this.InitModelingItems();
}
InitModelingItems()
{
this.modelingItems.length = 0;
for (let i = 0; i < 24; i++)
{
this.modelingItems.push({
color: i + 1,
dir: FaceDirection.Front,
knife: { id: "", name: "" }
});
}
}
InitOption()
{
this.InitModelingItems();
}
SaveConfig()
{
//新的配置
let newConfig: IConfigOption = {};
return newConfig;
}
UpdateOption(cof: IConfigOption)
{
}
}

@ -10,6 +10,7 @@ import { DrillingStore } from "./DrillingStore";
import { LightStore } from "./LightStore"; import { LightStore } from "./LightStore";
import { ModelingStore } from "./ModelingStore"; import { ModelingStore } from "./ModelingStore";
import { SealingStore } from "./SealingStore"; import { SealingStore } from "./SealingStore";
import { Modeling2Store } from "./Modeling2Store";
export class RightPanelStore extends Singleton export class RightPanelStore extends Singleton
@ -23,6 +24,8 @@ export class RightPanelStore extends Singleton
lightStore = new LightStore(); lightStore = new LightStore();
sealingStore = new SealingStore(); sealingStore = new SealingStore();
drillingStore = new DrillingStore(); drillingStore = new DrillingStore();
modeling2Store = new Modeling2Store();
modeling3Store = new Modeling2Store();
constructor() constructor()
{ {
super(); super();

Loading…
Cancel
Save