!1086 功能:右侧造型面板加入槽加深和加宽,通槽自动加长

pull/1086/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 4ef725881e
commit 55f3e99f01

@ -8,18 +8,17 @@ import { Circle } from "../../DatabaseServices/Entity/Circle";
import { Curve } from "../../DatabaseServices/Entity/Curve"; import { Curve } from "../../DatabaseServices/Entity/Curve";
import { Line } from "../../DatabaseServices/Entity/Line"; import { Line } from "../../DatabaseServices/Entity/Line";
import { Polyline } from "../../DatabaseServices/Entity/Polyline"; import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { HardwareCompositeEntity } from '../../DatabaseServices/Hardware/HardwareCompositeEntity';
import { Shape } from "../../DatabaseServices/Shape"; import { Shape } from "../../DatabaseServices/Shape";
import { ShapeManager } from "../../DatabaseServices/ShapeManager"; import { ShapeManager } from "../../DatabaseServices/ShapeManager";
import { Route } from "../../Geometry/CurveMap"; import { Route } from "../../Geometry/CurveMap";
import { GetSideFaceMtx } from "../../Geometry/DrillParse/BoardGetFace"; import { GetSideFaceMtx } from "../../Geometry/DrillParse/BoardGetFace";
import { angleTo, isParallelTo, MoveMatrix, XAxis } from "../../Geometry/GeUtils"; import { angleTo, isParallelTo, MoveMatrix, XAxis } from "../../Geometry/GeUtils";
import { RegionParse } from "../../Geometry/RegionParse"; import { RegionParse } from "../../Geometry/RegionParse";
import { Production } from "../../Production/Product";
import { FaceDirection } from "../../UI/Store/BoardInterface"; import { FaceDirection } from "../../UI/Store/BoardInterface";
import { BoolOpeartionType, isTargetCurInOrOnSourceCur } from "../BoolOperateUtils"; import { BoolOpeartionType, isTargetCurInOrOnSourceCur } from "../BoolOperateUtils";
import { GetSealedBoardContour } from "../CalcEdgeSealing"; import { GetSealedBoardContour } from "../CalcEdgeSealing";
import { GetCurveToInDir, GetOffsetCurves, OptimizeToolPath } from "./OptimizeToolPath"; import { GetCurveToInDir, GetOffsetCurves, OptimizeToolPath } from "./OptimizeToolPath";
import { FixIndex } from "../../Nest/Common/Util";
/** /**
* *
@ -158,7 +157,7 @@ export class FeedingToolPath extends Singleton
let modelings = br.BoardModeling; let modelings = br.BoardModeling;
let allModeling = GetModelingFromCustomDrill(br); let allModeling = GetModelingFromCustomDrill(br);
modelings.push(...allModeling.modeling); modelings.push(...allModeling.modeling);
let cus = this.CalcPath(modelings, br.Thickness); let cus = this.CalcPath(modelings, br);
let outline = br.ContourCurve as Polyline; let outline = br.ContourCurve as Polyline;
let dir = Math.sign(outline.Area2); let dir = Math.sign(outline.Area2);
@ -180,7 +179,7 @@ export class FeedingToolPath extends Singleton
sideOutlines.push(pl); sideOutlines.push(pl);
} }
cus.push(...this.CalcPath(allModeling.sideModeling, br.Height)); cus.push(...this.CalcPath(allModeling.sideModeling, br));
//加入板件轮廓 //加入板件轮廓
cus.unshift(br.ContourCurve.Clone()); cus.unshift(br.ContourCurve.Clone());
if (cus.length === 1) if (cus.length === 1)
@ -210,17 +209,18 @@ export class FeedingToolPath extends Singleton
* *
* TODO:===ys * TODO:===ys
*/ */
CalcPath(modelings: IModeling[], thickness: number): Curve[] CalcPath(modelings: IModeling[], br: Board): Curve[]
{ {
let cus: Curve[] = []; let cus: Curve[] = [];
for (let m of modelings) for (let m of modelings)
{ {
cus.push(...this.GetModelFeedPath(thickness, m)); cus.push(...this.GetModelFeedPath(br, m));
} }
return cus; return cus;
} }
GetModelFeedPath(brThickness: number, m: IModeling): Curve[] GetModelFeedPath(br: Board, m: IModeling): Curve[]
{ {
const brThickness = br.Thickness;
let cus: Curve[] = []; let cus: Curve[] = [];
let { shape, thickness, knifeRadius, addLen, addWidth, addDepth } = m; let { shape, thickness, knifeRadius, addLen, addWidth, addDepth } = m;
if (!knifeRadius) knifeRadius = 3; if (!knifeRadius) knifeRadius = 3;
@ -228,6 +228,7 @@ export class FeedingToolPath extends Singleton
shape = shape.Clone(); shape = shape.Clone();
shape.Z0(); shape.Z0();
this.GrooveAddSize(shape, addLen, addWidth); this.GrooveAddSize(shape, addLen, addWidth);
this.HandleThoughGroove(br, shape, knifeRadius);
if (thickness >= brThickness) if (thickness >= brThickness)
{ {
@ -323,12 +324,97 @@ export class FeedingToolPath extends Singleton
let modelings = br.BoardModeling; let modelings = br.BoardModeling;
for (let i = 0; i < modelings.length; i++) for (let i = 0; i < modelings.length; i++)
{ {
let cus = this.GetModelFeedPath(br.Thickness, modelings[i]); let cus = this.GetModelFeedPath(br, modelings[i]);
if (cus.length === 0) if (cus.length === 0)
errorIndexs.push(i); errorIndexs.push(i);
} }
return errorIndexs; return errorIndexs;
} }
HandleThoughGroove(br: Board, shape: Shape, knifeRadius: number)
{
let brCon = br.ContourCurve;
let outline = shape.Outline.Curve;
if (outline instanceof Circle) return;
let cus = outline.Explode();
let hasChange = false;
for (let i = 0; i < cus.length; i++)
{
let c = cus[i];
if (c instanceof Line)
{
let mp = c.Midpoint;
if (brCon.PtOnCurve(mp))
{
hasChange = true;
let cs = c.GetOffsetCurves(knifeRadius);
cus[i] = cs[0];
let fline = cus[FixIndex(i - 1, cus.length)];
if (fline instanceof Line)
{
let intPts = fline.IntersectWith(cs[0], 3);
if (intPts.length === 0)
{
console.error("未知错误情况");
return;
}
fline.EndPoint = intPts[0];
cs[0].StartPoint = intPts[0];
}
else
{
let newLine = new Line(fline.EndPoint, cs[0].StartPoint);
if (i === 0)
{
cus.push(newLine);
}
else
{
cus.splice(i, 0, newLine);
i++;
}
}
let backLine = cus[FixIndex(i + 1, cus.length)];
if (backLine instanceof Line)
{
let intPts = backLine.IntersectWith(cs[0], 3);
if (intPts.length === 0)
{
console.error("未知错误情况");
return;
}
backLine.StartPoint = intPts[0];
cs[0].EndPoint = intPts[0];
}
else
{
let newLine = new Line(cs[0].EndPoint, backLine.StartPoint);
if (i + 1 === cus.length)
{
cus.unshift(newLine);
}
else
{
cus.splice(i + 1, 0, newLine);
i++;
}
}
}
}
}
if (hasChange)
{
let con = Contour.CreateContour(Polyline.Combine(cus));
if (con)
shape.Outline = con;
else
console.error("错误");
}
}
} }
export function GetModelingFromCustomDrill(br: Board) export function GetModelingFromCustomDrill(br: Board)
{ {

@ -368,7 +368,6 @@ export namespace Production
export function GetBoardModelingData(br: Board, offsetTanslation: Vector3) export function GetBoardModelingData(br: Board, offsetTanslation: Vector3)
{ {
const tool = FeedingToolPath.GetInstance() as FeedingToolPath; const tool = FeedingToolPath.GetInstance() as FeedingToolPath;
const thickness = br.Thickness;
const getModelings = (ms: IModeling[], isSide: boolean): IModelingData[] => const getModelings = (ms: IModeling[], isSide: boolean): IModelingData[] =>
{ {
@ -381,7 +380,7 @@ export namespace Production
continue; continue;
if (!isSide) if (!isSide)
m.shape.ApplyMatrix(MoveMatrix(offsetTanslation.clone().negate())); m.shape.ApplyMatrix(MoveMatrix(offsetTanslation.clone().negate()));
let feeding = tool.GetModelFeedPath(thickness, m).map(ConverToPolylineAndSplitArc); let feeding = tool.GetModelFeedPath(br, m).map(ConverToPolylineAndSplitArc);
if (feeding.length > 0) if (feeding.length > 0)
data.push({ data.push({
feeding, feeding,

@ -188,12 +188,12 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
store.modelingStore.ChangeModelingValue(color - 1, data); store.modelingStore.ChangeModelingValue(color - 1, data);
} }
let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().ApplyMatrix(br.OCS)); let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().Z0().ApplyMatrix(br.OCS));
cu.ColorIndex = color; cu.ColorIndex = color;
moveCus.push(cu); moveCus.push(cu);
for (let c of data.shape.Holes) for (let c of data.shape.Holes)
{ {
cu = JigUtils.Draw(c.Curve.Clone().ApplyMatrix(br.OCS)); cu = JigUtils.Draw(c.Curve.Clone().Z0().ApplyMatrix(br.OCS));
cu.ColorIndex = color; cu.ColorIndex = color;
moveCus.push(cu); moveCus.push(cu);
} }
@ -368,6 +368,8 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
groove.ContourCurve = shape.Outline.Curve; groove.ContourCurve = shape.Outline.Curve;
groove.KnifeRadius = cd.knifeRad; groove.KnifeRadius = cd.knifeRad;
groove.GroovesAddLength = cd.addLen; groove.GroovesAddLength = cd.addLen;
groove.GroovesAddWidth = cd.addWidth;
groove.GroovesAddDepth = cd.addDepth;
for (let hole of shape.Holes) for (let hole of shape.Holes)
{ {
let holeSolid = new ExtrudeSolid(); let holeSolid = new ExtrudeSolid();

@ -1,5 +1,5 @@
import { Button, Card, Checkbox, Classes, Intent, IOptionProps, Popover, Position, Radio, RadioGroup, HTMLSelect } from '@blueprintjs/core'; import { Button, Card, Checkbox, Classes, Intent, IOptionProps, Popover, Position, Radio, RadioGroup, HTMLSelect } from '@blueprintjs/core';
import { observable, toJS } from 'mobx'; import { observable, toJS, action } from 'mobx';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { DirUrl, TemplateUrls } from '../../../Common/HostUrl'; import { DirUrl, TemplateUrls } from '../../../Common/HostUrl';
@ -40,12 +40,12 @@ export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { type
this.handleUpdate(); this.handleUpdate();
} }
}; };
private handleUpdate = () => private handleUpdate = action(() =>
{ {
const store = this.props.store; const store = this.props.store;
observable(store.rules).replace(store.drillConfig.get(store.type)); observable(store.rules).replace(store.drillConfig.get(store.type));
store.ChangeRules(0); store.ChangeRules(0);
}; });
private renderRadiosType = () => private renderRadiosType = () =>
{ {
const store = this.props.store; const store = this.props.store;

@ -9,7 +9,7 @@
#RightPanel .bp3-tab-panel { #RightPanel .bp3-tab-panel {
width: 100%; width: 100%;
overflow: auto; overflow: auto;
padding: 10px; padding: 5px;
} }
#RightPanel .bp3-tab-panel.tab-unstyle { #RightPanel .bp3-tab-panel.tab-unstyle {
@ -32,7 +32,7 @@
&>li>label { &>li>label {
text-align: center; text-align: center;
flex: 1; width: 20%;
box-shadow: 0 0 0 0 rgba(19, 124, 189, 0), box-shadow: 0 0 0 0 rgba(19, 124, 189, 0),
0 0 0 0 rgba(19, 124, 189, 0), 0 0 0 0 rgba(19, 124, 189, 0),
0 0 0 0 rgba(19, 124, 189, 0), 0 0 0 0 rgba(19, 124, 189, 0),
@ -52,9 +52,18 @@
span, span,
input, input,
&>div { &>div {
width: 20%; width: 15%;
margin: 0; margin: 0;
} }
&>span:first-child,
&>label:first-child {
line-height: 2;
width: 10%;
padding: 0;
text-align: center;
display: inline-block;
}
} }
} }

@ -15,6 +15,8 @@ export interface IModelingItem
dir: FaceDirection; dir: FaceDirection;
knifeRad: number; knifeRad: number;
addLen: number; addLen: number;
addWidth: number;
addDepth: number;
} }
@inject("store") @inject("store")
@ -34,6 +36,8 @@ export class ModelingComponent extends React.Component<{ store?: RightPanelStore
<Label></Label> <Label></Label>
<Label></Label> <Label></Label>
<Label></Label> <Label></Label>
<Label></Label>
<Label></Label>
</li> </li>
{ {
uiData.map((item, index) => uiData.map((item, index) =>
@ -46,22 +50,15 @@ export class ModelingComponent extends React.Component<{ store?: RightPanelStore
if (k === "dir") if (k === "dir")
{ {
return ( return (
<HTMLSelect <select value={data[index].dir}
options={
[{
label: "正", value: FaceDirection.Front
},
{
label: "反", value: FaceDirection.Back
}]
}
value={item[k]}
onChange={e => onChange={e =>
{ {
data[index].dir = safeEval(e.target.value) as FaceDirection; data[index].dir = Number(e.target.value) as FaceDirection;
item[k] = safeEval(e.target.value);
}} }}
/> >
<option value={FaceDirection.Front}></option>
<option value={FaceDirection.Back}></option>
</select>
); );
} }
else if (k !== "color") else if (k !== "color")

@ -1,5 +1,5 @@
import { observable, toJS } from 'mobx'; import { observable, toJS, action } from 'mobx';
import { app } from '../../ApplicationServices/Application'; import { app } from '../../ApplicationServices/Application';
import { EBoardKeyList } from '../../Common/BoardKeyList'; import { EBoardKeyList } from '../../Common/BoardKeyList';
import { CheckObjectType, CheckoutValid } from '../../Common/CheckoutVaildValue'; import { CheckObjectType, CheckoutValid } from '../../Common/CheckoutVaildValue';
@ -171,6 +171,7 @@ export class BoardStore extends Singleton implements IConfigStore
]; ];
return newConfig; return newConfig;
} }
@action
UpdateOption(cof: IConfigOption) UpdateOption(cof: IConfigOption)
{ {
if (!cof.option) if (!cof.option)
@ -192,6 +193,7 @@ export class BoardStore extends Singleton implements IConfigStore
this.InitDrillType(); this.InitDrillType();
this.InitRectDrillData(cof.processData.highDrill); this.InitRectDrillData(cof.processData.highDrill);
} }
@action
protected UpdateRemarks(cof: IConfigOption) protected UpdateRemarks(cof: IConfigOption)
{ {
this.remarks.forEach(d => this.remarks.forEach(d =>

@ -1,4 +1,4 @@
import { observable, toJS } from "mobx"; import { observable, toJS, action } from "mobx";
import { CheckObjectType, CheckoutValid } from "../../Common/CheckoutVaildValue"; import { CheckObjectType, CheckoutValid } from "../../Common/CheckoutVaildValue";
import { DataAdapter } from "../../Common/DataAdapter"; import { DataAdapter } from "../../Common/DataAdapter";
import { IConfigOption } from "../Components/Board/UserConfig"; import { IConfigOption } from "../Components/Board/UserConfig";
@ -184,6 +184,7 @@ export class DrillStore extends BoardStore
newConfig.ruleMap = toJS(config, { exportMapsAsObjects: false }); newConfig.ruleMap = toJS(config, { exportMapsAsObjects: false });
return newConfig; return newConfig;
} }
@action
UpdateOption(cof: IConfigOption) UpdateOption(cof: IConfigOption)
{ {
this.drillConfig.clear(); this.drillConfig.clear();

@ -1,30 +1,23 @@
import { observable, toJS } from "mobx"; import { observable, toJS, action } from "mobx";
import { IModelingItem } from "../../Components/RightPanel/ModelingComponent"; import { IModelingItem } from "../../Components/RightPanel/ModelingComponent";
import { Modify } from "../../../Common/TypeOperator";
import { IModeling } from "../../../DatabaseServices/Entity/Board"; import { IModeling } from "../../../DatabaseServices/Entity/Board";
import { FixedNotZero } from "../../../Common/Utils"; import { FixedNotZero } from "../../../Common/Utils";
import { FaceDirection } from "../BoardInterface"; import { FaceDirection, IUiOption } from "../BoardInterface";
import { IConfigOption } from "../../Components/Board/UserConfig"; import { IConfigOption } from "../../Components/Board/UserConfig";
import { IConfigStore } from "../BoardStore"; import { IConfigStore } from "../BoardStore";
type IUIModeiling = Modify<IModelingItem, {
color: string;
height: string;
knifeRad: string;
addLen: string;
}>;
export class ModelingStore implements IConfigStore export class ModelingStore implements IConfigStore
{ {
@observable configName = "默认"; @observable configName = "默认";
@observable configsNames: string[] = []; @observable configsNames: string[] = [];
@observable modelingItems: IModelingItem[] = []; @observable modelingItems: IModelingItem[] = [];
@observable UIModelingItems: IUIModeiling[] = []; @observable UIModelingItems: IUiOption<IModelingItem>[] = [];
isUpdate = true; isUpdate = true;
constructor() constructor()
{ {
this.InitModelingItems(); this.InitModelingItems();
} }
@action
InitModelingItems() InitModelingItems()
{ {
this.modelingItems.length = 0; this.modelingItems.length = 0;
@ -34,29 +27,42 @@ export class ModelingStore implements IConfigStore
this.UIModelingItems.push({ this.UIModelingItems.push({
color: (i + 1).toString(), color: (i + 1).toString(),
height: "0", height: "0",
dir: FaceDirection.Front, dir: "0",
knifeRad: "3", knifeRad: "3",
addLen: "0" addLen: "0",
addWidth: "0",
addDepth: "0",
}); });
this.modelingItems.push({ this.modelingItems.push({
color: i + 1, color: i + 1,
height: 0, height: 0,
dir: FaceDirection.Front, dir: FaceDirection.Front,
knifeRad: 3, knifeRad: 3,
addLen: 0 addLen: 0,
addWidth: 0,
addDepth: 0,
}); });
} }
} }
@action
ChangeModelingValue(index: number, data: IModeling) ChangeModelingValue(index: number, data: IModeling)
{ {
this.modelingItems[index].height = data.thickness; this.modelingItems[index].height = data.thickness;
this.UIModelingItems[index]["height"] = FixedNotZero(data.thickness, 2); this.UIModelingItems[index].height = FixedNotZero(data.thickness, 2);
this.modelingItems[index].dir = data.dir; this.modelingItems[index].dir = data.dir;
this.UIModelingItems[index]["dir"] = data.dir;
this.modelingItems[index].knifeRad = data.knifeRadius; this.modelingItems[index].knifeRad = data.knifeRadius;
this.UIModelingItems[index]["knifeRad"] = data.knifeRadius.toString(); this.UIModelingItems[index].knifeRad = data.knifeRadius.toString();
this.modelingItems[index].addLen = data.addLen; this.modelingItems[index].addLen = data.addLen;
this.UIModelingItems[index]["addLen"] = data.addLen.toString(); this.UIModelingItems[index].addLen = data.addLen.toString();
this.modelingItems[index].addWidth = data.addWidth;
this.UIModelingItems[index].addWidth = data.addWidth.toString();
this.modelingItems[index].addDepth = data.addDepth;
this.UIModelingItems[index].addDepth = data.addDepth.toString();
} }
InitOption() InitOption()
{ {
@ -69,6 +75,7 @@ export class ModelingStore implements IConfigStore
newConfig.option = toJS(this.modelingItems); newConfig.option = toJS(this.modelingItems);
return newConfig; return newConfig;
} }
@action
UpdateOption(cof: IConfigOption) UpdateOption(cof: IConfigOption)
{ {
observable(this.modelingItems).replace(cof.option as IModelingItem[]); observable(this.modelingItems).replace(cof.option as IModelingItem[]);
@ -77,6 +84,8 @@ export class ModelingStore implements IConfigStore
this.UIModelingItems[i].height = this.modelingItems[i].height.toString(); this.UIModelingItems[i].height = this.modelingItems[i].height.toString();
this.UIModelingItems[i].knifeRad = this.modelingItems[i].knifeRad.toString(); this.UIModelingItems[i].knifeRad = this.modelingItems[i].knifeRad.toString();
this.UIModelingItems[i].addLen = this.modelingItems[i].addLen.toString(); this.UIModelingItems[i].addLen = this.modelingItems[i].addLen.toString();
this.UIModelingItems[i].addWidth = this.modelingItems[i].addWidth?.toString() ?? "0";
this.UIModelingItems[i].addDepth = this.modelingItems[i].addDepth?.toString() ?? "0";
} }
} }
} }

Loading…
Cancel
Save