box2drevolutejoint.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Box2D QML plugin
  3. * Copyright (C) 2010 Nokia Corporation
  4. *
  5. * This file is part of the Box2D QML plugin.
  6. *
  7. * This library is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  14. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  15. * License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this library; If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef BOX2DREVOLUTEJOINT_H
  21. #define BOX2DREVOLUTEJOINT_H
  22. #include "box2djoint.h"
  23. #include <Box2D.h>
  24. class b2World;
  25. class b2RevoluteJoint;
  26. class b2RevoluteJointDef;
  27. class Box2DRevoluteJoint : public Box2DJoint
  28. {
  29. Q_OBJECT
  30. Q_PROPERTY(float lowerAngle READ lowerAngle WRITE setLowerAngle NOTIFY lowerAngleChanged)
  31. Q_PROPERTY(float upperAngle READ upperAngle WRITE setUpperAngle NOTIFY upperAngleChanged)
  32. Q_PROPERTY(float maxMotorTorque READ maxMotorTorque WRITE setMaxMotorTorque NOTIFY maxMotorTorqueChanged)
  33. Q_PROPERTY(float motorSpeed READ motorSpeed WRITE setMotorSpeed NOTIFY motorSpeedChanged)
  34. Q_PROPERTY(bool enableLimit READ enableLimit WRITE setEnableLimit NOTIFY enableLimitChanged)
  35. Q_PROPERTY(bool enableMotor READ enableMotor WRITE setEnableMotor NOTIFY enableMotorChanged)
  36. Q_PROPERTY(QPointF localAnchorA READ localAnchorA WRITE setLocalAnchorA NOTIFY localAnchorAChanged)
  37. public:
  38. explicit Box2DRevoluteJoint(QDeclarativeItem *parent = 0);
  39. //~Box2DRevoluteJoint();
  40. float lowerAngle() const;
  41. void setLowerAngle(float lowerAngle);
  42. float upperAngle() const;
  43. void setUpperAngle(float upperAngle);
  44. float maxMotorTorque() const;
  45. void setMaxMotorTorque(float maxMotorTorque);
  46. float motorSpeed() const;
  47. void setMotorSpeed(float motorSpeed);
  48. bool enableLimit() const;
  49. void setEnableLimit(bool enableLimit);
  50. bool enableMotor() const;
  51. void setEnableMotor(bool enableMotor);
  52. QPointF localAnchorA() const;
  53. void setLocalAnchorA(const QPointF &localAnchorA);
  54. void createJoint();
  55. void cleanup(b2World *world);
  56. Q_INVOKABLE void release();
  57. Q_INVOKABLE void grab();
  58. signals:
  59. void lowerAngleChanged();
  60. void upperAngleChanged();
  61. void maxMotorTorqueChanged();
  62. void motorSpeedChanged();
  63. void enableLimitChanged();
  64. void enableMotorChanged();
  65. void localAnchorAChanged();
  66. private:
  67. b2RevoluteJointDef mRevoluteJointDef;
  68. b2RevoluteJoint *mRevoluteJoint;
  69. bool mOverrideLocalAnchorA;
  70. QPointF mLocalAnchorA;
  71. };
  72. #endif // BOX2DREVOLUTEJOINT_H