From c8a3e5c9a76a61fb06e1fdbf9c0644f9587af679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Thu, 12 Sep 2024 03:49:44 +0000 Subject: [PATCH] =?UTF-8?q?!2577=20=E5=8A=9F=E8=83=BD:=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=20=20=E5=91=BD=E4=BB=A4:Style=20Merge=20pull?= =?UTF-8?q?=20request=20!2577=20from=20=E6=9E=97=E4=B8=89/font=5Fstyle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/CFImport.test.ts.snap | 6 +- .../__snapshots__/file.test.ts.snap | 4 +- .../__snapshots__/wblockClone.test.ts.snap | 30 +- src/Add-on/ACAD/DxfEntityConvert.ts | 2 +- src/Add-on/DrawBoard/DrawTemplateByImport.ts | 8 +- src/Add-on/DrawDim/BoardInfoDimTool.ts | 5 + src/Add-on/DrawDim/DimStylePanel.tsx | 6 +- src/Add-on/DrawText.ts | 26 +- src/Add-on/ShareView/ShareViewService.ts | 5 +- src/Add-on/Text2Curve.ts | 6 +- src/Add-on/TextStyle/Command_FontStyle.ts | 12 + src/Add-on/TextStyle/FontStyleCSS.less | 94 ++++ src/Add-on/TextStyle/FontStyleInterface.ts | 29 ++ src/Add-on/TextStyle/FontStylePanel.tsx | 412 ++++++++++++++++++ src/Add-on/TextStyle/FontStyleStore.ts | 11 + src/ApplicationServices/Application.ts | 8 +- .../HostApplicationServices.ts | 3 +- src/Common/CommandNames.ts | 4 +- src/DatabaseServices/BlockTableRecord.ts | 7 + src/DatabaseServices/Database.ts | 36 +- src/DatabaseServices/Dimension/Dimension.ts | 2 +- .../FontStyle/FontStyleKeyCodeEnum.ts | 6 + .../FontStyle/FontStyleTable.ts | 35 ++ .../FontStyle/FontsStyleRecord.ts | 45 ++ .../Room/Entity/Region/RoomRegion.ts | 7 +- src/DatabaseServices/Text/FontExt.ts | 33 +- src/DatabaseServices/Text/Text.ts | 166 +++++-- src/DatabaseServices/Text/TextArea.ts | 27 +- src/Editor/CommandRegister.ts | 6 +- src/Editor/DefaultConfig.ts | 10 + src/Editor/UserConfig.ts | 2 - src/UI/Components/Board/BoardModalType.ts | 1 + src/UI/Components/Board/DrillCommon.tsx | 4 +- .../Components/Board/UserConfigComponent.tsx | 2 +- src/UI/Components/CommandPanel/CommandList.ts | 10 +- src/UI/Components/INumericInput.tsx | 7 +- .../Modal/OptionModal/ConfigDialog.tsx | 4 +- .../Modal/OptionModal/TextConfigPanel.tsx | 22 +- src/UI/Components/Panel.tsx | 33 +- src/UI/Components/ToolBar/Properties_Text.tsx | 137 ++---- src/UI/Store/DownPanelStore.ts | 9 +- 41 files changed, 1057 insertions(+), 225 deletions(-) create mode 100644 src/Add-on/TextStyle/Command_FontStyle.ts create mode 100644 src/Add-on/TextStyle/FontStyleCSS.less create mode 100644 src/Add-on/TextStyle/FontStyleInterface.ts create mode 100644 src/Add-on/TextStyle/FontStylePanel.tsx create mode 100644 src/Add-on/TextStyle/FontStyleStore.ts create mode 100644 src/DatabaseServices/FontStyle/FontStyleKeyCodeEnum.ts create mode 100644 src/DatabaseServices/FontStyle/FontStyleTable.ts create mode 100644 src/DatabaseServices/FontStyle/FontsStyleRecord.ts diff --git a/__test__/CFImport/__snapshots__/CFImport.test.ts.snap b/__test__/CFImport/__snapshots__/CFImport.test.ts.snap index 4d1f0b547..40d8f9426 100644 --- a/__test__/CFImport/__snapshots__/CFImport.test.ts.snap +++ b/__test__/CFImport/__snapshots__/CFImport.test.ts.snap @@ -1,14 +1,14 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`晨丰导入CAD解析 1`] = `"[13,103,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,3,\\"Board\\",11,2,100,0,1,2,0,[0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,1,0,0,0,20,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,20,0,0,1],0,0,1,0,4,100,80,18,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[0,100],0,[80,100],0,[80,0],0,true,1,4,20,10,1,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[0,20],0,[10,20],0,[10,0],0,true,0,3,0,0,0,0,0,0,[0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,1,0,0,0,20,6.123233995736766e-16,10,1],3,0,0,0,0,0,0,23,1,\\"层板\\",\\"板主卧\\",\\"板标准柜\\",\\"默认板材5厘\\",\\"生态板\\",\\"经典檀木\\",0,0,\\"不排\\",2,0,\\"1.5\\",\\"1.5\\",\\"1.5\\",\\"1.5\\",\\"\\",\\"\\",\\"\\",4,\\"三合一\\",\\"三合一\\",\\"三合一\\",\\"三合一\\",true,true,2,\\"备注1\\",\\"434\\",\\"备注2\\",\\"434\\",0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,\\"HardwareCompositeEntity\\",2,11,2,101,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,\\"Board\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,30,50,60,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[50,0],0,[50,30],0,[0,30],0,true,0,3,0,0,0,0,0,0,23,null,\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",0,0,\\"\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,0,6,\\"五金\\",false,false,\\"五金颜色\\",\\"五金材质\\",\\"五金\\",\\"五金主卧\\",\\"五金标准柜\\",\\"L*W*H*100\\",\\"L*W*H\\",\\"X-1\\",\\"厂家晨丰\\",\\"品牌晨丰\\",\\"{L*2}\\",\\"1\\",\\"五金备注\\",\\"个\\",0,true,0,0,0,\\"\\",\\"\\",\\"HardwareTopline\\",11,2,102,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,\\"\\",1,\\"\\",0,0,3,0,\\"0\\",\\"\\",\\"模板主卧\\",\\"模板标准柜\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",0,\\"\\",\\"\\",0,2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,3,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,1,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,2,\\"CreateObjectData\\",1,[],2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0]"`; +exports[`晨丰导入CAD解析 1`] = `"[14,103,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,3,\\"Board\\",11,2,100,0,1,2,0,[0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,1,0,0,0,20,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,20,0,0,1],0,0,1,0,4,100,80,18,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[0,100],0,[80,100],0,[80,0],0,true,1,4,20,10,1,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[0,20],0,[10,20],0,[10,0],0,true,0,3,0,0,0,0,0,0,[0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,1,0,0,0,20,6.123233995736766e-16,10,1],3,0,0,0,0,0,0,23,1,\\"层板\\",\\"板主卧\\",\\"板标准柜\\",\\"默认板材5厘\\",\\"生态板\\",\\"经典檀木\\",0,0,\\"不排\\",2,0,\\"1.5\\",\\"1.5\\",\\"1.5\\",\\"1.5\\",\\"\\",\\"\\",\\"\\",4,\\"三合一\\",\\"三合一\\",\\"三合一\\",\\"三合一\\",true,true,2,\\"备注1\\",\\"434\\",\\"备注2\\",\\"434\\",0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,\\"HardwareCompositeEntity\\",2,11,2,101,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,\\"Board\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,30,50,60,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[50,0],0,[50,30],0,[0,30],0,true,0,3,0,0,0,0,0,0,23,null,\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",0,0,\\"\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,0,6,\\"五金\\",false,false,\\"五金颜色\\",\\"五金材质\\",\\"五金\\",\\"五金主卧\\",\\"五金标准柜\\",\\"L*W*H*100\\",\\"L*W*H\\",\\"X-1\\",\\"厂家晨丰\\",\\"品牌晨丰\\",\\"{L*2}\\",\\"1\\",\\"五金备注\\",\\"个\\",0,true,0,0,0,\\"\\",\\"\\",\\"HardwareTopline\\",11,2,102,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,\\"\\",1,\\"\\",0,0,3,0,\\"0\\",\\"\\",\\"模板主卧\\",\\"模板标准柜\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",0,\\"\\",\\"\\",0,2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,3,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,1,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,2,\\"CreateObjectData\\",1,[],2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0,1,2,15,0,0,5,0,0]"`; exports[`晨丰导入五金解析 1`] = `"[2,11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,\\"Board\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,30,50,60,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[50,0],0,[50,30],0,[0,30],0,true,0,3,0,0,0,0,0,0,23,null,\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",0,0,\\"\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,0,6,\\"五金\\",false,false,\\"五金颜色\\",\\"五金材质\\",\\"五金\\",\\"五金主卧\\",\\"五金标准柜\\",\\"L*W*H*100\\",\\"L*W*H\\",\\"X-1\\",\\"厂家晨丰\\",\\"品牌晨丰\\",\\"{L*2}\\",\\"1\\",\\"五金备注\\",\\"个\\",0,true,0,0,0,\\"\\",\\"\\"]"`; -exports[`晨丰导入五金解析 2`] = `"[13,102,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,2,\\"HardwareCompositeEntity\\",2,11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,\\"Board\\",11,2,101,0,1,2,0,[0,1,0,0,-1,0,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"五金主卧\\",\\"五金标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,0,6,\\"五金\\",false,false,\\"五金颜色\\",\\"五金材质\\",\\"五金\\",\\"五金主卧\\",\\"五金标准柜\\",\\"L*W*H*100\\",\\"L*W*H\\",\\"X-1\\",\\"厂家晨丰\\",\\"品牌晨丰\\",\\"{L*2}\\",\\"1\\",\\"五金备注\\",\\"个\\",0,true,0,0,0,\\"\\",\\"\\",\\"Board\\",11,2,101,0,1,2,0,[0,1,0,0,-1,0,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"五金主卧\\",\\"五金标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,2,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,1,\\"CreateObjectData\\",1,[],2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0]"`; +exports[`晨丰导入五金解析 2`] = `"[14,102,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,2,\\"HardwareCompositeEntity\\",2,11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,\\"Board\\",11,2,101,0,1,2,0,[0,1,0,0,-1,0,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"五金主卧\\",\\"五金标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,0,6,\\"五金\\",false,false,\\"五金颜色\\",\\"五金材质\\",\\"五金\\",\\"五金主卧\\",\\"五金标准柜\\",\\"L*W*H*100\\",\\"L*W*H\\",\\"X-1\\",\\"厂家晨丰\\",\\"品牌晨丰\\",\\"{L*2}\\",\\"1\\",\\"五金备注\\",\\"个\\",0,true,0,0,0,\\"\\",\\"\\",\\"Board\\",11,2,101,0,1,2,0,[0,1,0,0,-1,0,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"五金主卧\\",\\"五金标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,2,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,1,\\"CreateObjectData\\",1,[],2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0,1,2,15,0,0,5,0,0]"`; exports[`晨丰导入板解析 1`] = `"[11,2,0,0,0,2,0,[0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,1,0,0,0,20,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,20,0,0,1],0,0,1,0,4,100,80,18,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[0,100],0,[80,100],0,[80,0],0,true,1,4,20,10,1,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[0,20],0,[10,20],0,[10,0],0,true,0,3,0,0,0,0,0,0,[0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,1,0,0,0,20,6.123233995736766e-16,10,1],3,0,0,0,0,0,0,23,1,\\"层板\\",\\"板主卧\\",\\"板标准柜\\",\\"默认板材5厘\\",\\"生态板\\",\\"经典檀木\\",0,0,\\"不排\\",2,0,\\"1.5\\",\\"1.5\\",\\"1.5\\",\\"1.5\\",\\"\\",\\"\\",\\"\\",4,\\"三合一\\",\\"三合一\\",\\"三合一\\",\\"三合一\\",true,true,2,\\"备注1\\",\\"434\\",\\"备注2\\",\\"434\\",0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0]"`; -exports[`晨丰导入模板解析 1`] = `"[13,102,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,2,\\"HardwareCompositeEntity\\",2,11,2,100,0,1,7,0,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,0,1,\\"Board\\",11,2,101,0,1,2,0,[0,6.123233995736766e-17,1,0,-1,0,0,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"模板主卧\\",\\"模板标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,0,6,\\"五金\\",false,false,\\"\\",\\"\\",\\"复合实体\\",\\"模板主卧\\",\\"模板标准柜\\",\\"L*W*H*100\\",\\"L*W*H*300\\",\\"X-1\\",\\"晨丰\\",\\"晨丰\\",\\"个\\",\\"1\\",\\"\\",\\"\\",0,true,0,0,0,\\"\\",\\"\\",\\"Board\\",11,2,101,0,1,2,0,[0,6.123233995736766e-17,1,0,-1,0,0,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"模板主卧\\",\\"模板标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,2,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,1,\\"CreateObjectData\\",1,[],2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0]"`; +exports[`晨丰导入模板解析 1`] = `"[14,102,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,2,\\"HardwareCompositeEntity\\",2,11,2,100,0,1,7,0,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,0,1,\\"Board\\",11,2,101,0,1,2,0,[0,6.123233995736766e-17,1,0,-1,0,0,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"模板主卧\\",\\"模板标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,0,6,\\"五金\\",false,false,\\"\\",\\"\\",\\"复合实体\\",\\"模板主卧\\",\\"模板标准柜\\",\\"L*W*H*100\\",\\"L*W*H*300\\",\\"X-1\\",\\"晨丰\\",\\"晨丰\\",\\"个\\",\\"1\\",\\"\\",\\"\\",0,true,0,0,0,\\"\\",\\"\\",\\"Board\\",11,2,101,0,1,2,0,[0,6.123233995736766e-17,1,0,-1,0,0,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,[1,0,0,0,0,6.123233995736766e-17,1,0,0,-1,6.123233995736766e-17,0,400,0,0,1],0,0,1,0,4,100,100,100,true,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,4,[0,0],0,[100,0],0,[100,100],0,[0,100],0,true,0,3,0,0,0,0,0,0,23,0,\\"层板\\",\\"模板主卧\\",\\"模板标准柜\\",\\"\\",\\"\\",\\"\\",0,0,\\"不排\\",2,0,\\"1\\",\\"1\\",\\"1\\",\\"1\\",\\"\\",\\"\\",\\"\\",4,\\"不排\\",\\"不排\\",\\"不排\\",\\"不排\\",true,true,0,0,0,0,0,0,0,0,true,0,0,null,0,0,\\"\\",\\"\\",\\"\\",\\"\\",0,false,0,\\"\\",0,0,0,2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,2,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[],\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,1,\\"CreateObjectData\\",1,[],2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0,1,2,15,0,0,5,0,0]"`; exports[`晨丰导入顶线解析 1`] = `"[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,4,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,5,[0,0],0,[0,20],0,[20,20],0,[20,0],0,[0,0],0,false,1,\\"Polyline\\",11,2,0,0,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,2,5,[0,0],0,[0,100],0,[100,100],0,[100,0],0,[0,0],0,true,0,0,3,0,\\"0\\",\\"顶线\\",\\"顶线主卧\\",\\"顶线标准柜\\",\\"\\",\\"L*W*H\\",\\"X-1\\",\\"厂家晨丰\\",\\"品牌晨丰\\",\\"{L*2}\\",\\"顶线备注\\",0,\\"\\",\\"\\",0]"`; diff --git a/__test__/FileSystem/__snapshots__/file.test.ts.snap b/__test__/FileSystem/__snapshots__/file.test.ts.snap index 72e5fff0a..1d1a23b4e 100644 --- a/__test__/FileSystem/__snapshots__/file.test.ts.snap +++ b/__test__/FileSystem/__snapshots__/file.test.ts.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`changev 1`] = `"[13,101,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[2,3,4],[0,0,0],2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],100,1,\\"ObjectAllDataHistoryRecord\\",1,2,\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"\\",100,2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0]"`; +exports[`changev 1`] = `"[14,101,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[2,3,4],[0,0,0],2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],100,1,\\"ObjectAllDataHistoryRecord\\",1,2,\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"\\",100,2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0,1,2,15,0,0,5,0,0]"`; -exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[13,101,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[1,2,3],[0,0,0],2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,1,2,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"CommandHistoryRecord\\",1,\\"\\",1,100,1,\\"ObjectAllDataHistoryRecord\\",1,2,\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[1,2,3],[0,0,0]],100,2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0]"`; +exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[14,101,1,2,14,0,0,5,0,0,\\"LayerNode\\",\\"根节点\\",0,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[1,2,3],[0,0,0],2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,1,2,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"CommandHistoryRecord\\",1,\\"\\",1,100,1,\\"ObjectAllDataHistoryRecord\\",1,2,\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[1,2,3],[0,0,0]],100,2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null,2,13,0,0,0,1,2,15,0,0,5,0,0]"`; exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,1,2,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",2,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"CommandHistoryRecord\\",1,\\"\\",1,100,1,\\"ObjectAllDataHistoryRecord\\",1,2,\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[0,0,0],[0,0,0]],\\"AllObjectData\\",1,[11,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,0,1,[1,2,3],[0,0,0]],100]"`; diff --git a/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap b/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap index 4fb13d25c..c449d3e88 100644 --- a/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap +++ b/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap @@ -2,7 +2,7 @@ exports[`wblockClone 1`] = ` Array [ - 13, + 14, 102, 1, 2, @@ -177,12 +177,20 @@ Array [ 0, 0, 0, + 1, + 2, + 15, + 0, + 0, + 5, + 0, + 0, ] `; exports[`wblockClone 2`] = ` Array [ - 13, + 14, 104, 1, 2, @@ -433,12 +441,20 @@ Array [ 0, 0, 0, + 1, + 2, + 15, + 0, + 0, + 5, + 0, + 0, ] `; exports[`wblockClone 3`] = ` Array [ - 13, + 14, 102, 1, 2, @@ -613,5 +629,13 @@ Array [ 0, 0, 0, + 1, + 2, + 15, + 0, + 0, + 5, + 0, + 0, ] `; diff --git a/src/Add-on/ACAD/DxfEntityConvert.ts b/src/Add-on/ACAD/DxfEntityConvert.ts index b7ba12903..88a21a401 100644 --- a/src/Add-on/ACAD/DxfEntityConvert.ts +++ b/src/Add-on/ACAD/DxfEntityConvert.ts @@ -15,7 +15,7 @@ import { Polyline } from "../../DatabaseServices/Entity/Polyline"; import { SmartPolylineSimply2Polyline } from "../../DatabaseServices/SplineConver2Polyline"; import { Text, TextAligen } from "../../DatabaseServices/Text/Text"; import { userConfig } from "../../Editor/UserConfig"; -import { angle, AsVector2, AsVector3, equaln, equalv3, ZAxis } from "../../Geometry/GeUtils"; +import { AsVector2, AsVector3, ZAxis, angle, equaln, equalv3 } from "../../Geometry/GeUtils"; import { Vec3 } from "../../Geometry/IVec3"; import { Orbit } from "../../Geometry/Orbit"; import { DXFSpline2Points } from "../DXFSpline2Points"; diff --git a/src/Add-on/DrawBoard/DrawTemplateByImport.ts b/src/Add-on/DrawBoard/DrawTemplateByImport.ts index 1d3ae26cc..4cebf8ae8 100644 --- a/src/Add-on/DrawBoard/DrawTemplateByImport.ts +++ b/src/Add-on/DrawBoard/DrawTemplateByImport.ts @@ -17,6 +17,7 @@ import { Text } from "../../DatabaseServices/Text/Text"; import { Command, CommandWrap } from "../../Editor/CommandMachine"; import { PromptResult } from "../../Editor/PromptResult"; import { AppToaster } from "../../UI/Components/Toaster"; +import { FontType } from "../TextStyle/FontStyleInterface"; interface IList @@ -433,12 +434,13 @@ export class DrawTemplateByImport implements Command } private DrawText(ocs: Matrix4, isRed: boolean, name?: string) { - const textHeight = TextHeight; - let text = new Text(new Vector3(), name || "平板", "songti", textHeight); + let text = new Text(new Vector3(), name || "平板"); + text.Height = TextHeight; + text.FontName = FontType.SongTi; if (isRed) text.ColorIndex = 1; text.ApplyMatrix(ocs); - text.Position = text.Position.add(new Vector3(0, 0, -textHeight * 3)); + text.Position = text.Position.add(new Vector3(0, 0, -TextHeight * 3)); app.Database.ModelSpace.Append(text); } private DrawDim(width: number, height: number, ocs: Matrix4) diff --git a/src/Add-on/DrawDim/BoardInfoDimTool.ts b/src/Add-on/DrawDim/BoardInfoDimTool.ts index 0e084f934..42ca3794c 100644 --- a/src/Add-on/DrawDim/BoardInfoDimTool.ts +++ b/src/Add-on/DrawDim/BoardInfoDimTool.ts @@ -1,5 +1,6 @@ import { Vector2, Vector3 } from "three"; import { app } from "../../ApplicationServices/Application"; +import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; import { EBoardKeyList } from "../../Common/BoardKeyList"; import { BigFaceSelectOption, ComposingFaceSelectOption, LineTypeSelectOption } from "../../Common/CommonSelectOption"; import { LogType } from "../../Common/Log"; @@ -9,6 +10,7 @@ import { Board } from "../../DatabaseServices/Entity/Board"; import { BoardOpenDir, ComposingType, LinesType } from "../../DatabaseServices/Entity/BoardInterface"; import { Line } from "../../DatabaseServices/Entity/Line"; import { Polyline } from "../../DatabaseServices/Entity/Polyline"; +import { FontStyleRecord } from "../../DatabaseServices/FontStyle/FontsStyleRecord"; import { GroupRecord } from "../../DatabaseServices/GroupTableRecord"; import { ObjectId } from "../../DatabaseServices/ObjectId"; import { ProcessingGroupRecord } from "../../DatabaseServices/ProcessingGroup/ProcessingGroupRecord"; @@ -43,12 +45,15 @@ export class Command_BoardInfoDimTool implements Command let jpgEnt: Text[] = []; let textEnts: Text[] = []; let backUCS = app.Editor.UCSMatrix.setPosition(0, 0, 0); + let fontName = (HostApplicationServices.CurrentFontStyle.Object as FontStyleRecord).FontType; const DrawText = (textString: string) => { let text = new Text(); text.TextString = textString; text.Height = userConfig.dimTextHeight; + text.FontName = fontName; + text.WidthFactor = 1; text.ApplyMatrix(backUCS); textEnts.push(text); }; diff --git a/src/Add-on/DrawDim/DimStylePanel.tsx b/src/Add-on/DrawDim/DimStylePanel.tsx index ce9d1a789..c609c2637 100644 --- a/src/Add-on/DrawDim/DimStylePanel.tsx +++ b/src/Add-on/DrawDim/DimStylePanel.tsx @@ -5,13 +5,13 @@ import { observer } from 'mobx-react'; import React, { Component } from 'react'; import { app } from '../../ApplicationServices/Application'; import { HostApplicationServices } from '../../ApplicationServices/HostApplicationServices'; -import { Dimension } from '../../DatabaseServices/Dimension/Dimension'; import { DimStyleRecord } from '../../DatabaseServices/DimStyle/DimStyleRecord'; +import { Dimension } from '../../DatabaseServices/Dimension/Dimension'; import { CommandWrap } from '../../Editor/CommandMachine'; import { AppConfirm } from '../../UI/Components/Common/Confirm'; import { ModalHeader } from '../../UI/Components/Modal/ModalContainer'; import { DimStyleParam } from './DimStyleParam'; -import { dimStyleStore, DimStyleStore } from './DimStyleStore'; +import { DimStyleStore, dimStyleStore } from './DimStyleStore'; import { OperDimStyle, OperDimStyleType } from './OperDimStyle'; export const DEFAULT_STYLE_NAME = "默认"; //默认样式名称 @@ -30,7 +30,7 @@ export class DimStylePanel extends Component<{ store: DimStyleStore; currentStyl { return (
-
+
(); + +@observer +export class FontStylePanel extends Component<{ store: FontStyleStore; }> { + + @observable _CurrentStyleName = ""; //当前UI展示的样式名称 + @observable _CurrentDBStyleName = ""; //当前DB使用的样式名称 + _Preview: React.RefObject = React.createRef(); + _PreviewScence: Scene = new Scene();; + _Camera = new OrthographicCamera(150, -150, 150, -150, 0.1, 1000); + _Renderer: WebGLRenderer; + _NameInput = React.createRef(); + + constructor(props) + { + super(props); + const Name = (app.Database.FontStyleTable.Current.Object as FontStyleRecord).Name; + this._CurrentStyleName = Name; + this._CurrentDBStyleName = Name; + this.GetFontStyle(this._CurrentStyleName, this.props.store); + } + + async componentDidMount() + { + //创建预览图 + this._Renderer = new WebGLRenderer({ canvas: this._Preview.current, antialias: true }); + await this.UpdateScene(); + } + + componentWillUnmount() + { + let gl = this._Preview.current.getContext("webgl2"); + gl.getExtension('WEBGL_lose_context').loseContext(); + + this._PreviewScence.clear(); + this._Renderer.clear(); + } + + async componentDidUpdate(prevProps, prevState) + { + await this.UpdateScene(); + } + + //更新预览图 + UpdateScene = async () => + { + this._PreviewScence.clear(); + const option = this.props.store.m_Option; + const key = option.fontType + option.widthFactor; + + let cube = GEOMETRY_CACHE.get(key); + if (!cube) + { + let f = FontLoader.GetLoader(option.fontType); + await f.LoadGlyphs("AaBb123"); + await f.AwaitLoaded(); + + let shapes = f.Font.generateShapes("AaBb123", 100, option.widthFactor); + let geometry = new ShapeGeometry(shapes); + geometry.name = "Text"; + geometry.computeBoundingBox(); + + geometry.rotateY(90); + const material = new MeshBasicMaterial(); + cube = new Mesh(geometry, material); + + GEOMETRY_CACHE.set(key, cube); + } + this._Camera.position.set(cube.geometry.boundingBox.getCenter(new Vector3).x, 50, 0); + this._Camera.updateMatrix(); + this._PreviewScence.add(cube); + this._Renderer.render(this._PreviewScence, this._Camera); + }; + + render() + { + const store = this.props.store; + const option = store.m_Option; + + return ( +
+
+ +
+
+ +
+
样式列表
+
+ { this.GetFontStyle(name.toString(), this.props.store); }} + animate={true} + > + { + app.Database.FontStyleTable.FontStyleNames.map((name) => + { + return + { + this._CurrentDBStyleName === name + && + } + {name} +
+ } + />; + }) + } + + +
+
+ +
+ 字体 +
+
+
+ 字体名: + + { + option.fontType = e.target.value as FontType; + }} + /> +
+
+
+ +
+
+ 大小 +
+
+
+ 高度: + { option.height = parseInt(e.target.value); }} + /> +
+
+
+
+ +
+ 效果 +
+
+
+ 宽度因子: + + { + let value = parseFloat(e.target.value); + if (value <= 0) + { + value = 0.1; + e.target.value = value.toString(); + } + option.widthFactor = value; + }} + /> +
+
+ +
+
+
+
+
+
+
+
+
+ ); + } + + AddStyleRecord = async () => + { + let name = this._NameInput.current.value; + //添加样式 + if (!name) return; + + let fontStyleRecord: FontStyleRecord = app.Database.FontStyleTable.Symbols.get(name) as FontStyleRecord; + if (fontStyleRecord) + { + await AppConfirm.show({ message: "已存在该名称样式!" }); + return; + } + else + { + fontStyleRecord = new FontStyleRecord(); + fontStyleRecord.Name = name; + this.ApplyParams(fontStyleRecord, this.props.store.m_Option); + app.Database.FontStyleTable.Add(fontStyleRecord); + this._CurrentStyleName = name; + } + }; + + //应用参数 返回fontStyleRecord属性是否被改动 + ApplyParams(fontStyleRecord: FontStyleRecord, option: FontStyleInfoOption): boolean + { + if (fontStyleRecord.Height !== option.height || + fontStyleRecord.WidthFactor !== option.widthFactor || + fontStyleRecord.FontType !== option.fontType + ) + { + fontStyleRecord.Height = option.height; + fontStyleRecord.WidthFactor = option.widthFactor; + fontStyleRecord.FontType = option.fontType; + return true; + } + return false; + } + + //获取画布使用DB当前FontStyleRecord的Text + GetCurrentFontStyleRecordTexts(): Text[] + { + return app.Database.ModelSpace.Entitys.filter(ent => + { + return ent instanceof Text && + !ent.IsErase && + (ent.FontStyle?.Object as FontStyleRecord)?.Name === this._CurrentStyleName; + }) as Text[]; + } + + //保存 + SaveConfig = async () => + { + let fontStyleRecord = app.Database.FontStyleTable.Symbols.get(this._CurrentStyleName) as FontStyleRecord; + if (fontStyleRecord) + { + await CommandWrap(() => + { + if (this.ApplyParams(fontStyleRecord, this.props.store.m_Option)) + { + let ents = this.GetCurrentFontStyleRecordTexts(); + for (let ent of ents) + { + //写入撤回重做记录 + ent.WriteAllObjectRecord(); + ent.Update(); + } + AppToaster.show({ + message: "保存字体样式成功", + timeout: 5000, + intent: Intent.SUCCESS, + }); + } + }, "保存字体样式"); + } + }; + + //置为当前 + SetToCurrent() + { + let fontStyleRecord = app.Database.FontStyleTable.Symbols.get(this._CurrentStyleName) as FontStyleRecord; + if (fontStyleRecord) + { + this.SetFontStyleId(fontStyleRecord); + this._CurrentDBStyleName = fontStyleRecord.Name; + DownPanelStore.GetInstance().fontType = fontStyleRecord.Name; + } + } + + /** + * 删除Database里的标注样式 + * @memberof FontStylePanel + */ + Delete = async () => + { + let texts = this.GetCurrentFontStyleRecordTexts(); + + let status = await AppConfirm.show({ + message: (texts.length > 0 ? "有部分文字使用该样式," : "") + "确定删除' " + this._CurrentStyleName + " '样式?" + }); + if (status) + { + await CommandWrap(() => + { + //删除database当前使用的样式时 删除后使用默认样式 + if (this._CurrentStyleName === (app.Database.FontStyleTable.Current.Object as FontStyleRecord).Name) + { + let defaultFontStyle = app.Database.FontStyleTable.Symbols.get(DEFAULT_STYLE_NAME) as FontStyleRecord; + this.SetFontStyleId(defaultFontStyle); + } + + //使用该样式的标注,使用当前标注样式 + for (let ent of texts) + (ent as Text).FontStyle = app.Database.FontStyleTable.Current; + + app.Database.FontStyleTable.Remove(app.Database.FontStyleTable.Symbols.get(this._CurrentStyleName)); + }, "删除样式"); + + //UI指向默认 + this._CurrentStyleName = DEFAULT_STYLE_NAME; + this.GetFontStyle(DEFAULT_STYLE_NAME, this.props.store); + } + }; + + /** + * @param {string} name 目标名称 app.Database.FontStyleTable.Symbols.get(name) + * @param {FontStyleStore} store 赋值对象 store.m_Option + * @memberof FontStylePanel + */ + GetFontStyle = async (name: string, store: FontStyleStore) => + { + let fontStyle = app.Database.FontStyleTable.Symbols.get(name) as FontStyleRecord; + if (!fontStyle) return; + + let option = store.m_Option; + option.height = fontStyle.Height; + option.fontType = fontStyle.FontType; + option.widthFactor = fontStyle.WidthFactor; + + this._CurrentStyleName = name; + }; + + SetFontStyleId(fontStyle: FontStyleRecord) + { + app.Database.FontStyleTable.Current = fontStyle.objectId; + HostApplicationServices.CurrentFontStyle = fontStyle.objectId; + } + + Cancel = () => + { + app.Editor.ModalManage.Destory(); + }; +} diff --git a/src/Add-on/TextStyle/FontStyleStore.ts b/src/Add-on/TextStyle/FontStyleStore.ts new file mode 100644 index 000000000..5b50c6e80 --- /dev/null +++ b/src/Add-on/TextStyle/FontStyleStore.ts @@ -0,0 +1,11 @@ +import { observable } from "mobx"; +import { Singleton } from "../../Common/Singleton"; +import { DefaultFontStyleOption } from "../../Editor/DefaultConfig"; +import { FontStyleInfoOption } from "./FontStyleInterface"; + +export class FontStyleStore extends Singleton +{ + @observable m_Option: FontStyleInfoOption = { ...DefaultFontStyleOption }; +} + +export const fontStyleStore = FontStyleStore.GetInstance(); diff --git a/src/ApplicationServices/Application.ts b/src/ApplicationServices/Application.ts index fbf9b4077..47afab044 100644 --- a/src/ApplicationServices/Application.ts +++ b/src/ApplicationServices/Application.ts @@ -11,6 +11,7 @@ import { AppendUserInfo } from '../Add-on/ExportData'; import { FbxImport } from '../Add-on/FBXLoad'; import { ImportJiajuFile } from '../Add-on/JiaJu/Import/JiaJuImport'; import { ImportKJLData } from '../Add-on/KJL/Import/KJLImport'; +import { FontType } from '../Add-on/TextStyle/FontStyleInterface'; import { CommandNames } from '../Common/CommandNames'; import { IsDev } from '../Common/Deving'; import { MouseKey } from '../Common/KeyEnum'; @@ -22,6 +23,7 @@ import { BoardLinesReactor } from '../DatabaseServices/BoardLinesReactor'; import { CADFiler } from '../DatabaseServices/CADFiler'; import { Database } from '../DatabaseServices/Database'; import { Entity } from '../DatabaseServices/Entity/Entity'; +import { FontStyleRecord } from '../DatabaseServices/FontStyle/FontsStyleRecord'; import { RoomParseReactor } from '../DatabaseServices/Room/ParseService/RoomParseReactor'; import { FontLoader } from '../DatabaseServices/Text/FontLoader'; import { AutoSaveServer } from '../Editor/AutoSave'; @@ -372,8 +374,8 @@ export class ApplicationService }); //加载字体. - FontLoader.GetLoader("yahei").LoadGlyphs("1234567890."); - FontLoader.GetLoader("songti").LoadGlyphs("1234567890."); + FontLoader.GetLoader(FontType.YaHei).LoadGlyphs("1234567890."); + FontLoader.GetLoader(FontType.SongTi).LoadGlyphs("1234567890."); if (isHasTouch()) { @@ -592,5 +594,7 @@ export class ApplicationService app.LayoutTool.CacheCamera(); app.LayoutTool.bakUCS = undefined;//否则开图后UCS回归不到正确的位置(在已经切换过布局的状态下) app.LayoutTool.Reset(); + + DownPanelStore.GetInstance().fontType = (HostApplicationServices.CurrentFontStyle.Object as FontStyleRecord).Name; } } diff --git a/src/ApplicationServices/HostApplicationServices.ts b/src/ApplicationServices/HostApplicationServices.ts index 14a9e4268..7eb9390f9 100644 --- a/src/ApplicationServices/HostApplicationServices.ts +++ b/src/ApplicationServices/HostApplicationServices.ts @@ -18,11 +18,12 @@ export class IHostApplicationServices IsRoomEntityVisible = true;//室内实体可见 - CurrentDimStyle: ObjectId; CurrentLayer: ObjectId; /** 当前画笔的颜色索引 */ CurrentColorindex: number = 7; + CurrentDimStyle: ObjectId; //标注样式 + CurrentFontStyle: ObjectId; //字体样式 @ProxyValue isShowLightShadow: boolean = true;//灯光阴影 (除太阳光外) ShowHistoryLog: boolean = true; diff --git a/src/Common/CommandNames.ts b/src/Common/CommandNames.ts index e71c667b5..7d65722d4 100644 --- a/src/Common/CommandNames.ts +++ b/src/Common/CommandNames.ts @@ -168,7 +168,7 @@ export enum CommandNames Config = "CONFIG", Enablesyncdata = "ENABLESYNCDATA", DimStyle = "DIMSTYLE", - TextStyle = "TEXTSTYLE", + TextConfig = "TEXTCONFIG", ToggleDrillingReactor = "TOGGLEDRILLINGREACTOR", AddAloneDrillLock = "ADDALONEDRILLLOCK", AddAssocDrillLock = "ADDASSOCDRILLLOCK", @@ -434,4 +434,6 @@ export enum CommandNames MoveLayerFolder = "移动图层文件夹", DrawArcBoard = "DRAWARCBOARD", //绘制圆弧板 PartsAnalysis = "PARTSANALYSIS", // 复合实体名称写入关联板件备注 + FontStyle = "FONTSTYLE",//字体样式 + Style = "STYLE",//字体样式 } diff --git a/src/DatabaseServices/BlockTableRecord.ts b/src/DatabaseServices/BlockTableRecord.ts index 22415f452..0bc4f770e 100644 --- a/src/DatabaseServices/BlockTableRecord.ts +++ b/src/DatabaseServices/BlockTableRecord.ts @@ -12,6 +12,7 @@ import { RoomFlatTop } from './Room/Entity/Flat/RoomFlatTop'; import { RoomHolePolyline } from './Room/Entity/Wall/Hole/RoomHolePolyline'; import { RoomWallBase } from './Room/Entity/Wall/RoomWallBase'; import { SymbolTableRecord } from './SymbolTableRecord'; +import { Text } from './Text/Text'; @Factory export class BlockTableRecord extends SymbolTableRecord @@ -66,6 +67,12 @@ export class BlockTableRecord extends SymbolTableRecord if (!entity.HasLayer) entity.Layer = this._db.LayerTable.Current; + + else if (entity instanceof Text) + { + if (!entity.FontStyle) + entity.FontStyle = this._db.FontStyleTable.Current;//设置默认的字体样式 + } } this.EntityCol.Append(entity, isCheckObjectCleanly); diff --git a/src/DatabaseServices/Database.ts b/src/DatabaseServices/Database.ts index ee87ccd13..c02eeebc1 100644 --- a/src/DatabaseServices/Database.ts +++ b/src/DatabaseServices/Database.ts @@ -1,4 +1,5 @@ import { MirroredRepeatWrapping, Vector3 } from 'three'; +import { FontType } from '../Add-on/TextStyle/FontStyleInterface'; import { HostApplicationServices } from '../ApplicationServices/HostApplicationServices'; import { DuplicateRecordCloning } from '../Common/Status'; import { AlignLineGroupTable } from './AlignLine/AlignLineGroupTable'; @@ -11,6 +12,8 @@ import { DeepCloneFiler } from './DeepCloneFiler'; import { DimStyleRecord } from './DimStyle/DimStyleRecord'; import { DimStyleTable } from './DimStyle/DimStyleTable'; import { Entity } from './Entity/Entity'; +import { FontStyleTable } from './FontStyle/FontStyleTable'; +import { FontStyleRecord } from './FontStyle/FontsStyleRecord'; import { GroupTable } from './GroupTable'; import { HistoricManage } from './HistoricManage'; import { IdMaping } from './IdMaping'; @@ -49,6 +52,7 @@ export class Database AlignLineGroupTable: AlignLineGroupTable; DimStyleTable: DimStyleTable; LayerTable: LayerTable; + FontStyleTable: FontStyleTable; //模型空间(里面有模型空间的实体列表) ModelSpace: BlockTableRecord; @@ -101,6 +105,7 @@ export class Database this.AlignLineGroupTable = new AlignLineGroupTable().SetOwnerDatabase(this); //注意:新对象在这里添加 this.LayerTable = new LayerTable().SetOwnerDatabase(this); + this.FontStyleTable = new FontStyleTable().SetOwnerDatabase(this); if (IsDefaultDatabase) { @@ -119,6 +124,8 @@ export class Database this.InitLight(); + this.InitFontStyle(); + this.SettingDefaultStyleAndMaterial(); } @@ -193,6 +200,20 @@ export class Database this.Lights.Add(this.HemisphereLight); } + private InitFontStyle() + { + this.idIndex = 90; + let styleRd = new FontStyleRecord; + styleRd.Name = "默认"; + this.FontStyleTable.Add(styleRd); + this.FontStyleTable.Current = styleRd.Id; + + let styleRd1 = new FontStyleRecord; + styleRd1.Name = "样式1"; + styleRd1.FontType = FontType.SongTi; + this.FontStyleTable.Add(styleRd1); + } + private SettingDefaultStyleAndMaterial() { if (!this.IsDefaultDatabase) @@ -210,6 +231,7 @@ export class Database HostApplicationServices.CurrentDimStyle = this.DimStyleTable.Current; HostApplicationServices.CurrentLayer = this.LayerTable.Current; + HostApplicationServices.CurrentFontStyle = this.FontStyleTable.Current; } Destroy() @@ -228,6 +250,7 @@ export class Database this.AlignLineGroupTable.Destroy(); this.DimStyleTable.Destroy(); this.LayerTable.Destroy(); + this.FontStyleTable.Destroy(); this.hm.Destroy(); this.CameraSnapshoots.length = 0; this.hm.historyRecord.length = 0; @@ -247,6 +270,7 @@ export class Database this.AlignLineGroupTable.SetOwnerDatabase(this); //注意:新对象在这里添加 this.LayerTable.SetOwnerDatabase(this); + this.FontStyleTable.SetOwnerDatabase(this); this.idIndex = 100; } @@ -254,7 +278,7 @@ export class Database FileWrite(file = new CADFiler): CADFiler { - file.Write(13);//ver; + file.Write(14);//ver; file.Write(this.idIndex); this.LayerTable.WriteFile(file); @@ -279,6 +303,7 @@ export class Database file.Write(this.ExtendedData); this.AlignLineGroupTable.WriteFile(file); + this.FontStyleTable.WriteFile(file); return file; } @@ -369,6 +394,15 @@ export class Database if (ver > 11) this.AlignLineGroupTable.ReadFile(file); + if (ver > 13) + this.FontStyleTable.ReadFile(file); + else + { + let indexBak = this.idIndex; + this.InitFontStyle(); + this.idIndex = indexBak; + } + this.SettingDefaultStyleAndMaterial(); this.hm.doing = false; diff --git a/src/DatabaseServices/Dimension/Dimension.ts b/src/DatabaseServices/Dimension/Dimension.ts index bf483ac23..fee4b0823 100644 --- a/src/DatabaseServices/Dimension/Dimension.ts +++ b/src/DatabaseServices/Dimension/Dimension.ts @@ -13,7 +13,7 @@ export abstract class Dimension extends Entity { OnlyRenderType = true; protected _TextString: string; - protected _Text = new Text(undefined, undefined, "yahei"); + protected _Text = new Text(); //避免标注实体使用材质 get Material() { return this._MaterialId; } diff --git a/src/DatabaseServices/FontStyle/FontStyleKeyCodeEnum.ts b/src/DatabaseServices/FontStyle/FontStyleKeyCodeEnum.ts new file mode 100644 index 000000000..ced762418 --- /dev/null +++ b/src/DatabaseServices/FontStyle/FontStyleKeyCodeEnum.ts @@ -0,0 +1,6 @@ +export enum FontStyleKeyCode +{ + Height = 1, + WidthFactor = 2, + FontType = 3 +} diff --git a/src/DatabaseServices/FontStyle/FontStyleTable.ts b/src/DatabaseServices/FontStyle/FontStyleTable.ts new file mode 100644 index 000000000..0f1e76f71 --- /dev/null +++ b/src/DatabaseServices/FontStyle/FontStyleTable.ts @@ -0,0 +1,35 @@ +import { Factory } from "../CADFactory"; +import { CADFiler } from "../CADFiler"; +import { ObjectId } from "../ObjectId"; +import { SymbolTable } from "../Tables/SymbolTable"; + +@Factory +export class FontStyleTable extends SymbolTable +{ + Current: ObjectId; + + get FontStyleNames(): string[] + { + let fontStyleNames = []; + for (let fontStyle of this.Symbols) + fontStyleNames.push(fontStyle[0]); + return fontStyleNames; + } + + //#region -------------------------File------------------------- + //对象从文件中读取数据,初始化自身 + override ReadFile(file: CADFiler) + { + let ver = file.Read(); + super.ReadFile(file); + this.Current = file.ReadObjectId(); + } + //对象将自身数据写入到文件. + override WriteFile(file: CADFiler) + { + file.Write(1); + super.WriteFile(file); + file.WriteObjectId(this.Current); + } + //#endregion +} diff --git a/src/DatabaseServices/FontStyle/FontsStyleRecord.ts b/src/DatabaseServices/FontStyle/FontsStyleRecord.ts new file mode 100644 index 000000000..a9a6ecb82 --- /dev/null +++ b/src/DatabaseServices/FontStyle/FontsStyleRecord.ts @@ -0,0 +1,45 @@ +import { FontType } from "../../Add-on/TextStyle/FontStyleInterface"; +import { AutoRecord } from "../AutoRecord"; +import { Factory } from "../CADFactory"; +import { CADFiler } from "../CADFiler"; +import { SymbolTableRecord } from "../SymbolTableRecord"; + +/** + * 字体样式 + */ +@Factory +export class FontStyleRecord extends SymbolTableRecord +{ + /** 字体高度 1 */ + @AutoRecord Height: number = 60;//1 + + /** 宽度因子 2 字符串间距 */ + @AutoRecord WidthFactor: number = 1; + + /** 样式类型 3 */ + @AutoRecord FontType: FontType = FontType.YaHei; + + //#region -------------------------File------------------------- + //对象从文件中读取数据,初始化自身 + override ReadFile(file: CADFiler) + { + let ver = file.Read(); + super.ReadFile(file); + + this.Height = file.Read(); + this.WidthFactor = file.Read(); + this.FontType = file.Read(); + } + + //对象将自身数据写入到文件. + override WriteFile(file: CADFiler) + { + file.Write(1); + super.WriteFile(file); + + file.Write(this.Height); + file.Write(this.WidthFactor); + file.Write(this.FontType); + } + //#endregion +} diff --git a/src/DatabaseServices/Room/Entity/Region/RoomRegion.ts b/src/DatabaseServices/Room/Entity/Region/RoomRegion.ts index 763d64fb3..f81549472 100644 --- a/src/DatabaseServices/Room/Entity/Region/RoomRegion.ts +++ b/src/DatabaseServices/Room/Entity/Region/RoomRegion.ts @@ -1,4 +1,5 @@ import { BufferGeometry, Line, Object3D, Vector2, Vector3 } from "three"; +import { FontType } from "../../../../Add-on/TextStyle/FontStyleInterface"; import { AddEntityDrawObject } from "../../../../Common/AddEntityDrawObject"; import { FixedNotZero } from "../../../../Common/Utils"; import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils"; @@ -79,7 +80,11 @@ export class RoomRegion extends RoomBase private get Text() { if (!this._Text) - this._Text = new Text(undefined, undefined, "yahei", 100); + { + this._Text = new Text(); + this._Text.Height = 100; + this._Text.FontName = FontType.YaHei; + } return this._Text; } diff --git a/src/DatabaseServices/Text/FontExt.ts b/src/DatabaseServices/Text/FontExt.ts index 646553774..9709f26dd 100644 --- a/src/DatabaseServices/Text/FontExt.ts +++ b/src/DatabaseServices/Text/FontExt.ts @@ -7,16 +7,23 @@ import { IsPointInPolygon } from "../PointInPolyline"; export class FontExt extends Font { - generateShapes(text: string, size: number = 100) + /** + * @param {string} text + * @param {number} [size=100] + * @param {number} [widthFactor=1] 宽度因子 + * @return {*} + * @memberof FontExt + */ + generateShapes(text: string, size: number = 100, widthFactor = 1) { let shapes: Shape[] = []; - let paths = createPaths(text, size, this.data); + let paths = createPaths(text, size, this.data, widthFactor); for (let p of paths) arrayPushArray(shapes, p.toShapes(false)); return shapes; } } -function createPaths(text: string, size: number, data: any) +function createPaths(text: string, size: number, data: any, widthFactor: number) { let scale = size / data.resolution; let line_height = (data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness) * scale; @@ -38,7 +45,7 @@ function createPaths(text: string, size: number, data: any) } else { - let ret = createPath(char, scale, offsetX, offsetY, data); + let ret = createPath(char, scale, offsetX, offsetY, data, widthFactor); if (ret) { offsetX += ret.offsetX; @@ -48,7 +55,7 @@ function createPaths(text: string, size: number, data: any) } return paths; } -function createPath(char: string, scale: number, offsetX: number, offsetY: number, data: any): { offsetX: number, path: ShapePath; } +function createPath(char: string, scale: number, offsetX: number, offsetY: number, data: any, widthFactor: number): { offsetX: number, path: ShapePath; } { let glyph = data.glyphs[char] || data.glyphs['?']; @@ -73,7 +80,7 @@ function createPath(char: string, scale: number, offsetX: number, offsetY: numbe case 'm': // moveTo - x = outline[i++] * scale + offsetX; + x = outline[i++] * scale * widthFactor + offsetX; y = outline[i++] * scale + offsetY; path.moveTo(x, y); @@ -82,7 +89,7 @@ function createPath(char: string, scale: number, offsetX: number, offsetY: numbe case 'l': // lineTo - x = outline[i++] * scale + offsetX; + x = outline[i++] * scale * widthFactor + offsetX; y = outline[i++] * scale + offsetY; path.lineTo(x, y); @@ -91,9 +98,9 @@ function createPath(char: string, scale: number, offsetX: number, offsetY: numbe case 'q': // quadraticCurveTo - cpx = outline[i++] * scale + offsetX; + cpx = outline[i++] * scale * widthFactor + offsetX; cpy = outline[i++] * scale + offsetY; - cpx1 = outline[i++] * scale + offsetX; + cpx1 = outline[i++] * scale * widthFactor + offsetX; cpy1 = outline[i++] * scale + offsetY; path.quadraticCurveTo(cpx1, cpy1, cpx, cpy); @@ -102,11 +109,11 @@ function createPath(char: string, scale: number, offsetX: number, offsetY: numbe case 'b': // bezierCurveTo - cpx = outline[i++] * scale + offsetX; + cpx = outline[i++] * scale * widthFactor + offsetX; cpy = outline[i++] * scale + offsetY; - cpx1 = outline[i++] * scale + offsetX; + cpx1 = outline[i++] * scale * widthFactor + offsetX; cpy1 = outline[i++] * scale + offsetY; - cpx2 = outline[i++] * scale + offsetX; + cpx2 = outline[i++] * scale * widthFactor + offsetX; cpy2 = outline[i++] * scale + offsetY; path.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy); @@ -119,7 +126,7 @@ function createPath(char: string, scale: number, offsetX: number, offsetY: numbe } - return { offsetX: glyph.ha * scale, path: path }; + return { offsetX: glyph.ha * scale * widthFactor, path: path }; } class PathData extends Path diff --git a/src/DatabaseServices/Text/Text.ts b/src/DatabaseServices/Text/Text.ts index cf76c2df0..04fd222ee 100644 --- a/src/DatabaseServices/Text/Text.ts +++ b/src/DatabaseServices/Text/Text.ts @@ -1,14 +1,17 @@ import { BufferGeometry, Geometry, Matrix3, Matrix4, Mesh, Object3D, ShapeGeometry, Vector3 } from 'three'; +import { FontType } from '../../Add-on/TextStyle/FontStyleInterface'; +import { HostApplicationServices } from '../../ApplicationServices/HostApplicationServices'; import { ColorMaterial } from '../../Common/ColorPalette'; -import { UpdateDraw } from '../../Common/Status'; import { ObjectSnapMode } from '../../Editor/ObjectSnapMode'; import { Box3Ext } from '../../Geometry/Box'; import { GetBox, MoveMatrix, XAxis, XAxisN, YAxis, YAxisN, ZAxisN } from '../../Geometry/GeUtils'; import { RenderType } from '../../GraphicsSystem/RenderType'; -import { equaln } from '../../Nest/Common/Util'; import { Factory } from '../CADFactory'; import { CADFiler } from '../CADFiler'; import { Entity } from '../Entity/Entity'; +import { FontStyleKeyCode } from '../FontStyle/FontStyleKeyCodeEnum'; +import { FontStyleRecord } from '../FontStyle/FontsStyleRecord'; +import { ObjectId } from '../ObjectId'; import { FontLoader } from './FontLoader'; export const TEXT_HEIGHT_SCALE = 1.35; @@ -35,21 +38,18 @@ export function DisposeTextShapeCache() export class Text extends Entity { protected OnlyRenderType = true; - + protected _FontStyle: ObjectId;//字体样式 + protected _FontStyleOverride: Map = new Map;//字体样式替代 + private _Align: TextAligen = TextAligen.LeftDown; IsDoubleMesh = false;//文字使用双面网格体 IsFsText = false;//文字写在俯视图上 - private _Align: TextAligen = TextAligen.LeftDown; - constructor(pos?: Vector3, - private _TextString: string = "", - public _FontName: string = "songti", - private _Height: number = 60, - private _TextRotation: number = 0, - ) + constructor(pos?: Vector3, private _TextString: string = "", private _TextRotation: number = 0) { super(); pos && this._Matrix.setPosition(pos); } + get TextRotation() { return this._TextRotation; @@ -62,6 +62,7 @@ export class Text extends Entity this._TextRotation = v; this.UpdateTranslate(); } + get TextString() { return this._TextString; @@ -88,18 +89,87 @@ export class Text extends Entity return this._Align; } - get Height() + /**设置字体样式 */ + set FontStyle(styleId: ObjectId) + { + if (styleId === this._FontStyle) return; + + this.WriteAllObjectRecord(); + + this._FontStyle = styleId; + + this.Update(); + } + get FontStyle() { return this._FontStyle; } + + //字体样式名称 + get FontName() + { + return this.GetFontStyleValue(FontStyleKeyCode.FontType); + } + set FontName(fontName: FontType) + { + this.SetFontStyleOverrideValue(FontStyleKeyCode.FontType, fontName); + } + + //字体尺寸大小 + get Height(): number + { + return this.GetFontStyleValue(FontStyleKeyCode.Height); + } + set Height(value: number) + { + this.SetFontStyleOverrideValue(FontStyleKeyCode.Height, value); + } + + //字体间距 + get WidthFactor(): number + { + return this.GetFontStyleValue(FontStyleKeyCode.WidthFactor); + } + set WidthFactor(value: number) + { + this.SetFontStyleOverrideValue(FontStyleKeyCode.WidthFactor, value); + } + + GetFontStyleOverrideValue(key: FontStyleKeyCode): any { return this._FontStyleOverride.get(key); } + + GetFontStyleValue(key: FontStyleKeyCode) { - return this._Height; + let value = this.GetFontStyleOverrideValue(key); + if (value !== undefined) return value; + + if (this._FontStyle?.Object) + return this._FontStyle.Object[FontStyleKeyCode[key]]; + + if (HostApplicationServices.CurrentFontStyle && HostApplicationServices.CurrentFontStyle.Object instanceof FontStyleRecord) + return HostApplicationServices.CurrentFontStyle.Object[FontStyleKeyCode[key]]; } - set Height(v: number) + + //设置覆盖的样式 + SetFontStyleOverrideValue(key: FontStyleKeyCode, value: any) { - if (equaln(v, this._Height)) return; + if (this.GetFontStyleOverrideValue(key) === value) return; this.WriteAllObjectRecord(); - this._Height = v; - this.Update(UpdateDraw.Geometry); + + let oldV = this.GetFontStyleValue(key); + + this._FontStyleOverride.set(key, value); + + if (oldV !== value) + this.Update(); + } + + ClearFontStyleOverride() + { + if (this._FontStyleOverride.size === 0) return; + + this.WriteAllObjectRecord(); + this._FontStyleOverride.clear(); + this.Update(); } + //创建字体对象 async AsyncUpdateDrawObject(obj: Object3D, renderType: RenderType) { @@ -128,16 +198,20 @@ export class Text extends Entity } } - let f = FontLoader.GetLoader(this._FontName); + const Height = this.Height; + const FontName = this.FontName; + const WidthFactor = this.GetFontStyleValue(FontStyleKeyCode.WidthFactor); + + let f = FontLoader.GetLoader(FontName); await f.LoadGlyphs(this.TextString); await f.AwaitLoaded(); - const key = this._FontName + this._TextString + this._Height; + const key = FontName + this._TextString + Height + WidthFactor; let geometry = ShapeCache.get(key); if (!geometry) { - let shapes = f.Font.generateShapes(this._TextString || ".", this._Height); + let shapes = f.Font.generateShapes(this._TextString || ".", Height, WidthFactor); geometry = new ShapeGeometry(shapes); geometry.name = "Text"; geometry.computeBoundingBox(); @@ -180,7 +254,8 @@ export class Text extends Entity else count += 0.5; } - return count * this._Height * TEXT_HEIGHT_SCALE; + + return count * this.Height * TEXT_HEIGHT_SCALE * this.WidthFactor; } get HasBoundingBox() { return this._CacheDrawObject.has(RenderType.Wireframe); } @@ -307,7 +382,7 @@ export class Text extends Entity { this.WriteAllObjectRecord(); let p1 = this.Position; - let p2 = new Vector3(0, this._Height).applyMatrix4(this.OCS); + let p2 = new Vector3(0, this.Height).applyMatrix4(this.OCS); [p1, p2].forEach(p => p.applyMatrix4(m)); this.Position = p1; this.Height = p1.distanceTo(p2); @@ -395,27 +470,66 @@ export class Text extends Entity //#region -----------------------------File----------------------------- //对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化 + protected ReadFontStyle(file: CADFiler) + { + this._FontStyleOverride.clear(); + let size = file.Read(); + for (let i = 0; i < size; i++) + { + let k = file.Read(); + let v = file.Read(); + this._FontStyleOverride.set(k, v); + } + } + protected WriteFontStyle(file: CADFiler) + { + file.Write(this._FontStyleOverride.size); + for (let [k, v] of this._FontStyleOverride) + { + file.Write(k); + file.Write(v); + } + } + //对象从文件中读取数据,初始化自身 protected _ReadFile(file: CADFiler) { super._ReadFile(file); let ver = file.Read();//1 this._TextString = file.Read(); - this._Height = file.Read(); + + if (ver < 2) + this.Height = file.Read(); + this.TextRotation = file.Read(); - this._FontName = file.Read(); + + if (ver < 2) + this.FontName = file.Read(); + this._Align = file.Read(); + + //从版本开始使用FontStyle + if (ver >= 2) + { + this.ReadFontStyle(file); + this._FontStyle = file.ReadHardObjectId() ?? HostApplicationServices.CurrentFontStyle; + } + else + this._FontStyle = HostApplicationServices.CurrentFontStyle; } + //对象将自身数据写入到文件. WriteFile(file: CADFiler) { super.WriteFile(file); - file.Write(1);//ver + file.Write(2);//ver + file.Write(this._TextString); - file.Write(this._Height); file.Write(this.TextRotation); - file.Write(this._FontName); file.Write(this._Align); + + this.WriteFontStyle(file); + file.WriteHardObjectId(this._FontStyle); } //#endregion-----------------------------File End----------------------------- } diff --git a/src/DatabaseServices/Text/TextArea.ts b/src/DatabaseServices/Text/TextArea.ts index 134901f37..a6e246e3b 100644 --- a/src/DatabaseServices/Text/TextArea.ts +++ b/src/DatabaseServices/Text/TextArea.ts @@ -1,10 +1,13 @@ import { Object3D, Vector3 } from 'three'; import { end } from 'xaop'; +import { FontType } from '../../Add-on/TextStyle/FontStyleInterface'; import { app } from '../../ApplicationServices/Application'; +import { HostApplicationServices } from '../../ApplicationServices/HostApplicationServices'; import { KeyBoard } from '../../Common/KeyEnum'; import { Singleton } from '../../Common/Singleton'; import { GetEntity } from '../../Common/Utils'; -import { DownPanelStore } from '../../UI/Store/DownPanelStore'; +import { equaln } from '../../Geometry/GeUtils'; +import { FontStyleRecord } from '../FontStyle/FontsStyleRecord'; import { RoomRegion } from '../Room/Entity/Region/RoomRegion'; import { FontLoader } from './FontLoader'; import { TEXT_HEIGHT_SCALE, Text } from './Text'; @@ -20,6 +23,8 @@ export class TextArea extends Singleton private _TextRotation: number; private _CurrentValue: string = "";//当前编辑框的值 private _EditoringObject: Object3D; //正在编辑的对象 + private _FontType: FontType = FontType.YaHei; + constructor() { super(); @@ -34,7 +39,7 @@ export class TextArea extends Singleton zIndex:1; `; } - StartDrawText(position: Vector3, height: number, rotate: number, str: string) + StartDrawText(position: Vector3, height: number, rotate: number, str: string, fontType: FontType, widthFactor: number) { document.getElementById('Webgl').parentNode.appendChild(this._AreaContiner); this.RegisterEvent(); @@ -42,6 +47,7 @@ export class TextArea extends Singleton this._TextHeight = height; this._TextRotation = rotate; this._CurrentValue = str; + this._FontType = fontType; this.CreateEditorArea(); } StartEditorText(textObj, editorPosition?: Vector3) @@ -49,8 +55,6 @@ export class TextArea extends Singleton let text = GetEntity(textObj) as Text | RoomRegion; if (text) { - if (text instanceof Text) - DownPanelStore.GetInstance().fontName = text._FontName; document.getElementById('Webgl').parentNode.appendChild(this._AreaContiner); textObj.visible = false; app.Editor.UpdateScreen(); @@ -66,11 +70,13 @@ export class TextArea extends Singleton { this._TextHeight = text.Height; this._TextRotation = text.TextRotation; + this._FontType = text.FontName; } else { this._TextHeight = 60; this._TextRotation = 0; + this._FontType = FontType.YaHei; } this._CurrentValue = text.TextString; this.CreateEditorArea(editorPosition); @@ -185,7 +191,7 @@ export class TextArea extends Singleton if (this._EditoringObject) { let t = GetEntity(this._EditoringObject) as Text; - let f = FontLoader.GetLoader(DownPanelStore.GetInstance().fontName); + let f = FontLoader.GetLoader(this._FontType); f.LoadGlyphs(el.innerText); await f.AwaitLoaded(); t.TextString = el.innerText; @@ -210,13 +216,20 @@ export class TextArea extends Singleton async EndEditor() { this.ClearEvent(); - let f = FontLoader.GetLoader(DownPanelStore.GetInstance().fontName); + let f = FontLoader.GetLoader(this._FontType); for (let [el, pos] of this._EditorElList) { f.LoadGlyphs(el.innerText); await f.AwaitLoaded(); - let text = new Text(new Vector3(), el.innerText, f.FontName, this._TextHeight, this._TextRotation); + let text = new Text(new Vector3(), el.innerText, this._TextRotation); + + const FontStyle = HostApplicationServices.CurrentFontStyle.Object as FontStyleRecord; + text.FontStyle = FontStyle.objectId; + + if (!equaln(this._TextHeight, FontStyle.Height)) + text.Height = this._TextHeight; + text.ApplyMatrix(app.Editor.UCSMatrix.setPosition(pos)); app.LayoutTool.AppendDatabaseSpace(text); if (el.parentElement) diff --git a/src/Editor/CommandRegister.ts b/src/Editor/CommandRegister.ts index dfeb5cb4c..f4a18aca6 100644 --- a/src/Editor/CommandRegister.ts +++ b/src/Editor/CommandRegister.ts @@ -243,6 +243,7 @@ import { Command_Show2DPathObject } from "../Add-on/Show2DPathLine/Show2DPathObj import { TestFb } from "../Add-on/TestFb"; import { Command_TestPointPickParse } from "../Add-on/TestPointPickParse"; import { Text2Curve } from "../Add-on/Text2Curve"; +import { Command_FontStyle } from "../Add-on/TextStyle/Command_FontStyle"; import { Command_ToggleUI } from "../Add-on/ToggleUI"; import { Command_Trim } from "../Add-on/Trim"; import { Redo, Undo } from "../Add-on/Undo"; @@ -574,7 +575,9 @@ export function registerCommand() commandMachine.RegisterCommand(CommandNames.BreakDim, new BreakDim()); commandMachine.RegisterCommand(CommandNames.DeleteDim, new DeleteDim()); commandMachine.RegisterCommand(CommandNames.DeleteMinDim, new DeleteMinDim()); + commandMachine.RegisterCommand(CommandNames.DimStyle, new Command_DimStyle()); + commandMachine.RegisterCommand(CommandNames.Style, new Command_FontStyle()); commandMachine.RegisterCommand(CommandNames.RotateLayerBoard, new RotateLayerBoard()); @@ -661,8 +664,7 @@ export function registerCommand() commandMachine.RegisterCommand(CommandNames.SwitchServers, new Comman_SwitchServers()); //选项 commandMachine.RegisterCommand(CommandNames.Config, new Command_Options(EOptionTabId.Show)); - commandMachine.RegisterCommand(CommandNames.DimStyle, new Command_DimStyle()); - commandMachine.RegisterCommand(CommandNames.TextStyle, new Command_Options(EOptionTabId.TextStyle)); + commandMachine.RegisterCommand(CommandNames.TextConfig, new Command_Options(EOptionTabId.TextConfig)); commandMachine.RegisterCommand("esc", new Command_Esc()); commandMachine.RegisterCommand(CommandNames.EraseNoSelect, new Command_EraseNoSelect()); diff --git a/src/Editor/DefaultConfig.ts b/src/Editor/DefaultConfig.ts index d24412e3f..4424a7ab9 100644 --- a/src/Editor/DefaultConfig.ts +++ b/src/Editor/DefaultConfig.ts @@ -1,4 +1,5 @@ import { FaceDirection } from "../Add-on/DrawDrilling/DrillType"; +import { FontStyleInfoOption, FontType } from "../Add-on/TextStyle/FontStyleInterface"; import { EditViewOption } from "../Add-on/ViewortConfig/EditViewOption"; import { Curve2RecOption } from "../Add-on/twoD2threeD/Modals/Curve2RecOption"; import { IParseBoardNameOption, IRec2BrOption, IRect2Br2Option } from "../Add-on/twoD2threeD/R2bInterface"; @@ -1211,6 +1212,8 @@ export const DefaultFastDimOption: IFastDimOption = { filterAppointForBoardNameValues: "", conditionType: ForBoardNameType.Same, }; +Object.freeze(DefaultFastDimOption); + export const DefaultOneClickInspectionOption: OneClickInspectionOption = { version: 2, InspectionOption: { @@ -1301,3 +1304,10 @@ export const DefaultEditViewOption: EditViewOption = { showLayerValue: "" }; Object.freeze(DefaultEditViewOption); + +export const DefaultFontStyleOption: FontStyleInfoOption = { + height: 60, + fontType: FontType.YaHei, + widthFactor: 1, +}; +Object.freeze(DefaultFontStyleOption); diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index 98c80a8f5..0f198f32c 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -161,7 +161,6 @@ export class UserConfig implements IConfigStore @observable textStyleOption = { appointTextHight: false, noNeedAngle: false, - textHight: 30, }; showShareModule: boolean = false; @observable openHistoryList = true; @@ -274,7 +273,6 @@ export class UserConfig implements IConfigStore Object.assign(this.textStyleOption, { appointTextHight: false, needAngle: false, - textHight: 60, }); this.dimTextHeight = 60; this.boardCustomNumberTextHeight = 60; diff --git a/src/UI/Components/Board/BoardModalType.ts b/src/UI/Components/Board/BoardModalType.ts index 9b94c8f09..e4851797b 100644 --- a/src/UI/Components/Board/BoardModalType.ts +++ b/src/UI/Components/Board/BoardModalType.ts @@ -81,4 +81,5 @@ export enum BoardModalType ResourceStoreIcon = "resourceStoreIcon",//模型库列表的显示方式 SpaceParse = "SpaceParse",//空间解析配置 BBSModelStore = "bbsModelStore",//bbs模态框位置大小 + FontStyleStore = "FontStyleStore",//字体样式 } diff --git a/src/UI/Components/Board/DrillCommon.tsx b/src/UI/Components/Board/DrillCommon.tsx index 1607c2c34..a3ed8a900 100644 --- a/src/UI/Components/Board/DrillCommon.tsx +++ b/src/UI/Components/Board/DrillCommon.tsx @@ -1,4 +1,4 @@ -import { Button, Card, Checkbox, Classes, HTMLSelect, Intent, IOptionProps, Popover, Position } from '@blueprintjs/core'; +import { Button, Card, Checkbox, Classes, HTMLSelect, Intent, Popover, Position } from '@blueprintjs/core'; import { action, observable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; @@ -276,8 +276,6 @@ export class DrillTypeCom extends React.Component<{ store: DrillStore; }, { type @observer export class SelectDrillTemp extends React.Component<{ store: DrillStore; }, {}> { - @observable drillingTempList: IOptionProps[] = []; - @observable drillingDirList: IOptionProps[] = []; render() { let option = this.props.store.m_Option; diff --git a/src/UI/Components/Board/UserConfigComponent.tsx b/src/UI/Components/Board/UserConfigComponent.tsx index ab83e1f44..58e044116 100644 --- a/src/UI/Components/Board/UserConfigComponent.tsx +++ b/src/UI/Components/Board/UserConfigComponent.tsx @@ -52,7 +52,7 @@ export enum Config_ModalType ConfigListModal = 3, //用户列表样式 } -const alwaysUpdateType = [BoardModalType.SpotLight, BoardModalType.PointLight]; //都更新 (保存上一次配置除外) +const alwaysUpdateType = [BoardModalType.SpotLight, BoardModalType.PointLight, BoardModalType.FontStyleStore]; //都更新 (保存上一次配置除外) const alwaysNotUpdateType = [BoardModalType.RectAreaLight]; //都不更新 diff --git a/src/UI/Components/CommandPanel/CommandList.ts b/src/UI/Components/CommandPanel/CommandList.ts index 1233eff10..85b6484fa 100644 --- a/src/UI/Components/CommandPanel/CommandList.ts +++ b/src/UI/Components/CommandPanel/CommandList.ts @@ -1710,7 +1710,15 @@ export const CommandList: ICommand[] = [ chName: "标注样式", chDes: "设置当前图纸的标注样式", }, - + { + typeId: "dim", + link: `#`, + defaultCustom: CommandNames.Style, + command: CommandNames.Style, + type: "标注", + chName: "字体样式", + chDes: "设置字体样式", + }, //视觉样式命令 { icon: IconEnum.WireframeView, diff --git a/src/UI/Components/INumericInput.tsx b/src/UI/Components/INumericInput.tsx index 695c29a3a..6685397d0 100644 --- a/src/UI/Components/INumericInput.tsx +++ b/src/UI/Components/INumericInput.tsx @@ -17,6 +17,8 @@ interface INumericInputProps onBlur?: (e: React.FocusEvent) => void; //可以用来赋值使用 style?: React.CSSProperties; tooltip?: boolean; + tooltipValue?: string; + intent?: Intent; } @observer @@ -28,6 +30,7 @@ export class INumericInput extends React.Component _Value_Max: number = this.props.max ?? 1e7; _CanNull: boolean = this.props.canNull ?? false; //输入框值可为空 _InitialValue: number | string = this.props.value; //初始值 + _Intent: Intent = this.props.intent ?? Intent.WARNING; //tip Intent属性 @observable _Value: number | string = this.props.value; @observable _isPopoverOpen: boolean = false; @@ -41,9 +44,9 @@ export class INumericInput extends React.Component { return ( } /> } /> } /> - } /> + } />
diff --git a/src/UI/Components/Modal/OptionModal/TextConfigPanel.tsx b/src/UI/Components/Modal/OptionModal/TextConfigPanel.tsx index 1e6328e95..d90cb908a 100644 --- a/src/UI/Components/Modal/OptionModal/TextConfigPanel.tsx +++ b/src/UI/Components/Modal/OptionModal/TextConfigPanel.tsx @@ -5,10 +5,6 @@ import * as React from 'react'; import { userConfig } from "../../../../Editor/UserConfig"; import { INumericInput } from "../../INumericInput"; -const WDCss: React.CSSProperties = { - width: 100 -}; - const Padding: React.CSSProperties = { padding: "4px 0", margin: 0 @@ -18,8 +14,6 @@ const Padding: React.CSSProperties = { export class TextConfigPanel extends React.Component<{}> { @observable _isPopoverOpen: boolean = false; - @observable _textHeight: number = userConfig.dimTextHeight; - @observable _appoinTextHeight: boolean = userConfig.textStyleOption.appointTextHight; _InputEl = React.createRef(); render() { @@ -35,20 +29,6 @@ export class TextConfigPanel extends React.Component<{}> onChange={() => userConfig.textStyleOption.appointTextHight = !userConfig.textStyleOption.appointTextHight} />
-
- 文字高度: - - { - userConfig.textStyleOption.textHight = parseInt(e.currentTarget.value); - }} - /> -
/>
- 板号文字高度: + 板号文字高度: export class DownPanel extends React.Component<{ store: DownPanelStore; }, {}> { @observable showHideSyncEnable = false; //显隐同步显示 - rStore: RightPanelStore = RightPanelStore.GetInstance(); private downStore = DownPanelStore.GetInstance(); private handleChange = async (e: React.FormEvent) => { @@ -401,6 +402,21 @@ export class DownPanel extends React.Component<{ store: DownPanelStore; }, {}> return LightDataModeType.P; } + private GetFontStyleOption() + { + let option = []; + for (let symbols of app.Database.FontStyleTable.Symbols) + { + if (symbols) + { + let key = (symbols[1] as FontStyleRecord).FontType; + let label = FontTypeOption.find((obj) => obj.value === key).label; + option.push({ label: `${symbols[0]}(${label})`, value: symbols[0] }); + } + } + return option; + } + componentDidMount(): void { let gws = SwitchServerStore.GetInstance()._gangplankWs; @@ -515,13 +531,16 @@ export class DownPanel extends React.Component<{ store: DownPanelStore; }, {}> { - this.props.store.fontName = e.target.value; - this.props.store.Upload(); + let name = e.target.value; + let fontStyle = app.Database.FontStyleTable.Symbols.get(name) as FontStyleRecord; + app.Database.FontStyleTable.Current = fontStyle.objectId; + HostApplicationServices.CurrentFontStyle = fontStyle.objectId; + this.props.store.fontType = fontStyle.Name; }} - value={this.props.store.fontName} + value={this.props.store.fontType} style={{ height: 15, fontSize: "12px", outline: "none", verticalAlign: "bottom" }} - options={[ - { label: "宋体", value: "songti" }, { label: "雅黑", value: "yahei" }]} /> + options={this.GetFontStyleOption()} + />
diff --git a/src/UI/Components/ToolBar/Properties_Text.tsx b/src/UI/Components/ToolBar/Properties_Text.tsx index da4f86974..735913188 100644 --- a/src/UI/Components/ToolBar/Properties_Text.tsx +++ b/src/UI/Components/ToolBar/Properties_Text.tsx @@ -1,16 +1,11 @@ -import { Card, Classes, HTMLSelect, Intent, Position, Tooltip } from "@blueprintjs/core"; -import hotkeys from "hotkeys-js-ext"; +import { Card, Classes, HTMLSelect } from "@blueprintjs/core"; import { observable } from "mobx"; import { observer } from "mobx-react"; import React from "react"; -import { end } from "xaop"; -import { app } from "../../../ApplicationServices/Application"; -import { KeyBoard, KeyCode } from "../../../Common/KeyEnum"; -import { LogType } from "../../../Common/Log"; -import { FixedNotZero, digitStrReg } from "../../../Common/Utils"; -import { safeEval } from "../../../Common/eval"; +import { FixedNotZero } from "../../../Common/Utils"; import { Text, TextAligen } from "../../../DatabaseServices/Text/Text"; import { CommandWrap } from "../../../Editor/CommandMachine"; +import { INumericInput } from "../INumericInput"; export interface Properties_TextProps { @@ -21,26 +16,14 @@ export interface Properties_TextProps export class Properties_Text extends React.Component { _removeFuncs: Function[] = []; - _textHeightInputEl = React.createRef(); - @observable _numericInputVal: string = ""; - @observable _isPopoverOpen: boolean = false; + @observable _TextHeight: number = 60; + @observable _TextWidthFactor: number = 1; componentDidMount() { - let numval = this.props.ents[0].Height; - this._numericInputVal = FixedNotZero(numval, 2); - - this._removeFuncs.push( - end(app.Editor.KeyCtrl, app.Editor.KeyCtrl.OnKeyUp, (e: KeyboardEvent) => - { - if (hotkeys.ctrl) - if (e.code === KeyCode.KeyZ || e.code === KeyCode.KeyY) - { - let numval = this.props.ents[0].Height; - this._numericInputVal = FixedNotZero(numval, 2); - } - }) - ); + let text = this.props.ents[0]; + this._TextHeight = parseFloat(FixedNotZero(text.Height, 2)); + this._TextWidthFactor = text.WidthFactor; } componentWillUnmount() @@ -50,47 +33,6 @@ export class Properties_Text extends React.Component this._removeFuncs.length = 0; } - private handleChange = (el: HTMLInputElement) => - { - const vs = el.value; - let isOK = digitStrReg.test(vs); - if (isOK || vs === "") - { - this._textHeightInputEl.current.classList.remove("bp3-intent-danger"); - this._isPopoverOpen = false; - } - else - { - this._textHeightInputEl.current.classList.add("bp3-intent-danger"); - this._isPopoverOpen = true; - } - this._numericInputVal = vs; - }; - private handleFocus = (e: React.FocusEvent) => - { - this._textHeightInputEl.current.setSelectionRange(0, this._textHeightInputEl.current.value.length); - }; - private handleBlur = (e: React.FocusEvent) => - { - let val = safeEval(e.target.value); - if (!isNaN(val)) - { - if (val <= 0 || val > 999) - app.Editor.Prompt('文字尺寸仅限1-999间的数字!', LogType.Error); - else - { - CommandWrap(() => - { - for (let al of this.props.ents) - { - al.Height = val; - } - }, "字体大小"); - } - } - else - app.Editor.Prompt('文字尺寸仅限1-999间的数字!', LogType.Error); - }; _HandleSelectOnChange(e: React.ChangeEvent) { let ents = this.props.ents; @@ -111,36 +53,39 @@ export class Properties_Text extends React.Component
  • 文字尺寸: -
    - - - { - if (e.keyCode === KeyBoard.Escape) - { - //@ts-ignore - e.target.blur(); - } - - if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space) - this._textHeightInputEl.current.blur(); - e.stopPropagation(); - }} - onChange={e => this.handleChange(e.target)} - value={this._numericInputVal} - onFocus={this.handleFocus} - onBlur={this.handleBlur} - /> - -
    + + { + CommandWrap(() => + { + for (let al of this.props.ents) + al.Height = parseInt(e.target.value); + }, "字体大小"); + }} + /> +
    +
  • +
  • +
    + 宽度因子: + + { + CommandWrap(() => + { + for (let text of this.props.ents) + text.WidthFactor = parseInt(e.target.value); + }, "字体间距"); + }} + />
  • diff --git a/src/UI/Store/DownPanelStore.ts b/src/UI/Store/DownPanelStore.ts index 25b91a941..441bcf320 100644 --- a/src/UI/Store/DownPanelStore.ts +++ b/src/UI/Store/DownPanelStore.ts @@ -2,10 +2,12 @@ import { action, autorun, observable, reaction } from 'mobx'; import * as xaop from 'xaop'; import { Command_ToggleUI } from '../../Add-on/ToggleUI'; import { app } from '../../ApplicationServices/Application'; +import { HostApplicationServices } from '../../ApplicationServices/HostApplicationServices'; import { appCache } from '../../Common/AppCache'; import { ConfigUrls } from '../../Common/HostUrl'; import { PostJson, RequestStatus } from '../../Common/Request'; import { GetIndexDBID } from '../../Common/Utils'; +import { FontStyleRecord } from '../../DatabaseServices/FontStyle/FontsStyleRecord'; import { ObjectSnapMode } from '../../Editor/ObjectSnapMode'; import { SNAPMODE } from '../../Editor/ShowSnapMenu'; import { AxisSnapMode } from '../../Editor/SnapServices'; @@ -57,8 +59,6 @@ export class DownPanelStore @observable useDynSnap: boolean = true; @observable usePass: boolean = true; @observable useOrtho: boolean = false; - @observable fontName: string = "songti"; - @observable progressName = ""; @observable progress = 1; @observable isF3Checked: boolean = true;//捕捉开启 @@ -158,6 +158,7 @@ export class DownPanelStore @observable showHideSync: boolean = false; //显隐同步 @observable smartUCS: boolean = false; //智能UCS @observable capturePenetration: boolean = true; //捕捉穿透 + @observable fontType = ""; private timeId; private constructor() @@ -189,6 +190,8 @@ export class DownPanelStore app.LayoutTool.SwitchLayout(); }); + + this.fontType = (HostApplicationServices.CurrentFontStyle.Object as FontStyleRecord).Name; } private OnWindowsResize = () => @@ -226,7 +229,6 @@ export class DownPanelStore isF3Checked: this.isF3Checked, isF11Checked: this.isF11Checked, snapData: this.snapData.map(d => d.enable), - fontName: this.fontName, lightsData: this.lightsData.map(l => l.enable), showHideSync: this.showHideSync, smartUCS: this.smartUCS, @@ -298,7 +300,6 @@ export class DownPanelStore this.isF3Checked = config.isF3Checked; this.isF11Checked = config.isF11Checked; - this.fontName = config.fontName; for (let i = 0; i < config.snapData.length; i++) { if (this.snapData[i])