<file>resources/clock_small.png</file>
<file>resources/arrow_left.png</file>
<file>resources/arrow_right.png</file>
+ <file>resources/zoom_in.png</file>
+ <file>resources/zoom_out.png</file>
</qresource>
</RCC>
const int ZOOM_FPS = 30; ///< FPS for the zoom effect
const qreal ZOOM_TIME = 250; ///< Length of the zoom effect (ms)
+static const int MAP_ZOOM_PANEL_POSITION_X = 10; ///< Horizontal position of zoom panel
+static const int MAP_ZOOM_PANEL_POSITION_Y = 10; ///< Vertical position of zoom panel
+static const int MAP_ZOOM_PANEL_LEVEL = MIN_MAP_SCENE_NORMAL_LEVEL
+ + MAX_MAP_ZOOM_LEVEL + 2; ///< Zepth of zoom panel (Z-axis)
+static const int MAP_ZOOM_PANEL_BUTTON_SIZE = 48; ///< Size of a zoom panel button
+
const qreal MAX_LATITUDE = 85.05112877980659237802; ///< Maximum latitude value
const qreal MIN_LATITUDE = -MAX_LATITUDE; ///< Minimum latitude value
const qreal MIN_LONGITUDE = -180.0; ///< Minimum longitude value
Sami Rämö - sami.ramo@ixonos.com
Jussi Laitinen - jussi.laitinen@ixonos.com
+ Pekka Nissinen - pekka.nissinen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
connect(this, SIGNAL(fetchImage(QUrl)), m_mapFetcher, SLOT(fetchMapImage(QUrl)));
connect(m_mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap)), this,
SLOT(mapImageReceived(QUrl, QPixmap)));
+
+ m_mapZoomPanel = new MapZoomPanel(NULL, MAP_ZOOM_PANEL_POSITION_X, MAP_ZOOM_PANEL_POSITION_Y);
+ m_mapScene->addItem(m_mapZoomPanel);
+ connect(m_mapZoomPanel, SIGNAL(zoomInPressed()), this, SLOT(zoomIn()));
+ connect(m_mapZoomPanel, SIGNAL(zoomOutPressed()), this, SLOT(zoomOut()));
}
void MapEngine::init()
return QRect(topLeftX, topLeftY, gridWidth, gridHeight);
}
+void MapEngine::alignImmovableItems(QPoint viewTopLeft)
+{
+ m_mapZoomPanel->setPos(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::removeTile(MapTile *tile)
{
- //qDebug() << __PRETTY_FUNCTION__;
+// qDebug() << __PRETTY_FUNCTION__;
if (tile) {
m_mapTilesInScene.remove(tilePath(tile->zoomLevel(), tile->tileNumber().x(),
void MapEngine::removeTilesOutOfView()
{
- //qDebug() << __PRETTY_FUNCTION__;
+// qDebug() << __PRETTY_FUNCTION__;
QPoint topLeft = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewGrid.topLeft());
QPoint bottomRight = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewGrid.bottomRight()
void MapEngine::removeStackedTiles(MapTile *newTile)
{
- //qDebug() << __PRETTY_FUNCTION__;
+// qDebug() << __PRETTY_FUNCTION__;
QRectF newTileSceneRect = newTile->sceneBoundingRect();
QList<QGraphicsItem *> collidingTiles = newTile->collidingItems(Qt::IntersectsItemBoundingRect);
void MapEngine::setTilesDrawingLevels()
{
- //qDebug() << __PRETTY_FUNCTION__ << "m_zoomLevel:" << m_zoomLevel;
+// qDebug() << __PRETTY_FUNCTION__ << "m_zoomLevel:" << m_zoomLevel;
QList<QGraphicsItem *> items = m_mapScene->items();
if (item)
item->setSceneLevel(m_zoomLevel);
}
-
}
QString MapEngine::tilePath(int zoomLevel, int x, int y)
return tilePathString;
}
-void MapEngine::scalingFactorChanged(qreal scaleFactor)
-{
- qDebug() << __PRETTY_FUNCTION__;
- Q_UNUSED(scaleFactor);
-}
-
QPoint MapEngine::convertSceneCoordinateToTileNumber(int zoomLevel, QPoint sceneCoordinate)
{
int pow = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
Sami Rämö - sami.ramo@ixonos.com
Jussi Laitinen - jussi.laitinen@ixonos.com
+ Pekka Nissinen - pekka.nissinen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#include "mapfetcher.h"
#include "mapscene.h"
#include "maptile.h"
+#include "mapzoompanel.h"
/**
* @brief Map engine
* converting coordinates.
* @author Sami Rämö - sami.ramo (at) ixonos.com
* @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
*/
class MapEngine : public QObject
{
public slots:
/**
+ * @brief Slot for immovable scene items position correction
+ *
+ * @param viewTopLeft Scene coordinate of the viewport top left corner
+ */
+ void alignImmovableItems(QPoint viewTopLeft);
+
+ /**
* @brief Slot for setting current view location
*
* Emits locationChanged signal.
void removeTilesOutOfView();
/**
- * @brief Slot for view scaling factor change events
- *
- * Can be used to trigger scaling of zoom buttons, friend indicators and other
- * MapScene elements which should retain their visual size
- * @param scaleFactor view's scale factor
- */
- void scalingFactorChanged(qreal scaleFactor);
-
- /**
* @brief Slot for zooming in
*
*/
* DATA MEMBERS
******************************************************************************/
private:
- QPoint m_centerTile; ///< Current center tile
MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
MapScene *m_mapScene; ///< Scene for map tiles
+ MapZoomPanel *m_mapZoomPanel; ///< Toolbar for zoom buttons
QHash<QString, MapTile *> m_mapTilesInScene; ///< List of map tiles in map scene
- QPoint m_sceneCoordinate; ///< Current center coordinate
+ QPoint m_centerTile; ///< Current center tile
+ QPoint m_sceneCoordinate; ///< Current center coordinate
QRect m_viewGrid; ///< Current grid of tiles in view
- QSize m_viewSize; ///< Current view size
+ QSize m_viewSize; ///< Current view size
int m_zoomLevel; ///< Current zoom level
};
QTransform transform;
transform.scale(scaleFactor, scaleFactor);
- emit scalingFactorChanged(scaleFactor);
setTransform(transform);
+ emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
}
}
m_scenePosition += m_mousePosition - mapToScene(event->pos()).toPoint();
emit viewScrolled(m_scenePosition);
- //qDebug() << __PRETTY_FUNCTION__ << "m_scenePosition" << m_scenePosition;
+// qDebug() << __PRETTY_FUNCTION__ << "m_scenePosition:" << m_scenePosition;
m_mousePosition = mapToScene(event->pos()).toPoint();
+ emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
}
void MapView::mousePressEvent(QMouseEvent *event)
{
+ QGraphicsView::mousePressEvent(event);
+
m_mousePosition = mapToScene(event->pos()).toPoint();
m_scenePosition = mapToScene(width() / 2 - 1, height() / 2 - 1).toPoint();
}
-
void MapView::centerToSceneCoordinates(QPoint sceneCoordinate)
{
// qDebug() << __PRETTY_FUNCTION__ << "sceneCoordinate" << sceneCoordinate;
void MapView::resizeEvent(QResizeEvent *event)
{
- //qDebug() << "Resize event: " << event->size();
+// qDebug() << "Resize event: " << event->size();
emit viewResized(event->size());
+ emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
}
class MapView : public QGraphicsView
{
Q_OBJECT
+
public:
/**
* @brief Constructor
******************************************************************************/
signals:
/**
- * @brief Signal for view scale factor change events
- *
- * Can be used to trigger scaling of zoom buttons, friend indicators and other
- * MapScene elements which should retain their visual size
- * @param scaleFactor view's scale factor
- */
- void scalingFactorChanged(qreal scaleFactor);
-
- /**
* @brief Signal for view resize events.
*
* Signal is emitted when view has been resized.
*/
void viewScrolled(QPoint sceneCoordinate);
+ /**
+ * @brief Signal for updating view content
+ *
+ * Signal is emitted when view content needs an update.
+ * @param viewTopLeft Scene coordinate of the viewport top left corner
+ */
+ void viewContentChanged(QPoint viewTopLeft);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
map/mapscene.cpp \
map/maptile.cpp \
map/mapfetcher.cpp \
+ map/mapzoompanel.cpp \
+ map/mapbutton.cpp \
ui/pixmap.cpp \
ui/infotab.cpp \
ui/updatelocation/updatelocationdialog.cpp \
map/maptile.h \
map/mapfetcher.h \
map/mapcommon.h \
+ map/mapzoompanel.h \
+ map/mapbutton.h \
ui/pixmap.h \
ui/infotab.h \
ui/updatelocation/updatelocationdialog.h \
mapView, SLOT(centerToSceneCoordinates(QPoint)));
connect(mapEngine, SIGNAL(zoomLevelChanged(int)), mapView, SLOT(setZoomLevel(int)));
connect(mapView, SIGNAL(viewResized(QSize)), mapEngine, SLOT(viewResized(QSize)));
- connect(mapView, SIGNAL(scalingFactorChanged(qreal)),
- mapEngine, SLOT(scalingFactorChanged(qreal)));
+ connect(mapView, SIGNAL(viewContentChanged(QPoint)),
+ mapEngine, SLOT(alignImmovableItems(QPoint)));
QHBoxLayout *mapViewLayout = new QHBoxLayout;
//DEBUG