!1825 优化:右侧栏造型刀取时配置不重置

pull/1821/MERGE
林三 2 years ago committed by ChenX
parent 8eb4f7bbbf
commit cea86767b4

@ -243,29 +243,49 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
cu.Erase(false); cu.Erase(false);
let moveCus = [cu]; let moveCus = [cu];
let store = RightPanelStore.GetInstance() as RightPanelStore; let store = RightPanelStore.GetInstance();
//初始化造型数据,提取出形状 //初始化造型数据,提取出形状
store.modelingStore.InitModelingItems(); // store.modelingStore.InitModelingItems(); //需求:不重置配置
let dataColorMap = new Map<string, number>();//data->color
let canUseColor: number[] = [];//可使用的颜色(无高度)
let onUseColor: number[] = [];//已经使用的颜色
let colorIndex = 1; let colorIndex = 1;
let dataMap = new Map<string, number>(); for (let item of store.modelingStore.modelingItems)
{
let str = [item.height, item.dir, item.knifeRad, item.addLen].join("-");
if (dataColorMap.has(str) || item.height === 0)//重复的相同设定一样没有意义,所以可以覆盖
canUseColor.push(item.color);//可以被覆盖
else
dataColorMap.set(str, item.color);//记录颜色
}
for (let data of br.BoardModeling) for (let data of br.BoardModeling)
{ {
let str = [data.thickness, data.dir, data.knifeRadius, data.addLen].join("-"); let str = [data.thickness, data.dir, data.knifeRadius, data.addLen].join("-");
let color: number; let color: number;
if (dataMap.has(str)) if (dataColorMap.has(str))
color = dataMap.get(str); color = dataColorMap.get(str);
else else
{ {
color = colorIndex; color = canUseColor[0];
dataMap.set(str, color); if (!color)
colorIndex++; {
while (colorIndex < 24)
{
if (!onUseColor.includes(colorIndex)) break;
colorIndex++;
}
color = colorIndex;
}
canUseColor.shift();
dataColorMap.set(str, color);
store.modelingStore.ChangeModelingValue(color - 1, data); store.modelingStore.ChangeModelingValue(color - 1, data);
} }
onUseColor.push(color);
let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().Z0().ApplyMatrix(br.OCSNoClone)); let cu = JigUtils.Draw(data.shape.Outline.Curve.Clone().Z0().ApplyMatrix(br.OCSNoClone));
cu.ColorIndex = color; cu.ColorIndex = color;
moveCus.push(cu); moveCus.push(cu);
@ -284,7 +304,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
{ {
//显示右侧状态栏 //显示右侧状态栏
store.modelingStore.isUpdate = false; store.modelingStore.isUpdate = false;
store.modelingStore.configName = ""; //store.modelingStore.configName = ""; //需求:不重置配置
store.m_IsShow = true; store.m_IsShow = true;
store.m_TabId = RightTabId.Model; store.m_TabId = RightTabId.Model;
app.Editor.MaskManage.OnFocusEvent(); app.Editor.MaskManage.OnFocusEvent();

@ -110,6 +110,9 @@ export class UserConfig extends React.Component<IConfigProps, {}>{
BoardModalType.TempDes, BoardModalType.TempDes,
// BoardModalType.YX // BoardModalType.YX
]; ];
const NotUpdateNameTypes = [
BoardModalType.Zx,
];
let type = this.props.type; let type = this.props.type;
let configs = (await this._userConfigStore.GetAllConfigs(type)) || {}; let configs = (await this._userConfigStore.GetAllConfigs(type)) || {};
@ -122,7 +125,8 @@ export class UserConfig extends React.Component<IConfigProps, {}>{
{ {
await this.handleInitConfig(); await this.handleInitConfig();
} }
this.props.store.configName = ""; if (!NotUpdateNameTypes.includes(type))
this.props.store.configName = "";
return; return;
} }
//如果没保存过配置,添加一个默认 //如果没保存过配置,添加一个默认

@ -1,9 +1,9 @@
import { observable, toJS, action } from "mobx"; import { action, observable, toJS } from "mobx";
import { IModelingItem } from "../../Components/RightPanel/ModelingComponent";
import { IModeling } from "../../../DatabaseServices/Entity/Board";
import { FixedNotZero } from "../../../Common/Utils"; import { FixedNotZero } from "../../../Common/Utils";
import { FaceDirection, IUiOption } from "../BoardInterface"; import { IModeling } from "../../../DatabaseServices/Entity/Board";
import { IConfigOption } from "../../Components/Board/UserConfig"; import { IConfigOption } from "../../Components/Board/UserConfig";
import { IModelingItem } from "../../Components/RightPanel/ModelingComponent";
import { FaceDirection, IUiOption } from "../BoardInterface";
import { IConfigStore } from "../BoardStore"; import { IConfigStore } from "../BoardStore";
export class ModelingStore implements IConfigStore export class ModelingStore implements IConfigStore

@ -174,6 +174,21 @@ export class UserConfigStore extends Singleton
} }
} }
} }
//ModelingStore
async InitModelingStore()
{
let configs = await this.GetAllConfigs(BoardModalType.Zx);
if (configs)
{
let confNames = [...Object.keys(configs)];
let curName = userConfig.userConfigName[BoardModalType.Zx];
if (!curName)
curName = confNames[0];
let rightPanelStore = RightPanelStore.GetInstance();
rightPanelStore.modelingStore.UpdateOption(configs[curName]);
rightPanelStore.modelingStore.configName = curName;
}
}
/**处理用户登陆后的信息 */ /**处理用户登陆后的信息 */
async InitUserData() async InitUserData()
@ -195,6 +210,7 @@ export class UserConfigStore extends Singleton
await this.InitUserConfig(); await this.InitUserConfig();
await this.InitBBSTabIndex(); await this.InitBBSTabIndex();
await this.InitCommonPanelStore(); await this.InitCommonPanelStore();
await this.InitModelingStore();
await (DownPanelStore.GetInstance() as DownPanelStore).Update(); await (DownPanelStore.GetInstance() as DownPanelStore).Update();
CommandServer.GetInstance().InitCommandCustomCmdAndHotkey(); CommandServer.GetInstance().InitCommandCustomCmdAndHotkey();
RoomBaseParamsStore.GetSingleInstance(); RoomBaseParamsStore.GetSingleInstance();

Loading…
Cancel
Save