Module: Ui::RelationsView::GraphicsViewBehaviour

Defined in:
lib/roby/gui/relations_view.rb

Overview

Module used to extend the relation view GraphicsView object, to add double-click and context-menu events

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#displayObject

Returns the value of attribute display.



88
89
90
# File 'lib/roby/gui/relations_view.rb', line 88

def display
  @display
end

Instance Method Details

#contextMenuEvent(event) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/roby/gui/relations_view.rb', line 107

def contextMenuEvent(event)
    item = itemAt(event.pos)
    if item
        unless obj = display.object_of(item)
            return super(event)
        end
    end

    return unless obj.kind_of?(Roby::Task)

    menu = Qt::Menu.new
    hide_this     = menu.add_action("Hide")
    hide_children = menu.add_action("Hide children")
    show_children = menu.add_action("Show children")
    return unless action = menu.exec(event.globalPos)

    case action.text
    when "Hide"
        display.selected_objects.delete(obj)
    when "Hide children"
        obj.plan.compute_useful_tasks([obj]).each do |child|
            if child != obj
                display.selected_objects.delete(child)
            end
        end
    when "Show children"
        obj.plan.compute_useful_tasks([obj]).each do |child|
            if child != obj
                display.selected_objects << child
            end
        end
    end

    display.update
end

#mouseDoubleClickEvent(event) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/roby/gui/relations_view.rb', line 90

def mouseDoubleClickEvent(event)
    item = itemAt(event.pos)
    if item
        obj = display.object_of(item) ||
            display.relation_of(item)

        if !obj
            return super(event)
        end
    end

    @object_info ||= Roby::GUI::ObjectInfoView.new
    if @object_info.display(obj)
        @object_info.activate
    end
end