!293 修复排钻bug

Merge pull request !293 from ZoeLeeFZ/fixSealAndDrill2
pull/293/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent bd43717005
commit 0fb795581c

@ -1,20 +1,21 @@
import { Command } from "../Editor/CommandMachine";
import { toJS } from "mobx";
import { app } from "../ApplicationServices/Application";
import BoardFindModifyModal from "../UI/Components/Board/BoardFindModify";
import { ModalPosition, ModalState } from "../UI/Components/Modal/ModalsManage";
import { BoardFindStore } from "../UI/Store/BoardFindModifyStore";
import { EFindType, IBoardFindOption, ECompareType } from "../UI/Store/BoardFindInterface";
import { arrayLast } from "../Common/ArrayExt";
import { EBoardKeyList } from "../Common/BoardKeyList";
import { GangDrill, GangDrillType } from "../DatabaseServices/3DSolid/GangDrill";
import { Board } from "../DatabaseServices/Board";
import { equaln } from "../Geometry/GeUtils";
import { LineAngularDimension } from "../DatabaseServices/Dimension/2LineAngularDimension";
import { AlignedDimension } from "../DatabaseServices/Dimension/AlignedDimension";
import { Command } from "../Editor/CommandMachine";
import { PromptStatus } from "../Editor/PromptResult";
import { SelectSetBase } from "../Editor/SelectBase";
import { EBoardKeyList } from "../Common/BoardKeyList";
import { userConfig } from "../Editor/UserConfig";
import { arrayLast } from "../Common/ArrayExt";
import { equaln } from "../Geometry/GeUtils";
import BoardFindModifyModal from "../UI/Components/Board/BoardFindModify";
import { ModalPosition } from "../UI/Components/Modal/ModalsManage";
import { ECompareType, EFindType, IBoardFindOption } from "../UI/Store/BoardFindInterface";
import { BoardFindStore } from "../UI/Store/BoardFindModifyStore";
import { LinesType } from "../UI/Store/BoardInterface";
import { AlignedDimension } from "../DatabaseServices/Dimension/AlignedDimension";
import { LineAngularDimension } from "../DatabaseServices/Dimension/2LineAngularDimension";
import { GangDrill, GangDrillType } from "../DatabaseServices/3DSolid/GangDrill";
export class BoardFindModify implements Command
{
@ -23,20 +24,16 @@ export class BoardFindModify implements Command
const store = BoardFindStore.GetInstance() as BoardFindStore;
app.m_Editor.m_ModalManage.RenderModeless(BoardFindModifyModal, ModalPosition.Right, { store });
app.m_Editor.m_SelectCtrl.Cancel();
while (true)
{
const res = await app.m_Editor.m_ModalManage.Wait();
if (res.Status !== ModalState.Ok)
break;
switch (res.Data.type)
app.m_Editor.m_ModalManage.Callback = async (res) =>
{
switch (res.type)
{
case EFindType.Find:
await this.FindBrs(store.m_Option);
break;
case EFindType.Modify:
await this.ModifyBrs(store.m_Option);
await this.ModifyBrs(toJS(store.m_Option));
break;
case EFindType.FindMaxSize:
await this.FindMaxSizeBrs();
@ -49,13 +46,16 @@ export class BoardFindModify implements Command
default:
break;
}
app.m_Editor.m_ModalManage.ToggleShow();
if (store.m_Option.isClose && res.Data.type !== EFindType)
break;
if (store.m_Option.isClose)
{
app.m_Editor.m_ModalManage.Clear();
app.m_Editor.m_ModalManage.EndCmd();
}
else
{
app.m_Editor.m_MaskManage.ShowMask();
app.m_Editor.m_ModalManage.ToggleShow();
}
}
}
@ -252,11 +252,14 @@ export class BoardFindModify implements Command
case EBoardKeyList.Mat:
br.BoardProcessOption[EBoardKeyList.Mat] = option[EBoardKeyList.Mat];
break;
case EBoardKeyList.DrillType:
br.BoardProcessOption[i] = option[i];
br.BoardProcessOption.highDrill.fill(option[i], 2);
break;
case EBoardKeyList.RoomName:
case EBoardKeyList.CabinetName:
case EBoardKeyList.Lines:
case EBoardKeyList.BigHole:
case EBoardKeyList.DrillType:
case EBoardKeyList.ComposingFace:
br.BoardProcessOption[i] = option[i];
break;
@ -266,7 +269,8 @@ export class BoardFindModify implements Command
case EBoardKeyList.RightSealed:
if (option[i])
br.BoardProcessOption[i] = option[i];
br.BoardProcessOption.highDrill = option.highDrill;
if (!br.IsSpecialShape)
br.BoardProcessOption.highDrill = option.highDrill;
break;
default:
break;

@ -5,6 +5,7 @@ import { MoveMatrix } from '../../Geometry/GeUtils';
import { BehindBoardOption, BehindHeightPositon, BrRelativePos } from '../../UI/Store/BoardInterface';
import { DrawBoardTool } from './DrawBoardTool';
import { BehindBoardStore } from '../../UI/Store/BoardStore';
import { toJS } from 'mobx';
export class DrawBehindBoard extends DrawBoardTool
{
@ -62,6 +63,7 @@ export class DrawBehindBoard extends DrawBoardTool
board.GroovesAddDepth = parseFloat(grooveOption.grooveAddDepth);
board.GroovesAddWidth = parseFloat(grooveOption.grooveAddWidth);
board.GroovesAddLength = parseFloat(grooveOption.grooveAddLength);
board.BoardProcessOption = toJS(this.store.m_BoardProcessOption);
opt.height = height;
opt.width = size.x;
@ -73,7 +75,6 @@ export class DrawBehindBoard extends DrawBoardTool
{
let b = board.Clone();
b.Name = opt.name;
b.BoardProcessOption = this.store.m_BoardProcessOption;
if (relPos === BrRelativePos.Front)
b.ApplyMatrix(MoveMatrix(newBox.min.clone().add(new Vector3(0, spaceSize * i + thickness * i, 0))));

@ -70,7 +70,6 @@ export class DrawLayerBoard extends DrawBoardTool
{
let b = board.Clone() as Board;
b.Name = opt.name;
b.BoardProcessOption = this.store.m_BoardProcessOption;
if (type === BrRelativePos.Top)
b.ApplyMatrix(MoveMatrix(spaceBox.min.clone().add(

@ -5,6 +5,7 @@ import { MoveMatrix } from '../../Geometry/GeUtils';
import { BrRelativePos, VerticalBoardOption } from '../../UI/Store/BoardInterface';
import { } from '../../UI/Store/BoardStore';
import { DrawBoardTool } from './DrawBoardTool';
import { toJS } from 'mobx';
export class DrawVerticalBoard extends DrawBoardTool
{
@ -44,6 +45,7 @@ export class DrawVerticalBoard extends DrawBoardTool
let thickness = opt.thickness;
let board = Board.CreateBoard(length, width, thickness, BoardType.Vertical);
board.BoardProcessOption = toJS(this.store.m_BoardProcessOption);
opt.height = length;
opt.width = width;
@ -54,7 +56,6 @@ export class DrawVerticalBoard extends DrawBoardTool
{
let b = board.Clone() as Board;
b.Name = opt.name;
b.BoardProcessOption = this.store.m_BoardProcessOption;
if (type === BrRelativePos.Left)
b.ApplyMatrix(MoveMatrix(spaceBox.min.clone().add(

@ -0,0 +1,24 @@
import { Command } from "../../Editor/CommandMachine";
import { app } from "../../ApplicationServices/Application";
import { Board } from "../../DatabaseServices/Board";
import { PromptStatus } from "../../Editor/PromptResult";
export class DeleteDrill implements Command
{
async exec()
{
let brRes = await app.m_Editor.GetSelection({
Msg: "选择板件",
Filter: { filterTypes: [Board] }
});
if (brRes.Status !== PromptStatus.OK) return;
let brs = brRes.SelectSet.SelectEntityList as Board[];
for (let br of brs)
{
br.ClearAllDrill();
}
}
}

@ -26,17 +26,13 @@ export class DrawDrillingTool extends Singleton
/**获取用户正在使用的配置 */
private GetDrillingConfig(type: string)
{
const store = DrillStore.GetInstance() as DrillStore;
let configs = toJS(userConfig.drillConfigs, { exportMapsAsObjects: false });
let configs = toJS(userConfig.DrillConfigs, { exportMapsAsObjects: false });
if (configs && configs.size > 0)
{
if (configs.has(type))
return configs.get(type);
else
return configs.get(store.type);
}
else
return store.rules;
return [];
}
private GetRuleByFace(f: Face)
{
@ -367,7 +363,7 @@ export class DrawDrillingTool extends Singleton
{
for (let refDr of refDrillList)
{
if (this.IsCollision(ds, refDr))
if (this.IsCollision(ds.filter(id => id.Object), refDr.filter(id => id.Object)))
{
let offsetDist = this.m_Option.collsionDist;
this.MoveDrillEnts(ds, offsetDist, this.m_Face.IsPositiveFace ? 1 : -1);
@ -383,7 +379,7 @@ export class DrawDrillingTool extends Singleton
for (let objId1 of drs2)
{
let d2 = objId1.Object as GangDrill;
if (d1.Collise(d2))
if (!equaln(d1.Position.distanceTo(d2.Position), this.m_Face.m_LocalBoard.Thickness) && d1.Collise(d2))
{
return true;
}
@ -410,7 +406,7 @@ export class DrawDrillingTool extends Singleton
if (!suitableOption)
{
app.m_Editor.Prompt("长度" + f.m_Length + "没有合适的规则");
app.m_Editor.Prompt("长度" + f.m_Length + "没有合适的规则,或者当前配置不存在" + f.drillType + "类型排钻");
continue;
}
let notGangDist = suitableOption.notGangDist;

@ -628,7 +628,10 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
if (pl)
{
let br = Board.CreateBoard(1, 1, config.boardThick);
br.Name = (d.isLeft ? "右板" : "左板") + (i + 1);
if (d.isLeft)
br.Name = "右板" + (lData.length - i);
else
br.Name = "左板" + (i + 1);
br.ContourCurve = pl;
this.ParseHighSealing(br, config.leftEdge, config.rightEdge, config.topEdge, config.bottomEdge, d.isLeft);
br.RotateBoard(0, Math.PI / 4 * (d.isLeft ? -1 : 1), 0);

@ -5,7 +5,7 @@ import { WineRackStore } from "../../UI/Store/WineRackStore";
import { Vector3 } from "three";
import { operationExpReg } from "../../Common/Utils";
import { Board, BoardType } from "../../DatabaseServices/Board";
import { IHighSealedItem } from "../../UI/Store/BoardInterface";
import { IHighSealedItem, DrillType } from "../../UI/Store/BoardInterface";
import { app } from "../../ApplicationServices/Application";
export const SIN45 = Math.sin(Math.PI / 4);
@ -82,6 +82,7 @@ export class DrawWineRackTool extends Singleton
highSeals.push(topSeal, leftSeal);
}
br.BoardProcessOption.highSealed = highSeals;
br.BoardProcessOption.drillType = DrillType.None;
}
/**补板 */
protected AddLayerOrVerticalBoard(actWidth: number, actHeight: number)

@ -0,0 +1,56 @@
import { IndexedDbStore, StoreName } from "../IndexedDb/IndexedDbStore";
import { BoardModalType } from "../UI/Components/Board/BoardModal";
import { Command } from "../Editor/CommandMachine";
import { FileSystem } from "../Common/FileSystem";
import { HotCMD } from "../Hot/HotCommand";
@HotCMD
export class DownLoadDrillConfig implements Command
{
async exec()
{
let dbstore = await IndexedDbStore.CADStore();
let configs = await dbstore.Get(StoreName.ConfigData, BoardModalType.Dr);
if (configs)
{
let data = {};
for (let [k, v] of configs)
{
let obj = {};
for (let [k1, v1] of v.ruleMap)
{
obj[k1] = v1;
}
data[k] = { ruleMap: obj };
}
FileSystem.writeFile("drillconfig.json", JSON.stringify(data));
}
}
}
export class UpLoadDrillConfig implements Command
{
async exec()
{
let dbstore = await IndexedDbStore.CADStore();
FileSystem.chooseFile(async files =>
{
if (files.length === 1)
{
let f = files[0];
let fileData = JSON.parse(await FileSystem.readFileAsText(f));
let config = new Map();
for (let key in fileData)
{
let v = fileData[key];
let rule = new Map();
for (let k1 in v.ruleMap)
{
rule.set(k1, v.ruleMap[k1]);
}
config.set(key, { ruleMap: rule });
}
await dbstore.Put(StoreName.ConfigData, BoardModalType.Dr, config);
}
}, ".json", false);
}
}

@ -51,11 +51,15 @@ export class GangDrill extends Solid3D
}
set Height(v: number)
{
this.WriteAllObjectRecord();
this.m_Height = v;
this.Update();
}
set Radian(r: number)
{
this.WriteAllObjectRecord();
(this.m_Shape.Outline.Curve as Circle).Radius = r;
this.Update();
}
get Radian()
{

@ -80,7 +80,7 @@ export class Board extends ExtureSolid
color: "",
lines: LinesType.Positive,
bigHoleDir: FaceDirection.Front,
drillType: [...userConfig.drillConfigs.keys()][0],
drillType: "",
composingFace: ComposingType.Arbitrary,
highSealed: [],
sealedUp: "1",
@ -92,6 +92,8 @@ export class Board extends ExtureSolid
spliteThickness: "",
highDrill: [],
};
if (userConfig.DrillConfigs.size > 0)
this.m_BoardProcessOption.drillType = [...userConfig.DrillConfigs.keys()][0];
}
//初始化板件 来自长宽高
@ -242,6 +244,22 @@ export class Board extends ExtureSolid
this.m_DrillList.delete(k);
}
}
ClearAllDrill()
{
this.WriteAllObjectRecord();
for (const [id, dris] of this.m_DrillList)
{
if (id)
{
for (let dri of dris)
{
for (let d of dri)
if (d && d.Object)
d.Object.Erase();
}
}
}
}
Erase(isErase: boolean = true)
{
if (isErase === this.IsErase)

@ -108,6 +108,8 @@ import { ConfigureWineRack } from '../Add-on/DrawWineRack/ConfigureWineRack';
import { DrawWineRack, DrawWineRack2 } from '../Add-on/DrawWineRack/DrawWineRack';
import { DrawLattice } from '../Add-on/LatticeDrawer/DrawLatticeDrawer';
import { TestFb } from '../Add-on/TestFb';
import { DeleteDrill } from '../Add-on/DrawDrilling/DeleteDrill';
import { DownLoadDrillConfig, UpLoadDrillConfig } from '../Add-on/LoadConfig';
export function registerCommand()
@ -249,6 +251,7 @@ export function registerCommand()
commandMachine.RegisterCommand("rotatelybr", new RotateLayerBoard());
commandMachine.RegisterCommand("drawer", new DrawDrawrer());
commandMachine.RegisterCommand("deletedrill", new DeleteDrill());
//修改颜色命令
for (let i = 0; i < 24; i++)
@ -301,6 +304,10 @@ export function registerCommand()
commandMachine.RegisterCommand("Wireframe", new CMD_Wireframe());
commandMachine.RegisterCommand("Conceptual", new CMD_Conceptual());
//导入导出排钻配置
commandMachine.RegisterCommand("downloaddrconfig", new DownLoadDrillConfig());
commandMachine.RegisterCommand("uploaddrconfig", new UpLoadDrillConfig());
RegistCustomCommand();
}

@ -11,7 +11,7 @@ class UserConfig
maxHeight = 2440;
maxWidth = 1220;
isContinuousDraw = false; //是否连续绘制层板立板背板...
@observable drillConfigs: Map<string, DrillingOption[]> = new Map();
@observable private _drillConfigs: Map<string, DrillingOption[]> = new Map();
constructor()
{
this.Init();
@ -36,7 +36,14 @@ class UserConfig
get RenderType() { return this._renderType; }
SetRenderTypeEvent() { }
get DrillConfigs()
{
return this._drillConfigs || new Map();
}
set DrillConfigs(config: Map<string, DrillingOption[]>)
{
observable(this._drillConfigs).replace(config);
}
}
export const userConfig = new UserConfig();

@ -56,4 +56,11 @@ export class Box3Ext extends Box3
interBox.max.setComponent(splitType, Math.max(this.min.getComponent(splitType), b2.min.getComponent(splitType)));
return interBox;
}
intersectsBox(box: this, fuzz = 1e-8)
{
// 重载three.js的相交判断,加入误差
return box.max.x < this.min.x - fuzz || box.min.x > this.max.x + fuzz ||
box.max.y < this.min.y - fuzz || box.min.y > this.max.y + fuzz ||
box.max.z < this.min.z - fuzz || box.min.z > this.max.z + fuzz ? false : true;
}
}

@ -124,8 +124,8 @@ export class BoardGetFace
{
//都是正面,或者不允许侧面同侧面并且2板件类型不一样就跳过
if (f1.type === f2.type
&& (f1.type !== BoardFaceType.NoSide || !bInsEqual)
&& br.m_Board.BoardType !== this.m_Board.BoardType)
&& (f1.type === BoardFaceType.NoSide || !bInsEqual || br.m_Board.BoardType !== this.m_Board.BoardType)
)
continue;
//不共面
if (!matrixIsCoplane(f1.OCS, f2.OCS, 1e-4))

@ -417,6 +417,17 @@ interface IDrillTypeSelect
export class DrillTypeSelectCom extends React.Component<IDrillTypeSelect, {}>{
private editorDrilling(br: Board)
{
const options = this.props.drillConfigs ? ["",
...this.props.drillConfigs.keys(), "不排"
] : [];
if (!options.includes(this.props.br.BoardProcessOption.drillType))
{
AppToaster.show({
message: "您当前没有对应的排钻配置,请先选择排钻类型,然后确定写入板件,或者选择批量修改",
timeout: 2000
});
return;
}
app.m_Editor.m_ModalManage.Clear();
let store = RightPanelStore.GetInstance() as RightPanelStore;
store.m_IsShow = true;
@ -430,14 +441,11 @@ export class DrillTypeSelectCom extends React.Component<IDrillTypeSelect, {}>{
private handleChange = (e) =>
{
this.props.opt.drillType = e.target.value;
if (this.props.br && !this.props.br.IsSpecialShape)
{
this.props.opt.highDrill.fill(e.target.value, 2);
}
this.props.opt.highDrill.fill(e.target.value, 2);
}
render()
{
const options = this.props.drillConfigs ? [
const options = this.props.drillConfigs ? ["",
...this.props.drillConfigs.keys(), "不排"
] : [];
const select = <HTMLSelect

@ -14,7 +14,6 @@ import { observable } from 'mobx';
import { LinesType, FaceDirection, ComposingType, DrillType } from '../../Store/BoardInterface';
import { userConfig } from '../../../Editor/UserConfig';
interface IBoardFindState
{
userInputName: string;
@ -114,8 +113,7 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
const matPars1 = [
["房名", EBoardKeyList.RoomName], ["柜名", EBoardKeyList.CabinetName],
]
const selectOptions = userConfig.drillConfigs ? [...userConfig.drillConfigs.keys(), "不排"] : [];
const selectOptions = userConfig.DrillConfigs.size > 0 ? [...userConfig.DrillConfigs.keys(), "不排"] : [];
return (
<div
className={Classes.DIALOG_CONTAINER}

@ -105,6 +105,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
if (oldDrillType !== this.m_ProcessOption.drillType)
{
board.BoardProcessOption.highDrill.fill(this.m_ProcessOption.drillType);
(DrawDrillingTool.GetInstance() as DrawDrillingTool).ResetGangDrill(board);
}

@ -40,7 +40,7 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
}
async componentWillMount()
{
this.drillConfigs = userConfig.drillConfigs;
this.drillConfigs = userConfig.DrillConfigs;
}
render()
{
@ -98,7 +98,6 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
this.props.opt.lines = parseFloat(e.target.value);
}}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
@ -217,7 +216,7 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
rightKey="sealedRight"
option={this.props.opt}
drillConfigs={this.drillConfigs}
isShowEditor={Boolean(this.props.br)}
isShowEditor={true}
/>
}
</div>

@ -212,7 +212,6 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
onChange={e =>
{
store.m_Option.tIsOffset = e.currentTarget.value === "0";
store.m_Option.tIsChange = e.currentTarget.value === "1";
}}
>
<Radio label="通孔偏移" value="0" />
@ -224,7 +223,7 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
optKey="tHoleOffset"
option={store.m_Option}
title="偏移距离"
isDisabled={store.m_Option.tIsChange}
isDisabled={!store.m_Option.tIsOffset}
/>
<SetBoardDataItem
type={CheckObjectType.DR}

@ -79,8 +79,8 @@ export class UserConfig extends React.Component<IConfigProps, UserConfigState>{
}
else if (type !== BoardModalType.Zx)
{
let curName = localStorage.getItem("configName");
if (!curName)
let curName = localStorage.getItem("configName_" + type);
if (!curName || !confNames.includes(curName))
curName = arrayLast(confNames);
this._userConfigStore.configName = curName;
this.updateBoardOption(curName);

@ -457,6 +457,15 @@ export const CommandList: ICommand[] = observable([
// enName: "DrillConfig",
chDes: "排钻配置",
},
{
typeId: "pz",
link: "#",
defaultCustom: "DELETEDRILL",
command: "DELETEDRILL",
type: "排钻",
chName: "删除排钻",
chDes: "删除排钻",
},
//视图命令
{

@ -24,9 +24,10 @@ export class MainContent extends React.Component<{ store?: TopPanelStore }>
}
async componentDidMount()
{
//TODO:暂时在页面加载完后初始化排钻配置
let config = await userConfigStore.GetConfig(BoardModalType.Dr);
if (config)
userConfig.drillConfigs = config.ruleMap;
userConfig.DrillConfigs = config.ruleMap;
else
await userConfigStore.SaveConfig(BoardModalType.Dr, DrillStore.GetInstance(), true);
}

@ -157,12 +157,12 @@ export class ModalManage
await Sleep(10);
}
}
async ExecCmd()
async ExecCmd(data?)
{
await this.EndExecingCmd();
if (commandMachine.CommandStart("draw") !== true)
return;
await this.Callback();
await this.Callback(data);
commandMachine.CommandEnd();
}
Wait(): Promise<IModalResult>

@ -1,39 +1,23 @@
import { Button, Classes, HTMLSelect, Intent, Label } from '@blueprintjs/core';
import { toJS } from 'mobx';
import { inject, observer } from 'mobx-react';
import * as React from 'react';
import { ColorMaterial } from '../../../Common/ColorPalette';
import { userConfig } from '../../../Editor/UserConfig';
import { IndexedDbStore, StoreName } from '../../../IndexedDb/IndexedDbStore';
import { DrillType } from '../../Store/BoardInterface';
import { RightPanelStore } from '../../Store/RightPanelStore';
import { RightTabId } from './RightPanel';
@inject("store")
@observer
export class DrillingComponent extends React.Component<{ store?: RightPanelStore }>
{
private save = async () =>
{
const store = this.props.store;
let dbstore = await IndexedDbStore.CADStore();
let drillData = await dbstore.Get(StoreName.ConfigData, RightTabId.Drill) as string[];
if (drillData)
{
drillData.length = 0;
drillData.push(...toJS(store.drillDataList));
}
else
drillData = toJS(store.drillDataList);
dbstore.Put(StoreName.ConfigData, RightTabId.Drill, drillData);
}
render()
{
const store = this.props.store;
const options = userConfig.drillConfigs ? [
...userConfig.drillConfigs.keys(), "不排"
const options = userConfig.DrillConfigs.size > 0 ? [
...userConfig.DrillConfigs.keys(), "不排"
] : [];
const options2 = ["排", "不排"];
const options2 = [DrillType.Yes, DrillType.None];
return (
<>
<ul className={"modeling drilling " + Classes.LIST_UNSTYLED}>
@ -91,11 +75,9 @@ export class DrillingComponent extends React.Component<{ store?: RightPanelStore
</>
}
</ul>
<div className="flex-arround">
<div className="flex-end">
<Button text="确定" intent={Intent.SUCCESS} onClick={() => store.WriteDrillData()}
/>
<Button text="保存" intent={Intent.SUCCESS} onClick={this.save}
/>
<Button text="退出" intent={Intent.DANGER} onClick={() => store.ExitEditor()}
/>
</div>

@ -12,10 +12,6 @@ import { RightTabId } from './RightPanel';
@observer
export class SealingComponent extends React.Component<{ store?: RightPanelStore }>
{
private addColor = () =>
{
this.props.store.highSizes.push("1");
}
private save = async () =>
{
const store = this.props.store;

@ -581,6 +581,10 @@ div {
.flex();
justify-content: center;
}
.flex-end{
.flex();
justify-content: flex-end;
}
.half {
width: 50%;
}

@ -67,7 +67,7 @@ export class BoardFindStore extends BoardStore
color: "",
lines: LinesType.Positive,
bigHoleDir: FaceDirection.Front,
drillType: [...userConfig.drillConfigs.keys()][0],
drillType: [...userConfig.DrillConfigs.keys()][0],
composingFace: ComposingType.Positive,
sealedUp: "",
sealedDown: "",
@ -83,24 +83,30 @@ export class BoardFindStore extends BoardStore
constructor()
{
super();
let drilltypes = [...userConfig.drillConfigs.keys()];
this.InitDrillType();
}
private InitDrillType()
{
let drilltypes = [...userConfig.DrillConfigs.keys()];
if (drilltypes.length > 0)
{
this.m_Option.highDrill.push(...Array(6).fill(drilltypes[0]));
this.m_Option.drillType = drilltypes[0];
}
}
async OnOk<T>(state: number, data?: T)
{
if ((this.m_Option.isClose || state === ModalState.Cancel))
if ((state === ModalState.Cancel))
{
app.m_Editor.m_ModalManage.Clear();
app.m_Editor.m_ModalManage.EndCmd();
}
else
{
app.m_Editor.m_MaskManage.Clear();
app.m_Editor.m_ModalManage.ToggleShow();
await app.m_Editor.m_ModalManage.ExecCmd(data);
}
app.m_Editor.m_ModalManage.m_PromisRes({ Status: state, Data: data });
app.m_Editor.m_ModalManage.EndCmd();
}
SaveConfig()
{
@ -112,6 +118,7 @@ export class BoardFindStore extends BoardStore
UpdateOption(cof: IConfigOption)
{
Object.assign(this.m_Option, cof.option);
this.InitDrillType();
this.CheckIsSelectAll();
this.isRevSelect = false;
}

@ -40,14 +40,21 @@ export class BoardStore extends Singleton implements IConfigStore
sealedRight: "1",
spliteHeight: "",
spliteWidth: "",
spliteThickness: ""
spliteThickness: "",
highDrill: [],
}
constructor()
{
super();
let drilltypes = [...userConfig.drillConfigs.keys()];
if (drilltypes.length > 0)
this.m_BoardProcessOption.drillType = drilltypes[0];
if (userConfig.DrillConfigs)
{
let drilltypes = [...userConfig.DrillConfigs.keys()];
if (drilltypes.length > 0)
{
this.m_BoardProcessOption.drillType = drilltypes[0];
observable(this.m_BoardProcessOption.highDrill).replace(Array(6).fill(drilltypes[0]));
}
}
}
get UIOption()
{

@ -126,6 +126,7 @@ export class DrillStore extends BoardStore
let rule = this.rules[i];
if (rule.startDist === this.m_Option.startDist && rule.endDist === this.m_Option.endDist)
{
this.m_CurrentRuleIndex = i;
hasEqualRule = false;
break;
}
@ -149,10 +150,10 @@ export class DrillStore extends BoardStore
//新的配置
let newConfig: IConfigOption = {};
this.SaveRuleOption();
let config = toJS(this.drillConfig, { exportMapsAsObjects: false });
let config = this.drillConfig;
if (config.has(this.type))
config.set(this.type, toJS(this.rules))
newConfig.ruleMap = config;
newConfig.ruleMap = toJS(config, { exportMapsAsObjects: false });
return newConfig;
}
UpdateOption(cof: IConfigOption)

@ -163,7 +163,7 @@ export class RightPanelStore extends Singleton implements IConfigStore
let drillData = await dbstore.Get(StoreName.ConfigData, RightTabId.Drill);
if (!drillData)
drillData = [];
let types = [...userConfig.drillConfigs.keys(), "不排"];
let types = [...userConfig.DrillConfigs.keys(), "不排"];
drillData[0] = drillData[0] || DrillType.Yes;
drillData[1] = drillData[1] || DrillType.Yes;
for (let i = 0, len = types.length; i < len; i++)
@ -239,20 +239,25 @@ export class RightPanelStore extends Singleton implements IConfigStore
}
WriteDrillData()
{
if (!this.currentBoard)
return;
if (!commandMachine.CommandStart("_editor"))
return;
const highDrill = this.currentBoard.BoardProcessOption.highDrill;
highDrill.length = 0;
highDrill.push(...this.drillDataList.slice(0, 2));
let defultType = [...userConfig.drillConfigs.keys()][0];
let types = [...userConfig.DrillConfigs.keys(), DrillType.None];
let defaultType = types[0];
if (!types.includes(this.currentBoard.BoardProcessOption.drillType))
this.currentBoard.BoardProcessOption.drillType = defaultType;
for (let cu of this.cuList)
{
let type = this.drillDataList[cu.ColorIndex + 1];
if (!type)
{
AppToaster.show({ message: "未知色号,默认三合一", timeout: 1000 });
type = defultType;
AppToaster.show({ message: "未知色号,默认" + defaultType, timeout: 1000 });
type = defaultType;
}
highDrill.push(type);
}
@ -273,6 +278,7 @@ export class RightPanelStore extends Singleton implements IConfigStore
// this.RemoveEvent();
JigUtils.Destroy();
AppToaster.clear();
this.currentBoard = null;
}
SaveConfig()
{

@ -7,6 +7,7 @@ import { IConfigStore } from "./BoardStore";
import { BoardModalType } from "../Components/Board/BoardModal";
import { arrayLast } from "../../Common/ArrayExt";
import { userConfig } from "../../Editor/UserConfig";
import { RightPanelStore } from "./RightPanelStore";
export class UserConfigStore extends Singleton
{
@ -19,7 +20,7 @@ export class UserConfigStore extends Singleton
if (configs)
{
let confNames = [...configs.keys()];
let curName = localStorage.getItem("configName");
let curName = localStorage.getItem("configName_" + type);
if (!curName)
curName = arrayLast(confNames);
return configs.get(curName);
@ -55,9 +56,9 @@ export class UserConfigStore extends Singleton
message: isInit ? "初始化配置成功" : "配置保存成功",
timeout: 1000
});
localStorage.setItem("configName", name);
localStorage.setItem("configName_" + type, name);
if (type === BoardModalType.Dr)
userConfig.drillConfigs = newConfig.ruleMap;
userConfig.DrillConfigs = newConfig.ruleMap;
}
//删除配置
async DeleteConfig(type: BoardModalType, store: IConfigStore)
@ -86,10 +87,10 @@ export class UserConfigStore extends Singleton
let newName = confNames.length > 0 ? confNames[0] : "";
this.configName = newName;
await this.UpdateBoardOption(newName, type, store);
localStorage.setItem("configName", newName);
localStorage.setItem("configName_" + type, newName);
if (type === BoardModalType.Dr)
userConfig.drillConfigs = brDataMap.get(newName).ruleMap;
userConfig.DrillConfigs = brDataMap.get(newName).ruleMap;
}
//更新配置
UpdateBoardOption = async (k: string, type: BoardModalType, store: IConfigStore) =>
@ -101,9 +102,12 @@ export class UserConfigStore extends Singleton
if (brDataMap && conf)
{
store.UpdateOption(conf);
localStorage.setItem("configName", k);
localStorage.setItem("configName_" + type, k);
if (type === BoardModalType.Dr)
userConfig.drillConfigs = conf.ruleMap;
{
userConfig.DrillConfigs = conf.ruleMap;
(RightPanelStore.GetInstance() as RightPanelStore).InitDrillingData();
}
}
}

@ -1,8 +1,3 @@
export enum DrillType
{
Three = "three",
Two = "two"
}
export enum SpacingType
{
Multiple32 = "32",

Loading…
Cancel
Save