<file>res/images/sliding_bar_left.png</file>
<file>res/images/sliding_bar_right.png</file>
<file>res/images/clock.png</file>
+ <file>res/images/led_red_g.png</file>
+ <file>res/images/led_red_h.png</file>
+ <file>res/images/led_red_s.png</file>
</qresource>
</RCC>
+ MAX_MAP_ZOOM_LEVEL + 2; ///< Zepth of zoom panel (Z-axis)
static const int MAP_ZOOM_PANEL_BUTTON_SIZE = 74; ///< Size of a zoom panel button
+static const int MAP_OWN_LOCATION_ICON_SIZE = 24; ///< Size of own location item icon
+static const int OWN_LOCATION_ICON_Z_LEVEL = MAP_ZOOM_PANEL_LEVEL - 1; ///< Z-Level of own location icon
+
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
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()
#include "mapscene.h"
#include "maptile.h"
#include "mapzoompanel.h"
+#include "ownlocationitem.h"
/**
* @brief Map engine
MapScene *m_mapScene; ///< Scene for map tiles
MapZoomPanel *m_mapZoomPanel; ///< Toolbar for zoom buttons
QPoint m_centerTile; ///< Current center tile
+ OwnLocationItem *m_ownLocation; ///< Item to show own location
QPoint m_sceneCoordinate; ///< Current center coordinate
QRect m_viewGrid; ///< Current grid of tiles in view (includes margin)
QSize m_viewSize; ///< Current view size
#include <QMouseEvent>
#ifndef Q_WS_MAEMO_5
- #include <QGLWidget>
+// #include <QGLWidget>
#endif // Q_WS_MAEMO_5
#include "mapcommon.h"
* OpenGL can't be used in scratchbox.
*/
#ifndef Q_WS_MAEMO_5
- setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer)));
+ // setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer)));
#endif // !Q_WS_MAEMO_5
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Ville Tiensuu - ville.tiensuu@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#include <QDebug>
+
+#include "ownlocationitem.h"
+#include "mapengine.h"
+#include "mapcommon.h"
+
+OwnLocationItem::OwnLocationItem()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QPixmap ownLocationIcon(":/res/images/led_red_h.png");
+ setPixmap(ownLocationIcon);
+
+ QPointF defaultLocation(DEFAULT_LONGITUDE,DEFAULT_LATITUDE);
+ //QPoint position = MapEngine::convertLatLonToSceneCoordinate(home);
+
+ setPos(MapEngine::convertLatLonToSceneCoordinate(defaultLocation));
+ setZValue(OWN_LOCATION_ICON_Z_LEVEL);
+ setOffset(-MAP_OWN_LOCATION_ICON_SIZE/2, -MAP_OWN_LOCATION_ICON_SIZE/2);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
+}
+
+OwnLocationItem::OwnLocationItem(const qreal &longitude, const qreal &latitude)
+{
+ QPointF ownPosition(longitude,latitude);
+
+ QPixmap ownLocationIcon(":/res/images/led_red_h.png");
+ setPixmap(ownLocationIcon);
+
+ setPos(MapEngine::convertLatLonToSceneCoordinate(ownPosition));
+ setZValue(OWN_LOCATION_ICON_Z_LEVEL);
+ setOffset(-MAP_OWN_LOCATION_ICON_SIZE/2, -MAP_OWN_LOCATION_ICON_SIZE/2);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
+}
+
+OwnLocationItem::OwnLocationItem(const QPointF & ownPosition)
+{
+ QPixmap ownLocationIcon(":/res/images/led_red_h.png");
+ setPixmap(ownLocationIcon);
+
+ setPos(MapEngine::convertLatLonToSceneCoordinate(ownPosition));
+ setZValue(OWN_LOCATION_ICON_Z_LEVEL);
+ setOffset(-MAP_OWN_LOCATION_ICON_SIZE/2, -MAP_OWN_LOCATION_ICON_SIZE/2);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
+}
+
+void OwnLocationItem::setPosition(const QPointF & newPosition)
+{
+ setPos(MapEngine::convertLatLonToSceneCoordinate(newPosition));
+}
+
+QPoint OwnLocationItem::position() const
+{
+ QPointF currentPosition;
+ currentPosition = pos();
+
+ return currentPosition.toPoint();
+}
+
+void OwnLocationItem::hideOwnLocation()
+{
+ hide();
+}
+
+void OwnLocationItem::showOwnLocation()
+{
+ show();
+}
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Ville Tiensuu - ville.tiensuu@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+
+#ifndef OWNLOCATIONITEM_H
+#define OWNLOCATIONITEM_H
+
+#include <QGraphicsPixmapItem>
+
+/**
+* @brief Class that shows own location icon on the map
+*
+* @class OwnLocationItem ownlocationitem.h "map/ownlocationitem.h"
+* @author Ville Tiensuu
+*/
+class OwnLocationItem : public QGraphicsPixmapItem
+{
+public:
+ /**
+ * @brief Default constructor of OwnLocationItem.
+ * Sets position to default location.
+ * Loads and sets default pixmap that is show on the map.
+ * Sets default Z-value to show icon on top of maps but under zoom buttons.
+ * Sets offset so that achor of the picture is at the origin. this feature is
+ * needed to center icon on the middle of the location.
+ * Sets item to ignore transformations. this feature is needed to make icon on the map
+ * immune to scaling
+ */
+ OwnLocationItem();
+
+ /**
+ * @brief Overloaded constructor for OwnLocationItem.
+ * Otherwise same as default constructor, but position is set according to parameters.
+ *
+ * @param longitude Longitude coordinate of position.
+ * @param latitude Latitude coordinate of position.
+ */
+ OwnLocationItem(const qreal & longitude, const qreal & latitude);
+
+ /**
+ * @brief Overloaded constructor for OwnLocationItem.
+ * Otherwise same as default constructor, but position is set according to parameter.
+ *
+ * @param ownPosition Position in QPoinF format
+ */
+ OwnLocationItem(const QPointF & ownPosition);
+
+ /*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+ public:
+
+ /**
+ * @brief Hides OwnLocationItem so that it is invisible on the map
+ *
+ */
+ void hideOwnLocation();
+
+ /**
+ * @brief returns position of OwnLocationItem
+ *
+ * @return QPoint position of OwnLocationItem
+ */
+ QPoint position() const;
+
+ /**
+ * @brief sets position of OwnLocationItem as specified in parameter.
+ * Position defines where icon is show on the map.
+ *
+ * @param newPosition Parameter that specifies new position.
+ */
+ void setPosition(const QPointF & newPosition);
+
+ /**
+ * @brief Sets OwnLocationItem to be visible on the map.
+ * OwnLocationImte is visible by default, function is needed only when own location
+ * needs to be set back visible after hideOwnLocation function call.
+ */
+ void showOwnLocation();
+};
+
+#endif // OWNLOCATIONITEM_H
map/mapfetcher.cpp \
map/mapzoompanel.cpp \
map/mapbutton.cpp \
+ map/ownlocationitem.cpp \
ui/pixmap.cpp \
ui/infotab.cpp \
ui/updatelocation/updatelocationdialog.cpp \
map/mapcommon.h \
map/mapzoompanel.h \
map/mapbutton.h \
+ map/ownlocationitem.h \
ui/pixmap.h \
ui/infotab.h \
ui/updatelocation/updatelocationdialog.h \
# use don't use OpenGL when building in scratchbox
!maemo5 {
- QT += opengl
+# QT += opengl
message(OpenGL built in)
message(Make sure you have OpenGL development headers installed)
message(install headers with: sudo apt-get install libgl-dev libglu-dev)
--- /dev/null
+######################################################################
+# Automatically generated by qmake (2.01a) Tue Apr 27 14:52:31 2010
+######################################################################
+
+CONFIG += qtestlib
+QT += network
+TEMPLATE = app
+TARGET = ownlocation
+DEPENDPATH += .
+INCLUDEPATH += . \
+ ../../../src/
+
+# Input
+SOURCES += testownlocationitem.cpp \
+ ../../../src/map/mapscene.cpp \
+ ../../../src/map/maptile.cpp \
+ ../../../src/map/mapengine.cpp \
+ ../../../src/map/mapfetcher.cpp \
+ ../../../src/map/ownlocationitem.cpp \
+ ../../../src/map/mapview.cpp \
+ ../../../src/map/mapzoompanel.cpp \
+ ../../../src/map/mapbutton.cpp
+
+HEADERS += ../../../src/map/ownlocationitem.h \
+ ../../../src/map/mapscene.h \
+ ../../../src/map/maptile.h \
+ ../../../src/map/mapengine.h \
+ ../../../src/map/mapfetcher.h \
+ ../../../src/map/mapcommon.h \
+ ../../../src/map/mapview.h \
+ ../../../src/map/mapzoompanel.h \
+ ../../../src/map/mapbutton.h
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Ville Tiensuu - ville.tiensuu@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#include <QtTest/QtTest>
+#include <QDebug>
+#include <QList>
+
+#include "map/ownlocationitem.h"
+#include "map/mapscene.h"
+#include "map/maptile.h"
+#include "map/mapengine.h"
+#include "map/mapcommon.h"
+#include "map/mapview.h"
+
+namespace TestOwnLocation // Test data for function is defined in namespace
+{
+ const qreal xCoordinate = 65.525;
+ const qreal yCoordinate = 25.345;
+ const QPointF testLocationPoint(65.525, 25.345);
+ const QPointF defaultLocationPoint(DEFAULT_LONGITUDE,DEFAULT_LATITUDE);
+ const QPointF locationIconOffset(-MAP_OWN_LOCATION_ICON_SIZE/2, -MAP_OWN_LOCATION_ICON_SIZE/2);
+ const int itemIgnoresTransformationsFlagValue = 0x20;
+}
+
+using namespace TestOwnLocation;
+
+
+/**
+* @brief Class that test OwnLocationItem
+*
+* @author Ville Tiensuu
+*/
+class TestOwnLocationItem: public QObject
+ {
+ Q_OBJECT
+ private slots:
+
+ /**
+ * @brief Test method for constructors.
+ * Creates instance of OwnLocationItem using three different constructors and tests
+ * that positions are set correctly.
+ * Tests that Z-values are set correctly.
+ * Tests that offses are set correctly.
+ * Tests that ItemIgnoresTransformations flag is set.
+ */
+ void testConstructors();
+
+ /**
+ * @brief Creates instance of OwnLocationItem.
+ * Sets test position for location item in geographic coordinates.
+ * Reads position from location item in scene coordinates and
+ * verifies that it correctly formed.
+ */
+ void testSetAndGetPosition();
+
+ /**
+ * @brief Creates instance of OwnLocationItem.
+ * Verifies that instance is visible.
+ * Hides instance and verifies that it is not visible.
+ */
+ void testHideAndShowPosition();
+ };
+
+ void TestOwnLocationItem::testConstructors()
+ {
+ OwnLocationItem ownLocationItem1;
+ OwnLocationItem ownLocationItem2(xCoordinate, yCoordinate);
+ OwnLocationItem ownLocationItem3(testLocationPoint);
+
+ // Test Positions
+ QCOMPARE(ownLocationItem1.position(),
+ MapEngine::convertLatLonToSceneCoordinate(defaultLocationPoint));
+
+ QCOMPARE(ownLocationItem2.position(),
+ MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
+
+ QCOMPARE(ownLocationItem3.position(),
+ MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
+
+ // Test Z-values
+ QCOMPARE(static_cast<int>(ownLocationItem1.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
+ QCOMPARE(static_cast<int>(ownLocationItem2.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
+ QCOMPARE(static_cast<int>(ownLocationItem3.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
+
+ // Test Offsets
+ QCOMPARE(ownLocationItem1.offset(), locationIconOffset);
+ QCOMPARE(ownLocationItem2.offset(), locationIconOffset);
+ QCOMPARE(ownLocationItem3.offset(), locationIconOffset);
+
+ // Test ItemIgnoresTransformations Flags
+ QGraphicsItem::GraphicsItemFlags ownLocationItem1Flags = ownLocationItem1.flags();
+ QGraphicsItem::GraphicsItemFlags ownLocationItem2Flags = ownLocationItem1.flags();
+ QGraphicsItem::GraphicsItemFlags ownLocationItem3Flags = ownLocationItem1.flags();
+
+ QCOMPARE(ownLocationItem1Flags, itemIgnoresTransformationsFlagValue);
+ QCOMPARE(ownLocationItem2Flags, itemIgnoresTransformationsFlagValue);
+ QCOMPARE(ownLocationItem3Flags, itemIgnoresTransformationsFlagValue);
+ }
+
+ void TestOwnLocationItem::testSetAndGetPosition()
+ {
+ OwnLocationItem ownLocation;
+ ownLocation.setPosition(testLocationPoint);
+
+ QCOMPARE(ownLocation.position(),
+ MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
+ }
+
+ void TestOwnLocationItem::testHideAndShowPosition()
+ {
+ OwnLocationItem ownLocation;
+
+ QCOMPARE(ownLocation.isVisible(), true);
+
+ ownLocation.hideOwnLocation();
+
+ QCOMPARE(ownLocation.isVisible(), false);
+
+ }
+
+ QTEST_MAIN(TestOwnLocationItem)
+ #include "testownlocationitem.moc"