!288 fixed #IV3Z2 #ITJB3

Merge pull request !288 from ZoeLeeFZ/optSealAndDrill
pull/288/MERGE
ZoeLeeFZ 6 years ago committed by ChenX
parent f95e0ff9fa
commit 5d2456a98e

@ -90,3 +90,21 @@ test("异型板件,非相切圆弧", () =>
sealingSize = [3, 5, 3, 3, 3];
testBrSealing(br, sealingSize);
})
test("丢失线段板件", () =>
{
let data =
[1, "Board", 3, 2, 101, false, 1, 1, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 817.4143763202346, -26.547581507291397, -408.40778761079696, 1], 2, 1200.0000000000002, 600, 18, false, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1025.70079227525, -1279.6056228760524, 0, 1], 2, 54, [1025.70079227525, 2058.576017106141], 0, [1325.865855638082, 2058.576017106141], 0.41421356237309503, [1345.865855638082, 2078.576017106141], 0, [1345.865855638082, 2097.321917106141], 0.41421356237309503, [1325.865855638082, 2117.321917106141], 0, [1025.70079227525, 2137.2691008583533], 0, [1025.70079227525, 2137.2691008583533], -0.41421356237309503, [1045.70079227525, 2157.2691008583533], 0, [1325.865855638082, 2157.2691008583533], 0.41421356237309503, [1345.865855638082, 2177.2691008583533], 0, [1345.865855638082, 2196.0150008583532], 0.41421356237309503, [1325.865855638082, 2216.0150008583532], 0, [1025.70079227525, 2216.0150008583532], 0, [1025.70079227525, 2248.912678628265], 0, [1325.865855638082, 2248.912678628265], 0.41421356237309503, [1345.865855638082, 2268.912678628265], 0, [1345.865855638082, 2287.658578628265], 0.41421356237309503, [1325.865855638082, 2307.658578628265], 0, [1045.70079227525, 2307.658578628265], -0.41421356237309503, [1025.70079227525, 2327.658578628265], 0, [1025.70079227525, 2479.6056228760526], 0, [1625.70079227525, 2479.6056228760526], 0, [1625.70079227525, 1279.6056228760524], 0, [1025.70079227525, 1279.6056228760524], 0, [1025.70079227525, 1375.9224547698577], -0.41421356237309503, [1045.70079227525, 1395.9224547698577], 0, [1345.865855638082, 1395.9224547698577], 0, [1345.865855638082, 1404.6683547698576], 0.41421356237309503, [1295.865855638082, 1454.6683547698576], 0, [1025.70079227525, 1454.6683547698576], 0, [1025.70079227525, 1522.813562451274], 0, [1325.865855638082, 1522.813562451274], 0.41421356237309503, [1345.865855638082, 1542.813562451274], 0, [1345.865855638082, 1561.559462451274], 0.41421356237309503, [1325.865855638082, 1581.559462451274], 0, [1045.70079227525, 1581.559462451274], -0.41421356237309503, [1025.70079227525, 1601.559462451274], 0, [1025.70079227525, 1652.6155645751674], -0.41421356237309503, [1045.70079227525, 1672.6155645751674], 0, [1345.865855638082, 1672.6155645751674], 0, [1345.865855638082, 1701.988514575167], 0, [1045.70079227525, 1731.3614645751672], -0.41421356237309503, [1025.70079227525, 1751.3614645751672], 0, [1025.70079227525, 1761.8829073008312], -0.41421356237309503, [1045.70079227525, 1781.8829073008312], 0, [1363.4896205938342, 1781.8829073008312], 0, [1363.4896205938342, 1840.628807300831], 0, [1025.70079227525, 1881.684909424725], 0, [1025.70079227525, 1881.684909424725], -0.41421356237309503, [1075.70079227525, 1931.684909424725], 0, [1345.865855638082, 1931.684909424725], 0, [1345.865855638082, 1990.4308094247249], 0, [1075.70079227525, 1990.4308094247249], -0.41421356237309503, [1025.70079227525, 2040.4308094247249], 0, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -401.8444990614662, -7520.408091226085, -408.40778761079696, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0]
//第3段为圆弧
let br = LoadBoardsFromFileData(data)[0];
let sealingSize = [];
for (let i = 0; i < 20; i++)
sealingSize.push(1);
testBrSealing(br, sealingSize);
data = [1, "Board", 3, 2, 103, false, 1, 1, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 475.1861812309362, -119.62672264222056, 591, 1], 2, 799.9999999999999, 600, 18, false, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -102.47516991969519, 1419.0110848098525, 0, 1], 2, 39, [122.47516991969519, -814.6847031918554], 0, [340.6340264789152, -814.6847031918554], 0.41421356237309503, [360.6340264789152, -794.6847031918554], 0, [360.63402647891513, -756.0122031918554], 0, [102.47516991969522, -756.0122031918554], 0, [102.47516991969522, -639.0110848098526], -0.41421356237309503, [122.47516991969522, -619.0110848098526], 0, [682.4751699196952, -619.0110848098526], -0.41421356237309503, [702.4751699196952, -639.0110848098526], 0, [702.4751699196952, -1399.0110848098525], -0.41421356237309503, [682.4751699196952, -1419.0110848098525], 0, [102.47516991969522, -1419.0110848098525], 0, [102.47516991969519, -1251.259221730597], -0.41421356237309503, [122.47516991969519, -1231.259221730597], 0, [360.63402647891513, -1231.259221730597], 0, [360.63402647891513, -1172.5867217305968], 0, [122.47516991969522, -1172.5867217305968], -0.41421356237309503, [102.47516991969522, -1152.5867217305968], 0, [102.4751699196952, -1137.3832738908804], 0, [340.63402647891513, -1137.3832738908804], 0.41421356237309503, [360.63402647891513, -1117.3832738908804], 0, [360.63402647891513, -1078.7107738908805], 0, [102.47516991969522, -1078.7107738908805], 0, [102.4751699196952, -1031.7728325711996], 0, [340.63402647891513, -1031.7728325711996], 0.41421356237309503, [360.63402647891513, -1011.7728325711997], 0, [360.63402647891513, -993.1003325711996], 0.41421356237309503, [340.63402647891513, -973.1003325711996], 0, [122.47516991969519, -973.1003325711996], -0.41421356237309503, [102.47516991969519, -953.1003325711996], 0, [102.47516991969519, -948.1181401648461], -0.41421356237309503, [122.47516991969519, -928.1181401648461], 0, [340.6340264789152, -928.1181401648461], 0.41421356237309503, [360.6340264789152, -908.1181401648461], 0, [360.6340264789152, -889.4456401648459], 0.41421356237309503, [340.6340264789152, -869.4456401648459], 0, [122.47516991969522, -869.4456401648459], -0.41421356237309503, [102.47516991969522, -849.4456401648459], 0, [102.47516991969519, -834.6847031918554], -0.41421356237309503, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 475.1861812309362, -119.62672264222056, 591, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":1,\"color\":1},{\"size\":1,\"color\":1},{\"size\":1,\"color\":1},{\"size\":2,\"color\":2},{\"size\":3,\"color\":3},{\"size\":4,\"color\":4},{\"size\":5,\"color\":5},{\"size\":6,\"color\":6},{\"size\":8,\"color\":7},{\"size\":7,\"color\":8},{\"size\":9,\"color\":9},{\"size\":10,\"color\":10},{\"size\":11,\"color\":11},{\"size\":12,\"color\":12},{\"size\":13,\"color\":13},{\"size\":14,\"color\":14},{\"size\":15,\"color\":15},{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":1,\"color\":1}],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0];
br = LoadBoardsFromFileData(data)[0];
sealingSize = [];
for (let i = 0; i < 9; i++)
sealingSize.push(1);
testBrSealing(br, sealingSize);
})

@ -1,5 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`丢失线段板件 1`] = `538651.2759963807`;
exports[`丢失线段板件 2`] = `398758.87896958226`;
exports[`常规板件,常规坐标系 1`] = `716404`;
exports[`常规板件,常规坐标系 2`] = `711624`;

@ -264,7 +264,9 @@ export class BoardFindModify implements Command
case EBoardKeyList.DownSealed:
case EBoardKeyList.LeftSealed:
case EBoardKeyList.RightSealed:
if (option[i])
br.BoardProcessOption[i] = option[i];
br.BoardProcessOption.highDrill = option.highDrill;
break;
default:
break;

@ -7,6 +7,7 @@ import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal
import { ModalPosition } from '../../UI/Components/Modal/ModalsManage';
import { BehindBoardStore, LayerBoardStore, VerticalBoardStore } from '../../UI/Store/BoardStore';
import { ISpaceParse } from '../../Geometry/SpaceParse/ISpaceParse';
import { userConfig } from '../../Editor/UserConfig';
export abstract class DrawBoardTool implements Command
{
@ -71,6 +72,9 @@ export abstract class DrawBoardTool implements Command
this.buildBoard();
app.m_Editor.UpdateScreen();
if (!userConfig.isContinuousDraw)
break;
}
//恢复原先状态
app.m_Editor.m_GetpointServices.snapServices.Disabled = oldSnapState;

