changed 3D rendering

added pan/zoom gesture
This commit is contained in:
2018-02-04 17:02:14 +01:00
parent 3b62f23c0e
commit 076c0e9157
32 changed files with 446 additions and 484 deletions

View File

@@ -9,6 +9,8 @@
*/
class ToolMapZoom : public Tool {
float startScale = NAN;
public:
const std::string getName() const override {
@@ -32,6 +34,34 @@ public:
}
virtual bool pinchTriggered(MapView2D *m, QPinchGesture* g) override {
Scaler& s = m->getScaler();
// https://doc.qt.io/qt-5/qtwidgets-gestures-imagegestures-example.html
QPinchGesture::ChangeFlags changeFlags = g->changeFlags();
if (changeFlags & QPinchGesture::RotationAngleChanged) {
// qreal rotationDelta = gesture->rotationAngle() - gesture->lastRotationAngle();
// rotationAngle += rotationDelta;
// qCDebug(lcExample) << "pinchTriggered(): rotate by" <<
// rotationDelta << "->" << rotationAngle;
}
if (changeFlags & QPinchGesture::ScaleFactorChanged) {
if (startScale != startScale) {startScale = s.getScale();}
s.setScale(startScale * g->totalScaleFactor());
}
if (g->state() == Qt::GestureFinished) {
startScale = NAN;
}
if (s.getScale() > 1000) {s.setScale(1000);}
if (s.getScale() < 5) {s.setScale(5);}
return true;
}
};
#endif // TOOLMAPZOOM_H