1 #ifndef OSMSCOUT_CLIENT_QT_MAPWIDGET_H 2 #define OSMSCOUT_CLIENT_QT_MAPWIDGET_H 24 #include <QQuickPaintedItem> 59 Q_PROPERTY(QObject *view READ GetView WRITE SetMapView NOTIFY viewChanged)
60 Q_PROPERTY(QObject *vehiclePosition READ GetVehiclePosition WRITE SetVehiclePosition)
61 Q_PROPERTY(
double lat READ GetLat NOTIFY viewChanged)
62 Q_PROPERTY(
double lon READ GetLon NOTIFY viewChanged)
63 Q_PROPERTY(
int zoomLevel READ GetMagLevel NOTIFY viewChanged)
64 Q_PROPERTY(QString zoomLevelName READ GetZoomLevelName NOTIFY viewChanged)
65 Q_PROPERTY(
double pixelSize READ GetPixelSize NOTIFY viewChanged)
66 Q_PROPERTY(
bool databaseLoaded READ isDatabaseLoaded NOTIFY databaseLoaded)
67 Q_PROPERTY(
bool finished READ IsFinished NOTIFY finishedChanged)
68 Q_PROPERTY(
bool showCurrentPosition READ getShowCurrentPosition WRITE setShowCurrentPosition)
69 Q_PROPERTY(
bool lockToPosition READ isLockedToPosition WRITE setLockToPosition NOTIFY lockToPossitionChanged)
70 Q_PROPERTY(
bool followVehicle READ isFollowVehicle WRITE setFollowVehicle NOTIFY followVehicleChanged)
71 Q_PROPERTY(QString stylesheetFilename READ GetStylesheetFilename NOTIFY stylesheetFilenameChanged)
72 Q_PROPERTY(QString renderingType READ GetRenderingType WRITE SetRenderingType NOTIFY renderingTypeChanged)
79 Q_PROPERTY(
bool preventMouseStealing READ isPreventMouseStealing WRITE setPreventMouseStealing)
81 Q_PROPERTY(
bool stylesheetHasErrors READ stylesheetHasErrors NOTIFY styleErrorsChanged)
82 Q_PROPERTY(
int stylesheetErrorLine READ firstStylesheetErrorLine NOTIFY styleErrorsChanged)
83 Q_PROPERTY(
int stylesheetErrorColumn READ firstStylesheetErrorColumn NOTIFY styleErrorsChanged)
84 Q_PROPERTY(QString stylesheetErrorDescription READ firstStylesheetErrorDescription NOTIFY styleErrorsChanged)
86 Q_PROPERTY(QString vehicleStandardIconFile READ getVehicleStandardIconFile WRITE setVehicleStandardIconFile)
87 Q_PROPERTY(QString vehicleNoGpsSignalIconFile READ getVehicleNoGpsSignalIconFile WRITE setVehicleNoGpsSignalIconFile)
88 Q_PROPERTY(QString vehicleInTunnelIconFile READ getVehicleInTunnelIconFile WRITE setVehicleInTunnelIconFile)
89 Q_PROPERTY(
double vehicleIconSize READ getVehicleIconSize WRITE setVehicleIconSize)
96 InputHandler *inputHandler{
nullptr};
97 TapRecognizer tapRecognizer;
99 bool preventMouseStealing{
false};
101 bool finished{
false};
103 struct CurrentLocation {
104 QDateTime lastUpdate{QDateTime::currentDateTime()};
106 osmscout::GeoCoord coord;
107 bool horizontalAccuracyValid{
false};
108 double horizontalAccuracy{0};
110 CurrentLocation currentPosition;
111 bool showCurrentPosition{
false};
115 QMap<int, osmscout::GeoCoord> marks;
119 VehiclePosition *position{
nullptr};
125 QElapsedTimer lastGesture;
127 QString standardIconFile{
"vehicle.svg"};
128 QString noGpsSignalIconFile{
"vehicle_not_fixed.svg"};
129 QString inTunnelIconFile{
"vehicle_tunnel.svg"};
132 QImage noGpsSignalIcon;
137 if (position==
nullptr){
140 switch(position->getState()){
141 case PositionAgent::PositionState::EstimateInTunnel:
142 return !inTunnelIcon.isNull() ? inTunnelIcon : standardIcon;
143 case PositionAgent::PositionState::NoGpsSignal:
144 return !noGpsSignalIcon.isNull() ? noGpsSignalIcon : standardIcon;
152 float vehicleScaleFactor{1.0};
156 void lockToPossitionChanged();
157 void followVehicleChanged();
158 void finishedChanged(
bool finished);
160 void mouseMove(
const int screenX,
const int screenY,
const double lat,
const double lon,
const Qt::KeyboardModifiers modifiers);
161 void tap(
const int screenX,
const int screenY,
const double lat,
const double lon);
162 void doubleTap(
const int screenX,
const int screenY,
const double lat,
const double lon);
163 void longTap(
const int screenX,
const int screenY,
const double lat,
const double lon);
164 void tapLongTap(
const int screenX,
const int screenY,
const double lat,
const double lon);
166 void stylesheetFilenameChanged();
167 void styleErrorsChanged();
168 void databaseLoaded(osmscout::GeoBox);
169 void renderingTypeChanged(QString type);
172 void changeView(
const MapView &view);
177 void zoom(
double zoomFactor);
178 void zoomIn(
double zoomFactor);
179 void zoomOut(
double zoomFactor);
181 void zoom(
double zoomFactor,
const QPoint widgetPosition);
182 void zoomIn(
double zoomFactor,
const QPoint widgetPosition);
183 void zoomOut(
double zoomFactor,
const QPoint widgetPosition);
185 void move(QVector2D vector);
195 void rotateTo(
double angle);
199 void toggleDaylight();
201 void reloadTmpStyle();
203 void showCoordinates(osmscout::GeoCoord coord, osmscout::Magnification magnification);
204 void showCoordinates(
double lat,
double lon);
205 void showCoordinatesInstantly(osmscout::GeoCoord coord, osmscout::Magnification magnification);
206 void showCoordinatesInstantly(
double lat,
double lon);
207 void showLocation(LocationEntry* location);
209 void locationChanged(
bool locationValid,
210 double lat,
double lon,
211 bool horizontalAccuracyValid =
false,
212 double horizontalAccuracy = 0,
213 const QDateTime &lastUpdate = QDateTime::currentDateTime());
219 void addPositionMark(
int id,
double lat,
double lon);
220 void removePositionMark(
int id);
234 void addOverlayObject(
int id, QObject *o);
235 void removeOverlayObject(
int id);
236 void removeAllOverlayObjects();
238 OverlayWay *createOverlayWay(QString type=
"_route");
239 OverlayArea *createOverlayArea(QString type=
"_highlighted");
240 OverlayNode *createOverlayNode(QString type=
"_highlighted");
251 void setVehicleScaleFactor(
float factor);
255 virtual void onTap(
const QPoint p);
256 virtual void onDoubleTap(
const QPoint p);
257 virtual void onLongTap(
const QPoint p);
258 virtual void onTapLongTap(
const QPoint p);
259 virtual void onTapAndDrag(
const QPoint p);
261 void onMapDPIChange(
double dpi);
266 void setupInputHandler(InputHandler *newGesture);
268 void loadVehicleIcons();
274 osmscout::Magnification magnificationByDimension(
const Distance &dimension);
277 MapWidget(QQuickItem* parent =
nullptr);
278 ~MapWidget()
override;
288 if (updated ==
nullptr){
289 qWarning() <<
"Failed to cast " << o <<
" to MapView*.";
293 bool changed = *view != *updated;
296 changeView(*updated);
302 return vehicle.position;
305 void SetVehiclePosition(QObject *o);
309 return vehicle.standardIconFile;
314 vehicle.standardIconFile = file;
321 return vehicle.noGpsSignalIconFile;
326 vehicle.noGpsSignalIconFile = file;
333 return vehicle.inTunnelIconFile;
338 vehicle.inTunnelIconFile = file;
344 return vehicle.iconSize;
349 vehicle.iconSize = value;
356 return view->center.GetLat();
361 return view->center.GetLon();
369 QString GetStylesheetFilename()
const;
371 QString GetZoomLevelName()
const;
375 return view->magnification.GetLevel();
380 return getProjection().GetPixelSize();
390 return showCurrentPosition;
395 showCurrentPosition = b;
401 return inputHandler->isLockedToPosition();
404 void setLockToPosition(
bool);
408 return vehicle.follow;
411 void setFollowVehicle(
bool);
419 projection.
Set(GetCenter(),
420 view->angle.AsRadians(),
429 void wheelEvent(QWheelEvent* event)
override;
430 void touchEvent(QTouchEvent *event)
override;
432 void focusOutEvent(QFocusEvent *event)
override;
434 void translateToTouch(QMouseEvent* event, Qt::TouchPointStates states);
436 void mousePressEvent(QMouseEvent* event)
override;
437 void mouseMoveEvent(QMouseEvent* event)
override;
438 void mouseReleaseEvent(QMouseEvent* event)
override;
439 void hoverMoveEvent(QHoverEvent* event)
override;
441 void paint(QPainter *painter)
override;
443 bool stylesheetHasErrors()
const;
444 int firstStylesheetErrorLine()
const;
445 int firstStylesheetErrorColumn()
const;
446 QString firstStylesheetErrorDescription()
const;
448 bool isDatabaseLoaded();
449 Q_INVOKABLE
bool isInDatabaseBoundingBox(
double lat,
double lon);
450 Q_INVOKABLE QPointF screenPosition(
double lat,
double lon);
452 QString GetRenderingType()
const;
453 void SetRenderingType(QString type);
457 return preventMouseStealing;
462 preventMouseStealing = b;
468 static QImage loadSVGIcon(
const QString &directory,
const QString fileName,
double iconPixelSize);
473 #endif // OSMSCOUT_CLIENT_QT_MAPWIDGET_H
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
Definition: OSMScoutQt.h:192
Definition: Projection.h:333
Vehicle
Definition: OSMScoutTypes.h:55
bool Set(const GeoCoord &coord, const Magnification &magnification, size_t width, size_t height)
Definition: Projection.h:374
Definition: MapRenderer.h:72
Definition: VehiclePosition.h:40
Definition: InputHandler.h:160
RenderingType
Definition: OSMScoutQt.h:191