@ -8,6 +8,7 @@ import { LayerBoardStore } from '../../UI/Store/BoardStore';
import { DrawBoardTool } from './DrawBoardTool';
import { ObjectId } from '../../DatabaseServices/ObjectId';
import { arrayLast } from '../../Common/ArrayExt';
import { toJS } from 'mobx';
enum NailPos
{
@ -60,6 +61,7 @@ export class DrawLayerBoard extends DrawBoardTool
let board = Board.CreateBoard(len, width, thickness, BoardType.Layer);
opt.height = len;
opt.width = width;
board.BoardProcessOption = toJS(this.store.m_BoardProcessOption);
//等分单层空间大小
let singleSize = (size.z - (thickness * count)) / (count + 1);

@ -9,6 +9,7 @@ import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal
import { ModalPosition } from '../../UI/Components/Modal/ModalsManage';
import { SideBoardStore } from '../../UI/Store/BoardStore';
import { JigUtils } from '../../Editor/JigUtils';
import { toJS } from 'mobx';
export class DrawLeftRight implements Command
{
@ -47,10 +48,10 @@ export class DrawLeftRight implements Command
rightBoard.ApplyMatrix(MoveMatrix(vec));
leftBoard.Name = "左侧板"
leftBoard.BoardProcessOption = store.m_BoardProcessOption;
leftBoard.BoardProcessOption = toJS(store.m_BoardProcessOption);
rightBoard.Name = "右侧板"
rightBoard.BoardProcessOption = store.m_BoardProcessOption;
rightBoard.BoardProcessOption = toJS(store.m_BoardProcessOption);
app.m_Database.ModelSpace.Append(leftBoard);
app.m_Database.ModelSpace.Append(rightBoard);

@ -15,6 +15,13 @@ export class DrawTopBottomBoard implements Command
{
private store: TopBottomBoardStore;
async exec()
{
this.store = TopBottomBoardStore.GetInstance();
app.m_Editor.m_ModalManage.RenderModal(BoardModal, ModalPosition.Center, { store: this.store, type: BoardModalType.TB });
let res = await app.m_Editor.m_ModalManage.Wait();
if (res.Status === ModalState.Ok)
{
let selectSpace = new PointSelectSpaceSurround();
await selectSpace.Select();
@ -24,13 +31,6 @@ export class DrawTopBottomBoard implements Command
return;
}
this.store = TopBottomBoardStore.GetInstance();
app.m_Editor.m_ModalManage.RenderModal(BoardModal, ModalPosition.Center, { store: this.store, type: BoardModalType.TB });
let res = await app.m_Editor.m_ModalManage.Wait();
if (res.Status === ModalState.Ok)
{
let topOpt = this.store.topBoardOption;
let bottomOpt = this.store.bottomBoardOption;
let space = selectSpace.m_SpaceParse;

@ -18,7 +18,7 @@ export class DrawDrilling implements Command
let brs = brsRes.SelectSet.SelectEntityList.filter(e => e instanceof Board) as Board[];
if (brs.length >= 2)
{
DrawDrillingTool.GetInstance().StartGangDrill(brs);
(DrawDrillingTool.GetInstance() as DrawDrillingTool).StartGangDrill(brs);
}
else
{

@ -7,12 +7,15 @@ import { GangDrill } from "../../DatabaseServices/3DSolid/GangDrill";
import { Board } from "../../DatabaseServices/Board";
import { Circle } from "../../DatabaseServices/Circle";
import { ObjectId } from "../../DatabaseServices/ObjectId";
import { userConfig } from "../../Editor/UserConfig";
import { CollisionDetection } from "../../Geometry/DrillParse/CollisionDetection";
import { Face } from "../../Geometry/DrillParse/Face";
import { cZAxis, equaln, MoveMatrix } from "../../Geometry/GeUtils";
import { FaceDirection } from "../../UI/Store/BoardInterface";
import { DrillingOption, SpacingType } from "../../UI/Store/drillInterface";
import { DrillStore } from "../../UI/Store/DrillStore";
import { toJS } from "mobx";
export class DrawDrillingTool extends Singleton
{
@ -20,14 +23,24 @@ export class DrawDrillingTool extends Singleton
private m_Face: Face;
private m_Option: DrillingOption;
private drillEnts: GangDrill[] = [];
private GetDrillingConfig()
/**获取用户正在使用的配置 */
private GetDrillingConfig(type: string)
{
const store = DrillStore.GetInstance() as DrillStore;
let configs = toJS(userConfig.drillConfigs, { exportMapsAsObjects: false });
if (configs && configs.size > 0)
{
//TODO:完善用户配置类,暂用store得数据进行测试
return DrillStore.GetInstance().rules;
if (configs.has(type))
return configs.get(type);
else
return configs.get(store.type);
}
private GetRuleByFace(f: Face): DrillingOption
else
return store.rules;
}
private GetRuleByFace(f: Face)
{
const rules = this.GetDrillingConfig();
const rules = this.GetDrillingConfig(f.drillType);
let length = f.m_Length;
for (let rule of rules)
{
@ -270,7 +283,7 @@ export class DrawDrillingTool extends Singleton
//加入本地的板件排钻测试通孔
for (let [id, v] of locaBoard.DrillList)
{
if (id)
if (id && id.Object)
refDrillList.push(...v);
}
@ -391,7 +404,6 @@ export class DrawDrillingTool extends Singleton
//清理掉已经存在的排钻
this.ClearExitDrillList(checkRes.m_CollisonFaces);
for (let f of checkRes.m_CollisonFaces)
{
let suitableOption = this.GetRuleByFace(f);
@ -433,4 +445,17 @@ export class DrawDrillingTool extends Singleton
}
}
ResetGangDrill(br: Board)
{
let brs = [br];
for (let [k,] of br.DrillList)
{
if (k.Object)
{
brs.push(k.Object as Board);
br.ClearDrillList(k);
}
}
this.StartGangDrill(brs);
}
}

@ -54,29 +54,32 @@ export class DrawWineRackTool extends Singleton
br.BoardProcessOption.sealedUp = topSealed.toString();
br.BoardProcessOption.sealedDown = downSealed.toString();
let highSeals: IHighSealedItem[] = [{ size: downSealed }];
let sizes = [...new Set([downSealed, rightSealed, topSealed, leftSealed])];
let downSeal = {
size: downSealed, color: sizes.indexOf(downSealed) + 1
};
let rigthSeal = {
size: rightSealed, color: sizes.indexOf(rightSealed) + 1
};
let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1 };
let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1 };
let highSeals: IHighSealedItem[] = [downSeal];
if (isLeft)
{
highSeals.push(
{
size: rightSealed
},
{
size: topSealed
}
)
for (let i = 3; i <= cu.EndParam; i++)
highSeals.push(rigthSeal, topSeal);
for (let i = 3; i <= cu.EndParam - 1; i++)
{
highSeals.push({ size: leftSealed });
highSeals.push(leftSeal);
}
}
else
{
for (let i = 1; i <= cu.EndParam - 3; i++)
{
highSeals.push({ size: rightSealed });
highSeals.push(rigthSeal);
}
highSeals.push({ size: topSealed }, { size: leftSealed });
highSeals.push(topSeal, leftSeal);
}
br.BoardProcessOption.highSealed = highSeals;
}

@ -8,7 +8,7 @@ export class Command_HideSelected implements Command
{
let selects = app.m_Editor.m_SelectCtrl.SelectSet.SelectEntityList;
if (selects.length !== 0)
selects.forEach(e => { e.Erase(true) });
selects.forEach(e => { e.Visible = false });
else
app.m_Editor.Prompt("没有选中实体,隐藏失败!");
}
@ -20,7 +20,7 @@ export class Command_ShowAll implements Command
{
app.m_Database.ModelSpace.Entitys.forEach(o =>
{
o.Erase(false);
o.Visible = true;
});
}
}
@ -35,7 +35,7 @@ export class Command_HideUnselected implements Command
{
if (!selects.includes(o) && !(o instanceof Light))
{
o.Erase(true);
o.Visible = false;
count++;
}
});

@ -10,6 +10,7 @@ import { Vec3DTo2D } from "../../Common/CurveUtils";
import { arrayLast } from "../../Common/ArrayExt";
import { log } from "../../Common/Utils";
import { IHighSealedItem } from "../../UI/Store/BoardInterface";
import { equaln } from "../../Geometry/GeUtils";
export class DrawLatticeDrawerTool extends Singleton
{
@ -55,7 +56,10 @@ export class DrawLatticeDrawerTool extends Singleton
let verBr = Board.CreateBoard(size.z, size.y, config.thickness, BoardType.Vertical);
this.WriteBoardProcessOption(verBr);
this.ParseArcLenOrObliuqeAng(verBr);
//分析切角圆弧的结果
let res = this.ParseArcLenOrObliuqeAng(verBr);
if (!res) return;
this.ParseBrTooth(verBr);
this.ParseHighSealing(verBr, config.leftSealed, config.rightSealed, config.upSealed, config.downSealed, false);
@ -228,12 +232,12 @@ export class DrawLatticeDrawerTool extends Singleton
if (config.upCut > size.z || config.downCut > size.z)
{
log("切角过大");
return;
return false;
}
if (config.upCut < 1 || config.downCut < 1)
{
log("切角过小");
return;
return false;
}
let cu = br.ContourCurve as Polyline;
cu.AddVertexAt(3, new Vector2(config.upCut, br.Height));
@ -244,15 +248,16 @@ export class DrawLatticeDrawerTool extends Singleton
if (config.arcLen > size.z)
{
log("圆弧角过大");
return;
return false;
}
let cu = br.ContourCurve as Polyline;
cu.AddVertexAt(3, new Vector2(config.arcLen, br.Height));
cu.SetBulgeAt(3, Math.PI / 8);
cu.SetBulgeAt(3, Math.tan(Math.PI / 8));
cu.SetPointAt(4, new Vector2(0, br.Height - config.arcLen));
}
this.ChangeLeftRightBr(br);
return true;
}
private WriteBoardProcessOption(br: Board)
{
@ -265,36 +270,46 @@ export class DrawLatticeDrawerTool extends Singleton
}
protected ParseHighSealing(br: Board, leftSealed: number, rightSealed: number, topSealed: number, downSealed: number, isHor: boolean)
{
let cu = br.ContourCurve;
let cu = br.ContourCurve as Polyline;
br.BoardProcessOption.sealedLeft = leftSealed.toString();
br.BoardProcessOption.sealedRight = rightSealed.toString();
br.BoardProcessOption.sealedUp = topSealed.toString();
br.BoardProcessOption.sealedDown = downSealed.toString();
let highSeals: IHighSealedItem[] = [];
let sizes = [...new Set([downSealed, rightSealed, topSealed, leftSealed])];
let downSeal = {
size: downSealed, color: sizes.indexOf(downSealed) + 1
};
let rigthSeal = {
size: rightSealed, color: sizes.indexOf(rightSealed) + 1
};
let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1 };
let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1 };
if (isHor)
{
highSeals.push(
{
size: downSealed
},
{
size: rightSealed
}
)
highSeals.push(downSeal, rigthSeal);
for (let i = 1; i <= cu.EndParam - 3; i++)
{
highSeals.push({ size: topSealed });
highSeals.push(topSeal);
}
highSeals.push({ size: leftSealed });
highSeals.push(leftSeal);
}
else
{
for (let i = 0; i <= cu.EndParam - 5; i++)
{
highSeals.push({ size: downSealed });
highSeals.push(downSeal);
}
highSeals.push(rigthSeal, topSeal);
if (cu.PtsBuls.buls.every(b => equaln(b, 0)))
{
highSeals.push(topSeal, leftSeal);
}
highSeals.push({ size: rightSealed }, { size: topSealed }, { size: topSealed }, { size: topSealed });
}
br.BoardProcessOption.highSealed = highSeals;
}

@ -1,11 +1,12 @@
import { Command } from "../Editor/CommandMachine";
import { Vector3 } from "three";
import { app } from "../ApplicationServices/Application";
import { EBoardKeyList } from "../Common/BoardKeyList";
import { Board } from "../DatabaseServices/Board";
import { PromptStatus } from "../Editor/PromptResult";
import { Curve } from "../DatabaseServices/Curve";
import { calcEdgeSealing } from "../GraphicsSystem/CalcEdgeSealing";
import { Polyline } from "../DatabaseServices/Polyline";
import { Vector3 } from "three";
import { Command } from "../Editor/CommandMachine";
import { PromptStatus } from "../Editor/PromptResult";
import { calcEdgeSealing, paragraphCulist } from "../GraphicsSystem/CalcEdgeSealing";
export class TestFb implements Command
{
@ -29,12 +30,31 @@ export class TestFb implements Command
let offsetCus: Curve[] = [];
let highSeals = br.BoardProcessOption.highSealed;
let cus = br.ContourCurve.Explode() as Curve[];
//TODO:先能测试封边,未完善
if (!br.IsSpecialShape)
{
highSeals.length = 0;
let sealDown = parseFloat(br.BoardProcessOption[EBoardKeyList.DownSealed]);
let sealUp = parseFloat(br.BoardProcessOption[EBoardKeyList.UpSealed]);
let sealLeft = parseFloat(br.BoardProcessOption[EBoardKeyList.LeftSealed]);
let sealRight = parseFloat(br.BoardProcessOption[EBoardKeyList.RightSealed]);
let seals = [...new Set([sealDown, sealRight, sealUp, sealLeft])];
[sealDown, sealRight, sealUp, sealLeft].forEach(size => highSeals.push({ size, color: seals.indexOf(size) + 1 }));
}
else
paragraphCulist(cus);
if (highSeals.length > 0 && cus.length === highSeals.length)
{
for (let i = 0; i < cus.length; i++)
{
offsetCus.push(...cus[i].GetOffsetCurves(-highSeals[i].size));
let cs = cus[i].GetOffsetCurves(-highSeals[i].size);
for (let c of cs)
{
if (c instanceof Polyline)
offsetCus.push(...c.Explode());
else
offsetCus.push(c);
}
}
calcEdgeSealing(offsetCus);
let pl = new Polyline();
@ -54,18 +74,24 @@ export class TestFb implements Command
if (ptRes.Status === PromptStatus.OK)
{
let oldPosition = 0;
let moveDist = 0;
let vec = new Vector3();
for (let i = 0; i < showCus.length; i++)
{
let c = showCus[i];
c.Position = ptRes.Point.add(new Vector3(oldPosition));
if (i % 2 === 1)
if (i % 2 === 0)
{
oldPosition += c.BoundingBox.getSize(new Vector3).x + 20;
let min = c.BoundingBox.min;
vec = ptRes.Point.clone().sub(min).add(new Vector3(moveDist));
c.Position = c.Position.add(vec);
moveDist += c.BoundingBox.getSize(new Vector3).x + 20;
}
else
{
c.Position = c.Position.add(vec);
}
app.m_Database.ModelSpace.Append(c);
}
}
}
}

