!1948 功能:更改线框颜色配置

pull/1955/MERGE
黄诗津 2 years ago committed by ChenX
parent 09af081368
commit 9ce44cf743

@ -97,7 +97,7 @@ export class Command_PackageMove implements Command
let b = g.box; let b = g.box;
mmtz.setPosition(b.min.clone().negate().add(movex)); mmtz.setPosition(b.min.clone().negate().add(movex));
movex.setComponent(i1, movex.getComponent(i1) + b.getSize(size).getComponent(i1) + Number(userConfig.cabinetSpacing)); movex.setComponent(i1, movex.getComponent(i1) + b.getSize(size).getComponent(i1) + userConfig.cabinetSpacing);
for (let e of g.ens) for (let e of g.ens)
e.ApplyMatrix(mmtz); e.ApplyMatrix(mmtz);

@ -10,8 +10,8 @@ export class IHostApplicationServices
@ProxyValue isShowLightShadow: boolean = true;//灯光阴影 (除太阳光外) @ProxyValue isShowLightShadow: boolean = true;//灯光阴影 (除太阳光外)
ShowHistoryLog: boolean = true; ShowHistoryLog: boolean = true;
Physical2EdgeColor = 7;//真实视图带线框的线框颜色 默认白色 @ProxyValue Physical2EdgeColor = 7;//真实视图带线框的线框颜色 默认白色
ConceptualEdgeColor = 7;//概念线框的颜色 @ProxyValue ConceptualEdgeColor = 7;//概念线框的颜色
DrawWallBottomFace = false;//绘制底面 DrawWallBottomFace = false;//绘制底面

@ -1,5 +1,6 @@
import { Color, DoubleSide, FrontSide, LineBasicMaterial, LineDashedMaterial, MeshBasicMaterial, ShaderMaterial, Side, Vector2, Vector3 } from 'three'; import { Color, DoubleSide, FrontSide, LineBasicMaterial, LineDashedMaterial, MeshBasicMaterial, ShaderMaterial, Side, Vector2, Vector3 } from 'three';
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial'; import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial';
import { HostApplicationServices } from '../ApplicationServices/HostApplicationServices';
import { GetGoodShaderSimple } from '../GLSL/GoochShader'; import { GetGoodShaderSimple } from '../GLSL/GoochShader';
const ColorPalette = [ const ColorPalette = [
@ -399,6 +400,33 @@ export class ColorMaterial
return new Color(); return new Color();
} }
private static _ConceptualEdgeMaterial: LineBasicMaterial;
static GetConceptualEdgeMaterial()
{
if (!this._ConceptualEdgeMaterial)
this._ConceptualEdgeMaterial = new LineBasicMaterial({ color: this.GetColor(HostApplicationServices.ConceptualEdgeColor).clone(), side: DoubleSide });
return this._ConceptualEdgeMaterial;
}
static UpdateConceptualEdgeMaterial()
{
if (this._ConceptualEdgeMaterial)
this._ConceptualEdgeMaterial.color.copy(this.GetColor(HostApplicationServices.ConceptualEdgeColor));
}
private static _Physical2EdgeMaterial: LineBasicMaterial;
static GetPhysical2EdgeMaterial()
{
if (!this._Physical2EdgeMaterial)
this._Physical2EdgeMaterial = new LineBasicMaterial({ color: this.GetColor(HostApplicationServices.Physical2EdgeColor).clone(), side: DoubleSide });
return this._Physical2EdgeMaterial;
}
static UpdatePhysical2EdgeMaterial()
{
if (this._Physical2EdgeMaterial)
this._Physical2EdgeMaterial.color.copy(this.GetColor(HostApplicationServices.Physical2EdgeColor));
}
//橡皮筋材质: 黄色 点划线 //橡皮筋材质: 黄色 点划线
static RubberBandMaterial = new LineDashedMaterial({ static RubberBandMaterial = new LineDashedMaterial({
color: 0xF0B41E, color: 0xF0B41E,

@ -188,7 +188,7 @@ export class SweepSolid extends Entity
{ {
return new Object3D().add( return new Object3D().add(
new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)), new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)),
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(7)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetConceptualEdgeMaterial())
); );
} }
else if (renderType === RenderType.Physical) else if (renderType === RenderType.Physical)
@ -209,7 +209,7 @@ export class SweepSolid extends Entity
{ {
return new Object3D().add( return new Object3D().add(
new Mesh(this.MeshGeometry, this.MeshMaterial), new Mesh(this.MeshGeometry, this.MeshMaterial),
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(7)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetPhysical2EdgeMaterial())
); );
} }
} }
@ -234,7 +234,7 @@ export class SweepSolid extends Entity
Object3DRemoveAll(obj); Object3DRemoveAll(obj);
return obj.add( return obj.add(
new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)), new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)),
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(7)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetConceptualEdgeMaterial())
); );
} }
else if (renderType === RenderType.Physical) else if (renderType === RenderType.Physical)
@ -253,7 +253,7 @@ export class SweepSolid extends Entity
Object3DRemoveAll(obj); Object3DRemoveAll(obj);
return obj.add( return obj.add(
new Mesh(this.MeshGeometry, this.MeshMaterial), new Mesh(this.MeshGeometry, this.MeshMaterial),
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(7)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetPhysical2EdgeMaterial())
); );
} }
} }

