File indexing completed on 2024-04-21 14:43:26
0001 /* 0002 * box2ddistancejoint.h 0003 * Copyright (c) 2011 Joonas Erkinheimo <joonas.erkinheimo@nokia.com> 0004 * 0005 * This file is part of the Box2D QML plugin. 0006 * 0007 * This software is provided 'as-is', without any express or implied warranty. 0008 * In no event will the authors be held liable for any damages arising from 0009 * the use of this software. 0010 * 0011 * Permission is granted to anyone to use this software for any purpose, 0012 * including commercial applications, and to alter it and redistribute it 0013 * freely, subject to the following restrictions: 0014 * 0015 * 1. The origin of this software must not be misrepresented; you must not 0016 * claim that you wrote the original software. If you use this software in 0017 * a product, an acknowledgment in the product documentation would be 0018 * appreciated but is not required. 0019 * 0020 * 2. Altered source versions must be plainly marked as such, and must not be 0021 * misrepresented as being the original software. 0022 * 0023 * 3. This notice may not be removed or altered from any source distribution. 0024 */ 0025 0026 #ifndef BOX2WELDJOINT_H 0027 #define BOX2WELDJOINT_H 0028 0029 #include "box2djoint.h" 0030 #include <Box2D.h> 0031 0032 class Box2DWeldJoint : public Box2DJoint 0033 { 0034 Q_OBJECT 0035 0036 Q_PROPERTY(float referenceAngle READ referenceAngle WRITE setReferenceAngle NOTIFY referenceAngleChanged) 0037 Q_PROPERTY(float frequencyHz READ frequencyHz WRITE setFrequencyHz NOTIFY frequencyHzChanged) 0038 Q_PROPERTY(float dampingRatio READ dampingRatio WRITE setDampingRatio NOTIFY dampingRatioChanged) 0039 Q_PROPERTY(QPointF localAnchorA READ localAnchorA WRITE setLocalAnchorA NOTIFY localAnchorAChanged) 0040 Q_PROPERTY(QPointF localAnchorB READ localAnchorB WRITE setLocalAnchorB NOTIFY localAnchorBChanged) 0041 0042 public: 0043 explicit Box2DWeldJoint(QObject *parent = 0); 0044 0045 float referenceAngle() const; 0046 void setReferenceAngle(float referenceAngle); 0047 0048 float frequencyHz() const; 0049 void setFrequencyHz(float frequencyHz); 0050 0051 float dampingRatio() const; 0052 void setDampingRatio(float dampingRatio); 0053 0054 QPointF localAnchorA() const; 0055 void setLocalAnchorA(const QPointF &localAnchorA); 0056 0057 QPointF localAnchorB() const; 0058 void setLocalAnchorB(const QPointF &localAnchorB); 0059 0060 b2WeldJoint *weldJoint() const; 0061 0062 signals: 0063 void referenceAngleChanged(); 0064 void frequencyHzChanged(); 0065 void dampingRatioChanged(); 0066 void localAnchorAChanged(); 0067 void localAnchorBChanged(); 0068 0069 protected: 0070 b2Joint *createJoint(); 0071 0072 private: 0073 QPointF m_localAnchorA; 0074 QPointF m_localAnchorB; 0075 float m_referenceAngle; 0076 float m_frequencyHz; 0077 float m_dampingRatio; 0078 0079 bool m_defaultLocalAnchorA; 0080 bool m_defaultLocalAnchorB; 0081 bool m_defaultReferenceAngle; 0082 }; 0083 0084 inline QPointF Box2DWeldJoint::localAnchorA() const 0085 { 0086 return m_localAnchorA; 0087 } 0088 0089 inline QPointF Box2DWeldJoint::localAnchorB() const 0090 { 0091 return m_localAnchorB; 0092 } 0093 0094 inline float Box2DWeldJoint::referenceAngle() const 0095 { 0096 return m_referenceAngle; 0097 } 0098 0099 inline float Box2DWeldJoint::frequencyHz() const 0100 { 0101 return m_frequencyHz; 0102 } 0103 0104 inline float Box2DWeldJoint::dampingRatio() const 0105 { 0106 return m_dampingRatio; 0107 } 0108 0109 inline b2WeldJoint *Box2DWeldJoint::weldJoint() const 0110 { 0111 return static_cast<b2WeldJoint*>(joint()); 0112 } 0113 0114 #endif // BOX2WELDJOINT_H