@ -90,15 +90,18 @@ export namespace CheckoutValid
case "spliteWidth":
case "spliteThickness":
return "";
case "sealedUp":
case "sealedDown":
case "sealedLeft":
case "sealedRight":
if (!isNaN(parseFloat(v)) && parseFloat(v) < 0)
return "数值必须大于0";
return "";
case "height":
case "width":
case "count":
case "thickness":
case "footThickness":
case "sealedUp":
case "sealedDown":
case "sealedLeft":
case "sealedRight":
if (!isNaN(parseFloat(v)) && parseFloat(v) <= 0)
return "数值必须大于0";
default:
@ -181,18 +184,14 @@ export namespace CheckoutValid
case "arrayAngle":
if (Math.abs(parseFloat(v)) > 360)
return "角度不可大于360";
// case "":
// case "":
// case "":
// case "":
default:
if (v === "" || isNaN(Number(v)))
{
return "数值不能为空且必须为数字";
}
}
return "";
}
}
export function CheckoutDoorOption(k: string, v: string): string
{
switch (k)

@ -1,17 +1,16 @@
import { Matrix4, Mesh, Object3D, Vector3 } from 'three';
import { Matrix4, Vector3 } from 'three';
import { UpdateDraw } from '../Common/Status';
import { userConfig } from '../Editor/UserConfig';
import { boardUVGenerator, boardUVGenerator2 } from '../Geometry/BoardUVGenerator';
import { Box3Ext } from '../Geometry/Box';
import { equaln, MoveMatrix } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { BoardProcessOption, ComposingType, DrillType, FaceDirection, LinesType } from '../UI/Store/BoardInterface';
import { BoardProcessOption, ComposingType, FaceDirection, LinesType } from '../UI/Store/BoardInterface';
import { Factory } from './CADFactory';
import { CADFiler } from './CADFiler';
import { Circle } from './Circle';
import { Contour } from './Contour';
import { ExtureSolid } from './Extrude';
import { ObjectId } from './ObjectId';
import { PhysicalMaterialRecord } from './PhysicalMaterialRecord';
import { Shape } from './Shape';
export enum BoardType
@ -81,7 +80,7 @@ export class Board extends ExtureSolid
color: "",
lines: LinesType.Positive,
bigHoleDir: FaceDirection.Front,
drillType: DrillType.Three,
drillType: [...userConfig.drillConfigs.keys()][0],
composingFace: ComposingType.Arbitrary,
highSealed: [],
sealedUp: "1",
@ -90,7 +89,8 @@ export class Board extends ExtureSolid
sealedRight: "1",
spliteHeight: "",
spliteWidth: "",
spliteThickness: ""
spliteThickness: "",
highDrill: [],
};
}
@ -98,7 +98,12 @@ export class Board extends ExtureSolid
InitBoard(length: number, width: number, thickness: number, boardType: BoardType = BoardType.Layer)
{
this.m_BoardType = boardType;
this.ColorIndex = boardType + 1;
if (boardType === BoardType.Layer)
this.ColorIndex = 2;
else if (boardType === BoardType.Vertical)
this.ColorIndex = 11;
else
this.ColorIndex = 3;
this.ConverToRectSolid(width, length, thickness);
this.Update(UpdateDraw.Geometry);
}
@ -108,12 +113,6 @@ export class Board extends ExtureSolid
board.InitBoard(length, width, thickness, boardType);
board.ApplyMatrix(board.RotateMat);
board.m_SpecOCS.identity();
if (boardType === BoardType.Layer)
board.ColorIndex = 2;
else if (boardType === BoardType.Vertical)
board.ColorIndex = 11;
else
board.ColorIndex = 3;
return board;
}
get DrillList()
@ -480,9 +479,10 @@ export class Board extends ExtureSolid
}
ApplyMatrix(m: Matrix4): this
{
super.ApplyMatrix(m);
if (equaln(m.getMaxScaleOnAxis(), 1))
this.m_SpecOCS.multiplyMatrices(m, this.m_SpecOCS);
return super.ApplyMatrix(m);
return this;
}
protected ApplyScaleMatrix(m: Matrix4): this
{
@ -516,6 +516,10 @@ export class Board extends ExtureSolid
this.m_BoardType = file.Read();
this.m_Name = file.Read();
this.m_BoardProcessOption = JSON.parse(file.Read());
//兼容旧版本
if (!this.m_BoardProcessOption.highDrill)
this.m_BoardProcessOption.highDrill = [];
//读取排钻列表
this.m_DrillList.clear();
let size = file.Read();
@ -560,8 +564,14 @@ export class Board extends ExtureSolid
file.Write(this.m_Name);
file.Write(JSON.stringify(this.m_BoardProcessOption));
//写入排钻列表
file.Write(this.m_DrillList.size);
// 写入排钻列表
let size = 0;
for (let [id,] of this.m_DrillList)
{
if (id && id.Object && !id.Object.IsErase)
size++;
}
file.Write(size);
for (let [id, idList] of this.m_DrillList)
{
if (id && id.Object && !id.Object.IsErase)

@ -254,7 +254,15 @@ export class Entity extends CADObject
for (let [type, en] of this._CacheDrawObject)
this.UpdateDrawObjectMaterial(type, en);
}
get Visible()
{
return this._Visible;
}
set Visible(v: boolean)
{
this._Visible = v;
this.UpdateVisible();
}
UpdateVisible()
{
if (this._drawObject)

@ -1,4 +1,6 @@
import { RenderType } from "../GraphicsSystem/RenderType";
import { DrillingOption } from "../UI/Store/drillInterface";
import { observable } from "mobx";
/**
* //TODO:保存用户的配置,先保存在sessionStroage
@ -8,18 +10,18 @@ class UserConfig
private _renderType: RenderType = RenderType.Wireframe;
maxHeight = 2440;
maxWidth = 1220;
isContinuousDraw = false; //是否连续绘制层板立板背板...
@observable drillConfigs: Map<string, DrillingOption[]> = new Map();
constructor()
{
this.InitConfig();
this.Init();
}
InitConfig()
Init()
{
let type = sessionStorage.getItem("renderType");
if (type)
this._renderType = parseFloat(type);
}
set RenderType(t: RenderType)
{
if (t !== this._renderType)

@ -6,6 +6,7 @@ import { Curve } from "../../DatabaseServices/Curve";
import { Region } from "../../DatabaseServices/Region";
import { cZAxis, equaln, equalv3, rotatePoint } from "../GeUtils";
import { Face } from "./Face";
import { DrillType } from "../../UI/Store/BoardInterface";
export enum BoardFaceType
{
@ -42,7 +43,9 @@ export class BoardGetFace
let thickness = this.m_Board.Thickness;
let ocs = this.m_Board.OCS;
const highDrill = this.m_Board.BoardProcessOption.highDrill;
//正反面
if (highDrill.length === 0 || highDrill[0] !== DrillType.None)
this.m_Faces.push(new Face({
type: BoardFaceType.NoSide,
region: reg,
@ -55,6 +58,8 @@ export class BoardGetFace
width: size.y
}));
if (highDrill.length === 0 || highDrill[1] !== DrillType.None)
{
let mat = GetMirrorMat(cZAxis).setPosition(new Vector3());
this.m_Faces.push(new Face({
type: BoardFaceType.NoSide,
@ -67,15 +72,21 @@ export class BoardGetFace
width: size.y
}));
}
}
GetSideFaces()
{
// 判断板件构建曲线方向
let cus = this.m_Board.ContourCurve.Explode() as Curve[];
//板构建曲线方向
let dir = Math.sign(this.m_Board.ContourCurve.Area2)
let dir = Math.sign(this.m_Board.ContourCurve.Area2);
const highDrill = this.m_Board.BoardProcessOption.highDrill;
cus.forEach(cu =>
for (let i = 0; i < cus.length; i++)
{
if (highDrill.length > 0 && highDrill[i + 2] === DrillType.None)
continue;
let cu = cus[i];
let derv = cu.GetFistDeriv(0).normalize();
let len = cu.Length;
@ -93,15 +104,16 @@ export class BoardGetFace
isPositiveFace: derv.x + derv.y + derv.z > 0,
matrix4: new Matrix4().multiplyMatrices(this.m_Board.OCS.clone(), mat),
length: len,
width: this.m_Board.Thickness
width: this.m_Board.Thickness,
drillType: highDrill.length >= 2 && highDrill[i + 2]
}));
})
}
}
IntersectFace(br: BoardGetFace, bInsEqual: boolean = false): Face[]
{
//板件包围盒不相交
let localBox = this.m_Board.GetBoardBoxInMat(this.m_Board.SpaceOCSInv);
let interBox = br.m_Board.GetBoardBoxInMat(br.m_Board.SpaceOCSInv);
let interBox = br.m_Board.GetBoardBoxInMat(this.m_Board.SpaceOCSInv);
if (!localBox.intersectsBox(interBox)) return [];
let collisionFaces: Face[] = [];
@ -110,9 +122,10 @@ export class BoardGetFace
{
for (let f2 of br.m_Faces)
{
//都是正面,或者不允许侧面同侧面
if (f1.type === f2.type)
if (f1.type === BoardFaceType.NoSide || !bInsEqual)
//都是正面,或者不允许侧面同侧面并且2板件类型不一样就跳过
if (f1.type === f2.type
&& (f1.type !== BoardFaceType.NoSide || !bInsEqual)
&& br.m_Board.BoardType !== this.m_Board.BoardType)
continue;
//不共面
if (!matrixIsCoplane(f1.OCS, f2.OCS, 1e-4))

@ -1,6 +1,7 @@
import { Board } from "../../DatabaseServices/Board";
import { BoardGetFace } from "./BoardGetFace";
import { Face } from "./Face";
import { DrillType } from "../../UI/Store/BoardInterface";
export class CollisionDetection
{
@ -16,6 +17,7 @@ export class CollisionDetection
{
for (let b of this.m_Boards)
{
if (b.BoardProcessOption.drillType !== DrillType.None)
this.m_BoardGeList.push(new BoardGetFace(b));
}
for (let i = 0; i < this.m_BoardGeList.length; i++)

@ -17,6 +17,7 @@ export interface BoardFaceParams
matrix4: Matrix4;
region?: Region;
isRect?: boolean;
drillType?: string;
}
export class Face
{
@ -30,6 +31,7 @@ export class Face
isEqualType: boolean = false;
OCS: Matrix4 = new Matrix4();
m_IsRect: boolean = true;
drillType: string;
constructor(parameters?: BoardFaceParams)
{
if (parameters)
@ -43,6 +45,10 @@ export class Face
this.m_Width = parameters.width;
if (parameters.isRect !== undefined)
this.m_IsRect = parameters.isRect;
if (parameters.drillType)
this.drillType = parameters.drillType;
else
this.drillType = this.m_LocalBoard.BoardProcessOption.drillType;
}
}
get IsRect()
@ -143,7 +149,7 @@ export class Face
newFace.OCS = sideOcs.clone().setPosition(min);
newFace.IsPositiveFace = sideFace.IsPositiveFace;
newFace.drillType = sideFace.drillType;
//都是侧面
if (this.type === f.type)
newFace.isEqualType = true;

@ -1,7 +1,6 @@
import { Box3, BufferGeometry, Geometry, Line, Matrix4, Mesh, Object3D, Vector, Vector2, Vector3 } from 'three';
import { Box3, BufferGeometry, Geometry, Line, Matrix4, Mesh, Object3D, Vector, Vector2, Vector3, Scene } from 'three';
import { ToFixed } from '../Common/Utils';
import { Matrix2 } from './Matrix2';
export const cZeroVec = new Vector3();
export const cXAxis = new Vector3(1, 0, 0);
export const cYAxis = new Vector3(0, 1, 0);
@ -170,12 +169,8 @@ export function GetBox(obj: Object3D, updateMatrix?: boolean): Box3
if (updateMatrix) obj.updateMatrixWorld(false);
if (!obj.visible) return box;
obj.traverse(o =>
obj.traverseVisible(o =>
{
//因为实体Erase时,实体仍然保存在Scene中.
if (o.visible === false)
return;
//@ts-ignore
let geo = o.geometry as BufferGeometry;
if (geo)
@ -185,7 +180,6 @@ export function GetBox(obj: Object3D, updateMatrix?: boolean): Box3
box.union(geo.boundingBox.clone().applyMatrix4(o.matrixWorld));
}
});
return box;
}

@ -1,10 +1,10 @@
import { FixIndex } from "../Common/Utils";
import { Curve } from "../DatabaseServices/Curve";
import { Line } from "../DatabaseServices/Line";
import { Polyline } from "../DatabaseServices/Polyline";
import { equaln, equalv3, isParallelTo } from "../Geometry/GeUtils";
import { IntersectOption } from "./IntersectWith";
import { PolyOffsetUtil } from "./OffsetPolyline";
import { Line } from "../DatabaseServices/Line";
import { isParallelTo } from "../Geometry/GeUtils";
/**
*线
@ -16,7 +16,7 @@ export function paragraphCulist(cus: Curve[])
let usedCu: WeakSet<Curve> = new WeakSet();
//归类曲线,返回归类是否成功
const paragraph = (cu: Curve, originCu: Curve, cus: Curve[]) =>
const paragraph = (cu: Curve, originCu: Curve, cuList: Curve[], isBack: boolean) =>
{
const cuIsLine = cu instanceof Line;
const originCuIsLine = originCu instanceof Line;
@ -26,44 +26,62 @@ export function paragraphCulist(cus: Curve[])
if (originCuIsLine !== cuIsLine)
{
if (originCuIsLine && !isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(0)))
return false;
if (cuIsLine && !isParallelTo(originCu.GetFistDeriv(1), cu.GetFistDeriv(0)))
if (originCuIsLine &&
!isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(0))
&& !isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(1))
)
{
return false;
}
cus.push(cu);
if (cuIsLine
&& !isParallelTo(originCu.GetFistDeriv(1), cu.GetFistDeriv(0))
&& !isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(0)
))
{
return false;
}
}
if (isBack)
cuList.push(cu);
else
cuList.unshift(cu);
usedCu.add(cu);
return true;
}
let caclCus = cus.slice().filter(c => !equaln(c.Length, 0));
while (cus.length > 0)
while (caclCus.length > 0)
{
let originCu = cus.shift();
let originCu = caclCus.shift();
if (usedCu.has(originCu))
continue;
let originCus = [originCu];
usedCu.add(originCu);
//往后搜索
for (let i = 0; i < cus.length; i++)
for (let i = 0; i < caclCus.length; i++)
{
if (!paragraph(cus[i], originCu, originCus))
if (!paragraph(caclCus[i], originCu, originCus, true))
break;
originCu = cus[i];
originCu = caclCus[i];
}
//只有第一条才需要往前搜索
if (caclCus.length === cus.length - 1)
{
originCu = originCus[0];
//往前搜索
for (let i = cus.length - 1; i >= 0; i--)
for (let i = caclCus.length - 1; i >= 0; i--)
{
if (!paragraph(cus[i], originCu, originCus))
if (!paragraph(caclCus[i], originCu, originCus, false))
break;
originCu = cus[i];
originCu = caclCus[i];
}
}
newCulist.push(originCus);
}
cus.length = 0;
//同组多条曲线连接为多段线
for (let g of newCulist)
{
@ -92,6 +110,8 @@ export function calcEdgeSealing(cus: Curve[])
{
let frontLine = cus[i];
let laterLine = cus[FixIndex(i + 1, cus)];
if (equalv3(frontLine.EndPoint, laterLine.StartPoint))
continue;
let iPts = frontLine.IntersectWith(laterLine, IntersectOption.ExtendBoth);
let tPts = iPts.filter(p =>
frontLine.PtOnCurve(p)

@ -1,11 +1,14 @@
import { Checkbox, Classes, HTMLSelect, Radio, RadioGroup } from '@blueprintjs/core';
import { Button, Checkbox, Classes, HTMLSelect, Radio, RadioGroup } from '@blueprintjs/core';
import { observer } from 'mobx-react';
import * as React from 'react';
import { app } from '../../../ApplicationServices/Application';
import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
import { BoardType } from '../../../DatabaseServices/Board';
import { BoardConfigOption, BoardOption, BrRelativePos, TBBoardOption } from '../../Store/BoardInterface';
import { ToasterInput } from '../Toaster';
import { Board, BoardType } from '../../../DatabaseServices/Board';
import { BoardConfigOption, BoardOption, BoardProcessOption, BrRelativePos, TBBoardOption } from '../../Store/BoardInterface';
import { DrillingOption } from '../../Store/drillInterface';
import { RightPanelStore } from '../../Store/RightPanelStore';
import { RightTabId } from '../RightPanel/RightPanel';
import { AppToaster, ToasterInput } from '../Toaster';
type OptionType = BoardOption | DrillingOption;
@ -273,6 +276,8 @@ interface I5InputComponent extends ISetItemOption
leftKey: string;
rightKey: string;
centerKey?: string;
isShowEditor?: boolean;
drillConfigs?: Map<string, DrillingOption[]>;
}
/**
@ -283,8 +288,16 @@ export class Input5Or4Component extends React.Component<I5InputComponent, {}>
{
render()
{
const options = this.props.drillConfigs ? [
...this.props.drillConfigs.keys(), "不排"
] : [];
const hightDrill = (this.props.option as BoardProcessOption).highDrill;
const isShow = this.props.isShowEditor && hightDrill.length >= 6;
return (
<div className="boardSize center textCenter">
<div>
<ToasterInput
type={this.props.type}
optKey={this.props.upKey}
@ -292,7 +305,25 @@ export class Input5Or4Component extends React.Component<I5InputComponent, {}>
uiOption={this.props.uiOption}
onChange={this.props.onChange}
/>
<div>
{
isShow && <HTMLSelect
className="select-drillType"
options={options}
style={{ width: 50, padding: "0 5px" }}
value={hightDrill[4]}
onChange={e =>
{
hightDrill[4] = e.currentTarget.value;
}}
/>
}
</div>
<div style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
}}>
<div className="flexCol">
<ToasterInput
type={this.props.type}
optKey={this.props.leftKey}
@ -300,6 +331,19 @@ export class Input5Or4Component extends React.Component<I5InputComponent, {}>
uiOption={this.props.uiOption}
onChange={this.props.onChange}
/>
{
isShow && <HTMLSelect
className="select-drillType"
options={options}
style={{ width: 50, padding: "0 5px" }}
value={hightDrill[5]}
onChange={e =>
{
hightDrill[5] = e.currentTarget.value;
}}
/>
}
</div>
{
this.props.showDirectionIcon && <BoardDirectionIcon />
}
@ -312,6 +356,7 @@ export class Input5Or4Component extends React.Component<I5InputComponent, {}>
onChange={this.props.onChange}
/>
}
<div className="flexCol">
<ToasterInput
type={this.props.type}
optKey={this.props.rightKey}
@ -319,7 +364,21 @@ export class Input5Or4Component extends React.Component<I5InputComponent, {}>
uiOption={this.props.uiOption}
onChange={this.props.onChange}
/>
{
isShow && <HTMLSelect
className="select-drillType"
options={options}
style={{ width: 50, padding: "0 5px" }}
value={hightDrill[3]}
onChange={e =>
{
hightDrill[3] = e.currentTarget.value;
}}
/>
}
</div>
</div>
<div>
<ToasterInput
type={this.props.type}
optKey={this.props.downKey}
@ -327,7 +386,91 @@ export class Input5Or4Component extends React.Component<I5InputComponent, {}>
uiOption={this.props.uiOption}
onChange={this.props.onChange}
/>
{
isShow && <HTMLSelect
className="select-drillType"
options={options}
style={{ width: 50, padding: "0 5px" }}
value={hightDrill[2]}
onChange={e =>
{
hightDrill[2] = e.currentTarget.value;
}}
/>
}
</div>
</div>
)
}
}
interface IDrillTypeSelect
{
drillConfigs?: Map<string, DrillingOption[]>;
opt: BoardProcessOption;
br: Board;
isShowHigh?: boolean;
}
@observer
export class DrillTypeSelectCom extends React.Component<IDrillTypeSelect, {}>{
private editorDrilling(br: Board)
{
app.m_Editor.m_ModalManage.Clear();
let store = RightPanelStore.GetInstance() as RightPanelStore;
store.m_IsShow = true;
store.m_TabId = RightTabId.Drill;
store.EditorDrilling(br);
AppToaster.show({
message: <div>,<br />&lt;&gt;,<br />&lt;&gt;,<br />&lt;退&gt;退</div>,
timeout: 0
});
}
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);
}
}
render()
{
const options = this.props.drillConfigs ? [
...this.props.drillConfigs.keys(), "不排"
] : [];
const select = <HTMLSelect
className="select-drillType"
value={this.props.opt.drillType}
style={{ width: this.props.br && this.props.isShowHigh && "100%" }}
options={options}
onChange={this.handleChange}
/>
if (this.props.br && this.props.isShowHigh)
{
return <div className="flex" style={{
display: "inline-flex",
width: "72%"
}}>
{select}
<Button
text="高级"
intent="success"
style={{
minHeight: 18,
height: 18,
padding: 0,
fontSize: 8
}}
onClick={() => this.editorDrilling(this.props.br)}
/>
</div>
}
else
{
return select;
}
}
}

@ -19,6 +19,7 @@ import { MoveMatrix } from "../../../Geometry/GeUtils";
import { BoardConfigOption, BoardProcessOption, FaceDirection, IGrooveOption } from '../../Store/BoardInterface';
import { RightPanelStore } from "../../Store/RightPanelStore";
import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon";
import { RightTabId } from "../RightPanel/RightPanel";
interface BoardConfigProps
{
@ -172,6 +173,9 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
*/
private PickUpModelingOutline = async () =>
{
await app.m_Editor.m_ModalManage.EndExecingCmd();
if (!commandMachine.CommandStart("_pick"))
return;
app.m_Editor.m_ModalManage.ToggleShow();
let br = this.props.br;
@ -219,8 +223,9 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
//显示右侧状态栏
store.m_IsShow = true;
store.m_TabId = "modeling";
store.m_TabId = RightTabId.Model;
app.m_Editor.m_ModalManage.ToggleShow();
commandMachine.CommandEnd();
}
render()
{

@ -11,8 +11,8 @@ import { EFindType, ECompareType } from '../../Store/BoardFindInterface';
import { EBoardKeyList } from '../../../Common/BoardKeyList';
import { app } from '../../../ApplicationServices/Application';
import { observable } from 'mobx';
import { LinesType, FaceDirection, ComposingType } from '../../Store/BoardInterface';
import { DrillType } from '../../Store/drillInterface';
import { LinesType, FaceDirection, ComposingType, DrillType } from '../../Store/BoardInterface';
import { userConfig } from '../../../Editor/UserConfig';
interface IBoardFindState
@ -114,6 +114,7 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
const matPars1 = [
["房名", EBoardKeyList.RoomName], ["柜名", EBoardKeyList.CabinetName],
]
const selectOptions = userConfig.drillConfigs ? [...userConfig.drillConfigs.keys(), "不排"] : [];
return (
<div
@ -205,6 +206,13 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
value={option[EBoardKeyList.UpSealed]}
onChange={e => option[EBoardKeyList.UpSealed] = e.target.value}
/>
<HTMLSelect
className="select-drillType"
options={selectOptions}
style={{ width: 60, padding: "0 5px" }}
value={option.highDrill[4]}
onChange={e => option.highDrill[4] = e.currentTarget.value}
/>
</div>
<div className="flex-center">
<div>
@ -221,6 +229,13 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
value={option[EBoardKeyList.LeftSealed]}
onChange={e => option[EBoardKeyList.LeftSealed] = e.target.value}
/>
<HTMLSelect
className="select-drillType"
options={selectOptions}
style={{ width: 60, padding: "0 5px" }}
value={option.highDrill[5]}
onChange={e => option.highDrill[5] = e.currentTarget.value}
/>
</div>
<div>
<Checkbox
@ -236,6 +251,13 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
value={option[EBoardKeyList.RightSealed]}
onChange={e => option[EBoardKeyList.RightSealed] = e.target.value}
/>
<HTMLSelect
className="select-drillType"
options={selectOptions}
style={{ width: 60, padding: "0 5px" }}
value={option.highDrill[3]}
onChange={e => option.highDrill[3] = e.currentTarget.value}
/>
</div>
</div>
<div>
@ -252,6 +274,13 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
value={option[EBoardKeyList.DownSealed]}
onChange={e => option[EBoardKeyList.DownSealed] = e.target.value}
/>
<HTMLSelect
className="select-drillType"
options={selectOptions}
style={{ width: 60, padding: "0 5px" }}
value={option.highDrill[2]}
onChange={e => option.highDrill[2] = e.currentTarget.value}
/>
<Checkbox
className="all-sealed"
checked={store.isSelectAllSealed}
@ -260,6 +289,29 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
onChange={this.handleSelectAllSealed}
/>
</div>
<div>
<span></span>
<label>
<Checkbox
label="正"
defaultChecked={option.highDrill[0] !== DrillType.None}
inline
onChange={e =>
{
option.highDrill[0] = e.currentTarget.checked ? DrillType.Yes : DrillType.None;
}}
/>
<Checkbox
label="反"
defaultChecked={option.highDrill[1] !== DrillType.None}
inline
onChange={e =>
{
option.highDrill[1] = e.currentTarget.checked ? DrillType.Yes : DrillType.None;
}}
/>
</label>
</div>
</div>
</div>
<div>
@ -428,8 +480,7 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar
<BoardFindSelectItem
useKey="drillType"
k="drillType"
selectOption={[{ label: "三合一", value: DrillType.Three },
{ label: "二合一", value: DrillType.Two }]}
selectOption={selectOptions}
option={option}
title="排钻"
checkChange={this.handleIsSelectAll}

@ -1,21 +1,20 @@
import { Button, Classes, HTMLSelect, Icon } from '@blueprintjs/core';
import { observable } from 'mobx';
import { observable, toJS } from 'mobx';
import * as React from 'react';
import { Math } from 'three';
import { DrawDrillingTool } from '../../../Add-on/DrawDrilling/DrawDrillingTool';
import { app } from '../../../ApplicationServices/Application';
import { CheckObjectType, CheckoutValid } from '../../../Common/CheckoutVaildValue';
import { FixedNotZero } from '../../../Common/Utils';
import { Board } from '../../../DatabaseServices/Board';
import { Entity } from '../../../DatabaseServices/Entity';
import { commandMachine } from '../../../Editor/CommandMachine';
import { CheckFilter, Filter } from '../../../Editor/SelectFilter';
import { CommandState } from '../../../Editor/CommandState';
import { equaln } from '../../../Geometry/GeUtils';
import { BoardProcessOption, SingleBoardOption, IGrooveOption } from '../../Store/BoardInterface';
import { BoardProcessOption, IGrooveOption, SingleBoardOption } from '../../Store/BoardInterface';
import { AppToaster } from '../Toaster';
import { Notes } from './BoardCommon';
import { BoardConfigModal } from './BoardConfigModal';
import { BoardProcessModal } from './BoardProcessModal';
import { CommandState } from '../../../Editor/CommandState';
export class BoardOptionModal extends React.Component<{ board: Board }, {}>
{
@ -32,10 +31,9 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
super(props);
this.m_CurrentBoard = this.props.board;
this.m_IsSpecialBoard.set(this.props.board.IsSpecialShape);
this.SetBrConfig();
this.m_ProcessOption = Object.assign({}, this.m_CurrentBoard.BoardProcessOption);
this.setBrConfig();
}
SetBrConfig = () =>
private setBrConfig = () =>
{
let ro = this.m_CurrentBoard.Rotation;
@ -70,6 +68,25 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
else
this.m_GrooveOption = newGrooveOpt;
const boardProcessOption = this.m_CurrentBoard.BoardProcessOption;
if (!this.m_IsSpecialBoard.get() && boardProcessOption.highDrill.length === 0)
{
boardProcessOption.highDrill.push(...Array(6).fill(boardProcessOption.drillType));
}
if (!this.m_ProcessOption)
{
this.m_ProcessOption = boardProcessOption;
}
else
Object.assign(this.m_ProcessOption, boardProcessOption);
}
private handleChangeCurrentBoard = (e) =>
{
let br = this.m_BoardMap.get(e.target.value);
this.m_CurrentBoard = br;
this.setBrConfig();
}
handleComfirmOption = () =>
{
@ -83,9 +100,15 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
app.m_Database.hm.StartCmd("changeSize");
let board = this.m_CurrentBoard;
board.BoardProcessOption = this.m_ProcessOption;
board.Name = this.m_ConfigOption.name;
let oldDrillType = board.BoardProcessOption.drillType;
board.BoardProcessOption = toJS(this.m_ProcessOption);
if (oldDrillType !== this.m_ProcessOption.drillType)
{
(DrawDrillingTool.GetInstance() as DrawDrillingTool).ResetGangDrill(board);
}
board.Name = this.m_ConfigOption.name;
board.Height = this.m_ConfigOption.height;
board.Width = this.m_ConfigOption.width;
board.Thickness = this.m_ConfigOption.thickness;
@ -172,12 +195,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}>
}
})
}
onChange={e =>
{
let br = this.m_BoardMap.get(e.target.value);
this.SetBrConfig();
Object.assign(this.m_ProcessOption, br.BoardProcessOption);
}}
onChange={this.handleChangeCurrentBoard}
/>
</div>
<div className="flex">