@ -3,7 +3,6 @@ import Flatbush from 'flatbush';
import { Box3, BoxGeometry, BufferGeometry, ExtrudeGeometry, ExtrudeGeometryOptions, Float32BufferAttribute, Geometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, Line as TLine, LineSegments, Matrix3, Matrix4, Mesh, Object3D, UVGenerator, Vector3 } from "three"; import { Box3, BoxGeometry, BufferGeometry, ExtrudeGeometry, ExtrudeGeometryOptions, Float32BufferAttribute, Geometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, Line as TLine, LineSegments, Matrix3, Matrix4, Mesh, Object3D, UVGenerator, Vector3 } from "three";
import { Line2 } from "three/examples/jsm/lines/Line2"; import { Line2 } from "three/examples/jsm/lines/Line2";
import { LineGeometry } from "three/examples/jsm/lines/LineGeometry"; import { LineGeometry } from "three/examples/jsm/lines/LineGeometry";
import { HostApplicationServices } from '../../ApplicationServices/HostApplicationServices';
import { arrayClone, arrayLast, arrayPushArray, arrayRemoveIf, arrayRemoveOnce, arraySortByNumber, arraySum } from "../../Common/ArrayExt"; import { arrayClone, arrayLast, arrayPushArray, arrayRemoveIf, arrayRemoveOnce, arraySortByNumber, arraySum } from "../../Common/ArrayExt";
import { ColorMaterial } from "../../Common/ColorPalette"; import { ColorMaterial } from "../../Common/ColorPalette";
import { CSGIntersect } from '../../Common/CSGIntersect'; import { CSGIntersect } from '../../Common/CSGIntersect';
@ -1621,7 +1620,7 @@ export class ExtrudeSolid extends Entity
{ {
return new Object3D().add( return new Object3D().add(
new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)), new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)),
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(HostApplicationServices.ConceptualEdgeColor)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetConceptualEdgeMaterial())
); );
} }
else if (renderType === RenderType.Physical) else if (renderType === RenderType.Physical)
@ -1658,7 +1657,7 @@ export class ExtrudeSolid extends Entity
return new Object3D().add( return new Object3D().add(
mesh, mesh,
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(HostApplicationServices.Physical2EdgeColor)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetPhysical2EdgeMaterial())
); );
} }
} }
@ -2012,7 +2011,7 @@ export class ExtrudeSolid extends Entity
{ {
return obj.add( return obj.add(
new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)), new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.ColorIndex)),
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(HostApplicationServices.ConceptualEdgeColor)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetConceptualEdgeMaterial())
); );
} }
else if (renderType === RenderType.Physical) else if (renderType === RenderType.Physical)
@ -2044,7 +2043,7 @@ export class ExtrudeSolid extends Entity
return obj.add( return obj.add(
mesh, mesh,
new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(HostApplicationServices.Physical2EdgeColor)) new LineSegments(this.EdgeGeometry, ColorMaterial.GetPhysical2EdgeMaterial())
); );
} }
} }

