Class: Roby::GUI::ChronicleWidget::TaskLayout
- Defined in:
- lib/roby/gui/chronicle_widget.rb
Instance Attribute Summary collapse
-
#add_point ⇒ Object
readonly
Returns the value of attribute add_point.
-
#base_height ⇒ Object
readonly
Returns the value of attribute base_height.
-
#base_time ⇒ Object
readonly
Returns the value of attribute base_time.
-
#end_point ⇒ Object
readonly
Returns the value of attribute end_point.
-
#event_height ⇒ Object
readonly
Returns the value of attribute event_height.
-
#event_max_x ⇒ Object
readonly
Returns the value of attribute event_max_x.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#finalization_point ⇒ Object
readonly
Returns the value of attribute finalization_point.
-
#fm ⇒ Object
readonly
Returns the value of attribute fm.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#start_point ⇒ Object
readonly
Returns the value of attribute start_point.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
-
#time_to_pixel ⇒ Object
readonly
Returns the value of attribute time_to_pixel.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #append_event(event, event_height) ⇒ Object
- #events_in_range(display_start_time, display_end_time) ⇒ Object
- #height(display_start_time, display_end_time) ⇒ Object
-
#initialize(task, base_time, time_to_pixel, fm) ⇒ TaskLayout
constructor
A new instance of TaskLayout.
- #update ⇒ Object
Constructor Details
#initialize(task, base_time, time_to_pixel, fm) ⇒ TaskLayout
Returns a new instance of TaskLayout.
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/roby/gui/chronicle_widget.rb', line 635 def initialize(task, base_time, time_to_pixel, fm) @task = task @base_time = base_time @time_to_pixel = time_to_pixel @fm = fm @event_height = [2 * EVENT_CIRCLE_RADIUS, fm.height].max @add_point = time_to_pixel * (task.addition_time - base_time) @start_point = nil @end_point = nil @finalization_point = nil @state = :pending @messages = [] @events = [] @event_max_x = [] @base_height = event_height update end |
Instance Attribute Details
#add_point ⇒ Object (readonly)
Returns the value of attribute add_point.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def add_point @add_point end |
#base_height ⇒ Object (readonly)
Returns the value of attribute base_height.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def base_height @base_height end |
#base_time ⇒ Object (readonly)
Returns the value of attribute base_time.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def base_time @base_time end |
#end_point ⇒ Object (readonly)
Returns the value of attribute end_point.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def end_point @end_point end |
#event_height ⇒ Object (readonly)
Returns the value of attribute event_height.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def event_height @event_height end |
#event_max_x ⇒ Object (readonly)
Returns the value of attribute event_max_x.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def event_max_x @event_max_x end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def events @events end |
#finalization_point ⇒ Object (readonly)
Returns the value of attribute finalization_point.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def finalization_point @finalization_point end |
#fm ⇒ Object (readonly)
Returns the value of attribute fm.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def fm @fm end |
#messages ⇒ Object
Returns the value of attribute messages.
633 634 635 |
# File 'lib/roby/gui/chronicle_widget.rb', line 633 def @messages end |
#start_point ⇒ Object (readonly)
Returns the value of attribute start_point.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def start_point @start_point end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def state @state end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def task @task end |
#time_to_pixel ⇒ Object (readonly)
Returns the value of attribute time_to_pixel.
632 633 634 |
# File 'lib/roby/gui/chronicle_widget.rb', line 632 def time_to_pixel @time_to_pixel end |
#title ⇒ Object
Returns the value of attribute title.
633 634 635 |
# File 'lib/roby/gui/chronicle_widget.rb', line 633 def title @title end |
Instance Method Details
#append_event(event, event_height) ⇒ Object
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
# File 'lib/roby/gui/chronicle_widget.rb', line 688 def append_event(event, event_height) event_x = Integer(time_to_pixel * (event.time - base_time)) event_current_level = nil event_max_x.each_with_index do |x, idx| if x < event_x - EVENT_CIRCLE_RADIUS event_current_level = idx break end end event_current_level ||= event_max_x.size event_y = event_current_level * event_height event_max_x[event_current_level] = event_x + 2 * EVENT_CIRCLE_RADIUS + fm.width(event.symbol.to_s) events << [event.time, event_x, event_y, event.symbol.to_s] end |
#events_in_range(display_start_time, display_end_time) ⇒ Object
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
# File 'lib/roby/gui/chronicle_widget.rb', line 704 def events_in_range(display_start_time, display_end_time) if !@time_first_event nil elsif @time_first_event > display_end_time nil elsif @time_last_event < display_start_time nil else result = [] events.each do |ev| time = ev.first if time > display_start_time if time < display_end_time result << ev else break end end end result unless result.empty? end end |
#height(display_start_time, display_end_time) ⇒ Object
727 728 729 730 731 732 733 |
# File 'lib/roby/gui/chronicle_widget.rb', line 727 def height(display_start_time, display_end_time) if events = events_in_range(display_start_time, display_end_time) max_event_y = events.max_by { |_, _, y, _| y } max_event_y = max_event_y[2] end (max_event_y || 0) + (.size + 1) * fm.height end |
#update ⇒ Object
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'lib/roby/gui/chronicle_widget.rb', line 655 def update return if @finalization_point history_size = events.size return if !task.finalization_time && task.history.size == history_size last_event = task.last_event if !last_event @state = :pending else @state = GUI.task_state_at(task, last_event.time) @time_last_event = last_event.time if state != :running end_time = last_event.time end end if start_time = task.start_time @time_first_event = start_time @start_point = time_to_pixel * (start_time - base_time) end if end_time @end_point = time_to_pixel * (end_time - base_time) end if finalization_time = task.finalization_time @finalization_point = time_to_pixel * (finalization_time - base_time) end task.history[history_size..-1].each do |event| append_event(event, event_height) end end |