box2ddistancejoint.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 BOX2DDISTANCEJOINT_H
  21. #define BOX2DDISTANCEJOINT_H
  22. #include "box2djoint.h"
  23. #include <Box2D.h>
  24. class b2World;
  25. class b2DistanceJoint;
  26. class b2DistanceJointDef;
  27. class Box2DDistanceJoint : public Box2DJoint
  28. {
  29. Q_OBJECT
  30. Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged)
  31. Q_PROPERTY(float frequencyHz READ frequencyHz WRITE setFrequencyHz NOTIFY frequencyHzChanged)
  32. Q_PROPERTY(float dampingRatio READ dampingRatio WRITE setDampingRatio NOTIFY dampingRatioChanged)
  33. Q_PROPERTY(QPointF localAnchorA READ localAnchorA WRITE setLocalAnchorA NOTIFY localAnchorAChanged)
  34. Q_PROPERTY(QPointF localAnchorB READ localAnchorB WRITE setLocalAnchorB NOTIFY localAnchorBChanged)
  35. public:
  36. explicit Box2DDistanceJoint(QDeclarativeItem *parent = 0);
  37. //~Box2DDistanceJoint();
  38. float length() const;
  39. void setLength(float length);
  40. float frequencyHz() const;
  41. void setFrequencyHz(float frequencyHz);
  42. float dampingRatio() const;
  43. void setDampingRatio(float dampingRatio);
  44. QPointF localAnchorA() const;
  45. void setLocalAnchorA(const QPointF &localAnchorA);
  46. QPointF localAnchorB() const;
  47. void setLocalAnchorB(const QPointF &localAnchorB);
  48. void createJoint();
  49. void cleanup(b2World *world);
  50. Q_INVOKABLE void release();
  51. Q_INVOKABLE void grab();
  52. signals:
  53. void lengthChanged();
  54. void frequencyHzChanged();
  55. void dampingRatioChanged();
  56. void localAnchorAChanged();
  57. void localAnchorBChanged();
  58. private:
  59. b2DistanceJointDef mDistanceJointDef;
  60. b2DistanceJoint *mDistanceJoint;
  61. bool mOverrideAnchorLength;
  62. float mLength;
  63. bool mOverrideLocalAnchorA;
  64. QPointF mLocalAnchorA;
  65. bool mOverrideLocalAnchorB;
  66. QPointF mLocalAnchorB;
  67. };
  68. #endif // BOX2DDISTANCEJOINT_H