ea 0.6.104 → 0.6.105

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53866c904e4fef2b317cd5aeb9e0b142e3d970507b65e9d9f14d2c768a56f1e8
4
- data.tar.gz: 40ad1c86acd5461a89fe8e6b23a9da1f65eb43ef9eba632583344d09ed54b932
3
+ metadata.gz: 430568b3607d439af39bac818b48ee27caa207875c7f2015e3a6f5689419680b
4
+ data.tar.gz: dfb835e2208d50a51caa01acb96a30e2561f5ccbdf6e83a6a1c55ec368c4b5b8
5
5
  SHA512:
6
- metadata.gz: f475a015d57fc2337ef3a19ea8e81fbd75e2f04532d79893e5fc01e1e9b344b07b973e4b833a4480dc49aed31f1ff4b45463950e53dc5e290f2b7304638be9e9
7
- data.tar.gz: b8ca9731d6d2442f74778cbe4ad66550cada64399cbf33eb858a4e0ad59ad7e9488516732194d29ebaa7733c3beae401ae7e7856964b3d1c4fd0989abae0db6d
6
+ metadata.gz: ce35bed8f6b13d1f799d8c99b550ad70d19453e2f2827888c1dce54b246dc9a938baa52cfe2d24f9fb9f093ecce1a86b52c4dbecbb60b397777c592cc61ea654
7
+ data.tar.gz: 22747dc14774fbfaa984efba1c88078619d8ab6bc74b4d06d5276074a93957dccc071963574aad3ff272377d043e51e613723708d0fa48318acf6558ec920de1
@@ -4,7 +4,7 @@ module Ea
4
4
  module Sources
5
5
  module Qea
6
6
  class DiagramBuilder
7
- # Source-led routes for auto-routed associations with unequal end offsets.
7
+ # Stored mathematical docking for auto-routed associations.
8
8
  module AutoRouting
9
9
  private
10
10
 
@@ -22,6 +22,53 @@ module Ea
22
22
  model
23
23
  end
24
24
 
25
+ # When the shared row misses the target, retain the physical ports
26
+ # and let the emitter clip their ray before inserting the elbow.
27
+ def auto_port_elbow(model, link_row, diagram_row, geom, context)
28
+ return model if context || !auto_port_elbow_candidate?(model, link_row, geom)
29
+
30
+ source, target = stored_ray_boxes(link_row, diagram_row)
31
+ origins = [stored_ray_origin(source, geom[:sx], geom[:sy]),
32
+ stored_ray_origin(target, geom[:ex], geom[:ey])]
33
+ return model unless auto_port_elbow_origins?(source, target, origins, geom)
34
+
35
+ apply_auto_port_elbow(model, origins)
36
+ end
37
+
38
+ def apply_auto_port_elbow(model, origins)
39
+ model.source_anchor, model.target_anchor = origins
40
+ model.waypoints = origins.map { |point| Ea::Model::Waypoint.new(position: point) }
41
+ model.style = model.style.to_h.merge(association_ray_outline: true, auto_port_elbow: true)
42
+ model
43
+ end
44
+
45
+ def auto_port_elbow_candidate?(model, link_row, geom)
46
+ auto_port_elbow_model?(model) && link_row.path.to_s.empty? &&
47
+ source_row_style?(model.style.to_h) && uniform_overlap_offsets?(geom) && geom[:edge] == 4
48
+ end
49
+
50
+ def auto_port_elbow_model?(model)
51
+ model.connector_type == "Association" && model.has_geometry_offsets &&
52
+ model.source_anchor && model.target_anchor && model.waypoints.size == 2
53
+ end
54
+
55
+ def auto_port_elbow_origins?(source, target, origins, geom)
56
+ return false if overlap_origins(source, target, geom)
57
+ return false unless source_row_faces_target?(source, target, geom[:edge])
58
+ return false unless origins.first.x == source.x - 1
59
+ return false if within_height?(origins.first.y, target)
60
+ return false unless crosses_target_horizontal_edge?(origins, target)
61
+
62
+ [source, target].zip(origins).all? { |box, origin| inside_box?(origin, grown_bounds(box, 1)) }
63
+ end
64
+
65
+ def crosses_target_horizontal_edge?(origins, target)
66
+ outline = grown_bounds(target, 1)
67
+ edge = Ea::Model::Bounds.new(x: outline.x, width: outline.width, height: 0,
68
+ y: origins.first.y < outline.y ? outline.y : outline.y + outline.height)
69
+ segment_crosses_box?(*origins, edge)
70
+ end
71
+
25
72
  def source_row_origins(source, target, geom)
26
73
  return nil unless source_row_faces_target?(source, target, geom[:edge])
27
74
 
@@ -443,6 +443,7 @@ module Ea
443
443
  model = correct_stored_ray_origins(model, link_row, diagram_row, geom, context)
444
444
  model = source_row_association_ray(model, link_row, diagram_row, geom, context)
445
445
  model = overlap_ray_origins(model, link_row, diagram_row, geom, context)
446
+ model = auto_port_elbow(model, link_row, diagram_row, geom, context)
446
447
  model = mark_default_square_ray(model, link_row, geom, context)
447
448
  restore_stored_square_ports(model, link_row, diagram_row, geom, context)
448
449
  end
@@ -60,9 +60,26 @@ module Ea
60
60
  pairs = expanded ? candidate : original
61
61
  target = expanded ? outline.last : target_bounds
62
62
  pairs = default_square_pairs(connector, points, source_bounds, target, pairs)
63
- stored_top_pairs(connector, expanded ? outline.first : source_bounds, pairs)
63
+ source = expanded ? outline.first : source_bounds
64
+ pairs = stored_top_pairs(connector, source, pairs)
65
+ auto_port_elbow_pairs(connector, source, target, pairs)
64
66
  end
65
67
 
68
+ # Auto routing turns at the clipped target column when the source
69
+ # leaves a side edge and the target enters through its top or bottom.
70
+ def auto_port_elbow_pairs(connector, source, target, pairs)
71
+ return pairs unless connector.style.to_h[:auto_port_elbow] == true
72
+
73
+ first, last = pairs
74
+ return pairs unless on_side_edge?(first, source) &&
75
+ [target.y, target.y + target.height].include?(last[1]) &&
76
+ last[0].between?(target.x, target.x + target.width)
77
+ return pairs if first[0] == last[0] || first[1] == last[1]
78
+
79
+ [first, [last[0], first[1]], last]
80
+ end
81
+ private_class_method :auto_port_elbow_pairs
82
+
66
83
  # EDGE=1 explicitly seats an external source ray on the top edge;
67
84
  # its first contact can instead be the bottom when its origin is below.
68
85
  def stored_top_pairs(connector, source, pairs)
data/lib/ea/version.rb CHANGED
@@ -4,5 +4,5 @@ module Ea
4
4
  # Gem release version. Extracted to its own file so the
5
5
  # `gem-release` tool's `gem bump` can find and update it via the
6
6
  # standard `lib/<gem>/version.rb` convention.
7
- VERSION = "0.6.104"
7
+ VERSION = "0.6.105"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.104
4
+ version: 0.6.105
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.