diff --git a/.vscode/settings.json b/.vscode/settings.json index 61bd2c7a3..8d94f0ad4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,8 @@ "editor.formatOnSave": true, "editor.insertSpaces": true, "editor.detectIndentation": false, + //git + "git.rebaseWhenSync": true, //格式设置 "typescript.format.placeOpenBraceOnNewLineForFunctions": true, "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true, diff --git a/src/Add-on/ShareView/Command_ShareView.ts b/src/Add-on/ShareView/Command_ShareView.ts index d0f29068b..16bf0f909 100644 --- a/src/Add-on/ShareView/Command_ShareView.ts +++ b/src/Add-on/ShareView/Command_ShareView.ts @@ -5,33 +5,76 @@ import { deflate, GetCurrentViewPreViewImage } from "../../Common/SerializeMater import { Intent } from "../../Common/Toaster"; import { CADFiler } from "../../DatabaseServices/CADFiler"; import { Database } from "../../DatabaseServices/Database"; +import { Board } from "../../DatabaseServices/Entity/Board"; import { EntityRef } from "../../DatabaseServices/Entity/EntityRef"; import { FileServer } from "../../DatabaseServices/FileServer"; +import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity"; +import { HardwareTopline } from "../../DatabaseServices/Hardware/HardwareTopline"; import { Command } from "../../Editor/CommandMachine"; -import { PromptStatus } from "../../Editor/PromptResult"; +import { PromptSsgetResult, PromptStatus } from "../../Editor/PromptResult"; +import { BoardModalType } from "../../UI/Components/Board/BoardModalType"; +import { DialogUserConfig } from "../../UI/Components/Board/UserConfigComponent"; import { AppToaster } from "../../UI/Components/Toaster"; import { Purge } from "../Purge"; +import { ShareBoardInfoConfiguration } from "./components/ShareBoardInfoConfiguration"; +import { ShareViewStore } from "./ShareViewStore"; + +const barringKeyWord = { msg: "分享图设置", key: "S" }; export class Command_ShareView implements Command { async exec() { - // 参考 SuperCopy 命令 - let ssRes = await app.Editor.GetSelection({ - Msg: "请选择需要分享的柜子:", - UseSelect: true, - Filter: { - filterFunction: (obj, ent) => !(ent instanceof DirectionalLight || ent instanceof EntityRef), //避免拷贝太阳光 太阳光只能有一个 - }, - }); - if (ssRes.Status !== PromptStatus.OK) return; + let store: ShareViewStore = ShareViewStore.GetInstance(); + let config = new DialogUserConfig(store, BoardModalType.ShareBoardInfoUpdateConfiguration); + await config.LoadAndInitConfig();//载入或者初始化 + let ssRes: PromptSsgetResult; + while (true) + { + ssRes = await app.Editor.GetSelection({ + KeyWordList: [barringKeyWord], + Msg: "请选择需要分享的柜子:", + UseSelect: true, + Filter: { + filterFunction: (obj, ent) => + !(ent instanceof DirectionalLight || ent instanceof EntityRef || + (!store.m_Option.IsExportBoard && (ent instanceof Board)) || (!store.m_Option.IsExportHardware && (ent instanceof HardwareCompositeEntity || ent instanceof HardwareTopline)))//避免拷贝太阳光 太阳光只能有一个 + }, + }); + if (ssRes.Status === PromptStatus.Cancel) + return; - let f = new CADFiler(); - app.Database.FileWrite(f); + else if (ssRes.Status === PromptStatus.Keyword) + { + app.Editor.ModalManage.RenderModal(ShareBoardInfoConfiguration, { store }); + await app.Editor.ModalManage.Wait(); + } + else + break; + } + + if (ssRes.Status !== PromptStatus.OK) return; + let hasBrOrHardw = false; let ents = new Set(); for (let e of ssRes.SelectSet.SelectEntityList) + { + hasBrOrHardw = hasBrOrHardw || (e instanceof Board || e instanceof HardwareCompositeEntity || e instanceof HardwareTopline); ents.add(e.Id.Index); + } + + if (!hasBrOrHardw) + { + AppToaster.show({ + message: "未选中板件或五金无法分享,请检查!", + timeout: 5000, + intent: Intent.DANGER, + }, "shareview"); + return; + } + + let f = new CADFiler(); + app.Database.FileWrite(f); let db = new Database(false, false, true); db.FileRead(f); @@ -47,11 +90,14 @@ export class Command_ShareView implements Command f = new CADFiler; db.FileWrite(f); + const props = JSON.stringify({ showBom: store.m_Option.showBom }); + const formData = new FormData(); let fileServer = FileServer.GetInstance() as FileServer; formData.append("name", fileServer.currentFileInfo.name); formData.append("logo", GetCurrentViewPreViewImage(), "cover.jpg"); formData.append("file", deflate(f.ToString())); + formData.append("props", props); fetch(CURRENT_HOST + "/CAD-viewerUpload", { method: "POST", @@ -64,7 +110,7 @@ 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); + open('./shareview.html?view_id=' + result.view_id + "&VisualStyle=" + store.m_Option.VisualStyle + "&Viewport=" + store.m_Option.Viewport + "&Physical2EdgeColor=" + store.m_Option.Physical2EdgeColor); AppToaster.show({ message: "分享成功!", timeout: 5000, diff --git a/src/Add-on/ShareView/Entry.tsx b/src/Add-on/ShareView/ShareViewEntry.tsx similarity index 85% rename from src/Add-on/ShareView/Entry.tsx rename to src/Add-on/ShareView/ShareViewEntry.tsx index 61069939f..db1a9a44e 100644 --- a/src/Add-on/ShareView/Entry.tsx +++ b/src/Add-on/ShareView/ShareViewEntry.tsx @@ -2,10 +2,11 @@ import { Cache, Layers, Object3D } from "three"; import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; import { CommandNames } from "../../Common/CommandNames"; import { ErrorMonitoring } from "../../Common/ErrorMonitoring"; +import { safeEval } from "../../Common/eval"; import { CURRENT_HOST } from "../../Common/HostUrl"; +import { inflateBase64 } from "../../Common/inflate"; import { LogEnable, ReportErrorWrap } from "../../Common/Log"; import { RequestStatus } from "../../Common/Request"; -import { inflateBase64 } from "../../Common/inflate"; import { CADFiler } from "../../DatabaseServices/CADFiler"; import { commandMachine } from "../../Editor/CommandMachine"; import { userConfig } from "../../Editor/UserConfig"; @@ -14,9 +15,10 @@ import "../../UI/Css/blue.less"; import "../../UI/Css/golden.less"; import "../../UI/Css/style.less"; import "../../UI/Css/switchTheme.less"; -import { ShareViewLayout } from "./Layout"; -import { BoxStore } from "./Store"; -import { ChangeThemeColor, GetBoxCovers, resetBoxView } from "./Util"; +import { ShareViewLayout } from "./ShareViewLayout"; +import { ViewAngleTypes, ViewStyleTypes } from "./ShareViewRules"; +import { ShareViewStore } from "./ShareViewStore"; +import { ChangeThemeColor, GetBoxCovers, resetBoxView } from "./ShareViewUtil"; Cache.enabled = true; @@ -191,7 +193,7 @@ window.onload = function () // 修改默认为概念渲染 commandMachine.ExecCommand(CommandNames.Conceptual); - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); try { @@ -199,7 +201,7 @@ window.onload = function () { if (cadFile) { - commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测 + // commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测 layout.app.LoadFile(cadFile).then(async () => { setTimeout(async () => @@ -261,9 +263,12 @@ window.onload = function () async function LoadData() { - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); let urlSearch = new URLSearchParams(location.search); let viewId = urlSearch.get('view_id'); + + InitShareConfiguration(urlSearch); + if (viewId) { let res = await fetch(CURRENT_HOST + '/CAD-viewerDetail?view_id=' + viewId, { @@ -293,3 +298,27 @@ async function LoadData() boxStore.ViewIDErrorMsg = `url缺少view_id参数`; } } + +/* +//分享图纸url设置 +*/ +function InitShareConfiguration(urlSearch: URLSearchParams) +{ + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); + boxStore.viewUploadProps = { + ...boxStore.viewUploadProps, + VisualStyle: safeEval(urlSearch.get("VisualStyle")), + Viewport: safeEval(urlSearch.get("Viewport")), + Physical2EdgeColor: safeEval(urlSearch.get("Physical2EdgeColor")), + }; + const { Viewport, VisualStyle, Physical2EdgeColor } = boxStore.viewUploadProps; + + const viewDirectionIndex = ViewAngleTypes.findIndex((v) => v.viewDirection === Viewport); + if (viewDirectionIndex > -1) commandMachine.ExecCommand(ViewAngleTypes[viewDirectionIndex].command); + else commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测 + + const viewStyleIndex = ViewStyleTypes.findIndex((v) => v.renderType === VisualStyle); + if (viewStyleIndex > -1) commandMachine.ExecCommand(ViewStyleTypes[viewStyleIndex].cmd); + + if (Physical2EdgeColor) HostApplicationServices.Physical2EdgeColor = Physical2EdgeColor; +} diff --git a/src/Add-on/ShareView/Layout.tsx b/src/Add-on/ShareView/ShareViewLayout.tsx similarity index 98% rename from src/Add-on/ShareView/Layout.tsx rename to src/Add-on/ShareView/ShareViewLayout.tsx index 5bb0762ef..1da7a05cc 100644 --- a/src/Add-on/ShareView/Layout.tsx +++ b/src/Add-on/ShareView/ShareViewLayout.tsx @@ -15,8 +15,8 @@ import { MouseUI } from '../../Editor/TouchEditor/MouseUIComp'; import { VirtualKeys } from '../../Editor/TouchEditor/VirtualKeysComp'; import { CameraControlBtn } from '../../UI/Components/CameraControlButton/CameraControlBtn'; import { ShowLinesToaster, __AppToasterShowEntityMsg } from '../../UI/Components/Toaster'; -import { ShareViewUI } from './components/ShareViewUI'; -import { ShareViewService } from './Service'; +import ShareViewUI from './components/ShareViewUI'; +import { ShareViewService } from './ShareViewService'; // export let appUi: ShareViewLayout; diff --git a/src/Add-on/ShareView/ShareViewRules.ts b/src/Add-on/ShareView/ShareViewRules.ts new file mode 100644 index 000000000..185a45f8f --- /dev/null +++ b/src/Add-on/ShareView/ShareViewRules.ts @@ -0,0 +1,76 @@ +import { CommandNames } from "../../Common/CommandNames"; +import { RenderType } from "../../GraphicsSystem/RenderType"; +import { ViewDirection } from "../../UI/Store/BoardInterface"; + +//仅在分享图纸shareView使用 +export const ViewAngleTypes = [ + { + command: CommandNames.FS, + name: "俯视", + viewDirection: ViewDirection.Up + }, + { + command: CommandNames.YS, + name: "右视", + viewDirection: ViewDirection.Right + }, + { + command: CommandNames.ZS, + name: "左视", + viewDirection: ViewDirection.Left + }, + { + command: CommandNames.QS, + name: "前视", + viewDirection: ViewDirection.Front + }, + { + command: CommandNames.BottomView, + name: "仰视", + viewDirection: ViewDirection.Bottom + }, + { + command: CommandNames.BackView, + name: "后视", + viewDirection: ViewDirection.Back + }, + { + command: CommandNames.Swiso, + name: "西南等轴测", + viewDirection: ViewDirection.Southwest + }, +]; + +//仅在分享图纸shareView使用 +export const ViewStyleTypes = [ + { + title: "二维线框", + cmd: CommandNames.Wireframe, + renderType: RenderType.Wireframe, + }, + { + title: "概念", + cmd: CommandNames.Conceptual, + renderType: RenderType.Conceptual, + }, + { + title: "真实", + cmd: CommandNames.Physical, + renderType: RenderType.Physical, + }, + { + title: "真实带线框", + cmd: CommandNames.Physical2, + renderType: RenderType.Physical2, + }, + { + title: "排版面", + cmd: CommandNames.CheckPlaceFace, + renderType: RenderType.PlaceFace, + }, + { + title: "概念(透明)", + cmd: CommandNames.ConceptualTransparent, + renderType: RenderType.ConceptualTransparent, + }, +]; diff --git a/src/Add-on/ShareView/Service.ts b/src/Add-on/ShareView/ShareViewService.ts similarity index 93% rename from src/Add-on/ShareView/Service.ts rename to src/Add-on/ShareView/ShareViewService.ts index 8fdaf5c69..123f752c3 100644 --- a/src/Add-on/ShareView/Service.ts +++ b/src/Add-on/ShareView/ShareViewService.ts @@ -1,7 +1,7 @@ import Dimension from "dxf-parser/dist/entities/dimension"; import { Object3D } from "three"; import { begin, end } from "xaop"; -import { ApplicationService } from "../../ApplicationServices/Application"; +import { app, ApplicationService } from "../../ApplicationServices/Application"; import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; import { EBoardKeyList } from "../../Common/BoardKeyList"; import { CommandNames } from "../../Common/CommandNames"; @@ -39,9 +39,9 @@ import { ShowToasterClearSiteData } from "../../UI/Components/ToasterClearSiteDa import { DownPanelStore } from "../../UI/Store/DownPanelStore"; import { HardwareCuttingReactor } from "../BoardCutting/HardwareCuttingReactor"; import { DrillingReactor } from "../DrawDrilling/DrillingReactor"; -import { BoxStore } from "./Store"; +import { ShareViewStore } from "./ShareViewStore"; +import { MaterialDetailScrollTo } from "./ShareViewUtil"; import { SetSelectedBoardChange } from "./StoreEvent"; -import { MaterialDetailScrollTo } from "./Util"; export let shareViewApp: ShareViewService; export class ShareViewService extends ApplicationService { @@ -87,11 +87,11 @@ export class ShareViewService extends ApplicationService let currentItem = this.Editor.SelectCtrl.SelectSet.SelectEntityList[0]; if (currentItem instanceof Board) { - BoxStore.GetInstance().SelectedBoard = currentItem; + ShareViewStore.GetInstance().SelectedBoard = currentItem; MaterialDetailScrollTo(); } else { - BoxStore.GetInstance().SelectedBoard = null; + ShareViewStore.GetInstance().SelectedBoard = null; } }); SetSelectedBoardChange(null, () => @@ -276,7 +276,7 @@ export class ShareViewService extends ApplicationService { this.OpenFile(f); this.BoxCtrl = new BoxService(); - await this.BoxCtrl.Init(this.Editor); + await this.BoxCtrl.Init(); } } @@ -300,19 +300,17 @@ export class BoxService { return this._BoxList; } - async Init(editor: Editor) + async Init() { await commandMachine.ExecCommand(CommandNames.SelectAll); - let enRes = await editor.GetSelection({ - UseSelect: true, - Filter: { - filterFunction: (o, e: Entity) => - { - return e instanceof Board || e instanceof HardwareCompositeEntity || e instanceof HardwareTopline || e instanceof Dimension; - }, - }, - }); - enRes.SelectSet.SelectEntityList.forEach((entity) => + let ens: Entity[] = []; + for (let e of app.Database.ModelSpace.Entitys) + { + if (e.IsErase) continue; + if (e instanceof Board || e instanceof HardwareCompositeEntity || e instanceof HardwareTopline || e instanceof Dimension) + ens.push(e); + } + ens.forEach((entity) => { if (entity instanceof Dimension) { @@ -333,8 +331,12 @@ export class BoxService // this.SetBoxVisible(this._BoxList.length - 1, false); } } - await commandMachine.ExecCommand(CommandNames.SelectAll); - await commandMachine.ExecCommand(CommandNames.HideSelect); + //隐藏全部 + for (let e of app.Database.ModelSpace.Entitys) + { + if (e.IsErase) continue; + e.Visible = false; + } } SetBoxVisible(index: number, visible: boolean) { @@ -387,14 +389,10 @@ export class BoxService private GetBoxInfo(entity: Entity): BoxInfo { if (entity instanceof Board) - { return entity.BoardProcessOption; - } else if (entity instanceof HardwareCompositeEntity) - { + else if (entity instanceof HardwareCompositeEntity) return entity.HardwareOption; - } else if (entity instanceof HardwareTopline) - { + else if (entity instanceof HardwareTopline) return entity.HardwareOption; - } } } diff --git a/src/Add-on/ShareView/ShareViewStore.ts b/src/Add-on/ShareView/ShareViewStore.ts new file mode 100644 index 000000000..9717c8a44 --- /dev/null +++ b/src/Add-on/ShareView/ShareViewStore.ts @@ -0,0 +1,62 @@ +import { observable, toJS } from "mobx"; + +import { Singleton } from "../../Common/Singleton"; +import { Board } from "../../DatabaseServices/Entity/Board"; +import { DefaultShareBoardInfConfigurationOption } from "../../Editor/DefaultConfig"; +import { IConfigOption } from "../../UI/Components/Board/UserConfigComponent"; +import { ShareBoardInfConfigurationOption } from "../../UI/Store/BoardInterface"; +import { IConfigStore } from '../../UI/Store/BoardStore'; + +interface IProps +{ + /* 是否展示物料明细 */ + showBom?: boolean | null; +} + +export class ShareViewStore extends Singleton implements IConfigStore +{ + @observable + Index: number[] = []; + @observable + RoomName: string; + + @observable + SelectedBoard: Board = null; + + @observable + ViewIDErrorMsg: string = ''; + + // 主题 画布颜色 + @observable + Theme: 'light' | 'dark' | string = 'light'; + + // 纪录上一次 + @observable + ThemeLog: 'light' | 'dark' | string = ''; + + // 后台配置数据 + @observable + Props: IProps = {}; + @observable m_Option: ShareBoardInfConfigurationOption = DefaultShareBoardInfConfigurationOption; + + @observable viewUploadProps: ShareBoardInfConfigurationOption = DefaultShareBoardInfConfigurationOption; + + @observable configName = "默认"; + SaveConfig() + { + //新的配置 + let newConfig: IConfigOption = {}; + newConfig.option = toJS(this.m_Option); + return newConfig; + }; + //板数据 + @observable configsNames: string[] = []; + InitOption() + { + Object.assign(this.m_Option, DefaultShareBoardInfConfigurationOption); + } + UpdateOption(cof: IConfigOption) + { + Object.assign(this.m_Option, cof.option); + } +} diff --git a/src/Add-on/ShareView/index.less b/src/Add-on/ShareView/ShareViewStyle.less similarity index 100% rename from src/Add-on/ShareView/index.less rename to src/Add-on/ShareView/ShareViewStyle.less diff --git a/src/Add-on/ShareView/Util.ts b/src/Add-on/ShareView/ShareViewUtil.ts similarity index 98% rename from src/Add-on/ShareView/Util.ts rename to src/Add-on/ShareView/ShareViewUtil.ts index 886cd408d..820ac3b40 100644 --- a/src/Add-on/ShareView/Util.ts +++ b/src/Add-on/ShareView/ShareViewUtil.ts @@ -16,8 +16,8 @@ import { ICompHardwareOption, IToplineOption } from "../../UI/Components/RightPa import { AppToaster } from "../../UI/Components/Toaster"; import { autoDimBrsStore } from "../DrawDim/AutoDimBrsStore"; import { IsDoor, IsHinge } from "../HideSelect/HideSelectUtils"; -import { BoxInfo, shareViewApp } from "./Service"; -import { BoxStore } from "./Store"; +import { BoxInfo, shareViewApp } from "./ShareViewService"; +import { ShareViewStore } from "./ShareViewStore"; const EmptyToasterShow = (props: IToastProps, key?: string) => null; const ToasterShow = AppToaster.show; @@ -198,7 +198,7 @@ export async function SwitchDoor(visible: boolean) } }; let totalEntitys: Entity[] = []; - for (const i of BoxStore.GetInstance().Index) + for (const i of ShareViewStore.GetInstance().Index) { for (const item of shareViewApp.BoxCtrl.GetEntities(i)) { @@ -353,7 +353,7 @@ export function SPGetSpiteSize(board: Board) // 物料明细表滚动 export function MaterialDetailScrollTo() { - const boxStore = BoxStore.GetInstance(); + const boxStore = ShareViewStore.GetInstance(); if (boxStore.SelectedBoard && document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index)) { document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index).scrollIntoView(true); diff --git a/src/Add-on/ShareView/Store.ts b/src/Add-on/ShareView/Store.ts deleted file mode 100644 index 3e6871055..000000000 --- a/src/Add-on/ShareView/Store.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { observable } from "mobx"; - -import { Singleton } from "../../Common/Singleton"; -import { Board } from "../../DatabaseServices/Entity/Board"; - -interface IProps -{ - /* 是否展示物料明细 */ - IsMaterialDetails?: boolean | null; -} - -export class BoxStore extends Singleton -{ - @observable - Index: number[] = []; - @observable - RoomName: string; - - @observable - SelectedBoard: Board = null; - - @observable - ViewIDErrorMsg: string = ''; - - // 主题 画布颜色 - @observable - Theme: 'light' | 'dark' | string = 'light'; - - // 纪录上一次 - @observable - ThemeLog: 'light' | 'dark' | string = ''; - - // 后台配置数据 - @observable - Props: IProps = {} -} diff --git a/src/Add-on/ShareView/StoreEvent.ts b/src/Add-on/ShareView/StoreEvent.ts index 6b2c2d204..fab88e0d1 100644 --- a/src/Add-on/ShareView/StoreEvent.ts +++ b/src/Add-on/ShareView/StoreEvent.ts @@ -1,10 +1,10 @@ import { intercept } from "mobx"; -import { shareViewApp } from "./Service"; -import { BoxStore } from "./Store"; +import { shareViewApp } from "./ShareViewService"; +import { ShareViewStore } from "./ShareViewStore"; export function SetSelectedBoardChange(before: () => void = null, after: () => void = null) { - const disposer = intercept(BoxStore.GetInstance(), 'SelectedBoard', change => + const disposer = intercept(ShareViewStore.GetInstance(), 'SelectedBoard', change => { before && before(); if (change.newValue) diff --git a/src/Add-on/ShareView/components/BoardHideIcon.tsx b/src/Add-on/ShareView/components/BoardHideIcon.tsx index 0a9fc348b..ce5e6eb37 100644 --- a/src/Add-on/ShareView/components/BoardHideIcon.tsx +++ b/src/Add-on/ShareView/components/BoardHideIcon.tsx @@ -3,14 +3,14 @@ import { useObserver } from 'mobx-react'; import React from 'react'; import { Board } from '../../../DatabaseServices/Entity/Board'; import { Entity } from '../../../DatabaseServices/Entity/Entity'; -import { shareViewApp } from '../Service'; -import { BoxStore } from '../Store'; +import { shareViewApp } from '../ShareViewService'; +import { ShareViewStore } from '../ShareViewStore'; // 隐藏板块 const BoardHideIcon = () => { - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); // 隐藏板 function SetBoxVisibleHide() diff --git a/src/Add-on/ShareView/components/BoardMessageWidget.tsx b/src/Add-on/ShareView/components/BoardMessageWidget.tsx index 2e8a06913..71e8851d2 100644 --- a/src/Add-on/ShareView/components/BoardMessageWidget.tsx +++ b/src/Add-on/ShareView/components/BoardMessageWidget.tsx @@ -1,13 +1,13 @@ import { useObserver } from "mobx-react"; import React from "react"; -import { BoxStore } from "../Store"; -import { SPGetSpiteSize } from "../Util"; +import { ShareViewStore } from "../ShareViewStore"; +import { SPGetSpiteSize } from "../ShareViewUtil"; const BoardMessageWidget = (() => { - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); return useObserver( () => diff --git a/src/Add-on/ShareView/components/CabinetBottomSheet.tsx b/src/Add-on/ShareView/components/CabinetBottomSheet.tsx index 2603a3cc9..113919055 100644 --- a/src/Add-on/ShareView/components/CabinetBottomSheet.tsx +++ b/src/Add-on/ShareView/components/CabinetBottomSheet.tsx @@ -2,10 +2,10 @@ import { Icon } from "@blueprintjs/core"; import React, { forwardRef, useImperativeHandle, useState } from "react"; import { CommandNames } from "../../../Common/CommandNames"; import { commandMachine } from "../../../Editor/CommandMachine"; -import { shareViewApp } from "../Service"; -import { BoxStore } from "../Store"; -import { resetBoxView } from "../Util"; -import { CheckEmptySvg, CheckedSvg } from "./CommonSvgs"; +import { shareViewApp } from "../ShareViewService"; +import { ShareViewStore } from "../ShareViewStore"; +import { resetBoxView } from "../ShareViewUtil"; +import { CheckedSvg, CheckEmptySvg } from "./CommonSvgs"; import { SPToaster } from "./SPToater"; @@ -23,7 +23,7 @@ const CabinetBottomSheet: React.FC = forwardRef((props, ref) => const [selectedTab, setSelectedTab] = useState(''); const [list, setList] = useState({}); const [key, setKey] = useState(0); - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); const [selectAll, setSelectAll] = useState(false); // 判断是否全选状态 diff --git a/src/Add-on/ShareView/components/ColorSelect.css b/src/Add-on/ShareView/components/ColorSelect.css new file mode 100644 index 000000000..6d4b2c573 --- /dev/null +++ b/src/Add-on/ShareView/components/ColorSelect.css @@ -0,0 +1,125 @@ +.container { + position: relative; + min-height: 1.5em; + border: .05em solid #777; + display: flex; + width: 16em; + align-items: center; + gap: .5em; + padding: .5em; + margin-left: .5em; + border-radius: .25em; + outline: none; +} + +.container:focus { + border-color: hsl(200, 100%, 50%); +} + +.value { + flex-grow: 1; + display: flex; + gap: .5em; + flex-wrap: wrap; + align-items: center; +} + +.clear-btn { + background: none; + color: #777; + border: none; + outline: none; + cursor: pointer; + padding: 0; + font-size: 1.25em; +} + +.clear-btn:focus, +.clear-btn:hover { + color: #333; +} + +.divider { + background-color: #777; + align-self: stretch; + width: .05em; +} + +.caret { + translate: 0 25%; + border: .25em solid transparent; + border-top-color: #777; +} + +.options { + position: absolute; + margin: 0; + padding: 0; + list-style: none; + display: none; + max-height: 15em; + overflow-y: auto; + border: .05em solid #777; + border-radius: .25em; + width: 100%; + left: 0; + top: calc(100% + .25em); + background-color: white; + z-index: 100; +} + +.options.show { + display: block; +} + +.option { + display: flex; + align-items: center; + gap: 0.5em; + padding: .25em .5em; + cursor: pointer; +} + +.option.selected { + background-color: hsl(200, 100%, 70%); + color: white; +} + +.option.highlighted { + background-color: hsl(200, 100%, 50%); + color: white +} + +.option-badge { + display: flex; + align-items: center; + border: .05em solid #777; + border-radius: .25em; + padding: .15em .25em; + gap: .25em; + cursor: pointer; + background: none; + outline: none; +} + +.option-badge:hover, +.option-badge:focus { + background-color: hsl(0, 100%, 90%); + border-color: hsl(0, 100%, 50%); +} + +.option-badge:hover>.remove-btn, +.option-badge:focus>.remove-btn { + color: hsl(0, 100%, 50%); +} + +.option-badge>.remove-btn { + font-size: 1.25em; + color: #777; +} + +.container .colorBox { + width: 12px; + height: 12px; + display: inline-block; +} diff --git a/src/Add-on/ShareView/components/ColorSelect.tsx b/src/Add-on/ShareView/components/ColorSelect.tsx new file mode 100644 index 000000000..3ec6c580f --- /dev/null +++ b/src/Add-on/ShareView/components/ColorSelect.tsx @@ -0,0 +1,123 @@ +import React, { useEffect, useRef, useState } from "react"; +import "./ColorSelect.css"; + +export type SelectOption = { + label: string | number; + value: string | number | any; +}; + +type SelectProps = { + onChange: (value: number) => void; + options: SelectOption[]; + value: number; +}; + +export function ColorSelect({ value, onChange, options }: SelectProps) +{ + const [isOpen, setIsOpen] = useState(false); + const [highlightedIndex, setHighlightedIndex] = useState(0); + const containerRef = useRef(null); + + function selectOption(val: number) + { + if (val !== value) onChange(val); + } + + function isOptionSelected(option: number) + { + return option === value; + } + + useEffect(() => + { + if (isOpen) setHighlightedIndex(0); + }, [isOpen]); + + useEffect(() => + { + const handler = (e: KeyboardEvent) => + { + if (e.target != containerRef.current) return; + switch (e.code) + { + case "Enter": + case "Space": + setIsOpen(prev => !prev); + if (isOpen) selectOption(highlightedIndex); + break; + case "ArrowUp": + case "ArrowDown": { + if (!isOpen) + { + setIsOpen(true); + break; + } + + const newValue = highlightedIndex + (e.code === "ArrowDown" ? 1 : -1); + if (newValue >= 0 && newValue < options.length) + { + setHighlightedIndex(newValue); + } + break; + } + case "Escape": + setIsOpen(false); + break; + } + }; + containerRef.current?.addEventListener("keydown", handler); + + return () => + { + containerRef.current?.removeEventListener("keydown", handler); + }; + }, [isOpen, highlightedIndex, options]); + + const IsLightShadow = (rgb: number[]) => + { + const shadow = (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) * rgb[3]; + if (shadow > 192) return true; + return false; + }; + + return ( +
setIsOpen(false)} + onClick={() => setIsOpen(prev => !prev)} + tabIndex={0} + className="container" + > +
+ + {value}. + + +
+
+
+
    + {options.map((option, index) => + { + if (index === options.length - 1) return; + return ( +
  • + { + e.stopPropagation(); + selectOption(index); + setIsOpen(false); + }} + onMouseEnter={() => setHighlightedIndex(index)} + key={option.value} + className={`option ${isOptionSelected(index) ? "selected" : ""} ${index === highlightedIndex ? "highlighted" : ""}`} + > + {option.label}. + +
  • + ); + })} +
