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

View File

@@ -0,0 +1,15 @@
find_package(PIP)
if (PIP_FOUND)
project(mapviewer)
if(APPLE)
set(APP_ICON "")
elseif(WIN32)
set(APP_ICON "icons/maps.ico")
else()
set(APP_ICON "icons/maps.png")
endif()
set(APP_INFO "Map viewer")
qad_application(${PROJECT_NAME} "Gui;Widgets" "qad_map")
endif()

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

72
utils/mapviewer/main.cpp Normal file
View File

@@ -0,0 +1,72 @@
#include "mapitemellipse.h"
#include "mapitemgeopolygon.h"
#include "mapitemgeopolyline.h"
#include "mapitemimage.h"
#include "mapitempolygon.h"
#include "mapitemtext.h"
#include "mapview.h"
#include "qad_types.h"
#include <QApplication>
#include <QDateTime>
#include <QDebug>
#include <QTimer>
#include <math.h>
int main(int argc, char * argv[]) {
QApplication a(argc, argv);
enableHighDPI();
MapView w;
w.resize(800, 600);
w.show();
/*QVector<QPointF> g = {QPointF(55.583055, 37.580008), QPointF(55.583055, 37.590008), QPointF(55.593055, 37.580008)};
QVector<QPointF> p = {QPointF(0, 0), QPointF(200, 0), QPointF(0, 100)};
MapItemPolygon * pol = new MapItemPolygon(QPolygonF(p));
MapItemGeoPolyline * gpol = new MapItemGeoPolyline(QPolygonF(g));
MapItemEllipse * ell = new MapItemEllipse(QPointF(), 50, 50);
MapItemImage * im = new MapItemImage(QPixmap(":/icons/maps.png"));
MapItemText * it = new MapItemText(QString::fromUtf8("Это Ваня!"));
im->setPosition({55.583055, 37.580008});
im->setScale(0.2, 0.5);
im->setAlignment(Qt::AlignRight | Qt::AlignTop);
im->setCursor(Qt::PointingHandCursor);
im->setInteracive(true);
it->setPosition({55.583055, 37.580008});
it->setBrush(QColor(127, 0, 0, 127));
it->setPen(QColor(64, 255, 64));
it->setFont(QFont("times", 18));
it->setCursor(Qt::OpenHandCursor);
it->setInteracive(true);
pol->setPosition({55.583055, 37.580008});
pol->setUnits(MapItemNonGeoGeometryBase::Pixels);
gpol->setBrush(QColor(0, 0, 255, 64));
gpol->setPen(QPen(QColor(64, 64, 255), 3));
ell->setPosition({55.583055, 37.580008});
ell->setStartAngle(-20);
ell->setEndAngle(20);
ell->setEllipse(QPointF(100, 0), 50, 50);
ell->setInteracive(true);
QTimer t;
QObject::connect(&w, &MapView::itemClicked, [](MapItemBase * item) { qDebug() << "click" << item; });
QObject::connect(&w, &MapView::itemEntered, [](MapItemBase * item) { qDebug() << "enter" << item; });
QObject::connect(&w, &MapView::itemLeaved, [](MapItemBase * item) { qDebug() << "leave" << item; });
QObject::connect(&t, &QTimer::timeout, [im, it, pol, ell]() {
im->rotate(1);
it->rotate(-0.1);
// pol->rotate(0.2);
ell->rotate(-0.2);
static double t = 0.;
t += 0.025;
ell->setScale((sin(t) / 2. + 1.));
});
t.start(100);
w.addItem(im);
w.addItem(gpol);
w.addItem(pol);
w.addItem(it);
w.addItem(ell);*/
w.centerTo({55.583055, 37.580008});
w.zoomTo(17);
return a.exec();
}

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>icons/maps.png</file>
</qresource>
</RCC>