1787 新增:UCS网格配置

pull/1793/MERGE
ChenX 3 years ago
parent 3c57e025a9
commit 31e96b1c7b

@ -1,5 +1,7 @@
import { Group } from 'three';
import { Color, Group } from 'three';
import { ColorMaterial } from '../../Common/ColorPalette';
import { DisposeThreeObj } from '../../Common/Dispose';
import { IUCSGridConfig } from '../UserConfig';
import { Axes } from './Axes';
import GridHelper2 from './GridHelper2';
import { IGizmo } from './IGizmo';
@ -47,14 +49,29 @@ export class CoorAxes extends Group implements IGizmo
}
//添加网格助手
InitGripHelper()
private _gridHelper: GridHelper2;
//设置网格
SettingGripHelper(ucsGridConfig: IUCSGridConfig)
{
const gridHelper = new GridHelper2(2, 3, ColorMaterial.GetColor(9), ColorMaterial.GetColor(8));
gridHelper.position.set(0, 0, 0);
gridHelper.rotateX(Math.PI / -2);
gridHelper.updateMatrix();
this.add(gridHelper);
if (this._gridHelper)
{
this.remove(this._gridHelper);
DisposeThreeObj(this._gridHelper);
}
this._gridHelper = undefined;
if (!ucsGridConfig.isShowUCSGrid) return;
this._gridHelper = new GridHelper2(
ucsGridConfig.size,
ucsGridConfig.divisions,
new Color(ucsGridConfig.color1),
new Color(ucsGridConfig.color2),
);
this._gridHelper.position.set(0, 0, 0);
this._gridHelper.rotateX(Math.PI / -2);
this._gridHelper.updateMatrix();
this.add(this._gridHelper);
}
set AxtiveIndex(t) { };

@ -3,6 +3,7 @@ import { begin } from 'xaop';
import { Viewer } from '../GraphicsSystem/Viewer';
import { Editor } from './Editor';
import { CoorAxes } from './TranstrolControl/CoorAxes';
import { IUCSGridConfig } from './UserConfig';
export enum UCSPsotion
{
@ -21,8 +22,6 @@ export class UCSServices
let view = this._Editor.App.Viewer;
let preView = view.PreViewer;
//在前视图绘制ucs轴.
// this._UcsObj.InitGripHelper();
this._UcsObj.scale.set(50, 50, 50);
preView.Scene.add(this._UcsObj);
@ -60,6 +59,12 @@ export class UCSServices
this._UCSMatrix.copy(m);
this.Update();
}
SettingGripHelper(UCSGridConfig: IUCSGridConfig)
{
this._UcsObj.SettingGripHelper(UCSGridConfig);
}
}

@ -31,9 +31,18 @@ export interface ICursorConfig extends IBaseOption
SquareSize: number;
}
export interface IUCSGridConfig extends IBaseOption
{
isShowUCSGrid: boolean,
size: number,
divisions: number,
color1: string,
color2: string,
}
export class UserConfig implements IConfigStore
{
private readonly _version = 25;
private readonly _version = 26; //🌟🌟每次更新必须向上添加一次版本号🌟🌟
_renderType: RenderType = RenderType.Wireframe;
@observable maxSize: IMaxSizeProps = {
isShow: false,
@ -126,6 +135,15 @@ export class UserConfig implements IConfigStore
@observable openLightConfig: boolean = false; //画灯光前是否打开配置
@observable oneKeyOpenLight: boolean = false; //一键开关灯光(通电/不通电)
@observable isShowLightShadow = false; //一键开关灯光阴影(除了太阳光)
@observable UCSGridConfig: IUCSGridConfig = {//UCS网格配置
isShowUCSGrid: false,
size: 2,
divisions: 3,
color1: '#C0C0C0',
color2: '#808080',
};
@observable isOpenAxisSwitch: boolean = true;
@observable isOpenCameraSetting: boolean = true;
constructor()
{
@ -199,6 +217,15 @@ export class UserConfig implements IConfigStore
this.isModifyMaterial = false;
this.isHighlightMaterial = true;
this.isShowSkyBox = false;
Object.assign(this.UCSGridConfig, {
isShowUCSGrid: true,
size: 2,
divisions: 3,
color1: '#c0c0c0',
color2: '#808080',
});
this.isOpenAxisSwitch = true;
this.isOpenCameraSetting = true;
}
SaveConfig()
{
@ -238,6 +265,9 @@ export class UserConfig implements IConfigStore
isHighlightMaterial: this.isHighlightMaterial,
isShowSkyBox: this.isShowSkyBox,
openLightConfig: this.openLightConfig,
UCSGridConfig: toJS(this.UCSGridConfig),
isOpenAxisSwitch: this.isOpenAxisSwitch,
isOpenCameraSetting: this.isOpenCameraSetting,
}
};
}
@ -351,6 +381,12 @@ export class UserConfig implements IConfigStore
{
this.isHighlightMaterial = config.option.isHighlightMaterial;
}
if (config.option.version > 25)
{
Object.assign(this.UCSGridConfig, config.option.UCSGridConfig);
this.isOpenAxisSwitch = config.option.isOpenAxisSwitch;
this.isOpenCameraSetting = config.option.isOpenCameraSetting;
}
}
}

