class Robot

Public Class Methods

new(view) click to toggle source
Calls superclass method RobotPart.new
# File examples/graphicsview/dragdroprobot/robot.rb, line 137
def initialize(view)
    super(nil)
    torsoItem = RobotTorso.new(self)
    headItem = RobotHead.new(torsoItem)
    upperLeftArmItem = RobotLimb.new(torsoItem)
    lowerLeftArmItem = RobotLimb.new(upperLeftArmItem)
    upperRightArmItem = RobotLimb.new(torsoItem)
    lowerRightArmItem = RobotLimb.new(upperRightArmItem)
    upperRightLegItem = RobotLimb.new(torsoItem)
    lowerRightLegItem = RobotLimb.new(upperRightLegItem)
    upperLeftLegItem = RobotLimb.new(torsoItem)
    lowerLeftLegItem = RobotLimb.new(upperLeftLegItem)
    
    headItem.setPos(0, -18)
    upperLeftArmItem.setPos(-15, -10)
    lowerLeftArmItem.setPos(30, 0)
    upperRightArmItem.setPos(15, -10)
    lowerRightArmItem.setPos(30, 0)
    upperRightLegItem.setPos(10, 32)
    lowerRightLegItem.setPos(30, 0)
    upperLeftLegItem.setPos(-10, 32)
    lowerLeftLegItem.setPos(30, 0)

    @timeLine = Qt::TimeLine.new

    headAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = headItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 20)
        a.setRotationAt(1, -20)
        a.setScaleAt(1, 1.1, 1.1)
    end

    upperLeftArmAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = upperLeftArmItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 190)
        a.setRotationAt(1, 180)
    end

    lowerLeftArmAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = lowerLeftArmItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 50)
        a.setRotationAt(1, 10)
    end
    
    upperRightArmAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = upperRightArmItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 300)
        a.setRotationAt(1, 310)
    end

    lowerRightArmAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = lowerRightArmItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 0)
        a.setRotationAt(1, -70)
    end

    upperLeftLegAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = upperLeftLegItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 150)
        a.setRotationAt(1, 80)
    end

    lowerLeftLegAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = lowerLeftLegItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 70)
        a.setRotationAt(1, 10)
    end

    upperRightLegAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = upperRightLegItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 40)
        a.setRotationAt(1, 120)
    end
    
    lowerRightLegAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = lowerRightLegItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 10)
        a.setRotationAt(1, 50)
    end
    
    torsoAnimation = Qt::GraphicsItemAnimation.new(view) do |a|
        a.item = torsoItem
        a.timeLine = @timeLine
        a.setRotationAt(0, 5)
        a.setRotationAt(1, -20)
    end

    @timeLine.updateInterval = 1000 / 25
    @timeLine.curveShape = Qt::TimeLine::SineCurve
    @timeLine.loopCount = 0
    @timeLine.duration = 2000
    @timeLine.start
end

Public Instance Methods

boundingRect() click to toggle source
# File examples/graphicsview/dragdroprobot/robot.rb, line 240
def boundingRect
    return Qt::RectF.new()
end
paint(painter, option, widget) click to toggle source
# File examples/graphicsview/dragdroprobot/robot.rb, line 244
def paint(painter, option, widget)
end