优化背板布局

pull/93/head
Zoe 6 years ago
parent ad793b0b24
commit 8ec716ce5c

@ -59,7 +59,7 @@
"webpack-dev-server": "^2.11.1" "webpack-dev-server": "^2.11.1"
}, },
"dependencies": { "dependencies": {
"@blueprintjs/core": "^1.35.2", "@blueprintjs/core": "^1.39.0",
"blueimp-md5": "^2.10.0", "blueimp-md5": "^2.10.0",
"css-element-queries": "^1.0.2", "css-element-queries": "^1.0.2",
"dat.gui": "^0.7.1", "dat.gui": "^0.7.1",

@ -35,8 +35,8 @@ export class DrawBehindBoard implements Command
if (state === ModalState.Ok) if (state === ModalState.Ok)
{ {
let board = Board.CreateBoard(spaceParse.BehindLength, spaceParse.SpaceLength, parseFloat(store.behindBoardOption.thickness), BoardType.Behind); let board = Board.CreateBoard(spaceParse.BehindLength, spaceParse.SpaceLength, parseFloat(store.behindBoardOption.thickness) / 100, BoardType.Behind);
spaceParse.BaseBehindPoint.add(new Vector3(0, -parseFloat(store.behindBoardOption.thickness))) spaceParse.BaseBehindPoint.add(new Vector3(0, -parseFloat(store.behindBoardOption.thickness) / 100))
board.ApplyMatrix(MoveMatrix(spaceParse.BaseBehindPoint)); board.ApplyMatrix(MoveMatrix(spaceParse.BaseBehindPoint));
let rot = new Matrix4().extractRotation(spaceParse.OCS) let rot = new Matrix4().extractRotation(spaceParse.OCS)

@ -1,12 +1,12 @@
import { Vector3 } from 'three'; import { Vector3 } from 'three';
import { SideBoardStore, ModalState } from '../../UI/Store/BoardStore';
import { BoardType, Board } from '../../DatabaseServices/Board';
import { Command } from '../../Editor/CommandMachine';
import { app } from '../../ApplicationServices/Application'; import { app } from '../../ApplicationServices/Application';
import { MoveMatrix } from '../../Geometry/GeUtils'; import { Board, BoardType } from '../../DatabaseServices/Board';
import { Command } from '../../Editor/CommandMachine';
import { PromptStatus } from '../../Editor/PromptResult'; import { PromptStatus } from '../../Editor/PromptResult';
import { LeftRightBoardModal } from '../../UI/Components/Board/leftRightBoardModal'; import { MoveMatrix } from '../../Geometry/GeUtils';
import { BoardModalType } from '../../UI/Components/Board/BoardModal'; import { BoardModalType } from '../../UI/Components/Board/BoardModal';
import { ModalState, SideBoardStore } from '../../UI/Store/BoardStore';
export class DrawLeftRight implements Command export class DrawLeftRight implements Command
@ -22,14 +22,14 @@ export class DrawLeftRight implements Command
if (state === ModalState.Ok) if (state === ModalState.Ok)
{ {
let data = store.boardOption; let data = store.boardOption;
let lenght = data.lenght ? parseFloat(data.lenght) : 0; let lenght = data.lenght ? parseFloat(data.lenght) / 100 : 0;
let width = data.width ? parseFloat(data.width) : 0; let width = data.width ? parseFloat(data.width) / 100 : 0;
let thickness = data.thickness ? parseFloat(data.thickness) : 0; let thickness = data.thickness ? parseFloat(data.thickness) / 100 : 0;
let spacing = data.spacing ? parseFloat(data.spacing) : 0; let spacing = data.spacing ? parseFloat(data.spacing) / 100 : 0;
let leftBarod = Board.CreateBoard(lenght, width, thickness, BoardType.Vertical) let leftBarod = Board.CreateBoard(lenght, width, thickness, BoardType.Vertical)
let rightBoard = Board.CreateBoard(lenght, width, thickness, BoardType.Vertical); let rightBoard = Board.CreateBoard(lenght, width, thickness, BoardType.Vertical);
rightBoard.ApplyMatrix(MoveMatrix(new Vector3(spacing + thickness))); rightBoard.ApplyMatrix(MoveMatrix(new Vector3(spacing - thickness)));
app.m_Database.ModelSpace.Append(leftBarod); app.m_Database.ModelSpace.Append(leftBarod);
app.m_Database.ModelSpace.Append(rightBoard); app.m_Database.ModelSpace.Append(rightBoard);

@ -1,35 +1,188 @@
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { BehindBoardStore } from '../../Store/BoardStore'; import { Radio, RadioGroup } from '../../../../node_modules/@blueprintjs/core';
import { BehindBoardStore, BehindHeightPositon, BehindRelativePositon } from '../../Store/BoardStore';
import { SetBoardDataItem } from './BoardCommon';
@inject("store") @inject("store")
@observer @observer
export class BehindBoardModal extends React.Component<{ store?: BehindBoardStore }, {}> export class BehindBoardModal extends React.Component<{ store?: BehindBoardStore }, {}>
{ {
m_ScaleParameter = new Map([
["knifeRad", "刀具半径"],
["grooveAddLength", "槽加长"], ["grooveAddWidth", "槽加宽"], ["grooveAddDepth", "槽加深"]
]);
m_HeightParameter = new Map([
["height", "板件高度"], ["bottomExt", "移动"]
]);
m_PosParameter = new Map([
["spaceHeight", "单层空间"], ["count", "板件个数"], ["thickness", "背板厚度"]
]);
render() render()
{ {
let store = this.props.store; let store = this.props.store;
return ( return (
<> <div id="board">
<div className="pt-card">
<div className="flex">
<div className="process-data">
<h6></h6>
<div className="flexWrap">
{ {
Array.from(store.m_Parameter.keys()).map(k => Array.from(this.m_ScaleParameter.keys()).map(k =>
{ {
return ( return (
<div key={k}> <div key={k}>
<label htmlFor="">{store.m_Parameter.get(k)}:</label> <span> {this.m_ScaleParameter.get(k)}:</span>
<input <input
className="pt-input"
type="number" type="number"
value={store.behindBoardOption[k]} value={store.behindBoardOption[k]}
onChange={e => onChange={e =>
{ {
store.behindBoardOption[k] = e.target.value; store.behindBoardOption[k] = e.target.value;
}} }}
/> dir="auto" />
</div> </div>
) )
}) })
} }
</> </div>
</div>
<div>
<h6></h6>
<div className="boardSize center">
<label className="pt-label pt-inline">
<input
className="pt-input"
type="number"
value={store.behindBoardOption.topExt}
onChange={e =>
{
store.behindBoardOption.topExt = e.target.value;
}}
dir="auto" />
</label>
<div>
<label className="pt-label pt-inline">
<input
className="pt-input"
type="number"
value={store.behindBoardOption.leftExt}
onChange={e =>
{
store.behindBoardOption.leftExt = e.target.value;
}}
dir="auto" />
</label>
<label className="boardModel">
<span className="arrow arrowtop"></span>
<span className="line"></span>
<span className="arrow arrowbottom"></span>
</label>
<label className="pt-label pt-inline">
<input
className="pt-input"
type="number"
value={store.behindBoardOption.rightExt}
onChange={e =>
{
store.behindBoardOption.rightExt = e.target.value;
}}
dir="auto" />
</label>
</div>
<label className="pt-label pt-inline">
<input
className="pt-input"
type="number"
value={store.behindBoardOption.bottomExt}
onChange={e =>
{
store.behindBoardOption.bottomExt = e.target.value;
}}
dir="auto" />
</label>
</div>
</div>
</div>
<div>
<h6></h6>
<RadioGroup
className="boardRadio"
onChange={e =>
{
store.behindBoardOption.boardHeight = e.currentTarget.value as BehindHeightPositon;
}}
selectedValue={store.behindBoardOption.boardHeight}
>
<Radio label="全部高度" value={BehindHeightPositon.AllHeight} />
<Radio label="靠上" value={BehindHeightPositon.ForTop} />
<Radio label="靠下" value={BehindHeightPositon.ForBottom} />
</RadioGroup>
<div className="flexWrap">
{
Array.from(this.m_HeightParameter.keys()).map(k =>
{
return (
<div
key={k}>
<span>{this.m_HeightParameter.get(k)}:</span>
<input
className="pt-input"
type="number"
value={store.behindBoardOption[k]}
onChange={e =>
{
store.behindBoardOption[k] = e.target.value;
}}
dir="auto" />
</div>
)
})
}
</div>
</div>
<div>
<h6 ></h6>
<RadioGroup
className="boardRadio"
onChange={e =>
{
store.behindBoardOption.boardRelative = e.currentTarget.value as BehindRelativePositon;
}}
selectedValue={store.behindBoardOption.boardRelative}
>
<Radio label="靠前" value={BehindRelativePositon.ForFront} />
<Radio label="靠后" value={BehindRelativePositon.ForBack} />
<Radio label="等分板" value={BehindRelativePositon.Div} />
</RadioGroup>
<div className="flexWrap">
{
Array.from(this.m_PosParameter.keys()).map(k =>
{
return (
<SetBoardDataItem key={k} k={k} behindBoardOption={store.behindBoardOption} title={this.m_PosParameter.get(k)} />
)
})
}
</div>
</div>
</div>
</div>
) )
} }
} }

@ -0,0 +1,20 @@
import { inject, observer } from 'mobx-react';
import * as React from 'react';
export const SetBoardDataItem = observer(({ k, behindBoardOption, title }) =>
<div
className="pt-label">
<span>
{title}:
</span>
<input
className="pt-input"
type="number"
value={behindBoardOption[k]}
onChange={e =>
{
behindBoardOption[k] = e.target.value;
}}
/>
</div>
);

@ -1,10 +1,20 @@
import { Button, Dialog } from '@blueprintjs/core'; import { Button, Dialog } from '@blueprintjs/core';
import * as React from 'react'; import * as React from 'react';
import { BehindBoardStore, BoardStore, ModalState, SideBoardStore, TopBottomBoardStore, LayerBoardStore, VerticalBoardStore } from '../../Store/BoardStore';
import
{
BehindBoardStore,
BoardStore,
LayerBoardStore,
ModalState,
SideBoardStore,
TopBottomBoardStore,
VerticalBoardStore,
} from '../../Store/BoardStore';
import { BehindBoardModal } from './BehindBoardModal'; import { BehindBoardModal } from './BehindBoardModal';
import { LayerBoardModal } from './LayerBoardModal';
import { LeftRightBoardModal } from './leftRightBoardModal'; import { LeftRightBoardModal } from './leftRightBoardModal';
import { TopBottomBoardModal } from './TopBottomBoardModal'; import { TopBottomBoardModal } from './TopBottomBoardModal';
import { LayerBoardModal } from './LayerBoardModal';
import { VerticalBoardModal } from './VerticalBoardModal'; import { VerticalBoardModal } from './VerticalBoardModal';
export enum BoardModalType export enum BoardModalType
@ -87,3 +97,70 @@ export class BoardModal extends React.Component<BoardModalProps, {}> {
} }
} }
export class BoardModal1 extends React.Component<BoardModalProps, {}> {
private m_ModalMap: Map<string, any>;
constructor(props)
{
super(props);
let store = this.props.store;
this.m_ModalMap = new Map([
[BoardModalType.LR, <LeftRightBoardModal store={store as SideBoardStore} />],
[BoardModalType.TB, <TopBottomBoardModal store={store as TopBottomBoardStore} />],
[BoardModalType.Be, <BehindBoardModal store={store as BehindBoardStore} />],
[BoardModalType.Ly, <LayerBoardModal store={store as LayerBoardStore} />],
[BoardModalType.Ve, <VerticalBoardModal store={store as VerticalBoardStore} />],
])
}
render()
{
let store = this.props.store;
return (
<div className="pt-dialog-container" onKeyDown={(e) => e.stopPropagation()} >
<div className="pt-dialog">
<div
className="pt-dialog-header"
id="dragArea"
>
<span className="pt-icon-large pt-icon-lightbulb"></span>
<h5 className="pt-dialog-header-title">store.title</h5>
<button
aria-label="Close" className="pt-dialog-close-button pt-icon-small-cross"
onClick={() => store.OnOk(ModalState.Cancel)}
></button>
</div>
<div
className="pt-dialog-body"
onKeyDown={e =>
{
e.stopPropagation();
}
}>
{
this.m_ModalMap.get(this.props.type)
}
</div>
<div className="pt-dialog-footer">
<div className="pt-dialog-footer-actions">
<Button
className="LeftRightBtn"
text="确定"
onClick={() =>
{
store.OnOk(ModalState.Ok);
}} />
<Button className="LeftRightBtn" text="取消" onClick={() =>
{
store.OnOk(ModalState.Cancel);
}} />
</div>
</div>
</div>
</div>
);
}
}

@ -27,7 +27,7 @@ export class LayerBoardModal extends React.Component<{ store?: LayerBoardStore }
type="number" type="number"
value={store.layerBoardOption[k]} value={store.layerBoardOption[k]}
disabled={(k === "width" && store.layerBoardOption.isTotalWidth) disabled={(k === "width" && store.layerBoardOption.isTotalWidth)
|| (k === "dist" && store.layerBoardOption.posType == LayerPosType.Mid) || (k === "dist" && store.layerBoardOption.posType == LayerPosType.Div)
} }
onChange={e => onChange={e =>
{ {
@ -57,7 +57,7 @@ export class LayerBoardModal extends React.Component<{ store?: LayerBoardStore }
> >
<Radio label="距顶层版" value={LayerPosType.Top} /> <Radio label="距顶层版" value={LayerPosType.Top} />
<Radio label="距底层板" value={LayerPosType.Bottom} /> <Radio label="距底层板" value={LayerPosType.Bottom} />
<Radio label="等分层板" value={LayerPosType.Mid} /> <Radio label="等分层板" value={LayerPosType.Div} />
</RadioGroup> </RadioGroup>
</div> </div>
</div> </div>

@ -27,7 +27,7 @@ export class VerticalBoardModal extends React.Component<{ store?: VerticalBoardS
type="number" type="number"
value={store.verticalBoardOption[k]} value={store.verticalBoardOption[k]}
disabled={(k === "width" && store.verticalBoardOption.isTotalWidth) disabled={(k === "width" && store.verticalBoardOption.isTotalWidth)
|| (k === "dist" && store.verticalBoardOption.posType == VerticalPosType.Mid) || (k === "dist" && store.verticalBoardOption.posType == VerticalPosType.Div)
} }
onChange={e => onChange={e =>
{ {
@ -54,9 +54,9 @@ export class VerticalBoardModal extends React.Component<{ store?: VerticalBoardS
}} }}
selectedValue={store.verticalBoardOption.posType} selectedValue={store.verticalBoardOption.posType}
> >
<Radio label="距左立版" value={LayerPosType.Top} /> <Radio label="距左立版" value={VerticalPosType.Left} />
<Radio label="距右立板" value={LayerPosType.Bottom} /> <Radio label="距右立板" value={VerticalPosType.Right} />
<Radio label="等分立板" value={LayerPosType.Mid} /> <Radio label="等分立板" value={VerticalPosType.Div} />
</RadioGroup> </RadioGroup>
</div> </div>
</div> </div>

@ -1,35 +1,29 @@
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { SideBoardStore } from '../../Store/BoardStore'; import { SideBoardStore } from '../../Store/BoardStore';
@inject("store") export const LeftRightBoardModal =
@observer inject("store")
export class LeftRightBoardModal extends React.Component<{ store?: SideBoardStore }, {}> (observer((props: { store?: SideBoardStore }) => (
{ <div>
render()
{
let store = this.props.store;
return (
<>
{ {
Array.from(store.m_Parameter.keys()).map(k => Array.from(props.store.m_Parameter.keys()).map(k =>
{ {
return ( return (
<div key={k}> <div key={k}>
<label htmlFor="">{store.m_Parameter.get(k)}:</label> <label htmlFor="">{props.store.m_Parameter.get(k)}:</label>
<input <input
type="number" type="number"
value={store.boardOption[k]} value={props.store.boardOption[k]}
onChange={e => onChange={e =>
{ {
store.boardOption[k] = e.target.value; props.store.boardOption[k] = e.target.value;
}} }}
/> />
</div> </div>
) )
}) })
} }
</> </div>
) )))
}
}

@ -395,7 +395,55 @@ input[type=radio] {
height: 50px !important; height: 50px !important;
} }
} }
/**************板件模态框样式*************/
.boardRadio{
display: flex;
justify-content: flex-start;
}
.boardRadio>label{
margin-right: 10px;
}
#board .flexWrap>div{
width: 50%;
line-height: 15px;
}
#board .flexWrap>div{
width: 50%;
line-height: 30px;
}
#board .flexWrap>div>.pt-input{
padding:0 0 0 5px;
width: 60px;
}
#board .boardModel{
display: inline-block;
width: 35px;
height: 50px;
border: 1px solid #000;
vertical-align: middle;
margin: 10px;
}
#board .boardSize .pt-label{
display: inline-block;
margin: 0 5px;
}
#board .boardSize .pt-inline{
line-height: 15px;
}
#board .flex>div:first-child{
width: 40%;
}
#board .flex>div:last-child{
width: 60%;
}
#board .boardSize .pt-label>.pt-input{
display: block;
padding: 0;
width: 50px;
padding-left: 5px;
line-height: 15px;
}
/**********自定义通用样式*****************/ /**********自定义通用样式*****************/
@ -417,6 +465,11 @@ div {
.flex { .flex {
display: flex; display: flex;
justify-content: space-between;
}
.flexWrap{
display: flex;
flex-wrap: wrap
} }
.ul-unstyle { .ul-unstyle {
@ -441,3 +494,30 @@ img {
.button-marign { .button-marign {
margin-right: 10px; margin-right: 10px;
} }
.center{
text-align: center;
}
.widthHalf{
width: 50%;
}
.arrow{
display: block;
border: 10px solid transparent;
width: 0;
height: 0px;
margin: 0 auto;
}
.arrowtop{
border-bottom: 10px solid #000;
margin-top: -3px;
}
.arrowbottom{
border-top: 10px solid #000;
}
.line{
display: block;
border: 2px solid #000;
width: 0;
height: 16px;
margin: 0 auto;
}

@ -57,12 +57,12 @@ export class SideBoardStore extends BoardStore
{ {
//板数据 //板数据
@observable boardOption: SideBoardOption = { @observable boardOption: SideBoardOption = {
lenght: "12", lenght: "1200",
width: "6", width: "600",
thickness: "0.18", thickness: "18",
spacing: "8" spacing: "836"
}; };
m_Parameter = new Map([["lenght", "柜长"], ["width", "柜宽"], ["thickness", "板厚"], ["spacing", "间距"]]); m_Parameter = new Map([["lenght", "柜长"], ["width", "柜宽"], ["thickness", "板厚"], ["spacing", "总宽"]]);
title = "左右侧板"; title = "左右侧板";
private static _store: SideBoardStore; private static _store: SideBoardStore;
static Store() static Store()
@ -108,6 +108,19 @@ export class TopBottomBoardStore extends BoardStore
} }
} }
export enum BehindHeightPositon
{
ForTop = "top",
ForBottom = "bottom",
AllHeight = "all"
}
export enum BehindRelativePositon
{
ForFront = "front",
ForBack = "back",
Div = "div"
}
export class BehindBoardStore extends BoardStore export class BehindBoardStore extends BoardStore
{ {
title = "背板"; title = "背板";
@ -117,7 +130,17 @@ export class BehindBoardStore extends BoardStore
rightExt: "0", rightExt: "0",
topExt: "0", topExt: "0",
bottomExt: "0", bottomExt: "0",
thickness: "0.18", thickness: "18",
knifeRad: "3",
grooveAddLength: "0",
grooveAddWidth: "0",
grooveAddDepth: "0",
boardHeight: BehindHeightPositon.AllHeight,
height: "0",
isTotalHeight: true,
boardRelative: BehindRelativePositon.Div,
spaceHeight: "0",
count: "1"
}; };
m_Parameter = new Map([ m_Parameter = new Map([
["leftExt", "左延伸"], ["rightExt", "右延伸"], ["topExt", "顶延伸"], ["leftExt", "左延伸"], ["rightExt", "右延伸"], ["topExt", "顶延伸"],
@ -133,7 +156,7 @@ export class BehindBoardStore extends BoardStore
export enum LayerPosType export enum LayerPosType
{ {
Mid = "mid", Div = "div",
Top = "top", Top = "top",
Bottom = "bottom" Bottom = "bottom"
} }
@ -156,7 +179,7 @@ export class LayerBoardStore extends BoardStore
frontShrink: "0", frontShrink: "0",
width: "0.6", width: "0.6",
isTotalWidth: true, isTotalWidth: true,
posType: LayerPosType.Mid, posType: LayerPosType.Div,
thickness: "0.18", thickness: "0.18",
count: "1", count: "1",
dist: "100" dist: "100"
@ -177,7 +200,7 @@ export enum VerticalPosType
{ {
Left = "left", Left = "left",
Right = "right", Right = "right",
Mid = "mid" Div = "mid"
} }
export class VerticalBoardStore extends BoardStore export class VerticalBoardStore extends BoardStore
@ -187,7 +210,7 @@ export class VerticalBoardStore extends BoardStore
frontShrink: "0", frontShrink: "0",
width: "0.6", width: "0.6",
isTotalWidth: true, isTotalWidth: true,
posType: VerticalPosType.Mid, posType: VerticalPosType.Div,
thickness: "0.18", thickness: "0.18",
count: "1", count: "1",
dist: "100" dist: "100"

Loading…
Cancel
Save