Module: Roby::GUI::GraphvizPlan
- Included in:
- Plan
- Defined in:
- lib/roby/gui/plan_dot_layout.rb
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
The distance from the root plan.
-
#layout_level ⇒ Object
Returns the value of attribute layout_level.
Instance Method Summary collapse
- #all_events(display) ⇒ Object
- #apply_layout(bounding_rects, positions, display, max_depth = nil) ⇒ Object
-
#compute_depth(depth) ⇒ Object
Computes the plan depths and max_depth for this plan and all its children.
- #each_displayed_relation(display, graphs, objects, &block) ⇒ Object
- #each_edge(graph, display, objects) ⇒ Object
- #each_layout_relation(display, graphs, objects, &block) ⇒ Object
- #layout_relations(positions, display, graphs, objects) ⇒ Object
- #relations_to_dot(display, io, graphs, objects) ⇒ Object
- #to_dot(display, io, level) ⇒ Object
Instance Attribute Details
#depth ⇒ Object (readonly)
The distance from the root plan
99 100 101 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 99 def depth @depth end |
#layout_level ⇒ Object
Returns the value of attribute layout_level.
10 11 12 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 10 def layout_level @layout_level end |
Instance Method Details
#all_events(display) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 12 def all_events(display) tasks.inject(free_events.dup) do |events, task| if display.displayed?(task) events.merge(task.events.values.to_set) else events end end end |
#apply_layout(bounding_rects, positions, display, max_depth = nil) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 113 def apply_layout(bounding_rects, positions, display, max_depth = nil) max_depth ||= compute_depth(0) if rect = bounding_rects[dot_id] item = display[self] item.z_value = PLAN_LAYER + depth - max_depth item.rect = rect else DRoby::Logfile.warn "no bounding rectangle for #{self} (#{dot_id})" end (tasks | finalized_tasks | free_events | finalized_events) .each do |obj| next unless display.displayed?(obj) obj.apply_layout(bounding_rects, positions, display) end transactions.each do |trsc| trsc.apply_layout(bounding_rects, positions, display, max_depth) end layout_relations(positions, display, each_task_relation_graph.to_a, tasks) end |
#compute_depth(depth) ⇒ Object
Computes the plan depths and max_depth for this plan and all its children. depth
is this plan depth
Returns max_depth
105 106 107 108 109 110 111 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 105 def compute_depth(depth) @depth = depth child_depth = transactions .map { |trsc| trsc.compute_depth(depth + 1) } .max child_depth || depth end |
#each_displayed_relation(display, graphs, objects, &block) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 69 def each_displayed_relation(display, graphs, objects, &block) graphs.each do |g| next unless display.relation_enabled?(g.class) each_edge(g, display, objects, &block) end end |
#each_edge(graph, display, objects) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 39 def each_edge(graph, display, objects) objects.each do |from| next unless display.displayed?(from) unless display[from] DRoby::Logfile.warn "no display item for #{from} in #each_displayed_relation" next end graph.each_out_neighbour(from) do |to| next unless display.displayed?(to) unless display[to] DRoby::Logfile.warn "no display item for child in #{from} <#{rel}> #{to} in #each_displayed_relation" next end yield(graph, from, to) end end end |
#each_layout_relation(display, graphs, objects, &block) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 61 def each_layout_relation(display, graphs, objects, &block) graphs.each do |g| next unless display.layout_relation?(g.class) each_edge(g, display, objects, &block) end end |
#layout_relations(positions, display, graphs, objects) ⇒ Object
92 93 94 95 96 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 92 def layout_relations(positions, display, graphs, objects) each_displayed_relation(display, graphs, objects) do |graph, from, to| display.task_relation(from, to, graph.class, graph.edge_info(from, to)) end end |
#relations_to_dot(display, io, graphs, objects) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 77 def relations_to_dot(display, io, graphs, objects) each_layout_relation(display, graphs, objects) do |graph, from, to| from_id, to_id = from.dot_id, to.dot_id if from_id && to_id io << " #{from_id} -> #{to_id}\n" else DRoby::Logfile.warn( "ignoring #{from}(#{from.object_id} #{from_id}) -> "\ "#{to}(#{to.object_id} #{to_id}) in #{graph.class} "\ "in #{caller(1).join("\n ")}" ) end end end |
#to_dot(display, io, level) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/roby/gui/plan_dot_layout.rb', line 22 def to_dot(display, io, level) @layout_level = level io << "subgraph cluster_#{dot_id} {\n" (tasks | finalized_tasks | free_events | finalized_events) .each do |obj| obj.to_dot(display, io) if display.displayed?(obj) end io << "};\n" transactions.each do |trsc| trsc.to_dot(display, io, level + 1) end relations_to_dot(display, io, each_task_relation_graph, tasks) end |