+
+ ); +} diff --git a/src/Add-on/ShareView/components/ExplosionMapWidget.tsx b/src/Add-on/ShareView/components/ExplosionMapWidget.tsx index f14295208..011ea4a85 100644 --- a/src/Add-on/ShareView/components/ExplosionMapWidget.tsx +++ b/src/Add-on/ShareView/components/ExplosionMapWidget.tsx @@ -1,6 +1,6 @@ import React, { forwardRef, useImperativeHandle, useRef, useState } from "react"; -import { BoxStore } from "../Store"; -import { ExplosionView } from "../Util"; +import { ShareViewStore } from "../ShareViewStore"; +import { ExplosionView } from "../ShareViewUtil"; interface IProps { @@ -14,7 +14,7 @@ const ExplosionMapWidget: React.FC = forwardRef((props, ref) => { const [state, setState] = useState(false); const loadingRef = useRef(false); - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); async function changeDoorState(num: number) { diff --git a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx index f94204a6e..374857bc0 100644 --- a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx +++ b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx @@ -3,9 +3,9 @@ import { useObserver } from "mobx-react"; import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"; import { Board } from "../../../DatabaseServices/Entity/Board"; import { ICompHardwareOption, IHardwareOption, IToplineOption } from "../../../UI/Components/RightPanel/RightPanelInterface"; -import { shareViewApp } from "../Service"; -import { BoxStore } from "../Store"; -import { GetBoxItemInfo, MaterialDetailScrollTo, SPGetSpiteSize } from "../Util"; +import { shareViewApp } from "../ShareViewService"; +import { ShareViewStore } from "../ShareViewStore"; +import { GetBoxItemInfo, MaterialDetailScrollTo, SPGetSpiteSize } from "../ShareViewUtil"; interface IProps { @@ -28,14 +28,14 @@ const MaterialBottomSheet: React.FC = forwardRef((props, ref) => // 判断是否加载过 const flagRef = useRef(false); const bottomSheetRef = useRef(null); - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); useImperativeHandle(ref, () => ( { show: async () => { flagRef.current = true; - // const temp = GetBoxItemInfo(shareViewApp.BoxCtrl.GetEntities(BoxStore.GetInstance().index)) || []; + // const temp = GetBoxItemInfo(shareViewApp.BoxCtrl.GetEntities(ShareViewStore.GetInstance().index)) || []; const temp = []; boxStore.Index.forEach((i) => { diff --git a/src/Add-on/ShareView/components/ShareBoardInfoConfiguration.tsx b/src/Add-on/ShareView/components/ShareBoardInfoConfiguration.tsx new file mode 100644 index 000000000..497aea2c2 --- /dev/null +++ b/src/Add-on/ShareView/components/ShareBoardInfoConfiguration.tsx @@ -0,0 +1,149 @@ +import { Button, Checkbox, Classes, HTMLSelect, Icon, Intent } from "@blueprintjs/core"; +import { observer } from "mobx-react"; +import React from "react"; +import { begin } from "xaop"; +import { app } from "../../../ApplicationServices/Application"; +import { ColorPalette } from "../../../Common/ColorPalette"; +import { KeyBoard } from "../../../Common/KeyEnum"; +import { BoardModalType } from "../../../UI/Components/Board/BoardModalType"; +import { Config_ModalType, UserConfigComponent } from "../../../UI/Components/Board/UserConfigComponent"; +import { AppToaster } from "../../../UI/Components/Toaster"; +import { ViewAngleTypes, ViewStyleTypes } from "../ShareViewRules"; +import { ShareViewStore } from "../ShareViewStore"; +import { ColorSelect } from "./ColorSelect"; +import "./ShareBoradModal.less"; + +@observer +export class ShareBoardInfoConfiguration extends React.Component<{ store: ShareViewStore; }, {}> +{ + _RemoveFun: Function; + + componentDidMount() + { + this._RemoveFun = begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) => + { + if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space) + app.Editor.ModalManage.Destory(); + e.stopPropagation(); + }); + } + + componentWillUnmount() + { + if (this._RemoveFun) this._RemoveFun(); + } + + BoardAndHadrwareToaster() + { + AppToaster.show({ + message: "板件与五金必选其中一项!", + timeout: 5000, + intent: Intent.DANGER, + }, "shareview"); + } + + render() + { + const option = this.props.store.m_Option; + return ( +
+
+
+ +

分享图设置

+
+
+ 选择分享实体 +
+ + { + if (!option.IsExportHardware && option.IsExportBoard) + { + this.BoardAndHadrwareToaster(); + return; + } + option.IsExportBoard = !option.IsExportBoard; + }} + /> + + { + if (!option.IsExportBoard && option.IsExportHardware) + { + this.BoardAndHadrwareToaster(); + return; + } + option.IsExportHardware = !option.IsExportHardware; + }} + /> + +
+
+ { option.showBom = !option.showBom; }} + /> +
+
+ 真实带线框颜色: + ({ value: rgb, label: index }))} + value={option.Physical2EdgeColor} + onChange={(value) => + { + option.Physical2EdgeColor = value; + }} + /> +
+
+ 视觉角度: + ({ value: v.viewDirection, label: v.name }))} + onChange={(e) => { option.Viewport = parseInt(e.target.value); }} + /> +
+
+ 视觉样式: + ({ value: v.renderType, label: v.title }))} + onChange={(e) => { option.VisualStyle = parseInt(e.target.value); }} + /> +
+
+
+
+ +
+
+
+
+
+
+ ); + } +} diff --git a/src/Add-on/ShareView/components/ShareBoradModal.less b/src/Add-on/ShareView/components/ShareBoradModal.less new file mode 100644 index 000000000..f2d2c5e35 --- /dev/null +++ b/src/Add-on/ShareView/components/ShareBoradModal.less @@ -0,0 +1,21 @@ +#ShareBoardInfoPanel{ + .bp3-dialog-body{ + padding: 10px 20px 0 20px; + background-color: white; + + label{ + width: fit-content; + } + } + + .bp3-dialog-footer{ + background-color: white; + } + + .label{ + display: flex; + gap: 10px; + align-items: center; + margin-bottom: 10px; + } +} diff --git a/src/Add-on/ShareView/components/ShareViewUI.tsx b/src/Add-on/ShareView/components/ShareViewUI.tsx index 2e614643b..f75eb36ae 100644 --- a/src/Add-on/ShareView/components/ShareViewUI.tsx +++ b/src/Add-on/ShareView/components/ShareViewUI.tsx @@ -1,25 +1,26 @@ -import { Provider, useObserver } from "mobx-react"; +import { observer, Provider, useObserver } from "mobx-react"; import React, { useEffect, useRef, useState } from "react"; import { CommandNames } from "../../../Common/CommandNames"; import { Hole } from "../../../DatabaseServices/3DSolid/Hole"; import { commandMachine } from "../../../Editor/CommandMachine"; import { userConfig } from "../../../Editor/UserConfig"; import { IsDoor, IsDrawer, IsHandle, IsLattice } from "../../HideSelect/HideSelectUtils"; -import { shareViewApp } from "../Service"; -import { BoxStore } from "../Store"; -import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ForbiddenToaster, SwitchDoor, resetBoxView } from "../Util"; import "../index.less"; +import { shareViewApp } from "../ShareViewService"; +import { ShareViewStore } from "../ShareViewStore"; +import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ForbiddenToaster, resetBoxView, SwitchDoor } from "../ShareViewUtil"; import BoardMessageWidget from "./BoardMessageWidget"; import CabinetBottomSheet from "./CabinetBottomSheet"; import ExplosionMapWidget from "./ExplosionMapWidget"; import MaterialBottomSheet from "./MaterialBottomSheet"; -import { SPToaster } from "./SPToater"; import SideBar from "./SideBar"; +import { SPToaster } from "./SPToater"; import ViewAngle from "./ViewAngle"; import ViewIDErrorWidget from "./ViewIDErrorWidget"; import ViewStyle from "./ViewStyle"; -export function ShareViewUI() + +function ShareViewUI() { // 选择柜体 // const [selectCabinet, setSelectCabinet] = useState(false); @@ -34,11 +35,10 @@ export function ShareViewUI() // 显示隐藏标注 const [dimBrsState, setDimBrsState] = useState(false); - const viewStyleRef = useRef(null); const cabinetBottomSheetRef = useRef(null); const explosionMapWidgetRef = useRef(null); const materialBottomSheetRef = useRef(null); - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); // 按下 esc function escKeyDown(event) @@ -233,14 +233,14 @@ export function ShareViewUI() { return ( <> - {boxStore.Props.IsMaterialDetails == false ? null : ( + {boxStore.Props.showBom == false ? null : (
{ materialBottomSheetRef.current.show(); }} - >物料明细{boxStore.Props.IsMaterialDetails}
+ >物料明细{boxStore.Props.showBom} )} ); @@ -250,7 +250,7 @@ export function ShareViewUI() return ( - +
@@ -285,12 +285,14 @@ export function ShareViewUI() {/* 顶部栏 */}
- - - { - await closeDoor(); - await explosionMapWidgetRef.current.reset(); - }} ref={viewStyleRef}> + + + { + await closeDoor(); + await explosionMapWidgetRef.current.reset(); + }} + currentRenderType={boxStore.viewUploadProps.VisualStyle} />
标注
{/*
编号
*/}
@@ -323,3 +325,5 @@ export function ShareViewUI() ); } + +export default observer(ShareViewUI); diff --git a/src/Add-on/ShareView/components/SideBar.tsx b/src/Add-on/ShareView/components/SideBar.tsx index 526c22531..9b50d7b32 100644 --- a/src/Add-on/ShareView/components/SideBar.tsx +++ b/src/Add-on/ShareView/components/SideBar.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { CommandNames } from '../../../Common/CommandNames'; import { commandMachine } from '../../../Editor/CommandMachine'; -import { shareViewApp } from '../Service'; -import { resetBoxView } from '../Util'; +import { shareViewApp } from '../ShareViewService'; +import { resetBoxView } from '../ShareViewUtil'; import BoardHideIcon from './BoardHideIcon'; import ShareWidget from './ShareWidget'; import ThemeButton from './ThemeButton'; diff --git a/src/Add-on/ShareView/components/ThemeButton.tsx b/src/Add-on/ShareView/components/ThemeButton.tsx index a81436ce4..5a7b3aac9 100644 --- a/src/Add-on/ShareView/components/ThemeButton.tsx +++ b/src/Add-on/ShareView/components/ThemeButton.tsx @@ -1,12 +1,12 @@ import { useObserver } from "mobx-react"; import React from "react"; -import { shareViewApp } from "../Service"; -import { BoxStore } from "../Store"; -import { ChangeThemeColor } from "../Util"; +import { shareViewApp } from "../ShareViewService"; +import { ShareViewStore } from "../ShareViewStore"; +import { ChangeThemeColor } from "../ShareViewUtil"; function ThemeButton() { - const boxStore: BoxStore = BoxStore.GetInstance(); + const boxStore: ShareViewStore = ShareViewStore.GetInstance(); function changeTheme() { const t = boxStore.Theme === 'light' ? 'dark' : 'light'; diff --git a/src/Add-on/ShareView/components/ViewAngle.tsx b/src/Add-on/ShareView/components/ViewAngle.tsx index e8d75db98..7ea6835eb 100644 --- a/src/Add-on/ShareView/components/ViewAngle.tsx +++ b/src/Add-on/ShareView/components/ViewAngle.tsx @@ -1,48 +1,18 @@ -import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"; -import { CommandNames } from "../../../Common/CommandNames"; +import React, { forwardRef, useEffect, useRef, useState } from "react"; import { commandMachine } from "../../../Editor/CommandMachine"; -import { shareViewApp } from "../Service"; -import { ForbiddenToaster, resetBoxView } from "../Util"; +import { ViewDirection } from "../../../UI/Store/BoardInterface"; +import { ViewAngleTypes } from "../ShareViewRules"; +import { shareViewApp } from "../ShareViewService"; +import { ForbiddenToaster, resetBoxView } from "../ShareViewUtil"; interface IProps { closeDoor: Function; - ref: React.Ref; + currentViewDirection: ViewDirection; } - -const ViewAngle: React.FC = forwardRef((props, ref) => +const ViewAngle: React.FC = forwardRef((props) => { - const types = [ - { - command: CommandNames.FS, - name: "俯视", - }, - { - command: CommandNames.YS, - name: "右视", - }, - { - command: CommandNames.ZS, - name: "左视", - }, - { - command: CommandNames.QS, - name: "前视", - }, - { - command: CommandNames.BottomView, - name: "仰视", - }, - { - command: CommandNames.BackView, - name: "后视", - }, - { - command: CommandNames.Swiso, - name: "西南等轴测", - }, - ]; const [visible, setVisible] = useState(false); const [selected, setSelected] = useState(''); const selectDivRef = useRef(); @@ -50,13 +20,16 @@ const ViewAngle: React.FC = forwardRef((props, ref) => const hideSelect = (e) => { if (e.target != selectDivRef.current) - { - setSelected(''); setVisible(false); - } - }; + function checkViewDirection(viewDirection: ViewDirection): number + { + const viewAngleTypesIndex = ViewAngleTypes.findIndex(v => v.viewDirection === viewDirection); + if (viewAngleTypesIndex > -1) return viewAngleTypesIndex; + return 0; + } + useEffect(() => { document.addEventListener('click', hideSelect, false); @@ -71,14 +44,12 @@ const ViewAngle: React.FC = forwardRef((props, ref) => }; }, []); - useImperativeHandle(ref, () => ( - { - hide: () => - { - setVisible(false); - }, - } - )); + useEffect(() => + { + if (props.currentViewDirection) + setSelected(ViewAngleTypes[checkViewDirection(props.currentViewDirection)].name); + return () => { setSelected(""); }; + }, [props.currentViewDirection]); function stopPropagation(e) { @@ -94,14 +65,15 @@ const ViewAngle: React.FC = forwardRef((props, ref) => { setVisible(!visible); }} - >视角
+ > + 视角 +
    - {types.map((item) => + {ViewAngleTypes.map((item) => { return (
  • = forwardRef((props, ref) => }); setSelected(item.name); - }}>{item.name}
  • + }} + > + {item.name} + ); })}
