!1685 功能:底部工具栏增加隐藏显示灯光助手开关

pull/1679/MERGE
林三 3 years ago committed by ChenX
parent 6ba67dd2f1
commit d25a0b9f99

@ -0,0 +1,81 @@
import { Button, Menu, MenuItem, Popover } from "@blueprintjs/core";
import { observer } from "mobx-react";
import * as React from "react";
import { DownPanelStore, LightDataModeType } from "../UI/Store/DownPanelStore";
/**
* .
*/
@observer
export class LightsMenu extends React.Component<{}>
{
public state = {
isOpenMenu: false,
};
render()
{
return (
<Popover
isOpen={this.state.isOpenMenu ? true : undefined}
modifiers={{ arrow: { enabled: false } }}
onClosed={this.close}
>
<Button
style={{ fontSize: "11px", textAlign: "center", minHeight: "15px", height: "15px", lineHeight: "1px" }}
text="灯光助手"
/>
{this.RenderMenu()}
</Popover >
);
}
RenderMenu = () =>
{
const downStore = DownPanelStore.GetInstance() as DownPanelStore;
return (
<Menu
className="snapMenu-fixed"
style={{ minWidth: "120px" }}
tabIndex={-1}
>
{
downStore.lightsData.map(
(data) =>
<MenuItem
key={data.mode}
text={data.name}
icon={data.enable ? "tick" : "blank"}
shouldDismissPopover={false}
onClick={() =>
{
data.enable = !data.enable;
if (data.mode !== LightDataModeType.A && !data.enable) //有灯光取消打勾时, "全部"取消打勾
{
if (downStore.lightsData[0].enable)
downStore.lightsData[0].enable = false;
}
if (data.mode === LightDataModeType.A && data.enable) //选"全部"打勾时,所灯光ui打勾
{
for (let data of downStore.lightsData)
if (!data.enable && data.mode !== LightDataModeType.A)
data.enable = true;
}
else if (data.mode === LightDataModeType.A && !data.enable) // 选"全部"不打勾时,所灯光ui取消打勾
{
for (let data of downStore.lightsData)
if (data.enable && data.mode !== LightDataModeType.A)
data.enable = false;
}
}}
/>
)
}
</Menu>
);
};
private close = () =>
{
let store = DownPanelStore.GetInstance() as DownPanelStore;
store.Upload();
};
}