@ -1,13 +1,18 @@
import { Classes, HTMLSelect } from '@blueprintjs/core';
import { IObservableValue } from 'mobx';
import { Button, Classes, HTMLSelect, Checkbox } from '@blueprintjs/core';
import { IObservableValue, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { app } from '../../../ApplicationServices/Application';
import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
import { Board } from '../../../DatabaseServices/Board';
import { Circle } from '../../../DatabaseServices/Circle';
import { BoardProcessOption, ComposingType, DrillType, LinesType, FaceDirection } from '../../Store/BoardInterface';
import { Input5Or4Component, SetBoardDataBlock, SetBoardDataItem } from './BoardCommon';
import { EdgeSealingComponent } from './EdgeSealingComponent';
import { userConfig } from '../../../Editor/UserConfig';
import { BoardProcessOption, ComposingType, FaceDirection, LinesType, DrillType } from '../../Store/BoardInterface';
import { DrillingOption } from '../../Store/drillInterface';
import { RightPanelStore } from '../../Store/RightPanelStore';
import { RightTabId } from '../RightPanel/RightPanel';
import { AppToaster } from '../Toaster';
import { DrillTypeSelectCom, Input5Or4Component, SetBoardDataBlock, SetBoardDataItem } from './BoardCommon';
interface BoardProcessProps
{
@ -20,6 +25,23 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
private matPars = [
["boardName", "板材名"], ["material", "材料"], ["color", "颜色"]
];
@observable private drillConfigs: Map<string, DrillingOption[]>;
private editorEdgeSealing(br: Board)
{
app.m_Editor.m_ModalManage.Clear();
let store = RightPanelStore.GetInstance() as RightPanelStore;
store.m_IsShow = true;
store.m_TabId = RightTabId.Seal;
store.EditorEdgeSealing(br);
AppToaster.show({
message: <div>,<br />&lt;&gt;,<br />&lt;&gt;,<br />&lt;退&gt;退</div>,
timeout: 0
});
}
async componentWillMount()
{
this.drillConfigs = userConfig.drillConfigs;
}
render()
{
let isShowHighEditor = this.props.br
@ -102,28 +124,11 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
</label>
<label className="bp3-label bp3-inline .modifier">
<span></span>
<HTMLSelect
value={this.props.opt.drillType}
options={
[
{
label: "三合一",
value: DrillType.Three
},
{
label: "二合一",
value: DrillType.Two
},
{
label: "不排",
value: DrillType.None
}
]
}
onChange={e =>
{
this.props.opt.drillType = e.target.value as DrillType;
}}
<DrillTypeSelectCom
drillConfigs={this.drillConfigs}
opt={this.props.opt}
br={this.props.br}
isShowHigh={isShowHighEditor}
/>
</label>
<label className="bp3-label bp3-inline .modifier">
@ -152,11 +157,52 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
}}
/>
</label>
{
Boolean(this.props.br) && this.props.opt.highDrill.length > 0 && <label className="bp3-label bp3-inline .modifier">
<span></span>
<div className="inline">
<Checkbox
label="正面"
style={{
marginRight: 5,
marginLeft: 5
}}
inline
defaultChecked={this.props.opt.highDrill[0] !== DrillType.None}
onChange={(e) =>
{
this.props.opt.highDrill[0] = e.currentTarget.checked ? DrillType.Yes : DrillType.None;
}}
/>
<Checkbox
label="反面"
inline
defaultChecked={this.props.opt.highDrill[1] !== DrillType.None}
onChange={(e) =>
{
this.props.opt.highDrill[1] = e.currentTarget.checked ? DrillType.Yes : DrillType.None;
}}
/>
</div>
</label>
}
</div>
<h6 className={"edge-sealing " + Classes.HEADING}>
{
isShowHighEditor && <EdgeSealingComponent br={this.props.br} />
isShowHighEditor &&
<Button
text="高级编辑"
style={{
minHeight: 18,
height: 18,
padding: "0 10px",
fontSize: 8
}}
intent="success"
onClick={() => this.editorEdgeSealing(this.props.br)}
/>
}
</h6>
{
@ -170,6 +216,8 @@ export class BoardProcessModal extends React.Component<BoardProcessProps, {}>{
leftKey="sealedLeft"
rightKey="sealedRight"
option={this.props.opt}
drillConfigs={this.drillConfigs}
isShowEditor={Boolean(this.props.br)}
/>
}
</div>

@ -0,0 +1,95 @@
import { Button, Card, Classes, Popover, Position, Radio, RadioGroup, Intent } from '@blueprintjs/core';
import { observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { DrillStore } from '../../Store/DrillStore';
@observer
export class DrillTypeCom extends React.Component<{ store: DrillStore }, { typeName: string }>
{
constructor(props)
{
super(props);
this.state = {
typeName: ""
}
}
private addDrillType = () =>
{
this.props.store.AddNewDrillType(this.state.typeName);
this.props.store.type = this.state.typeName;
this.handleUpdate();
}
private handleOnChange = (e) =>
{
const store = this.props.store;
store.type = e.currentTarget.value;
this.handleUpdate();
}
private handleDelete = () =>
{
const store = this.props.store;
store.drillConfig.delete(store.type);
let types = [...store.drillConfig.keys()];
if (types.length > 0)
{
store.type = types[0];
this.handleUpdate();
}
}
private handleUpdate = () =>
{
const store = this.props.store;
observable(store.rules).replace(store.drillConfig.get(store.type));
store.ChangeRules(0);
}
render()
{
const store = this.props.store;
return (
<div className="flex drill-type">
<RadioGroup
inline={true}
selectedValue={store.type}
onChange={this.handleOnChange}
>
{
[...store.drillConfig.keys()].map(type => <Radio label={type} value={type} />)
}
</RadioGroup>
<div>
<Popover
position={Position.LEFT}
onClosed={() => this.setState({ typeName: "" })}
content={
<Card>
<input type="text"
className={Classes.INPUT}
value={this.state.typeName}
onChange={e => this.setState({ typeName: e.target.value })}
/>
<Button
text="确定"
className={Classes.POPOVER_DISMISS}
style={{ marginLeft: 20 }}
onClick={this.addDrillType}
/>
</Card>
}
target={<Button
text="添加类型"
intent={Intent.PRIMARY}
/>}
/>
<Button
text="删除选中类型"
intent={Intent.DANGER}
onClick={this.handleDelete}
/>
</div>
</div>
)
}
}

@ -1,161 +0,0 @@
import { Button, Classes, Intent, Popover } from '@blueprintjs/core';
import { observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { Matrix4, Vector3 } from 'three';
import { app } from '../../../ApplicationServices/Application';
import { Board } from '../../../DatabaseServices/Board';
import { Curve } from '../../../DatabaseServices/Curve';
import { Text } from '../../../DatabaseServices/Text/Text';
import { JigUtils } from '../../../Editor/JigUtils';
import { calcEdgeSealing, paragraphCulist } from '../../../GraphicsSystem/CalcEdgeSealing';
import { MoveMatrix } from '../../../Geometry/GeUtils';
@observer
export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
{
private ulList: HTMLUListElement;
@observable private cuList: Curve[] = [];
constructor(props)
{
super(props);
}
private EditorEdgeSealing = () =>
{
let br = this.props.br;
let cus = br.ContourCurve.Explode() as Curve[];
//曲线分段
paragraphCulist(cus);
//替换曲线列表
observable(this.cuList).replace(cus);
app.m_Viewer.m_CameraCtrl.LookAt(br.Normal.negate());
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
app.m_Editor.UpdateScreen();
JigUtils.Destroy();
for (let i = 0; i < this.cuList.length; i++)
{
let cu = this.cuList[i];
let p = cu.GetPointAtParam(cu.EndParam / 2);
JigUtils.Draw(new Text(p, (i + 1).toString())
.ApplyMatrix(MoveMatrix(new Vector3(0, 0, br.Thickness)))
.ApplyMatrix(br.OCS));
//显示对应设置的边
let refCu = cu.Clone();
refCu.ColorIndex = i + 1
JigUtils.Draw(refCu.ApplyMatrix(br.OCS));
}
}
private CalcEdgeSealing = () =>
{
let originCurve = this.props.br.ContourCurve;
let dir = Math.sign(originCurve.Area2) * -1;
let infoEls = this.ulList.querySelectorAll('li input');
let edgeSealingNum: number[] = [];
let highSeal = this.props.br.BoardProcessOption.highSealed;
highSeal.length = 0;
infoEls.forEach(el =>
{
let size = parseFloat((el as HTMLInputElement).value);
highSeal.push({
size
})
edgeSealingNum.push(size * dir);
});
let calcCus = this.cuList;
let offsetCus: Curve[] = [];
for (let i = 0; i < calcCus.length; i++)
{
let cu = calcCus[i];
offsetCus.push(...cu.GetOffsetCurves(edgeSealingNum[i]));
}
calcEdgeSealing(offsetCus);
this.ShowSealingResult(offsetCus);
}
private ShowSealingResult = (offsetCus: Curve[]) =>
{
offsetCus.forEach((cu, i) =>
{
cu.ApplyMatrix(MoveMatrix(new Vector3(0, 0, this.props.br.Thickness)))
.ApplyMatrix(this.props.br.OCS);
JigUtils.Draw(cu);
})
app.m_Editor.UpdateScreen();
}
render()
{
let highSeal = this.props.br.BoardProcessOption.highSealed;
//兼容以前没有这个属性的版本
if (!highSeal)
{
this.props.br.BoardProcessOption.highSealed = [];
highSeal = [];
}
return (
<Popover
usePortal={false}
modifiers={{
arrow: { enabled: false },
flip: { enabled: true },
keepTogether: { enabled: true },
preventOverflow: { enabled: true, boundariesElement: "scrollParent" }
}}
content={
<div tabIndex={-1} className={Classes.CARD}>
<h6 className={Classes.HEADING}></h6>
<ul
className={Classes.LIST_UNSTYLED}
ref={el => this.ulList = el}
>
{
this.cuList.map((cu, i) =>
{
let defaultValue = "1.0";
if (highSeal.length > 0)
defaultValue = highSeal[i] ? highSeal[i].size.toString() : "1";
return (
<li>
<label className="bp3-label bp3-inline .modifier">
{"封边(" + (i + 1).toString() + ")"}
<input
defaultValue={defaultValue}
className="bp3-input"
placeholder="输入封边大小"
dir="auto" />
</label>
</li>
)
})
}
</ul>
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: 15 }}>
<Button
onClick={this.CalcEdgeSealing}
text="确定"
className={Classes.POPOVER_DISMISS}
intent={Intent.SUCCESS}
style={{ marginRight: 10 }} />
<Button
text="取消"
onClick={() => JigUtils.Destroy()}
intent={Intent.DANGER}
className={Classes.POPOVER_DISMISS} />
</div>
</div>
}
target={
<Button
onClick={this.EditorEdgeSealing}
text="高级编辑"
intent="success"
/>
}
/>
)
}
}

@ -1,22 +1,24 @@
import { Button, Checkbox, Classes, HTMLSelect, Icon, Radio, RadioGroup } from '@blueprintjs/core';
import { inject, observer } from 'mobx-react';
import * as React from 'react';
import { hot } from 'react-hot-loader/root';
import * as xaop from 'xaop';
import { app } from '../../../ApplicationServices/Application';
import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
import { KeyBoard } from '../../../Common/KeyEnum';
import { commandMachine } from '../../../Editor/CommandMachine';
import { SpacingType } from '../../Store/drillInterface';
import { DrillStore } from '../../Store/DrillStore';
import { ModalState } from '../Modal/ModalsManage';
import { ToasterInput } from '../Toaster';
import { ItemName, SetBoardDataItem } from './BoardCommon';
import { BoardModalType } from './BoardModal';
import { DrillType, SpacingType } from '../../Store/drillInterface';
import { DrillRulesComponent } from './DrillRules';
import { UserConfig } from './UserConfig';
import { userConfigStore } from '../../Store/UserConfigStore';
import { DrillTypeCom } from './DrillCommon';
@hot
@inject('store')
@observer
export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
@ -46,6 +48,12 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
}
}));
}
private saveAndDrilling = () =>
{
userConfigStore.SaveConfig(BoardModalType.Dr, this.props.store);
app.m_Editor.m_ModalManage.Clear();
commandMachine.ExecCommand('PZ');
}
componentWillMount()
{
//注册事件
@ -75,43 +83,7 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
<div className={Classes.DIALOG_BODY}>
<div className={Classes.CARD}>
<h5 className={Classes.HEADING}></h5>
<div className="flex drill-type">
<RadioGroup
inline={true}
selectedValue={store.type}
onChange={e =>
{
store.type = e.currentTarget.value as DrillType;
if (store.type === DrillType.Three)
{
store.m_Option.name = "三合一";
store.m_Option.pxlRad = 7.5;
store.m_Option.ljgLength = 34;
store.UIOption["pxlRad"] = "7.5";
store.UIOption["ljgLength"] = "34";
}
else
{
store.m_Option.name = "二合一";
store.m_Option.pxlRad = 10;
store.m_Option.ljgLength = 10;
store.UIOption["pxlRad"] = "10";
store.UIOption["ljgLength"] = "10";
}
}}
>
<Radio label="三合一" value={DrillType.Three} />
<Radio label="二合一" value={DrillType.Two} />
</RadioGroup>
<div>
<Button
text="添加类型"
/>
<Button
text="删除选中类型"
/>
</div>
</div>
<DrillTypeCom store={store} />
</div>
<div className="flex">
<div className={Classes.CARD}>
@ -235,7 +207,7 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
<h5 className={Classes.HEADING}></h5>
<div className="flexWrap">
<RadioGroup
className="br-set"
className="br-set hole"
selectedValue={store.m_Option.tIsOffset ? "0" : "1"}
onChange={e =>
{
@ -343,12 +315,7 @@ export class DrillModal extends React.Component<{ store?: DrillStore }, {}> {
<Button
className={Classes.INTENT_SUCCESS}
text="保存并排钻"
onClick={() =>
{
store.SaveRuleOption();
app.m_Editor.m_ModalManage.Clear();
commandMachine.ExecCommand('PZ');
}}
onClick={this.saveAndDrilling}
/>
<Button
className={Classes.INTENT_SUCCESS}

@ -7,6 +7,9 @@ import { BoardProcessOption, LayerNailOption, TBBoardOption, IGrooveOption } fro
import { DrillingOption } from '../../Store/drillInterface';
import { AppToaster } from '../Toaster';
import { BoardModalType } from './BoardModal';
import { IConfigStore } from '../../Store/BoardStore';
import { userConfigStore, UserConfigStore } from '../../Store/UserConfigStore';
import { observable } from 'mobx';
//保存的配置
export interface IConfigOption
@ -16,20 +19,18 @@ export interface IConfigOption
topBoardData?: TBBoardOption;
bottomBoardData?: TBBoardOption;
processData?: BoardProcessOption;
rules?: DrillingOption[];
ruleMap?: Map<string, DrillingOption[]>;
grooveData?: IGrooveOption; //槽数据
}
interface UserConfigState
{
configName: string,
configs: Map<string, IConfigOption>,
}
interface IConfigPRops
interface IConfigProps
{
type: BoardModalType;
store: { SaveConfig: Function, UpdateOption: Function }
store: IConfigStore;
}
/**
@ -40,125 +41,40 @@ interface IConfigPRops
* @extends {React.Component<BoardModalProps, UserConfigState>}
*/
@observer
export class UserConfig extends React.Component<IConfigPRops, UserConfigState>{
export class UserConfig extends React.Component<IConfigProps, UserConfigState>{
_userConfigStore: UserConfigStore;
constructor(props)
{
super(props);
this.state = {
configName: "默认",
configs: new Map()
};
this._userConfigStore = userConfigStore;
}
handleSaveConfig = async (isInit: boolean = false) =>
{
let name = this.state.configName;
if (name === "")
{
AppToaster.show({
message: "请输入名称",
timeout: 1000
});
return;
}
if (!isInit && name === "默认")
{
AppToaster.show({
message: "默认配置不能修改",
timeout: 1000
});
}
let dbstore = await IndexedDbStore.CADStore();
let brStore = this.props.store;
let type = this.props.type;
//新的配置
let newConfig: IConfigOption = brStore.SaveConfig();
//获取数据库中对应板类型的配置
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, IConfigOption> || new Map();
//如果名字重复确认是否继续
let isContinue = true;
if (brDataMap.has(name))
{
isContinue = confirm("该名字存在,是否覆盖值");
}
if (isContinue)
{
// 配置添加到数据库
brDataMap.set(name, newConfig);
dbstore.Put(StoreName.ConfigData, type, brDataMap);
this.setState({ configs: brDataMap });
AppToaster.show({
message: isInit ? "初始化配置成功" : "配置保存成功",
timeout: 1000
});
localStorage.setItem("configName", name);
}
await this._userConfigStore.SaveConfig(this.props.type, this.props.store, isInit);
}
//删除配置
handleDeleteConfig = async () =>
{
// 删除视图中的对应项
let configs = this.state.configs;
let currentName = this.state.configName;
if (currentName === "默认")
{
AppToaster.show({
message: "默认配置不允许删除",
timeout: 1000
});
return;
}
configs.delete(currentName);
this.setState({ configs });
//删除数据库中的对应项
let dbstore = await IndexedDbStore.CADStore();
let type = this.props.type;
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, IConfigOption>;
brDataMap.delete(currentName);
dbstore.Put(StoreName.ConfigData, type, brDataMap);
//切换到第一项
let confNames = Array.from(brDataMap.keys());
let newName = confNames.length > 0 ? confNames[0] : "";
this.setState({ configName: newName });
await this.updateBoardOption(newName);
localStorage.setItem("configName", newName);
await this._userConfigStore.DeleteConfig(this.props.type, this.props.store);
}
//更新配置
updateBoardOption = async (k: string) =>
{
this.setState({ configName: k });
let dbstore = await IndexedDbStore.CADStore();
let type = this.props.type;
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, IConfigOption>;
let conf = brDataMap.get(k);
let store = this.props.store;
if (brDataMap && conf)
{
store.UpdateOption(conf);
localStorage.setItem("configName", k);
}
await this._userConfigStore.UpdateBoardOption(k, this.props.type, this.props.store);
}
async componentWillMount()
{
let dbstore = await IndexedDbStore.CADStore();
let type = this.props.type;
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, IConfigOption> || new Map();
this.setState({ configs: brDataMap });
observable(this._userConfigStore.configs).replace(brDataMap);
let confNames = Array.from(brDataMap.keys());
//如果没保存过配置,添加一个默认
if (confNames.length === 0)
{
this.setState({ configName: "默认" });
this._userConfigStore.configName = "默认";
await this.handleSaveConfig(true);
}
else if (type !== BoardModalType.Zx)
@ -166,7 +82,7 @@ export class UserConfig extends React.Component<IConfigPRops, UserConfigState>{
let curName = localStorage.getItem("configName");
if (!curName)
curName = arrayLast(confNames);
this.setState({ configName: curName });
this._userConfigStore.configName = curName;
this.updateBoardOption(curName);
}
}
@ -178,11 +94,11 @@ export class UserConfig extends React.Component<IConfigPRops, UserConfigState>{
<label></label>
<InputGroup
className="input-select"
value={this.state.configName}
value={this._userConfigStore.configName}
onChange={e =>
{
if (e.target.value.length <= 15)
this.setState({ configName: e.target.value })
this._userConfigStore.configName = e.target.value
}}
rightElement=
{
@ -200,7 +116,7 @@ export class UserConfig extends React.Component<IConfigPRops, UserConfigState>{
content={
<Menu>
{
Array.from(this.state.configs.keys())
Array.from(this._userConfigStore.configs.keys())
.map((k, i) =>
<MenuItem
onClick={e => this.updateBoardOption(e.currentTarget.text)}

@ -261,8 +261,8 @@ export class WineRackModal extends React.Component<{ store?: WineRackStore }, {}
store.m_Option.fullType = parseInt(e.currentTarget.value);
}}
>
<Radio label="高度优先" value={EFullType.ByHeight} />
<Radio label="宽度优先" value={EFullType.ByWidth} />
<Radio label="高度优先" value={EFullType.ByHeight} />
<Radio label="全对称" value={EFullType.Symmetry} disabled={m_Option.arrayType === EWRackArrayType.ByCount} />
</RadioGroup>
<div>

@ -8,6 +8,10 @@ import { Card } from '@blueprintjs/core';
import { ZINDEX } from '../../../Common/ZIndex';
import { request } from '../../../Common/Request';
import { SignUrl } from '../../../Common/HostUrl';
import { userConfig } from '../../../Editor/UserConfig';
import { userConfigStore } from '../../Store/UserConfigStore';
import { BoardModalType } from '../Board/BoardModal';
import { DrillStore } from '../../Store/DrillStore';
@inject('store')
@observer
@ -18,6 +22,14 @@ export class MainContent extends React.Component<{ store?: TopPanelStore }>
//一开始就检查是否登陆
await request(SignUrl.heart);
}
async componentDidMount()
{
let config = await userConfigStore.GetConfig(BoardModalType.Dr);
if (config)
userConfig.drillConfigs = config.ruleMap;
else
await userConfigStore.SaveConfig(BoardModalType.Dr, DrillStore.GetInstance(), true);
}
render()
{
return (

@ -125,8 +125,15 @@
margin-left:10px;
position: relative;
}
&>div>input,&>div>div>input{
width: 30px;
padding: 0 2px;
}
.all-sealed{
position: absolute;
}
.select-drillType{
vertical-align: baseline;
}
}
}

@ -47,9 +47,12 @@
.boardSize{
min-width: 151px;
}
.select-drillType{
flex: 1;
}
}
#commonModal .board-info .boardSize .bp3-input{
width: 4rem;
width: 30px;
}
#commonModal .boardSize .bp3-inline{
line-height: 15px;
@ -119,7 +122,7 @@
width: 2rem;
}
input{
width: 5.5rem;
width: 6.5rem;
}
}

@ -24,11 +24,14 @@
width: 8rem;
}
}
.hole{
flex-direction: column;
}
}
#drillModal .flexWrap>div{
white-space: nowrap;
}
#drillModal .br-set>span:first-child,#drillModal .bp3-dialog-body .bp3-label>span:first-child,{
#drillModal .br-set>span:first-child,#drillModal .bp3-dialog-body .bp3-label>span:first-child{
display: inline-block;
width: 5.5rem;
white-space: nowrap;
@ -60,7 +63,13 @@
#drillModal .drill-type{
justify-content: space-between;
align-items: center;
padding-bottom: 3px;
button{
margin-bottom: 10px;
}
&>div:first-child{
width: 680px;
overflow-x: auto;
white-space: nowrap;
}
}

