@mx-sose-front/mx-sose-graph 1.0.0
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 +21 -0
- package/README.md +343 -0
- package/dist/index.d.ts +3937 -0
- package/dist/index.esm.js +74367 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +38 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +70 -0
- package/src/components/ContextMenu.vue +475 -0
- package/src/components/Diagram/StrategicTaxonomyDiagram.vue +141 -0
- package/src/components/Edge/Edge.vue +366 -0
- package/src/components/InteractionLayer.vue +2033 -0
- package/src/components/Label.vue +0 -0
- package/src/components/LineStyle/ConnectionLine.vue +126 -0
- package/src/components/LineStyle/LineStyleMarker.vue +87 -0
- package/src/components/Pin/Pin.vue +220 -0
- package/src/components/Pin/Port.vue +172 -0
- package/src/components/Shape/Action.vue +121 -0
- package/src/components/Shape/ActivityAction.vue +155 -0
- package/src/components/Shape/Block.vue +306 -0
- package/src/components/Shape/ConceptualRole.vue +266 -0
- package/src/components/Shape/Diagram.vue +220 -0
- package/src/components/Shape/DividingLine.vue +594 -0
- package/src/components/Shape/DogEar.vue +224 -0
- package/src/components/Shape/Package.vue +340 -0
- package/src/constants/edgeShapeKeys.ts +81 -0
- package/src/constants/index.ts +440 -0
- package/src/index.ts +28 -0
- package/src/render/shape-registry.ts +17 -0
- package/src/render/shape-renderer.ts +103 -0
- package/src/statics/icons/childIcons/relations@3x.png +0 -0
- package/src/statics/icons/childIcons/role@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/344/277/241/345/217/267@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/344/277/241/346/201/257@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/344/277/241/346/201/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/217/202/346/225/260@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/257/271/350/261/241/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/211/247/350/241/214/350/200/205@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/216/245/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/216/247/345/210/266/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/344/270/216/350/203/275/345/212/233/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/253/257/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/273/223/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/207/252/347/224/261/345/210/206/347/261/273/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/351/253/230/347/272/247/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/272/246/346/235/237/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/273/267/345/200/274/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//344/273/273/346/204/217/345/205/263/347/263/273@3x.png +0 -0
- package/src/statics/icons/childIcons//344/273/273/346/204/217/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/344/275/277/345/221/275@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/345/205/250/347/224/237/345/221/275/345/221/250/346/234/237@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/346/204/277/346/231/257@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/347/233/256/346/240/207@3x.png +0 -0
- package/src/statics/icons/childIcons//344/275/215/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//344/275/223/347/263/273/346/236/266/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//344/276/235/350/265/226@3x.png +0 -0
- package/src/statics/icons/childIcons//344/277/235/346/212/244@3x.png +0 -0
- package/src/statics/icons/childIcons//344/277/241/346/201/257/346/250/241/345/236/213@3x.png +0 -0
- package/src/statics/icons/childIcons//345/210/233/351/200/240@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/344/270/216/344/270/232/345/212/241/346/264/273/345/212/250/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/345/257/271/350/261/241/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/346/216/247/345/210/266/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//345/217/214/345/220/221/345/205/263/350/201/224@3x.png +0 -0
- package/src/statics/icons/childIcons//345/217/227/345/210/260/345/275/261/345/223/215@3x.png +0 -0
- package/src/statics/icons/childIcons//345/234/260/347/220/206/346/224/277/346/262/273/350/214/203/345/233/264/347/261/273/345/236/213@3x.png +0 -0
- package/src/statics/icons/childIcons//345/241/253/345/206/231/350/201/214/344/275/215/347/224/263/350/257/267@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/216/247/345/210/266@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/265/201/347/250/213@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/265/201/347/250/213/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/351/232/224/347/246/273@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/345/205/263/347/263/273@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/345/205/263/350/201/224@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/347/273/204/346/210/220@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/350/201/232/345/220/210@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/344/272/272/345/221/230@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/344/274/201/344/270/232/351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/344/275/215/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/345/261/236/346/200/247/350/256/276/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/210/230/347/225/245/351/230/266/346/256/265/347/224/230/347/211/271/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/214/201/347/273/255/344/273/273/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/234/215/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/235/241/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/347/216/257/345/242/203@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/347/273/204/347/273/207@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/201/214/344/275/215@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/201/214/350/264/243@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/264/243/344/273/273@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/344/270/216/345/256/236/351/231/205/351/241/271/347/233/256/345/257/271/345/272/224/345/205/263/347/263/273/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/346/246/202/345/277/265/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256/344/270/216/350/203/275/345/212/233/347/232/204/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256/351/207/214/347/250/213/347/242/221@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256/351/207/214/347/250/213/347/242/221/346/261/207/346/200/273/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//345/261/225/347/244/272@3x.png +0 -0
- package/src/statics/icons/childIcons//345/267/262/347/237/245/350/265/204/346/272/220@3x.png +0 -0
- package/src/statics/icons/childIcons//345/274/200/345/261/225/345/267/245/344/275/234/350/203/275/345/212/233@3x.png +0 -0
- package/src/statics/icons/childIcons//345/274/225/347/224/250/345/261/236/346/200/247@3x.png +0 -0
- package/src/statics/icons/childIcons//345/275/261/345/223/215@3x-2.png +0 -0
- package/src/statics/icons/childIcons//345/275/261/345/223/215@3x.png +0 -0
- package/src/statics/icons/childIcons//346/204/277/346/231/257/345/256/243/350/250/200@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/344/277/241/346/201/257@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/344/277/241/346/201/257/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/344/277/241/346/201/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/345/256/236/351/231/205/346/210/230/347/225/245/351/230/266/346/256/265/345/210/206/347/261/273/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/345/256/236/351/231/205/351/203/250/347/275/262/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/346/265/201/347/250/213/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/347/237/251/351/230/265@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/347/273/223/346/236/204/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/277/346/213/205/351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//346/212/200/346/234/257@3x.png +0 -0
- package/src/statics/icons/childIcons//346/213/245/346/234/211/346/265/201/347/250/213@3x.png +0 -0
- package/src/statics/icons/childIcons//346/217/220/344/276/233/346/235/203/351/231/220@3x.png +0 -0
- package/src/statics/icons/childIcons//346/227/266/346/234/272@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/270/216/344/270/232/345/212/241/346/264/273/345/212/250/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/270/216/346/234/215/345/212/241/345/220/210/345/220/214/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/270/216/350/203/275/345/212/233/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/277/241/345/217/267@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/212/237/350/203/275@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/212/237/350/203/275/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/217/202/346/225/260@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/257/271/350/261/241/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/216/245/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/216/247/345/210/266/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/253/257/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/273/223/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/267/257/347/272/277/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/351/200/232/350/241/250@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/235/203/351/231/220@3x.png +0 -0
- package/src/statics/icons/childIcons//346/235/241/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/344/270/232/345/212/241/346/264/273/345/212/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/350/267/257/347/272/277/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/350/277/275/346/272/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/246/202/345/277/265/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//346/263/233/345/214/226@3x.png +0 -0
- package/src/statics/icons/childIcons//347/212/266/345/206/265@3x.png +0 -0
- package/src/statics/icons/childIcons//347/216/257/345/242/203@3x.png +0 -0
- package/src/statics/icons/childIcons//347/233/270/346/257/224@3x (1).png +0 -0
- package/src/statics/icons/childIcons//347/263/273/347/273/237@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/204/346/210/220@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/204/347/273/207@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/204/347/273/207/351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/221/345/256/232/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//347/274/223/350/247/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/201/214/344/275/215@3x.png +0 -0
- package/src/statics/icons/childIcons//350/201/232/345/220/210@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/212/233@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/212/233/350/201/214/350/264/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/212/233/351/205/215/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/244/237/350/203/234/344/273/273@3x.png +0 -0
- package/src/statics/icons/childIcons//350/207/252/347/204/266/350/265/204/346/272/220@3x.png +0 -0
- package/src/statics/icons/childIcons//350/246/201/346/261/202@3x.png +0 -0
- package/src/statics/icons/childIcons//350/256/276/347/275/256/347/261/273/345/236/213.png +0 -0
- package/src/statics/icons/childIcons//350/264/237/350/264/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/264/243/344/273/273@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/344/272/247/351/243/216/351/231/251/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/270/216/344/270/232/345/212/241/346/264/273/345/212/250/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/270/216/350/203/275/345/212/233/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/277/241/345/217/267@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/277/241/346/201/257@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/277/241/346/201/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/217/202/346/225/260@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/267/245/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/216/245/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/234/215/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/236/266/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/264/273/345/212/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/264/273/345/212/250/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/253/257/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/273/223/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/274/223/350/247/243/346/216/252/346/226/275@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/275/257/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//350/276/223/345/205/245/346/240/223@3x.png +0 -0
- package/src/statics/icons/childIcons//350/276/223/345/207/272/346/240/223@3x.png +0 -0
- package/src/statics/icons/childIcons//350/276/276/345/210/260@3x.png +0 -0
- package/src/statics/icons/childIcons//350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/277/236/347/272/277@3x.png +0 -0
- package/src/statics/icons/childIcons//351/207/214/347/250/213/347/242/221/344/276/235/350/265/226@3x.png +0 -0
- package/src/statics/icons/childIcons//351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//351/234/200/346/261/202/346/235/203/351/231/220@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/266/347/272/247/344/270/232/345/212/241/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/344/270/273/351/242/230@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/264/273/345/212/250@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/264/273/345/212/250/344/270/216/350/203/275/345/212/233/347/232/204/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/264/273/345/212/250/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/350/267/257/347/272/277/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/351/207/214/347/250/213/347/242/221@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/351/207/214/347/250/213/347/242/221/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/272/345/272/217@3x-2.png +0 -0
- package/src/statics/icons/childIcons//351/241/272/345/272/217@3x.png +0 -0
- package/src/statics/icons/childIcons//351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//351/243/216/351/231/251/344/270/216/345/256/211/345/205/250/346/216/247/345/210/266/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//351/253/230/347/272/247/344/270/232/345/212/241/346/246/202/345/277/265@3x.png +0 -0
- package/src/statics/icons/createMenu/config.png +0 -0
- package/src/statics/icons/createMenu/contact.png +0 -0
- package/src/statics/icons/createMenu/copy.png +0 -0
- package/src/statics/icons/createMenu/delete.png +0 -0
- package/src/statics/icons/createMenu/diagram.png +0 -0
- package/src/statics/icons/createMenu/element.png +0 -0
- package/src/statics/icons/createMenu/locateChart.png +0 -0
- package/src/statics/icons/createMenu/paste.png +0 -0
- package/src/statics/icons/createMenu/rename.png +0 -0
- package/src/statics/icons/createMenu/scissors.png +0 -0
- package/src/store/eventBus.ts +38 -0
- package/src/store/graphStore.ts +782 -0
- package/src/store/index.ts +8 -0
- package/src/style/index.css +1 -0
- package/src/style/tailwind.css +33 -0
- package/src/types/index.ts +200 -0
- package/src/utils/autoExpandParent.ts +94 -0
- package/src/utils/colorUtils.ts +137 -0
- package/src/utils/compartment.ts +534 -0
- package/src/utils/containers.ts +910 -0
- package/src/utils/diagram.ts +403 -0
- package/src/utils/dom.ts +21 -0
- package/src/utils/drag.ts +224 -0
- package/src/utils/edgeUtils.ts +787 -0
- package/src/utils/geom.ts +177 -0
- package/src/utils/graphDragService.ts +329 -0
- package/src/utils/highlightUtils.ts +162 -0
- package/src/utils/hittest.ts +135 -0
- package/src/utils/iconLoader.ts +105 -0
- package/src/utils/index.ts +20 -0
- package/src/utils/packgeMap.ts +1 -0
- package/src/utils/pinUtils.ts +484 -0
- package/src/utils/policy.ts +212 -0
- package/src/utils/zorder.ts +39 -0
- package/src/view/graph.vue +419 -0
- package/src/vite-env.d.ts +33 -0
|
@@ -0,0 +1,787 @@
|
|
|
1
|
+
// edge-utils.ts
|
|
2
|
+
import type { Shape } from "../types";
|
|
3
|
+
import { pickTarget } from "./hittest";
|
|
4
|
+
import { useGraphStore } from '../store/graphStore';
|
|
5
|
+
|
|
6
|
+
export class EdgeUtils {
|
|
7
|
+
/**
|
|
8
|
+
* 更新与指定图元相关的连线端点
|
|
9
|
+
* @param shapes 所有图元
|
|
10
|
+
* @param changedIds 发生变化的图元ID列表
|
|
11
|
+
* @param updateShape 更新图元的回调函数
|
|
12
|
+
*/
|
|
13
|
+
static updateRelatedEdges(
|
|
14
|
+
shapes: Shape[],
|
|
15
|
+
changedIds: string[],
|
|
16
|
+
updateShape: (shape: Shape) => void
|
|
17
|
+
) {
|
|
18
|
+
const edges = shapes.filter((shape) => shape.shapeType === "edge");
|
|
19
|
+
|
|
20
|
+
// 按源-目标对分组,为每组中的线条生成不同的偏移
|
|
21
|
+
// 同时处理反向连接(A→B 和 B→A)的情况
|
|
22
|
+
const edgeGroups = new Map<string, Shape[]>();
|
|
23
|
+
|
|
24
|
+
edges.forEach((edge) => {
|
|
25
|
+
if (edge.sourceId && edge.targetId) {
|
|
26
|
+
// 创建源-目标对的规范化键(确保 A-B 和 B-A 使用相同的键)
|
|
27
|
+
const isForward = edge.sourceId.localeCompare(edge.targetId) <= 0;
|
|
28
|
+
const groupKey = isForward
|
|
29
|
+
? `${edge.sourceId}-${edge.targetId}`
|
|
30
|
+
: `${edge.targetId}-${edge.sourceId}`;
|
|
31
|
+
|
|
32
|
+
if (!edgeGroups.has(groupKey)) {
|
|
33
|
+
edgeGroups.set(groupKey, []);
|
|
34
|
+
}
|
|
35
|
+
edgeGroups.get(groupKey)!.push(edge);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// 处理每个分组
|
|
40
|
+
edgeGroups.forEach((groupEdges, groupKey) => {
|
|
41
|
+
if (groupEdges.length > 1) {
|
|
42
|
+
// 如果同一源-目标对有多个线条,为每条线生成不同的偏移
|
|
43
|
+
groupEdges.forEach((edge, index) => {
|
|
44
|
+
const sourceChanged = edge.sourceId && changedIds.includes(edge.sourceId);
|
|
45
|
+
const targetChanged = edge.targetId && changedIds.includes(edge.targetId);
|
|
46
|
+
|
|
47
|
+
if (sourceChanged || targetChanged) {
|
|
48
|
+
const sourceShape = shapes.find((s) => s.id === edge.sourceId);
|
|
49
|
+
const targetShape = shapes.find((s) => s.id === edge.targetId);
|
|
50
|
+
|
|
51
|
+
if (sourceShape && targetShape && sourceShape.bounds && targetShape.bounds) {
|
|
52
|
+
// 计算基本连接点
|
|
53
|
+
const { x: sx = 0, y: sy = 0, width: sw = 0, height: sh = 0 } = sourceShape.bounds;
|
|
54
|
+
const { x: tx = 0, y: ty = 0, width: tw = 0, height: th = 0 } = targetShape.bounds;
|
|
55
|
+
|
|
56
|
+
// 计算中心点
|
|
57
|
+
const sourceCenter = { x: sx + sw / 2, y: sy + sh / 2 };
|
|
58
|
+
const targetCenter = { x: tx + tw / 2, y: ty + th / 2 };
|
|
59
|
+
|
|
60
|
+
// 计算连接方向
|
|
61
|
+
const dx = targetCenter.x - sourceCenter.x;
|
|
62
|
+
const dy = targetCenter.y - sourceCenter.y;
|
|
63
|
+
|
|
64
|
+
// 生成基于索引的偏移量(小到不会明显影响,但足以分开线条)
|
|
65
|
+
const offsetDistance = 5 * (index + 1);
|
|
66
|
+
|
|
67
|
+
// 根据方向计算偏移方向
|
|
68
|
+
let offsetX = 0, offsetY = 0;
|
|
69
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
70
|
+
// 水平方向为主,垂直偏移
|
|
71
|
+
offsetY = offsetDistance;
|
|
72
|
+
} else {
|
|
73
|
+
// 垂直方向为主,水平偏移
|
|
74
|
+
offsetX = offsetDistance;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 确保线条交替偏移方向,避免全部偏向一侧
|
|
78
|
+
if (index % 2 === 1) {
|
|
79
|
+
offsetX = -offsetX;
|
|
80
|
+
offsetY = -offsetY;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 确定连接点,添加偏移
|
|
84
|
+
let sourcePoint, targetPoint;
|
|
85
|
+
|
|
86
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
87
|
+
// 水平方向
|
|
88
|
+
sourcePoint = dx > 0
|
|
89
|
+
? { x: sx + sw, y: sourceCenter.y + offsetY }
|
|
90
|
+
: { x: sx, y: sourceCenter.y + offsetY };
|
|
91
|
+
|
|
92
|
+
targetPoint = dx > 0
|
|
93
|
+
? { x: tx, y: targetCenter.y + offsetY }
|
|
94
|
+
: { x: tx + tw, y: targetCenter.y + offsetY };
|
|
95
|
+
} else {
|
|
96
|
+
// 垂直方向
|
|
97
|
+
sourcePoint = dy > 0
|
|
98
|
+
? { x: sourceCenter.x + offsetX, y: sy + sh }
|
|
99
|
+
: { x: sourceCenter.x + offsetX, y: sy };
|
|
100
|
+
|
|
101
|
+
targetPoint = dy > 0
|
|
102
|
+
? { x: targetCenter.x + offsetX, y: ty }
|
|
103
|
+
: { x: targetCenter.x + offsetX, y: ty + th };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 更新连线,只使用源点和目标点确保线条保持直线
|
|
107
|
+
// 通过调整端点位置而不是添加中间点来避免线条重叠
|
|
108
|
+
const waypoints = [sourcePoint, targetPoint];
|
|
109
|
+
|
|
110
|
+
const updatedEdge = {
|
|
111
|
+
...edge,
|
|
112
|
+
waypointId: JSON.stringify(waypoints),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
updateShape(updatedEdge);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
// 单线条情况,使用原有的逻辑
|
|
121
|
+
const edge = groupEdges[0];
|
|
122
|
+
const sourceChanged = edge.sourceId && changedIds.includes(edge.sourceId);
|
|
123
|
+
const targetChanged = edge.targetId && changedIds.includes(edge.targetId);
|
|
124
|
+
|
|
125
|
+
if (sourceChanged || targetChanged) {
|
|
126
|
+
const sourceShape = shapes.find((s) => s.id === edge.sourceId);
|
|
127
|
+
const targetShape = shapes.find((s) => s.id === edge.targetId);
|
|
128
|
+
|
|
129
|
+
if (sourceShape && targetShape && sourceShape.bounds && targetShape.bounds) {
|
|
130
|
+
const { x: sx = 0, y: sy = 0, width: sw = 0, height: sh = 0 } = sourceShape.bounds;
|
|
131
|
+
const { x: tx = 0, y: ty = 0, width: tw = 0, height: th = 0 } = targetShape.bounds;
|
|
132
|
+
|
|
133
|
+
// 计算中心点
|
|
134
|
+
const sourceCenter = { x: sx + sw / 2, y: sy + sh / 2 };
|
|
135
|
+
const targetCenter = { x: tx + tw / 2, y: ty + th / 2 };
|
|
136
|
+
|
|
137
|
+
// 计算连接方向
|
|
138
|
+
const dx = targetCenter.x - sourceCenter.x;
|
|
139
|
+
const dy = targetCenter.y - sourceCenter.y;
|
|
140
|
+
|
|
141
|
+
// 确定连接点
|
|
142
|
+
let sourcePoint, targetPoint;
|
|
143
|
+
|
|
144
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
145
|
+
// 水平方向
|
|
146
|
+
sourcePoint = dx > 0
|
|
147
|
+
? { x: sx + sw, y: sourceCenter.y }
|
|
148
|
+
: { x: sx, y: sourceCenter.y };
|
|
149
|
+
|
|
150
|
+
targetPoint = dx > 0
|
|
151
|
+
? { x: tx, y: targetCenter.y }
|
|
152
|
+
: { x: tx + tw, y: targetCenter.y };
|
|
153
|
+
} else {
|
|
154
|
+
// 垂直方向
|
|
155
|
+
sourcePoint = dy > 0
|
|
156
|
+
? { x: sourceCenter.x, y: sy + sh }
|
|
157
|
+
: { x: sourceCenter.x, y: sy };
|
|
158
|
+
|
|
159
|
+
targetPoint = dy > 0
|
|
160
|
+
? { x: targetCenter.x, y: ty }
|
|
161
|
+
: { x: targetCenter.x, y: ty + th };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 更新连线
|
|
165
|
+
const updatedEdge = {
|
|
166
|
+
...edge,
|
|
167
|
+
waypointId: JSON.stringify([sourcePoint, targetPoint]),
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
updateShape(updatedEdge);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 获取图形的四个中心点(上下左右)
|
|
179
|
+
*/
|
|
180
|
+
static getShapeCenterPoints(bounds: {
|
|
181
|
+
x: number;
|
|
182
|
+
y: number;
|
|
183
|
+
width: number;
|
|
184
|
+
height: number;
|
|
185
|
+
}) {
|
|
186
|
+
const { x, y, width, height } = bounds;
|
|
187
|
+
return {
|
|
188
|
+
top: { x: x + width / 2, y: y },
|
|
189
|
+
bottom: { x: x + width / 2, y: y + height },
|
|
190
|
+
left: { x: x, y: y + height / 2 },
|
|
191
|
+
right: { x: x + width, y: y + height / 2 },
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 计算两点之间的距离
|
|
197
|
+
*/
|
|
198
|
+
static getDistance(
|
|
199
|
+
point1: { x: number; y: number },
|
|
200
|
+
point2: { x: number; y: number }
|
|
201
|
+
) {
|
|
202
|
+
const dx = point1.x - point2.x;
|
|
203
|
+
const dy = point1.y - point2.y;
|
|
204
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 找到距离鼠标位置最近的连接点
|
|
209
|
+
*/
|
|
210
|
+
static findNearestConnectPoint(
|
|
211
|
+
mousePos: { x: number; y: number },
|
|
212
|
+
shape: Shape | undefined,
|
|
213
|
+
diagramBounds: any
|
|
214
|
+
) {
|
|
215
|
+
if (!shape?.bounds || !diagramBounds) return null;
|
|
216
|
+
|
|
217
|
+
const canvas = document.querySelector(".diagram-content");
|
|
218
|
+
if (!canvas) return null;
|
|
219
|
+
|
|
220
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
221
|
+
const mouseX = mousePos.x - canvasRect.left - diagramBounds.x;
|
|
222
|
+
const mouseY = mousePos.y - canvasRect.top - diagramBounds.y;
|
|
223
|
+
|
|
224
|
+
const { x = 0, y = 0, width = 0, height = 0 } = shape.bounds;
|
|
225
|
+
|
|
226
|
+
const left = x;
|
|
227
|
+
const right = x + width;
|
|
228
|
+
const top = y;
|
|
229
|
+
const bottom = y + height;
|
|
230
|
+
|
|
231
|
+
const relativeX = mouseX - x;
|
|
232
|
+
const relativeY = mouseY - y;
|
|
233
|
+
|
|
234
|
+
const isInTopArea = relativeY < 0;
|
|
235
|
+
const isInBottomArea = relativeY > height;
|
|
236
|
+
const isInLeftArea = relativeX < 0;
|
|
237
|
+
const isInRightArea = relativeX > width;
|
|
238
|
+
|
|
239
|
+
const connectPoints = this.getShapeCenterPoints({
|
|
240
|
+
x: shape.bounds.x ?? 0,
|
|
241
|
+
y: shape.bounds.y ?? 0,
|
|
242
|
+
width: shape.bounds.width ?? 0,
|
|
243
|
+
height: shape.bounds.height ?? 0,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const mousePoint = { x: mouseX, y: mouseY };
|
|
247
|
+
|
|
248
|
+
// 计算最近的连接点
|
|
249
|
+
if (isInTopArea || isInBottomArea || isInLeftArea || isInRightArea) {
|
|
250
|
+
const distances = {
|
|
251
|
+
top: this.getDistance(mousePoint, connectPoints.top),
|
|
252
|
+
bottom: this.getDistance(mousePoint, connectPoints.bottom),
|
|
253
|
+
left: this.getDistance(mousePoint, connectPoints.left),
|
|
254
|
+
right: this.getDistance(mousePoint, connectPoints.right),
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const nearestPoint = Object.entries(distances).reduce(
|
|
258
|
+
(min, [key, distance]) =>
|
|
259
|
+
distance < min.distance ? { key, distance } : min,
|
|
260
|
+
{ key: "top", distance: Infinity }
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
return connectPoints[nearestPoint.key as keyof typeof connectPoints];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// 鼠标在图形内部,使用最近的边
|
|
267
|
+
const distances = {
|
|
268
|
+
top: Math.abs(mouseY - top),
|
|
269
|
+
bottom: Math.abs(mouseY - bottom),
|
|
270
|
+
left: Math.abs(mouseX - left),
|
|
271
|
+
right: Math.abs(mouseX - right),
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const nearestEdge = Object.entries(distances).reduce(
|
|
275
|
+
(min, [key, distance]) =>
|
|
276
|
+
distance < min.distance ? { key, distance } : min,
|
|
277
|
+
{ key: "top", distance: Infinity }
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
switch (nearestEdge.key) {
|
|
281
|
+
case "top":
|
|
282
|
+
return { x: mouseX, y: top };
|
|
283
|
+
case "bottom":
|
|
284
|
+
return { x: mouseX, y: bottom };
|
|
285
|
+
case "left":
|
|
286
|
+
return { x: left, y: mouseY };
|
|
287
|
+
case "right":
|
|
288
|
+
return { x: right, y: mouseY };
|
|
289
|
+
default:
|
|
290
|
+
return connectPoints.top;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* 完成连接操作,计算最终连接点
|
|
296
|
+
*/
|
|
297
|
+
static completeConnection(
|
|
298
|
+
sourceShape: Shape | undefined,
|
|
299
|
+
targetShape: Shape,
|
|
300
|
+
clickPoint: { x: number; y: number },
|
|
301
|
+
currentConnectPoint: { x: number; y: number },
|
|
302
|
+
shapes: Shape[] = [] // 添加shapes参数,避免在静态方法中使用组合式函数
|
|
303
|
+
) {
|
|
304
|
+
// 如果源图元和目标图元是同一个,直接返回 null
|
|
305
|
+
if (sourceShape?.id && targetShape.id && sourceShape.id === targetShape.id) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (!targetShape.bounds || !sourceShape?.bounds) return null;
|
|
310
|
+
|
|
311
|
+
// 计算源图元和目标图元的中心
|
|
312
|
+
const { x: sx = 0, y: sy = 0, width: sw = 0, height: sh = 0 } = sourceShape.bounds;
|
|
313
|
+
const { x: tx = 0, y: ty = 0, width: tw = 0, height: th = 0 } = targetShape.bounds;
|
|
314
|
+
|
|
315
|
+
const sourceCenter = { x: sx + sw / 2, y: sy + sh / 2 };
|
|
316
|
+
const targetCenter = { x: tx + tw / 2, y: ty + th / 2 };
|
|
317
|
+
|
|
318
|
+
// 获取两个图元的所有边中点
|
|
319
|
+
const sourcePoints = this.getShapeCenterPoints({
|
|
320
|
+
x: sourceShape.bounds.x ?? 0,
|
|
321
|
+
y: sourceShape.bounds.y ?? 0,
|
|
322
|
+
width: sourceShape.bounds.width ?? 0,
|
|
323
|
+
height: sourceShape.bounds.height ?? 0,
|
|
324
|
+
});
|
|
325
|
+
const targetPoints = this.getShapeCenterPoints({
|
|
326
|
+
x: targetShape.bounds.x ?? 0,
|
|
327
|
+
y: targetShape.bounds.y ?? 0,
|
|
328
|
+
width: targetShape.bounds.width ?? 0,
|
|
329
|
+
height: targetShape.bounds.height ?? 0,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// 找出源图元和目标图元之间距离最短的边中点组合
|
|
333
|
+
let minDistance = Infinity;
|
|
334
|
+
let bestSourcePoint = sourcePoints.top; // 默认值
|
|
335
|
+
let bestTargetPoint = targetPoints.top; // 默认值
|
|
336
|
+
|
|
337
|
+
// 遍历所有可能的源点和目标点组合
|
|
338
|
+
Object.values(sourcePoints).forEach(sourcePoint => {
|
|
339
|
+
Object.values(targetPoints).forEach(targetPoint => {
|
|
340
|
+
const distance = this.getDistance(sourcePoint, targetPoint);
|
|
341
|
+
if (distance < minDistance) {
|
|
342
|
+
minDistance = distance;
|
|
343
|
+
bestSourcePoint = sourcePoint;
|
|
344
|
+
bestTargetPoint = targetPoint;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
// 使用最短距离的点作为连接点
|
|
350
|
+
const startPoint = bestSourcePoint;
|
|
351
|
+
let targetPoint = bestTargetPoint;
|
|
352
|
+
|
|
353
|
+
// 以下是原始代码,保留以处理特殊情况(如果需要的话)
|
|
354
|
+
/*
|
|
355
|
+
const { x = 0, y = 0, width = 0, height = 0 } = targetShape.bounds;
|
|
356
|
+
|
|
357
|
+
const left = x;
|
|
358
|
+
const right = x + width;
|
|
359
|
+
const top = y;
|
|
360
|
+
const bottom = y + height;
|
|
361
|
+
|
|
362
|
+
const relativeX = clickPoint.x - x;
|
|
363
|
+
const relativeY = clickPoint.y - y;
|
|
364
|
+
|
|
365
|
+
const isInTopArea = relativeY < 0;
|
|
366
|
+
const isInBottomArea = relativeY > height;
|
|
367
|
+
const isInLeftArea = relativeX < 0;
|
|
368
|
+
const isInRightArea = relativeX > width;
|
|
369
|
+
|
|
370
|
+
if (isInTopArea) {
|
|
371
|
+
const constrainedX = Math.max(left, Math.min(right, clickPoint.x));
|
|
372
|
+
targetPoint = { x: constrainedX, y: top };
|
|
373
|
+
} else if (isInBottomArea) {
|
|
374
|
+
const constrainedX = Math.max(left, Math.min(right, clickPoint.x));
|
|
375
|
+
targetPoint = { x: constrainedX, y: bottom };
|
|
376
|
+
} else if (isInLeftArea) {
|
|
377
|
+
const constrainedY = Math.max(top, Math.min(bottom, clickPoint.y));
|
|
378
|
+
targetPoint = { x: left, y: constrainedY };
|
|
379
|
+
} else if (isInRightArea) {
|
|
380
|
+
const constrainedY = Math.max(top, Math.min(bottom, clickPoint.y));
|
|
381
|
+
targetPoint = { x: right, y: constrainedY };
|
|
382
|
+
} else {
|
|
383
|
+
const distances = {
|
|
384
|
+
top: Math.abs(clickPoint.y - top),
|
|
385
|
+
bottom: Math.abs(clickPoint.y - bottom),
|
|
386
|
+
left: Math.abs(clickPoint.x - left),
|
|
387
|
+
right: Math.abs(clickPoint.x - right),
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const nearestEdge = Object.entries(distances).reduce(
|
|
391
|
+
(min, [key, distance]) =>
|
|
392
|
+
distance < min.distance ? { key, distance } : min,
|
|
393
|
+
{ key: "top", distance: Infinity }
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
switch (nearestEdge.key) {
|
|
397
|
+
case "top":
|
|
398
|
+
targetPoint = { x: clickPoint.x, y: top };
|
|
399
|
+
break;
|
|
400
|
+
case "bottom":
|
|
401
|
+
targetPoint = { x: clickPoint.x, y: bottom };
|
|
402
|
+
break;
|
|
403
|
+
case "left":
|
|
404
|
+
targetPoint = { x: left, y: clickPoint.y };
|
|
405
|
+
break;
|
|
406
|
+
case "right":
|
|
407
|
+
targetPoint = { x: right, y: clickPoint.y };
|
|
408
|
+
break;
|
|
409
|
+
default:
|
|
410
|
+
targetPoint = { x: x + width / 2, y: y + height / 2 };
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
*/
|
|
414
|
+
|
|
415
|
+
// 计算路径点 - 直接返回两点连线,保留转折逻辑作为注释
|
|
416
|
+
|
|
417
|
+
// 检查是否已存在相同源和目标的边,以及反向连接的边,为新边添加偏移以避免重合
|
|
418
|
+
const existingEdges = shapes.filter(
|
|
419
|
+
shape => shape.shapeType === 'edge' &&
|
|
420
|
+
((shape.sourceId === sourceShape?.id && shape.targetId === targetShape.id) ||
|
|
421
|
+
(shape.sourceId === targetShape.id && shape.targetId === sourceShape?.id))
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
// 计算连接方向
|
|
425
|
+
const dx = targetCenter.x - sourceCenter.x;
|
|
426
|
+
const dy = targetCenter.y - sourceCenter.y;
|
|
427
|
+
|
|
428
|
+
// 为新连线添加偏移量,避免与已存在的连线重叠
|
|
429
|
+
let adjustedStartPoint = { ...startPoint };
|
|
430
|
+
let adjustedEndPoint = { ...targetPoint };
|
|
431
|
+
|
|
432
|
+
if (existingEdges.length > 0) {
|
|
433
|
+
// 新连线的索引(从0开始)
|
|
434
|
+
const index = existingEdges.length;
|
|
435
|
+
|
|
436
|
+
// 生成基于索引的偏移量
|
|
437
|
+
const offsetDistance = 5 * (index + 1);
|
|
438
|
+
|
|
439
|
+
// 根据方向计算偏移方向
|
|
440
|
+
let offsetX = 0, offsetY = 0;
|
|
441
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
442
|
+
// 水平方向为主,垂直偏移
|
|
443
|
+
offsetY = offsetDistance;
|
|
444
|
+
} else {
|
|
445
|
+
// 垂直方向为主,水平偏移
|
|
446
|
+
offsetX = offsetDistance;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// 确保线条交替偏移方向,避免全部偏向一侧
|
|
450
|
+
if (index % 2 === 1) {
|
|
451
|
+
offsetX = -offsetX;
|
|
452
|
+
offsetY = -offsetY;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// 应用偏移量到连接点
|
|
456
|
+
adjustedStartPoint = { x: startPoint.x + offsetX, y: startPoint.y + offsetY };
|
|
457
|
+
adjustedEndPoint = { x: targetPoint.x + offsetX, y: targetPoint.y + offsetY };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// 使用调整后的点作为waypoints
|
|
461
|
+
const waypoints = [adjustedStartPoint, adjustedEndPoint];
|
|
462
|
+
|
|
463
|
+
/* 保留转折逻辑以备后续使用
|
|
464
|
+
const deltaX = Math.abs(endPoint.x - startPoint.x);
|
|
465
|
+
const deltaY = Math.abs(endPoint.y - startPoint.y);
|
|
466
|
+
|
|
467
|
+
// 计算偏移量,每条现有边增加15px的偏移
|
|
468
|
+
const offsetAmount = existingEdges.length * 15;
|
|
469
|
+
|
|
470
|
+
waypoints = [startPoint];
|
|
471
|
+
if (deltaX > 0 || deltaY > 0) {
|
|
472
|
+
let midPoint;
|
|
473
|
+
|
|
474
|
+
// 如果有现有边,使用偏移的路径以避免重合
|
|
475
|
+
if (existingEdges.length > 0) {
|
|
476
|
+
// 根据连接方向决定偏移方向
|
|
477
|
+
if (deltaX <= deltaY) {
|
|
478
|
+
// 垂直方向为主,水平偏移
|
|
479
|
+
const offsetDir = existingEdges.length % 2 === 0 ? 1 : -1; // 交替偏移方向
|
|
480
|
+
midPoint = {
|
|
481
|
+
x: endPoint.x + offsetDir * offsetAmount,
|
|
482
|
+
y: startPoint.y
|
|
483
|
+
};
|
|
484
|
+
} else {
|
|
485
|
+
// 水平方向为主,垂直偏移
|
|
486
|
+
const offsetDir = existingEdges.length % 2 === 0 ? 1 : -1; // 交替偏移方向
|
|
487
|
+
midPoint = {
|
|
488
|
+
x: startPoint.x,
|
|
489
|
+
y: endPoint.y + offsetDir * offsetAmount
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
// 没有现有边,使用标准直角路径
|
|
494
|
+
midPoint = deltaX <= deltaY
|
|
495
|
+
? { x: endPoint.x, y: startPoint.y }
|
|
496
|
+
: { x: startPoint.x, y: endPoint.y };
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (midPoint.x !== startPoint.x || midPoint.y !== startPoint.y) {
|
|
500
|
+
if (midPoint.x !== endPoint.x || midPoint.y !== endPoint.y) {
|
|
501
|
+
waypoints.push(midPoint);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
waypoints.push(endPoint);
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
return {
|
|
509
|
+
sourceId: sourceShape?.id,
|
|
510
|
+
sourceModelId: sourceShape?.modelId,
|
|
511
|
+
targetId: targetShape.id,
|
|
512
|
+
targetModelId: targetShape.modelId,
|
|
513
|
+
sourcePoint: adjustedStartPoint,
|
|
514
|
+
targetPoint: adjustedEndPoint,
|
|
515
|
+
waypoints,
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* 计算线路径点
|
|
521
|
+
* 当前实现:直接返回两点连线,暂时不添加转折点
|
|
522
|
+
* 保留转折点计算逻辑以备后续使用
|
|
523
|
+
*/
|
|
524
|
+
static calculateLinePoints(
|
|
525
|
+
startPoint: { x: number; y: number },
|
|
526
|
+
endPoint: { x: number; y: number }
|
|
527
|
+
) {
|
|
528
|
+
// 当前实现:直接返回两点连线
|
|
529
|
+
return `${startPoint.x},${startPoint.y} ${endPoint.x},${endPoint.y}`;
|
|
530
|
+
|
|
531
|
+
/* 保留转折点计算逻辑以备后续使用
|
|
532
|
+
const deltaX = Math.abs(endPoint.x - startPoint.x);
|
|
533
|
+
const deltaY = Math.abs(endPoint.y - startPoint.y);
|
|
534
|
+
|
|
535
|
+
let midX, midY;
|
|
536
|
+
if (deltaX <= deltaY) {
|
|
537
|
+
midX = endPoint.x;
|
|
538
|
+
midY = startPoint.y;
|
|
539
|
+
} else {
|
|
540
|
+
midX = startPoint.x;
|
|
541
|
+
midY = endPoint.y;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return `${startPoint.x},${startPoint.y} ${midX},${midY} ${endPoint.x},${endPoint.y}`;
|
|
545
|
+
*/
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* 检查鼠标是否在画布内
|
|
550
|
+
*/
|
|
551
|
+
static isWithinCanvas(x: number, y: number) {
|
|
552
|
+
const canvas = document.querySelector(".diagram-content");
|
|
553
|
+
if (!canvas) return false;
|
|
554
|
+
|
|
555
|
+
const rect = canvas.getBoundingClientRect();
|
|
556
|
+
return (
|
|
557
|
+
x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* 检查鼠标悬停的目标图形
|
|
563
|
+
*/
|
|
564
|
+
static checkHoverTarget(
|
|
565
|
+
x: number,
|
|
566
|
+
y: number,
|
|
567
|
+
shapes: Shape[],
|
|
568
|
+
diagramBounds: any,
|
|
569
|
+
sourceId?: string
|
|
570
|
+
) {
|
|
571
|
+
const canvas = document.querySelector(".diagram-content");
|
|
572
|
+
if (!canvas) return null;
|
|
573
|
+
|
|
574
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
575
|
+
const clickX = x - canvasRect.left - (diagramBounds?.x || 0);
|
|
576
|
+
const clickY = y - canvasRect.top - (diagramBounds?.y || 0);
|
|
577
|
+
|
|
578
|
+
const hit = pickTarget(shapes, { x: clickX, y: clickY });
|
|
579
|
+
|
|
580
|
+
if (["shape","pin"].includes(hit.kind) && hit.shape?.id && sourceId && hit.shape.id !== sourceId) {
|
|
581
|
+
return hit.shape;
|
|
582
|
+
}
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* 初始化连接点位置
|
|
588
|
+
*/
|
|
589
|
+
static initializeConnectPoint(sourceShape: Shape | undefined, initialMousePos?: { x: number; y: number }, diagramBounds?: any) {
|
|
590
|
+
if (!sourceShape?.bounds) return null;
|
|
591
|
+
|
|
592
|
+
// 如果提供了鼠标位置,使用findNearestConnectPoint计算初始连接点
|
|
593
|
+
if (initialMousePos && diagramBounds) {
|
|
594
|
+
// 直接使用传入的鼠标位置(屏幕坐标)调用findNearestConnectPoint
|
|
595
|
+
// findNearestConnectPoint方法内部会进行坐标转换
|
|
596
|
+
const nearestPoint = this.findNearestConnectPoint(initialMousePos, sourceShape, diagramBounds);
|
|
597
|
+
if (nearestPoint) {
|
|
598
|
+
return nearestPoint;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// 如果没有鼠标位置,或者findNearestConnectPoint返回null,使用中心点作为后备方案
|
|
603
|
+
const { x = 0, y = 0, width = 0, height = 0 } = sourceShape.bounds;
|
|
604
|
+
|
|
605
|
+
return {
|
|
606
|
+
x: x + width / 2,
|
|
607
|
+
y: y + height / 2,
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
static isEndPointInShape(shapes: Shape[], endPoint: { x: number; y: number }) {
|
|
612
|
+
for (const shape of shapes) {
|
|
613
|
+
// 排除 diagram 类型的图形
|
|
614
|
+
if (shape.shapeType === 'diagram') continue;
|
|
615
|
+
|
|
616
|
+
if (!shape.bounds) continue;
|
|
617
|
+
|
|
618
|
+
const { x = 0, y = 0, width = 0, height = 0 } = shape.bounds;
|
|
619
|
+
|
|
620
|
+
// 判断点是否在矩形内
|
|
621
|
+
if (
|
|
622
|
+
endPoint.x >= x &&
|
|
623
|
+
endPoint.x <= x + width &&
|
|
624
|
+
endPoint.y >= y &&
|
|
625
|
+
endPoint.y <= y + height
|
|
626
|
+
) {
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* 初始化所有连线的端点
|
|
636
|
+
* 用于在初始加载后端数据后,自动计算所有连线的合适端点,避免线横跨图元
|
|
637
|
+
* @param shapes 所有图元列表
|
|
638
|
+
* @param updateShape 更新图元的回调函数
|
|
639
|
+
*/
|
|
640
|
+
static initializeAllEdgeEndpoints(shapes: Shape[], updateShape: (shape: Shape) => void) {
|
|
641
|
+
const edges = shapes.filter((shape) => shape.shapeType === "edge");
|
|
642
|
+
|
|
643
|
+
// 按源-目标对分组,为每组中的线条生成不同的偏移
|
|
644
|
+
const edgeGroups = new Map<string, Shape[]>();
|
|
645
|
+
|
|
646
|
+
edges.forEach((edge) => {
|
|
647
|
+
if (edge.sourceId && edge.targetId) {
|
|
648
|
+
// 创建源-目标对的规范化键(确保 A-B 和 B-A 使用相同的键)
|
|
649
|
+
const isForward = edge.sourceId.localeCompare(edge.targetId) <= 0;
|
|
650
|
+
const groupKey = isForward
|
|
651
|
+
? `${edge.sourceId}-${edge.targetId}`
|
|
652
|
+
: `${edge.targetId}-${edge.sourceId}`;
|
|
653
|
+
|
|
654
|
+
if (!edgeGroups.has(groupKey)) {
|
|
655
|
+
edgeGroups.set(groupKey, []);
|
|
656
|
+
}
|
|
657
|
+
edgeGroups.get(groupKey)!.push(edge);
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
// 处理每个分组
|
|
662
|
+
edgeGroups.forEach((groupEdges, groupKey) => {
|
|
663
|
+
if (groupEdges.length > 1) {
|
|
664
|
+
// 如果同一源-目标对有多个线条,为每条线生成不同的偏移
|
|
665
|
+
groupEdges.forEach((edge, index) => {
|
|
666
|
+
const sourceShape = shapes.find((s) => s.id === edge.sourceId);
|
|
667
|
+
const targetShape = shapes.find((s) => s.id === edge.targetId);
|
|
668
|
+
|
|
669
|
+
if (sourceShape && targetShape && sourceShape.bounds && targetShape.bounds) {
|
|
670
|
+
// 计算基本连接点
|
|
671
|
+
const { x: sx = 0, y: sy = 0, width: sw = 0, height: sh = 0 } = sourceShape.bounds;
|
|
672
|
+
const { x: tx = 0, y: ty = 0, width: tw = 0, height: th = 0 } = targetShape.bounds;
|
|
673
|
+
|
|
674
|
+
// 计算中心点
|
|
675
|
+
const sourceCenter = { x: sx + sw / 2, y: sy + sh / 2 };
|
|
676
|
+
const targetCenter = { x: tx + tw / 2, y: ty + th / 2 };
|
|
677
|
+
|
|
678
|
+
// 计算连接方向
|
|
679
|
+
const dx = targetCenter.x - sourceCenter.x;
|
|
680
|
+
const dy = targetCenter.y - sourceCenter.y;
|
|
681
|
+
|
|
682
|
+
// 生成基于索引的偏移量(小到不会明显影响,但足以分开线条)
|
|
683
|
+
const offsetDistance = 5 * (index + 1);
|
|
684
|
+
|
|
685
|
+
// 根据方向计算偏移方向
|
|
686
|
+
let offsetX = 0, offsetY = 0;
|
|
687
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
688
|
+
// 水平方向为主,垂直偏移
|
|
689
|
+
offsetY = offsetDistance;
|
|
690
|
+
} else {
|
|
691
|
+
// 垂直方向为主,水平偏移
|
|
692
|
+
offsetX = offsetDistance;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// 确保线条交替偏移方向,避免全部偏向一侧
|
|
696
|
+
if (index % 2 === 1) {
|
|
697
|
+
offsetX = -offsetX;
|
|
698
|
+
offsetY = -offsetY;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// 确定连接点,添加偏移
|
|
702
|
+
let sourcePoint, targetPoint;
|
|
703
|
+
|
|
704
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
705
|
+
// 水平方向
|
|
706
|
+
sourcePoint = dx > 0
|
|
707
|
+
? { x: sx + sw, y: sourceCenter.y + offsetY }
|
|
708
|
+
: { x: sx, y: sourceCenter.y + offsetY };
|
|
709
|
+
|
|
710
|
+
targetPoint = dx > 0
|
|
711
|
+
? { x: tx, y: targetCenter.y + offsetY }
|
|
712
|
+
: { x: tx + tw, y: targetCenter.y + offsetY };
|
|
713
|
+
} else {
|
|
714
|
+
// 垂直方向
|
|
715
|
+
sourcePoint = dy > 0
|
|
716
|
+
? { x: sourceCenter.x + offsetX, y: sy + sh }
|
|
717
|
+
: { x: sourceCenter.x + offsetX, y: sy };
|
|
718
|
+
|
|
719
|
+
targetPoint = dy > 0
|
|
720
|
+
? { x: targetCenter.x + offsetX, y: ty }
|
|
721
|
+
: { x: targetCenter.x + offsetX, y: ty + th };
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// 更新连线,只使用源点和目标点确保线条保持直线
|
|
725
|
+
const waypoints = [sourcePoint, targetPoint];
|
|
726
|
+
|
|
727
|
+
const updatedEdge = {
|
|
728
|
+
...edge,
|
|
729
|
+
waypointId: JSON.stringify(waypoints),
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
updateShape(updatedEdge);
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
} else {
|
|
736
|
+
// 单线条情况
|
|
737
|
+
const edge = groupEdges[0];
|
|
738
|
+
const sourceShape = shapes.find((s) => s.id === edge.sourceId);
|
|
739
|
+
const targetShape = shapes.find((s) => s.id === edge.targetId);
|
|
740
|
+
|
|
741
|
+
if (sourceShape && targetShape && sourceShape.bounds && targetShape.bounds) {
|
|
742
|
+
const { x: sx = 0, y: sy = 0, width: sw = 0, height: sh = 0 } = sourceShape.bounds;
|
|
743
|
+
const { x: tx = 0, y: ty = 0, width: tw = 0, height: th = 0 } = targetShape.bounds;
|
|
744
|
+
|
|
745
|
+
// 计算中心点
|
|
746
|
+
const sourceCenter = { x: sx + sw / 2, y: sy + sh / 2 };
|
|
747
|
+
const targetCenter = { x: tx + tw / 2, y: ty + th / 2 };
|
|
748
|
+
|
|
749
|
+
// 计算连接方向
|
|
750
|
+
const dx = targetCenter.x - sourceCenter.x;
|
|
751
|
+
const dy = targetCenter.y - sourceCenter.y;
|
|
752
|
+
|
|
753
|
+
// 确定连接点
|
|
754
|
+
let sourcePoint, targetPoint;
|
|
755
|
+
|
|
756
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
757
|
+
// 水平方向
|
|
758
|
+
sourcePoint = dx > 0
|
|
759
|
+
? { x: sx + sw, y: sourceCenter.y }
|
|
760
|
+
: { x: sx, y: sourceCenter.y };
|
|
761
|
+
|
|
762
|
+
targetPoint = dx > 0
|
|
763
|
+
? { x: tx, y: targetCenter.y }
|
|
764
|
+
: { x: tx + tw, y: targetCenter.y };
|
|
765
|
+
} else {
|
|
766
|
+
// 垂直方向
|
|
767
|
+
sourcePoint = dy > 0
|
|
768
|
+
? { x: sourceCenter.x, y: sy + sh }
|
|
769
|
+
: { x: sourceCenter.x, y: sy };
|
|
770
|
+
|
|
771
|
+
targetPoint = dy > 0
|
|
772
|
+
? { x: targetCenter.x, y: ty }
|
|
773
|
+
: { x: targetCenter.x, y: ty + th };
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// 更新连线
|
|
777
|
+
const updatedEdge = {
|
|
778
|
+
...edge,
|
|
779
|
+
waypointId: JSON.stringify([sourcePoint, targetPoint]),
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
updateShape(updatedEdge);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
}
|