物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.9 KiB

  1. import { getShapeStyleFuction, getTextStyleFunction } from './getShapeStyleUtil.js'
  2. const { PureCurvedPolylineEdge, PureCurvedPolylineEdgeModel } = window
  3. // 折线
  4. class PureCurvedConnection extends PureCurvedPolylineEdge {
  5. constructor() {
  6. super()
  7. this.textRef = null
  8. }
  9. getText() {
  10. return null
  11. }
  12. getEndArrow() {
  13. const h = window.h
  14. const { model, graphModel } = this.props
  15. const {
  16. id,
  17. properties: { arrowType, borderColor },
  18. } = model
  19. const { stroke, strokeWidth } = model.getArrowStyle()
  20. const pathAttr = {
  21. stroke,
  22. strokeWidth,
  23. }
  24. if (arrowType === 'empty') {
  25. // 空心箭头
  26. return h('path', {
  27. ...pathAttr,
  28. fill: '#FFF',
  29. d: 'M 0 0 -10 -5 -10 5 z',
  30. })
  31. }
  32. else if (arrowType === 'half') {
  33. // 半箭头
  34. return h('path', {
  35. ...pathAttr,
  36. d: 'M 0 0 -10 5',
  37. })
  38. }
  39. else if (arrowType === 'none') {
  40. // 无箭头
  41. return h('path', {
  42. ...pathAttr,
  43. d: '',
  44. })
  45. }
  46. return h('path', {
  47. ...pathAttr,
  48. fill: borderColor,
  49. d: 'M 0 0 -10 -5 -10 5 z',
  50. })
  51. }
  52. }
  53. class PureCurvedModel extends PureCurvedPolylineEdgeModel {
  54. constructor(data, graphModel) {
  55. super(data, graphModel)
  56. this.strokeWidth = 1
  57. this.isShowAdjustPoint = false
  58. this.modelType = 'pure-curved-polyline-edge'
  59. this.isCurved = false
  60. }
  61. getEdgeAnimationStyle() {
  62. const animation = super.getEdgeAnimationStyle()
  63. const { borderColor, strokeDashWidth, strokeDashWidth2, strokeDashSpace, animationName, animationDuration, animationReverse } = this.properties
  64. animation.stroke = borderColor
  65. animation.strokeDashoffset = ''
  66. animation.strokeDasharray = `${strokeDashWidth},${strokeDashSpace},${strokeDashWidth2}`
  67. animation.animationName = animationName || 'lf_animate_dash'
  68. animation.animationDuration = animationDuration || '20s'
  69. animation.animationDirection = animationReverse ? 'reverse' : ''
  70. return animation
  71. }
  72. setAttributes() {
  73. const { defaultValue, min, max } = this.properties
  74. if (defaultValue) {
  75. const realValue = window.resolveScadaNewValue(defaultValue)
  76. const realMin = min < max ? min : max
  77. const realMax = max > min ? max : min
  78. if (realValue >= realMin && realValue <= realMax)
  79. this.isAnimation = true
  80. else
  81. this.isAnimation = false
  82. }
  83. else {
  84. this.isAnimation = this.properties.isAnimation || false
  85. }
  86. }
  87. getTextStyle() {
  88. const style = super.getTextStyle()
  89. return getTextStyleFunction(style, this.properties)
  90. }
  91. getEdgeStyle() {
  92. const attributes = super.getEdgeStyle()
  93. const properties = this.properties
  94. const style = getShapeStyleFuction(attributes, properties)
  95. return { ...style, fill: 'none', class: properties.isCustomHelperLine ? 'customHelperLine' : '' }
  96. }
  97. }
  98. export default {
  99. type: 'pure-curved-polyline',
  100. view: PureCurvedConnection,
  101. model: PureCurvedModel,
  102. }