@ -5,9 +5,9 @@
@inputHeight:1.5rem;
@noteInputHeight:2.5rem;
@selectWidth:10rem;
@inputWidth:5.5rem;
@inputWidth:5rem;
@nameInput:12rem;
@infoSelectWidth:8rem;
@infoSelectWidth:9rem;
#modal{
position: fixed;
@ -123,7 +123,7 @@
//select高度改变,调整切换符号位置
#modal .bp3-html-select .bp3-icon{
right: 1px;
top:1px;
top:2.5px;
}
.input-select{

@ -0,0 +1,105 @@
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 { 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 options2 = ["排", "不排"];
return (
<>
<ul className={"modeling drilling " + Classes.LIST_UNSTYLED}>
<li>
<Label></Label>
<Label></Label>
</li>
{
store.drillDataList.map((d, i) =>
{
if (i >= 2)
return (
<li>
<span style={{
background: ColorMaterial.GetColor(i - 1).getStyle(), width: "50%"
}} className={Classes.INPUT}>{i - 1}</span>
<HTMLSelect
options={options}
value={d}
onChange={e =>
{
store.drillDataList[i] = e.target.value;
}}
/>
</li>
)
})
}
</ul>
<ul className={"modeling drilling " + Classes.LIST_UNSTYLED}>
{
store.drillDataList.length > 2 && <>
<li>
<span style={{ width: "50%" }} className={Classes.INPUT}></span>
<HTMLSelect
options={options2}
value={store.drillDataList[0]}
onChange={e =>
{
store.drillDataList[0] = e.target.value;
}}
/>
</li>
<li>
<span style={{ width: "50%" }} className={Classes.INPUT}></span>
<HTMLSelect
options={options2}
value={store.drillDataList[1]}
onChange={e =>
{
store.drillDataList[1] = e.target.value;
}}
/>
</li>
</>
}
</ul>
<div className="flex-arround">
<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>
</>
)
}
}

