aldehyde 0.2.480 → 0.2.481
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +2 -2
- package/lib/controls/2dEditor/2dEditor/index.less +5 -5
- package/lib/controls/2dEditor/2dView/index.less +8 -8
- package/lib/controls/2dEditor/components/component.less +83 -83
- package/lib/controls/action/index.css +8 -8
- package/lib/controls/action/index.d.ts.map +1 -1
- package/lib/controls/chemstruc/graph.d.ts.map +1 -1
- package/lib/controls/chemstruc/index.css +28 -28
- package/lib/controls/collapse-card/index.css +8 -8
- package/lib/controls/collapse-card/index.d.ts.map +1 -1
- package/lib/controls/cquery/cquick-button.d.ts.map +1 -1
- package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
- package/lib/controls/entity-select/index.css +7 -7
- package/lib/controls/entity-select/lab-tree-select.d.ts.map +1 -1
- package/lib/controls/entity-select/popover-entity-select.d.ts.map +1 -1
- package/lib/controls/file-view/index.less +9 -9
- package/lib/controls/html-editor/index.less +67 -67
- package/lib/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.css +147 -147
- package/lib/controls/password-setter/index.css +2 -2
- package/lib/controls/password-setter/index.d.ts.map +1 -1
- package/lib/controls/qr-code/index.less +28 -28
- package/lib/controls/relation-existion/index.css +3 -3
- package/lib/controls/relation-existion/index.d.ts.map +1 -1
- package/lib/controls/rfield/index.css +4 -4
- package/lib/controls/rfield/index.d.ts.map +1 -1
- package/lib/controls/select/index.d.ts.map +1 -1
- package/lib/controls/signature/index.d.ts.map +1 -1
- package/lib/controls/text/ellipsis-text.d.ts.map +1 -1
- package/lib/controls/text/index.less +7 -7
- package/lib/controls/upload/index.d.ts.map +1 -1
- package/lib/controls/upload/mult-file-upload.d.ts.map +1 -1
- package/lib/custom-page/dtmpl-custom-edit-modal-page.d.ts.map +1 -1
- package/lib/detail/button/bottom-submit-button-bar.d.ts.map +1 -1
- package/lib/detail/button/cquery-button-bar.d.ts.map +1 -1
- package/lib/detail/button/fix-right-submit-button-bar.d.ts.map +1 -1
- package/lib/detail/button/index.css +42 -42
- package/lib/detail/dtmpl.css +67 -67
- package/lib/detail/edit/fields-edit-card.d.ts.map +1 -1
- package/lib/detail/edit/modal-row-edit.d.ts.map +1 -1
- package/lib/detail/edit/popover-edit-card.d.ts.map +1 -1
- package/lib/detail/rightbar/index.css +34 -34
- package/lib/detail/rightbar/index.d.ts.map +1 -1
- package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/field-view-group.d.ts.map +1 -1
- package/lib/detail/view/modal-dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/snapshot-timeline.d.ts.map +1 -1
- package/lib/detail/view/tab-act-dtmpl-view.d.ts.map +1 -1
- package/lib/draw-canvas-edit/components/render/components/index.d.ts +3 -0
- package/lib/draw-canvas-edit/components/render/components/index.d.ts.map +1 -0
- package/lib/draw-canvas-edit/components/render/components/index.js +3 -0
- package/lib/draw-canvas-edit/components/render/components/index.js.map +1 -0
- package/lib/draw-canvas-edit/components/render/components/workstation-component.d.ts +31 -0
- package/lib/draw-canvas-edit/components/render/components/workstation-component.d.ts.map +1 -0
- package/lib/draw-canvas-edit/components/render/components/workstation-component.js +105 -0
- package/lib/draw-canvas-edit/components/render/components/workstation-component.js.map +1 -0
- package/lib/draw-canvas-edit/components/render/tools/component-factory.d.ts +2 -0
- package/lib/draw-canvas-edit/components/render/tools/component-factory.d.ts.map +1 -1
- package/lib/draw-canvas-edit/components/render/tools/component-factory.js +10 -42
- package/lib/draw-canvas-edit/components/render/tools/component-factory.js.map +1 -1
- package/lib/draw-canvas-edit/components/render/types.d.ts +3 -0
- package/lib/draw-canvas-edit/components/render/types.d.ts.map +1 -1
- package/lib/draw-canvas-edit/components/render/types.js.map +1 -1
- package/lib/draw-canvas-edit/index.less +48 -48
- package/lib/draw-canvas-view/index.less +59 -59
- package/lib/draw-canvas-view/view.d.ts.map +1 -1
- package/lib/draw-canvas-view/view.js +19 -6
- package/lib/draw-canvas-view/view.js.map +1 -1
- package/lib/export/export-frame.css +2 -2
- package/lib/export/export-frame.d.ts.map +1 -1
- package/lib/export/select-code-export-frame.d.ts.map +1 -1
- package/lib/form/dtmpl-form.css +3 -3
- package/lib/form/dtmpl-form.d.ts.map +1 -1
- package/lib/form/dtmpl-form.js +1 -1
- package/lib/form/dtmpl-form.js.map +1 -1
- package/lib/form/field-group-form.d.ts.map +1 -1
- package/lib/form/form-Item-group.d.ts.map +1 -1
- package/lib/form/index.css +12 -12
- package/lib/import/excel-import.d.ts.map +1 -1
- package/lib/import/index.css +53 -53
- package/lib/import/template.css +50 -50
- package/lib/layout/common.css +64 -64
- package/lib/layout/coverstyle.css +51 -51
- package/lib/layout/footer/index.css +5 -5
- package/lib/layout/header/index.css +122 -122
- package/lib/layout/menu/block.css +7 -7
- package/lib/layout/menu/block.d.ts.map +1 -1
- package/lib/layout/menu/l2menu-quick-bar.d.ts.map +1 -1
- package/lib/layout/menu/menu-2layers.d.ts.map +1 -1
- package/lib/layout/menu/message-bar.less +73 -73
- package/lib/layout/menu/reset-password.d.ts.map +1 -1
- package/lib/layout/menu/user-bar.d.ts.map +1 -1
- package/lib/layout/menu/userinfo-bar.d.ts.map +1 -1
- package/lib/layout/sidebar/index.css +57 -57
- package/lib/layout2/css/header.css +41 -41
- package/lib/layout2/css/sider.less +17 -17
- package/lib/layout2/css/tabs-layout.less +18 -18
- package/lib/layout3/css/header.less +195 -195
- package/lib/layout3/css/main.less +161 -161
- package/lib/layout3/css/sider.less +32 -32
- package/lib/layout3/css/tabs-layout.less +38 -38
- package/lib/layout4/css/header.less +196 -196
- package/lib/layout4/css/main.less +154 -154
- package/lib/layout4/css/sider.less +37 -37
- package/lib/layout4/css/tabs-layout.less +42 -42
- package/lib/layout5/css/header.less +35 -35
- package/lib/layout5/css/sider.less +18 -18
- package/lib/list/calendar/index.less +20 -20
- package/lib/list/card-list/index.less +154 -154
- package/lib/list/gantt/index.less +8 -8
- package/lib/list/vertical-list/index.less +208 -208
- package/lib/login/index.css +19 -19
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/vertify/index.css +143 -143
- package/lib/login3/index.less +136 -136
- package/lib/lowcode-components/act-table/index.less +26 -26
- package/lib/lowcode-components/base-button/index.less +7 -7
- package/lib/lowcode-components/base-map/index.js +6 -6
- package/lib/lowcode-components/base-radio/index.less +23 -23
- package/lib/lowcode-components/base-tabs/index.less +14 -14
- package/lib/lowcode-components/border/border10/index.less +26 -26
- package/lib/lowcode-components/border/border11/index.js +46 -46
- package/lib/lowcode-components/border/border11/index.less +17 -17
- package/lib/lowcode-components/border/border12/index.js +13 -13
- package/lib/lowcode-components/border/border12/index.less +13 -13
- package/lib/lowcode-components/border/border13/index.js +5 -5
- package/lib/lowcode-components/border/border13/index.less +13 -13
- package/lib/lowcode-components/border/border2/index.less +17 -17
- package/lib/lowcode-components/border/border3/index.less +25 -25
- package/lib/lowcode-components/border/border4/index.js +2 -2
- package/lib/lowcode-components/border/border4/index.less +72 -72
- package/lib/lowcode-components/border/border5/index.js +2 -2
- package/lib/lowcode-components/border/border5/index.less +35 -35
- package/lib/lowcode-components/border/border6/index.less +17 -17
- package/lib/lowcode-components/border/border7/index.less +26 -26
- package/lib/lowcode-components/border/border8/index.less +13 -13
- package/lib/lowcode-components/border/border9/index.js +14 -14
- package/lib/lowcode-components/border/border9/index.less +13 -13
- package/lib/lowcode-components/decoration/decoration1/index.less +7 -7
- package/lib/lowcode-components/decoration/decoration10/index.js +3 -3
- package/lib/lowcode-components/decoration/decoration10/index.less +5 -5
- package/lib/lowcode-components/decoration/decoration11/index.less +5 -5
- package/lib/lowcode-components/decoration/decoration2/index.less +6 -6
- package/lib/lowcode-components/decoration/decoration3/index.less +7 -7
- package/lib/lowcode-components/decoration/decoration4/index.less +29 -29
- package/lib/lowcode-components/decoration/decoration5/index.less +3 -3
- package/lib/lowcode-components/decoration/decoration6/index.less +7 -7
- package/lib/lowcode-components/decoration/decoration7/index.less +4 -4
- package/lib/lowcode-components/decoration/decoration8/index.less +14 -14
- package/lib/lowcode-components/decoration/decoration9/index.less +4 -4
- package/lib/lowcode-components/effectScatter-map/index.js +6 -6
- package/lib/lowcode-components/effectScatter-map-3d/index.js +6 -6
- package/lib/lowcode-components/lowcode-view/index.less +19 -19
- package/lib/lowcode-components/search-form/index.less +25 -25
- package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
- package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
- package/lib/module/index.less +4 -4
- package/lib/module/ltmpl-modal.d.ts.map +1 -1
- package/lib/module/ltmpl-table.d.ts.map +1 -1
- package/lib/routable/index.less +25 -25
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/column/index.less +63 -63
- package/lib/table/index.css +211 -211
- package/lib/table/modal-select-table.d.ts.map +1 -1
- package/lib/table/pagination.css +14 -14
- package/lib/table/pagination.d.ts.map +1 -1
- package/lib/table/relation-table.d.ts.map +1 -1
- package/lib/table/select-table.d.ts.map +1 -1
- package/lib/table/select-table.js +14 -2
- package/lib/table/select-table.js.map +1 -1
- package/lib/table/selected-rows-card.d.ts.map +1 -1
- package/lib/table/stat/restat.d.ts.map +1 -1
- package/lib/tree/act-tree.d.ts.map +1 -1
- package/lib/tree/block-menu-auth-tree.d.ts.map +1 -1
- package/lib/tree/index.css +22 -22
- package/lib/tree/tmpl-tree.d.ts.map +1 -1
- package/lib/welcome/components/menu-card.less +96 -96
- package/lib/welcome/components/page-card.less +49 -49
- package/lib/welcome/components/quick-entrance.less +120 -120
- package/lib/welcome/components/user-menus.less +192 -192
- package/lib/welcome/components/workbench.less +118 -118
- package/lib/welcome/index.css +13 -13
- package/package.json +223 -223
- package/src/aldehyde/controls/2dEditor/2dEditor/index.less +5 -5
- package/src/aldehyde/controls/2dEditor/2dEditor/index.tsx +270 -270
- package/src/aldehyde/controls/2dEditor/2dView/index.less +8 -8
- package/src/aldehyde/controls/2dEditor/2dView/index.tsx +110 -110
- package/src/aldehyde/controls/2dEditor/components/card.tsx +256 -256
- package/src/aldehyde/controls/2dEditor/components/component.less +83 -83
- package/src/aldehyde/controls/2dEditor/components/data.d.ts +32 -32
- package/src/aldehyde/controls/2dEditor/components/hotspot.tsx +80 -80
- package/src/aldehyde/controls/2dEditor/components/html-box.tsx +101 -101
- package/src/aldehyde/controls/2dEditor/components/image.tsx +99 -99
- package/src/aldehyde/controls/2dEditor/components/line.tsx +73 -73
- package/src/aldehyde/controls/action/index.css +8 -8
- package/src/aldehyde/controls/action/index.tsx +406 -406
- package/src/aldehyde/controls/action/utils.tsx +306 -306
- package/src/aldehyde/controls/auto-complete/index.tsx +82 -82
- package/src/aldehyde/controls/cascader/index.tsx +112 -112
- package/src/aldehyde/controls/chemstruc/graph.tsx +185 -185
- package/src/aldehyde/controls/chemstruc/index.css +28 -28
- package/src/aldehyde/controls/code-editor/sql-code-editor.tsx +73 -73
- package/src/aldehyde/controls/collapse-card/index.css +8 -8
- package/src/aldehyde/controls/collapse-card/index.tsx +109 -109
- package/src/aldehyde/controls/color-picker/index.tsx +21 -21
- package/src/aldehyde/controls/counting-tag/index.tsx +53 -53
- package/src/aldehyde/controls/cquery/cquick-button.tsx +145 -145
- package/src/aldehyde/controls/date-picker/index.tsx +199 -199
- package/src/aldehyde/controls/direct-file-view/drawer-file-view.tsx +54 -54
- package/src/aldehyde/controls/direct-file-view/index.tsx +145 -145
- package/src/aldehyde/controls/direct-upload/index.tsx +139 -139
- package/src/aldehyde/controls/entity-select/entity-select.tsx +791 -791
- package/src/aldehyde/controls/entity-select/index.css +7 -7
- package/src/aldehyde/controls/entity-select/lab-tree-select.tsx +154 -154
- package/src/aldehyde/controls/entity-select/popover-entity-select.tsx +205 -205
- package/src/aldehyde/controls/entry-control.tsx +418 -418
- package/src/aldehyde/controls/enum-badge/index.tsx +42 -42
- package/src/aldehyde/controls/enum-tag/index.tsx +45 -45
- package/src/aldehyde/controls/field-history/index.tsx +81 -81
- package/src/aldehyde/controls/file-export/select-code-export.tsx +40 -40
- package/src/aldehyde/controls/file-view/drawer-file-view.tsx +117 -117
- package/src/aldehyde/controls/file-view/index.less +9 -9
- package/src/aldehyde/controls/file-view/index.tsx +148 -148
- package/src/aldehyde/controls/file-view/multi-file-view.tsx +39 -39
- package/src/aldehyde/controls/file-view/newin-file-view.tsx +40 -40
- package/src/aldehyde/controls/html-editor/draft.tsx +136 -136
- package/src/aldehyde/controls/html-editor/index.less +67 -67
- package/src/aldehyde/controls/icon-selector/app-icon-selector.tsx +68 -68
- package/src/aldehyde/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.css +147 -147
- package/src/aldehyde/controls/icon-selector/icon/aldehyde-menu-icon/iconfont.json +240 -240
- package/src/aldehyde/controls/icon-selector/pc-icon-selector.tsx +68 -68
- package/src/aldehyde/controls/input-number/index.tsx +148 -148
- package/src/aldehyde/controls/input-range/index.tsx +59 -59
- package/src/aldehyde/controls/password-setter/index.css +2 -2
- package/src/aldehyde/controls/password-setter/index.js +88 -88
- package/src/aldehyde/controls/progress/index.tsx +74 -74
- package/src/aldehyde/controls/qr-code/index.less +28 -28
- package/src/aldehyde/controls/qr-code/index.tsx +40 -40
- package/src/aldehyde/controls/relation-existion/index.css +3 -3
- package/src/aldehyde/controls/relation-existion/index.tsx +144 -144
- package/src/aldehyde/controls/rfield/index.css +4 -4
- package/src/aldehyde/controls/rfield/index.tsx +225 -225
- package/src/aldehyde/controls/select/index.tsx +216 -216
- package/src/aldehyde/controls/signature/index.tsx +226 -226
- package/src/aldehyde/controls/single-checkbox/index.tsx +18 -18
- package/src/aldehyde/controls/steps/index.tsx +59 -59
- package/src/aldehyde/controls/text/ellipsis-text.tsx +98 -98
- package/src/aldehyde/controls/text/index.less +7 -7
- package/src/aldehyde/controls/tree-select/navigation-tree.tsx +122 -122
- package/src/aldehyde/controls/tree-select/tree-entity-select.tsx +121 -121
- package/src/aldehyde/controls/upload/index.tsx +128 -128
- package/src/aldehyde/controls/upload/mult-file-upload.tsx +240 -240
- package/src/aldehyde/controls/view-control.tsx +289 -289
- package/src/aldehyde/custom-page/custom-detail-modal-page.tsx +69 -69
- package/src/aldehyde/custom-page/custom-page-router.tsx +64 -64
- package/src/aldehyde/custom-page/def-custom-page.tsx +17 -17
- package/src/aldehyde/custom-page/dtmpl-custom-edit-modal-page.tsx +88 -88
- package/src/aldehyde/detail/button/bottom-submit-button-bar.tsx +91 -91
- package/src/aldehyde/detail/button/cquery-button-bar.tsx +144 -144
- package/src/aldehyde/detail/button/edit-button.tsx +61 -61
- package/src/aldehyde/detail/button/fix-right-submit-button-bar.tsx +186 -186
- package/src/aldehyde/detail/button/index.css +42 -42
- package/src/aldehyde/detail/button/inline-edit-button.tsx +40 -40
- package/src/aldehyde/detail/button/submit-button-bar.tsx +57 -57
- package/src/aldehyde/detail/button/view-button.tsx +64 -64
- package/src/aldehyde/detail/dtmpl.css +67 -67
- package/src/aldehyde/detail/edit/dtmpl-edit.tsx +279 -279
- package/src/aldehyde/detail/edit/fields-edit-card.tsx +145 -145
- package/src/aldehyde/detail/edit/modal-row-edit.tsx +95 -95
- package/src/aldehyde/detail/edit/popover-edit-card.tsx +167 -167
- package/src/aldehyde/detail/edit/popover-editor.tsx +70 -70
- package/src/aldehyde/detail/edit/post-result/index.tsx +86 -86
- package/src/aldehyde/detail/rightbar/index.css +34 -34
- package/src/aldehyde/detail/rightbar/index.tsx +92 -92
- package/src/aldehyde/detail/tooltipbar/index.tsx +32 -32
- package/src/aldehyde/detail/view/act-dtmpl-view.tsx +288 -288
- package/src/aldehyde/detail/view/dtmpl-view.tsx +314 -314
- package/src/aldehyde/detail/view/field-view-group.tsx +88 -88
- package/src/aldehyde/detail/view/modal-dtmpl-view.tsx +73 -73
- package/src/aldehyde/detail/view/snapshot-timeline.tsx +231 -231
- package/src/aldehyde/detail/view/tab-act-dtmpl-view.tsx +304 -304
- package/src/aldehyde/detail/view/view-compare-panel.tsx +57 -57
- package/src/aldehyde/draw-canvas-edit/components/render/components/index.ts +3 -0
- package/src/aldehyde/draw-canvas-edit/components/render/components/workstation-component.tsx +104 -0
- package/src/aldehyde/draw-canvas-edit/components/render/draws/bg-draw.ts +176 -176
- package/src/aldehyde/draw-canvas-edit/components/render/draws/contextmenu-draw.ts +329 -329
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/bezier.ts +542 -542
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-outside-handlers.ts +72 -72
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/selection-handlers.ts +396 -396
- package/src/aldehyde/draw-canvas-edit/components/render/index.ts +808 -808
- package/src/aldehyde/draw-canvas-edit/components/render/tools/attract-tool.ts +457 -457
- package/src/aldehyde/draw-canvas-edit/components/render/tools/component-factory.ts +270 -302
- package/src/aldehyde/draw-canvas-edit/components/render/tools/copy-tool.ts +244 -244
- package/src/aldehyde/draw-canvas-edit/components/render/tools/import-export-tool.ts +576 -576
- package/src/aldehyde/draw-canvas-edit/components/render/tools/index.ts +10 -10
- package/src/aldehyde/draw-canvas-edit/components/render/tools/position-tool.ts +191 -191
- package/src/aldehyde/draw-canvas-edit/components/render/tools/selection-tool.ts +140 -140
- package/src/aldehyde/draw-canvas-edit/components/render/types.ts +294 -291
- package/src/aldehyde/draw-canvas-edit/components/setting-form/index.tsx +291 -291
- package/src/aldehyde/draw-canvas-edit/constant.ts +5 -5
- package/src/aldehyde/draw-canvas-edit/index.less +48 -48
- package/src/aldehyde/draw-canvas-edit/index.tsx +201 -201
- package/src/aldehyde/draw-canvas-view/index.less +59 -59
- package/src/aldehyde/draw-canvas-view/index.tsx +49 -49
- package/src/aldehyde/draw-canvas-view/view.tsx +17 -5
- package/src/aldehyde/export/export-frame.css +2 -2
- package/src/aldehyde/export/export-frame.tsx +301 -301
- package/src/aldehyde/export/select-code-export-frame.tsx +212 -212
- package/src/aldehyde/form/criteria-form.tsx +604 -604
- package/src/aldehyde/form/dtmpl-form.css +3 -3
- package/src/aldehyde/form/dtmpl-form.tsx +552 -552
- package/src/aldehyde/form/field-group-form.tsx +102 -102
- package/src/aldehyde/form/fields-form.tsx +45 -45
- package/src/aldehyde/form/form-Item-group.tsx +245 -245
- package/src/aldehyde/form/index.css +12 -12
- package/src/aldehyde/hooks/use-match-route/index.tsx +62 -62
- package/src/aldehyde/hooks/use-tabs/index.tsx +139 -139
- package/src/aldehyde/hooks/useVarCssColor.ts +6 -6
- package/src/aldehyde/icon/aliIcon.tsx +9 -9
- package/src/aldehyde/icon/index.tsx +28 -28
- package/src/aldehyde/import/excel-import.tsx +450 -450
- package/src/aldehyde/import/index.css +53 -53
- package/src/aldehyde/import/template.css +50 -50
- package/src/aldehyde/index.tsx +220 -220
- package/src/aldehyde/layout/MainPage.tsx +334 -334
- package/src/aldehyde/layout/common.css +64 -64
- package/src/aldehyde/layout/coverstyle.css +51 -51
- package/src/aldehyde/layout/footer/index.css +5 -5
- package/src/aldehyde/layout/footer/index.js +17 -17
- package/src/aldehyde/layout/header/index.css +122 -122
- package/src/aldehyde/layout/header/index.tsx +152 -152
- package/src/aldehyde/layout/menu/block.css +7 -7
- package/src/aldehyde/layout/menu/block.tsx +174 -174
- package/src/aldehyde/layout/menu/l2menu-message-bar.tsx +160 -160
- package/src/aldehyde/layout/menu/l2menu-quick-bar.tsx +175 -175
- package/src/aldehyde/layout/menu/menu-2layers.tsx +117 -117
- package/src/aldehyde/layout/menu/menu-render.tsx +168 -168
- package/src/aldehyde/layout/menu/message-bar.less +73 -73
- package/src/aldehyde/layout/menu/reset-password.tsx +255 -255
- package/src/aldehyde/layout/menu/user-bar.tsx +259 -259
- package/src/aldehyde/layout/menu/userinfo-bar.tsx +69 -69
- package/src/aldehyde/layout/sidebar/index.css +57 -57
- package/src/aldehyde/layout/sidebar/index.tsx +84 -84
- package/src/aldehyde/layout2/components/icon-font.tsx +7 -7
- package/src/aldehyde/layout2/components/screenfull-button.tsx +21 -21
- package/src/aldehyde/layout2/components/search-menu.tsx +85 -85
- package/src/aldehyde/layout2/components/system-messages.tsx +75 -75
- package/src/aldehyde/layout2/components/theme-button.tsx +65 -65
- package/src/aldehyde/layout2/components/user-button.tsx +258 -258
- package/src/aldehyde/layout2/components/user-notification.tsx +74 -74
- package/src/aldehyde/layout2/css/header.css +41 -41
- package/src/aldehyde/layout2/css/sider.less +17 -17
- package/src/aldehyde/layout2/css/tabs-layout.less +18 -18
- package/src/aldehyde/layout2/header.tsx +278 -278
- package/src/aldehyde/layout2/layout-context.tsx +95 -95
- package/src/aldehyde/layout2/main.tsx +30 -30
- package/src/aldehyde/layout2/page.tsx +315 -315
- package/src/aldehyde/layout2/sider.tsx +230 -230
- package/src/aldehyde/layout2/tabs/tabs-context.tsx +37 -37
- package/src/aldehyde/layout2/tabs/tabs-layout.tsx +146 -146
- package/src/aldehyde/layout2/type/layout-type.ts +15 -15
- package/src/aldehyde/layout2/util/menu-util.tsx +125 -125
- package/src/aldehyde/layout3/components/tabs-layout.tsx +110 -110
- package/src/aldehyde/layout3/components/time.tsx +25 -25
- package/src/aldehyde/layout3/css/header.less +195 -195
- package/src/aldehyde/layout3/css/main.less +161 -161
- package/src/aldehyde/layout3/css/sider.less +32 -32
- package/src/aldehyde/layout3/css/tabs-layout.less +38 -38
- package/src/aldehyde/layout3/header.tsx +187 -187
- package/src/aldehyde/layout3/main.tsx +29 -29
- package/src/aldehyde/layout3/page.tsx +110 -110
- package/src/aldehyde/layout3/sider.tsx +198 -198
- package/src/aldehyde/layout4/components/tabs-layout.tsx +110 -110
- package/src/aldehyde/layout4/css/header.less +196 -196
- package/src/aldehyde/layout4/css/main.less +154 -154
- package/src/aldehyde/layout4/css/sider.less +37 -37
- package/src/aldehyde/layout4/css/tabs-layout.less +42 -42
- package/src/aldehyde/layout4/header.tsx +190 -190
- package/src/aldehyde/layout4/main.tsx +29 -29
- package/src/aldehyde/layout4/page.tsx +125 -125
- package/src/aldehyde/layout4/sider.tsx +201 -201
- package/src/aldehyde/layout5/css/header.less +35 -35
- package/src/aldehyde/layout5/css/sider.less +18 -18
- package/src/aldehyde/layout5/header.tsx +204 -204
- package/src/aldehyde/layout5/page.tsx +107 -107
- package/src/aldehyde/layout5/sider.tsx +235 -235
- package/src/aldehyde/list/calendar/index.less +20 -20
- package/src/aldehyde/list/calendar/index.tsx +157 -157
- package/src/aldehyde/list/card-list/card-list-item.tsx +111 -111
- package/src/aldehyde/list/card-list/index.less +154 -154
- package/src/aldehyde/list/card-list/index.tsx +83 -83
- package/src/aldehyde/list/gantt/index.less +8 -8
- package/src/aldehyde/list/gantt/index.tsx +508 -508
- package/src/aldehyde/list/vertical-list/index.less +208 -208
- package/src/aldehyde/list/vertical-list/index.tsx +55 -55
- package/src/aldehyde/list/vertical-list/item.tsx +136 -136
- package/src/aldehyde/locale/LocaleButton.tsx +48 -48
- package/src/aldehyde/locale/LocaleProvider.tsx +265 -265
- package/src/aldehyde/locale/langMp.ts +45 -45
- package/src/aldehyde/locale/translate.ts +80 -80
- package/src/aldehyde/locale/useLocale.ts +72 -72
- package/src/aldehyde/login/context-setter.tsx +130 -130
- package/src/aldehyde/login/index.css +19 -19
- package/src/aldehyde/login/login.tsx +255 -255
- package/src/aldehyde/login/router-login.tsx +107 -107
- package/src/aldehyde/login/vertify/index.css +143 -143
- package/src/aldehyde/login/vertify/index.tsx +360 -360
- package/src/aldehyde/login/vertify/tool.ts +13 -13
- package/src/aldehyde/login2/login-page.tsx +92 -92
- package/src/aldehyde/login2/login.tsx +226 -226
- package/src/aldehyde/login3/index.less +136 -136
- package/src/aldehyde/login3/login-page.tsx +71 -71
- package/src/aldehyde/lowcode-components/act-table/index.less +26 -26
- package/src/aldehyde/lowcode-components/act-table/index.tsx +139 -139
- package/src/aldehyde/lowcode-components/assets/lowcode-constant.tsx +12 -12
- package/src/aldehyde/lowcode-components/bar-chart/index.tsx +268 -268
- package/src/aldehyde/lowcode-components/base-button/index.less +7 -7
- package/src/aldehyde/lowcode-components/base-button/index.tsx +197 -197
- package/src/aldehyde/lowcode-components/base-image/index.tsx +220 -220
- package/src/aldehyde/lowcode-components/base-map/index.tsx +292 -292
- package/src/aldehyde/lowcode-components/base-radio/index.less +23 -23
- package/src/aldehyde/lowcode-components/base-radio/index.tsx +157 -157
- package/src/aldehyde/lowcode-components/base-table/index.tsx +268 -268
- package/src/aldehyde/lowcode-components/base-tabs/index.less +14 -14
- package/src/aldehyde/lowcode-components/base-tabs/index.tsx +183 -183
- package/src/aldehyde/lowcode-components/base-text/index.tsx +58 -58
- package/src/aldehyde/lowcode-components/border/border1/index.tsx +70 -70
- package/src/aldehyde/lowcode-components/border/border10/index.less +26 -26
- package/src/aldehyde/lowcode-components/border/border10/index.tsx +45 -45
- package/src/aldehyde/lowcode-components/border/border11/index.less +17 -17
- package/src/aldehyde/lowcode-components/border/border11/index.tsx +232 -232
- package/src/aldehyde/lowcode-components/border/border12/index.less +13 -13
- package/src/aldehyde/lowcode-components/border/border12/index.tsx +115 -115
- package/src/aldehyde/lowcode-components/border/border13/index.less +13 -13
- package/src/aldehyde/lowcode-components/border/border13/index.tsx +69 -69
- package/src/aldehyde/lowcode-components/border/border2/index.less +17 -17
- package/src/aldehyde/lowcode-components/border/border2/index.tsx +51 -51
- package/src/aldehyde/lowcode-components/border/border3/index.less +25 -25
- package/src/aldehyde/lowcode-components/border/border3/index.tsx +61 -61
- package/src/aldehyde/lowcode-components/border/border4/index.less +72 -72
- package/src/aldehyde/lowcode-components/border/border4/index.tsx +79 -79
- package/src/aldehyde/lowcode-components/border/border5/index.less +35 -35
- package/src/aldehyde/lowcode-components/border/border5/index.tsx +75 -75
- package/src/aldehyde/lowcode-components/border/border6/index.less +17 -17
- package/src/aldehyde/lowcode-components/border/border6/index.tsx +60 -60
- package/src/aldehyde/lowcode-components/border/border7/index.less +26 -26
- package/src/aldehyde/lowcode-components/border/border7/index.tsx +75 -75
- package/src/aldehyde/lowcode-components/border/border8/index.less +13 -13
- package/src/aldehyde/lowcode-components/border/border8/index.tsx +84 -84
- package/src/aldehyde/lowcode-components/border/border9/index.less +13 -13
- package/src/aldehyde/lowcode-components/border/border9/index.tsx +154 -154
- package/src/aldehyde/lowcode-components/capsule-bar-chart/index.tsx +290 -290
- package/src/aldehyde/lowcode-components/carousel/index.tsx +218 -218
- package/src/aldehyde/lowcode-components/circular-progress-chart/index.tsx +263 -263
- package/src/aldehyde/lowcode-components/column-3d-chart/index.tsx +438 -438
- package/src/aldehyde/lowcode-components/column-chart/index.tsx +293 -293
- package/src/aldehyde/lowcode-components/data-number/index.tsx +219 -219
- package/src/aldehyde/lowcode-components/data.d.ts +18 -18
- package/src/aldehyde/lowcode-components/decoration/decoration1/index.less +7 -7
- package/src/aldehyde/lowcode-components/decoration/decoration1/index.tsx +153 -153
- package/src/aldehyde/lowcode-components/decoration/decoration10/index.less +5 -5
- package/src/aldehyde/lowcode-components/decoration/decoration10/index.tsx +89 -89
- package/src/aldehyde/lowcode-components/decoration/decoration11/index.less +5 -5
- package/src/aldehyde/lowcode-components/decoration/decoration11/index.tsx +133 -133
- package/src/aldehyde/lowcode-components/decoration/decoration2/index.less +6 -6
- package/src/aldehyde/lowcode-components/decoration/decoration2/index.tsx +61 -61
- package/src/aldehyde/lowcode-components/decoration/decoration3/index.less +7 -7
- package/src/aldehyde/lowcode-components/decoration/decoration3/index.tsx +87 -87
- package/src/aldehyde/lowcode-components/decoration/decoration4/index.less +29 -29
- package/src/aldehyde/lowcode-components/decoration/decoration4/index.tsx +53 -53
- package/src/aldehyde/lowcode-components/decoration/decoration5/index.less +3 -3
- package/src/aldehyde/lowcode-components/decoration/decoration5/index.tsx +116 -116
- package/src/aldehyde/lowcode-components/decoration/decoration6/index.less +7 -7
- package/src/aldehyde/lowcode-components/decoration/decoration6/index.tsx +121 -121
- package/src/aldehyde/lowcode-components/decoration/decoration7/index.less +4 -4
- package/src/aldehyde/lowcode-components/decoration/decoration7/index.tsx +70 -70
- package/src/aldehyde/lowcode-components/decoration/decoration8/index.less +14 -14
- package/src/aldehyde/lowcode-components/decoration/decoration8/index.tsx +122 -122
- package/src/aldehyde/lowcode-components/decoration/decoration9/index.less +4 -4
- package/src/aldehyde/lowcode-components/decoration/decoration9/index.tsx +196 -196
- package/src/aldehyde/lowcode-components/effectScatter-map/index.tsx +315 -315
- package/src/aldehyde/lowcode-components/effectScatter-map-3d/index.tsx +419 -419
- package/src/aldehyde/lowcode-components/gauge-chart/index.tsx +254 -254
- package/src/aldehyde/lowcode-components/index.ts +130 -130
- package/src/aldehyde/lowcode-components/line-bar-chart/index.tsx +300 -300
- package/src/aldehyde/lowcode-components/line-chart/index.tsx +290 -290
- package/src/aldehyde/lowcode-components/liquid-chart/index.tsx +250 -250
- package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +478 -478
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-controller.ts +153 -153
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-definition.ts +23 -23
- package/src/aldehyde/lowcode-components/lowcode-view/component/loading.tsx +20 -20
- package/src/aldehyde/lowcode-components/lowcode-view/component/util.ts +27 -27
- package/src/aldehyde/lowcode-components/lowcode-view/index.less +19 -19
- package/src/aldehyde/lowcode-components/lowcode-view/index.tsx +277 -277
- package/src/aldehyde/lowcode-components/lowcode-view/interface.ts +189 -189
- package/src/aldehyde/lowcode-components/pie-chart/index.tsx +349 -349
- package/src/aldehyde/lowcode-components/progress-chart/index.tsx +295 -295
- package/src/aldehyde/lowcode-components/radar-chart/index.tsx +322 -322
- package/src/aldehyde/lowcode-components/search-form/index.less +25 -25
- package/src/aldehyde/lowcode-components/search-form/index.tsx +121 -121
- package/src/aldehyde/lowcode-components/stroke-animation/index.tsx +219 -219
- package/src/aldehyde/module/block-menu-tree-drawer.tsx +118 -118
- package/src/aldehyde/module/criteria-page.tsx1 +175 -175
- package/src/aldehyde/module/draggable-modal.tsx +66 -66
- package/src/aldehyde/module/dtmpl-edit-card.tsx +437 -437
- package/src/aldehyde/module/dtmpl-edit-drawer.tsx +23 -23
- package/src/aldehyde/module/dtmpl-edit-modal.tsx +25 -25
- package/src/aldehyde/module/dtmpl-edit-page.tsx +558 -558
- package/src/aldehyde/module/dtmpl-editor.tsx +165 -165
- package/src/aldehyde/module/dtmpl-view-card.tsx +64 -64
- package/src/aldehyde/module/dtmpl-view-drawer.tsx +71 -71
- package/src/aldehyde/module/dtmpl-view-modal.tsx +56 -56
- package/src/aldehyde/module/embed-dtmpl-edit-page.tsx +137 -137
- package/src/aldehyde/module/index.less +4 -4
- package/src/aldehyde/module/ltmpl-drawer.tsx +60 -60
- package/src/aldehyde/module/ltmpl-modal.tsx +63 -63
- package/src/aldehyde/module/ltmpl-table.tsx +378 -378
- package/src/aldehyde/module/ttmpl-tree.tsx +47 -47
- package/src/aldehyde/routable/dtmpl-route.tsx +173 -173
- package/src/aldehyde/routable/import-route.tsx +35 -35
- package/src/aldehyde/routable/index.less +25 -25
- package/src/aldehyde/routable/ltmpl-route.tsx +539 -539
- package/src/aldehyde/routable/splitview-ltmpl-route.tsx +377 -377
- package/src/aldehyde/routable/ttmpl-route.tsx +93 -93
- package/src/aldehyde/routable/withroute.tsx +36 -36
- package/src/aldehyde/sso-Login/index.tsx +73 -73
- package/src/aldehyde/sso-Login/service/index.js +16 -16
- package/src/aldehyde/sso-Login/service/login.js +75 -75
- package/src/aldehyde/table/act-table.tsx +1831 -1831
- package/src/aldehyde/table/column/column-builder.tsx +864 -864
- package/src/aldehyde/table/column/column-selector.tsx +130 -130
- package/src/aldehyde/table/column/index.less +63 -63
- package/src/aldehyde/table/column/summary-builder.tsx +712 -712
- package/src/aldehyde/table/column/theme-color-getter.tsx +25 -25
- package/src/aldehyde/table/control-table-x-axis-wrapper.tsx +80 -80
- package/src/aldehyde/table/index.css +211 -211
- package/src/aldehyde/table/l2-act-table.tsx +91 -91
- package/src/aldehyde/table/modal-select-table.tsx +308 -308
- package/src/aldehyde/table/page-config-button.tsx +203 -203
- package/src/aldehyde/table/pagination.css +14 -14
- package/src/aldehyde/table/pagination.tsx +81 -81
- package/src/aldehyde/table/query-table.tsx +658 -658
- package/src/aldehyde/table/relation-table.tsx +1093 -1093
- package/src/aldehyde/table/report-table.tsx +125 -125
- package/src/aldehyde/table/resizable-table.tsx +97 -97
- package/src/aldehyde/table/select-table.tsx +559 -548
- package/src/aldehyde/table/selected-rows-card.tsx +78 -78
- package/src/aldehyde/table/stat/restat.tsx +122 -122
- package/src/aldehyde/table/table-util.tsx +25 -25
- package/src/aldehyde/tmpl/control-type-supportor.tsx +154 -154
- package/src/aldehyde/tmpl/hc-data-source.tsx +566 -566
- package/src/aldehyde/tmpl/hcservice-v3.tsx +1590 -1590
- package/src/aldehyde/tmpl/interface.tsx +919 -919
- package/src/aldehyde/tmpl/model-struc-v3.tsx +111 -111
- package/src/aldehyde/tmpl/superagent.js +146 -146
- package/src/aldehyde/tmpl/tmpl-config-analysis.tsx +585 -585
- package/src/aldehyde/tmpl/web-socket.ts +366 -366
- package/src/aldehyde/tree/act-tree.tsx +217 -217
- package/src/aldehyde/tree/block-menu-auth-tree.tsx +189 -189
- package/src/aldehyde/tree/index.css +22 -22
- package/src/aldehyde/tree/navigation-tree.tsx +39 -39
- package/src/aldehyde/tree/tmpl-tree.tsx +751 -751
- package/src/aldehyde/tree/tree-node.tsx +73 -73
- package/src/aldehyde/tree/tree-utils.tsx +317 -317
- package/src/aldehyde/units/EncryptUtils.js +37 -37
- package/src/aldehyde/units/image.d.ts +7 -7
- package/src/aldehyde/units/index.tsx +1367 -1367
- package/src/aldehyde/units/storage.js +2 -2
- package/src/aldehyde/utils/dsu.ts +27 -27
- package/src/aldehyde/welcome/HCWelcome.js +404 -404
- package/src/aldehyde/welcome/HCWelcome1.js +259 -259
- package/src/aldehyde/welcome/components/menu-card.less +96 -96
- package/src/aldehyde/welcome/components/menu-card.tsx +70 -70
- package/src/aldehyde/welcome/components/page-card.less +49 -49
- package/src/aldehyde/welcome/components/page-card.tsx +97 -97
- package/src/aldehyde/welcome/components/quick-entrance.less +120 -120
- package/src/aldehyde/welcome/components/quick-entrance.tsx +80 -80
- package/src/aldehyde/welcome/components/user-menus.less +192 -192
- package/src/aldehyde/welcome/components/user-menus.tsx +279 -279
- package/src/aldehyde/welcome/components/workbench.less +118 -118
- package/src/aldehyde/welcome/components/workbench.tsx +146 -146
- package/src/aldehyde/welcome/index.css +13 -13
|
@@ -1,542 +1,542 @@
|
|
|
1
|
-
import Konva from 'konva';
|
|
2
|
-
import { GraphAnchor, Render, AssetInfoPoint, LineManualPoint } from '../types';
|
|
3
|
-
import { GraphDraw, LinkDraw, PreviewDraw } from '../draws';
|
|
4
|
-
import { BaseGraph } from './base-graph';
|
|
5
|
-
import { BezierSceneFunc } from '../utils/bezier-scene-func';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 贝赛尔曲线
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export class Bezier extends BaseGraph {
|
|
12
|
-
// 实现:更新 图形 的 调整点 的 锚点位置
|
|
13
|
-
static override updateAnchorShadows(graph: Konva.Group, anchorShadows: Konva.Circle[], shape?: Konva.Line): void {
|
|
14
|
-
if (shape) {
|
|
15
|
-
const points = shape.points();
|
|
16
|
-
for (const shadow of anchorShadows) {
|
|
17
|
-
switch (shadow.attrs.adjustType) {
|
|
18
|
-
case 'start':
|
|
19
|
-
shadow.position({ x: points[0], y: points[1] });
|
|
20
|
-
break;
|
|
21
|
-
case 'end':
|
|
22
|
-
shadow.position({ x: points[points.length - 2], y: points[points.length - 1] });
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// 实现:更新 图形 的 连接点 的 锚点位置
|
|
29
|
-
static override updateLinkAnchorShadows(graph: Konva.Group, linkAnchorShadows: Konva.Circle[], shape?: Konva.Line): void {
|
|
30
|
-
if (shape) {
|
|
31
|
-
const points = shape.points();
|
|
32
|
-
for (const shadow of linkAnchorShadows) {
|
|
33
|
-
switch (shadow.attrs.alias) {
|
|
34
|
-
case 'start':
|
|
35
|
-
shadow.position({ x: points[0], y: points[1] });
|
|
36
|
-
break;
|
|
37
|
-
case 'end':
|
|
38
|
-
shadow.position({ x: points[points.length - 2], y: points[points.length - 1] });
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static calculateAngle(sideA: number, sideB: number) {
|
|
46
|
-
if (!isNaN(sideA) && !isNaN(sideB)) {
|
|
47
|
-
const angleInRadians = Math.atan2(sideA, sideB);
|
|
48
|
-
const angleInDegrees = angleInRadians * (180 / Math.PI);
|
|
49
|
-
return angleInDegrees;
|
|
50
|
-
}
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 实现:生成 调整点
|
|
55
|
-
static override createAnchorShapes(
|
|
56
|
-
render: Render,
|
|
57
|
-
graph: Konva.Group,
|
|
58
|
-
anchorAndShadows: {
|
|
59
|
-
anchor: GraphAnchor,
|
|
60
|
-
anchorShadow: Konva.Circle,
|
|
61
|
-
shape?: Konva.Shape
|
|
62
|
-
}[],
|
|
63
|
-
adjustAnchor?: GraphAnchor
|
|
64
|
-
): { anchorAndShadows: { anchor: GraphAnchor, anchorShadow: Konva.Circle, shape?: Konva.Shape | undefined }[] } {
|
|
65
|
-
const stageState = render.getStageState();
|
|
66
|
-
const graphShape = graph.findOne('.graph') as Konva.Line;
|
|
67
|
-
if (graphShape) {
|
|
68
|
-
const points = graphShape.points();
|
|
69
|
-
for (const anchorAndShadow of anchorAndShadows) {
|
|
70
|
-
let rotate = 0;
|
|
71
|
-
const { anchor, anchorShadow } = anchorAndShadow;
|
|
72
|
-
const x = render.toStageValue(anchorShadow.getAbsolutePosition().x - stageState.x);
|
|
73
|
-
const y = render.toStageValue(anchorShadow.getAbsolutePosition().y - stageState.y);
|
|
74
|
-
if (anchor.adjustType === 'manual') {
|
|
75
|
-
const anchorShape = new Konva.Circle({
|
|
76
|
-
name: 'anchor',
|
|
77
|
-
anchor: anchor,
|
|
78
|
-
fill: anchor.adjusted ? `rgba(0,0,0,0.4)` : `rgba(0,0,255,0.4)`,
|
|
79
|
-
radius: render.toStageValue(5),
|
|
80
|
-
strokeWidth: 0,
|
|
81
|
-
x: x,
|
|
82
|
-
y: y,
|
|
83
|
-
rotation: graph.getAbsoluteRotation(),
|
|
84
|
-
// 阻止多余的调整点出现
|
|
85
|
-
visible:
|
|
86
|
-
(graph.attrs.adjusting || graph.attrs.hover === true) &&
|
|
87
|
-
(anchor.adjusted || anchorAndShadows.length <= 6)
|
|
88
|
-
});
|
|
89
|
-
anchorShape.on('mouseenter', () => {
|
|
90
|
-
document.body.style.cursor = 'move';
|
|
91
|
-
graph.setAttr('hover', true);
|
|
92
|
-
graph.setAttr('hoverAnchor', true);
|
|
93
|
-
});
|
|
94
|
-
anchorShape.on('mouseleave', () => {
|
|
95
|
-
document.body.style.cursor = anchorShape.attrs.adjusting ? 'move' : 'default';
|
|
96
|
-
graph.setAttr('hover', false);
|
|
97
|
-
graph.setAttr('hoverAnchor', false);
|
|
98
|
-
// 进入其他元素区域时离开需要靠它 redraw
|
|
99
|
-
render.redraw([GraphDraw.name]);
|
|
100
|
-
});
|
|
101
|
-
anchorAndShadow.shape = anchorShape;
|
|
102
|
-
} else {
|
|
103
|
-
if (anchor.adjustType === 'start') {
|
|
104
|
-
rotate = Bezier.calculateAngle(points[2] - points[0], points[3] - points[1]);
|
|
105
|
-
} else if (anchor.adjustType === 'end') {
|
|
106
|
-
rotate = Bezier.calculateAngle(
|
|
107
|
-
points[points.length - 2] - points[points.length - 4],
|
|
108
|
-
points[points.length - 1] - points[points.length - 3]
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
const cos = Math.cos((rotate * Math.PI) / 180);
|
|
112
|
-
const sin = Math.sin((rotate * Math.PI) / 180);
|
|
113
|
-
const offset = render.toStageValue(render.pointSize - 20);
|
|
114
|
-
const offsetX = offset * sin;
|
|
115
|
-
const offsetY = offset * cos;
|
|
116
|
-
const anchorShape = new Konva.Circle({
|
|
117
|
-
name: 'anchor',
|
|
118
|
-
anchor: anchor,
|
|
119
|
-
fill: `rgba(0,0,255,0.4)`,
|
|
120
|
-
radius: render.toStageValue(5),
|
|
121
|
-
strokeWidth: 0,
|
|
122
|
-
// 位置
|
|
123
|
-
x: x,
|
|
124
|
-
y: y,
|
|
125
|
-
offsetX:
|
|
126
|
-
anchor.adjustType === 'start' ? offsetX : anchor.adjustType === 'end' ? -offsetX : 0,
|
|
127
|
-
offsetY:
|
|
128
|
-
anchor.adjustType === 'start' ? offsetY : anchor.adjustType === 'end' ? -offsetY : 0,
|
|
129
|
-
// 旋转角度
|
|
130
|
-
rotation: graph.getAbsoluteRotation(),
|
|
131
|
-
visible: graph.attrs.adjusting || graph.attrs.hover === true
|
|
132
|
-
});
|
|
133
|
-
anchorShape.on('mouseenter', () => {
|
|
134
|
-
document.body.style.cursor = 'move';
|
|
135
|
-
graph.setAttr('hover', true);
|
|
136
|
-
graph.setAttr('hoverAnchor', true);
|
|
137
|
-
});
|
|
138
|
-
anchorShape.on('mouseleave', () => {
|
|
139
|
-
document.body.style.cursor = anchorShape.attrs.adjusting ? 'move' : 'default';
|
|
140
|
-
graph.setAttr('hover', false);
|
|
141
|
-
graph.setAttr('hoverAnchor', false);
|
|
142
|
-
// 进入其他元素区域时离开需要靠它 redraw
|
|
143
|
-
render.redraw([GraphDraw.name]);
|
|
144
|
-
});
|
|
145
|
-
anchorAndShadow.shape = anchorShape;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return { anchorAndShadows };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* 矩阵变换:坐标系中的一个点,围绕着另外一个点进行旋转
|
|
154
|
-
* - - - - - - - -
|
|
155
|
-
* |x`| |cos -sin| |x-a| |a|
|
|
156
|
-
* | | = | | | | +
|
|
157
|
-
* |y`| |sin cos| |y-b| |b|
|
|
158
|
-
* - - - - - - - -
|
|
159
|
-
* @param x 目标节点坐标 x
|
|
160
|
-
* @param y 目标节点坐标 y
|
|
161
|
-
* @param centerX 围绕的点坐标 x
|
|
162
|
-
* @param centerY 围绕的点坐标 y
|
|
163
|
-
* @param angle 旋转角度
|
|
164
|
-
* @returns
|
|
165
|
-
*/
|
|
166
|
-
static rotatePoint(x: number, y: number, centerX: number, centerY: number, angle: number) {
|
|
167
|
-
// 将角度转换为弧度
|
|
168
|
-
const radians = (angle * Math.PI) / 180;
|
|
169
|
-
// 计算旋转后的坐标
|
|
170
|
-
const newX = Math.cos(radians) * (x - centerX) - Math.sin(radians) * (y - centerY) + centerX;
|
|
171
|
-
const newY = Math.sin(radians) * (x - centerX) + Math.cos(radians) * (y - centerY) + centerY;
|
|
172
|
-
return { x: newX, y: newY };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// 实现:调整 图形
|
|
176
|
-
static override adjust(
|
|
177
|
-
render: Render,
|
|
178
|
-
graph: Konva.Group,
|
|
179
|
-
graphSnap: Konva.Group,
|
|
180
|
-
adjustShape: Konva.Shape,
|
|
181
|
-
anchorAndShadows: {
|
|
182
|
-
anchor: GraphAnchor,
|
|
183
|
-
anchorShadow: Konva.Circle,
|
|
184
|
-
shape?: Konva.Shape | undefined,
|
|
185
|
-
}[],
|
|
186
|
-
startPoint: Konva.Vector2d,
|
|
187
|
-
endPoint: Konva.Vector2d,
|
|
188
|
-
hoverRect?: Konva.Rect
|
|
189
|
-
) {
|
|
190
|
-
// 目标 曲线
|
|
191
|
-
const line = graph.findOne('.graph') as Konva.Line;
|
|
192
|
-
// 镜像
|
|
193
|
-
const lineSnap = graphSnap.findOne('.graph') as Konva.Line;
|
|
194
|
-
// 调整点 锚点
|
|
195
|
-
const anchors = (graph.find('.anchor') ?? []) as Konva.Circle[];
|
|
196
|
-
// 镜像
|
|
197
|
-
const anchorsSnap = (graphSnap.find('.anchor') ?? []) as Konva.Circle[];
|
|
198
|
-
// 连接点 锚点
|
|
199
|
-
const linkAnchors = (graph.find('.link-anchor') ?? []) as Konva.Circle[];
|
|
200
|
-
if (line && lineSnap) {
|
|
201
|
-
const stageState = render.getStageState();
|
|
202
|
-
{
|
|
203
|
-
const [graphRotation, adjustType, ex, ey] = [Math.round(graph.rotation()), adjustShape.attrs.anchor?.adjustType, endPoint.x, endPoint.y];
|
|
204
|
-
const { x: cx, y: cy, width: cw, height: ch } = graphSnap.getClientRect();
|
|
205
|
-
const { x, y } = graph.position();
|
|
206
|
-
const [centerX, centerY] = [cx + cw / 2, cy + ch / 2];
|
|
207
|
-
const { x: sx, y: sy } = Bezier.rotatePoint(ex, ey, centerX, centerY, -graphRotation);
|
|
208
|
-
const { x: rx, y: ry } = Bezier.rotatePoint(x, y, centerX, centerY, -graphRotation);
|
|
209
|
-
const points = line.points();
|
|
210
|
-
const manualPoints = (line.attrs.manualPoints ?? []) as LineManualPoint[];
|
|
211
|
-
if (adjustType === 'manual') {
|
|
212
|
-
if (adjustShape.attrs.anchor?.manualIndex !== void 0) {
|
|
213
|
-
const index = adjustShape.attrs.anchor?.adjusted
|
|
214
|
-
? adjustShape.attrs.anchor?.manualIndex
|
|
215
|
-
: adjustShape.attrs.anchor?.manualIndex + 1;
|
|
216
|
-
const manualPointIndex = manualPoints.findIndex((o) => o.index === index);
|
|
217
|
-
if (manualPointIndex > -1) {
|
|
218
|
-
manualPoints[manualPointIndex].x = (sx - rx) / graph.scaleX();
|
|
219
|
-
manualPoints[manualPointIndex].y = (sy - ry) / graph.scaleY();
|
|
220
|
-
}
|
|
221
|
-
const linkPoints = [
|
|
222
|
-
[points[0], points[1]],
|
|
223
|
-
...manualPoints.sort((a, b) => a.index - b.index).map((o) => [o.x, o.y]),
|
|
224
|
-
[points[points.length - 2], points[points.length - 1]]
|
|
225
|
-
].flat();
|
|
226
|
-
line.setAttr('manualPoints', manualPoints);
|
|
227
|
-
line.points(linkPoints);
|
|
228
|
-
const adjustAnchorShadow = anchors.find((o) => o.attrs.adjustType === 'manual' && o.attrs.manualIndex === index);
|
|
229
|
-
if (adjustAnchorShadow) {
|
|
230
|
-
adjustAnchorShadow.position({ x: (sx - rx) / graph.scaleX(), y: (sy - ry) / graph.scaleY() });
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
} else {
|
|
234
|
-
const anchor = anchors.find((o) => o.attrs.adjustType === adjustType);
|
|
235
|
-
const anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === adjustType);
|
|
236
|
-
if (anchor && anchorShadow) {
|
|
237
|
-
const linkPoints = [
|
|
238
|
-
[points[0], points[1]],
|
|
239
|
-
...manualPoints.sort((a, b) => a.index - b.index).map((o) => [o.x, o.y]),
|
|
240
|
-
[points[points.length - 2], points[points.length - 1]]
|
|
241
|
-
];
|
|
242
|
-
switch (adjustType) {
|
|
243
|
-
case 'start':
|
|
244
|
-
linkPoints[0] = [(sx - rx) / graph.scaleX(), (sy - ry) / graph.scaleY()];
|
|
245
|
-
line.points(linkPoints.flat());
|
|
246
|
-
break;
|
|
247
|
-
case 'end':
|
|
248
|
-
linkPoints[linkPoints.length - 1] = [(sx - rx) / graph.scaleX(), (sy - ry) / graph.scaleY()];
|
|
249
|
-
line.points(linkPoints.flat());
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
// 更新 调整点(拐点)
|
|
256
|
-
Bezier.updateAnchor(render, graph);
|
|
257
|
-
// 更新 调整点 的 锚点 位置
|
|
258
|
-
Bezier.updateAnchorShadows(graph, anchors, line);
|
|
259
|
-
// 更新 图形 的 连接点 的 锚点位置
|
|
260
|
-
Bezier.updateLinkAnchorShadows(graph, linkAnchors, line);
|
|
261
|
-
// 更新 调整点 位置
|
|
262
|
-
for (const anchor of anchors) {
|
|
263
|
-
for (const { shape } of anchorAndShadows) {
|
|
264
|
-
if (shape) {
|
|
265
|
-
if (shape.attrs.anchor?.adjustType === anchor.attrs.adjustType) {
|
|
266
|
-
const anchorShadow = graph
|
|
267
|
-
.find(`.anchor`)
|
|
268
|
-
.find((o) => o.attrs.adjustType === anchor.attrs.adjustType);
|
|
269
|
-
if (anchorShadow) {
|
|
270
|
-
shape.position({
|
|
271
|
-
x: render.toStageValue(anchorShadow.getAbsolutePosition().x - stageState.x),
|
|
272
|
-
y: render.toStageValue(anchorShadow.getAbsolutePosition().y - stageState.y)
|
|
273
|
-
});
|
|
274
|
-
shape.rotation(graph.getAbsoluteRotation());
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
// 重绘
|
|
281
|
-
render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
|
|
282
|
-
}
|
|
283
|
-
const allXs = line.points().reduce((arr, item, idx) => {
|
|
284
|
-
if (idx % 2 === 0) {
|
|
285
|
-
arr.push(item);
|
|
286
|
-
}
|
|
287
|
-
return arr;
|
|
288
|
-
}, [] as number[]);
|
|
289
|
-
const allYs = line.points().reduce((arr, item, idx) => {
|
|
290
|
-
if (idx % 2 === 1) {
|
|
291
|
-
arr.push(item);
|
|
292
|
-
}
|
|
293
|
-
return arr;
|
|
294
|
-
}, [] as number[]);
|
|
295
|
-
const minX = Math.min(...allXs);
|
|
296
|
-
const maxX = Math.max(...allXs);
|
|
297
|
-
const minY = Math.min(...allYs);
|
|
298
|
-
const maxY = Math.max(...allYs);
|
|
299
|
-
BaseGraph.adjust(
|
|
300
|
-
render,
|
|
301
|
-
graph,
|
|
302
|
-
graphSnap,
|
|
303
|
-
adjustShape,
|
|
304
|
-
anchorAndShadows,
|
|
305
|
-
startPoint,
|
|
306
|
-
endPoint,
|
|
307
|
-
hoverRect,
|
|
308
|
-
{ width: maxX - minX, height: maxY - minY },
|
|
309
|
-
{ x: minX, y: minY }
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* 提供给 GraphDraw draw 使用
|
|
315
|
-
*/
|
|
316
|
-
static override draw(graph: Konva.Group, render: Render, adjustAnchor?: GraphAnchor) {
|
|
317
|
-
// 调整点 信息
|
|
318
|
-
const anchors = (graph.attrs.anchors ?? []) as (GraphAnchor & { manualIndex?: number, adjusted?: boolean })[];
|
|
319
|
-
// 调整点 锚点
|
|
320
|
-
const anchorShapes = graph.find(`.anchor`);
|
|
321
|
-
// 调整点 信息&锚点
|
|
322
|
-
const anchorAndShadows = anchors
|
|
323
|
-
.map((anchor) => ({
|
|
324
|
-
anchor,
|
|
325
|
-
anchorShadow: anchorShapes.find(
|
|
326
|
-
(shape) =>
|
|
327
|
-
shape.attrs.adjustType === anchor.adjustType &&
|
|
328
|
-
shape.attrs.manualIndex === anchor.manualIndex
|
|
329
|
-
) as Konva.Circle
|
|
330
|
-
}))
|
|
331
|
-
.filter((o) => o.anchorShadow !== void 0);
|
|
332
|
-
return Bezier.createAnchorShapes(render, graph, anchorAndShadows, adjustAnchor);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* 默认图形大小
|
|
337
|
-
*/
|
|
338
|
-
static size = 100;
|
|
339
|
-
/**
|
|
340
|
-
* 曲线 对应的 Konva 实例
|
|
341
|
-
*/
|
|
342
|
-
private line: Konva.Line;
|
|
343
|
-
constructor(render: Render, dropPoint: Konva.Vector2d) {
|
|
344
|
-
super(render, dropPoint, {
|
|
345
|
-
type: "Bezier",
|
|
346
|
-
// 定义了 2 个 调整点
|
|
347
|
-
anchors: [{ adjustType: 'start' }, { adjustType: 'end' }].map((o) => ({ adjustType: o.adjustType })), // 调整点 类型定义
|
|
348
|
-
linkAnchors: [{ x: 0, y: 0, alias: 'start' }, { x: 0, y: 0, alias: 'end' }] as AssetInfoPoint[]
|
|
349
|
-
})
|
|
350
|
-
// 新建 曲线
|
|
351
|
-
this.line = new Konva.Arrow({
|
|
352
|
-
name: 'graph',
|
|
353
|
-
x: 0,
|
|
354
|
-
y: 0,
|
|
355
|
-
stroke: "#000000",
|
|
356
|
-
strokeWidth: 1,
|
|
357
|
-
fill: "#000000",
|
|
358
|
-
points: [],
|
|
359
|
-
pointerAtBeginning: true,
|
|
360
|
-
pointerAtEnding: true,
|
|
361
|
-
lineJoin: 'miter',
|
|
362
|
-
sceneFunc: BezierSceneFunc
|
|
363
|
-
});
|
|
364
|
-
// 给予 1 像素,防止导出图片 toDataURL 失败
|
|
365
|
-
this.group.size({ width: 1, height: 1 });
|
|
366
|
-
// 加入
|
|
367
|
-
this.group.add(this.line);
|
|
368
|
-
// 鼠标按下位置 作为起点
|
|
369
|
-
this.group.position(this.dropPoint);
|
|
370
|
-
}
|
|
371
|
-
// 实现:拖动进行时
|
|
372
|
-
override drawMove(point: Konva.Vector2d): void {
|
|
373
|
-
// 鼠标拖动偏移量
|
|
374
|
-
const offsetX = point.x - this.dropPoint.x;
|
|
375
|
-
const offsetY = point.y - this.dropPoint.y;
|
|
376
|
-
// 起点、终点
|
|
377
|
-
const linkPoints = [[this.line.x(), this.line.y()], [this.line.x() + offsetX, this.line.y() + offsetY]];
|
|
378
|
-
// 曲线 路径
|
|
379
|
-
this.line.points(linkPoints.flat());
|
|
380
|
-
// 更新 图形 的 调整点 的 锚点位置
|
|
381
|
-
Bezier.updateAnchorShadows(this.group, this.anchorShadows, this.line);
|
|
382
|
-
// 更新 图形 的 连接点 的 锚点位置
|
|
383
|
-
Bezier.updateLinkAnchorShadows(this.group, this.linkAnchorShadows, this.line);
|
|
384
|
-
// 重绘
|
|
385
|
-
this.render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// 实现:拖动结束
|
|
389
|
-
override drawEnd(): void {
|
|
390
|
-
if (this.line.width() <= 10 && this.line.height() <= 10) {
|
|
391
|
-
// 加入只点击,无拖动
|
|
392
|
-
// 默认大小
|
|
393
|
-
const width = Bezier.size;
|
|
394
|
-
const height = width;
|
|
395
|
-
// 起点、终点
|
|
396
|
-
const linkPoints = [[this.line.x(), this.line.y()], [this.line.x() + width, this.line.y() + height]].flat();
|
|
397
|
-
// 曲线 位置大小
|
|
398
|
-
this.line.points(linkPoints);
|
|
399
|
-
}
|
|
400
|
-
// 更新 调整点(拐点)
|
|
401
|
-
Bezier.updateAnchor(this.render, this.group);
|
|
402
|
-
// 更新 图形 的 调整点 的 锚点位置
|
|
403
|
-
Bezier.updateAnchorShadows(this.group, this.anchorShadows, this.line);
|
|
404
|
-
// 更新 图形 的 连接点 的 锚点位置
|
|
405
|
-
Bezier.updateLinkAnchorShadows(this.group, this.linkAnchorShadows, this.line);
|
|
406
|
-
// 扣除多余的间隙
|
|
407
|
-
const size = { width: this.line.size().width - 10, height: this.line.size().height - 10 };
|
|
408
|
-
// 更新大小
|
|
409
|
-
this.group.size(size);
|
|
410
|
-
// 对齐线清除
|
|
411
|
-
this.render.attractTool.alignLinesClear();
|
|
412
|
-
// 更新历史
|
|
413
|
-
this.render.updateHistory();
|
|
414
|
-
// 重绘
|
|
415
|
-
this.render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
|
|
416
|
-
super.drawEnd(size, {
|
|
417
|
-
x: Math.min(
|
|
418
|
-
...this.line.points().reduce((arr, item, idx) => {
|
|
419
|
-
if (idx % 2 === 0) {
|
|
420
|
-
arr.push(item);
|
|
421
|
-
}
|
|
422
|
-
return arr;
|
|
423
|
-
}, [] as number[])
|
|
424
|
-
),
|
|
425
|
-
y: Math.min(
|
|
426
|
-
...this.line.points().reduce((arr, item, idx) => {
|
|
427
|
-
if (idx % 2 === 1) {
|
|
428
|
-
arr.push(item);
|
|
429
|
-
}
|
|
430
|
-
return arr;
|
|
431
|
-
}, [] as number[])
|
|
432
|
-
)
|
|
433
|
-
})
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* 更新 调整点(拐点)
|
|
438
|
-
* @param render
|
|
439
|
-
* @param graph
|
|
440
|
-
*/
|
|
441
|
-
static updateAnchor(render: Render, graph: Konva.Group) {
|
|
442
|
-
const anchors = graph.attrs.anchors ?? [];
|
|
443
|
-
const anchorShadows = graph.find('.anchor') ?? [];
|
|
444
|
-
const shape = graph.findOne('.graph') as Konva.Line;
|
|
445
|
-
if (shape) {
|
|
446
|
-
// 已拐
|
|
447
|
-
let manualPoints = (shape.attrs.manualPoints ?? []) as LineManualPoint[];
|
|
448
|
-
const points = shape.points();
|
|
449
|
-
// 调整点 + 拐点
|
|
450
|
-
const linkPoints = [
|
|
451
|
-
[points[0], points[1]],
|
|
452
|
-
...manualPoints.sort((a, b) => a.index - b.index).map((o) => [o.x, o.y]),
|
|
453
|
-
[points[points.length - 2], points[points.length - 1]]
|
|
454
|
-
];
|
|
455
|
-
// 清空 调整点(拐点),保留 start end
|
|
456
|
-
anchors.splice(2);
|
|
457
|
-
const shadows = anchorShadows.splice(2);
|
|
458
|
-
for (const shadow of shadows) {
|
|
459
|
-
shadow.remove();
|
|
460
|
-
shadow.destroy();
|
|
461
|
-
}
|
|
462
|
-
manualPoints = [];
|
|
463
|
-
for (let i = linkPoints.length - 1; i > 0; i--) {
|
|
464
|
-
linkPoints.splice(i, 0, []);
|
|
465
|
-
}
|
|
466
|
-
// 调整点(拐点)
|
|
467
|
-
for (let i = 1; i < linkPoints.length - 1; i++) {
|
|
468
|
-
const anchor = {
|
|
469
|
-
type: graph.attrs.graphType,
|
|
470
|
-
adjustType: 'manual',
|
|
471
|
-
name: 'anchor',
|
|
472
|
-
groupId: graph.id(),
|
|
473
|
-
manualIndex: i,
|
|
474
|
-
adjusted: false
|
|
475
|
-
};
|
|
476
|
-
if (linkPoints[i].length === 0) {
|
|
477
|
-
anchor.adjusted = false;
|
|
478
|
-
// 新增
|
|
479
|
-
const prev = linkPoints[i - 1];
|
|
480
|
-
const next = linkPoints[i + 1];
|
|
481
|
-
const circle = new Konva.Circle({
|
|
482
|
-
adjustType: anchor.adjustType,
|
|
483
|
-
anchorType: anchor.type,
|
|
484
|
-
name: anchor.name,
|
|
485
|
-
manualIndex: anchor.manualIndex,
|
|
486
|
-
radius: 0,
|
|
487
|
-
x: (prev[0] + next[0]) / 2,
|
|
488
|
-
y: (prev[1] + next[1]) / 2,
|
|
489
|
-
anchor
|
|
490
|
-
});
|
|
491
|
-
graph.add(circle);
|
|
492
|
-
} else {
|
|
493
|
-
anchor.adjusted = true;
|
|
494
|
-
// 已拐
|
|
495
|
-
const circle = new Konva.Circle({
|
|
496
|
-
adjustType: anchor.adjustType,
|
|
497
|
-
anchorType: anchor.type,
|
|
498
|
-
name: anchor.name,
|
|
499
|
-
manualIndex: anchor.manualIndex,
|
|
500
|
-
adjusted: true,
|
|
501
|
-
radius: 0,
|
|
502
|
-
x: linkPoints[i][0],
|
|
503
|
-
y: linkPoints[i][1],
|
|
504
|
-
anchor
|
|
505
|
-
});
|
|
506
|
-
graph.add(circle);
|
|
507
|
-
manualPoints.push({ x: linkPoints[i][0], y: linkPoints[i][1], index: anchor.manualIndex });
|
|
508
|
-
}
|
|
509
|
-
anchors.push(anchor);
|
|
510
|
-
}
|
|
511
|
-
shape.setAttr('manualPoints', manualPoints);
|
|
512
|
-
graph.setAttr('anchors', anchors);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* 调整之前
|
|
518
|
-
*/
|
|
519
|
-
static adjustStart(
|
|
520
|
-
render: Render,
|
|
521
|
-
graph: Konva.Group,
|
|
522
|
-
adjustAnchor: GraphAnchor & { manualIndex?: number; adjusted?: boolean },
|
|
523
|
-
endPoint: Konva.Vector2d
|
|
524
|
-
) {
|
|
525
|
-
const { x: gx, y: gy } = graph.position();
|
|
526
|
-
const shape = graph.findOne('.graph') as Konva.Line;
|
|
527
|
-
if (shape && typeof adjustAnchor.manualIndex === 'number') {
|
|
528
|
-
const manualPoints = (shape.attrs.manualPoints ?? []) as LineManualPoint[];
|
|
529
|
-
if (adjustAnchor.adjusted) {
|
|
530
|
-
} else {
|
|
531
|
-
manualPoints.push({
|
|
532
|
-
x: endPoint.x - gx,
|
|
533
|
-
y: endPoint.y - gy,
|
|
534
|
-
index: adjustAnchor.manualIndex
|
|
535
|
-
});
|
|
536
|
-
shape.setAttr('manualPoints', manualPoints);
|
|
537
|
-
}
|
|
538
|
-
// 更新 调整点(拐点)
|
|
539
|
-
Bezier.updateAnchor(render, graph);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
1
|
+
import Konva from 'konva';
|
|
2
|
+
import { GraphAnchor, Render, AssetInfoPoint, LineManualPoint } from '../types';
|
|
3
|
+
import { GraphDraw, LinkDraw, PreviewDraw } from '../draws';
|
|
4
|
+
import { BaseGraph } from './base-graph';
|
|
5
|
+
import { BezierSceneFunc } from '../utils/bezier-scene-func';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 贝赛尔曲线
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export class Bezier extends BaseGraph {
|
|
12
|
+
// 实现:更新 图形 的 调整点 的 锚点位置
|
|
13
|
+
static override updateAnchorShadows(graph: Konva.Group, anchorShadows: Konva.Circle[], shape?: Konva.Line): void {
|
|
14
|
+
if (shape) {
|
|
15
|
+
const points = shape.points();
|
|
16
|
+
for (const shadow of anchorShadows) {
|
|
17
|
+
switch (shadow.attrs.adjustType) {
|
|
18
|
+
case 'start':
|
|
19
|
+
shadow.position({ x: points[0], y: points[1] });
|
|
20
|
+
break;
|
|
21
|
+
case 'end':
|
|
22
|
+
shadow.position({ x: points[points.length - 2], y: points[points.length - 1] });
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// 实现:更新 图形 的 连接点 的 锚点位置
|
|
29
|
+
static override updateLinkAnchorShadows(graph: Konva.Group, linkAnchorShadows: Konva.Circle[], shape?: Konva.Line): void {
|
|
30
|
+
if (shape) {
|
|
31
|
+
const points = shape.points();
|
|
32
|
+
for (const shadow of linkAnchorShadows) {
|
|
33
|
+
switch (shadow.attrs.alias) {
|
|
34
|
+
case 'start':
|
|
35
|
+
shadow.position({ x: points[0], y: points[1] });
|
|
36
|
+
break;
|
|
37
|
+
case 'end':
|
|
38
|
+
shadow.position({ x: points[points.length - 2], y: points[points.length - 1] });
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static calculateAngle(sideA: number, sideB: number) {
|
|
46
|
+
if (!isNaN(sideA) && !isNaN(sideB)) {
|
|
47
|
+
const angleInRadians = Math.atan2(sideA, sideB);
|
|
48
|
+
const angleInDegrees = angleInRadians * (180 / Math.PI);
|
|
49
|
+
return angleInDegrees;
|
|
50
|
+
}
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 实现:生成 调整点
|
|
55
|
+
static override createAnchorShapes(
|
|
56
|
+
render: Render,
|
|
57
|
+
graph: Konva.Group,
|
|
58
|
+
anchorAndShadows: {
|
|
59
|
+
anchor: GraphAnchor,
|
|
60
|
+
anchorShadow: Konva.Circle,
|
|
61
|
+
shape?: Konva.Shape
|
|
62
|
+
}[],
|
|
63
|
+
adjustAnchor?: GraphAnchor
|
|
64
|
+
): { anchorAndShadows: { anchor: GraphAnchor, anchorShadow: Konva.Circle, shape?: Konva.Shape | undefined }[] } {
|
|
65
|
+
const stageState = render.getStageState();
|
|
66
|
+
const graphShape = graph.findOne('.graph') as Konva.Line;
|
|
67
|
+
if (graphShape) {
|
|
68
|
+
const points = graphShape.points();
|
|
69
|
+
for (const anchorAndShadow of anchorAndShadows) {
|
|
70
|
+
let rotate = 0;
|
|
71
|
+
const { anchor, anchorShadow } = anchorAndShadow;
|
|
72
|
+
const x = render.toStageValue(anchorShadow.getAbsolutePosition().x - stageState.x);
|
|
73
|
+
const y = render.toStageValue(anchorShadow.getAbsolutePosition().y - stageState.y);
|
|
74
|
+
if (anchor.adjustType === 'manual') {
|
|
75
|
+
const anchorShape = new Konva.Circle({
|
|
76
|
+
name: 'anchor',
|
|
77
|
+
anchor: anchor,
|
|
78
|
+
fill: anchor.adjusted ? `rgba(0,0,0,0.4)` : `rgba(0,0,255,0.4)`,
|
|
79
|
+
radius: render.toStageValue(5),
|
|
80
|
+
strokeWidth: 0,
|
|
81
|
+
x: x,
|
|
82
|
+
y: y,
|
|
83
|
+
rotation: graph.getAbsoluteRotation(),
|
|
84
|
+
// 阻止多余的调整点出现
|
|
85
|
+
visible:
|
|
86
|
+
(graph.attrs.adjusting || graph.attrs.hover === true) &&
|
|
87
|
+
(anchor.adjusted || anchorAndShadows.length <= 6)
|
|
88
|
+
});
|
|
89
|
+
anchorShape.on('mouseenter', () => {
|
|
90
|
+
document.body.style.cursor = 'move';
|
|
91
|
+
graph.setAttr('hover', true);
|
|
92
|
+
graph.setAttr('hoverAnchor', true);
|
|
93
|
+
});
|
|
94
|
+
anchorShape.on('mouseleave', () => {
|
|
95
|
+
document.body.style.cursor = anchorShape.attrs.adjusting ? 'move' : 'default';
|
|
96
|
+
graph.setAttr('hover', false);
|
|
97
|
+
graph.setAttr('hoverAnchor', false);
|
|
98
|
+
// 进入其他元素区域时离开需要靠它 redraw
|
|
99
|
+
render.redraw([GraphDraw.name]);
|
|
100
|
+
});
|
|
101
|
+
anchorAndShadow.shape = anchorShape;
|
|
102
|
+
} else {
|
|
103
|
+
if (anchor.adjustType === 'start') {
|
|
104
|
+
rotate = Bezier.calculateAngle(points[2] - points[0], points[3] - points[1]);
|
|
105
|
+
} else if (anchor.adjustType === 'end') {
|
|
106
|
+
rotate = Bezier.calculateAngle(
|
|
107
|
+
points[points.length - 2] - points[points.length - 4],
|
|
108
|
+
points[points.length - 1] - points[points.length - 3]
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
const cos = Math.cos((rotate * Math.PI) / 180);
|
|
112
|
+
const sin = Math.sin((rotate * Math.PI) / 180);
|
|
113
|
+
const offset = render.toStageValue(render.pointSize - 20);
|
|
114
|
+
const offsetX = offset * sin;
|
|
115
|
+
const offsetY = offset * cos;
|
|
116
|
+
const anchorShape = new Konva.Circle({
|
|
117
|
+
name: 'anchor',
|
|
118
|
+
anchor: anchor,
|
|
119
|
+
fill: `rgba(0,0,255,0.4)`,
|
|
120
|
+
radius: render.toStageValue(5),
|
|
121
|
+
strokeWidth: 0,
|
|
122
|
+
// 位置
|
|
123
|
+
x: x,
|
|
124
|
+
y: y,
|
|
125
|
+
offsetX:
|
|
126
|
+
anchor.adjustType === 'start' ? offsetX : anchor.adjustType === 'end' ? -offsetX : 0,
|
|
127
|
+
offsetY:
|
|
128
|
+
anchor.adjustType === 'start' ? offsetY : anchor.adjustType === 'end' ? -offsetY : 0,
|
|
129
|
+
// 旋转角度
|
|
130
|
+
rotation: graph.getAbsoluteRotation(),
|
|
131
|
+
visible: graph.attrs.adjusting || graph.attrs.hover === true
|
|
132
|
+
});
|
|
133
|
+
anchorShape.on('mouseenter', () => {
|
|
134
|
+
document.body.style.cursor = 'move';
|
|
135
|
+
graph.setAttr('hover', true);
|
|
136
|
+
graph.setAttr('hoverAnchor', true);
|
|
137
|
+
});
|
|
138
|
+
anchorShape.on('mouseleave', () => {
|
|
139
|
+
document.body.style.cursor = anchorShape.attrs.adjusting ? 'move' : 'default';
|
|
140
|
+
graph.setAttr('hover', false);
|
|
141
|
+
graph.setAttr('hoverAnchor', false);
|
|
142
|
+
// 进入其他元素区域时离开需要靠它 redraw
|
|
143
|
+
render.redraw([GraphDraw.name]);
|
|
144
|
+
});
|
|
145
|
+
anchorAndShadow.shape = anchorShape;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { anchorAndShadows };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 矩阵变换:坐标系中的一个点,围绕着另外一个点进行旋转
|
|
154
|
+
* - - - - - - - -
|
|
155
|
+
* |x`| |cos -sin| |x-a| |a|
|
|
156
|
+
* | | = | | | | +
|
|
157
|
+
* |y`| |sin cos| |y-b| |b|
|
|
158
|
+
* - - - - - - - -
|
|
159
|
+
* @param x 目标节点坐标 x
|
|
160
|
+
* @param y 目标节点坐标 y
|
|
161
|
+
* @param centerX 围绕的点坐标 x
|
|
162
|
+
* @param centerY 围绕的点坐标 y
|
|
163
|
+
* @param angle 旋转角度
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
static rotatePoint(x: number, y: number, centerX: number, centerY: number, angle: number) {
|
|
167
|
+
// 将角度转换为弧度
|
|
168
|
+
const radians = (angle * Math.PI) / 180;
|
|
169
|
+
// 计算旋转后的坐标
|
|
170
|
+
const newX = Math.cos(radians) * (x - centerX) - Math.sin(radians) * (y - centerY) + centerX;
|
|
171
|
+
const newY = Math.sin(radians) * (x - centerX) + Math.cos(radians) * (y - centerY) + centerY;
|
|
172
|
+
return { x: newX, y: newY };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 实现:调整 图形
|
|
176
|
+
static override adjust(
|
|
177
|
+
render: Render,
|
|
178
|
+
graph: Konva.Group,
|
|
179
|
+
graphSnap: Konva.Group,
|
|
180
|
+
adjustShape: Konva.Shape,
|
|
181
|
+
anchorAndShadows: {
|
|
182
|
+
anchor: GraphAnchor,
|
|
183
|
+
anchorShadow: Konva.Circle,
|
|
184
|
+
shape?: Konva.Shape | undefined,
|
|
185
|
+
}[],
|
|
186
|
+
startPoint: Konva.Vector2d,
|
|
187
|
+
endPoint: Konva.Vector2d,
|
|
188
|
+
hoverRect?: Konva.Rect
|
|
189
|
+
) {
|
|
190
|
+
// 目标 曲线
|
|
191
|
+
const line = graph.findOne('.graph') as Konva.Line;
|
|
192
|
+
// 镜像
|
|
193
|
+
const lineSnap = graphSnap.findOne('.graph') as Konva.Line;
|
|
194
|
+
// 调整点 锚点
|
|
195
|
+
const anchors = (graph.find('.anchor') ?? []) as Konva.Circle[];
|
|
196
|
+
// 镜像
|
|
197
|
+
const anchorsSnap = (graphSnap.find('.anchor') ?? []) as Konva.Circle[];
|
|
198
|
+
// 连接点 锚点
|
|
199
|
+
const linkAnchors = (graph.find('.link-anchor') ?? []) as Konva.Circle[];
|
|
200
|
+
if (line && lineSnap) {
|
|
201
|
+
const stageState = render.getStageState();
|
|
202
|
+
{
|
|
203
|
+
const [graphRotation, adjustType, ex, ey] = [Math.round(graph.rotation()), adjustShape.attrs.anchor?.adjustType, endPoint.x, endPoint.y];
|
|
204
|
+
const { x: cx, y: cy, width: cw, height: ch } = graphSnap.getClientRect();
|
|
205
|
+
const { x, y } = graph.position();
|
|
206
|
+
const [centerX, centerY] = [cx + cw / 2, cy + ch / 2];
|
|
207
|
+
const { x: sx, y: sy } = Bezier.rotatePoint(ex, ey, centerX, centerY, -graphRotation);
|
|
208
|
+
const { x: rx, y: ry } = Bezier.rotatePoint(x, y, centerX, centerY, -graphRotation);
|
|
209
|
+
const points = line.points();
|
|
210
|
+
const manualPoints = (line.attrs.manualPoints ?? []) as LineManualPoint[];
|
|
211
|
+
if (adjustType === 'manual') {
|
|
212
|
+
if (adjustShape.attrs.anchor?.manualIndex !== void 0) {
|
|
213
|
+
const index = adjustShape.attrs.anchor?.adjusted
|
|
214
|
+
? adjustShape.attrs.anchor?.manualIndex
|
|
215
|
+
: adjustShape.attrs.anchor?.manualIndex + 1;
|
|
216
|
+
const manualPointIndex = manualPoints.findIndex((o) => o.index === index);
|
|
217
|
+
if (manualPointIndex > -1) {
|
|
218
|
+
manualPoints[manualPointIndex].x = (sx - rx) / graph.scaleX();
|
|
219
|
+
manualPoints[manualPointIndex].y = (sy - ry) / graph.scaleY();
|
|
220
|
+
}
|
|
221
|
+
const linkPoints = [
|
|
222
|
+
[points[0], points[1]],
|
|
223
|
+
...manualPoints.sort((a, b) => a.index - b.index).map((o) => [o.x, o.y]),
|
|
224
|
+
[points[points.length - 2], points[points.length - 1]]
|
|
225
|
+
].flat();
|
|
226
|
+
line.setAttr('manualPoints', manualPoints);
|
|
227
|
+
line.points(linkPoints);
|
|
228
|
+
const adjustAnchorShadow = anchors.find((o) => o.attrs.adjustType === 'manual' && o.attrs.manualIndex === index);
|
|
229
|
+
if (adjustAnchorShadow) {
|
|
230
|
+
adjustAnchorShadow.position({ x: (sx - rx) / graph.scaleX(), y: (sy - ry) / graph.scaleY() });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
const anchor = anchors.find((o) => o.attrs.adjustType === adjustType);
|
|
235
|
+
const anchorShadow = anchorsSnap.find((o) => o.attrs.adjustType === adjustType);
|
|
236
|
+
if (anchor && anchorShadow) {
|
|
237
|
+
const linkPoints = [
|
|
238
|
+
[points[0], points[1]],
|
|
239
|
+
...manualPoints.sort((a, b) => a.index - b.index).map((o) => [o.x, o.y]),
|
|
240
|
+
[points[points.length - 2], points[points.length - 1]]
|
|
241
|
+
];
|
|
242
|
+
switch (adjustType) {
|
|
243
|
+
case 'start':
|
|
244
|
+
linkPoints[0] = [(sx - rx) / graph.scaleX(), (sy - ry) / graph.scaleY()];
|
|
245
|
+
line.points(linkPoints.flat());
|
|
246
|
+
break;
|
|
247
|
+
case 'end':
|
|
248
|
+
linkPoints[linkPoints.length - 1] = [(sx - rx) / graph.scaleX(), (sy - ry) / graph.scaleY()];
|
|
249
|
+
line.points(linkPoints.flat());
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// 更新 调整点(拐点)
|
|
256
|
+
Bezier.updateAnchor(render, graph);
|
|
257
|
+
// 更新 调整点 的 锚点 位置
|
|
258
|
+
Bezier.updateAnchorShadows(graph, anchors, line);
|
|
259
|
+
// 更新 图形 的 连接点 的 锚点位置
|
|
260
|
+
Bezier.updateLinkAnchorShadows(graph, linkAnchors, line);
|
|
261
|
+
// 更新 调整点 位置
|
|
262
|
+
for (const anchor of anchors) {
|
|
263
|
+
for (const { shape } of anchorAndShadows) {
|
|
264
|
+
if (shape) {
|
|
265
|
+
if (shape.attrs.anchor?.adjustType === anchor.attrs.adjustType) {
|
|
266
|
+
const anchorShadow = graph
|
|
267
|
+
.find(`.anchor`)
|
|
268
|
+
.find((o) => o.attrs.adjustType === anchor.attrs.adjustType);
|
|
269
|
+
if (anchorShadow) {
|
|
270
|
+
shape.position({
|
|
271
|
+
x: render.toStageValue(anchorShadow.getAbsolutePosition().x - stageState.x),
|
|
272
|
+
y: render.toStageValue(anchorShadow.getAbsolutePosition().y - stageState.y)
|
|
273
|
+
});
|
|
274
|
+
shape.rotation(graph.getAbsoluteRotation());
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// 重绘
|
|
281
|
+
render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
|
|
282
|
+
}
|
|
283
|
+
const allXs = line.points().reduce((arr, item, idx) => {
|
|
284
|
+
if (idx % 2 === 0) {
|
|
285
|
+
arr.push(item);
|
|
286
|
+
}
|
|
287
|
+
return arr;
|
|
288
|
+
}, [] as number[]);
|
|
289
|
+
const allYs = line.points().reduce((arr, item, idx) => {
|
|
290
|
+
if (idx % 2 === 1) {
|
|
291
|
+
arr.push(item);
|
|
292
|
+
}
|
|
293
|
+
return arr;
|
|
294
|
+
}, [] as number[]);
|
|
295
|
+
const minX = Math.min(...allXs);
|
|
296
|
+
const maxX = Math.max(...allXs);
|
|
297
|
+
const minY = Math.min(...allYs);
|
|
298
|
+
const maxY = Math.max(...allYs);
|
|
299
|
+
BaseGraph.adjust(
|
|
300
|
+
render,
|
|
301
|
+
graph,
|
|
302
|
+
graphSnap,
|
|
303
|
+
adjustShape,
|
|
304
|
+
anchorAndShadows,
|
|
305
|
+
startPoint,
|
|
306
|
+
endPoint,
|
|
307
|
+
hoverRect,
|
|
308
|
+
{ width: maxX - minX, height: maxY - minY },
|
|
309
|
+
{ x: minX, y: minY }
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* 提供给 GraphDraw draw 使用
|
|
315
|
+
*/
|
|
316
|
+
static override draw(graph: Konva.Group, render: Render, adjustAnchor?: GraphAnchor) {
|
|
317
|
+
// 调整点 信息
|
|
318
|
+
const anchors = (graph.attrs.anchors ?? []) as (GraphAnchor & { manualIndex?: number, adjusted?: boolean })[];
|
|
319
|
+
// 调整点 锚点
|
|
320
|
+
const anchorShapes = graph.find(`.anchor`);
|
|
321
|
+
// 调整点 信息&锚点
|
|
322
|
+
const anchorAndShadows = anchors
|
|
323
|
+
.map((anchor) => ({
|
|
324
|
+
anchor,
|
|
325
|
+
anchorShadow: anchorShapes.find(
|
|
326
|
+
(shape) =>
|
|
327
|
+
shape.attrs.adjustType === anchor.adjustType &&
|
|
328
|
+
shape.attrs.manualIndex === anchor.manualIndex
|
|
329
|
+
) as Konva.Circle
|
|
330
|
+
}))
|
|
331
|
+
.filter((o) => o.anchorShadow !== void 0);
|
|
332
|
+
return Bezier.createAnchorShapes(render, graph, anchorAndShadows, adjustAnchor);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* 默认图形大小
|
|
337
|
+
*/
|
|
338
|
+
static size = 100;
|
|
339
|
+
/**
|
|
340
|
+
* 曲线 对应的 Konva 实例
|
|
341
|
+
*/
|
|
342
|
+
private line: Konva.Line;
|
|
343
|
+
constructor(render: Render, dropPoint: Konva.Vector2d) {
|
|
344
|
+
super(render, dropPoint, {
|
|
345
|
+
type: "Bezier",
|
|
346
|
+
// 定义了 2 个 调整点
|
|
347
|
+
anchors: [{ adjustType: 'start' }, { adjustType: 'end' }].map((o) => ({ adjustType: o.adjustType })), // 调整点 类型定义
|
|
348
|
+
linkAnchors: [{ x: 0, y: 0, alias: 'start' }, { x: 0, y: 0, alias: 'end' }] as AssetInfoPoint[]
|
|
349
|
+
})
|
|
350
|
+
// 新建 曲线
|
|
351
|
+
this.line = new Konva.Arrow({
|
|
352
|
+
name: 'graph',
|
|
353
|
+
x: 0,
|
|
354
|
+
y: 0,
|
|
355
|
+
stroke: "#000000",
|
|
356
|
+
strokeWidth: 1,
|
|
357
|
+
fill: "#000000",
|
|
358
|
+
points: [],
|
|
359
|
+
pointerAtBeginning: true,
|
|
360
|
+
pointerAtEnding: true,
|
|
361
|
+
lineJoin: 'miter',
|
|
362
|
+
sceneFunc: BezierSceneFunc
|
|
363
|
+
});
|
|
364
|
+
// 给予 1 像素,防止导出图片 toDataURL 失败
|
|
365
|
+
this.group.size({ width: 1, height: 1 });
|
|
366
|
+
// 加入
|
|
367
|
+
this.group.add(this.line);
|
|
368
|
+
// 鼠标按下位置 作为起点
|
|
369
|
+
this.group.position(this.dropPoint);
|
|
370
|
+
}
|
|
371
|
+
// 实现:拖动进行时
|
|
372
|
+
override drawMove(point: Konva.Vector2d): void {
|
|
373
|
+
// 鼠标拖动偏移量
|
|
374
|
+
const offsetX = point.x - this.dropPoint.x;
|
|
375
|
+
const offsetY = point.y - this.dropPoint.y;
|
|
376
|
+
// 起点、终点
|
|
377
|
+
const linkPoints = [[this.line.x(), this.line.y()], [this.line.x() + offsetX, this.line.y() + offsetY]];
|
|
378
|
+
// 曲线 路径
|
|
379
|
+
this.line.points(linkPoints.flat());
|
|
380
|
+
// 更新 图形 的 调整点 的 锚点位置
|
|
381
|
+
Bezier.updateAnchorShadows(this.group, this.anchorShadows, this.line);
|
|
382
|
+
// 更新 图形 的 连接点 的 锚点位置
|
|
383
|
+
Bezier.updateLinkAnchorShadows(this.group, this.linkAnchorShadows, this.line);
|
|
384
|
+
// 重绘
|
|
385
|
+
this.render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// 实现:拖动结束
|
|
389
|
+
override drawEnd(): void {
|
|
390
|
+
if (this.line.width() <= 10 && this.line.height() <= 10) {
|
|
391
|
+
// 加入只点击,无拖动
|
|
392
|
+
// 默认大小
|
|
393
|
+
const width = Bezier.size;
|
|
394
|
+
const height = width;
|
|
395
|
+
// 起点、终点
|
|
396
|
+
const linkPoints = [[this.line.x(), this.line.y()], [this.line.x() + width, this.line.y() + height]].flat();
|
|
397
|
+
// 曲线 位置大小
|
|
398
|
+
this.line.points(linkPoints);
|
|
399
|
+
}
|
|
400
|
+
// 更新 调整点(拐点)
|
|
401
|
+
Bezier.updateAnchor(this.render, this.group);
|
|
402
|
+
// 更新 图形 的 调整点 的 锚点位置
|
|
403
|
+
Bezier.updateAnchorShadows(this.group, this.anchorShadows, this.line);
|
|
404
|
+
// 更新 图形 的 连接点 的 锚点位置
|
|
405
|
+
Bezier.updateLinkAnchorShadows(this.group, this.linkAnchorShadows, this.line);
|
|
406
|
+
// 扣除多余的间隙
|
|
407
|
+
const size = { width: this.line.size().width - 10, height: this.line.size().height - 10 };
|
|
408
|
+
// 更新大小
|
|
409
|
+
this.group.size(size);
|
|
410
|
+
// 对齐线清除
|
|
411
|
+
this.render.attractTool.alignLinesClear();
|
|
412
|
+
// 更新历史
|
|
413
|
+
this.render.updateHistory();
|
|
414
|
+
// 重绘
|
|
415
|
+
this.render.redraw([GraphDraw.name, LinkDraw.name, PreviewDraw.name]);
|
|
416
|
+
super.drawEnd(size, {
|
|
417
|
+
x: Math.min(
|
|
418
|
+
...this.line.points().reduce((arr, item, idx) => {
|
|
419
|
+
if (idx % 2 === 0) {
|
|
420
|
+
arr.push(item);
|
|
421
|
+
}
|
|
422
|
+
return arr;
|
|
423
|
+
}, [] as number[])
|
|
424
|
+
),
|
|
425
|
+
y: Math.min(
|
|
426
|
+
...this.line.points().reduce((arr, item, idx) => {
|
|
427
|
+
if (idx % 2 === 1) {
|
|
428
|
+
arr.push(item);
|
|
429
|
+
}
|
|
430
|
+
return arr;
|
|
431
|
+
}, [] as number[])
|
|
432
|
+
)
|
|
433
|
+
})
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* 更新 调整点(拐点)
|
|
438
|
+
* @param render
|
|
439
|
+
* @param graph
|
|
440
|
+
*/
|
|
441
|
+
static updateAnchor(render: Render, graph: Konva.Group) {
|
|
442
|
+
const anchors = graph.attrs.anchors ?? [];
|
|
443
|
+
const anchorShadows = graph.find('.anchor') ?? [];
|
|
444
|
+
const shape = graph.findOne('.graph') as Konva.Line;
|
|
445
|
+
if (shape) {
|
|
446
|
+
// 已拐
|
|
447
|
+
let manualPoints = (shape.attrs.manualPoints ?? []) as LineManualPoint[];
|
|
448
|
+
const points = shape.points();
|
|
449
|
+
// 调整点 + 拐点
|
|
450
|
+
const linkPoints = [
|
|
451
|
+
[points[0], points[1]],
|
|
452
|
+
...manualPoints.sort((a, b) => a.index - b.index).map((o) => [o.x, o.y]),
|
|
453
|
+
[points[points.length - 2], points[points.length - 1]]
|
|
454
|
+
];
|
|
455
|
+
// 清空 调整点(拐点),保留 start end
|
|
456
|
+
anchors.splice(2);
|
|
457
|
+
const shadows = anchorShadows.splice(2);
|
|
458
|
+
for (const shadow of shadows) {
|
|
459
|
+
shadow.remove();
|
|
460
|
+
shadow.destroy();
|
|
461
|
+
}
|
|
462
|
+
manualPoints = [];
|
|
463
|
+
for (let i = linkPoints.length - 1; i > 0; i--) {
|
|
464
|
+
linkPoints.splice(i, 0, []);
|
|
465
|
+
}
|
|
466
|
+
// 调整点(拐点)
|
|
467
|
+
for (let i = 1; i < linkPoints.length - 1; i++) {
|
|
468
|
+
const anchor = {
|
|
469
|
+
type: graph.attrs.graphType,
|
|
470
|
+
adjustType: 'manual',
|
|
471
|
+
name: 'anchor',
|
|
472
|
+
groupId: graph.id(),
|
|
473
|
+
manualIndex: i,
|
|
474
|
+
adjusted: false
|
|
475
|
+
};
|
|
476
|
+
if (linkPoints[i].length === 0) {
|
|
477
|
+
anchor.adjusted = false;
|
|
478
|
+
// 新增
|
|
479
|
+
const prev = linkPoints[i - 1];
|
|
480
|
+
const next = linkPoints[i + 1];
|
|
481
|
+
const circle = new Konva.Circle({
|
|
482
|
+
adjustType: anchor.adjustType,
|
|
483
|
+
anchorType: anchor.type,
|
|
484
|
+
name: anchor.name,
|
|
485
|
+
manualIndex: anchor.manualIndex,
|
|
486
|
+
radius: 0,
|
|
487
|
+
x: (prev[0] + next[0]) / 2,
|
|
488
|
+
y: (prev[1] + next[1]) / 2,
|
|
489
|
+
anchor
|
|
490
|
+
});
|
|
491
|
+
graph.add(circle);
|
|
492
|
+
} else {
|
|
493
|
+
anchor.adjusted = true;
|
|
494
|
+
// 已拐
|
|
495
|
+
const circle = new Konva.Circle({
|
|
496
|
+
adjustType: anchor.adjustType,
|
|
497
|
+
anchorType: anchor.type,
|
|
498
|
+
name: anchor.name,
|
|
499
|
+
manualIndex: anchor.manualIndex,
|
|
500
|
+
adjusted: true,
|
|
501
|
+
radius: 0,
|
|
502
|
+
x: linkPoints[i][0],
|
|
503
|
+
y: linkPoints[i][1],
|
|
504
|
+
anchor
|
|
505
|
+
});
|
|
506
|
+
graph.add(circle);
|
|
507
|
+
manualPoints.push({ x: linkPoints[i][0], y: linkPoints[i][1], index: anchor.manualIndex });
|
|
508
|
+
}
|
|
509
|
+
anchors.push(anchor);
|
|
510
|
+
}
|
|
511
|
+
shape.setAttr('manualPoints', manualPoints);
|
|
512
|
+
graph.setAttr('anchors', anchors);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* 调整之前
|
|
518
|
+
*/
|
|
519
|
+
static adjustStart(
|
|
520
|
+
render: Render,
|
|
521
|
+
graph: Konva.Group,
|
|
522
|
+
adjustAnchor: GraphAnchor & { manualIndex?: number; adjusted?: boolean },
|
|
523
|
+
endPoint: Konva.Vector2d
|
|
524
|
+
) {
|
|
525
|
+
const { x: gx, y: gy } = graph.position();
|
|
526
|
+
const shape = graph.findOne('.graph') as Konva.Line;
|
|
527
|
+
if (shape && typeof adjustAnchor.manualIndex === 'number') {
|
|
528
|
+
const manualPoints = (shape.attrs.manualPoints ?? []) as LineManualPoint[];
|
|
529
|
+
if (adjustAnchor.adjusted) {
|
|
530
|
+
} else {
|
|
531
|
+
manualPoints.push({
|
|
532
|
+
x: endPoint.x - gx,
|
|
533
|
+
y: endPoint.y - gy,
|
|
534
|
+
index: adjustAnchor.manualIndex
|
|
535
|
+
});
|
|
536
|
+
shape.setAttr('manualPoints', manualPoints);
|
|
537
|
+
}
|
|
538
|
+
// 更新 调整点(拐点)
|
|
539
|
+
Bezier.updateAnchor(render, graph);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|