@ -36,7 +36,7 @@ export interface IUCSGridConfig extends IBaseOption
export class UserConfig implements IConfigStore export class UserConfig implements IConfigStore
{ {
private readonly _version = 28; //🌟🌟每次更新必须向上添加一次版本号🌟🌟 private readonly _version = 29; //🌟🌟每次更新必须向上添加一次版本号🌟🌟
_renderType: RenderType = RenderType.Wireframe; _renderType: RenderType = RenderType.Wireframe;
@observable maxSize: IMaxSizeProps = { @observable maxSize: IMaxSizeProps = {
isShow: false, isShow: false,
@ -83,6 +83,8 @@ export class UserConfig implements IConfigStore
@observable isModifyMaterial: boolean = true;//右侧工具栏应用时覆盖新的材质 @observable isModifyMaterial: boolean = true;//右侧工具栏应用时覆盖新的材质
@observable isHighlightMaterial: boolean = true;//亮显材质球 @observable isHighlightMaterial: boolean = true;//亮显材质球
@observable cabinetSpacing: number = 1000; //柜子移动到0点配置 柜子间距 @observable cabinetSpacing: number = 1000; //柜子移动到0点配置 柜子间距
@observable ConceptualEdgeColor = 7;//概念线框的颜色
@observable Physical2EdgeColor = 7;//真实视图带线框的线框颜色 默认白色
@observable autoSaveConfig = { @observable autoSaveConfig = {
enable: true, enable: true,
time: 1, time: 1,
@ -213,6 +215,8 @@ export class UserConfig implements IConfigStore
this.isModifyMaterial = false; this.isModifyMaterial = false;
this.isHighlightMaterial = true; this.isHighlightMaterial = true;
this.cabinetSpacing = 1000; this.cabinetSpacing = 1000;
this.ConceptualEdgeColor = 7;
this.Physical2EdgeColor = 7;
this.isShowSkyBox = false; this.isShowSkyBox = false;
Object.assign(this.UCSGridConfig, { Object.assign(this.UCSGridConfig, {
isShowUCSGrid: true, isShowUCSGrid: true,
@ -262,6 +266,8 @@ export class UserConfig implements IConfigStore
isModifyMaterial: this.isModifyMaterial, isModifyMaterial: this.isModifyMaterial,
isHighlightMaterial: this.isHighlightMaterial, isHighlightMaterial: this.isHighlightMaterial,
cabinetSpacing: this.cabinetSpacing, cabinetSpacing: this.cabinetSpacing,
ConceptualEdgeColor: this.ConceptualEdgeColor,
Physical2EdgeColor: this.Physical2EdgeColor,
isShowSkyBox: this.isShowSkyBox, isShowSkyBox: this.isShowSkyBox,
openLightConfig: this.openLightConfig, openLightConfig: this.openLightConfig,
UCSGridConfig: toJS(this.UCSGridConfig), UCSGridConfig: toJS(this.UCSGridConfig),
@ -395,6 +401,11 @@ export class UserConfig implements IConfigStore
{ {
this.cabinetSpacing = config.option.cabinetSpacing; this.cabinetSpacing = config.option.cabinetSpacing;
} }
if (config.option.version > 28)
{
this.ConceptualEdgeColor = config.option.ConceptualEdgeColor;
this.Physical2EdgeColor = config.option.Physical2EdgeColor;
}
} }
} }

@ -0,0 +1,130 @@
import { Classes, Icon, Label } from '@blueprintjs/core';
import { observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { ColorMaterial } from '../../../../Common/ColorPalette';
import { userConfig } from '../../../../Editor/UserConfig';
import { ColorList } from './DisplayConfigPanel';
interface IColorList
{
text: string;
type: "ConceptualEdgeColor" | "Physical2EdgeColor";
handleClick: (e: React.MouseEvent<HTMLUListElement>, type: string) => void;
}
@observer
export class ConfigColorList extends React.Component<IColorList>
{
@observable isShow = false;
liEl = React.createRef<HTMLLIElement>();
divEl = React.createRef<HTMLDivElement>();
constructor(props)
{
super(props);
this.registerEvent();
}
private registerEvent()
{
document.body.addEventListener('mousedown', this.CloseColorList);
document.body.addEventListener('wheel', this.CloseColorList);
}
private CloseColorList = (e: MouseEvent) =>
{
//在任何地方点到鼠标,都将取消下拉菜单
let el = e.target as HTMLElement;
for (let i = 0; i < 4; i++)
{
if (el?.className === this.liEl.current.className)
return;
else
el = el.parentElement;
if (el === null)
break;
}
if (this.isShow)
{
this.isShow = false;
e.stopPropagation();
}
};
componentWillUnmount()
{
document.body.removeEventListener('mousedown', this.CloseColorList);
document.body.removeEventListener('wheel', this.CloseColorList);
}
getCalcStyles = () =>
{
let el = this.divEl.current as HTMLElement;
if (!el) return;
let scrolltop: number = 0;
while (true)
{
if (el.className.includes("bp3-card"))
{
scrolltop = el.scrollTop;
break;
}
else
el = el.parentElement;
if (el === null)
break;
}
this.divEl.current.style.cssText = `
position: absolute;
top: ${this.divEl.current.parentElement.offsetTop - scrolltop}px;
`;
};
render()
{
let type = this.props.type;
return (
<Label className={Classes.INLINE} style={{ display: "flex" }}>
<span style={{ width: 95 }}>{this.props.text}</span>
<ul className={`${Classes.LIST_UNSTYLED}`} id="color-list">
<li
onClick={(e) =>
{
this.isShow = !this.isShow;
if (this.isShow)
this.getCalcStyles();
e.stopPropagation();
}}
ref={this.liEl}
className={type}
>
<div>
<Icon icon={"symbol-square"} color={"#" + ColorMaterial.GetColor(userConfig[type]).getHexString()} />
{ColorList[userConfig[type]][0]}
</div>
<Icon icon="caret-down" />
</li>
<li>
<div ref={this.divEl}>
<ul
className={`${Classes.LIST_UNSTYLED} ${Classes.POPOVER}`}
onMouseDown={e => this.props.handleClick(e, type)}
style={{ display: this.isShow ? "block" : "none" }}
>
{ColorList.map(([txt, color]) =>
{
return (
<li key={color} value={color}>
<Icon icon={"symbol-square"} color={"#" + ColorMaterial.GetColor(color).getHexString()} />
{txt}
</li>
);
})}
</ul>
</div>
</li>
</ul>
</Label>
);
}
}

@ -41,6 +41,8 @@ export class ConfigStore extends Singleton
{ {
oldBgcolor: string; oldBgcolor: string;
oldLyBg: string; oldLyBg: string;
oldConceptualEdgeColor: number = userConfig.ConceptualEdgeColor;
oldPhysical2EdgeColor: number = userConfig.Physical2EdgeColor;
oldViewSize = { oldViewSize = {
minViewHeight: userConfig.viewSize.minViewHeight, minViewHeight: userConfig.viewSize.minViewHeight,
maxViewHeight: userConfig.viewSize.maxViewHeight, maxViewHeight: userConfig.viewSize.maxViewHeight,
@ -62,6 +64,9 @@ export class ConfigStore extends Singleton
userConfig.SystemConfig.background = this.oldBgcolor; userConfig.SystemConfig.background = this.oldBgcolor;
} }
userConfig.ConceptualEdgeColor = this.oldConceptualEdgeColor;
userConfig.Physical2EdgeColor = this.oldPhysical2EdgeColor;
//视图范围和缩放速度恢复上一次保存 //视图范围和缩放速度恢复上一次保存
userConfig.viewSize.minViewHeight = this.oldViewSize.minViewHeight; userConfig.viewSize.minViewHeight = this.oldViewSize.minViewHeight;
userConfig.viewSize.maxViewHeight = this.oldViewSize.maxViewHeight; userConfig.viewSize.maxViewHeight = this.oldViewSize.maxViewHeight;
@ -88,6 +93,12 @@ export class ConfigStore extends Singleton
else else
this.oldBgcolor = userConfig.SystemConfig.background; this.oldBgcolor = userConfig.SystemConfig.background;
//更新线框颜色
this.oldConceptualEdgeColor = userConfig.ConceptualEdgeColor;
this.oldPhysical2EdgeColor = userConfig.Physical2EdgeColor;
ColorMaterial.UpdateConceptualEdgeMaterial();
ColorMaterial.UpdatePhysical2EdgeMaterial();
//更新视图范围和缩放是速度 //更新视图范围和缩放是速度
this.oldViewSize.minViewHeight = userConfig.viewSize.minViewHeight; this.oldViewSize.minViewHeight = userConfig.viewSize.minViewHeight;
this.oldViewSize.maxViewHeight = userConfig.viewSize.maxViewHeight; this.oldViewSize.maxViewHeight = userConfig.viewSize.maxViewHeight;

@ -10,6 +10,7 @@ import { KeyBoard } from "../../../../Common/KeyEnum";
import { AAType, ViewDirType } from "../../../../Common/SystemEnum"; import { AAType, ViewDirType } from "../../../../Common/SystemEnum";
import { FixedNotZero } from "../../../../Common/Utils"; import { FixedNotZero } from "../../../../Common/Utils";
import { userConfig } from "../../../../Editor/UserConfig"; import { userConfig } from "../../../../Editor/UserConfig";
import { ConfigColorList } from "./ConfigColorList";
import { ConfigStore } from "./ConfigDialog"; import { ConfigStore } from "./ConfigDialog";
import './ConfigPanelStyle.less'; import './ConfigPanelStyle.less';
@ -34,6 +35,13 @@ const Padding: React.CSSProperties = {
margin: 0 margin: 0
}; };
export const ColorList: [string, number][] = [
["黑色", 0], ["红色", 1],
["黄色", 2], ["绿色", 3],
["青色", 4], ["蓝色", 5],
["洋红色", 6], ["白色", 7],
];
@observer @observer
export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }> export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }>
{ {
@ -42,6 +50,7 @@ export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }>
@observable _ZoomSpeed: number = userConfig.viewSize.zoomSpeed; @observable _ZoomSpeed: number = userConfig.viewSize.zoomSpeed;
@observable private errorMsg: boolean[] = [false, false, false]; @observable private errorMsg: boolean[] = [false, false, false];
@observable private errorStr = ""; @observable private errorStr = "";
@observable isShow = false;
_inputEl1 = React.createRef<HTMLInputElement>(); _inputEl1 = React.createRef<HTMLInputElement>();
_inputEl2 = React.createRef<HTMLInputElement>(); _inputEl2 = React.createRef<HTMLInputElement>();
_SpeedInputEl = React.createRef<HTMLInputElement>(); _SpeedInputEl = React.createRef<HTMLInputElement>();
@ -60,6 +69,13 @@ export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }>
app.Viewer.Renderer.setClearColor(new Color(color.hex), 1); app.Viewer.Renderer.setClearColor(new Color(color.hex), 1);
app.Editor.UpdateScreen(); app.Editor.UpdateScreen();
}; };
handleChangeEdgeColor = (e: React.MouseEvent<HTMLUListElement>, type: string) =>
{
let el = e.target as HTMLLIElement;
if (el.value !== undefined)
userConfig[type] = el.value;
};
render() render()
{ {
let isLayout = app.Viewer.isLayout; let isLayout = app.Viewer.isLayout;
@ -68,7 +84,7 @@ export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }>
<div> <div>
<div style={{ display: "inline-flex", ...Padding }}> <div style={{ display: "inline-flex", ...Padding }}>
<span style={WDCss}>:</span> <span style={WDCss}>:</span>
<div style={{ zIndex: 100, border: "1px solid" }}> <div style={{ zIndex: 100, marginLeft: 5, border: "1px solid" }}>
<div <div
style={{ style={{
background: isLayout ? userConfig.SystemConfig.layoutBackground : userConfig.SystemConfig.background, background: isLayout ? userConfig.SystemConfig.layoutBackground : userConfig.SystemConfig.background,
@ -113,6 +129,16 @@ export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }>
onChange={e => userConfig.viewDirType = parseFloat(e.target.value)} onChange={e => userConfig.viewDirType = parseFloat(e.target.value)}
/> />
</Label> </Label>
<ConfigColorList
text={"概念线框的颜色"}
type={"ConceptualEdgeColor"}
handleClick={this.handleChangeEdgeColor}
/>
<ConfigColorList
text={"真实视图带线框的线框颜色"}
type={"Physical2EdgeColor"}
handleClick={this.handleChangeEdgeColor}
/>
<Tooltip content="可以将头部栏的功能更全面的展示出来,方便使用"> <Tooltip content="可以将头部栏的功能更全面的展示出来,方便使用">
<Checkbox <Checkbox
label="双层小图标模式" label="双层小图标模式"
@ -213,7 +239,7 @@ export class DisplayConfigPanel extends React.Component<{ store: ConfigStore; }>
<div> <div>
<div style={{ display: "inline-flex", ...Padding }}> <div style={{ display: "inline-flex", ...Padding }}>
<span style={WDCss}></span> <span style={WDCss}></span>
<div> <div style={{ marginLeft: 5 }}>
<div className="numeric_input"> <div className="numeric_input">
<Tooltip <Tooltip
content={this.errorStr} content={this.errorStr}

@ -173,6 +173,7 @@ export class DrawConfigPanel extends React.Component<IConfigProps, {}> {
type={CheckObjectType.OnlyNumber} type={CheckObjectType.OnlyNumber}
option={userConfig} option={userConfig}
optKey={"cabinetSpacing"} optKey={"cabinetSpacing"}
onChange={(e) => { userConfig.cabinetSpacing = Number(e.target.value); }}
onBlur={(e, hasErr) => onBlur={(e, hasErr) =>
{ {
if (hasErr) if (hasErr)

@ -1191,3 +1191,38 @@ img {
background-color: white; background-color: white;
} }
} }
#color-list {
.borderstyle {
border: 1px solid #aaa;
border-radius: 4px;
}
width: 120px;
&>:nth-child(1){
.borderstyle();
cursor: pointer;
display: flex;
justify-content: space-between
}
&>:nth-child(2){
// position: relative;
&>div{
&>ul {
.borderstyle();
width: 120px;
height: auto;
background-color: white;
border-top: none;
z-index: 20;
position: absolute;
}
}
}
li:hover{
background-color: #ccc;
}
}

Loading…
Cancel
Save