@ -9,6 +9,7 @@
width: 100%;
overflow: auto;
height: 100%;
padding: 10px;
}
#RightPanel .bp3-tab-panel.tab-unstyle {
.bp3-tab.tab-unstyle{
@ -24,8 +25,9 @@
.modeling{
margin-bottom: 2rem;
width: 100%;
&>li:first-child>label{
&>li>label{
text-align: center;
flex:1;
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),
@ -41,11 +43,16 @@
label,span,input,&>div {
width: 20%;
margin: 0;
}
}
}
.drilling{
&>li{
&>div{
width: 50%;
}
}
}
/* 滚动条 */
::-webkit-scrollbar-track-piece {
background-color: #fff; /*滚动条的背景颜色*/

@ -9,6 +9,22 @@ import { ModelingComponent } from './ModelingComponent';
import { ScenePanel } from './ScenePanel';
import { BoardTemplatePanel } from './BoardTemplatePanel';
import { MaterialExplorer } from '../MaterialExplorer';
import { hot } from 'react-hot-loader/root';
import { SealingComponent } from './SealingComponent';
import { DrillingComponent } from './DrillComponent';
export enum RightTabId
{
Model = "modeing",
Seal = "sealing",
Drill = "drilling",
Scene = "scenes",
Material = "material",
Template = "template",
Accessories = "accessories",
}
@hot
@inject('store')
@observer
export class RightPanel extends React.Component<{ store?: RightPanelStore }>
@ -51,7 +67,7 @@ export class RightPanel extends React.Component<{ store?: RightPanelStore }>
icon="drag-handle-vertical"
/>
{
store.m_IsShow ? (<div
store.m_IsShow && (<div
onFocus={this.HandleFocus}
ref={this.m_Container}
className="bp3-card tabs-unstyle"
@ -65,15 +81,17 @@ export class RightPanel extends React.Component<{ store?: RightPanelStore }>
vertical={true}
animate={false}
selectedTabId={store.m_TabId}
onChange={(e) => { store.m_TabId = e }}
onChange={e => store.m_TabId = e}
>
<Tab className="tab-unstyle" id="modeling" title="造 型" panel={< ModelingComponent />} />
<Tab className="tab-unstyle" id="scenes" title="场 景" panel={<ScenePanel />} />
<Tab className="tab-unstyle" id="material" title="材 质" panel={<MaterialExplorer materialTable={app.m_Database.MaterialTable}></MaterialExplorer>} />
<Tab className="tab-unstyle" id="template" title="模 板" panel={<BoardTemplatePanel store={store} />} />
<Tab className="tab-unstyle" id="accessories" title="配 件" />
<Tab className="tab-unstyle" id={RightTabId.Model} title="造 型" panel={< ModelingComponent />} />
<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.Scene} title="场 景" panel={<ScenePanel />} />
<Tab className="tab-unstyle" id={RightTabId.Material} title="材 质" panel={<MaterialExplorer materialTable={app.m_Database.MaterialTable}></MaterialExplorer>} />
<Tab className="tab-unstyle" id={RightTabId.Template} title="模 板" panel={<BoardTemplatePanel store={store} />} />
<Tab className="tab-unstyle" id={RightTabId.Accessories} title="配 件" />
</ Tabs>
</div>) : null
</div>)
}
</>
)

