Class: Roby::Log::RelationsDisplay
- Includes:
- DataDisplay, TaskDisplaySupport
- Defined in:
- lib/roby/log/relations.rb
Constant Summary collapse
- COLORS =
%w{'black' #800000 #008000 #000080 #C05800 #6633FF #CDBE70 #CD8162 #A2B5CD}
Instance Attribute Summary collapse
-
#arrows ⇒ Object
readonly
A [DRbObject, DRbObject] => GraphicsItem mapping of arrows.
-
#current_color ⇒ Object
readonly
Returns the value of attribute current_color.
-
#enabled_relations ⇒ Object
readonly
Returns the value of attribute enabled_relations.
-
#execution_events ⇒ Object
readonly
The array of events for which a command has been called, or which have been emitted.
-
#flashing_objects ⇒ Object
readonly
A set of events that are shown during only two calls of #update.
-
#graphics ⇒ Object
readonly
A DRbObject => GraphicsItem mapping.
-
#hide_finalized ⇒ Object
True if the finalized tasks should not be displayed.
-
#keep_signals ⇒ Object
Returns the value of attribute keep_signals.
-
#postponed_events ⇒ Object
readonly
The set of postponed events that have occured since the last call to #update.
-
#propagated_events ⇒ Object
readonly
The set of signals since the last call to #update Each element is [flag, from, to, event_id].
-
#relation_brushes ⇒ Object
readonly
Returns the value of attribute relation_brushes.
-
#relation_colors ⇒ Object
readonly
Returns the value of attribute relation_colors.
-
#relation_pens ⇒ Object
readonly
Returns the value of attribute relation_pens.
-
#scene ⇒ Object
readonly
Returns the value of attribute scene.
-
#signal_arrows ⇒ Object
readonly
A pool of arrows items used to display the event signalling.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
-
#visible_objects ⇒ Object
readonly
The set of objects that are to be shown permanently.
Attributes included from DataDisplay
Instance Method Summary collapse
- #[](item) ⇒ Object
-
#add_flashing_object(object, &block) ⇒ Object
Add
objectto the list of objects temporarily displayed. - #add_internal_propagation(flag, generator, source_generators) ⇒ Object
-
#allocate_color ⇒ Object
returns the next color in COLORS, cycles if at the end of the array.
- #arrow(from, to, rel, info, base_layer) ⇒ Object
- #clear ⇒ Object
- #clear_arrows(object) ⇒ Object
- #clear_flashing_objects ⇒ Object
- #clear_integrated ⇒ Object
- #create_or_get_item(object) ⇒ Object
- #disable_relation(relation) ⇒ Object
- #discovered_tasks(time, plan, tasks) ⇒ Object
- #displayed?(object) ⇒ Boolean
- #enable_relation(relation) ⇒ Object
- #event_relation(form, to, rel, info) ⇒ Object
-
#find(regex = nil) ⇒ Object
Centers the view on the set of object found which matches
regex. - #generator_called(time, generator, context) ⇒ Object
- #generator_calling(*args) ⇒ Object
- #generator_emitting(*args) ⇒ Object
- #generator_fired(time, generator, event_id, event_time, event_context) ⇒ Object
- #generator_forwarding(time, flag, from, to, event_id, event_time, event_context) ⇒ Object
- #generator_postponed(time, generator, context, until_generator, reason) ⇒ Object
- #generator_signalling(time, flag, from, to, event_id, event_time, event_context) ⇒ Object
- #ignore_relation(relation) ⇒ Object
-
#initialize ⇒ RelationsDisplay
constructor
A new instance of RelationsDisplay.
- #layout_method ⇒ Object
- #layout_method=(new_method) ⇒ Object
- #layout_options ⇒ Object
- #layout_relation(relation) ⇒ Object
- #layout_relation?(relation) ⇒ Boolean
- #local_event(obj) ⇒ Object
- #local_object(obj) ⇒ Object
- #local_plan(obj) ⇒ Object
- #local_task(obj) ⇒ Object
- #object_of(item) ⇒ Object
- #propagation_style(arrow, flag) ⇒ Object
- #relation_color(relation) ⇒ Object
- #relation_enabled?(relation) ⇒ Boolean
- #remove_graphics(item, scene = nil) ⇒ Object
- #removed_event_child(time, parent, rel, child) ⇒ Object
- #removed_task_child(time, parent, rel, child) ⇒ Object
- #set_visibility(object, flag) ⇒ Object
- #stream=(data_stream) ⇒ Object
- #task_relation(from, to, rel, info) ⇒ Object
- #update ⇒ Object
- #update_relation_color(relation, color) ⇒ Object
Methods included from TaskDisplaySupport
#filter_prefixes, #update_prefixes_removal
Methods included from DataDisplay
Constructor Details
#initialize ⇒ RelationsDisplay
Returns a new instance of RelationsDisplay.
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/roby/log/relations.rb', line 459 def initialize @scene = Qt::GraphicsScene.new super() @main = Qt::MainWindow.new @ui = Ui::RelationsView.new @graphics = Hash.new @visible_objects = ValueSet.new @flashing_objects = Hash.new @arrows = Hash.new @enabled_relations = Set.new @layout_relations = Set.new @relation_colors = Hash.new @relation_pens = Hash.new(Qt::Pen.new(Qt::Color.new(ARROW_COLOR))) @relation_brushes = Hash.new(Qt::Brush.new(Qt::Color.new(ARROW_COLOR))) @current_color = 0 @propagated_events = [] @execution_events = [] @postponed_events = ValueSet.new @signal_arrows = [] @hide_finalized = true ui.setupUi(self) ui.graphics.scene = scene default_colors = { Roby::TaskStructure::Hierarchy => 'grey', Roby::TaskStructure::PlannedBy => '#32ba21', Roby::TaskStructure::ExecutionAgent => '#5d95cf', Roby::TaskStructure::ErrorHandling => '#ff2727' } default_colors.each do |rel, color| update_relation_color(rel, color) end @shortcuts = [] shortcut = Qt::Shortcut.new(Qt::KeySequence.new('f'), main) connect(shortcut, SIGNAL('activated()'), self, SLOT('find()')) @shortcuts << shortcut main.resize 500, 500 end |
Instance Attribute Details
#arrows ⇒ Object (readonly)
A [DRbObject, DRbObject] => GraphicsItem mapping of arrows
425 426 427 |
# File 'lib/roby/log/relations.rb', line 425 def arrows @arrows end |
#current_color ⇒ Object (readonly)
Returns the value of attribute current_color.
585 586 587 |
# File 'lib/roby/log/relations.rb', line 585 def current_color @current_color end |
#enabled_relations ⇒ Object (readonly)
Returns the value of attribute enabled_relations.
605 606 607 |
# File 'lib/roby/log/relations.rb', line 605 def enabled_relations @enabled_relations end |
#execution_events ⇒ Object (readonly)
The array of events for which a command has been called, or which have been emitted. The order in this array is the arrival order of the corresponding events.
An array element is [fired, event], when fired is true if the event has been fired, and false if it is pending
446 447 448 |
# File 'lib/roby/log/relations.rb', line 446 def execution_events @execution_events end |
#flashing_objects ⇒ Object (readonly)
A set of events that are shown during only two calls of #update
434 435 436 |
# File 'lib/roby/log/relations.rb', line 434 def flashing_objects @flashing_objects end |
#graphics ⇒ Object (readonly)
A DRbObject => GraphicsItem mapping
428 429 430 |
# File 'lib/roby/log/relations.rb', line 428 def graphics @graphics end |
#hide_finalized ⇒ Object
True if the finalized tasks should not be displayed
457 458 459 |
# File 'lib/roby/log/relations.rb', line 457 def hide_finalized @hide_finalized end |
#keep_signals ⇒ Object
Returns the value of attribute keep_signals.
582 583 584 |
# File 'lib/roby/log/relations.rb', line 582 def keep_signals @keep_signals end |
#postponed_events ⇒ Object (readonly)
The set of postponed events that have occured since the last call to #update. Each element is [postponed_generator, until_generator]
451 452 453 |
# File 'lib/roby/log/relations.rb', line 451 def postponed_events @postponed_events end |
#propagated_events ⇒ Object (readonly)
The set of signals since the last call to #update Each element is [flag, from, to, event_id]
438 439 440 |
# File 'lib/roby/log/relations.rb', line 438 def propagated_events @propagated_events end |
#relation_brushes ⇒ Object (readonly)
Returns the value of attribute relation_brushes.
627 628 629 |
# File 'lib/roby/log/relations.rb', line 627 def relation_brushes @relation_brushes end |
#relation_colors ⇒ Object (readonly)
Returns the value of attribute relation_colors.
625 626 627 |
# File 'lib/roby/log/relations.rb', line 625 def relation_colors @relation_colors end |
#relation_pens ⇒ Object (readonly)
Returns the value of attribute relation_pens.
626 627 628 |
# File 'lib/roby/log/relations.rb', line 626 def relation_pens @relation_pens end |
#scene ⇒ Object (readonly)
Returns the value of attribute scene.
422 423 424 |
# File 'lib/roby/log/relations.rb', line 422 def scene @scene end |
#signal_arrows ⇒ Object (readonly)
A pool of arrows items used to display the event signalling
454 455 456 |
# File 'lib/roby/log/relations.rb', line 454 def signal_arrows @signal_arrows end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
422 423 424 |
# File 'lib/roby/log/relations.rb', line 422 def ui @ui end |
#visible_objects ⇒ Object (readonly)
The set of objects that are to be shown permanently
431 432 433 |
# File 'lib/roby/log/relations.rb', line 431 def visible_objects @visible_objects end |
Instance Method Details
#[](item) ⇒ Object
524 |
# File 'lib/roby/log/relations.rb', line 524 def [](item); graphics[item] end |
#add_flashing_object(object, &block) ⇒ Object
Add object to the list of objects temporarily displayed. If a block is given, the object is removed when the block returns false. Otherwise, it is removed at the next display update
If this method is called more than once for the same object, the object is removed when all blocks have returned false at least once
716 717 718 719 720 721 722 723 724 725 |
# File 'lib/roby/log/relations.rb', line 716 def add_flashing_object(object, &block) if block flashing_objects[object] ||= [] flashing_objects[object] << block else flashing_objects[object] ||= nil end create_or_get_item(object) end |
#add_internal_propagation(flag, generator, source_generators) ⇒ Object
933 934 935 936 937 938 939 940 941 942 943 944 945 |
# File 'lib/roby/log/relations.rb', line 933 def add_internal_propagation(flag, generator, source_generators) generator = local_event(generator) if source_generators && !source_generators.empty? source_generators = source_generators.map { |source_generator| local_event(source_generator) } source_generators.delete_if do |ev| ev == generator || propagated_events.find { |_, from, to| to == generator && from.include?(ev) } end unless source_generators.empty? propagated_events << [flag, source_generators, generator] end end end |
#allocate_color ⇒ Object
returns the next color in COLORS, cycles if at the end of the array
587 588 589 590 |
# File 'lib/roby/log/relations.rb', line 587 def allocate_color @current_color = (current_color + 1) % COLORS.size COLORS[current_color] end |
#arrow(from, to, rel, info, base_layer) ⇒ Object
532 533 534 535 536 537 538 539 540 541 |
# File 'lib/roby/log/relations.rb', line 532 def arrow(from, to, rel, info, base_layer) id = [from, to, rel] unless item = arrows[id] item = (arrows[id] ||= scene.add_arrow(ARROW_SIZE)) item.z_value = base_layer - 1 item.pen = item.line.pen = relation_pens[rel] item.brush = relation_brushes[rel] end Log.arrow_set item, self[from], self[to] end |
#clear ⇒ Object
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 |
# File 'lib/roby/log/relations.rb', line 1020 def clear arrows.dup.each_value(&method(:remove_graphics)) graphics.dup.each_value(&method(:remove_graphics)) arrows.clear graphics.clear signal_arrows.each do |arrow| arrow.visible = false end visible_objects.clear flashing_objects.clear propagated_events.clear execution_events.clear postponed_events.clear scene.update(scene.scene_rect) end |
#clear_arrows(object) ⇒ Object
1011 1012 1013 1014 1015 1016 1017 1018 |
# File 'lib/roby/log/relations.rb', line 1011 def clear_arrows(object) arrows.delete_if do |(from, to, _), arrow| if from == object || to == object remove_graphics(arrow) true end end end |
#clear_flashing_objects ⇒ Object
726 727 728 729 730 731 732 733 734 735 736 737 738 |
# File 'lib/roby/log/relations.rb', line 726 def clear_flashing_objects (flashing_objects.keys.to_value_set - visible_objects).each do |object| if blocks = flashing_objects[object] blocks.delete_if { |block| !block.call } next unless blocks.empty? end if item = graphics[object] item.visible = false end flashing_objects.delete(object) end end |
#clear_integrated ⇒ Object
758 759 760 761 762 |
# File 'lib/roby/log/relations.rb', line 758 def clear_integrated postponed_events.clear execution_events.clear @execution_events = execution_events.find_all { |fired, ev| !fired } end |
#create_or_get_item(object) ⇒ Object
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/roby/log/relations.rb', line 692 def create_or_get_item(object) unless item = graphics[object] item = graphics[object] = object.display_create(self) if item item.parent_item = self[object.display_parent] if object.display_parent yield(item) if block_given? if !displayed?(object) item.visible = false end end end item.visible = displayed?(object) item end |
#disable_relation(relation) ⇒ Object
615 616 617 618 619 620 621 622 623 |
# File 'lib/roby/log/relations.rb', line 615 def disable_relation(relation) return unless relation_enabled?(relation) @enabled_relations.delete(relation) arrows.each do |(_, _, rel), arrow| if rel == relation arrow.visible = false end end end |
#discovered_tasks(time, plan, tasks) ⇒ Object
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'lib/roby/log/relations.rb', line 998 def discovered_tasks(time, plan, tasks) tasks.each do |obj| obj.flags[:pending] = true if obj.respond_to?(:flags) task = local_task(obj) set_visibility(task, true) task.events.each_value do |ev| if item = self[ev] item.visible = false end end end end |
#displayed?(object) ⇒ Boolean
674 675 676 677 |
# File 'lib/roby/log/relations.rb', line 674 def displayed?(object) visible_objects.include?(object) || flashing_objects.has_key?(object) end |
#enable_relation(relation) ⇒ Object
595 596 597 598 599 600 601 602 603 |
# File 'lib/roby/log/relations.rb', line 595 def enable_relation(relation) return if relation_enabled?(relation) @enabled_relations << relation arrows.each do |(_, _, rel), arrow| if rel == relation arrow.visible = true end end end |
#event_relation(form, to, rel, info) ⇒ Object
528 529 530 |
# File 'lib/roby/log/relations.rb', line 528 def event_relation(form, to, rel, info) arrow(from, to, rel, info, EVENT_LAYER) end |
#find(regex = nil) ⇒ Object
Centers the view on the set of object found which matches regex. If regex is nil, ask one to the user
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/roby/log/relations.rb', line 545 def find(regex = nil) unless regex regex = Qt::InputDialog.get_text main, 'Find objects in relation view', 'Object name' return unless regex && !regex.empty? end regex = /#{regex.to_str}/i if regex.respond_to?(:to_str) # Get the tasks and events matching the string objects = [] for p in decoder.plans objects.concat p.known_tasks. find_all { |object| displayed?(object) && regex === object.display_name(self) } objects.concat p.free_events. find_all { |object| displayed?(object) && regex === object.display_name(self) } end return if objects.empty? # Find the graphics items bb = objects.inject(Qt::RectF.new) do |bb, object| if item = self[object] item.selected = true bb | item.scene_bounding_rect | item.map_to_scene(item.children_bounding_rect).bounding_rect else bb end end bb.adjust -FIND_MARGIN, -FIND_MARGIN, FIND_MARGIN, FIND_MARGIN ui.graphics.fit_in_view bb, Qt::KeepAspectRatio scale = ui.graphics.matrix.m11 if scale > 1 ui.graphics.resetMatrix ui.graphics.scale 1, 1 end end |
#generator_called(time, generator, context) ⇒ Object
973 974 975 |
# File 'lib/roby/log/relations.rb', line 973 def generator_called(time, generator, context) execution_events << [EVENT_CALLED, local_event(generator)] end |
#generator_calling(*args) ⇒ Object
946 947 948 949 950 951 952 953 954 955 |
# File 'lib/roby/log/relations.rb', line 946 def generator_calling(*args) if args.size == 3 time, generator, context = *args source_generators = [] else time, generator, source_generators, context = *args end add_internal_propagation(PROPAG_CALLING, generator, source_generators) end |
#generator_emitting(*args) ⇒ Object
956 957 958 959 960 961 962 963 964 965 |
# File 'lib/roby/log/relations.rb', line 956 def generator_emitting(*args) if args.size == 3 time, generator, context = *args source_generators = [] else time, generator, source_generators, context = *args end add_internal_propagation(PROPAG_EMITTING, generator, source_generators) end |
#generator_fired(time, generator, event_id, event_time, event_context) ⇒ Object
976 977 978 979 980 981 982 983 984 985 986 |
# File 'lib/roby/log/relations.rb', line 976 def generator_fired(time, generator, event_id, event_time, event_context) generator = local_event(generator) found_pending = false execution_events.delete_if do |flags, ev| if flags == EVENT_CALLED && generator == ev found_pending = true end end execution_events << [(found_pending ? EVENT_CALLED_AND_EMITTED : EVENT_EMITTED), generator] end |
#generator_forwarding(time, flag, from, to, event_id, event_time, event_context) ⇒ Object
969 970 971 |
# File 'lib/roby/log/relations.rb', line 969 def generator_forwarding(time, flag, from, to, event_id, event_time, event_context) propagated_events << [PROPAG_FORWARD, [local_event(from)], local_event(to)] end |
#generator_postponed(time, generator, context, until_generator, reason) ⇒ Object
987 988 989 |
# File 'lib/roby/log/relations.rb', line 987 def generator_postponed(time, generator, context, until_generator, reason) postponed_events << [local_event(generator), local_event(until_generator)] end |
#generator_signalling(time, flag, from, to, event_id, event_time, event_context) ⇒ Object
966 967 968 |
# File 'lib/roby/log/relations.rb', line 966 def generator_signalling(time, flag, from, to, event_id, event_time, event_context) propagated_events << [PROPAG_SIGNAL, [local_event(from)], local_event(to)] end |
#ignore_relation(relation) ⇒ Object
610 611 612 613 |
# File 'lib/roby/log/relations.rb', line 610 def ignore_relation(relation) disable_relation(relation) @layout_relations.delete(relation) end |
#layout_method ⇒ Object
669 670 671 672 |
# File 'lib/roby/log/relations.rb', line 669 def layout_method return @layout_method if @layout_method "dot" end |
#layout_method=(new_method) ⇒ Object
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
# File 'lib/roby/log/relations.rb', line 647 def layout_method=(new_method) return if new_method == @layout_method @layout_method = nil = nil if new_method new_method =~ /^(\w+)(?: \[(.*)\])?$/ @layout_method = $1 if $2 = $2.split(",").inject(Hash.new) do |h, v| k, v = v.split("=") h[k] = v h end end end display end |
#layout_options ⇒ Object
665 666 667 668 |
# File 'lib/roby/log/relations.rb', line 665 def return if { :rankdir => 'TB' } end |
#layout_relation(relation) ⇒ Object
606 607 608 609 |
# File 'lib/roby/log/relations.rb', line 606 def layout_relation(relation) disable_relation(relation) @layout_relations << relation end |
#layout_relation?(relation) ⇒ Boolean
593 |
# File 'lib/roby/log/relations.rb', line 593 def layout_relation?(relation); relation_enabled?(relation) || @layout_relations.include?(relation) end |
#local_event(obj) ⇒ Object
929 |
# File 'lib/roby/log/relations.rb', line 929 def local_event(obj); decoder.local_event(obj) end |
#local_object(obj) ⇒ Object
931 |
# File 'lib/roby/log/relations.rb', line 931 def local_object(obj); decoder.local_object(obj) end |
#local_plan(obj) ⇒ Object
930 |
# File 'lib/roby/log/relations.rb', line 930 def local_plan(obj); decoder.local_plan(obj) end |
#local_task(obj) ⇒ Object
928 |
# File 'lib/roby/log/relations.rb', line 928 def local_task(obj); decoder.local_task(obj) end |
#object_of(item) ⇒ Object
503 504 505 506 507 508 509 510 511 |
# File 'lib/roby/log/relations.rb', line 503 def object_of(item) return if !(id = item.data(0).to_int).valid? id = id.to_int obj, _ = graphics.find do |obj, obj_item| obj.object_id == id end obj end |
#propagation_style(arrow, flag) ⇒ Object
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
# File 'lib/roby/log/relations.rb', line 740 def propagation_style(arrow, flag) unless defined? @@propagation_styles @@propagation_styles = Hash.new @@propagation_styles[PROPAG_FORWARD] = [Qt::Brush.new(Qt::Color.new('black')), (forward_pen = Qt::Pen.new)] forward_pen.style = Qt::DotLine @@propagation_styles[PROPAG_SIGNAL] = [Qt::Brush.new(Qt::Color.new('black')), Qt::Pen.new] @@propagation_styles[PROPAG_EMITTING] = [Qt::Brush.new(Qt::Color.new('blue')), (emitting_pen = Qt::Pen.new(Qt::Color.new('blue')))] emitting_pen.style = Qt::DotLine @@propagation_styles[PROPAG_CALLING] = [Qt::Brush.new(Qt::Color.new('blue')), Qt::Pen.new(Qt::Color.new('blue'))] end arrow.brush, pen = @@propagation_styles[flag] arrow.pen = arrow.line.pen = pen end |
#relation_color(relation) ⇒ Object
628 629 630 631 632 633 |
# File 'lib/roby/log/relations.rb', line 628 def relation_color(relation) if !relation_colors.has_key?(relation) update_relation_color(relation, allocate_color) end relation_colors[relation] end |
#relation_enabled?(relation) ⇒ Boolean
592 |
# File 'lib/roby/log/relations.rb', line 592 def relation_enabled?(relation); @enabled_relations.include?(relation) end |
#remove_graphics(item, scene = nil) ⇒ Object
922 923 924 925 926 |
# File 'lib/roby/log/relations.rb', line 922 def remove_graphics(item, scene = nil) return unless item scene ||= item.scene scene.remove_item(item) if scene end |
#removed_event_child(time, parent, rel, child) ⇒ Object
995 996 997 |
# File 'lib/roby/log/relations.rb', line 995 def removed_event_child(time, parent, rel, child) remove_graphics(arrows.delete([local_event(parent), local_event(child), rel])) end |
#removed_task_child(time, parent, rel, child) ⇒ Object
992 993 994 |
# File 'lib/roby/log/relations.rb', line 992 def removed_task_child(time, parent, rel, child) remove_graphics(arrows.delete([local_task(parent), local_task(child), rel])) end |
#set_visibility(object, flag) ⇒ Object
678 679 680 681 682 683 684 685 686 687 688 689 690 |
# File 'lib/roby/log/relations.rb', line 678 def set_visibility(object, flag) return if visible_objects.include?(object) == flag if item = graphics[object] item.visible = flag end if flag visible_objects << object else visible_objects.delete(object) end end |
#stream=(data_stream) ⇒ Object
513 514 515 516 517 518 519 520 521 522 |
# File 'lib/roby/log/relations.rb', line 513 def stream=(data_stream) super # Initialize the display ... decoder.plans.each do |plan| discovered_tasks(Time.now, plan, plan.known_tasks) discovered_events(Time.now, plan, plan.free_events) end display end |
#task_relation(from, to, rel, info) ⇒ Object
525 526 527 |
# File 'lib/roby/log/relations.rb', line 525 def task_relation(from, to, rel, info) arrow(from, to, rel, info, TASK_LAYER) end |
#update ⇒ Object
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
# File 'lib/roby/log/relations.rb', line 764 def update return unless decoder if keep_signals @execution_events = @last_execution_events.concat(execution_events) @propagated_events.concat @last_propagated_events end update_prefixes_removal clear_flashing_objects # The sets of tasks and events know to the data stream all_tasks = decoder.plans.inject(ValueSet.new) do |all_tasks, plan| all_tasks.merge plan.known_tasks all_tasks.merge plan.finalized_tasks end all_events = decoder.plans.inject(ValueSet.new) do |all_events, plan| all_events.merge plan.free_events all_events.merge plan.finalized_events end # Remove the items for objects that don't exist anymore (graphics.keys.to_value_set - all_tasks - all_events).each do |obj| visible_objects.delete(obj) remove_graphics(graphics.delete(obj)) clear_arrows(obj) end visible_objects.merge(decoder.plans) decoder.plans.each do |plan| if hide_finalized @visible_objects = visible_objects - plan.finalized_tasks @visible_objects = visible_objects - plan.finalized_events all_finalized = plan.finalized_tasks | plan.finalized_events flashing_objects.delete_if { |obj, _| all_finalized.include?(obj) } else visible_objects.merge(plan.finalized_tasks) visible_objects.merge(plan.finalized_events) end end # Create graphics items for tasks and events if necessary, and # update their visibility according to the visible_objects set [all_tasks, all_events, decoder.plans].each do |object_set| object_set.each do |object| if displayed?(object) create_or_get_item(object) elsif !object.display_parent if item = graphics[object] item.visible = false end end end end EventGeneratorDisplay.priorities.clear event_priority = 0 execution_events.each_with_index do |(flags, object), event_priority| EventGeneratorDisplay.priorities[object] = event_priority next if object.respond_to?(:task) && !displayed?(object.task) graphics = if flashing_objects.has_key?(object) self.graphics[object] else add_flashing_object(object) end graphics.brush, graphics.pen = EventGeneratorDisplay.style(object, flags) end propagated_events.each do |_, sources, to, _| sources.each do |from| if !EventGeneratorDisplay.priorities.has_key?(from) EventGeneratorDisplay.priorities[from] = (event_priority += 1) end if !EventGeneratorDisplay.priorities.has_key?(to) EventGeneratorDisplay.priorities[to] = (event_priority += 1) end if from.respond_to?(:task) next if !displayed?(from.task) else next if !all_events.include?(from) end if to.respond_to?(:task) next if !displayed?(to.task) else next if !all_events.include?(to) end add_flashing_object from add_flashing_object to end end [all_tasks, all_events, decoder.plans].each do |object_set| object_set.each do |object| next unless displayed?(object) object.display(self, graphics[object]) end end # Update arrow visibility arrows.each do |(from, to, rel), item| item.visible = (displayed?(from) && displayed?(to)) end # Layout the graph layouts = decoder.plans.find_all { |p| p.root_plan? }. map do |p| dot = Layout.new dot.layout(self, p) dot end layouts.each { |dot| dot.apply } # Display the signals signal_arrow_idx = -1 propagated_events.each_with_index do |(flag, sources, to), signal_arrow_idx| sources.each do |from| unless arrow = signal_arrows[signal_arrow_idx] arrow = signal_arrows[signal_arrow_idx] = scene.add_arrow(ARROW_SIZE) arrow.z_value = EVENT_LAYER + 1 arrow.line.z_value = EVENT_LAYER - 1 end # It is possible that the objects have been removed in the # same display cycle than they have been signalled. Do not # display them if it is the case unless displayed?(from) && displayed?(to) arrow.visible = false next end puts from if !self[from] puts to if !self[to] arrow.visible = true propagation_style(arrow, flag) Log.arrow_set(arrow, self[from], self[to]) end end # ... and hide the remaining arrows that are not used anymore if signal_arrow_idx + 1 < signal_arrows.size signal_arrows[(signal_arrow_idx + 1)..-1].each do |arrow| arrow.visible = false end end @last_propagated_events, @propagated_events = propagated_events, Array.new @last_execution_events, @execution_events = execution_events.partition { |fired, ev| fired } postponed_events.clear end |
#update_relation_color(relation, color) ⇒ Object
634 635 636 637 638 639 640 641 642 643 644 645 |
# File 'lib/roby/log/relations.rb', line 634 def update_relation_color(relation, color) relation_colors[relation] = color color = Qt::Color.new(color) pen = relation_pens[relation] = Qt::Pen.new(color) brush = relation_brushes[relation] = Qt::Brush.new(color) arrows.each do |(_, _, rel), arrow| if rel == relation arrow.pen = arrow.line.pen = pen arrow.brush = brush end end end |