summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@nokia.com>2011-10-26 15:13:09 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-26 07:49:19 +0200
commitbf9752bd9102631e1c7462fcf7acfc895e3dae4d (patch)
tree6e2c677419566e508b6e0e0b515e03e80cc1eab7 /src
parentbef5f51913200af264116a3f772effc717829d23 (diff)
downloadqtlocation-bf9752bd9102631e1c7462fcf7acfc895e3dae4d.tar.gz
QML Map pinch and flick part 2/3
Bunch of autotests, fixes, API changes and preliminary docs. Change-Id: If540adbc3068fc7bee401bfacb791cb685ad1298 Reviewed-by: David Laing <david.laing@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/location.cpp2
-rw-r--r--src/imports/location/location.pro2
-rw-r--r--src/imports/location/qdeclarative3dgraphicsgeomap.cpp69
-rw-r--r--src/imports/location/qdeclarative3dgraphicsgeomap_p.h10
-rw-r--r--src/imports/location/qdeclarativegeomappincharea.cpp248
-rw-r--r--src/imports/location/qdeclarativegeomappincharea_p.h84
6 files changed, 262 insertions, 153 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index a1d0fa57..e06f342d 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -124,7 +124,7 @@ public:
qmlRegisterType<QDeclarativeGeoManeuver>(uri, 5, 0, "RouteManeuver");
qmlRegisterUncreatableType<QDeclarativeGeoMapFlickable>(uri, 5, 0, "MapFlickable", QDeclarativeGeoMapFlickable::tr("(Map)Flickable is not intended instantiable by developer."));
qmlRegisterUncreatableType<QDeclarativeGeoMapPinchArea>(uri, 5, 0, "MapPinch", QDeclarativeGeoMapPinchArea::tr("(Map)PinchArea is not intended instantiable by developer."));
- qmlRegisterUncreatableType<QDeclarativeGeoMapPinchEvent>(uri, 5, 0, "", QDeclarativeGeoMapPinchEvent::tr("(Map)PinchEvent is not intended instantiable by developer."));
+ qmlRegisterUncreatableType<QDeclarativeGeoMapPinchEvent>(uri, 5, 0, "MapPinchEvent", QDeclarativeGeoMapPinchEvent::tr("(Map)PinchEvent is not intended instantiable by developer."));
qmlRegisterType<QDeclarativeCategory>(uri, 5, 0, "Category");
qmlRegisterType<QDeclarativePlaceEditorialModel>(uri, 5, 0, "EditorialModel");
diff --git a/src/imports/location/location.pro b/src/imports/location/location.pro
index 3abb186b..33f7ca08 100644
--- a/src/imports/location/location.pro
+++ b/src/imports/location/location.pro
@@ -76,8 +76,8 @@ INSTALLS += target qmldir
# manually enable mouse area and map items (shader effect source) if you know symbols to be
# present in your environment
+
#message('Will try to build QML Map 3D with QML2 user interaction elements and Map Items.')
#DEFINES += QQUICKMOUSEAREA_AVAILABLE
#DEFINES += QQUICKSHADEREFFECTSOURCE_AVAILABLE
message('QML2 3D Map user interaction elements and MapItems not available. Check location.pro - file for instructions.')
-
diff --git a/src/imports/location/qdeclarative3dgraphicsgeomap.cpp b/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
index 87c3bb82..82327b19 100644
--- a/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
+++ b/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
@@ -108,6 +108,8 @@ QDeclarative3DGraphicsGeoMap::QDeclarative3DGraphicsGeoMap(QQuickItem *parent)
plugin_(0),
serviceProvider_(0),
mappingManager_(0),
+ zoomLevel_(8.0),
+ bearing_(0.0),
center_(0),
// mapType_(NoMap),
// connectivityMode_(NoConnectivity),
@@ -121,7 +123,6 @@ QDeclarative3DGraphicsGeoMap::QDeclarative3DGraphicsGeoMap(QQuickItem *parent)
tileCache_(0)
{
QLOC_TRACE0;
- zoomLevel_ = 8;
size_ = QSizeF(100.0, 100.0);
setAcceptHoverEvents(false);
setAcceptedMouseButtons(Qt::LeftButton | Qt::MidButton | Qt::RightButton);
@@ -560,6 +561,7 @@ void QDeclarative3DGraphicsGeoMap::mappingManagerInitialized()
CameraData cameraData = map_->cameraData();
cameraData.setCenter(center_->coordinate());
cameraData.setZoomFactor(zoomLevel_);
+ cameraData.setBearing(bearing_);
map_->setCameraData(cameraData);
map_->update();
}
@@ -637,6 +639,55 @@ QSizeF QDeclarative3DGraphicsGeoMap::size() const
return size_;
}
+void QDeclarative3DGraphicsGeoMap::setBearing(qreal bearing)
+{
+ if (bearing_ == bearing)
+ return;
+ bool clockwise = (bearing >= 0);
+ qreal fractions = bearing - int(bearing);
+ bearing = (int(qAbs(bearing))) % 359;
+ if (!clockwise)
+ bearing = (-1.0 * bearing) + 360;
+ bearing_ = bearing + fractions;
+ if (mappingManagerInitialized_) {
+ CameraData cameraData = map_->cameraData();
+ cameraData.setBearing(bearing_);
+ map_->setCameraData(cameraData);
+ }
+ emit bearingChanged(bearing_);
+}
+
+/*!
+ \qmlproperty qreal Map::bearing
+
+ This property holds the current bearing (starting from 0 and increasing
+ clockwise to 359,9 degrees) pointing up.
+
+ For example setting bearing to 10 will set bearing 10 to point up, which
+ visually looks like rotating the map counter-clockwise.
+
+ You can also assign negative values, which will internally get
+ translated into positive bearing (e.g. -10 equals 350). This is primarily for
+ convenience (e.g. you can decrement bearing without worrying about it).
+ Assigning values greater than abs(360) will be mod'd (e.g. 365 will result
+ in 5).
+
+ The default value is 0 corresponding North pointing up.
+*/
+
+qreal QDeclarative3DGraphicsGeoMap::bearing() const
+{
+ if (mappingManagerInitialized_) {
+ if (map_->cameraData().bearing() >= 0)
+ return map_->cameraData().bearing();
+ else
+ return map_->cameraData().bearing() + 360;
+ } else {
+ return bearing_;
+ }
+}
+
+
/*!
\qmlproperty qreal Map::zoomLevel
@@ -650,11 +701,7 @@ void QDeclarative3DGraphicsGeoMap::setZoomLevel(qreal zoomLevel)
{
if (zoomLevel_ == zoomLevel)
return;
- if (!componentCompleted_) {
- zoomLevel_ = zoomLevel;
- return;
- }
- if (mappingManager_ &&
+ if (mappingManagerInitialized_ &&
(zoomLevel < mappingManager_->minimumZoomLevel() ||
zoomLevel > mappingManager_->maximumZoomLevel())) {
return;
@@ -662,12 +709,10 @@ void QDeclarative3DGraphicsGeoMap::setZoomLevel(qreal zoomLevel)
zoomLevel_ = zoomLevel;
if (mappingManagerInitialized_) {
CameraData cameraData = map_->cameraData();
- cameraData.setZoomFactor(zoomLevel);
+ cameraData.setZoomFactor(zoomLevel_);
map_->setCameraData(cameraData);
- if (!map_->autoUpdate())
- map_->update();
}
- emit zoomLevelChanged(zoomLevel_);
+ emit zoomLevelChanged(zoomLevel);
}
qreal QDeclarative3DGraphicsGeoMap::zoomLevel() const
@@ -753,6 +798,10 @@ void QDeclarative3DGraphicsGeoMap::cameraDataChanged(const CameraData &cameraDat
zoomLevel_ = cameraData.zoomFactor();
emit zoomLevelChanged(zoomLevel_);
}
+ if (cameraData.bearing() != bearing_) {
+ bearing_ = cameraData.bearing();
+ emit bearingChanged(bearing_);
+ }
}
void QDeclarative3DGraphicsGeoMap::centerLatitudeChanged(double latitude)
diff --git a/src/imports/location/qdeclarative3dgraphicsgeomap_p.h b/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
index a810c23b..d6999cb9 100644
--- a/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
+++ b/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
@@ -102,6 +102,7 @@ class QDeclarative3DGraphicsGeoMap : public QQuickPaintedItem
Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel CONSTANT)
Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel CONSTANT)
Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
+ Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
// Q_PROPERTY(MapType mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
Q_PROPERTY(QDeclarativeCoordinate* center READ center WRITE setCenter NOTIFY centerChanged)
// Q_PROPERTY(ConnectivityMode connectivityMode READ connectivityMode WRITE setConnectivityMode NOTIFY connectivityModeChanged)
@@ -152,6 +153,9 @@ public:
void setZoomLevel(qreal zoomLevel);
qreal zoomLevel() const;
+ void setBearing(qreal bearing);
+ qreal bearing() const;
+
void setCenter(QDeclarativeCoordinate *center);
QDeclarativeCoordinate* center();
@@ -195,10 +199,6 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
- // hover is just a placeholder
- //void hoverEnterEvent(QHoverEvent *event);
- //void hoverMoveEvent(QHoverEvent *event);
- //void hoverLeaveEvent(QHoverEvent *event);
void keyPressEvent(QKeyEvent *e);
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
@@ -207,6 +207,7 @@ Q_SIGNALS:
void pluginChanged(QDeclarativeGeoServiceProvider *plugin);
void sizeChanged(const QSizeF &size);
void zoomLevelChanged(qreal zoomLevel);
+ void bearingChanged(qreal bearing);
void centerChanged(const QDeclarativeCoordinate *coordinate);
// void mapTypeChanged(QDeclarative3DGraphicsGeoMap::MapType mapType);
// void connectivityModeChanged(QDeclarative3DGraphicsGeoMap::ConnectivityMode connectivityMode);
@@ -251,6 +252,7 @@ private:
QGeoMappingManager* mappingManager_;
qreal zoomLevel_;
+ qreal bearing_;
QPointer<QDeclarativeCoordinate> center_;
// QDeclarative3DGraphicsGeoMap::MapType mapType_;
diff --git a/src/imports/location/qdeclarativegeomappincharea.cpp b/src/imports/location/qdeclarativegeomappincharea.cpp
index 4731d884..21cbfbd0 100644
--- a/src/imports/location/qdeclarativegeomappincharea.cpp
+++ b/src/imports/location/qdeclarativegeomappincharea.cpp
@@ -44,12 +44,138 @@
#include "qdeclarative3dgraphicsgeomap_p.h"
#include <QtGui/qevent.h>
#include <QtGui/QStyleHints>
+#include <QtDeclarative/qdeclarativeinfo.h>
#include <QDebug>
#include "math.h"
#include "map.h"
QT_BEGIN_NAMESPACE
+/*!
+ \qmlclass MapPinchEvent
+
+ \brief MapPinchEvent element provides basic information about pinch event.
+
+ MapPinchEvent element provides basic information about pinch event. They are
+ present in handlers of MapPinch (e.g. pinchStarted/pinchUpdated). Events are only
+ guaranteed to be valid for the duration of the handler.
+
+ Except for the \l accepted property, all properties are read-only.
+
+ \ingroup qml-location-maps
+ \since 5.0
+
+*/
+
+/*!
+ \qmlproperty QPoint MapPinchEvent::center
+
+ This read-only property holds the current center point.
+
+*/
+
+/*!
+ \qmlproperty real MapPinchEvent::angle
+
+ This read-only property holds the current angle between the two points in
+ the range -180 to 180. Positive values for the angles mean counter-clockwise
+ while negative values mean the clockwise direction. Zero degrees is at the
+ 3 o'clock position.
+
+*/
+
+/*!
+ \qmlproperty QPoint MapPinchEvent::point1
+ \qmlproperty QPoint MapPinchEvent::point2
+
+ These read-only properties hold the actual touch points generating the pinch.
+ The points are not in any particular order.
+
+*/
+
+/*!
+ \qmlproperty int MapPinchEvent::pointCount
+
+ This read-only property holds the number of points currently touched.
+ The MapPinch will not react until two touch points have initited a gesture,
+ but will remain active until all touch points have been released.
+
+*/
+
+/*!
+ \qmlproperty bool MapPinchEvent::accepted
+
+ Setting this property to false in the \c MapPinch::onPinchStarted handler
+ will result in no further pinch events being generated, and the gesture
+ ignored.
+
+*/
+
+/*!
+ \qmlclass MapPinch
+
+ \brief The MapPinch element provides basic Map pinch interaction.
+
+ It provides basic Map pinch interaction. It caters for out-of-the-box interaction
+ (e.g. zoom and rotation), as well as provides means for more customized behavior.
+ It is a non-user-instantiable member of \l Map element.
+
+ \ingroup qml-location-maps
+ \since 5.0
+
+*/
+
+/*!
+ \qmlproperty bool MapPinch::enabled
+
+ This property holds whether the pinch gestures are enabled.
+ Note: disabling pinch during active pinch does not have effect on
+ the potentially active current pinch.
+
+ */
+
+/*!
+ \qmlproperty bool MapPinch::active
+
+ This read-only property holds whether a pinch gesture is active.
+
+ */
+
+/*!
+ \qmlproperty enumeration MapPinch::activeGestures
+
+ This property holds the gestures that the pinch should control.
+ For the time being, only ZoomGesture is supported.
+
+ For the extremist, one may OR flag the RotationGesture or TiltGesture
+ but these come with absolutely no warranty or guarantees at the moment
+ (may be removed, changed, moved around)
+
+ */
+
+/*!
+ \qmlproperty real MapPinch::maximumZoomLevelChange
+
+ This property holds the maximum zoom level change per pinch, essentially
+ meant to be used for setting the zoom sensitivity.
+
+ It is an indicative measure calculated from the dimensions of the
+ map area, roughly corresponding how much zoom level could change with
+ maximum pinch zoom. Default value is 2.0, maximum value is 10.0
+
+ */
+
+/* todo uncomment this when rotation is supported
+ \qmlproperty real MapPinch::rotationFactor
+
+ This property holds the rotation factor for zoom, essentially meant to be used for setting
+ the rotation sensitivity.
+
+ It is an indicative measure; the default value 1.0 means the map roughly follows the fingers,
+ whereas 2.0 means rotating twice as fast. Maximum value is 5.0.
+
+ */
+
QDeclarativeGeoMapPinchArea::QDeclarativeGeoMapPinchArea(QDeclarative3DGraphicsGeoMap* map, QObject *parent)
: QObject(parent),
map_(map),
@@ -58,7 +184,7 @@ QDeclarativeGeoMapPinchArea::QDeclarativeGeoMapPinchArea(QDeclarative3DGraphicsG
minimumZoomLevel_(-1.0),
maximumZoomLevel_(-1.0),
minimumRotation_(0.0),
- maximumRotation_(45.0),
+ maximumRotation_(0.0),
inPinch_(false),
pinchRejected_(false),
pinchActivated_(false),
@@ -66,12 +192,11 @@ QDeclarativeGeoMapPinchArea::QDeclarativeGeoMapPinchArea(QDeclarative3DGraphicsG
pinchStartZoomLevel_(0.0),
pinchLastZoomLevel_(0.0),
pinchStartRotation_(0.0),
- pinchStartAngle_(0.0),
pinchLastAngle_(0.0),
pinchRotation_(0.0),
id1_(-1),
maximumZoomLevelChange_(2.0),
- rotationSpeed_(1.0),
+ rotationFactor_(1.0),
activeGestures_(ZoomGesture | RotationGesture),
minimumTilt_(0.0),
maximumTilt_(90.0),
@@ -79,8 +204,6 @@ QDeclarativeGeoMapPinchArea::QDeclarativeGeoMapPinchArea(QDeclarative3DGraphicsG
pinchLastTilt_(0.0),
pinchStartTilt_(0.0)
{
- // this can be set as 'target' property should the need be to distinguish this element into MapPinchArea:
- Q_ASSERT(map_);
}
QDeclarativeGeoMapPinchArea::~QDeclarativeGeoMapPinchArea()
@@ -96,6 +219,10 @@ void QDeclarativeGeoMapPinchArea::setActiveGestures(ActiveGestures activeGesture
{
if (activeGestures == activeGestures_)
return;
+ if (activeGestures_ & RotationGesture)
+ qmlInfo(this) << tr("Pinchrotation gesture activated. Note that it is experimental feature.");
+ if (activeGestures_ & TiltGesture)
+ qmlInfo(this) << tr("Pinchtilt gesture activated. Note that it is experimental feature.");
activeGestures_ = activeGestures;
emit activeGesturesChanged();
}
@@ -210,19 +337,19 @@ void QDeclarativeGeoMapPinchArea::setMaximumRotation(qreal rotation)
emit maximumRotationChanged();
}
-qreal QDeclarativeGeoMapPinchArea::rotationSpeed() const
+qreal QDeclarativeGeoMapPinchArea::rotationFactor() const
{
- return rotationSpeed_;
+ return rotationFactor_;
}
-void QDeclarativeGeoMapPinchArea::setRotationSpeed(qreal speed)
+void QDeclarativeGeoMapPinchArea::setRotationFactor(qreal factor)
{
- if (rotationSpeed_ == speed ||
- speed < 0 ||
- speed > 10)
+ if (rotationFactor_ == factor ||
+ factor < 0 ||
+ factor > 5)
return;
- rotationSpeed_ = speed;
- emit rotationSpeedChanged();
+ rotationFactor_ = factor;
+ emit rotationFactorChanged();
}
qreal QDeclarativeGeoMapPinchArea::maximumTilt() const
@@ -297,16 +424,13 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
if (inPinch_) {
inPinch_ = false;
QPointF pinchCenter = map_->mapFromScene(sceneLastCenter_);
- QDeclarativeGeoMapPinchEvent pe(pinchCenter, pinchLastZoomLevel_, pinchLastAngle_, pinchRotation_);
- pe.setStartCenter(pinchStartCenter_);
- pe.setPreviousCenter(pinchCenter);
- pe.setPreviousAngle(pinchLastAngle_);
- pe.setPreviousZoomLevel(pinchLastZoomLevel_);
- pe.setStartPoint1(map_->mapFromScene(sceneStartPoint1_));
- pe.setStartPoint2(map_->mapFromScene(sceneStartPoint2_));
- pe.setPoint1(map_->mapFromScene(lastPoint1_));
- pe.setPoint2(map_->mapFromScene(lastPoint2_));
- emit pinchFinished(&pe);
+ pinchEvent_.setCenter(pinchCenter);
+ pinchEvent_.setAngle(pinchLastAngle_);
+ pinchEvent_.setPoint1(map_->mapFromScene(lastPoint1_));
+ pinchEvent_.setPoint2(map_->mapFromScene(lastPoint2_));
+ pinchEvent_.setAccepted(true);
+ pinchEvent_.setPointCount(0);
+ emit pinchFinished(&pinchEvent_);
pinchStartDist_ = 0;
pinchActivated_ = false;
setActive(false);
@@ -332,9 +456,8 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
qreal dist = sqrt(dx*dx + dy*dy);
QPointF sceneCenter = (p1 + p2)/2;
qreal angle = QLineF(p1, p2).angle();
- //qDebug() << "angle between point1, point2, s: " << p1 << p2 << angle;
if (touchPoints_.count() == 1) {
- // If we only have one point then just move the center. TODO do we need this anymore.
+ // If we only have one point then just move the center
if (id1_ == touchPoint1.id())
sceneCenter = sceneLastCenter_ + touchPoint1.scenePos() - lastPoint1_;
else
@@ -350,11 +473,8 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
|| qAbs(p1.y()-sceneStartPoint1_.y()) > dragThreshold
|| qAbs(p2.x()-sceneStartPoint2_.x()) > dragThreshold
|| qAbs(p2.y()-sceneStartPoint2_.y()) > dragThreshold)) {
- sceneStartCenter_ = sceneCenter;
sceneLastCenter_ = sceneCenter;
- pinchStartCenter_ = map_->mapFromScene(sceneCenter);
pinchStartDist_ = dist;
- pinchStartAngle_ = angle;
pinchLastZoomLevel_ = 1.0;
pinchLastTilt_ = 0.0;
pinchLastAngle_ = angle;
@@ -362,21 +482,16 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
lastPoint1_ = p1;
lastPoint2_ = p2;
- QDeclarativeGeoMapPinchEvent pe(pinchStartCenter_, 1.0, angle, 0.0);
- pe.setStartCenter(pinchStartCenter_);
- pe.setPreviousCenter(pinchStartCenter_);
- pe.setPreviousAngle(pinchLastAngle_);
- pe.setPreviousZoomLevel(pinchLastZoomLevel_);
- pe.setStartPoint1(map_->mapFromScene(sceneStartPoint1_));
- pe.setStartPoint2(map_->mapFromScene(sceneStartPoint2_));
- pe.setPoint1(map_->mapFromScene(lastPoint1_));
- pe.setPoint2(map_->mapFromScene(lastPoint2_));
- pe.setPointCount(touchPoints_.count());
- emit pinchStarted(&pe);
- if (pe.accepted()) {
+ pinchEvent_.setCenter(map_->mapFromScene(sceneCenter));
+ pinchEvent_.setAngle(angle);
+ pinchEvent_.setPoint1(map_->mapFromScene(lastPoint1_));
+ pinchEvent_.setPoint2(map_->mapFromScene(lastPoint2_));
+ pinchEvent_.setPointCount(touchPoints_.count());
+ pinchEvent_.setAccepted(true);
+ emit pinchStarted(&pinchEvent_);
+
+ if (pinchEvent_.accepted()) {
inPinch_ = true;
- // TODO is this pos needed. Analyze.
- pinchStartPos_ = map_->pos();
pinchStartZoomLevel_ = map_->cameraData().zoomFactor();
pinchStartRotation_ = map_->cameraData().bearing();
pinchStartTilt_ = map_->cameraData().tilt();
@@ -385,7 +500,7 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
pinchRejected_ = true;
}
}
- } else if (pinchStartDist_ > 0) { // TODO restructure this codeblock according to activeGestures_
+ } else if (pinchStartDist_ > 0) {
// Calculate the new zoom level if we have distance ( >= 2 touchpoints), otherwise stick with old.
qreal newZoomLevel = pinchLastZoomLevel_;
if (dist) {
@@ -403,25 +518,19 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
else if (da < -180)
da += 360;
pinchRotation_ -= da;
- // TODO check how this impacts is this needed
- QPointF pinchCenter = map_->mapFromScene(sceneCenter);
- QDeclarativeGeoMapPinchEvent pe(pinchCenter, newZoomLevel, angle, pinchRotation_);
- // TODO these events need to accommodate tilt.
- pe.setStartCenter(pinchStartCenter_);
- pe.setPreviousCenter(map_->mapFromScene(sceneLastCenter_));
- pe.setPreviousAngle(pinchLastAngle_);
- pe.setPreviousZoomLevel(pinchLastZoomLevel_);
- pe.setStartPoint1(map_->mapFromScene(sceneStartPoint1_));
- pe.setStartPoint2(map_->mapFromScene(sceneStartPoint2_));
- pe.setPoint1(touchPoint1.pos());
- pe.setPoint2(touchPoint2.pos());
- pe.setPointCount(touchPoints_.count());
+ pinchEvent_.setCenter(map_->mapFromScene(sceneCenter));
+ pinchEvent_.setAngle(angle);
+ pinchEvent_.setPoint1(touchPoint1.pos());
+ pinchEvent_.setPoint2(touchPoint2.pos());
+ pinchEvent_.setPointCount(touchPoints_.count());
+ pinchEvent_.setAccepted(true);
sceneLastCenter_ = sceneCenter;
pinchLastAngle_ = angle;
lastPoint1_ = touchPoint1.scenePos();
lastPoint2_ = touchPoint2.scenePos();
- emit pinchUpdated(&pe);
+ emit pinchUpdated(&pinchEvent_);
+
if (activeGestures_ & ZoomGesture) {
// Take maximum and minimumzoomlevel into account
qreal perPinchMinimumZoomLevel = qMax(pinchStartZoomLevel_ - maximumZoomLevelChange_, minimumZoomLevel_);
@@ -433,7 +542,7 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
map_->map()->setCameraData(cam);
}
if (activeGestures_ & TiltGesture && minimumZoomLevel_ >= 0 && maximumZoomLevel_ >= 0) {
- // TODO zzz
+ // Note: tilt is not yet supported.
qreal newTilt = pinchLastTilt_;
if (dist) {
newTilt =
@@ -453,41 +562,22 @@ void QDeclarativeGeoMapPinchArea::updatePinch()
cam.setTilt(newTilt);
map_->map()->setCameraData(cam);
}
-
- //QPointF pos = sceneCenter - sceneStartCenter_ + pinchStartPos_;
- // TODO we probably don't want drag - leave that to flickable
- //if (pinch()->axis() & QQuickPinch::XAxis) {
- // qreal x = pos.x();
- // if (x < pinch()->xmin())
- // x = pinch()->xmin();
- // else if (x > pinch()->xmax())
- // x = pinch()->xmax();
- // pinch()->target()->setX(x);
- //}
- //if (pinch()->axis() & QQuickPinch::YAxis) {
- // qreal y = pos.y();
- // if (y < pinch()->ymin())
- // y = pinch()->ymin();
- // else if (y > pinch()->ymax())
- // y = pinch()->ymax();
- // pinch()->target()->setY(y);
- //}
if (activeGestures_ & RotationGesture) {
bool unlimitedRotation = (minimumRotation_ == 0.0 && maximumRotation_ == 0.0);
if ((pinchStartRotation_ >= minimumRotation_ && pinchStartRotation_ <= maximumRotation_) || unlimitedRotation) {
- qreal r = pinchRotation_ * rotationSpeed_ + pinchStartRotation_;
+ qreal r = pinchRotation_ * rotationFactor_ + pinchStartRotation_;
if (!unlimitedRotation)
r = qMin(qMax(minimumRotation_,r), maximumRotation_);
if (r > 360.0)
r -= 360;
if (r < -360.0)
r += 360.0;
+
CameraData cam = map_->map()->cameraData();
cam.setBearing(r);
map_->map()->setCameraData(cam);
}
}
- // }
}
}
}
diff --git a/src/imports/location/qdeclarativegeomappincharea_p.h b/src/imports/location/qdeclarativegeomappincharea_p.h
index 148e691c..52eafc6e 100644
--- a/src/imports/location/qdeclarativegeomappincharea_p.h
+++ b/src/imports/location/qdeclarativegeomappincharea_p.h
@@ -59,45 +59,30 @@ class QDeclarativeGeoMapPinchEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(QPointF center READ center) // TODO this probably needs to reset every time
- Q_PROPERTY(QPointF startCenter READ startCenter)
- Q_PROPERTY(QPointF previousCenter READ previousCenter)
- Q_PROPERTY(qreal zoomLevel READ zoomLevel)
- Q_PROPERTY(qreal previousZoomLevel READ previousZoomLevel)
+ Q_PROPERTY(QPointF center READ center)
Q_PROPERTY(qreal angle READ angle)
- Q_PROPERTY(qreal previousAngle READ previousAngle)
- Q_PROPERTY(qreal rotation READ rotation)
Q_PROPERTY(QPointF point1 READ point1)
- Q_PROPERTY(QPointF startPoint1 READ startPoint1)
Q_PROPERTY(QPointF point2 READ point2)
- Q_PROPERTY(QPointF startPoint2 READ startPoint2)
Q_PROPERTY(int pointCount READ pointCount)
Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
public:
- QDeclarativeGeoMapPinchEvent(QPointF c, qreal s, qreal a, qreal r)
- : QObject(), center_(c), zoomLevel_(s), angle_(a), rotation_(r)
- , pointCount_(0), accepted_(true) {}
+ QDeclarativeGeoMapPinchEvent(QPointF center, qreal angle,
+ QPointF point1, QPointF point2,
+ int pointCount = 0, bool accepted = true)
+ : QObject(), center_(center), angle_(angle),
+ point1_(point1), point2_(point2),
+ pointCount_(pointCount), accepted_(accepted) {}
+ QDeclarativeGeoMapPinchEvent() {}
+
QPointF center() const { return center_; }
- QPointF startCenter() const { return startCenter_; }
- void setStartCenter(QPointF c) { startCenter_ = c; }
- QPointF previousCenter() const { return lastCenter_; }
- void setPreviousCenter(QPointF c) { lastCenter_ = c; }
- qreal zoomLevel() const { return zoomLevel_; }
- qreal previousZoomLevel() const { return lastZoomLevel_; }
- void setPreviousZoomLevel(qreal s) { lastZoomLevel_ = s; }
+ void setCenter(QPointF center) { center_ = center; }
qreal angle() const { return angle_; }
- qreal previousAngle() const { return lastAngle_; }
- void setPreviousAngle(qreal a) { lastAngle_ = a; }
- qreal rotation() const { return rotation_; }
+ void setAngle(qreal angle) { angle_ = angle; }
QPointF point1() const { return point1_; }
void setPoint1(QPointF p) { point1_ = p; }
- QPointF startPoint1() const { return startPoint1_; }
- void setStartPoint1(QPointF p) { startPoint1_ = p; }
QPointF point2() const { return point2_; }
void setPoint2(QPointF p) { point2_ = p; }
- QPointF startPoint2() const { return startPoint2_; }
- void setStartPoint2(QPointF p) { startPoint2_ = p; }
int pointCount() const { return pointCount_; }
void setPointCount(int count) { pointCount_ = count; }
bool accepted() const { return accepted_; }
@@ -105,17 +90,9 @@ public:
private:
QPointF center_;
- QPointF startCenter_;
- QPointF lastCenter_;
- qreal zoomLevel_;
- qreal lastZoomLevel_;
qreal angle_;
- qreal lastAngle_;
- qreal rotation_;
QPointF point1_;
QPointF point2_;
- QPointF startPoint1_;
- QPointF startPoint2_;
int pointCount_;
bool accepted_;
};
@@ -129,15 +106,17 @@ class QDeclarativeGeoMapPinchArea: public QObject
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
Q_PROPERTY(ActiveGestures activeGestures READ activeGestures WRITE setActiveGestures NOTIFY activeGesturesChanged)
- Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel WRITE setMinimumZoomLevel NOTIFY minimumZoomLevelChanged)
- Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel WRITE setMaximumZoomLevel NOTIFY maximumZoomLevelChanged)
Q_PROPERTY(qreal maximumZoomLevelChange READ maximumZoomLevelChange WRITE setMaximumZoomLevelChange NOTIFY maximumZoomLevelChangeChanged)
- Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
- Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
- Q_PROPERTY(qreal rotationSpeed READ rotationSpeed WRITE setRotationSpeed NOTIFY rotationSpeedChanged)
- Q_PROPERTY(qreal maximumTilt READ maximumTilt WRITE setMaximumTilt NOTIFY maximumTiltChanged)
- Q_PROPERTY(qreal minimumTilt READ minimumTilt WRITE setMinimumTilt NOTIFY minimumTiltChanged)
- Q_PROPERTY(qreal maximumTiltChange READ maximumTiltChange WRITE setMaximumTiltChange NOTIFY maximumTiltChangeChanged)
+ Q_PROPERTY(qreal rotationFactor READ rotationFactor WRITE setRotationFactor NOTIFY rotationFactorChanged)
+ // need for these is not clear, use-case(s) not yet identified:
+ //Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
+ //Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
+ //Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel WRITE setMinimumZoomLevel NOTIFY minimumZoomLevelChanged)
+ //Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel WRITE setMaximumZoomLevel NOTIFY maximumZoomLevelChanged)
+ // when tilt is supported, these are needed:
+ //Q_PROPERTY(qreal maximumTilt READ maximumTilt WRITE setMaximumTilt NOTIFY maximumTiltChanged)
+ //Q_PROPERTY(qreal minimumTilt READ minimumTilt WRITE setMinimumTilt NOTIFY minimumTiltChanged)
+ //Q_PROPERTY(qreal maximumTiltChange READ maximumTiltChange WRITE setMaximumTiltChange NOTIFY maximumTiltChangeChanged)
public:
QDeclarativeGeoMapPinchArea(QDeclarative3DGraphicsGeoMap* map, QObject *parent = 0);
@@ -175,8 +154,8 @@ public:
qreal maximumRotation() const;
void setMaximumRotation(qreal zoomLevel);
- qreal rotationSpeed() const;
- void setRotationSpeed(qreal speed);
+ qreal rotationFactor() const;
+ void setRotationFactor(qreal factor);
qreal maximumTilt() const;
void setMaximumTilt(qreal tilt);
@@ -199,7 +178,7 @@ signals:
void maximumZoomLevelChangeChanged();
void minimumRotationChanged();
void maximumRotationChanged();
- void rotationSpeedChanged();
+ void rotationFactorChanged();
void activeGesturesChanged();
void minimumTiltChanged();
void maximumTiltChanged();
@@ -213,25 +192,18 @@ private:
void updatePinch();
private:
- // pinch target (fixed for now)
QDeclarative3DGraphicsGeoMap* map_;
-
- // own
+ QDeclarativeGeoMapPinchEvent pinchEvent_;
bool enabled_;
-
- // qquickpinch
bool active_;
qreal minimumZoomLevel_;
qreal maximumZoomLevel_;
qreal minimumRotation_;
qreal maximumRotation_;
-
- // qquickpincharea
QList<QTouchEvent::TouchPoint> touchPoints_;
bool inPinch_;
bool pinchRejected_;
bool pinchActivated_;
- //QQuickPinch *pinch_;
QPointF sceneStartPoint1_;
QPointF sceneStartPoint2_;
QPointF lastPoint1_;
@@ -240,16 +212,12 @@ private:
qreal pinchStartZoomLevel_;
qreal pinchLastZoomLevel_;
qreal pinchStartRotation_;
- qreal pinchStartAngle_;
qreal pinchLastAngle_;
qreal pinchRotation_;
- QPointF sceneStartCenter_;
- QPointF pinchStartCenter_;
QPointF sceneLastCenter_;
- QPointF pinchStartPos_;
int id1_;
qreal maximumZoomLevelChange_;
- qreal rotationSpeed_;
+ qreal rotationFactor_;
ActiveGestures activeGestures_;
qreal minimumTilt_;
qreal maximumTilt_;