@ -120,6 +120,8 @@ export class UserConfig implements IConfigStore
showShareModule: boolean = false; showShareModule: boolean = false;
@observable openHistoryList = true; @observable openHistoryList = true;
isOpenCabinet: boolean = false; //是否时开启门板、抽屉动作 isOpenCabinet: boolean = false; //是否时开启门板、抽屉动作
@observable lightHelper: boolean = false; //是否显示灯光助手
constructor() constructor()
{ {
this.Init(); this.Init();

@ -7,12 +7,17 @@ import { SignUrl } from '../../Common/HostUrl';
import { Log } from '../../Common/Log'; import { Log } from '../../Common/Log';
import { Post, RequestStatus } from '../../Common/Request'; import { Post, RequestStatus } from '../../Common/Request';
import { Entity } from '../../DatabaseServices/Entity/Entity'; import { Entity } from '../../DatabaseServices/Entity/Entity';
import { commandMachine } from '../../Editor/CommandMachine'; import { DirectionalLight } from '../../DatabaseServices/Lights/DirectionalLight';
import { Light } from '../../DatabaseServices/Lights/Light';
import { RectAreaLight } from '../../DatabaseServices/Lights/RectAreaLight';
import { SpotLight } from '../../DatabaseServices/Lights/SpotLight';
import { commandMachine, CommandWrap } from '../../Editor/CommandMachine';
import { CommandState } from '../../Editor/CommandState'; import { CommandState } from '../../Editor/CommandState';
import { LightsMenu } from '../../Editor/LightsMenu';
import { SnapMenuFixed } from '../../Editor/SnapMenuFixed'; import { SnapMenuFixed } from '../../Editor/SnapMenuFixed';
import { TempEditor } from '../../Editor/TempEditor'; import { TempEditor } from '../../Editor/TempEditor';
import { userConfig } from '../../Editor/UserConfig'; import { userConfig } from '../../Editor/UserConfig';
import { DownPanelStore } from '../Store/DownPanelStore'; import { DownPanelStore, LightDataModeType } from '../Store/DownPanelStore';
import { RightPanelStore } from '../Store/RightPanelStore/RightPanelStore'; import { RightPanelStore } from '../Store/RightPanelStore/RightPanelStore';
import { TopPanelStore } from '../Store/TopPanelStore'; import { TopPanelStore } from '../Store/TopPanelStore';
import { userConfigStore } from '../Store/UserConfigStore'; import { userConfigStore } from '../Store/UserConfigStore';
@ -250,12 +255,45 @@ export class DownPanel extends React.Component<{ store?: DownPanelStore; }, {}>
await userConfigStore.SaveConfig(BoardModalType.UserConfig, userConfig); await userConfigStore.SaveConfig(BoardModalType.UserConfig, userConfig);
return; return;
} }
if (key === "lightHelper")
{
userConfig.lightHelper = !userConfig.lightHelper;
const downStore = DownPanelStore.GetInstance() as DownPanelStore;
let Lights: string[] = [];
for (let light of downStore.lightsData)
{
if (light.enable && light.mode !== LightDataModeType.A)
Lights.push(light.mode);
}
if (Lights.length > 0)
CommandWrap(() =>
{
for (let light of app.Database.Lights.Entitys)
{
if (Lights.includes(this.GetLightType(light)))
(light as Light).ShowHelper = userConfig.lightHelper;
}
}, userConfig.lightHelper ? "显示灯光助手" : "隐藏灯光助手");
e.currentTarget.blur();
return;
}
this.props.store[key] = e.currentTarget.checked; this.props.store[key] = e.currentTarget.checked;
if (!app.Viewer.isLayout) if (!app.Viewer.isLayout)
userConfig.switchBackground = true; userConfig.switchBackground = true;
e.currentTarget.blur(); e.currentTarget.blur();
this.props.store.Upload(); this.props.store.Upload();
}; };
private GetLightType(ent: Entity)
{
if (ent instanceof SpotLight)
return LightDataModeType.S;
else if (ent instanceof RectAreaLight)
return LightDataModeType.R;
else if (ent instanceof DirectionalLight)
return LightDataModeType.D;
}
componentDidMount() componentDidMount()
{ {
this.rStore.lightStore.ShowShadowObject(true); this.rStore.lightStore.ShowShadowObject(true);
@ -390,6 +428,15 @@ export class DownPanel extends React.Component<{ store?: DownPanelStore; }, {}>
e.currentTarget.blur(); e.currentTarget.blur();
}} }}
/> />
<Switch
checked={userConfig.lightHelper}
data-key="lightHelper"
onChange={this.handleChange}
style={switchStyle}
alignIndicator={Alignment.RIGHT}
>
<LightsMenu />
</Switch>
</div> </div>
); );
} }

@ -36,6 +36,21 @@ export interface ISnapData
enable: boolean; enable: boolean;
} }
export interface LightsData
{
mode: LightDataModeType;
name: string;
enable: boolean;
}
export enum LightDataModeType
{
A = "AllLight",
S = "SpotLight",
R = "RectAreaLight",
D = "DirectionalLight"
}
/** /**
* . * .
*/ */
@ -109,6 +124,29 @@ export class DownPanelStore
enable: true enable: true
}, },
]; ];
@observable lightsData: LightsData[] = [
{
mode: LightDataModeType.A,
name: "全部",
enable: true
},
{
mode: LightDataModeType.S,
name: "射灯",
enable: true
},
{
mode: LightDataModeType.R,
name: "矩形灯",
enable: true
},
{
mode: LightDataModeType.D,
name: "太阳光",
enable: true
},
];
private timeId; private timeId;
private constructor() private constructor()
{ {
@ -154,6 +192,7 @@ export class DownPanelStore
isF11Checked: this.isF11Checked, isF11Checked: this.isF11Checked,
snapData: this.snapData.map(d => d.enable), snapData: this.snapData.map(d => d.enable),
fontName: this.fontName, fontName: this.fontName,
lightsData: this.lightsData.map(l => l.enable),
}; };
} }
async Upload() async Upload()
@ -220,6 +259,11 @@ export class DownPanelStore
{ {
this.snapData[i].enable = config.snapData[i]; this.snapData[i].enable = config.snapData[i];
} }
if (config.lightsData)
for (let i = 0; i < config.lightsData.length; i++)
{
this.lightsData[i].enable = config.lightsData[i];
}
this.SetSnapMode(); this.SetSnapMode();
this.showType = !this.isLeftToolBarShow ? this.showType ^ ToolBarType.lefttoolbar : this.showType | ToolBarType.lefttoolbar; this.showType = !this.isLeftToolBarShow ? this.showType ^ ToolBarType.lefttoolbar : this.showType | ToolBarType.lefttoolbar;
} }

Loading…
Cancel
Save