@ -3,6 +3,7 @@ import { observer } from 'mobx-react';
import React, { Component } from 'react';
import { app } from '../../../ApplicationServices/Application';
import { SpaceCSType, TransMode } from '../../../Editor/TranstrolControl/TransformServices';
import { userConfig } from '../../../Editor/UserConfig';
import './AxisMode.less';
import AxisModeStore from './AxisModeStore';
export const spanColor = "#1890ff";
@ -25,7 +26,7 @@ export default class AxisMode extends Component
render()
{
return (
<div className='AxisModeWrapper'>
<div className='AxisModeWrapper' style={{ display: userConfig.isOpenAxisSwitch ? "flex" : 'none' }}>
<div className='SwitchAxisMode'>
<Popover content={
<div className='AxisModeToolTip'>

@ -2,6 +2,7 @@ import { Button, FocusStyleManager, Icon, IconName, Tooltip } from '@blueprintjs
import { observer } from 'mobx-react';
import React, { Component } from 'react';
import { app } from '../../../../ApplicationServices/Application';
import { userConfig } from '../../../../Editor/UserConfig';
import { GetBox } from '../../../../Geometry/GeUtils';
import { CameraType } from '../../../../GraphicsSystem/CameraUpdate';
import ModifyModelStore from '../../ToolBar/ModifyModel/ModifyModelStore';
@ -40,7 +41,7 @@ export default class CameraState extends Component
render()
{
return (
<div className='CameraState'>
<div className='CameraState' style={{ display: userConfig.isOpenCameraSetting ? "flex" : "none" }}>
<CameraSnapshootPanel />
<CameraSetting />
<Tooltip content='重置视图' minimal>

@ -129,8 +129,11 @@ export class ConfigStore extends Singleton
for (let b of app.Database.ModelSpace.Entitys)
if (b instanceof Board)
b.Update(UpdateDraw.Geometry);
app.Editor.UcsServices.SettingGripHelper(userConfig.UCSGridConfig);
app.Viewer.UpdateRender();
await userConfigStore.SaveConfig(BoardModalType.UserConfig, userConfig);
};
}

@ -0,0 +1,19 @@
.USCConfigPanel
{
label
{
width: fit-content;
}
label:nth-child(3), label:nth-child(4)
{
.bp3-popover-target
{
position: absolute;
}
.bp3-input-group
{
width : max-content;
margin-left: 2.5px;
}
}
}

@ -1,5 +1,5 @@
import React = require("react");
import { Card, Checkbox, Classes, HTMLSelect, Intent, Label, Slider, Tooltip } from "@blueprintjs/core";
import { Card, Checkbox, Classes, HTMLSelect, InputGroup, Intent, Label, Popover, PopoverPosition, Slider, Tooltip } from "@blueprintjs/core";
import { observable } from "mobx";
import { observer } from "mobx-react";
import { ColorResult, SketchPicker } from "react-color";
@ -11,6 +11,7 @@ import { AAType, ViewDirType } from "../../../../Common/SystemEnum";
import { FixedNotZero } from "../../../../Common/Utils";
import { userConfig } from "../../../../Editor/UserConfig";
import { ConfigStore } from "./ConfigDialog";
import './ConfigPanelStyle.less';
const popover: React.CSSProperties = {
@ -284,6 +285,86 @@ export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }>
vertical={false}
/>
</div>
<div style={{ marginTop: "10px" }}>
<Checkbox style={{ color: 'rgb(96, 110, 122)' }} inline label="开启切换轴线"
checked={userConfig.isOpenAxisSwitch} onChange={(e) =>
{
userConfig.isOpenAxisSwitch = !userConfig.isOpenAxisSwitch;
}} />
<br />
<Checkbox style={{ color: 'rgb(96, 110, 122)' }} inline label="开启相机设置"
checked={userConfig.isOpenCameraSetting} onChange={async (e) =>
{
userConfig.isOpenCameraSetting = !userConfig.isOpenCameraSetting;
}} />
</div>
<div>
<Checkbox style={{ color: 'rgb(96, 110, 122)' }} inline label="开启UCS网格" checked={userConfig.UCSGridConfig.isShowUCSGrid} onChange={async (e) =>
{
userConfig.UCSGridConfig.isShowUCSGrid = !userConfig.UCSGridConfig.isShowUCSGrid;
app.Editor.UcsServices.SettingGripHelper(userConfig.UCSGridConfig);
}} />
<div className="USCConfigPanel" style={{ display: userConfig.UCSGridConfig.isShowUCSGrid ? 'block' : 'none' }}>
<Label style={{ color: "#606E7A" }} className={Classes.INLINE} >
:
<InputGroup defaultValue={userConfig.UCSGridConfig.size.toString()}
onBlur={(e) =>
{
if (Number.isNaN(Number(e.target.value))) return;
userConfig.UCSGridConfig.size = Number(e.target.value);
}} />
</Label>
<Label style={{ color: "#606E7A" }} className={Classes.INLINE} >
:
<InputGroup defaultValue={userConfig.UCSGridConfig.divisions.toString()}
onBlur={(e) =>
{
if (Number.isNaN(Number(e.target.value))) return;
userConfig.UCSGridConfig.divisions = Number(e.target.value);
}} />
</Label>
<Label style={{ color: "#606E7A" }} className={Classes.INLINE} >
线:
<Popover
position={PopoverPosition.BOTTOM}
minimal
className="bp3-input-group"
content={
<SketchPicker
color={userConfig.UCSGridConfig.color1}
onChange={async (e: ColorResult) =>
{
userConfig.UCSGridConfig.color1 = e.hex;
}}
/>
}>
<InputGroup
defaultValue={userConfig.UCSGridConfig.color1}
/>
</Popover>
</Label>
<Label style={{ color: "#606E7A" }} className={Classes.INLINE} >
线:
<Popover
position={PopoverPosition.BOTTOM}
minimal
className="bp3-input-group"
content={
<SketchPicker
color={userConfig.UCSGridConfig.color2}
onChange={async (e: ColorResult) =>
{
userConfig.UCSGridConfig.color2 = e.hex;
}}
/>
}>
<InputGroup
defaultValue={userConfig.UCSGridConfig.color2}
/>
</Popover>
</Label>
</div>
</div>
</div>
</Card >
);

@ -137,12 +137,20 @@ export class UserConfigStore extends Singleton
app.Viewer.Renderer.setClearColor(userConfig.SystemConfig.background);
Light.DefaultOpenLight = userConfig.oneKeyOpenLight;
//天空盒
app.PerCameraUseSkyBox = userConfig.isShowSkyBox;
app.MoveTool.Disable = !userConfig.dimensions;
//在前视图绘制ucs轴
app.Editor.UcsServices.SettingGripHelper(userConfig.UCSGridConfig);
}
else
{
await this.SaveConfig(BoardModalType.UserConfig, userConfig, { isInit: true });
}
}
//bbs
async InitBBSTabIndex()
{
let config = await this.GetConfig(BBSEditor.name as BoardModalType) as IConfigOption<number[]>;
@ -543,8 +551,6 @@ export class UserConfigStore extends Singleton
}
});
}
app.PerCameraUseSkyBox = userConfig.isShowSkyBox;
app.MoveTool.Disable = !userConfig.dimensions;
}
ClearUserData()
{

Loading…
Cancel
Save