@ -0,0 +1,92 @@
import { Button, Classes, 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 { IndexedDbStore, StoreName } from '../../../IndexedDb/IndexedDbStore';
import { RightPanelStore } from '../../Store/RightPanelStore';
import { RightTabId } from './RightPanel';
@inject("store")
@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;
let dbstore = await IndexedDbStore.CADStore();
let highSizes = await dbstore.Get(StoreName.ConfigData, RightTabId.Seal) as string[];
if (highSizes)
{
highSizes.length = 0;
highSizes.push(...toJS(store.highSizes));
}
else
highSizes = toJS(store.highSizes);
dbstore.Put(StoreName.ConfigData, RightTabId.Seal, highSizes);
}
render()
{
const store = this.props.store;
return (
<>
<ul className={"modeling " + Classes.LIST_UNSTYLED}>
<li>
<Label></Label>
<Label></Label>
</li>
{
store.highSizes.map((v, i) =>
{
return (
<li>
<span
className={Classes.INPUT}
style={{
background: ColorMaterial.GetColor(i + 1).getStyle(),
width: "50%"
}}
>{i + 1}</span>
<input
style={{ width: "50%" }}
tabIndex={1}
value={v}
onFocus={e =>
{
e.target.setSelectionRange(0, e.target.value.length);
}}
className={Classes.INPUT}
onChange={(e) =>
{
store.highSizes[i] = e.target.value;
}}
onBlur={e =>
{
let val = parseFloat(e.target.value);
if (isNaN(val))
store.highSizes[i] = "0";
}}
/>
</li>
)
})
}
</ul>
<div className="flex-arround">
<Button text="写入" intent={Intent.SUCCESS}
onClick={() => store.WriteSealingData()} />
<Button text="保存" intent={Intent.SUCCESS}
onClick={this.save} />
<Button text="退出" intent={Intent.DANGER}
onClick={() => store.ExitEditor()} />
</div>
</>
)
}
}

@ -125,7 +125,7 @@
flex-direction: row;
.bp3-tab{
padding: 0;
height: 20%;
flex:1;
border-radius: 0px;
border-width:0;
outline: none;

@ -766,3 +766,6 @@ img {
#matContent canvas{
border-left: 1px solid #30404d;
}
.right{
text-align: right;
}

@ -1,4 +1,4 @@
import { LinesType, DrillType, FaceDirection, ComposingType } from "./BoardInterface";
import { LinesType, FaceDirection, ComposingType } from "./BoardInterface";
import { EBoardKeyList } from "../../Common/BoardKeyList";
export interface IBoardFindOption
@ -18,12 +18,13 @@ export interface IBoardFindOption
[EBoardKeyList.Color]: string;
[EBoardKeyList.Lines]: LinesType;
[EBoardKeyList.BigHole]: FaceDirection;
[EBoardKeyList.DrillType]: DrillType;
[EBoardKeyList.DrillType]: string;
[EBoardKeyList.ComposingFace]: ComposingType;
[EBoardKeyList.UpSealed]: string;
[EBoardKeyList.DownSealed]: string;
[EBoardKeyList.LeftSealed]: string;
[EBoardKeyList.RightSealed]: string;
highDrill: string[];
isClose: boolean;
}
export interface IFindCondition

