Home · All Classes · Main Classes · Deprecated |
This class is an integrator which integrates an object/position in 1D or 2D space using Newtonian physics it is typically used by MPannableWidget. More...
Inherits QObject.
Public Types | |
enum | BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds } |
Signals | |
void | positionChanged (const QPointF &position) |
void | panningStopped () |
void | pointerPressed () |
void | pointerReleased () |
Public Member Functions | |
MPhysics2DPanning (QObject *parent) | |
virtual | ~MPhysics2DPanning () |
qreal | maximumVelocity () const |
void | setMaximumVelocity (qreal velocity) |
bool | enabled () const |
void | setEnabled (bool enabled) |
Qt::Orientations | panDirection () const |
void | setPanDirection (Qt::Orientations direction) |
QRectF | range () const |
void | setRange (const QRectF &range) |
qreal | pointerSpringK () const |
void | setPointerSpringK (qreal value) |
qreal | friction () const |
void | setFriction (qreal value) |
qreal | slidingFriction () const |
void | setSlidingFriction (qreal value) |
qreal | borderSpringK () const |
void | setBorderSpringK (qreal value) |
qreal | borderFriction () const |
void | setBorderFriction (qreal value) |
void | setPosition (const QPointF &position) |
QPointF | position () const |
bool | inMotion () const |
QPointF | velocity () const |
virtual void | pointerPress (const QPointF &pos) |
virtual void | pointerMove (const QPointF &pos) |
virtual void | pointerRelease () |
void | stop () |
BoundsBehavior | boundsBehavior () const |
void | setBoundsBehavior (BoundsBehavior newBoundsBehavior) |
Protected Member Functions | |
void | start () |
virtual void | integrateAxis (Qt::Orientation orientation, qreal &position, qreal &velocity, qreal &acceleration, qreal &pointerDifference, bool pointerPressed) |
Properties | |
bool | enabled |
Qt::Orientations | panDirection |
QRectF | range |
qreal | pointerSpringK |
qreal | friction |
qreal | slidingFriction |
qreal | borderSpringK |
qreal | borderFriction |
QPointF | position |
qreal | maximumVelocity |
BoundsBehavior | boundsBehavior |
This class is an integrator which integrates an object/position in 1D or 2D space using Newtonian physics it is typically used by MPannableWidget.
The user can change the behaviour of the kinetic panning that the pannable widget is providing to some other algorithm. In order to do that, a new class inheriting from MPhysics2DPanning should be created.
The main force in the physics is originating from the pointer via a spring. Additional forces come into play if the position goes outside the range (border springs are applied). There are various friction constants slowing down the movement
The kinetic action of the springs can be disabled with setEnabled() methods. In case the physics is disabled, the viewport will not keep panning after the pointer is released.
By default, the kinetic action of the springs is enabled.
The behavior when panning hits a range boundary
MPhysics2DPanning::MPhysics2DPanning | ( | QObject * | parent | ) |
Constructs an integrator.
MPhysics2DPanning::~MPhysics2DPanning | ( | ) | [virtual] |
Destructs an integrator.
qreal MPhysics2DPanning::borderFriction | ( | ) | const |
Returns the physics parameter: Friction when a pointer is up and position is in border.
qreal MPhysics2DPanning::borderSpringK | ( | ) | const |
Returns the physics parameter: K value for the border spring.
BoundsBehavior MPhysics2DPanning::boundsBehavior | ( | ) | const |
Returns the value of BoundsBehavior property.
bool MPhysics2DPanning::enabled | ( | ) | const |
Returns the enabled state of the physics engine.
qreal MPhysics2DPanning::friction | ( | ) | const |
Returns the physics parameter: friction when a pointer is down and position is not in the border.
bool MPhysics2DPanning::inMotion | ( | ) | const |
Returns the movement status of the integrated position.
void MPhysics2DPanning::integrateAxis | ( | Qt::Orientation | orientation, | |
qreal & | position, | |||
qreal & | velocity, | |||
qreal & | acceleration, | |||
qreal & | pointerDifference, | |||
bool | pointerPressed | |||
) | [protected, virtual] |
Single axis integration algorithm implementation.
This method will be called for each integration axis that is set by setPanDirection() method. orientation - currently integrated axis. position - position calculated in previous step of integration. velocity - velocity calculated in previous step of integration. acceleration - acceleration calculated in previous step of integration. pointerDifference - distance between current mouse position and previously received mouse position. pointerPressed - state of the pointer.
qreal MPhysics2DPanning::maximumVelocity | ( | ) | const |
Returns the maximum speed of this simulation.
Qt::Orientations MPhysics2DPanning::panDirection | ( | ) | const |
Returns the allowed direction of panning movement.
void MPhysics2DPanning::panningStopped | ( | ) | [signal] |
Signals that the panning movement has stopped.
void MPhysics2DPanning::pointerMove | ( | const QPointF & | pos | ) | [virtual] |
Tells physics that pointer has moved.
void MPhysics2DPanning::pointerPress | ( | const QPointF & | pos | ) | [virtual] |
Tells physics that pointer was pressed.
void MPhysics2DPanning::pointerPressed | ( | ) | [signal] |
Signals that the pointer has been pressed.
void MPhysics2DPanning::pointerRelease | ( | ) | [virtual] |
Tells physics that pointer was released.
void MPhysics2DPanning::pointerReleased | ( | ) | [signal] |
Signals that the pointer has been released.
qreal MPhysics2DPanning::pointerSpringK | ( | ) | const |
Returns the physics parameter: K value for the pointer spring.
QPointF MPhysics2DPanning::position | ( | ) | const |
Returns the current position of the physics.
void MPhysics2DPanning::positionChanged | ( | const QPointF & | position | ) | [signal] |
Signals a change in the position of the physics.
QRectF MPhysics2DPanning::range | ( | ) | const |
Returns the range of the physics.
void MPhysics2DPanning::setBorderFriction | ( | qreal | value | ) |
Sets a physics parameter: Friction when a pointer is up and position is in border.
void MPhysics2DPanning::setBorderSpringK | ( | qreal | value | ) |
Sets a physics parameter: K value for the border spring.
void MPhysics2DPanning::setBoundsBehavior | ( | MPhysics2DPanning::BoundsBehavior | newBoundsBehavior | ) |
Sets the value of BoundsBehavior property.
void MPhysics2DPanning::setEnabled | ( | bool | enabled | ) |
Sets the enabled/disabled state of the physics engine. If the physics is disabled, the integration algorithm is not started when the user moves the pointer on the screen.
When disabled, the viewport will still be scrollable but it will not keep panning after the pointer is released.
By default, the physics engine is enabled.
void MPhysics2DPanning::setFriction | ( | qreal | value | ) |
Sets a physics parameter: Friction when a pointer is down and position is not in the border.
void MPhysics2DPanning::setMaximumVelocity | ( | qreal | velocity | ) |
Sets the maximum speed.
speed | The maximum speed this simulation can reach. |
void MPhysics2DPanning::setPanDirection | ( | Qt::Orientations | direction | ) |
Sets the allowed orientations of panning movement.
void MPhysics2DPanning::setPointerSpringK | ( | qreal | value | ) |
Sets a physics parameter: K value for the pointer spring.
void MPhysics2DPanning::setPosition | ( | const QPointF & | position | ) |
Sets the position of the physics.
If the new position is in the border, the border springs are activated.
void MPhysics2DPanning::setRange | ( | const QRectF & | range | ) |
Sets the range of the physics.
If the range is shrank so that the current position goes to border, the border springs are activated.
void MPhysics2DPanning::setSlidingFriction | ( | qreal | value | ) |
Sets a physics parameter: Friction when a pointer is up and position is not in border.
qreal MPhysics2DPanning::slidingFriction | ( | ) | const |
Returns the physics parameter: friction when a pointer is up and position is not in the border.
void MPhysics2DPanning::start | ( | ) | [protected] |
Starts the physics algorithm. The engine will now call the integrator() method periodically.
void MPhysics2DPanning::stop | ( | ) |
Stops the integration algorithm. The algorithm will be restarted when pointer will be pressed again.
QPointF MPhysics2DPanning::velocity | ( | ) | const |
Returns the current velocity of the physics.
qreal MPhysics2DPanning::borderFriction [read, write] |
Current border friction constant value.
qreal MPhysics2DPanning::borderSpringK [read, write] |
Current border spring K constant value.
MPhysics2DPanning::boundsBehavior [read, write] |
This property holds whether the position may be dragged beyond the range's boundaries, or overshoot the range's boundaries when flicked.
This enables the feeling that the edges of the view are soft, rather than a hard physical boundary.
Its default value is DragAndOvershootBounds.
bool MPhysics2DPanning::enabled [read, write] |
Current enabled/disabled state.
qreal MPhysics2DPanning::friction [read, write] |
Current friction constant value.
qreal MPhysics2DPanning::maximumVelocity [read, write] |
Current maximum speed value.
Qt::Orientations MPhysics2DPanning::panDirection [read, write] |
Current panning orientations.
qreal MPhysics2DPanning::pointerSpringK [read, write] |
Current pointer spring K constant value.
QPointF MPhysics2DPanning::position [read, write] |
Current position value.
QRectF MPhysics2DPanning::range [read, write] |
Current panning range.
qreal MPhysics2DPanning::slidingFriction [read, write] |
Current sliding friction constant value.
Copyright © 2010 Nokia Corporation | MeeGo Touch |