2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Ville Tiensuu - ville.tiensuu@ixonos.com
6 Sami Rämö - sami.ramo@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #include "mapcommon.h"
27 #include "baselocationitem.h"
29 BaseLocationItem::BaseLocationItem(QObject *parent)
32 qDebug() << __PRETTY_FUNCTION__;
34 setFlag(QGraphicsItem::ItemIgnoresTransformations);
37 QRect BaseLocationItem::sceneTransformedBoundingRect(int zoomLevel) const
39 qDebug() << __PRETTY_FUNCTION__;
41 // picture side length used for collision detection
42 const int IMAGE_SIDE = 58;
44 int multiplier = 1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel);
45 int side = multiplier * IMAGE_SIDE;
47 QPoint center = pos().toPoint();
48 QPoint topLeft(center.x() - side / 2, center.y() - side / 2);
49 QRect rect = QRect(topLeft, QSize(side, side));
51 // normalize rect's center point to be inside the map
52 if (center.x() < OSM_MAP_MIN_PIXEL_X)
53 rect.translate(OSM_MAP_PIXELS_X, 0);
54 else if (center.x() > OSM_MAP_MAX_PIXEL_X)
55 rect.translate(-OSM_MAP_PIXELS_X, 0);