Class: Robot
- Defined in:
- ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb
Instance Method Summary collapse
- #boundingRect ⇒ Object
-
#initialize(view) ⇒ Robot
constructor
A new instance of Robot.
- #paint(painter, option, widget) ⇒ Object
Methods inherited from RobotPart
#dragEnterEvent, #dragLeaveEvent, #dropEvent
Methods inherited from Qt::GraphicsItem
Methods inherited from Qt::Base
#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~
Constructor Details
#initialize(view) ⇒ Robot
Returns a new instance of Robot.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'ext/ruby/qtruby/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 |
Instance Method Details
#boundingRect ⇒ Object
240 241 242 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 240 def boundingRect return Qt::RectF.new() end |
#paint(painter, option, widget) ⇒ Object
244 245 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 244 def paint(painter, option, ) end |