@ -1,11 +1,12 @@
import { BoardStore } from "./BoardStore";
import { IBoardFindOption, ECompareType } from "./BoardFindInterface";
import { observable, toJS } from "mobx";
import { LinesType, FaceDirection, DrillType, ComposingType } from "./BoardInterface";
import { LinesType, FaceDirection, ComposingType } from "./BoardInterface";
import { IConfigOption } from "../Components/Board/UserConfig";
import { app } from "../../ApplicationServices/Application";
import { ModalState } from "../Components/Modal/ModalsManage";
import { EBoardKeyList } from "../../Common/BoardKeyList";
import { userConfig } from "../../Editor/UserConfig";
export class BoardFindStore extends BoardStore
{
@ -66,18 +67,26 @@ export class BoardFindStore extends BoardStore
color: "",
lines: LinesType.Positive,
bigHoleDir: FaceDirection.Front,
drillType: DrillType.Three,
drillType: [...userConfig.drillConfigs.keys()][0],
composingFace: ComposingType.Positive,
sealedUp: "",
sealedDown: "",
sealedLeft: "",
sealedRight: "",
highDrill: [],
isClose: false,
};
@observable isSelectAllSealed = false;
@observable isSelectAll = false;
@observable isRevSelect = false;
constructor()
{
super();
let drilltypes = [...userConfig.drillConfigs.keys()];
if (drilltypes.length > 0)
this.m_Option.highDrill.push(...Array(6).fill(drilltypes[0]));
}
async OnOk<T>(state: number, data?: T)
{
if ((this.m_Option.isClose || state === ModalState.Cancel))

@ -1,5 +1,5 @@
import { BoardType } from "../../DatabaseServices/Board";
import { EBoardKeyList } from "../../Common/BoardKeyList";
import { BoardType } from "../../DatabaseServices/Board";
/**
*,,UIkey
@ -16,11 +16,9 @@ export interface BoardData
//排钻类型
export enum DrillType
{
Three = "three",
Two = "two",
None = "no"
Yes = "排",
None = "不排"
}
//偏心轮类型
export enum FaceDirection
{
@ -72,7 +70,7 @@ export enum BrRelativePos
export interface IHighSealedItem
{
size: number;
color?: number;
color: number;
}
export interface BoardProcessOption extends BoardOption
@ -84,9 +82,9 @@ export interface BoardProcessOption extends BoardOption
[EBoardKeyList.Color]?: string;
[EBoardKeyList.Lines]?: LinesType;//纹路
[EBoardKeyList.BigHole]?: FaceDirection;//大孔面
[EBoardKeyList.DrillType]?: DrillType;//排钻类型
[EBoardKeyList.DrillType]?: string;//排钻类型
[EBoardKeyList.ComposingFace]?: ComposingType;//排版面
[EBoardKeyList.HighSealed]?: { size: number, color?: number }[];
[EBoardKeyList.HighSealed]?: IHighSealedItem[];
[EBoardKeyList.UpSealed]?: string;//封边上下左右
[EBoardKeyList.DownSealed]?: string;
[EBoardKeyList.LeftSealed]?: string;
@ -94,7 +92,7 @@ export interface BoardProcessOption extends BoardOption
spliteHeight?: string;//拆单高/宽/厚
spliteWidth?: string;
spliteThickness?: string;
highDrill?: string[];
}
/**
*

@ -7,9 +7,17 @@ import { Singleton } from '../../Common/Singleton';
import { Board, BoardType } from '../../DatabaseServices/Board';
import { IConfigOption } from '../Components/Board/UserConfig';
import { ModalState } from '../Components/Modal/ModalsManage';
import { BehindBoardOption, BehindHeightPositon, BoardConfigOption, BoardOption, BoardProcessOption, BrRelativePos, ClosingStripOption, ComposingType, DrillType, LayerBoardOption, LayerNailOption, LinesType, FaceDirection, SideBoardOption, SingleBoardOption, StripType, TBBoardOption, VerticalBoardOption, IGrooveOption } from './BoardInterface';
import { BehindBoardOption, BehindHeightPositon, BoardConfigOption, BoardOption, BoardProcessOption, BrRelativePos, ClosingStripOption, ComposingType, LayerBoardOption, LayerNailOption, LinesType, FaceDirection, SideBoardOption, SingleBoardOption, StripType, TBBoardOption, VerticalBoardOption, IGrooveOption } from './BoardInterface';
import { userConfig } from '../../Editor/UserConfig';
export class BoardStore extends Singleton
export interface IConfigStore
{
SaveConfig: Function,
UpdateOption: Function,
}
export class BoardStore extends Singleton implements IConfigStore
{
m_Option: BoardOption;
protected m_UiOption;
@ -23,7 +31,7 @@ export class BoardStore extends Singleton
color: "",
lines: LinesType.Positive,
bigHoleDir: FaceDirection.Front,
drillType: DrillType.Three,
drillType: "",
composingFace: ComposingType.Arbitrary,
highSealed: [],
sealedUp: "1",
@ -34,6 +42,13 @@ export class BoardStore extends Singleton
spliteWidth: "",
spliteThickness: ""
}
constructor()
{
super();
let drilltypes = [...userConfig.drillConfigs.keys()];
if (drilltypes.length > 0)
this.m_BoardProcessOption.drillType = drilltypes[0];
}
get UIOption()
{
if (!this.m_UiOption)

@ -1,24 +1,25 @@
import { observable, toJS } from "mobx";
import { CheckObjectType, CheckoutValid } from "../../Common/CheckoutVaildValue";
import { DrillingOption, DrillType, SpacingType } from "./drillInterface";
import { DataAdapter } from "../../Common/DataAdapter";
import { IConfigOption } from "../Components/Board/UserConfig";
import { BoardStore } from "./BoardStore";
import { DataAdapter } from "../../Common/DataAdapter";
import { DrillingOption, SpacingType } from "./drillInterface";
export class DrillStore extends BoardStore
{
@observable m_CurrentRuleIndex = 0;
@observable type: DrillType = DrillType.Three;
@observable type = "三合一";
@observable rules: DrillingOption[] = []
@observable rules: DrillingOption[] = [];
@observable m_Option: DrillingOption;
@observable drillConfig: Map<string, DrillingOption[]> = new Map();
constructor()
{
super();
this.Init();
}
Init()
private GetDefaultOption()
{
let originOption: DrillingOption = {
startDist: 0,
@ -57,42 +58,32 @@ export class DrillStore extends BoardStore
ymjDepth: 13.5,
ljgPos: "H*0.5",
woodPinPos: "H*0.5"
}
this.m_Option = originOption;
this.rules.push(originOption);
};
let opt1 = Object.assign({}, originOption);
opt1.count = 1;
opt1.startDist = 40;
opt1.endDist = 80;
this.rules.push(opt1);
let opt2 = Object.assign({}, opt1);
opt2.count = 2;
opt2.isForceDiv = true;
opt2.startDist = 80;
opt2.endDist = 200;
this.rules.push(opt2);
let opt3 = Object.assign({}, opt2);
opt3.isForceDiv = false;
opt3.startDist = 200;
opt3.endDist = 500;
this.rules.push(opt3);
let opt4 = Object.assign({}, opt3);
opt4.count = 3;
opt4.startDist = 500;
opt4.endDist = 900;
this.rules.push(opt4);
let opt5 = Object.assign({}, opt4);
opt5.count = 4;
opt5.startDist = 900;
opt5.endDist = 1500;
this.rules.push(opt5);
let opt6 = Object.assign({}, opt5);
opt6.count = 5;
@ -100,7 +91,29 @@ export class DrillStore extends BoardStore
opt6.retDist = 100;
opt6.startDist = 1500;
opt6.endDist = 2000;
this.rules.push(opt6);
return [originOption, opt1, opt2, opt3, opt4, opt5, opt6];
}
Init()
{
let rules = this.GetDefaultOption();
this.m_Option = rules[0];
this.rules.push(...rules);
this.drillConfig.set("三合一", rules);
this.drillConfig.set("二合一", this.GetDefaultOption().map(opt =>
{
opt.pxlRad = 10;
opt.ljgLength = 10;
opt.name = "二合一";
return opt;
}));
}
AddNewDrillType(name: string)
{
this.drillConfig.set(name, this.GetDefaultOption());
}
SaveRuleOption()
{
@ -136,20 +149,35 @@ export class DrillStore extends BoardStore
//新的配置
let newConfig: IConfigOption = {};
this.SaveRuleOption();
newConfig.rules = toJS(this.rules);
let config = toJS(this.drillConfig, { exportMapsAsObjects: false });
if (config.has(this.type))
config.set(this.type, toJS(this.rules))
newConfig.ruleMap = config;
return newConfig;
}
UpdateOption(cof: IConfigOption)
{
observable(this.rules).replace(cof.rules);
this.drillConfig.clear();
for (let [k, v] of cof.ruleMap)
{
this.drillConfig.set(k, v);
}
if (cof.ruleMap.size > 0)
{
this.type = [...cof.ruleMap.keys()][0];
observable(this.rules).replace(cof.ruleMap.get(this.type));
this.ChangeRules(0);
}
ChangeRules(i)
}
ChangeRules(i: number)
{
this.m_CurrentRuleIndex = i;
if (this.rules.length > 0)
{
Object.assign(this.m_Option, this.rules[this.m_CurrentRuleIndex]);
Object.assign(this.m_UiOption, DataAdapter.ConvertUIData(this.rules[this.m_CurrentRuleIndex]));
}
}
DeleteRule = () =>
{
this.rules.splice(this.m_CurrentRuleIndex, 1);

@ -1,24 +1,74 @@
import { TabId } from "@blueprintjs/core";
import { observable, toJS } from "mobx";
import { DrawDrillingTool } from "../../Add-on/DrawDrilling/DrawDrillingTool";
import { app } from "../../ApplicationServices/Application";
import { KeyCode } from "../../Common/KeyEnum";
import { Singleton } from "../../Common/Singleton";
import { IModeling } from "../../DatabaseServices/Board";
import { Board, IModeling } from "../../DatabaseServices/Board";
import { Curve } from "../../DatabaseServices/Curve";
import { JigUtils } from "../../Editor/JigUtils";
import { paragraphCulist } from "../../GraphicsSystem/CalcEdgeSealing";
import { IConfigOption } from "../Components/Board/UserConfig";
import { IModelingItem } from "../Components/RightPanel/ModelingComponent";
import { FaceDirection } from "./BoardInterface";
import { FaceDirection, IHighSealedItem, DrillType } from "./BoardInterface";
import { LightStore } from "./LightStore";
import { TabId } from "@blueprintjs/core";
import { IndexedDbStore, StoreName } from "../../IndexedDb/IndexedDbStore";
import { commandMachine } from "../../Editor/CommandMachine";
import { AppToaster } from "../Components/Toaster";
import { RightTabId } from "../Components/RightPanel/RightPanel";
import { IConfigStore } from "./BoardStore";
import { userConfig } from "../../Editor/UserConfig";
import { Matrix4 } from "three";
import { Entity } from "../../DatabaseServices/Entity";
export function toggleObject3DVisible(visible = false)
{
app.m_Database.ModelSpace.Entitys.forEach(e =>
{
e.Visible = visible;
})
}
export function changeView(en: Entity)
{
app.m_Viewer.m_CameraCtrl.LookAt(en.Normal.negate());
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(en.OCS);
app.m_Viewer.ZoomAll();
app.m_Editor.UpdateScreen();
}
export class RightPanelStore extends Singleton
export class RightPanelStore extends Singleton implements IConfigStore
{
@observable m_TabId: TabId = "modeling";
@observable m_TabId: TabId = RightTabId.Model;
@observable m_BoardTemplateTabId: TabId = "cabinet";
@observable m_IsShow = false;
@observable modelingItems: IModelingItem[] = [];
@observable UIModelingItems = [];
lightStore = new LightStore();
currentBoard: Board;
@observable cuList: Curve[] = [];
@observable highSizes: string[] = [];
@observable drillDataList: string[] = []; //前2个为正反面排钻类型
constructor()
{
super();
this.InitModelingItems();
this.InitSealingData();
this.InitDrillingData();
}
RegisterEvent()
{
document.addEventListener('keydown', this.Exit)
}
RemoveEvent()
{
document.removeEventListener('keydown', this.Exit);
}
Exit = (e: KeyboardEvent) =>
{
if (e.code === KeyCode.Escape)
{
this.ExitEditor();
}
}
InitModelingItems()
{
@ -49,6 +99,181 @@ export class RightPanelStore extends Singleton
this.modelingItems[index].dir = data.dir;
this.UIModelingItems[index]["dir"] = data.dir;
}
ShowCurve()
{
for (let i = 0; i < this.cuList.length; i++)
{
let cu = this.cuList[i];
cu.ApplyMatrix(this.currentBoard.OCS);
app.m_Database.ModelSpace.Append(cu);
}
app.m_Editor.UpdateScreen();
}
async InitSealingData()
{
let dbstore = await IndexedDbStore.CADStore();
//获取数据库中对应板类型的配置
let highSizes = await dbstore.Get(StoreName.ConfigData, RightTabId.Seal);
if (highSizes)
observable(this.highSizes).replace(highSizes);
else
{
this.highSizes.push(...Array(15).fill("1"));
dbstore.Put(StoreName.ConfigData, RightTabId.Seal, toJS(this.highSizes));
}
}
async EditorEdgeSealing(br: Board)
{
// this.RegisterEvent();
toggleObject3DVisible();
let cus = br.ContourCurve.Explode() as Curve[];
this.currentBoard = br;
//曲线分段
paragraphCulist(cus);
//替换曲线列表
observable(this.cuList).replace(cus);
let highseals = br.BoardProcessOption.highSealed;
await this.InitSealingData();
if (highseals.length === cus.length)
{
for (let i = 0; i < highseals.length; i++)
{
let s = highseals[i];
let color = s.color;
this.cuList[i].ColorIndex = color;
this.highSizes[color - 1] = s.size.toString();
}
}
else
{
this.cuList.forEach(cu => cu.ColorIndex = 1);
}
this.ShowCurve();
changeView(br);
}
async InitDrillingData()
{
let dbstore = await IndexedDbStore.CADStore();
//获取数据库中对应板类型的配置
let drillData = await dbstore.Get(StoreName.ConfigData, RightTabId.Drill);
if (!drillData)
drillData = [];
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++)
{
drillData[i + 2] = drillData[i + 2] || types[i];
}
observable(this.drillDataList).replace(drillData);
}
async EditorDrilling(br: Board)
{
// this.RegisterEvent();
toggleObject3DVisible();
this.currentBoard = br;
observable(this.cuList).replace(br.ContourCurve.Explode() as Curve[]);
let highDrillData = br.BoardProcessOption.highDrill;
await this.InitDrillingData();
if (highDrillData.length === br.ContourCurve.EndParam + 2)
{
this.drillDataList[0] = highDrillData[0];
this.drillDataList[1] = highDrillData[1];
let drills = [...new Set(highDrillData.slice(2))];
for (let i = 0; i < drills.length; i++)
{
this.drillDataList[i + 2] = drills[i];
}
for (let i = 2; i < highDrillData.length; i++)
{
this.cuList[i - 2].ColorIndex = drills.indexOf(highDrillData[i]) + 1;
}
}
else
{
this.drillDataList[0] = br.BoardProcessOption.drillType;
this.drillDataList[1] = br.BoardProcessOption.drillType;
this.drillDataList[2] = br.BoardProcessOption.drillType;
this.cuList.forEach(c => c.ColorIndex = 1);
}
this.ShowCurve();
changeView(br);
}
WriteSealingData()
{
if (!this.currentBoard)
return;
let highSeal: IHighSealedItem[] = [];
for (let cu of this.cuList)
{
const color = cu.ColorIndex;
if (color > this.highSizes.length)
{
AppToaster.show({
message: color + "号色未设置数据",
timeout: 1500
})
highSeal = null;
break;
}
const size = this.highSizes[color - 1];
highSeal.push({ size: parseFloat(size), color });
}
if (highSeal)
{
if (!commandMachine.CommandStart("_editor"))
return;
this.currentBoard.BoardProcessOption.highSealed = highSeal;
commandMachine.CommandEnd();
this.ExitEditor();
}
}
WriteDrillData()
{
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];
for (let cu of this.cuList)
{
let type = this.drillDataList[cu.ColorIndex + 1];
if (!type)
{
AppToaster.show({ message: "未知色号,默认三合一", timeout: 1000 });
type = defultType;
}
highDrill.push(type);
}
let tool = DrawDrillingTool.GetInstance() as DrawDrillingTool;
tool.ResetGangDrill(this.currentBoard);
commandMachine.CommandEnd();
this.ExitEditor();
}
ExitEditor()
{
toggleObject3DVisible(true);
for (let c of this.cuList)
{
!c.IsErase && app.m_Database.ModelSpace.Remove(c);
}
this.cuList.length = 0;
// this.RemoveEvent();
JigUtils.Destroy();
AppToaster.clear();
}
SaveConfig()
{
//新的配置

@ -0,0 +1,112 @@
import { Singleton } from "../../Common/Singleton";
import { observable } from "mobx";
import { AppToaster } from "../Components/Toaster";
import { IndexedDbStore, StoreName } from "../../IndexedDb/IndexedDbStore";
import { IConfigOption } from "../Components/Board/UserConfig";
import { IConfigStore } from "./BoardStore";
import { BoardModalType } from "../Components/Board/BoardModal";
import { arrayLast } from "../../Common/ArrayExt";
import { userConfig } from "../../Editor/UserConfig";
export class UserConfigStore extends Singleton
{
@observable configName = "默认";
@observable configs: Map<string, IConfigOption> = new Map();
async GetConfig(type: BoardModalType): Promise<IConfigOption | null>
{
let dbstore = await IndexedDbStore.CADStore();
let configs = await dbstore.Get(StoreName.ConfigData, type);
if (configs)
{
let confNames = [...configs.keys()];
let curName = localStorage.getItem("configName");
if (!curName)
curName = arrayLast(confNames);
return configs.get(curName);
}
return null;
}
async SaveConfig(type: BoardModalType, store: IConfigStore, isInit: boolean = false)
{
let name = this.configName;
if (name === "")
{
AppToaster.show({
message: "请输入名称",
timeout: 1000
});
return;
}
let dbstore = await IndexedDbStore.CADStore();
//新的配置
let newConfig: IConfigOption = store.SaveConfig();
//获取数据库中对应板类型的配置
let brDataMap = (await dbstore.Get(StoreName.ConfigData, type) || new Map()) as Map<string, IConfigOption>;
// 配置添加到数据库
brDataMap.set(name, newConfig);
dbstore.Put(StoreName.ConfigData, type, brDataMap);
observable(this.configs).replace(brDataMap);
AppToaster.show({
message: isInit ? "初始化配置成功" : "配置保存成功",
timeout: 1000
});
localStorage.setItem("configName", name);
if (type === BoardModalType.Dr)
userConfig.drillConfigs = newConfig.ruleMap;
}
//删除配置
async DeleteConfig(type: BoardModalType, store: IConfigStore)
{
// 删除视图中的对应项
let currentName = this.configName;
if (currentName === "默认")
{
AppToaster.show({
message: "默认配置不允许删除",
timeout: 1000
});
return;
}
this.configs.delete(currentName);
//删除数据库中的对应项
let dbstore = await IndexedDbStore.CADStore();
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, IConfigOption>;
brDataMap.delete(currentName);
dbstore.Put(StoreName.ConfigData, type, brDataMap);
//切换到第一项
let confNames = Array.from(brDataMap.keys());
let newName = confNames.length > 0 ? confNames[0] : "";
this.configName = newName;
await this.UpdateBoardOption(newName, type, store);
localStorage.setItem("configName", newName);
if (type === BoardModalType.Dr)
userConfig.drillConfigs = brDataMap.get(newName).ruleMap;
}
//更新配置
UpdateBoardOption = async (k: string, type: BoardModalType, store: IConfigStore) =>
{
this.configName = k;
let dbstore = await IndexedDbStore.CADStore();
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, IConfigOption>;
let conf = brDataMap.get(k);
if (brDataMap && conf)
{
store.UpdateOption(conf);
localStorage.setItem("configName", k);
if (type === BoardModalType.Dr)
userConfig.drillConfigs = conf.ruleMap;
}
}
}
export const userConfigStore = UserConfigStore.GetInstance() as UserConfigStore;

@ -10,7 +10,7 @@ export class WineRackStore extends BoardStore
@observable m_Option: IWineRackOption = {
type: EWineRackType.Bias,
arrayType: EWRackArrayType.ByWidth,
fullType: EFullType.ByHeight,
fullType: EFullType.ByWidth,
isFull: false,
isLock: false,
fullDir: EFullDir.Left,

Loading…
Cancel
Save