module Orocos::QtOrocos

Public Instance Methods

connect_to(obj=nil, options = Hash.new,&block) click to toggle source
# File lib/vizkit/qt_orocos.rb, line 53
def connect_to(obj=nil, options = Hash.new,&block)
    obj,options = if obj.is_a?(Hash)
                         [nil,obj]
                     else
                         [obj,options]
                     end
    raise ArgumentError,"cannot connect port #{full_name} to a string #{obj}" if obj.is_a? String
    raise ArgumentError,"cannot connect port #{full_name} to#{obj} and code block at the same time" if obj && block

    # connection is to another orocos port
    if obj.respond_to?(:to_orocos_port) || obj.respond_to?(:find_port)
        return org_connect_to obj,options,&block
    end
    widget,callback = if !obj
                          [nil,block]
                      elsif obj.respond_to?(:call)
                          if obj.respond_to?(:receiver)
                              [obj.receiver,obj]
                          else
                              [nil,obj]
                          end
                      else
                          [obj,nil]
                      end
    if widget.respond_to?(:connection_manager)
        widget.connection_manager.connect_to(self,callback,options,&block)
    else
        raise ArgumentError,"Cannot connect port #{full_name} to #{obj}. No connection manager found!" if obj.is_a?(Qt::Object)
        # use global connection manager
        Vizkit.connection_manager.connect_to(self,callback,options,&block)
    end
end