: QObject(parent)
, m_centerTile(QPoint(UNDEFINED, UNDEFINED))
, m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT))
- , m_zoomDirection(OUT)
+ , m_zoomedIn(false)
, m_zoomLevel(DEFAULT_ZOOM_LEVEL)
{
m_mapScene = new MapScene(this);
m_mapScene->addItem(m_mapZoomPanel);
connect(m_mapZoomPanel, SIGNAL(zoomInPressed()), this, SLOT(zoomIn()));
connect(m_mapZoomPanel, SIGNAL(zoomOutPressed()), this, SLOT(zoomOut()));
+
+ m_ownLocation = new OwnLocationItem();
+ m_mapScene->addItem(m_ownLocation);
}
void MapEngine::init()
void MapEngine::mapImageReceived(const QUrl &url, const QPixmap &pixmap)
{
- //qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
int zoom = UNDEFINED;
int x = UNDEFINED;
if (!m_mapScene->isTileInScene(hashKey)) {
MapTile *mapTile = new MapTile();
- /// @todo SET SCENE LEVEL AUTOMATICALLY WHEN CHANGING ZOOM LEVEL
- mapTile->setZoomLevel(zoom);
- mapTile->setSceneLevel(m_zoomLevel);
+ mapTile->setZoomLevel(zoom, m_zoomLevel);
mapTile->setTileNumber(QPoint(x, y));
mapTile->setPixmap(pixmap);
m_mapScene->debugItemsCount();
m_mapScene->enqueueRemoveStackedTiles(mapTile);
- //m_mapScene->removeStackedTiles(mapTile, viewRect());
}
}
int topLeftX = tileCoordinate.x() - (gridWidth/2);
int topLeftY = tileCoordinate.y() - (gridHeight/2);
+ m_mapFetcher->setDownloadQueueSize(gridWidth * gridHeight);
+
return QRect(topLeftX, topLeftY, gridWidth, gridHeight);
}
{
m_mapZoomPanel->setPos(viewTopLeft);
-// qDebug() << __PRETTY_FUNCTION__ << "viewTopLeft:" << viewTopLeft;
+ qDebug() << __PRETTY_FUNCTION__ << "viewTopLeft:" << viewTopLeft;
}
void MapEngine::setLocation(QPoint sceneCoordinate)
{
-// qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
m_sceneCoordinate = sceneCoordinate;
emit locationChanged(m_sceneCoordinate);
void MapEngine::getTiles(QPoint sceneCoordinate)
{
-// qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
m_viewTilesGrid = calculateTileGrid(sceneCoordinate);
updateViewTilesSceneRect();
void MapEngine::updateViewTilesSceneRect()
{
QPoint topLeft = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewTilesGrid.topLeft());
- QPoint bottomRight = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewTilesGrid.bottomRight()
- + QPoint(1, 1));
+ QPoint bottomRight = convertTileNumberToSceneCoordinate(m_zoomLevel,
+ m_viewTilesGrid.bottomRight()
+ + QPoint(1, 1)) - QPoint(1, 1);
m_mapScene->viewRectUpdated(QRect(topLeft, bottomRight));
}
void MapEngine::viewZoomFinished()
{
-// qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
- if (m_zoomDirection == IN)
+ if (m_zoomedIn) {
+ m_zoomedIn = false;
m_mapScene->removeOutOfViewTiles();
+ }
}
void MapEngine::zoomIn()
{
-// qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
if (m_zoomLevel < MAX_MAP_ZOOM_LEVEL) {
m_zoomLevel++;
- m_zoomDirection = IN;
+ m_zoomedIn = true;
emit zoomLevelChanged(m_zoomLevel);
m_mapScene->setTilesDrawingLevels(m_zoomLevel);
void MapEngine::zoomOut()
{
-// qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
if (m_zoomLevel > MIN_VIEW_ZOOM_LEVEL) {
m_zoomLevel--;
- m_zoomDirection = OUT;
emit zoomLevelChanged(m_zoomLevel);
m_mapScene->setTilesDrawingLevels(m_zoomLevel);
QPoint MapEngine::convertLatLonToSceneCoordinate(QPointF latLonCoordinate)
{
-// qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
qreal longitude = latLonCoordinate.x();
qreal latitude = latLonCoordinate.y();