!2369 优化:加大板编号数字字体大小,"未编号"保存不变

pull/2594/MERGE
林三 7 months ago committed by ChenX
parent 2e67025fd0
commit 10278cefe7

@ -1,5 +1,6 @@
import { DirectionalLight } from "three";
import { app } from "../../ApplicationServices/Application";
import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices";
import { CURRENT_HOST } from "../../Common/HostUrl";
import { LogType } from "../../Common/Log";
import { deflate, GetCurrentViewPreViewImage } from "../../Common/SerializeMaterial";
@ -112,7 +113,9 @@ export class Command_ShareView implements Command
var result = JSON.parse(await res.text());
if (result.err_code == 0)
{
open('./shareview.html?view_id=' + result.view_id + "&VisualStyle=" + store.m_Option.VisualStyle + "&Viewport=" + store.m_Option.Viewport + "&Physical2EdgeColor=" + store.m_Option.Physical2EdgeColor);
open('./shareview.html?view_id=' + result.view_id + "&VisualStyle=" + store.m_Option.VisualStyle +
"&Viewport=" + store.m_Option.Viewport + "&Physical2EdgeColor=" + store.m_Option.Physical2EdgeColor +
"&CustomNumberHeight=" + HostApplicationServices.boardCustomNumberTextHeight);
AppToaster.show({
message: "分享成功!",
timeout: 5000,

@ -285,12 +285,13 @@ async function LoadData(): Promise<{ cadFile: CADFiler; urlSearch: URLSearchPara
{
shareViewStore.Props = data.fileInfo.props;
}
//板编号字体大小
userConfig.boardCustomNumberTextHeight = safeEval(urlSearch.get("CustomNumberHeight")) || 60;
return { cadFile: new CADFiler(file), urlSearch };
} else
{
shareViewStore.ViewIDErrorMsg = `${data.err_code}: ${data.err_msg}`;
}
}
else
shareViewStore.ViewIDErrorMsg = `url缺少view_id参数`;
}
/*

@ -5,7 +5,6 @@ import { ShareViewStore } from "../ShareViewStore";
import { GetBlockColor, SPGetSpiteSize } from "../ShareViewUtil";
import { BoardMoreMsgWidget, BoardMsgDialog, IBoardMsgDialogShow } from "./BoardRemarksWidget";
const BoardMessageWidget = (() =>
{
const shareViewStore: ShareViewStore = ShareViewStore.GetInstance();
@ -23,6 +22,7 @@ const BoardMessageWidget = (() =>
<div>{size.width}</div>
<div>{size.thickness}</div>
<div>{GetBlockColor(shareViewStore.SelectedBoard)}</div>
<div>{shareViewStore.SelectedBoard.CustomNumber || "未编号"}</div>
<div
onClick={(e) =>
{

@ -112,6 +112,7 @@ export class IHostApplicationServices
};
@ProxyValue dimTextHeight = 60;
@ProxyValue boardCustomNumberTextHeight = 60; //板编号字体高度
@ProxyValue lineWidth = 2; //打印线框
@ProxyValue fractionDigitsType: FractionDigitsType = FractionDigitsType.two;

@ -323,6 +323,7 @@ export class Board extends ExtrudeSolid
{
this._CustomNumberTextEntity.TextString = n?.toString() ?? "";
this._CustomNumberTextEntity.Visible = this._CustomNumberTextEntity.TextString !== "";
this._CustomNumberTextEntity.Height = HostApplicationServices.boardCustomNumberTextHeight;
}
}
}
@ -1629,6 +1630,11 @@ export class Board extends ExtrudeSolid
this._CustomNumberTextEntity.TextString = this._CustomNumber?.toString() ?? (this.objectId?.Index > 0 ? "未编号" : " ");
if (this._CustomNumberTextEntity.TextString === "未编号")
this._CustomNumberTextEntity.Height = 60;
else
this._CustomNumberTextEntity.Height = HostApplicationServices.boardCustomNumberTextHeight;
let o = this._CustomNumberTextEntity.GetDrawObjectFromRenderType(RenderType.Conceptual);
if (o)
{

@ -44,7 +44,7 @@ export interface IChat
export class UserConfig implements IConfigStore
{
private readonly _version = 38; //🌟🌟每次更新必须向上添加一次版本号🌟🌟
private readonly _version = 39; //🌟🌟每次更新必须向上添加一次版本号🌟🌟
@observable designer = ""; //一键布局的设计师
_renderType: RenderType = RenderType.Wireframe;
@observable maxSize: IMaxSizeProps = {
@ -136,6 +136,7 @@ export class UserConfig implements IConfigStore
};
@observable autoLines = false;
@observable dimTextHeight = 60;
@observable boardCustomNumberTextHeight = 60; //自定义编号字体高度
@observable performanceConfig = {
fakersweep: false,
disablerefcut: false,
@ -250,6 +251,7 @@ export class UserConfig implements IConfigStore
textHight: 60,
});
this.dimTextHeight = 60;
this.boardCustomNumberTextHeight = 60;
this.smalliconmode = false;
this.dimensions = true;
this.switchBackground = false;
@ -341,7 +343,8 @@ export class UserConfig implements IConfigStore
show2DPathLine: this.show2DPathLine,
show2DPathObject: this.show2DPathObject,
templateDisplayCount: this.templateDisplayCount,
hingeLidRule: toJS(this.hingeLidRule)
hingeLidRule: toJS(this.hingeLidRule),
boardCustomNumberTextHeight: this.boardCustomNumberTextHeight,
}
};
}
@ -498,19 +501,28 @@ export class UserConfig implements IConfigStore
{
Object.assign(this.printOption, config.option.printOption);
}
if (config.option.version > 35)
{
this.show2DPathLine = config.option.show2DPathLine;
this.show2DPathObject = config.option.show2DPathObject;
}
if (config.option.version > 36)
{
this.templateDisplayCount = config.option.templateDisplayCount;
}
if (config.option.version > 37)
{
Object.assign(this.hingeLidRule, config.option.hingeLidRule);
}
if (config.option.version > 38)
{
this.boardCustomNumberTextHeight = config.option.boardCustomNumberTextHeight;
}
else
this.boardCustomNumberTextHeight = 60;
}
}

@ -0,0 +1,121 @@
import { Intent, NumericInput, Position, Tooltip } from "@blueprintjs/core";
import { observable } from "mobx";
import { observer } from "mobx-react";
import React from "react";
import { KeyBoard } from "../../Common/KeyEnum";
import { FixedNotZero } from "../../Common/Utils";
interface INumericInputProps
{
value: number;
canNull?: boolean; //输入框可以为空
min?: number; //最小值
max?: number; //最大值
stepSize?: number;
float?: number; //保留小数位数
onValueChange?: (valueAsNumber: number, valueAsString: string, inputElement: HTMLInputElement) => void;
onBlur?: (e: React.FocusEvent<HTMLInputElement, Element>) => void; //可以用来赋值使用
style?: React.CSSProperties;
tooltip?: boolean;
}
@observer
export class INumericInput extends React.Component<INumericInputProps, {}>
{
_InputRef = React.createRef<NumericInput>();
_Float: number = this.props.float ?? 0; //支持几位小数, 等于0时 为整数
_Value_Min: number = this.props.min ?? -1e7;
_Value_Max: number = this.props.max ?? 1e7;
_CanNull: boolean = this.props.canNull ?? false; //输入框值可为空
_InitialValue: number | string = this.props.value; //初始值
@observable _Value: number | string = this.props.value;
@observable _isPopoverOpen: boolean = false;
componentDidUpdate(prevProps: INumericInputProps)
{
if (this.props.value !== prevProps.value)
this._Value = this.props.value;
}
render()
{
return (
<Tooltip
content={`仅限${this._Value_Min}-${this._Value_Max}间的数字!`}
position={Position.TOP}
intent={Intent.WARNING}
isOpen={this.props.tooltip && this._isPopoverOpen}
>
<NumericInput
tabIndex={1}
ref={this._InputRef}
style={this.props.style}
buttonPosition="none"
min={this._Value_Min}
max={this._Value_Max}
stepSize={this.props.stepSize ?? 1}
value={this._Value}
onValueChange={(num, value, e) =>
{
if (value === "-")
{
if (this._Value_Min >= 0)
{
this._Value = 0;
this._isPopoverOpen = true;
return;
}
}
if (value === "" || "-0.".includes(value) && value !== "0")
{
this._Value = value;
return;
}
if (isNaN(num) || num < this._Value_Min || num > this._Value_Max)
{
this._isPopoverOpen = true; 3;
return;
}
if (num >= this._Value_Min && num < this._Value_Max && value === num + ".")
{
if (num === this._Value_Min) return; //MIN = -3 ,防止输入出现如( -3.)
this._Value = value;
return;
}
this._Value = parseFloat(FixedNotZero(num, this._Float));
this._isPopoverOpen = false;
}}
onFocus={(e) =>
{
e.target.select();
//记录初始值 按ESC键时还原这个值
this._InitialValue = this._Value;
}}
onKeyDown={(e: React.KeyboardEvent) =>
{
if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space)
this._InputRef.current.inputElement.blur();
else if (e.keyCode === KeyBoard.Escape)
{
this._InputRef.current.inputElement.value = this._InitialValue.toString();
this._InputRef.current.inputElement.blur();
}
e.stopPropagation();
}}
onBlur={(e) =>
{
this._Value = FixedNotZero(e.currentTarget.value, this._Float);
if (!this._Value)
{
this._Value = this._CanNull ? "" : this._Value_Min.toString();
e.currentTarget.value = this._Value;
}
if (this.props.onBlur)
this.props.onBlur(e);
this._isPopoverOpen = false;
}}
/>
</Tooltip>
);
}
}

@ -1,13 +1,9 @@
import { Card, Checkbox, Intent, Position, Tooltip } from "@blueprintjs/core";
import { Card, Checkbox } from "@blueprintjs/core";
import { observable } from "mobx";
import { observer } from "mobx-react";
import * as React from 'react';
import { app } from "../../../../ApplicationServices/Application";
import { KeyBoard } from "../../../../Common/KeyEnum";
import { LogType } from "../../../../Common/Log";
import { safeEval } from "../../../../Common/eval";
import { CommandWrap } from "../../../../Editor/CommandMachine";
import { userConfig } from "../../../../Editor/UserConfig";
import { INumericInput } from "../../INumericInput";
const WDCss: React.CSSProperties = {
width: 100
@ -41,67 +37,17 @@ export class TextConfigPanel extends React.Component<{}>
</div>
<div>
<span style={WDCss}></span>
<Tooltip
content={"仅限1-300间的数字!"}
position={Position.TOP}
intent={Intent.WARNING}
isOpen={this._isPopoverOpen}
>
<input
className={"time-config"}
ref={this._InputEl}
defaultValue={userConfig.textStyleOption.textHight}
style={{ width: "80%", border: "1px solid silver", backgroundColor: userConfig.textStyleOption.appointTextHight ? "#ffffff" : "#dddddd" }}
disabled={!userConfig.textStyleOption.appointTextHight}
onKeyDown={(e) =>
{
if (e.keyCode === KeyBoard.Escape)
{
//@ts-ignore
e.target.blur();
}
else if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space)
{
if (!this._isPopoverOpen)
//@ts-ignore
e.target.blur();
else
//@ts-ignore
e.target.focus();
e.preventDefault();
}
e.stopPropagation();
}}
onFocus={(e) =>
{
this._InputEl.current.setSelectionRange(0, this._InputEl.current.value.length);
}}
onBlur={(e) =>
{
let val = safeEval(e.target.value);
if (!isNaN(val))
{
if (val <= 0 || val > 300)
{
app.Editor.Prompt('文字尺寸仅限1-300间的数字!', LogType.Error);
e.target.value = userConfig.textStyleOption.textHight.toString();
}
else
{
CommandWrap(() =>
{
userConfig.textStyleOption.textHight = val;
}, "修改字体大小");
}
}
else
{
app.Editor.Prompt('文字尺寸仅限1-300间的数字!', LogType.Error);
e.target.value = userConfig.textStyleOption.textHight.toString();
}
}}
/>
</Tooltip>
<INumericInput
min={1}
max={300}
float={0}
value={userConfig.textStyleOption.textHight}
tooltip
onBlur={(e) =>
{
userConfig.textStyleOption.textHight = parseInt(e.currentTarget.value);
}}
/>
</div>
<div>
<Checkbox
@ -111,6 +57,20 @@ export class TextConfigPanel extends React.Component<{}>
onChange={() => userConfig.textStyleOption.noNeedAngle = !userConfig.textStyleOption.noNeedAngle}
/>
</div>
<div>
<span style={WDCss}></span>
<INumericInput
min={1}
max={300}
float={0}
value={userConfig.boardCustomNumberTextHeight}
tooltip
onBlur={(e) =>
{
userConfig.boardCustomNumberTextHeight = parseInt(e.currentTarget.value);
}}
/>
</div>
</div>
</div>
</Card >

Loading…
Cancel
Save