diff --git a/src/Add-on/ShareView/components/ViewIDErrorWidget.tsx b/src/Add-on/ShareView/components/ViewIDErrorWidget.tsx index 174bebdc7..2d4309b25 100644 --- a/src/Add-on/ShareView/components/ViewIDErrorWidget.tsx +++ b/src/Add-on/ShareView/components/ViewIDErrorWidget.tsx @@ -1,7 +1,7 @@ import { Icon } from "@blueprintjs/core"; import { useObserver } from "mobx-react"; import React from "react"; -import { BoxStore } from "../Store"; +import { ShareViewStore } from "../ShareViewStore"; const ViewIDErrorWidget = () => @@ -10,10 +10,10 @@ const ViewIDErrorWidget = () => () => { return ( - <>{BoxStore.GetInstance().ViewIDErrorMsg ? ( + <>{ShareViewStore.GetInstance().ViewIDErrorMsg ? (
-
{BoxStore.GetInstance().ViewIDErrorMsg}
+
{ShareViewStore.GetInstance().ViewIDErrorMsg}
) : <> } diff --git a/src/Add-on/ShareView/components/ViewStyle.tsx b/src/Add-on/ShareView/components/ViewStyle.tsx index a0ac5d444..01ae4b5a3 100644 --- a/src/Add-on/ShareView/components/ViewStyle.tsx +++ b/src/Add-on/ShareView/components/ViewStyle.tsx @@ -1,49 +1,17 @@ -import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"; -import { CommandNames } from "../../../Common/CommandNames"; +import React, { forwardRef, useEffect, useRef, useState } from "react"; import { commandMachine } from "../../../Editor/CommandMachine"; -import { ForbiddenToaster } from "../Util"; +import { RenderType } from "../../../GraphicsSystem/RenderType"; +import { ViewStyleTypes } from "../ShareViewRules"; +import { ForbiddenToaster } from "../ShareViewUtil"; interface IProps { reset: Function; - ref: React.Ref; + currentRenderType: RenderType; } - -const ViewStyle: React.FC = forwardRef((props, ref) => +const ViewStyle: React.FC = forwardRef((props) => { - const types = [ - { - title: "二维线框", - cmd: CommandNames.Wireframe, - renderType: 1, - }, - { - title: "概念", - cmd: CommandNames.Conceptual, - renderType: 2, - }, - { - title: "真实", - cmd: CommandNames.Physical, - renderType: 3, - }, - { - title: "真实带线框", - cmd: CommandNames.Physical2, - renderType: 6, - }, - { - title: "排版面", - cmd: CommandNames.CheckPlaceFace, - renderType: 8, - }, - { - title: "概念(透明)", - cmd: CommandNames.ConceptualTransparent, - renderType: 2, - }, - ]; const [visible, setVisible] = useState(false); const [selected, setSelected] = useState('概念'); const selectDivRef = useRef(); @@ -51,20 +19,13 @@ const ViewStyle: React.FC = forwardRef((props, ref) => const hideSelect = (e) => { if (e.target != selectDivRef.current) - { setVisible(false); - } }; - function checkRenderType(renderType) + function checkRenderType(renderType: RenderType): number { - for (let i = 0; i < types.length; i++) - { - if (`${types[i].renderType}` == `${renderType}`) - { - return i; - } - } + const viewStyleIndex = ViewStyleTypes.findIndex(v => v.renderType === renderType); + if (viewStyleIndex > -1) return viewStyleIndex; return 0; } @@ -73,14 +34,7 @@ const ViewStyle: React.FC = forwardRef((props, ref) => document.addEventListener('click', hideSelect, false); document.addEventListener('touchstart', hideSelect, false); document.addEventListener('mousedown', hideSelect, false); - const renderType: string | null = localStorage.getItem('renderType'); - if (renderType) - { - setSelected(types[checkRenderType(renderType)].title); - } else - { - commandMachine.ExecCommand(CommandNames.Conceptual); - } + return () => { document.removeEventListener('click', hideSelect, false); @@ -89,14 +43,12 @@ const ViewStyle: React.FC = forwardRef((props, ref) => }; }, []); - useImperativeHandle(ref, () => ( - { - hide: () => - { - setVisible(false); - }, - } - )); + useEffect(() => + { + if (props.currentRenderType) + setSelected(ViewStyleTypes[checkRenderType(props.currentRenderType)].title); + return () => { setSelected(""); }; + }, [props.currentRenderType]); function stopPropagation(e) { @@ -116,9 +68,8 @@ const ViewStyle: React.FC = forwardRef((props, ref) => onTouchStart={stopPropagation} onMouseDown={stopPropagation} onClick={stopPropagation} - > - {types.map((item) => + {ViewStyleTypes.map((item) => { return (
  • = forwardRef((props, ref) => await commandMachine.ExecCommand(item.cmd); }); setSelected(item.title); - - }}>{item.title}
  • + }} + >{item.title} ); })} diff --git a/src/Common/ColorPalette.ts b/src/Common/ColorPalette.ts index 5052aa9f1..56750b747 100644 --- a/src/Common/ColorPalette.ts +++ b/src/Common/ColorPalette.ts @@ -3,7 +3,7 @@ import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial'; import { HostApplicationServices } from '../ApplicationServices/HostApplicationServices'; import { GetGoodShaderSimple } from '../GLSL/GoochShader'; -const ColorPalette = [ +export const ColorPalette = [ [0, 0, 0, 0], //----- 0 - lets make it red for an example //[255, 255, 255, 255],//----- 0 - ByBlock - White [255, 0, 0, 255], //----- 1 - Red diff --git a/src/Editor/DefaultConfig.ts b/src/Editor/DefaultConfig.ts index 0ad549640..2e8f54712 100644 --- a/src/Editor/DefaultConfig.ts +++ b/src/Editor/DefaultConfig.ts @@ -6,11 +6,11 @@ import { IUpdateBoardInfosOption } from "../UI/Components/Board/UpdateBoardInfoi import { EMetalsType, ICompHardwareOption, ICylMetalsOption, IExtMetalsOption, IToplineOption } from "../UI/Components/RightPanel/RightPanelInterface"; import { IKuGangDrawOption } from "../UI/Components/Template/TemplateInterface"; import { ECompareType, IBoardFindOption } from "../UI/Store/BoardFindInterface"; -import { BehindBoardOption, BehindHeightPositon, BoardProcessOption, BoardType, BrRelativePos, ChangeColorByBoardMaterialOption, ClosingStripOption, CommonPanelConfigOption, ComposingType, CurtailType, FaceDirection, IAutoDimBrsOption, IBatchModifyPanelOption, IBoardBatchCurtailOption, IDimStyleOption, LayerBoardOption, LayerNailOption, LinesType, ModifyTextsConfigOption, PointLightOption, RadioType, RectAreaLightOption, RightPlaneLightOption, SideBoardOption, SingleBoardOption, SpotLightOption, StripType, TBBoardOption, VerticalBoardOption, ViewDirection, Viewport2ConfigOption, Viewport3ConfigOption, Viewport4ConfigOption, ViewportConfigOption, ViewportPosition, WindowPanelConfigOption } from "../UI/Store/BoardInterface"; +import { BehindBoardOption, BehindHeightPositon, BoardProcessOption, BoardType, BrRelativePos, ChangeColorByBoardMaterialOption, ClosingStripOption, CommonPanelConfigOption, ComposingType, CurtailType, FaceDirection, IAutoDimBrsOption, IBatchModifyPanelOption, IBoardBatchCurtailOption, IDimStyleOption, LayerBoardOption, LayerNailOption, LinesType, ModifyTextsConfigOption, PointLightOption, RadioType, RectAreaLightOption, RightPlaneLightOption, ShareBoardInfConfigurationOption, SideBoardOption, SingleBoardOption, SpotLightOption, StripType, TBBoardOption, VerticalBoardOption, ViewDirection, Viewport2ConfigOption, Viewport3ConfigOption, Viewport4ConfigOption, ViewportConfigOption, ViewportPosition, WindowPanelConfigOption } from "../UI/Store/BoardInterface"; import { DoorPosType, HandleHorPos, HandleVePos, IDoorConfigOption, IDrawerConfigOption, IHingeConfigOption } from "../UI/Store/DoorInterface"; import { IHSOption } from "../UI/Store/HSInterface"; import { ELatticeArrayType, ILatticeOption } from "../UI/Store/LatticeInterface"; -import { EFullDir, EFullType, EWRackArrayType, EWineRackStyle, EWineRackType, IWineRackOption } from "../UI/Store/WineRackInterface"; +import { EFullDir, EFullType, EWineRackStyle, EWineRackType, EWRackArrayType, IWineRackOption } from "../UI/Store/WineRackInterface"; import { EOrderType } from "./OrderType"; export const DefaultLayerBoardConfig: LayerBoardOption = { @@ -929,3 +929,13 @@ export const DefaultChangeColorByBoardMaterialOption: ChangeColorByBoardMaterial accordMaterialName: true }; Object.freeze(DefaultChangeColorByBoardMaterialOption); + +export const DefaultShareBoardInfConfigurationOption: ShareBoardInfConfigurationOption = { + Physical2EdgeColor: 7, + VisualStyle: RenderType.Conceptual, + Viewport: ViewDirection.Southwest, + IsExportBoard: true, + IsExportHardware: true, + showBom: true, +}; +Object.freeze(DefaultShareBoardInfConfigurationOption); diff --git a/src/GraphicsSystem/RenderType.ts b/src/GraphicsSystem/RenderType.ts index c7317191e..d9cf3c2e5 100644 --- a/src/GraphicsSystem/RenderType.ts +++ b/src/GraphicsSystem/RenderType.ts @@ -50,6 +50,8 @@ export enum RenderType /**真实带线框 */ Physical2Print = 106, CustomNumberPrint = 109, + + ConceptualTransparent = 182//概念透明 } export function IsPhysical(renderType: RenderType) diff --git a/src/UI/Components/Board/BoardModalType.ts b/src/UI/Components/Board/BoardModalType.ts index 8552ac5b2..98590e466 100644 --- a/src/UI/Components/Board/BoardModalType.ts +++ b/src/UI/Components/Board/BoardModalType.ts @@ -41,6 +41,7 @@ export enum BoardModalType AutoDimBrs = "AutoDimBrs", SelectThinBehindBoard = "SelectThinBehindBoard", ChangeColorByBoardMaterial = "ChangeColorByMaterial", + ShareBoardInfoUpdateConfiguration = "ShareBoardInfoSettings", ModifyTexts = "ModifyTexts", Viewport = "Viewport", Viewport2 = "Viewport2", diff --git a/src/UI/Css/golden.less b/src/UI/Css/golden.less index 5836cc6cf..5cc92bb7e 100644 --- a/src/UI/Css/golden.less +++ b/src/UI/Css/golden.less @@ -240,7 +240,7 @@ background-color: @properties_header_bg; } .resources ul li{ - background-color: @fileName_bg; + background-color: @fileName_bg; } } } @@ -248,7 +248,18 @@ //画廊 .GalleryIndexList{ .GalleryIndexListHeader{ - background-color: @fileName_bg; + background-color: @fileName_bg; + } + } + + //分享图设置 + #ShareBoardInfoPanel{ + .container{ + background-color: @verticalTab_selected_bg; + } + + .options{ + background-color: @verticalTab_selected_bg; } } } diff --git a/src/UI/Store/BoardInterface.ts b/src/UI/Store/BoardInterface.ts index 7f6697f24..8d9bef2cb 100644 --- a/src/UI/Store/BoardInterface.ts +++ b/src/UI/Store/BoardInterface.ts @@ -158,7 +158,7 @@ export interface BoardConfigOption extends IBaseOption thickness?: number; height?: number; width?: number; - openDir?: BoardOpenDir + openDir?: BoardOpenDir; } export interface LightConfigOption extends IBaseOption @@ -577,3 +577,13 @@ export interface ChangeColorByBoardMaterialOption accordMaterialName: boolean; accordMaterialColor: boolean; } + +export interface ShareBoardInfConfigurationOption +{ + Physical2EdgeColor: number; //真实带线框颜色 + VisualStyle: RenderType; //视觉样式 + Viewport: ViewDirection; //视觉角度 + IsExportBoard: boolean; //是否导出板件 + IsExportHardware: boolean; //是否导出五金 + showBom: boolean; //是否展示物料明细 +}