/* 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 . */ #ifndef mapitembase_h #define mapitembase_h #include "qad_map_export.h" #include #include #include #include #include #include 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); QPainter::RenderHints renderHints() const { return m_hints; } void setRenderHints(QPainter::RenderHints h); void setRenderHint(QPainter::RenderHint h, bool on = true); bool isVisible() const { return m_visible; } void setVisible(bool newVisible); bool isHidden() const { return !isVisible(); } void setHidden(bool newHidden) { setVisible(!newHidden); } void show() { setVisible(true); } void hide() { setVisible(false); } 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(QPointF(lat, lng)); } void setPosition(QGeoCoordinate c) { setPosition(QPointF(c.latitude(), c.longitude())); } QPointF offset() const { return m_offset; } void setOffset(QPointF pixels); void setOffset(double x, double y) { setOffset({x, y}); } 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.}, m_offset; QRectF m_bounding; QCursor m_cursor; QPainter::RenderHints m_hints; QMap data_; }; #endif