!2204 新增:分享图纸导出配置

pull/2211/MERGE
林伟强 1 year ago committed by ChenX
parent 6717dbcc71
commit 9c243e918c

@ -7,6 +7,8 @@
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.insertSpaces": true, "editor.insertSpaces": true,
"editor.detectIndentation": false, "editor.detectIndentation": false,
//git
"git.rebaseWhenSync": true,
// //
"typescript.format.placeOpenBraceOnNewLineForFunctions": true, "typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true, "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,

@ -5,33 +5,76 @@ import { deflate, GetCurrentViewPreViewImage } from "../../Common/SerializeMater
import { Intent } from "../../Common/Toaster"; import { Intent } from "../../Common/Toaster";
import { CADFiler } from "../../DatabaseServices/CADFiler"; import { CADFiler } from "../../DatabaseServices/CADFiler";
import { Database } from "../../DatabaseServices/Database"; import { Database } from "../../DatabaseServices/Database";
import { Board } from "../../DatabaseServices/Entity/Board";
import { EntityRef } from "../../DatabaseServices/Entity/EntityRef"; import { EntityRef } from "../../DatabaseServices/Entity/EntityRef";
import { FileServer } from "../../DatabaseServices/FileServer"; import { FileServer } from "../../DatabaseServices/FileServer";
import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity";
import { HardwareTopline } from "../../DatabaseServices/Hardware/HardwareTopline";
import { Command } from "../../Editor/CommandMachine"; 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 { AppToaster } from "../../UI/Components/Toaster";
import { Purge } from "../Purge"; import { Purge } from "../Purge";
import { ShareBoardInfoConfiguration } from "./components/ShareBoardInfoConfiguration";
import { ShareViewStore } from "./ShareViewStore";
const barringKeyWord = { msg: "分享图设置", key: "S" };
export class Command_ShareView implements Command export class Command_ShareView implements Command
{ {
async exec() async exec()
{ {
// 参考 SuperCopy 命令 let store: ShareViewStore = ShareViewStore.GetInstance();
let ssRes = await app.Editor.GetSelection({ let config = new DialogUserConfig(store, BoardModalType.ShareBoardInfoUpdateConfiguration);
await config.LoadAndInitConfig();//载入或者初始化
let ssRes: PromptSsgetResult;
while (true)
{
ssRes = await app.Editor.GetSelection({
KeyWordList: [barringKeyWord],
Msg: "请选择需要分享的柜子:", Msg: "请选择需要分享的柜子:",
UseSelect: true, UseSelect: true,
Filter: { Filter: {
filterFunction: (obj, ent) => !(ent instanceof DirectionalLight || ent instanceof EntityRef), //避免拷贝太阳光 太阳光只能有一个 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.OK) return; if (ssRes.Status === PromptStatus.Cancel)
return;
let f = new CADFiler(); else if (ssRes.Status === PromptStatus.Keyword)
app.Database.FileWrite(f); {
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(); let ents = new Set();
for (let e of ssRes.SelectSet.SelectEntityList) for (let e of ssRes.SelectSet.SelectEntityList)
{
hasBrOrHardw = hasBrOrHardw || (e instanceof Board || e instanceof HardwareCompositeEntity || e instanceof HardwareTopline);
ents.add(e.Id.Index); 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); let db = new Database(false, false, true);
db.FileRead(f); db.FileRead(f);
@ -47,11 +90,14 @@ export class Command_ShareView implements Command
f = new CADFiler; f = new CADFiler;
db.FileWrite(f); db.FileWrite(f);
const props = JSON.stringify({ showBom: store.m_Option.showBom });
const formData = new FormData(); const formData = new FormData();
let fileServer = FileServer.GetInstance() as FileServer; let fileServer = FileServer.GetInstance() as FileServer;
formData.append("name", fileServer.currentFileInfo.name); formData.append("name", fileServer.currentFileInfo.name);
formData.append("logo", GetCurrentViewPreViewImage(), "cover.jpg"); formData.append("logo", GetCurrentViewPreViewImage(), "cover.jpg");
formData.append("file", deflate(f.ToString())); formData.append("file", deflate(f.ToString()));
formData.append("props", props);
fetch(CURRENT_HOST + "/CAD-viewerUpload", { fetch(CURRENT_HOST + "/CAD-viewerUpload", {
method: "POST", method: "POST",
@ -64,7 +110,7 @@ export class Command_ShareView implements Command
var result = JSON.parse(await res.text()); var result = JSON.parse(await res.text());
if (result.err_code == 0) 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({ AppToaster.show({
message: "分享成功!", message: "分享成功!",
timeout: 5000, timeout: 5000,

@ -2,10 +2,11 @@ import { Cache, Layers, Object3D } from "three";
import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices";
import { CommandNames } from "../../Common/CommandNames"; import { CommandNames } from "../../Common/CommandNames";
import { ErrorMonitoring } from "../../Common/ErrorMonitoring"; import { ErrorMonitoring } from "../../Common/ErrorMonitoring";
import { safeEval } from "../../Common/eval";
import { CURRENT_HOST } from "../../Common/HostUrl"; import { CURRENT_HOST } from "../../Common/HostUrl";
import { inflateBase64 } from "../../Common/inflate";
import { LogEnable, ReportErrorWrap } from "../../Common/Log"; import { LogEnable, ReportErrorWrap } from "../../Common/Log";
import { RequestStatus } from "../../Common/Request"; import { RequestStatus } from "../../Common/Request";
import { inflateBase64 } from "../../Common/inflate";
import { CADFiler } from "../../DatabaseServices/CADFiler"; import { CADFiler } from "../../DatabaseServices/CADFiler";
import { commandMachine } from "../../Editor/CommandMachine"; import { commandMachine } from "../../Editor/CommandMachine";
import { userConfig } from "../../Editor/UserConfig"; import { userConfig } from "../../Editor/UserConfig";
@ -14,9 +15,10 @@ import "../../UI/Css/blue.less";
import "../../UI/Css/golden.less"; import "../../UI/Css/golden.less";
import "../../UI/Css/style.less"; import "../../UI/Css/style.less";
import "../../UI/Css/switchTheme.less"; import "../../UI/Css/switchTheme.less";
import { ShareViewLayout } from "./Layout"; import { ShareViewLayout } from "./ShareViewLayout";
import { BoxStore } from "./Store"; import { ViewAngleTypes, ViewStyleTypes } from "./ShareViewRules";
import { ChangeThemeColor, GetBoxCovers, resetBoxView } from "./Util"; import { ShareViewStore } from "./ShareViewStore";
import { ChangeThemeColor, GetBoxCovers, resetBoxView } from "./ShareViewUtil";
Cache.enabled = true; Cache.enabled = true;
@ -191,7 +193,7 @@ window.onload = function ()
// 修改默认为概念渲染 // 修改默认为概念渲染
commandMachine.ExecCommand(CommandNames.Conceptual); commandMachine.ExecCommand(CommandNames.Conceptual);
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
try try
{ {
@ -199,7 +201,7 @@ window.onload = function ()
{ {
if (cadFile) if (cadFile)
{ {
commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测 // commandMachine.ExecCommand(CommandNames.Swiso); // 设置默认视图为 西南等轴测
layout.app.LoadFile(cadFile).then(async () => layout.app.LoadFile(cadFile).then(async () =>
{ {
setTimeout(async () => setTimeout(async () =>
@ -261,9 +263,12 @@ window.onload = function ()
async function LoadData() async function LoadData()
{ {
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
let urlSearch = new URLSearchParams(location.search); let urlSearch = new URLSearchParams(location.search);
let viewId = urlSearch.get('view_id'); let viewId = urlSearch.get('view_id');
InitShareConfiguration(urlSearch);
if (viewId) if (viewId)
{ {
let res = await fetch(CURRENT_HOST + '/CAD-viewerDetail?view_id=' + viewId, { let res = await fetch(CURRENT_HOST + '/CAD-viewerDetail?view_id=' + viewId, {
@ -293,3 +298,27 @@ async function LoadData()
boxStore.ViewIDErrorMsg = `url缺少view_id参数`; 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;
}

@ -15,8 +15,8 @@ import { MouseUI } from '../../Editor/TouchEditor/MouseUIComp';
import { VirtualKeys } from '../../Editor/TouchEditor/VirtualKeysComp'; import { VirtualKeys } from '../../Editor/TouchEditor/VirtualKeysComp';
import { CameraControlBtn } from '../../UI/Components/CameraControlButton/CameraControlBtn'; import { CameraControlBtn } from '../../UI/Components/CameraControlButton/CameraControlBtn';
import { ShowLinesToaster, __AppToasterShowEntityMsg } from '../../UI/Components/Toaster'; import { ShowLinesToaster, __AppToasterShowEntityMsg } from '../../UI/Components/Toaster';
import { ShareViewUI } from './components/ShareViewUI'; import ShareViewUI from './components/ShareViewUI';
import { ShareViewService } from './Service'; import { ShareViewService } from './ShareViewService';
// export let appUi: ShareViewLayout; // export let appUi: ShareViewLayout;

@ -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,
},
];

@ -1,7 +1,7 @@
import Dimension from "dxf-parser/dist/entities/dimension"; import Dimension from "dxf-parser/dist/entities/dimension";
import { Object3D } from "three"; import { Object3D } from "three";
import { begin, end } from "xaop"; import { begin, end } from "xaop";
import { ApplicationService } from "../../ApplicationServices/Application"; import { app, ApplicationService } from "../../ApplicationServices/Application";
import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices";
import { EBoardKeyList } from "../../Common/BoardKeyList"; import { EBoardKeyList } from "../../Common/BoardKeyList";
import { CommandNames } from "../../Common/CommandNames"; import { CommandNames } from "../../Common/CommandNames";
@ -39,9 +39,9 @@ import { ShowToasterClearSiteData } from "../../UI/Components/ToasterClearSiteDa
import { DownPanelStore } from "../../UI/Store/DownPanelStore"; import { DownPanelStore } from "../../UI/Store/DownPanelStore";
import { HardwareCuttingReactor } from "../BoardCutting/HardwareCuttingReactor"; import { HardwareCuttingReactor } from "../BoardCutting/HardwareCuttingReactor";
import { DrillingReactor } from "../DrawDrilling/DrillingReactor"; import { DrillingReactor } from "../DrawDrilling/DrillingReactor";
import { BoxStore } from "./Store"; import { ShareViewStore } from "./ShareViewStore";
import { MaterialDetailScrollTo } from "./ShareViewUtil";
import { SetSelectedBoardChange } from "./StoreEvent"; import { SetSelectedBoardChange } from "./StoreEvent";
import { MaterialDetailScrollTo } from "./Util";
export let shareViewApp: ShareViewService; export let shareViewApp: ShareViewService;
export class ShareViewService extends ApplicationService export class ShareViewService extends ApplicationService
{ {
@ -87,11 +87,11 @@ export class ShareViewService extends ApplicationService
let currentItem = this.Editor.SelectCtrl.SelectSet.SelectEntityList[0]; let currentItem = this.Editor.SelectCtrl.SelectSet.SelectEntityList[0];
if (currentItem instanceof Board) if (currentItem instanceof Board)
{ {
BoxStore.GetInstance().SelectedBoard = currentItem; ShareViewStore.GetInstance().SelectedBoard = currentItem;
MaterialDetailScrollTo(); MaterialDetailScrollTo();
} else } else
{ {
BoxStore.GetInstance().SelectedBoard = null; ShareViewStore.GetInstance().SelectedBoard = null;
} }
}); });
SetSelectedBoardChange(null, () => SetSelectedBoardChange(null, () =>
@ -276,7 +276,7 @@ export class ShareViewService extends ApplicationService
{ {
this.OpenFile(f); this.OpenFile(f);
this.BoxCtrl = new BoxService(); this.BoxCtrl = new BoxService();
await this.BoxCtrl.Init(this.Editor); await this.BoxCtrl.Init();
} }
} }
@ -300,19 +300,17 @@ export class BoxService
{ {
return this._BoxList; return this._BoxList;
} }
async Init(editor: Editor) async Init()
{ {
await commandMachine.ExecCommand(CommandNames.SelectAll); await commandMachine.ExecCommand(CommandNames.SelectAll);
let enRes = await editor.GetSelection({ let ens: Entity[] = [];
UseSelect: true, for (let e of app.Database.ModelSpace.Entitys)
Filter: {
filterFunction: (o, e: Entity) =>
{ {
return e instanceof Board || e instanceof HardwareCompositeEntity || e instanceof HardwareTopline || e instanceof Dimension; if (e.IsErase) continue;
}, if (e instanceof Board || e instanceof HardwareCompositeEntity || e instanceof HardwareTopline || e instanceof Dimension)
}, ens.push(e);
}); }
enRes.SelectSet.SelectEntityList.forEach((entity) => ens.forEach((entity) =>
{ {
if (entity instanceof Dimension) if (entity instanceof Dimension)
{ {
@ -333,8 +331,12 @@ export class BoxService
// this.SetBoxVisible(this._BoxList.length - 1, false); // 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) SetBoxVisible(index: number, visible: boolean)
{ {
@ -387,14 +389,10 @@ export class BoxService
private GetBoxInfo(entity: Entity): BoxInfo private GetBoxInfo(entity: Entity): BoxInfo
{ {
if (entity instanceof Board) if (entity instanceof Board)
{
return entity.BoardProcessOption; return entity.BoardProcessOption;
} else if (entity instanceof HardwareCompositeEntity) else if (entity instanceof HardwareCompositeEntity)
{
return entity.HardwareOption; return entity.HardwareOption;
} else if (entity instanceof HardwareTopline) else if (entity instanceof HardwareTopline)
{
return entity.HardwareOption; return entity.HardwareOption;
} }
}
} }

@ -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<ShareBoardInfConfigurationOption>)
{
Object.assign(this.m_Option, cof.option);
}
}

@ -16,8 +16,8 @@ import { ICompHardwareOption, IToplineOption } from "../../UI/Components/RightPa
import { AppToaster } from "../../UI/Components/Toaster"; import { AppToaster } from "../../UI/Components/Toaster";
import { autoDimBrsStore } from "../DrawDim/AutoDimBrsStore"; import { autoDimBrsStore } from "../DrawDim/AutoDimBrsStore";
import { IsDoor, IsHinge } from "../HideSelect/HideSelectUtils"; import { IsDoor, IsHinge } from "../HideSelect/HideSelectUtils";
import { BoxInfo, shareViewApp } from "./Service"; import { BoxInfo, shareViewApp } from "./ShareViewService";
import { BoxStore } from "./Store"; import { ShareViewStore } from "./ShareViewStore";
const EmptyToasterShow = (props: IToastProps, key?: string) => null; const EmptyToasterShow = (props: IToastProps, key?: string) => null;
const ToasterShow = AppToaster.show; const ToasterShow = AppToaster.show;
@ -198,7 +198,7 @@ export async function SwitchDoor(visible: boolean)
} }
}; };
let totalEntitys: Entity[] = []; 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)) for (const item of shareViewApp.BoxCtrl.GetEntities(i))
{ {
@ -353,7 +353,7 @@ export function SPGetSpiteSize(board: Board)
// 物料明细表滚动 // 物料明细表滚动
export function MaterialDetailScrollTo() export function MaterialDetailScrollTo()
{ {
const boxStore = BoxStore.GetInstance(); const boxStore = ShareViewStore.GetInstance();
if (boxStore.SelectedBoard && document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index)) if (boxStore.SelectedBoard && document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index))
{ {
document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index).scrollIntoView(true); document.querySelector('.sp-anchor-' + boxStore.SelectedBoard.objectId.Index).scrollIntoView(true);

@ -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 = {}
}

@ -1,10 +1,10 @@
import { intercept } from "mobx"; import { intercept } from "mobx";
import { shareViewApp } from "./Service"; import { shareViewApp } from "./ShareViewService";
import { BoxStore } from "./Store"; import { ShareViewStore } from "./ShareViewStore";
export function SetSelectedBoardChange(before: () => void = null, after: () => void = null) 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(); before && before();
if (change.newValue) if (change.newValue)

@ -3,14 +3,14 @@ import { useObserver } from 'mobx-react';
import React from 'react'; import React from 'react';
import { Board } from '../../../DatabaseServices/Entity/Board'; import { Board } from '../../../DatabaseServices/Entity/Board';
import { Entity } from '../../../DatabaseServices/Entity/Entity'; import { Entity } from '../../../DatabaseServices/Entity/Entity';
import { shareViewApp } from '../Service'; import { shareViewApp } from '../ShareViewService';
import { BoxStore } from '../Store'; import { ShareViewStore } from '../ShareViewStore';
// 隐藏板块 // 隐藏板块
const BoardHideIcon = () => const BoardHideIcon = () =>
{ {
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
// 隐藏板 // 隐藏板
function SetBoxVisibleHide() function SetBoxVisibleHide()

@ -1,13 +1,13 @@
import { useObserver } from "mobx-react"; import { useObserver } from "mobx-react";
import React from "react"; import React from "react";
import { BoxStore } from "../Store"; import { ShareViewStore } from "../ShareViewStore";
import { SPGetSpiteSize } from "../Util"; import { SPGetSpiteSize } from "../ShareViewUtil";
const BoardMessageWidget = (() => const BoardMessageWidget = (() =>
{ {
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
return useObserver( return useObserver(
() => () =>

@ -2,10 +2,10 @@ import { Icon } from "@blueprintjs/core";
import React, { forwardRef, useImperativeHandle, useState } from "react"; import React, { forwardRef, useImperativeHandle, useState } from "react";
import { CommandNames } from "../../../Common/CommandNames"; import { CommandNames } from "../../../Common/CommandNames";
import { commandMachine } from "../../../Editor/CommandMachine"; import { commandMachine } from "../../../Editor/CommandMachine";
import { shareViewApp } from "../Service"; import { shareViewApp } from "../ShareViewService";
import { BoxStore } from "../Store"; import { ShareViewStore } from "../ShareViewStore";
import { resetBoxView } from "../Util"; import { resetBoxView } from "../ShareViewUtil";
import { CheckEmptySvg, CheckedSvg } from "./CommonSvgs"; import { CheckedSvg, CheckEmptySvg } from "./CommonSvgs";
import { SPToaster } from "./SPToater"; import { SPToaster } from "./SPToater";
@ -23,7 +23,7 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
const [selectedTab, setSelectedTab] = useState(''); const [selectedTab, setSelectedTab] = useState('');
const [list, setList] = useState<any>({}); const [list, setList] = useState<any>({});
const [key, setKey] = useState<number>(0); const [key, setKey] = useState<number>(0);
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
const [selectAll, setSelectAll] = useState(false); const [selectAll, setSelectAll] = useState(false);
// 判断是否全选状态 // 判断是否全选状态

@ -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;
}

@ -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<HTMLDivElement>(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 (
<div
ref={containerRef}
onBlur={() => setIsOpen(false)}
onClick={() => setIsOpen(prev => !prev)}
tabIndex={0}
className="container"
>
<div className="value" >
<span >
{value}.
</span>
<span style={{ background: `rgba(${value === 0 ? "0,0,0,255" : options[value].value.join(",")})`, border: IsLightShadow(options[value].value) ? "1px solid #666" : null }} className="colorBox" />
</div>
<div className={"divider"}></div>
<div className={"caret"}></div>
<ul className={`options ${isOpen ? "show" : ""}`}>
{options.map((option, index) =>
{
if (index === options.length - 1) return;
return (
<li
onClick={e =>
{
e.stopPropagation();
selectOption(index);
setIsOpen(false);
}}
onMouseEnter={() => setHighlightedIndex(index)}
key={option.value}
className={`option ${isOptionSelected(index) ? "selected" : ""} ${index === highlightedIndex ? "highlighted" : ""}`}
>
<span> {option.label}. </span>
<span style={{ background: `rgba(${index === 0 ? "0,0,0,255" : option.value.join(",")})`, border: IsLightShadow(option.value) ? "1px solid #666" : null }} className="colorBox" />
</li>
);
})}
</ul>
</div>
);
}

@ -1,6 +1,6 @@
import React, { forwardRef, useImperativeHandle, useRef, useState } from "react"; import React, { forwardRef, useImperativeHandle, useRef, useState } from "react";
import { BoxStore } from "../Store"; import { ShareViewStore } from "../ShareViewStore";
import { ExplosionView } from "../Util"; import { ExplosionView } from "../ShareViewUtil";
interface IProps interface IProps
{ {
@ -14,7 +14,7 @@ const ExplosionMapWidget: React.FC<IProps> = forwardRef((props, ref) =>
{ {
const [state, setState] = useState(false); const [state, setState] = useState(false);
const loadingRef = useRef(false); const loadingRef = useRef(false);
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
async function changeDoorState(num: number) async function changeDoorState(num: number)
{ {

@ -3,9 +3,9 @@ import { useObserver } from "mobx-react";
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"; import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
import { Board } from "../../../DatabaseServices/Entity/Board"; import { Board } from "../../../DatabaseServices/Entity/Board";
import { ICompHardwareOption, IHardwareOption, IToplineOption } from "../../../UI/Components/RightPanel/RightPanelInterface"; import { ICompHardwareOption, IHardwareOption, IToplineOption } from "../../../UI/Components/RightPanel/RightPanelInterface";
import { shareViewApp } from "../Service"; import { shareViewApp } from "../ShareViewService";
import { BoxStore } from "../Store"; import { ShareViewStore } from "../ShareViewStore";
import { GetBoxItemInfo, MaterialDetailScrollTo, SPGetSpiteSize } from "../Util"; import { GetBoxItemInfo, MaterialDetailScrollTo, SPGetSpiteSize } from "../ShareViewUtil";
interface IProps interface IProps
{ {
@ -28,14 +28,14 @@ const MaterialBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
// 判断是否加载过 // 判断是否加载过
const flagRef = useRef<boolean>(false); const flagRef = useRef<boolean>(false);
const bottomSheetRef = useRef<any>(null); const bottomSheetRef = useRef<any>(null);
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
useImperativeHandle(ref, () => ( useImperativeHandle(ref, () => (
{ {
show: async () => show: async () =>
{ {
flagRef.current = true; flagRef.current = true;
// const temp = GetBoxItemInfo(shareViewApp.BoxCtrl.GetEntities(BoxStore.GetInstance().index)) || []; // const temp = GetBoxItemInfo(shareViewApp.BoxCtrl.GetEntities(ShareViewStore.GetInstance().index)) || [];
const temp = []; const temp = [];
boxStore.Index.forEach((i) => boxStore.Index.forEach((i) =>
{ {

@ -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 (
<div id="ShareBoardInfoPanel" className={Classes.DIALOG_CONTAINER}>
<div className={Classes.DIALOG} >
<div className={Classes.DIALOG_HEADER} data-id="dragArea">
<Icon icon="cog" iconSize={18} />
<h4 className={Classes.HEADING}></h4>
<Button
icon="cross"
aria-label="Close"
minimal={true}
onClick={() => { app.Editor.ModalManage.Destory(); }}
/>
</div>
<div className={Classes.DIALOG_BODY}>
<span ></span>
<div className="label" style={{ marginTop: "6px", marginBottom: "0px" }}>
<Checkbox
checked={option.IsExportBoard}
label="板件"
onChange={() =>
{
if (!option.IsExportHardware && option.IsExportBoard)
{
this.BoardAndHadrwareToaster();
return;
}
option.IsExportBoard = !option.IsExportBoard;
}}
/>
<Checkbox
checked={option.IsExportHardware}
label="五金"
onChange={() =>
{
if (!option.IsExportBoard && option.IsExportHardware)
{
this.BoardAndHadrwareToaster();
return;
}
option.IsExportHardware = !option.IsExportHardware;
}}
/>
<Checkbox
checked={true}
disabled
label="其他"
/>
</div>
<div className="label" style={{ marginTop: "6px", marginBottom: "0px" }}>
<Checkbox
checked={option.showBom}
label="展示物料明细"
onChange={() => { option.showBom = !option.showBom; }}
/>
</div>
<div className="label">
<span>线:</span>
<ColorSelect
options={JSON.parse(JSON.stringify(ColorPalette)).map((rgb, index) => ({ value: rgb, label: index }))}
value={option.Physical2EdgeColor}
onChange={(value) =>
{
option.Physical2EdgeColor = value;
}}
/>
</div>
<div className="label">
<span>:</span>
<HTMLSelect
style={{ height: "28px" }}
value={option.Viewport}
options={ViewAngleTypes.map((v) => ({ value: v.viewDirection, label: v.name }))}
onChange={(e) => { option.Viewport = parseInt(e.target.value); }}
/>
</div>
<div className="label">
<span>:</span>
<HTMLSelect
style={{ height: "28px" }}
value={option.VisualStyle}
options={ViewStyleTypes.map((v) => ({ value: v.renderType, label: v.title }))}
onChange={(e) => { option.VisualStyle = parseInt(e.target.value); }}
/>
</div>
</div>
<div className={Classes.DIALOG_FOOTER} >
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
<UserConfigComponent store={this.props.store} type={BoardModalType.ShareBoardInfoUpdateConfiguration} configType={Config_ModalType.UserConfigModal} />
<div className="foot_right">
<Button
intent={Intent.SUCCESS}
text="确定"
onClick={() => { app.Editor.ModalManage.DestoryAndExec(); }}
/>
</div>
</div>
</div>
</div>
</div>
);
}
}

@ -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;
}
}

@ -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 React, { useEffect, useRef, useState } from "react";
import { CommandNames } from "../../../Common/CommandNames"; import { CommandNames } from "../../../Common/CommandNames";
import { Hole } from "../../../DatabaseServices/3DSolid/Hole"; import { Hole } from "../../../DatabaseServices/3DSolid/Hole";
import { commandMachine } from "../../../Editor/CommandMachine"; import { commandMachine } from "../../../Editor/CommandMachine";
import { userConfig } from "../../../Editor/UserConfig"; import { userConfig } from "../../../Editor/UserConfig";
import { IsDoor, IsDrawer, IsHandle, IsLattice } from "../../HideSelect/HideSelectUtils"; 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 "../index.less";
import { shareViewApp } from "../ShareViewService";
import { ShareViewStore } from "../ShareViewStore";
import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ForbiddenToaster, resetBoxView, SwitchDoor } from "../ShareViewUtil";
import BoardMessageWidget from "./BoardMessageWidget"; import BoardMessageWidget from "./BoardMessageWidget";
import CabinetBottomSheet from "./CabinetBottomSheet"; import CabinetBottomSheet from "./CabinetBottomSheet";
import ExplosionMapWidget from "./ExplosionMapWidget"; import ExplosionMapWidget from "./ExplosionMapWidget";
import MaterialBottomSheet from "./MaterialBottomSheet"; import MaterialBottomSheet from "./MaterialBottomSheet";
import { SPToaster } from "./SPToater";
import SideBar from "./SideBar"; import SideBar from "./SideBar";
import { SPToaster } from "./SPToater";
import ViewAngle from "./ViewAngle"; import ViewAngle from "./ViewAngle";
import ViewIDErrorWidget from "./ViewIDErrorWidget"; import ViewIDErrorWidget from "./ViewIDErrorWidget";
import ViewStyle from "./ViewStyle"; import ViewStyle from "./ViewStyle";
export function ShareViewUI()
function ShareViewUI()
{ {
// 选择柜体 // 选择柜体
// const [selectCabinet, setSelectCabinet] = useState<boolean>(false); // const [selectCabinet, setSelectCabinet] = useState<boolean>(false);
@ -34,11 +35,10 @@ export function ShareViewUI()
// 显示隐藏标注 // 显示隐藏标注
const [dimBrsState, setDimBrsState] = useState<boolean>(false); const [dimBrsState, setDimBrsState] = useState<boolean>(false);
const viewStyleRef = useRef<any>(null);
const cabinetBottomSheetRef = useRef<any>(null); const cabinetBottomSheetRef = useRef<any>(null);
const explosionMapWidgetRef = useRef<any>(null); const explosionMapWidgetRef = useRef<any>(null);
const materialBottomSheetRef = useRef<any>(null); const materialBottomSheetRef = useRef<any>(null);
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
// 按下 esc // 按下 esc
function escKeyDown(event) function escKeyDown(event)
@ -233,14 +233,14 @@ export function ShareViewUI()
{ {
return ( return (
<> <>
{boxStore.Props.IsMaterialDetails == false ? null : ( {boxStore.Props.showBom == false ? null : (
<div <div
// className={`${selectMaterial ? 'active' : ''}`} // className={`${selectMaterial ? 'active' : ''}`}
onClick={() => onClick={() =>
{ {
materialBottomSheetRef.current.show(); materialBottomSheetRef.current.show();
}} }}
>{boxStore.Props.IsMaterialDetails}</div> >{boxStore.Props.showBom}</div>
)} )}
</> </>
); );
@ -250,7 +250,7 @@ export function ShareViewUI()
return ( return (
<React.Fragment> <React.Fragment>
<Provider store={BoxStore}> <Provider store={ShareViewStore}>
<ViewIDErrorWidget></ViewIDErrorWidget> <ViewIDErrorWidget></ViewIDErrorWidget>
<div className={`sp-loading-mask ${loading ? 'open' : ''}`}></div> <div className={`sp-loading-mask ${loading ? 'open' : ''}`}></div>
<div className="sp-bottom-container"> <div className="sp-bottom-container">
@ -285,12 +285,14 @@ export function ShareViewUI()
<BoardMessageWidget></BoardMessageWidget> <BoardMessageWidget></BoardMessageWidget>
{/* 顶部栏 */} {/* 顶部栏 */}
<div className="sp-top-container"> <div className="sp-top-container">
<ViewAngle closeDoor={closeDoor} ref={null}></ViewAngle> <ViewAngle closeDoor={closeDoor} currentViewDirection={boxStore.viewUploadProps.Viewport} />
<ViewStyle reset={async () => <ViewStyle
reset={async () =>
{ {
await closeDoor(); await closeDoor();
await explosionMapWidgetRef.current.reset(); await explosionMapWidgetRef.current.reset();
}} ref={viewStyleRef}></ViewStyle> }}
currentRenderType={boxStore.viewUploadProps.VisualStyle} />
<div className={`sp-top-btn ${dimBrsState ? 'active' : ''}`} onClick={dimBrsShowOrHide}></div> <div className={`sp-top-btn ${dimBrsState ? 'active' : ''}`} onClick={dimBrsShowOrHide}></div>
{/* <div className="sp-top-btn">编号</div> */} {/* <div className="sp-top-btn">编号</div> */}
</div> </div>
@ -323,3 +325,5 @@ export function ShareViewUI()
</React.Fragment> </React.Fragment>
); );
} }
export default observer(ShareViewUI);

@ -1,8 +1,8 @@
import React from 'react'; import React from 'react';
import { CommandNames } from '../../../Common/CommandNames'; import { CommandNames } from '../../../Common/CommandNames';
import { commandMachine } from '../../../Editor/CommandMachine'; import { commandMachine } from '../../../Editor/CommandMachine';
import { shareViewApp } from '../Service'; import { shareViewApp } from '../ShareViewService';
import { resetBoxView } from '../Util'; import { resetBoxView } from '../ShareViewUtil';
import BoardHideIcon from './BoardHideIcon'; import BoardHideIcon from './BoardHideIcon';
import ShareWidget from './ShareWidget'; import ShareWidget from './ShareWidget';
import ThemeButton from './ThemeButton'; import ThemeButton from './ThemeButton';

@ -1,12 +1,12 @@
import { useObserver } from "mobx-react"; import { useObserver } from "mobx-react";
import React from "react"; import React from "react";
import { shareViewApp } from "../Service"; import { shareViewApp } from "../ShareViewService";
import { BoxStore } from "../Store"; import { ShareViewStore } from "../ShareViewStore";
import { ChangeThemeColor } from "../Util"; import { ChangeThemeColor } from "../ShareViewUtil";
function ThemeButton() function ThemeButton()
{ {
const boxStore: BoxStore = BoxStore.GetInstance(); const boxStore: ShareViewStore = ShareViewStore.GetInstance();
function changeTheme() function changeTheme()
{ {
const t = boxStore.Theme === 'light' ? 'dark' : 'light'; const t = boxStore.Theme === 'light' ? 'dark' : 'light';

@ -1,48 +1,18 @@
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"; import React, { forwardRef, useEffect, useRef, useState } from "react";
import { CommandNames } from "../../../Common/CommandNames";
import { commandMachine } from "../../../Editor/CommandMachine"; import { commandMachine } from "../../../Editor/CommandMachine";
import { shareViewApp } from "../Service"; import { ViewDirection } from "../../../UI/Store/BoardInterface";
import { ForbiddenToaster, resetBoxView } from "../Util"; import { ViewAngleTypes } from "../ShareViewRules";
import { shareViewApp } from "../ShareViewService";
import { ForbiddenToaster, resetBoxView } from "../ShareViewUtil";
interface IProps interface IProps
{ {
closeDoor: Function; closeDoor: Function;
ref: React.Ref<any>; currentViewDirection: ViewDirection;
} }
const ViewAngle: React.FC<IProps> = forwardRef((props) =>
const ViewAngle: React.FC<IProps> = forwardRef((props, ref) =>
{ {
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<boolean>(false); const [visible, setVisible] = useState<boolean>(false);
const [selected, setSelected] = useState<string>(''); const [selected, setSelected] = useState<string>('');
const selectDivRef = useRef<any>(); const selectDivRef = useRef<any>();
@ -50,13 +20,16 @@ const ViewAngle: React.FC<IProps> = forwardRef((props, ref) =>
const hideSelect = (e) => const hideSelect = (e) =>
{ {
if (e.target != selectDivRef.current) if (e.target != selectDivRef.current)
{
setSelected('');
setVisible(false); setVisible(false);
}
}; };
function checkViewDirection(viewDirection: ViewDirection): number
{
const viewAngleTypesIndex = ViewAngleTypes.findIndex(v => v.viewDirection === viewDirection);
if (viewAngleTypesIndex > -1) return viewAngleTypesIndex;
return 0;
}
useEffect(() => useEffect(() =>
{ {
document.addEventListener('click', hideSelect, false); document.addEventListener('click', hideSelect, false);
@ -71,14 +44,12 @@ const ViewAngle: React.FC<IProps> = forwardRef((props, ref) =>
}; };
}, []); }, []);
useImperativeHandle(ref, () => ( useEffect(() =>
{
hide: () =>
{ {
setVisible(false); if (props.currentViewDirection)
}, setSelected(ViewAngleTypes[checkViewDirection(props.currentViewDirection)].name);
} return () => { setSelected(""); };
)); }, [props.currentViewDirection]);
function stopPropagation(e) function stopPropagation(e)
{ {
@ -94,14 +65,15 @@ const ViewAngle: React.FC<IProps> = forwardRef((props, ref) =>
{ {
setVisible(!visible); setVisible(!visible);
}} }}
></div> >
</div>
<ul className={`sp-select-ul ${visible ? 'open' : ''}`} <ul className={`sp-select-ul ${visible ? 'open' : ''}`}
onTouchStart={stopPropagation} onTouchStart={stopPropagation}
onMouseDown={stopPropagation} onMouseDown={stopPropagation}
onClick={stopPropagation} onClick={stopPropagation}
> >
{types.map((item) => {ViewAngleTypes.map((item) =>
{ {
return ( return (
<li key={item.name} className={selected == item.name ? 'sp-selected' : 'view-angle-li'} <li key={item.name} className={selected == item.name ? 'sp-selected' : 'view-angle-li'}
@ -117,7 +89,10 @@ const ViewAngle: React.FC<IProps> = forwardRef((props, ref) =>
}); });
setSelected(item.name); setSelected(item.name);
}}>{item.name}</li> }}
>
{item.name}
</li>
); );
})} })}
</ul> </ul>

@ -1,7 +1,7 @@
import { Icon } from "@blueprintjs/core"; import { Icon } from "@blueprintjs/core";
import { useObserver } from "mobx-react"; import { useObserver } from "mobx-react";
import React from "react"; import React from "react";
import { BoxStore } from "../Store"; import { ShareViewStore } from "../ShareViewStore";
const ViewIDErrorWidget = () => const ViewIDErrorWidget = () =>
@ -10,10 +10,10 @@ const ViewIDErrorWidget = () =>
() => () =>
{ {
return ( return (
<>{BoxStore.GetInstance().ViewIDErrorMsg ? ( <>{ShareViewStore.GetInstance().ViewIDErrorMsg ? (
<div className="sp-viewid-error-mask"> <div className="sp-viewid-error-mask">
<Icon icon="issue"></Icon> <Icon icon="issue"></Icon>
<div>{BoxStore.GetInstance().ViewIDErrorMsg}</div> <div>{ShareViewStore.GetInstance().ViewIDErrorMsg}</div>
</div> </div>
) : <></> ) : <></>
} </> } </>

@ -1,49 +1,17 @@
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"; import React, { forwardRef, useEffect, useRef, useState } from "react";
import { CommandNames } from "../../../Common/CommandNames";
import { commandMachine } from "../../../Editor/CommandMachine"; import { commandMachine } from "../../../Editor/CommandMachine";
import { ForbiddenToaster } from "../Util"; import { RenderType } from "../../../GraphicsSystem/RenderType";
import { ViewStyleTypes } from "../ShareViewRules";
import { ForbiddenToaster } from "../ShareViewUtil";
interface IProps interface IProps
{ {
reset: Function; reset: Function;
ref: React.Ref<any>; currentRenderType: RenderType;
} }
const ViewStyle: React.FC<IProps> = forwardRef((props) =>
const ViewStyle: React.FC<IProps> = forwardRef((props, ref) =>
{ {
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<boolean>(false); const [visible, setVisible] = useState<boolean>(false);
const [selected, setSelected] = useState<string>('概念'); const [selected, setSelected] = useState<string>('概念');
const selectDivRef = useRef<any>(); const selectDivRef = useRef<any>();
@ -51,20 +19,13 @@ const ViewStyle: React.FC<IProps> = forwardRef((props, ref) =>
const hideSelect = (e) => const hideSelect = (e) =>
{ {
if (e.target != selectDivRef.current) if (e.target != selectDivRef.current)
{
setVisible(false); setVisible(false);
}
}; };
function checkRenderType(renderType) function checkRenderType(renderType: RenderType): number
{ {
for (let i = 0; i < types.length; i++) const viewStyleIndex = ViewStyleTypes.findIndex(v => v.renderType === renderType);
{ if (viewStyleIndex > -1) return viewStyleIndex;
if (`${types[i].renderType}` == `${renderType}`)
{
return i;
}
}
return 0; return 0;
} }
@ -73,14 +34,7 @@ const ViewStyle: React.FC<IProps> = forwardRef((props, ref) =>
document.addEventListener('click', hideSelect, false); document.addEventListener('click', hideSelect, false);
document.addEventListener('touchstart', hideSelect, false); document.addEventListener('touchstart', hideSelect, false);
document.addEventListener('mousedown', 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 () => return () =>
{ {
document.removeEventListener('click', hideSelect, false); document.removeEventListener('click', hideSelect, false);
@ -89,14 +43,12 @@ const ViewStyle: React.FC<IProps> = forwardRef((props, ref) =>
}; };
}, []); }, []);
useImperativeHandle(ref, () => ( useEffect(() =>
{
hide: () =>
{ {
setVisible(false); if (props.currentRenderType)
}, setSelected(ViewStyleTypes[checkRenderType(props.currentRenderType)].title);
} return () => { setSelected(""); };
)); }, [props.currentRenderType]);
function stopPropagation(e) function stopPropagation(e)
{ {
@ -116,9 +68,8 @@ const ViewStyle: React.FC<IProps> = forwardRef((props, ref) =>
onTouchStart={stopPropagation} onTouchStart={stopPropagation}
onMouseDown={stopPropagation} onMouseDown={stopPropagation}
onClick={stopPropagation} onClick={stopPropagation}
> >
{types.map((item) => {ViewStyleTypes.map((item) =>
{ {
return ( return (
<li key={item.title} className={selected == item.title ? 'sp-selected' : ''} <li key={item.title} className={selected == item.title ? 'sp-selected' : ''}
@ -131,8 +82,8 @@ const ViewStyle: React.FC<IProps> = forwardRef((props, ref) =>
await commandMachine.ExecCommand(item.cmd); await commandMachine.ExecCommand(item.cmd);
}); });
setSelected(item.title); setSelected(item.title);
}}
}}>{item.title}</li> >{item.title}</li>
); );
})} })}
</ul> </ul>

@ -3,7 +3,7 @@ import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial';
import { HostApplicationServices } from '../ApplicationServices/HostApplicationServices'; import { HostApplicationServices } from '../ApplicationServices/HostApplicationServices';
import { GetGoodShaderSimple } from '../GLSL/GoochShader'; import { GetGoodShaderSimple } from '../GLSL/GoochShader';
const ColorPalette = [ export const ColorPalette = [
[0, 0, 0, 0], //----- 0 - lets make it red for an example [0, 0, 0, 0], //----- 0 - lets make it red for an example
//[255, 255, 255, 255],//----- 0 - ByBlock - White //[255, 255, 255, 255],//----- 0 - ByBlock - White
[255, 0, 0, 255], //----- 1 - Red [255, 0, 0, 255], //----- 1 - Red

@ -6,11 +6,11 @@ import { IUpdateBoardInfosOption } from "../UI/Components/Board/UpdateBoardInfoi
import { EMetalsType, ICompHardwareOption, ICylMetalsOption, IExtMetalsOption, IToplineOption } from "../UI/Components/RightPanel/RightPanelInterface"; import { EMetalsType, ICompHardwareOption, ICylMetalsOption, IExtMetalsOption, IToplineOption } from "../UI/Components/RightPanel/RightPanelInterface";
import { IKuGangDrawOption } from "../UI/Components/Template/TemplateInterface"; import { IKuGangDrawOption } from "../UI/Components/Template/TemplateInterface";
import { ECompareType, IBoardFindOption } from "../UI/Store/BoardFindInterface"; 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 { DoorPosType, HandleHorPos, HandleVePos, IDoorConfigOption, IDrawerConfigOption, IHingeConfigOption } from "../UI/Store/DoorInterface";
import { IHSOption } from "../UI/Store/HSInterface"; import { IHSOption } from "../UI/Store/HSInterface";
import { ELatticeArrayType, ILatticeOption } from "../UI/Store/LatticeInterface"; 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"; import { EOrderType } from "./OrderType";
export const DefaultLayerBoardConfig: LayerBoardOption = { export const DefaultLayerBoardConfig: LayerBoardOption = {
@ -929,3 +929,13 @@ export const DefaultChangeColorByBoardMaterialOption: ChangeColorByBoardMaterial
accordMaterialName: true accordMaterialName: true
}; };
Object.freeze(DefaultChangeColorByBoardMaterialOption); Object.freeze(DefaultChangeColorByBoardMaterialOption);
export const DefaultShareBoardInfConfigurationOption: ShareBoardInfConfigurationOption = {
Physical2EdgeColor: 7,
VisualStyle: RenderType.Conceptual,
Viewport: ViewDirection.Southwest,
IsExportBoard: true,
IsExportHardware: true,
showBom: true,
};
Object.freeze(DefaultShareBoardInfConfigurationOption);

@ -50,6 +50,8 @@ export enum RenderType
/**真实带线框 */ /**真实带线框 */
Physical2Print = 106, Physical2Print = 106,
CustomNumberPrint = 109, CustomNumberPrint = 109,
ConceptualTransparent = 182//概念透明
} }
export function IsPhysical(renderType: RenderType) export function IsPhysical(renderType: RenderType)

@ -41,6 +41,7 @@ export enum BoardModalType
AutoDimBrs = "AutoDimBrs", AutoDimBrs = "AutoDimBrs",
SelectThinBehindBoard = "SelectThinBehindBoard", SelectThinBehindBoard = "SelectThinBehindBoard",
ChangeColorByBoardMaterial = "ChangeColorByMaterial", ChangeColorByBoardMaterial = "ChangeColorByMaterial",
ShareBoardInfoUpdateConfiguration = "ShareBoardInfoSettings",
ModifyTexts = "ModifyTexts", ModifyTexts = "ModifyTexts",
Viewport = "Viewport", Viewport = "Viewport",
Viewport2 = "Viewport2", Viewport2 = "Viewport2",

@ -251,4 +251,15 @@
background-color: @fileName_bg; background-color: @fileName_bg;
} }
} }
//分享图设置
#ShareBoardInfoPanel{
.container{
background-color: @verticalTab_selected_bg;
}
.options{
background-color: @verticalTab_selected_bg;
}
}
} }

@ -158,7 +158,7 @@ export interface BoardConfigOption extends IBaseOption
thickness?: number; thickness?: number;
height?: number; height?: number;
width?: number; width?: number;
openDir?: BoardOpenDir openDir?: BoardOpenDir;
} }
export interface LightConfigOption extends IBaseOption export interface LightConfigOption extends IBaseOption
@ -577,3 +577,13 @@ export interface ChangeColorByBoardMaterialOption
accordMaterialName: boolean; accordMaterialName: boolean;
accordMaterialColor: boolean; accordMaterialColor: boolean;
} }
export interface ShareBoardInfConfigurationOption
{
Physical2EdgeColor: number; //真实带线框颜色
VisualStyle: RenderType; //视觉样式
Viewport: ViewDirection; //视觉角度
IsExportBoard: boolean; //是否导出板件
IsExportHardware: boolean; //是否导出五金
showBom: boolean; //是否展示物料明细
}

Loading…
Cancel
Save