version 2.13.0

add Map library (MapView with OSM maps and items) and mapviewer util
This commit is contained in:
2023-01-20 09:16:42 +03:00
parent 10212e2ebd
commit 958c81fb1d
46 changed files with 2383 additions and 1 deletions

94
libs/map/mapitembase.h Normal file
View File

@@ -0,0 +1,94 @@
/*
QAD - Qt ADvanced
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef mapitembase_h
#define mapitembase_h
#include "qad_map_export.h"
#include <QCursor>
#include <QMap>
#include <QPainter>
#include <QRectF>
#include <QVariant>
class MapView;
class QAD_MAP_EXPORT MapItemBase {
friend class MapView;
public:
explicit MapItemBase();
virtual ~MapItemBase();
bool isInteracive() const { return m_interacive; }
void setInteracive(bool newInteracive);
bool isVisible() const { return m_visible; }
void setVisible(bool newVisible);
double getRotation() const { return m_rotation; }
void setRotation(double deg);
void rotate(double deg);
QPointF getScale() const { return m_scale; }
void scale(double s) { scale({s, s}); }
void scale(double sx, double sy) { scale({sx, sy}); }
void scale(QPointF s);
void setScale(double s) { setScale({s, s}); }
void setScale(double sx, double sy) { scale({sx, sy}); }
void setScale(QPointF s);
QPointF position() const { return m_position; }
void setPosition(QPointF geo);
void setPosition(double lat, double lng) { setPosition({lat, lng}); }
const QCursor & cursor() const { return m_cursor; }
void setCursor(const QCursor & newCursor);
QVariant data(int id) const { return data_.value(id); }
void setData(int id, const QVariant & d) { data_[id] = d; }
protected:
QPointF mapToView(QPointF norm) const;
double scalePx2M(QPointF norm) const;
virtual void draw(QPainter * p) = 0;
void updateParent();
void setBoundingRect(QRectF b);
QPointF norm_pos;
bool ignore_scale = false;
private:
void updatePosition();
virtual void potitionChanged() {}
virtual void zoomChanged() {}
MapView * parent = nullptr;
bool m_visible = true, m_interacive = false;
double m_rotation = 0.;
QPointF m_position, m_scale = {1., 1.};
QRectF m_bounding;
QCursor m_cursor;
QMap<int, QVariant> data_;
};
#endif