From e142c4137c90c764282de17aa1c39efccd6d0c32 Mon Sep 17 00:00:00 2001 From: Roman Moravcik Date: Mon, 28 Mar 2011 13:12:17 +0200 Subject: [PATCH] Initial import of version 0.3 --- deployment.pri | 111 ++++++++ gpsdata.desktop | 11 + gpsdata.png | Bin 0 -> 4162 bytes gpsdata.pro | 52 ++++ gpsdata.svg | 62 +++++ qtc_packaging/debian_fremantle/README | 6 + qtc_packaging/debian_fremantle/changelog | 17 ++ qtc_packaging/debian_fremantle/compat | 1 + qtc_packaging/debian_fremantle/control | 110 ++++++++ qtc_packaging/debian_fremantle/copyright | 38 +++ qtc_packaging/debian_fremantle/rules | 91 +++++++ src/compass.cpp | 355 ++++++++++++++++++++++++ src/compass.h | 77 ++++++ src/gpscompasswindow.cpp | 90 +++++++ src/gpscompasswindow.h | 57 ++++ src/main.cpp | 36 +++ src/mainwindow.cpp | 434 ++++++++++++++++++++++++++++++ src/mainwindow.h | 115 ++++++++ src/satellitesignalstrength.cpp | 150 +++++++++++ src/satellitesignalstrength.h | 62 +++++ src/satellitesignalstrengthwindow.cpp | 83 ++++++ src/satellitesignalstrengthwindow.h | 61 +++++ src/satelliteview.cpp | 196 ++++++++++++++ src/satelliteview.h | 59 ++++ src/satelliteviewwindow.cpp | 90 +++++++ src/satelliteviewwindow.h | 57 ++++ 26 files changed, 2421 insertions(+) create mode 100644 deployment.pri create mode 100644 gpsdata.desktop create mode 100644 gpsdata.png create mode 100644 gpsdata.pro create mode 100644 gpsdata.svg create mode 100644 qtc_packaging/debian_fremantle/README create mode 100644 qtc_packaging/debian_fremantle/changelog create mode 100644 qtc_packaging/debian_fremantle/compat create mode 100644 qtc_packaging/debian_fremantle/control create mode 100644 qtc_packaging/debian_fremantle/copyright create mode 100755 qtc_packaging/debian_fremantle/rules create mode 100644 src/compass.cpp create mode 100644 src/compass.h create mode 100644 src/gpscompasswindow.cpp create mode 100644 src/gpscompasswindow.h create mode 100644 src/main.cpp create mode 100644 src/mainwindow.cpp create mode 100644 src/mainwindow.h create mode 100644 src/satellitesignalstrength.cpp create mode 100644 src/satellitesignalstrength.h create mode 100644 src/satellitesignalstrengthwindow.cpp create mode 100644 src/satellitesignalstrengthwindow.h create mode 100644 src/satelliteview.cpp create mode 100644 src/satelliteview.h create mode 100644 src/satelliteviewwindow.cpp create mode 100644 src/satelliteviewwindow.h diff --git a/deployment.pri b/deployment.pri new file mode 100644 index 0000000..04b1b16 --- /dev/null +++ b/deployment.pri @@ -0,0 +1,111 @@ +# checksum 0x2939 version 0x20001 +# This file was generated by an application wizard of Qt Creator. +# The code below handles deployment to Symbian and Maemo, aswell as copying +# of the application data to shadow build directories on desktop. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +defineTest(qtcAddDeployment) { +for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemsources = $${item}.sources + $$itemsources = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath= $$eval($${deploymentfolder}.target) + export($$itemsources) + export($$itempath) + DEPLOYMENT += $$item +} + +MAINPROFILEPWD = $$PWD + +symbian { + ICON = $${TARGET}.svg + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -lcone + contains(DEFINES, NETWORKACCESS):TARGET.CAPABILITY += NetworkServices +} else:win32 { + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, /, \\) + sourcePathSegments = $$split(source, \\) + target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) + target = $$replace(target, /, \\) + !isEqual(source,$$target) { + !isEmpty(copyCommand):copyCommand += && + copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } +} else:unix { + maemo5 { + installPrefix = /opt/usr + desktopfile.path = /usr/share/applications/hildon + } else { + installPrefix = /usr/local + desktopfile.path = /usr/share/applications + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, \\, /) + macx { + target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) + } else { + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + } + target = $$replace(target, \\, /) + sourcePathSegments = $$split(source, /) + targetFullPath = $$target/$$last(sourcePathSegments) + !isEqual(source,$$targetFullPath) { + !isEmpty(copyCommand):copyCommand += && + copyCommand += $(MKDIR) \"$$target\" + copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } + } + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + icon.files = $${TARGET}.png + icon.path = /usr/share/icons/hicolor/64x64/apps + desktopfile.files = $${TARGET}.desktop + target.path = $${installPrefix}/bin + export(icon.files) + export(icon.path) + export(desktopfile.files) + export(desktopfile.path) + export(target.path) + INSTALLS += desktopfile icon target +} + +export (ICON) +export (INSTALLS) +export (DEPLOYMENT) +export (TARGET.EPOCHEAPSIZE) +export (TARGET.CAPABILITY) +export (LIBS) +export (QMAKE_EXTRA_TARGETS) +} diff --git a/gpsdata.desktop b/gpsdata.desktop new file mode 100644 index 0000000..2a86584 --- /dev/null +++ b/gpsdata.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=GPSData +Exec=/opt/usr/bin/gpsdata +Icon=gpsdata +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/gpsdata.png b/gpsdata.png new file mode 100644 index 0000000000000000000000000000000000000000..c681b17015c019f39fd3d101edd798128ce3edcd GIT binary patch literal 4162 zcmV-I5WVk-P)eSG&|>;ZfMj2$p0sS|R+A_?8L zNeF5~l-;VkYNb@Gm7?8B+g53|{gO{xDVywStEiV1YNC`)ySrhNZb*R*g%)B%fQE~W z?O@}<#u)7J*q-~$Ip^IEV;egjd&Y#7k&?gk$Y-_oiNGa)k^G$4~Ib&$!`t^Ljt&Qipx_JKhaaNa?&*a4? zCNMfXbGGmI``Nm6D_*ZRUzM;di=LhyPM4dl@}7va@r+Ue`2@&6_vV(9p1?C?AbRIeGFV{r&xm zdQ~pu9Rw}Q!m=!SdwX%0mg0m=-~&9>)pN?)+-{sgU`dHIO*D@O%d+ORSz203Q&SUm zd)DQ}f*2SWpsTA3(=>DHoC|qVK23mWnwV?X&KdumKmIXHv27(1biVrPoP4FJX{P>k zbY8!HJuNLQOETUxP0pM-!};^)NvG3u+FVF-A#V?u?NZ6+W}HG~(tyDJ{fySvQ_<4G z!13e6CMPoZ&mW-c9Q&SVVt}oi_s;bi5+{~s; zn|!(2%i9A?)12c{>c)*Yu3SL^2$6{g(|>14)nkuQ*xXDo7^JeYa!JNUA`$xf`q;E- z6PYau*laeMo11BCYs*@vq@;vXU=f->eZR|9y@l7a5#+1;BIfvc*Yd#vk55w(wCN`%;@MSCr_Rv7K<@HK2Bd> zAH&1Lq|<3W_}~N9uV0Vb?Zz++5{U$fM1p8E%J%Ksi9{lll$6Zr{o&!^oZHhS5%9_A z8)<5yti63^BP0}M4gm#EKABhBQc5~HI_T=^A{-8L@!~~>hK498C}8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ycx&M7pprqHa6Pc-hSc0 zfdd~~mURg@0>pr>Y>|J?d+!ti0E7^wz$!9p_Pc=1cDvo(($Z2@U0v;SyWK9A%jGZ( z!-zy8@lYrfK7IOhU|?V%OeWHw21bAonZUQG@o + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qtc_packaging/debian_fremantle/README b/qtc_packaging/debian_fremantle/README new file mode 100644 index 0000000..9547fe7 --- /dev/null +++ b/qtc_packaging/debian_fremantle/README @@ -0,0 +1,6 @@ +The Debian Package gpsdata +---------------------------- + +Comments regarding the Package + + -- Roman Moravcik Å t, 03 feb 2011 12:38:40 +0100 diff --git a/qtc_packaging/debian_fremantle/changelog b/qtc_packaging/debian_fremantle/changelog new file mode 100644 index 0000000..35f7996 --- /dev/null +++ b/qtc_packaging/debian_fremantle/changelog @@ -0,0 +1,17 @@ +gpsdata (0.3-1) unstable; urgency=low + + * Maemo5: Don't update screen when it's locked. + + -- Roman Moravcik Mon, 28 Mar 2011 13:05:25 +0200 + +gpsdata (0.2-1) unstable; urgency=low + + * Fixed build on symbian target. + + -- Roman Moravcik Tue, 15 Feb 2011 07:59:11 +0100 + +gpsdata (0.1-1) unstable; urgency=low + + * Initial version. + + -- Roman Moravcik Mon, 07 Feb 2011 14:32:29 +0100 diff --git a/qtc_packaging/debian_fremantle/compat b/qtc_packaging/debian_fremantle/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/qtc_packaging/debian_fremantle/compat @@ -0,0 +1 @@ +7 diff --git a/qtc_packaging/debian_fremantle/control b/qtc_packaging/debian_fremantle/control new file mode 100644 index 0000000..03f0d94 --- /dev/null +++ b/qtc_packaging/debian_fremantle/control @@ -0,0 +1,110 @@ +Source: gpsdata +Section: user/navigation +Priority: optional +Maintainer: Roman Moravcik +Build-Depends: debhelper (>= 5), libqt4-dev +Standards-Version: 3.7.3 +Homepage: + +Package: gpsdata +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: A simple GPS status application and compass. + GPSData is an application displaying extended GPS informations (direction, ground + and vertical speeds, magnetic variation, horizontal and vertical accuracies, ...), + current position of GPS satellites on the sky and contains a simple GPS compass. +XB-Maemo-Icon-26: + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgI + fAhkiAAAAAlwSFlzAAAUIgAAFCIBjw1HyAAAABl0RVh0U29mdHdhcmUAd3d3 + Lmlua3NjYXBlLm9yZ5vuPBoAAA+/SURBVHic7ZtrbFTnmcd/77nMfXz3YOwB + fAGMHTAmqRNywSIJ3bZJCGpDlN2qu2qlVKuVot1K21Zptv2ST1spm+xqq6iX + FWqilE27u2GTbkiBDYUWYkOAhouN7WDjwcYY7PHYnvvMOefdD2MbOx57xoSV + kZK/9Mhn3tt5nv/7vM97OxZSSj7LUJZbgeXG5wQstwLLjc8JWG4FlhufE7Dc + Ciw3PidguRVYbnxOwHIrsNz4zBOg5VvwyJEjftM0bdnyurq6Jm6fSgujpKRE + 8/l87nzLq6qa2r59++BiZXISIIQQwPqhoaGzHo/Hnq1MUVERQ0ND+ep1S3C7 + 3TQ2NuJ2520/kUgkKYTYDPTIBba9+XiAZ0oWRF1dHaFQiFgslrdyS4Hf76eu + rg5FyX/EWpbF4ODgBDf1D2crlw8BYrHMSCDAuT17uPynPzE0MEBxRQXFjY0U + f+UrsASFs0HXdRobGyktLV1SvWg0SkdHB8FgcHwqaUEb8o4B2dD2ox+x7+c/ + J5pKIQEpJdbly8i2Nla+9Rb3fPvbuO+775baLi0tpbGxEZsta9hZEFevXqWn + pwfLssjnsCfvLpqcnEzM/v3B97/Pvp/8BJlK4YSMCDHzHAqFOPLSSyQvXEBK + mbcIIVi3bh3Nzc1LMj6dTnP27FkuXryIaZoz7d02As6dOzcSj8cBGG1r4/09 + e24aDriEoHbFClyzSNAsi7Mvv4yc6o1c4nK5aGlpYfXq1XkbDjA2NkZbWxs3 + btyY1+ZtI8AwDOv8+fNI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AnPWCssZENmoY0jAwBU54gAa2uDr2mJme70WiUtrY2gsEgQ0NDfPTRRzgc + Dp566ilaW1vRtJsqTk5OEggEKCgowO/3U1BQQFNTE01NTYyMjNDe3s4vfvEL + ioqK8Pv9t3cdML0Img1T10nU1VHc05MZArPigHPHjpxt9vf38+GHH5JOp+nu + 7ubjjz9m48aNfOtb38LpdJJMJjl06BC9vb109VzhynCKeNqLKpKUeJM0rC2n + traGlpYW1q1bxxNPPMHKlSt5/fXXuXbtGhs2bMgZDW95GoRM5LXv2IH70qV5 + AdDx+OOLtmcYxswmpr+/n56eHh555BG++tWvIoSgs7OTPb98k/OBYrBVoNtX + se3Rarp7R1njL+LK1XE+DIT548Ugb+3fw+4nNrNr1y6am5spLS3lpz/9Ke3t + 7Tl3VrfsAV6vl9bWVsrvvx/lZz9DAtY0AUVFKDkOQjRN44EHHmDv3r1cuHCB + e++9lyeffJJYLMa7777LO4e6maAZf10ZylQ/PrNzE4c/uExFuQchFBRVA4qJ + xtfwm//t40LnP/GNr++mpqaGZ599lldffVXNZdeS9wKWZVFbW8vOnTspKytD + 1tZiq63NrAqnxPboo6DmfDc+n4/R0VFWrVrF7t27MQyDX772Or86GIXih/H7 + V6JqOkLNSDiWpq66DFXTEKo2k+7xuCir3MiFkS289K+/oa+vj8rKSp555pmc + HpA3AaZpoqoqra2tbNu2DV3Xb5KzYwcqGXfSAfKc/k6ePInX6+Xpp59GCMGJ + Eyf4oEPH599EYaELRdPmiBAKh9sHePTBaoSqzcuvWOljTN3KvrffI5FI0NjY + 6HjllVceYJEzwbwJqKysdH7ta1+jrq5uXp4xK+BJRcF8+OGZ36ZMZ23PNE3a + 2tqoqamhvLyckZER9h/+CFnQhN3pQGi2eZI0JDcmDE53jiIVLWuZFRUr6A7W + cOTIEQzD4P777//bwsLCsk9NQGtrq8/jyX46bj74INLlAsC67z5kURFJK8I7 + w99l37W/y1qnr6+PZDLJ2rVrMU2Tw78/yuXoZspKC1BULavs2deDx+3g9Xc+ + Zj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T3UCg09tZbbx07derUaeAAMEHmG8EFz8fvCAIAhBDlwGqg + Cni0urrat3Pnzrtra2trNE3TF6s7NjY22t7efuHAgQMfW5Z1CTgCxICubJF/ + znvvFAIAhBClwCoya/a7gM12u93d0tJSVV1d7XO73S6Xy+UwDMOIRCLxUCgU + Pn36dGBgYCBMJtKfBkaAEJnAt6jxcIcRACCE0AE/mRlHAxrJeEUhmS8+p6fu + BDA2JR+TMdwkY3jWgJf1fXcaAdMQQnjIkFDMzRWrIENCmrmruggQBMYWG+9Z + 33OnEjCNqY+1PWSGhT4lksy6PgnEpZw6arqV9u90Av6/8Zn/h4nPCVhuBZYb + /wd67UkALBo43AAAAABJRU5ErkJggg== + diff --git a/qtc_packaging/debian_fremantle/copyright b/qtc_packaging/debian_fremantle/copyright new file mode 100644 index 0000000..51562b6 --- /dev/null +++ b/qtc_packaging/debian_fremantle/copyright @@ -0,0 +1,38 @@ +This package was debianized by Roman Moravcik on +Å t, 03 feb 2011 12:38:40 +0100. + +It was downloaded from + +Upstream Author(s): + + Roman Moravcik + +Copyright: + + + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This package 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 this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2011, Roman Moravcik and +is licensed under the GPL, see above. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/qtc_packaging/debian_fremantle/rules b/qtc_packaging/debian_fremantle/rules new file mode 100755 index 0000000..6578d53 --- /dev/null +++ b/qtc_packaging/debian_fremantle/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/gpsdata.sgml > gpsdata.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/gpsdata. + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/gpsdata install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + # dh_shlibdeps # Uncomment this line for publishing! + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/src/compass.cpp b/src/compass.cpp new file mode 100644 index 0000000..7636b46 --- /dev/null +++ b/src/compass.cpp @@ -0,0 +1,355 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "compass.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#ifdef Q_WS_MAEMO_5 +#define LABEL_FONT_HIGH 44 +#else +#define LABEL_FONT_HIGH 14 +#endif + +#ifdef Q_WS_MAEMO_5 +#define LABEL_FONT_SMALL 26 +#else +#define LABEL_FONT_SMALL 8 +#endif + +#define GPS_MIN_GROUND_SPEED 1 /* 3.6 km/h */ +#define SENSOR_CALIBRATION_THRESHOLD 0.5 + +#define WIDGET_MARGIN 8 + +void Compass::updateWidget(const int azimuth, double calibration) +{ + m_azimuth = azimuth; + if (m_azimuth == 360) + m_azimuth = 0; + + m_sensorCalibLevel = calibration; + + if (calibration > 0) { + m_locked = true; + + if (m_azimuth != m_compassAzimuth) { + if (m_rotateTimer->isActive()) + m_rotateTimer->stop(); + + m_rotateTimer->start(); + } + } else { + if (calibration == 0) + m_locked = false; + + if (m_rotateTimer->isActive()) + m_rotateTimer->stop(); + + update(); + } +} + +void Compass::updateWidget(const int azimuth, bool locked, int speed) +{ + m_azimuth = azimuth; + if (m_azimuth == 360) + m_azimuth = 0; + + m_locked = locked; + m_gpsSpeed = speed; + + if (speed >= GPS_MIN_GROUND_SPEED) { + if (m_azimuth != m_compassAzimuth) { + if (m_rotateTimer->isActive()) + m_rotateTimer->stop(); + + m_rotateTimer->start(); + } + } else { + if (m_rotateTimer->isActive()) + m_rotateTimer->stop(); + + update(); + } +} + +void Compass::paintEvent(QPaintEvent * /* event */) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + + double widget_width = 0; + double widget_height = 0; + double widget_x = 0; + double widget_y = 0; + + if (rect().width() < rect().height()) { + /* Portrait orientation */ + widget_width = rect().width() - 2 * WIDGET_MARGIN; + widget_height = widget_width; + widget_x = rect().x() + WIDGET_MARGIN; + widget_y = rect().y() + (rect().height() - widget_height) / 2.0; + } else { + /* Landscape orientation */ + widget_height = rect().height() - 2 * WIDGET_MARGIN; + widget_width = widget_height; + widget_x = rect().x() + (rect().width() - widget_width) / 2.0; + widget_y = rect().y() + WIDGET_MARGIN; + } + + /* Draw azimuth/warning */ + paintAzimuth(painter, rect()); + + QMatrix matrix; + matrix.translate(widget_x + widget_width / 2.0, widget_y + widget_height / 2.0); + matrix.rotate(360 - m_compassAzimuth); + painter.setMatrix(matrix); + + /* Draw compass */ + QRectF compassArea(0, 0, widget_width, widget_height); + paintCompass(painter, compassArea); +} + +void Compass::paintAzimuth(QPainter &painter, const QRectF &area) +{ + QFont font = QApplication::font(); + font.setPointSize(LABEL_FONT_SMALL); + painter.setFont(font); + painter.setPen(QApplication::palette().color(QPalette::Text)); + + double azimuth_offset = (area.height() - area.width()) / 4.0 - + painter.fontMetrics().height() + 2.0 * WIDGET_MARGIN; + QRectF azimuthArea(area.x(), area.y() + azimuth_offset, area.width(), painter.fontMetrics().height()); + + if (m_locked) { + QString s; + QChar degree(0x00B0); + + s = QString("%1%2") + .arg(QString::number(m_compassAzimuth)) + .arg(degree); + + if (m_type == Compass::Gps) { + if (m_gpsSpeed < GPS_MIN_GROUND_SPEED) + painter.setPen(m_azimuthLabelWarnColor); + } else if (m_type == Compass::Sensor) { + if (m_sensorCalibLevel < SENSOR_CALIBRATION_THRESHOLD) + painter.setPen(m_azimuthLabelWarnColor); + } + painter.drawText(azimuthArea, Qt::AlignCenter, s); + } else { + if (m_type == Compass::Gps) + painter.drawText(azimuthArea, Qt::AlignCenter, tr("GPS not locked")); + else if (m_type == Compass::Sensor) + painter.drawText(azimuthArea, Qt::AlignCenter, tr("Compass not calibrated")); + } +} + +void Compass::paintCompass(QPainter &painter, const QRectF &area) +{ + double compass_radius = area.width() / 2.0; + double compass_x = area.x() - compass_radius; + double compass_y = area.y() - compass_radius; + + /* Labels */ + QString label[8] = {tr("N"), tr("NE"), tr("E"), tr("SE"), tr("S"), tr("SW"), tr("W"), tr("NW")}; + double label_height = area.height() / 3.6; + double label_offset = area.width() / 14.4; + for (int i = 0; i < 8; i++) { + QFont font = QApplication::font(); + double label_y; + + if ((i % 2) == 0) { + font.setPointSize(LABEL_FONT_HIGH); + label_y = compass_y; + } else { + font.setPointSize(LABEL_FONT_SMALL); + label_y = compass_y + label_offset; + } + QRectF labelArea(compass_x, label_y, area.width(), label_height); + painter.setFont(font); + painter.drawText(labelArea, Qt::AlignCenter, label[i]); + painter.rotate(45); + } + + /* Compass scale */ + QRectF compassArea(compass_x, compass_y, area.width(), area.height()); + painter.setPen(QPen(m_scaleColor, 3)); + painter.drawArc(compassArea, 0, 5760); + + for (int angle = 0; angle < 360; angle += 2) { + double angle_rad = angle * M_PI / 180.0; + + double x1 = (compass_radius - (area.width() / 18.0)) * qCos(angle_rad); + double y1 = (compass_radius - (area.width() / 18.0)) * qSin(angle_rad); + double x2 = compass_radius * qCos(angle_rad); + double y2 = compass_radius * qSin(angle_rad); + + if (angle % 30) + painter.setPen(QPen(m_scaleColor, 0)); + else + painter.setPen(QPen(m_scaleColor, 3)); + + painter.drawLine(QLineF(x1, y1, x2, y2)); + } + + /* Compass windrose NE/SE/SW/NW */ + painter.setPen(m_windroseBckColor); + for (int angle = 45; angle < 360; angle += 90) { + double angle_rad1 = angle * M_PI / 180.0; + double angle_rad2 = (angle - 90) * M_PI / 180.0; + double angle_rad3 = (angle + 90) * M_PI / 180.0; + double temp1 = compass_radius - (area.width() / 3.6); + double temp2 = area.width() / 16.0; + + double x1 = temp1 * qCos(angle_rad1); + double y1 = temp1 * qSin(angle_rad1); + double x2 = temp2 * qCos(angle_rad2); + double y2 = temp2 * qSin(angle_rad2); + double x3 = temp2 * qCos(angle_rad3); + double y3 = temp2 * qSin(angle_rad3); + QPointF triangle1[3] = { QPointF(x1, y1), QPointF(x2, y2), QPointF(area.x(), area.y()) }; + painter.setBrush(m_windroseBckColor); + painter.drawPolygon(triangle1, 3); + + QPointF triangle2[3] = { QPointF(x1, y1), QPointF(x3, y3), QPointF(area.x(), area.y()) }; + painter.setBrush(m_windroseColor); + painter.drawPolygon(triangle2, 3); + } + + /* Compass windrose N/E/S/W */ + for (int angle = 0; angle < 360; angle += 90) { + double angle_rad1 = angle * M_PI / 180.0; + double angle_rad2 = (angle - 45) * M_PI / 180.0; + double angle_rad3 = (angle + 45) * M_PI / 180.0; + double temp1 = compass_radius - (area.width() / 4.5); + double temp2 = area.width() / 16.0; + + double x1 = temp1 * qCos(angle_rad1); + double y1 = temp1 * qSin(angle_rad1); + double x2 = temp2 * qCos(angle_rad2); + double y2 = temp2 * qSin(angle_rad2); + double x3 = temp2 * qCos(angle_rad3); + double y3 = temp2 * qSin(angle_rad3); + QPointF triangle1[3] = { QPointF(x1, y1), QPointF(x2, y2), QPointF(area.x(), area.y()) }; + if (angle == 270) + painter.setBrush(m_windroseNorthColor); + else + painter.setBrush(m_windroseBckColor); + + painter.drawPolygon(triangle1, 3); + + QPointF triangle2[3] = { QPointF(x1, y1), QPointF(x3, y3), QPointF(area.x(), area.y()) }; + painter.setBrush(m_windroseColor); + painter.drawPolygon(triangle2, 3); + } + + /* Red cursor */ + double x1 = area.x() + (area.width() / 12.0); + double y1 = compass_y - 5; + double x2 = area.x() - (area.width() / 12.0); + double y2 = compass_y - 5; + double x3 = area.x(); + double y3 = compass_y + (area.height() / 18.0) - 5; + QPointF triangle[3] = { QPointF(x1, y1), QPointF(x2, y2), QPointF(x3, y3) }; + + painter.rotate(m_compassAzimuth - 360); + painter.setPen(m_windroseNorthColor); + painter.setBrush(m_windroseNorthColor); + painter.drawPolygon(triangle, 3); +} + +void Compass::moveTimerEvent() +{ + if (m_locked) + { + int delta = qAbs(m_azimuth - m_compassAzimuth); + if (delta > 180) + delta = 360 - delta; + + int step = 1; + if (delta > 30) + step = 4; + else if (delta > 20) + step = 3; + else if (delta > 10) + step = 2; + else + step = 1; + + if (m_azimuth > m_compassAzimuth) { + if ((m_azimuth - m_compassAzimuth) < 180) + m_compassAzimuth += step; + else + m_compassAzimuth -= step; + } else { + if ((m_compassAzimuth - m_azimuth) < 180) + m_compassAzimuth -= step; + else + m_compassAzimuth += step; + } + + if (m_compassAzimuth >= 360) + m_compassAzimuth = m_compassAzimuth - 360; + else if (m_compassAzimuth < 0) + m_compassAzimuth = 360 + m_compassAzimuth; + + if (m_azimuth == m_compassAzimuth) + m_rotateTimer->stop(); + } else { + m_rotateTimer->stop(); + } + + update(); +} + +#ifdef QT_NO_OPENGL +Compass::Compass(CompassType type) : QWidget() +#else +Compass::Compass(CompassType type) : QGLWidget(QGLFormat(QGL::SampleBuffers), 0) +#endif +{ + m_type = type; + m_compassAzimuth = 0; + m_azimuth = 0; + m_locked = false; + m_gpsSpeed = 0; + m_sensorCalibLevel = 0; + + m_azimuthLabelWarnColor = QColor(255, 0, 0); + m_scaleColor = QColor(153, 153, 153); + m_windroseNorthColor = QColor(255, 0, 0); + m_windroseColor = QColor(153, 153, 153); + m_windroseBckColor = QColor(74, 69, 66); + + m_rotateTimer = new QTimer(); + m_rotateTimer->setInterval(70); + connect(m_rotateTimer, SIGNAL(timeout()), this, SLOT(moveTimerEvent())); +} + +Compass::~Compass() +{ + if (m_rotateTimer->isActive()) + m_rotateTimer->stop(); +} diff --git a/src/compass.h b/src/compass.h new file mode 100644 index 0000000..f30ea82 --- /dev/null +++ b/src/compass.h @@ -0,0 +1,77 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef COMPASS_H +#define COMPASS_H + +#ifdef QT_NO_OPENGL +#include +#else +#include +#endif +#include + +#ifdef QT_NO_OPENGL +class Compass : public QWidget +#else +class Compass : public QGLWidget +#endif +{ + Q_OBJECT + +public: + enum CompassType + { + Gps = 0, + Sensor = 1 + }; + + Compass(CompassType type); + ~Compass(); + + void updateWidget(const int azimuth, double calibration); + void updateWidget(const int azimuth, bool locked, int speed); + +private slots: + void moveTimerEvent(); + +private: + CompassType m_type; + int m_azimuth; + int m_compassAzimuth; + bool m_locked; + int m_gpsSpeed; + double m_sensorCalibLevel; + + QColor m_azimuthLabelWarnColor; + QColor m_scaleColor; + QColor m_windroseNorthColor; + QColor m_windroseColor; + QColor m_windroseBckColor; + + void paintAzimuth(QPainter &painter, const QRectF &area); + void paintCompass(QPainter &painter, const QRectF &area); + + QTimer *m_rotateTimer; + +protected: + void paintEvent(QPaintEvent *event); +}; + +#endif // GCOMPASS_H diff --git a/src/gpscompasswindow.cpp b/src/gpscompasswindow.cpp new file mode 100644 index 0000000..1dba3b5 --- /dev/null +++ b/src/gpscompasswindow.cpp @@ -0,0 +1,90 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "gpscompasswindow.h" + +GpsCompassWindow::GpsCompassWindow(QWidget *parent) : QMainWindow(parent) +{ + m_screenLocked = false; + + createUi(); + + connect(parent, SIGNAL(screenLocked(bool)), this, SLOT(onScreenLocked(bool))); +} + +GpsCompassWindow::~GpsCompassWindow() +{ + delete m_compass; +} + +void GpsCompassWindow::createUi() +{ +#if defined(Q_OS_SYMBIAN) + setAttribute(Qt::WA_DeleteOnClose); +#elif defined(Q_WS_MAEMO_5) + setAttribute(Qt::WA_Maemo5PortraitOrientation, true); + setAttribute(Qt::WA_Maemo5StackedWindow); + + /* Workaround to show compass widget maximized */ + showMaximized(); +#endif + + setWindowTitle(tr("GPS compass")); + + m_compass = new Compass(Compass::Gps); + setCentralWidget(m_compass); + +#ifdef Q_OS_SYMBIAN + QAction* backSoftkey = new QAction(tr("Back"), this); + backSoftkey->setSoftKeyRole(QAction::NegativeSoftKey); + connect(backSoftkey, SIGNAL(triggered()), this, SLOT(close())); + addAction(backSoftkey); +#endif +} + +void GpsCompassWindow::onScreenLocked(bool locked) +{ + m_screenLocked = locked; +} + +void GpsCompassWindow::onPositionUpdated(const QGeoPositionInfo &position) +{ + if (m_screenLocked) + return; + + if (position.hasAttribute(QGeoPositionInfo::Direction)) { + m_compass->updateWidget(position.attribute(QGeoPositionInfo::Direction), true, + position.attribute(QGeoPositionInfo::GroundSpeed)); + } else { + m_compass->updateWidget(0, false, 0); + } +} + +void GpsCompassWindow::setPositionInfoSource(QGeoPositionInfoSource *positionInfoSource) +{ + m_position = positionInfoSource; + if (m_position) { + connect(m_position, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this, + SLOT(onPositionUpdated(const QGeoPositionInfo &))); + + m_position->requestUpdate(); + } +} diff --git a/src/gpscompasswindow.h b/src/gpscompasswindow.h new file mode 100644 index 0000000..b071c8a --- /dev/null +++ b/src/gpscompasswindow.h @@ -0,0 +1,57 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GPSCOMPASSWINDOW_H +#define GPSCOMPASSWINDOW_H + +#include +#include + +#include + +#include "compass.h" + +QTM_USE_NAMESPACE + +class GpsCompassWindow : public QMainWindow +{ + Q_OBJECT + +public: + GpsCompassWindow(QWidget *parent = 0); + ~GpsCompassWindow(); + + void setPositionInfoSource(QGeoPositionInfoSource *positionInfoSource); + +private slots: + void onScreenLocked(bool locked); + void onPositionUpdated(const QGeoPositionInfo &position); + +private: + void createUi(); + +private: + bool m_screenLocked; + + QGeoPositionInfoSource *m_position; + + Compass *m_compass; +}; + +#endif // GPSCOMPASSWINDOW_H diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..db26e07 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,36 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + MainWindow window; +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) + window.showMaximized(); +#else + window.show(); +#endif + + return app.exec(); +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..892ed58 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,434 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include + +#ifdef Q_OS_SYMBIAN +#include +#include +#include +#include +#endif + +#ifdef Q_WS_MAEMO_5 +#include +#endif + +#include "mainwindow.h" +#include "gpscompasswindow.h" +#include "satelliteviewwindow.h" + +#ifdef Q_OS_SYMBIAN +#include "satellitesignalstrengthwindow.h" +#endif + +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) +{ + m_satellitesInView = 0; + m_satellitesInUse = 0; +#ifdef Q_WS_MAEMO_5 + m_screenLocked = false; +#endif + + m_position = QGeoPositionInfoSource::createDefaultSource(0); + if (m_position) { + connect(m_position, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this, + SLOT(onPositionUpdated(const QGeoPositionInfo &))); + + m_position->setUpdateInterval(3); + m_position->startUpdates(); + } + + m_satellite = QGeoSatelliteInfoSource::createDefaultSource(0); + if (m_satellite) { + connect(m_satellite, SIGNAL(satellitesInViewUpdated(const QList &)), this, + SLOT(onSatellitesInViewUpdated(const QList &))); + connect(m_satellite, SIGNAL(satellitesInUseUpdated(const QList &)), this, + SLOT(onSatellitesInUseUpdated(const QList &))); + + m_satellite->startUpdates(); + } + + createUi(); + createMenu(); + updateUi(); + +#ifdef Q_WS_MAEMO_5 + registerScreenLockMonitor(); +#endif +} + +MainWindow::~MainWindow() +{ + if (m_satellite) { + m_satellite->stopUpdates(); + delete m_satellite; + } + + if (m_position) { + m_position->stopUpdates(); + delete m_position; + } +} +void MainWindow::createUi() +{ + QWidget *widget = new QWidget; + setCentralWidget(widget); + +#ifdef Q_OS_SYMBIAN + const CAknAppUiBase::TAppUiOrientation uiOrientation = CAknAppUi::EAppUiOrientationPortrait; + CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(uiOrientation); + ); + Q_UNUSED(error) +#elif defined(Q_WS_MAEMO_5) + setAttribute(Qt::WA_Maemo5PortraitOrientation, true); + setAttribute(Qt::WA_Maemo5StackedWindow); +#endif + + setWindowTitle(tr("GPSData")); + + QVBoxLayout *mainLayout = new QVBoxLayout(); + widget->setLayout(mainLayout); + + QFormLayout *layout = new QFormLayout(); + layout->setMargin(8); + layout->setSpacing(8); + layout->setLabelAlignment(Qt::AlignLeft); + mainLayout->addLayout(layout); + + m_latitude = new QLabel(); + m_latitude->setDisabled(true); + layout->addRow(tr("Latitude:"), m_latitude); + + m_longitude = new QLabel(); + m_longitude->setDisabled(true); + layout->addRow(tr("Longtitude:"), m_longitude); + + m_accuracy = new QLabel(); + m_accuracy->setDisabled(true); + layout->addRow(tr("Accuracy:"), m_accuracy); + + m_altitude = new QLabel(); + m_altitude->setDisabled(true); + layout->addRow(tr("Altitude:"), m_altitude); + + m_altitudeAccuracy = new QLabel(); + m_altitudeAccuracy->setDisabled(true); + layout->addRow(tr("Altitude accura.:"), m_altitudeAccuracy); + + m_direction = new QLabel(); + m_direction->setDisabled(true); + layout->addRow(tr("Direction:"), m_direction); + + m_magneticDeclination = new QLabel(); + m_magneticDeclination->setDisabled(true); + layout->addRow(tr("Magnetic declin.:"), m_magneticDeclination); + + m_groundSpeed = new QLabel(); + m_groundSpeed->setDisabled(true); + layout->addRow(tr("Ground speed:"), m_groundSpeed); + + m_verticalSpeed = new QLabel(); + m_verticalSpeed->setDisabled(true); + layout->addRow(tr("Vertical speed:"), m_verticalSpeed); + + m_mode = new QLabel(); + m_mode->setDisabled(true); + layout->addRow(tr("Mode:"), m_mode); + + m_time = new QLabel(); + m_time->setDisabled(true); + layout->addRow(tr("GPS Timestamp:"), m_time); + + m_satUsedView = new QLabel(); + m_satUsedView->setDisabled(true); + layout->addRow(tr("Used/View sat.:"), m_satUsedView); + +#ifdef Q_WS_MAEMO_5 + m_satelliteSignalStrength = new SatelliteSignalStrength(); + m_satelliteSignalStrength->showTitle(true); + mainLayout->addWidget(m_satelliteSignalStrength); +#endif +} + +void MainWindow::createMenu() +{ + +#if defined(Q_OS_SYMBIAN) + QAction *menuSoftkey = new QAction(tr("Menu"), this); + menuSoftkey->setSoftKeyRole(QAction::PositiveSoftKey); + addAction(menuSoftkey); + + QMenu *menu = new QMenu(); + menuSoftkey->setMenu(menu); +#else + QMenuBar *menu = new QMenuBar(); + setMenuBar(menu); +#endif + +#ifdef Q_OS_SYMBIAN + QAction *satelliteSignalStrengthAction = new QAction(tr("Signal strength"), this); + menu->addAction(satelliteSignalStrengthAction); + connect(satelliteSignalStrengthAction, SIGNAL(triggered()), this, SLOT(onSatelliteSignalStrengthMenuClicked())); +#endif + + QAction *satelliteViewAction = new QAction(tr("Satellite view"), this); + menu->addAction(satelliteViewAction); + connect(satelliteViewAction, SIGNAL(triggered()), this, SLOT(onSatelliteViewMenuClicked())); + + QAction *gpsCompassAction = new QAction(tr("GPS compass"), this); + menu->addAction(gpsCompassAction); + connect(gpsCompassAction, SIGNAL(triggered()), this, SLOT(onGpsCompassMenuClicked())); +} + + +void MainWindow::updateUi() +{ + /* Don't update if window is not visible */ + if (!isVisible()) + return; + + if (m_positionInfo.isValid()){ + m_latitude->setText(convertCoordinate(m_positionInfo.coordinate().latitude(), LatitudeCoordinate)); + m_longitude->setText(convertCoordinate(m_positionInfo.coordinate().longitude(), LongitudeCoordinate)); + + if ((!qIsNaN(m_positionInfo.coordinate().altitude())) && + (m_positionInfo.coordinate().type() != QGeoCoordinate::InvalidCoordinate)) { + m_altitude->setText(formatLength(m_positionInfo.coordinate().altitude())); + + if (m_positionInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) + m_altitudeAccuracy->setText(formatLength(m_positionInfo.attribute(QGeoPositionInfo::VerticalAccuracy))); + else + m_altitudeAccuracy->clear(); + } else { + m_altitude->clear(); + m_altitudeAccuracy->clear(); + } + + if (m_positionInfo.coordinate().type() == QGeoCoordinate::Coordinate2D) + m_mode->setText("2D"); + else if (m_positionInfo.coordinate().type() == QGeoCoordinate::Coordinate3D) + m_mode->setText("3D"); + else + m_mode->clear(); + + m_time->setText(m_positionInfo.timestamp().toString("dd.MM.yyyy hh:mm:ss")); + + if (m_positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) + m_accuracy->setText(formatLength(m_positionInfo.attribute(QGeoPositionInfo::HorizontalAccuracy))); + else + m_accuracy->clear(); + + if (m_positionInfo.hasAttribute(QGeoPositionInfo::GroundSpeed)) + m_groundSpeed->setText(convertSpeed(m_positionInfo.attribute(QGeoPositionInfo::GroundSpeed))); + else + m_groundSpeed->clear(); + + if (m_positionInfo.hasAttribute(QGeoPositionInfo::VerticalSpeed)) + m_verticalSpeed->setText(convertSpeed(m_positionInfo.attribute(QGeoPositionInfo::VerticalSpeed))); + else + m_verticalSpeed->clear(); + + if (m_positionInfo.hasAttribute(QGeoPositionInfo::Direction)) + m_direction->setText(formatDirection(m_positionInfo.attribute(QGeoPositionInfo::Direction))); + else + m_direction->clear(); + + if (m_positionInfo.hasAttribute(QGeoPositionInfo::MagneticVariation)) + m_magneticDeclination->setText(formatDirection(m_positionInfo.attribute(QGeoPositionInfo::MagneticVariation))); + else + m_magneticDeclination->clear(); + + m_satUsedView->setText(QString::number(m_satellitesInUse) + " / " + QString::number(m_satellitesInView)); + } else { + m_latitude->setText(tr("Waiting for GPS data")); + m_longitude->clear(); + m_accuracy->clear(); + m_altitude->clear(); + m_altitudeAccuracy->clear(); + m_direction->clear(); + m_groundSpeed->clear(); + m_verticalSpeed->clear(); + m_mode->clear(); + m_time->clear(); + m_satUsedView->clear(); + } +} + +QString MainWindow::convertCoordinate(double coordinate, CoordinateType type) const +{ + QString s; + QChar degree(0x00B0); + + double coordinateAbs = qAbs(coordinate); + double coordinateMin = (coordinateAbs - int(coordinateAbs)) * 60; + double coordinateSec = (coordinateMin - int(coordinateMin)) * 60; + + s = QString("%1%2 %3' %4\"") + .arg(QString::number(int(coordinateAbs))) + .arg(degree) + .arg(QString::number(int(coordinateMin))) + .arg(QString::number(coordinateSec, 'f', 3)); + + if (type == LatitudeCoordinate) { + if (coordinate > 0) + s.append(" N"); + else + s.append(" S"); + } else { + if (coordinate > 0) + s.append(" E"); + else + s.append(" W"); + } + + return s; +} + +QString MainWindow::convertSpeed(double speed) const +{ + QString s; + + s.sprintf("%.2f km/h", speed * 3.6); + + return s; +} + +QString MainWindow::formatLength(double length) const +{ + QString s; + + if (length > 10000) + s.sprintf("%.2f km", length / 10000); + else + s.sprintf("%.2f m", length); + + return s; +} + +QString MainWindow::formatDirection(double length) const +{ + QString s; + QChar degree(0x00B0); + + s = QString("%1%2").arg(QString::number(length, 'f', 2)).arg(degree); + + return s; +} + +void MainWindow::onPositionUpdated(const QGeoPositionInfo &position) +{ +#ifdef Q_WS_MAEMO_5 + if (m_screenLocked) + return; +#endif + + if (position.isValid()) { + m_positionInfo = position; + updateUi(); + } +} + +void MainWindow::onSatellitesInViewUpdated(const QList &satellites) +{ +#ifdef Q_WS_MAEMO_5 + if (m_screenLocked) + return; + + m_satelliteSignalStrength->updateWidget(satellites, false); +#endif + m_satellitesInView = satellites.count(); + updateUi(); +} + +void MainWindow::onSatellitesInUseUpdated(const QList &satellites) +{ +#ifdef Q_WS_MAEMO_5 + if (m_screenLocked) + return; + + m_satelliteSignalStrength->updateWidget(satellites, true); +#endif + m_satellitesInUse = satellites.count(); + updateUi(); +} + +#ifdef Q_OS_SYMBIAN +void MainWindow::satelliteSignalStrengthMenuClicked() +{ + SatelliteSignalStrengthWindow *satelliteSignalStrengthWindow = new SatelliteSignalStrengthWindow(this); + satelliteSignalStrengthWindow->setSatelliteInfoSource(m_satellite); + satelliteSignalStrengthWindow->showMaximized(); +} +#endif + +void MainWindow::onSatelliteViewMenuClicked() +{ + SatelliteViewWindow *satelliteViewWindow = new SatelliteViewWindow(this); + satelliteViewWindow->setSatelliteInfoSource(m_satellite); +#if defined(Q_OS_SYMBIAN) + satelliteViewWindow->showMaximized(); +#elif defined(Q_WS_MAEMO_5) + satelliteViewWindow->show(); +#endif +} + +void MainWindow::onGpsCompassMenuClicked() +{ + GpsCompassWindow *gpsCompassWindow = new GpsCompassWindow(this); + gpsCompassWindow->setPositionInfoSource(m_position); +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) + gpsCompassWindow->showMaximized(); +#else + gpsCompassWindow->show(); +#endif +} + +#ifdef Q_WS_MAEMO_5 +void MainWindow::registerScreenLockMonitor() +{ + QDBusConnection::systemBus().connect("", + "/com/nokia/mce/signal", + "com.nokia.mce.signal", + "tklock_mode_ind", + this, + SLOT(onScreenLocked(QString))); +} + +void MainWindow::onScreenLocked(QString state) +{ + bool locked; + + if(state == "unlocked") + locked = false; + else + locked = true; + + if (m_screenLocked != locked) { + m_screenLocked = locked; + emit screenLocked(m_screenLocked); + } +} +#endif diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..8930707 --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,115 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef Q_WS_MAEMO_5 +#include "satellitesignalstrength.h" +#endif + +QTM_USE_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + enum CoordinateType + { + LatitudeCoordinate = 0, + LongitudeCoordinate = 1 + }; + + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +signals: + void screenLocked(bool locked); + +private slots: + void onPositionUpdated(const QGeoPositionInfo &position); + + void onSatellitesInViewUpdated(const QList &satellites); + void onSatellitesInUseUpdated(const QList &satellites); + +#ifdef Q_OS_SYMBIAN + void onSatelliteSignalStrengthMenuClicked(); +#endif + void onSatelliteViewMenuClicked(); + void onGpsCompassMenuClicked(); + +#ifdef Q_WS_MAEMO_5 + void onScreenLocked(QString state); +#endif + +private: + void createUi(); + void updateUi(); + + void createMenu(); + +#ifdef Q_WS_MAEMO_5 + void registerScreenLockMonitor(); +#endif + + QString convertCoordinate(double speed, CoordinateType type) const; + QString convertSpeed(double speed) const; + QString formatLength(double length) const; + QString formatDirection(double length) const; + +private: + QGeoPositionInfoSource *m_position; + QGeoSatelliteInfoSource *m_satellite; + + QGeoPositionInfo m_positionInfo; + int m_satellitesInView; + int m_satellitesInUse; + + QLabel *m_latitude; + QLabel *m_longitude; + QLabel *m_accuracy; + QLabel *m_altitude; + QLabel *m_altitudeAccuracy; + QLabel *m_direction; + QLabel *m_magneticDeclination; + QLabel *m_groundSpeed; + QLabel *m_verticalSpeed; + QLabel *m_mode; + QLabel *m_time; + QLabel *m_satUsedView; + +#ifdef Q_WS_MAEMO_5 + SatelliteSignalStrength *m_satelliteSignalStrength; + + bool m_screenLocked; +#endif +}; + +#endif // MAINWINDOW_H diff --git a/src/satellitesignalstrength.cpp b/src/satellitesignalstrength.cpp new file mode 100644 index 0000000..948b70a --- /dev/null +++ b/src/satellitesignalstrength.cpp @@ -0,0 +1,150 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "satellitesignalstrength.h" + +void SatelliteSignalStrength::updateWidget(const QList &satellites, bool inUseList) +{ + if (inUseList) + m_satellitesInUse = satellites; + else + m_satellitesInView = satellites; + + update(); +} + +void SatelliteSignalStrength::showTitle(bool show) +{ + m_showTitle = show; +} + +void SatelliteSignalStrength::paintEvent(QPaintEvent * /* event */) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + + int title_height = 0; + if (m_showTitle) { + int title_x = rect().x() + m_margin; + int title_y = rect().y() + m_margin; + int title_width = rect().width() - (2 * m_margin); + title_height = painter.fontMetrics().height(); + QRectF titleArea(title_x, title_y, title_width, title_height); + + /* Draw title */ + paintTitle(painter, titleArea); + } + + /* Signal strength graph */ + int graph_x = rect().x(); + int graph_y = rect().y() + title_height + m_spacing; + int graph_width = rect().width(); + int graph_height = rect().height() - title_height - m_spacing; + QRectF graphArea(graph_x, graph_y, graph_width, graph_height); + + /* Signal strength bar graphs */ + for (int index = 1; index <= m_numOfSatellites; ++index) { + paintBarGraph(painter, graphArea, index); + } +} + +void SatelliteSignalStrength::paintTitle(QPainter &painter, const QRectF &area) +{ + painter.setPen(QApplication::palette().color(QPalette::Text)); + painter.drawText(area, Qt::AlignLeft, tr("Signal strength:")); +} + +void SatelliteSignalStrength::paintBarGraph(QPainter &painter, const QRectF &area, int index) +{ + /* Bar graph backround */ + double barGraphBackground_x; + double barGraphBackground_y; + double barGraphBackground_width = (double) (area.width() - (2.0 * m_margin) - + (m_spacing * (m_numOfSatellitesInRow - 1))) / (double) m_numOfSatellitesInRow; + double barGraphBackground_height = (double) (area.height() - (2.0 * m_margin) - + (2.0 * m_spacing)) / (double) m_numOfRows; + + if (index <= m_numOfSatellitesInRow) { + barGraphBackground_x = area.x() + m_margin + + ((index - 1) * (barGraphBackground_width + m_spacing)); + barGraphBackground_y = area.y() + m_margin; + } else { + barGraphBackground_x = area.x() + m_margin + + (((index - 1) - m_numOfSatellitesInRow) * (barGraphBackground_width + m_spacing)); + barGraphBackground_y = area.y() + m_margin + (2.0 * m_spacing) + barGraphBackground_height; + } + QRectF barGraphBackgroundArea(barGraphBackground_x, barGraphBackground_y, + barGraphBackground_width, barGraphBackground_height); + + painter.setPen(m_barGraphBorderColor); + painter.setBrush(m_barGraphBackgroundColor); + painter.drawRect(barGraphBackgroundArea); + + bool inUse = false; + int signalStrength = 0; + + for (int iter = 0; iter < m_satellitesInView.count(); iter++) { + if (m_satellitesInView.at(iter).prnNumber() == index) { + signalStrength = m_satellitesInView.at(iter).signalStrength(); + break; + } + } + for (int iter = 0; iter < m_satellitesInUse.count(); iter++) { + if (m_satellitesInUse.at(iter).prnNumber() == index) { + signalStrength = m_satellitesInUse.at(iter).signalStrength(); + inUse = true; + break; + } + } + + if (signalStrength > 0) { + if (inUse) { + painter.setPen(m_barGraphInUseColor); + painter.setBrush(m_barGraphInUseColor); + } else { + painter.setPen(m_barGraphInViewColor); + painter.setBrush(m_barGraphInViewColor); + } + + double level_width = barGraphBackground_width - 2.0; + double level_height = (double) signalStrength * (barGraphBackground_height - 2.0) / 100.0; + double level_x = barGraphBackground_x + 1.0; + double level_y = barGraphBackground_y + barGraphBackground_height - level_height - 1.0; + + QRectF barGraphLevelArea(level_x, level_y, level_width, level_height); + painter.drawRect(barGraphLevelArea); + } + + /* Satellite's PRN must be painter over the level bar */ + QFont font = QApplication::font(); + font.setPixelSize(12); + painter.setFont(font); + painter.setPen(QApplication::palette().color(QPalette::Text)); + painter.drawText(barGraphBackgroundArea, Qt::AlignCenter, QString::number(index)); +} + +SatelliteSignalStrength::SatelliteSignalStrength(QWidget *parent) : QWidget(parent) +{ + m_barGraphBorderColor = QColor(0, 0, 0); + m_barGraphBackgroundColor = QColor(74, 69, 66); + m_barGraphInViewColor = QColor(153, 153, 153); + m_barGraphInUseColor = QColor(51, 191, 51); +} diff --git a/src/satellitesignalstrength.h b/src/satellitesignalstrength.h new file mode 100644 index 0000000..eadcafb --- /dev/null +++ b/src/satellitesignalstrength.h @@ -0,0 +1,62 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SATELLITESIGNALSTRENGTH_H +#define SATELLITESIGNALSTRENGTH_H + +#include + +#include + +QTM_USE_NAMESPACE + +class SatelliteSignalStrength : public QWidget +{ + Q_OBJECT + +public: + SatelliteSignalStrength(QWidget *parent = 0); + + void updateWidget(const QList &satellites, bool inUseList); + void showTitle(bool show); + +private: + bool m_showTitle; + static const int m_margin = 8; + static const int m_spacing = 8; + static const int m_numOfSatellites = 32; + static const int m_numOfRows = 2; + static const int m_numOfSatellitesInRow = m_numOfSatellites / m_numOfRows; + + QColor m_barGraphBorderColor; + QColor m_barGraphBackgroundColor; + QColor m_barGraphInViewColor; + QColor m_barGraphInUseColor; + + QList m_satellitesInView; + QList m_satellitesInUse; + + void paintTitle(QPainter &painter, const QRectF &area); + void paintBarGraph(QPainter &painter, const QRectF &area, int index); + +protected: + void paintEvent(QPaintEvent *event); +}; + +#endif // SATELLITESIGNALSTRENGTH_H diff --git a/src/satellitesignalstrengthwindow.cpp b/src/satellitesignalstrengthwindow.cpp new file mode 100644 index 0000000..8265e54 --- /dev/null +++ b/src/satellitesignalstrengthwindow.cpp @@ -0,0 +1,83 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "satellitesignalstrengthwindow.h" + +#ifdef Q_OS_SYMBIAN +SatelliteSignalStrengthWindow::SatelliteSignalStrengthWindow(QWidget *parent) : QMainWindow(parent) +{ + m_screenLocked = false; + + createUi(); + + connect(parent, SIGNAL(screenLocked(bool)), this, SLOT(onScreenLocked(bool))); +} + +void SatelliteSignalStrengthWindow::createUi() +{ + setAttribute(Qt::WA_DeleteOnClose); + + setWindowTitle(tr("Signal strength")); + + m_satelliteSignalStrength = new SatelliteSignalStrength(); + m_satelliteSignalStrength->showTitle(false); + setCentralWidget(m_satelliteSignalStrength); + + QAction* backSoftkey = new QAction(tr("Back"), this); + backSoftkey->setSoftKeyRole(QAction::NegativeSoftKey); + connect(backSoftkey, SIGNAL(triggered()), this, SLOT(close())); + addAction(backSoftkey); +} + +void SatelliteSignalStrengthWindow::onScreenLocked(bool locked) +{ + m_screenLocked = locked; +} + +void SatelliteSignalStrengthWindow::onSatellitesInViewUpdated(const QList &satellites) +{ + if (m_screenLocked) + return; + + m_satelliteSignalStrength->updateWidget(satellites, false); +} + +void SatelliteSignalStrengthWindow::onSatellitesInUseUpdated(const QList &satellites) +{ + if (m_screenLocked) + return; + + m_satelliteSignalStrength->updateWidget(satellites, true); +} + +void SatelliteSignalStrengthWindow::setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource) +{ + m_satellite = satelliteInfoSource; + if (m_satellite) { + connect(m_satellite, SIGNAL(satellitesInViewUpdated(const QList &)), this, + SLOT(onSatellitesInViewUpdated(const QList &))); + connect(m_satellite, SIGNAL(satellitesInUseUpdated(const QList &)), this, + SLOT(onSatellitesInUseUpdated(const QList &))); + + m_satellite->requestUpdate(); + } +} +#endif diff --git a/src/satellitesignalstrengthwindow.h b/src/satellitesignalstrengthwindow.h new file mode 100644 index 0000000..60b88de --- /dev/null +++ b/src/satellitesignalstrengthwindow.h @@ -0,0 +1,61 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SATELLITESIGNALSTRENGTHWINDOW_H +#define SATELLITESIGNALSTRENGTHWINDOW_H + +#include +#include + +#include + +#include "satellitesignalstrength.h" + +QTM_USE_NAMESPACE + +#ifdef Q_OS_SYMBIAN + +class SatelliteSignalStrengthWindow : public QMainWindow +{ + Q_OBJECT + +public: + SatelliteSignalStrengthWindow(QWidget *parent = 0); + + void setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource); + +private slots: + void onScreenLocked(bool locked); + void onSatellitesInViewUpdated(const QList &satellites); + void onSatellitesInUseUpdated(const QList &satellites); + +private: + void createUi(); + +private: + bool m_screenLocked; + + QGeoSatelliteInfoSource *m_satellite; + + SatelliteSignalStrength *m_satelliteSignalStrength; +}; + +#endif + +#endif // SATELLITESIGNALSTRENGTHWINDOW_H diff --git a/src/satelliteview.cpp b/src/satelliteview.cpp new file mode 100644 index 0000000..b90822f --- /dev/null +++ b/src/satelliteview.cpp @@ -0,0 +1,196 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "satelliteview.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +void SatelliteView::updateWidget(const QList &satellites, bool inUseList) +{ + if (inUseList) + m_satellitesInUse = satellites; + else + m_satellitesInView = satellites; + + update(); +} + +void SatelliteView::paintEvent(QPaintEvent * /* event */) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + + double widget_width = 0; + double widget_height = 0; + double widget_x = 0; + double widget_y = 0; + + if (rect().width() < rect().height()) { + /* Portrait orientation */ + widget_width = rect().width() - (2 * m_margin); + widget_height = widget_width; + widget_x = rect().x() + m_margin; + widget_y = rect().y() + (rect().height() - widget_height) / 2.0; + } else { + /* Landscape orientation */ + widget_height = rect().height() - (2 * m_margin); + widget_width = widget_height; + widget_x = rect().x() + (rect().width() - widget_width) / 2.0; + widget_y = rect().y() + m_margin; + } + QRectF widgetArea(widget_x, widget_y, widget_width, widget_height); + + /* Draw N/E/S/W labels */ + paintLabels(painter, widgetArea); + + int label_height = painter.fontMetrics().height(); + int label_width = label_height; + double grid_x = widget_x + m_margin + label_width; + double grid_y = widget_y + m_margin + label_height; + double grid_width = widget_width - (2 * m_margin) - (2 * label_width); + double grid_height = widget_height - (2 * m_margin) - (2 * label_height); + QRectF gridArea(grid_x, grid_y, grid_width, grid_height); + + /* Draw grid */ + paintGrid(painter, gridArea); + + /* Draw satellites in view */ + for (int index = 1; index <= m_numOfSatellites; ++index) { + paintSatellite(painter, gridArea, index); + } +} + +void SatelliteView::paintLabels(QPainter &painter, const QRectF &area) +{ + int label_height = painter.fontMetrics().height(); + int label_width = label_height; + + painter.setPen(QApplication::palette().color(QPalette::Text)); + + /* "North" label */ + QRect northLabel(area.x(), area.y(), area.width(), label_height); + painter.drawText(northLabel, Qt::AlignCenter, tr("N")); + + /* "South" label */ + QRect southLabel(area.x(), area.y() + area.height() - label_height, area.width(), label_height); + painter.drawText(southLabel, Qt::AlignCenter, tr("S")); + + /* "West" label */ + QRect westLabel(area.x(), area.y(), label_width, area.height()); + painter.drawText(westLabel, Qt::AlignCenter, tr("W")); + + /* "East" label */ + QRect eastLabel(area.x() + area.width() - label_width, area.y(), label_width, area.height()); + painter.drawText(eastLabel, Qt::AlignCenter, tr("E")); +} + +void SatelliteView::paintGrid(QPainter &painter, const QRectF &area) +{ + painter.setPen(m_graphGridColor); + for (int i = 0; i < 3; i++) { + double grid_width = area.width() * (3.0 - i) / 3.0; + double grid_height = area.height() * (3.0 - i) / 3.0; + double grid_x = area.x() + (area.width() * i / 6.0); + double grid_y = area.y() + (area.height() * i / 6.0); + + QRectF gridArea(grid_x, grid_y, grid_width, grid_height); + painter.drawArc(gridArea, 0, 5760); + } + + /* Grid */ + painter.drawLine(area.x(), area.y() + area.height() / 2.0, area.x() + area.width(), area.y() + area.height() / 2.0); + painter.drawLine(area.x() + area.width() / 2.0, area.y(), area.x() + area.width() / 2.0, area.y() + area.height()); + +} + +void SatelliteView::paintSatellite(QPainter &painter, const QRectF &area, int index) +{ + double center_x = area.x() + (double) area.width() / 2.0; + double center_y = area.y() + (double) area.height() / 2.0; + + bool inUse = false; + int satelliteElevation = -1; + int satelliteAzimuth = 0; + for (int iter = 0; iter < m_satellitesInView.count(); iter++) { + if (m_satellitesInView.at(iter).prnNumber() == index) { + if (m_satellitesInView.at(iter).hasAttribute(QGeoSatelliteInfo::Elevation)) + satelliteElevation = m_satellitesInView.at(iter).attribute(QGeoSatelliteInfo::Elevation); + + if (m_satellitesInView.at(iter).hasAttribute(QGeoSatelliteInfo::Azimuth)) + satelliteAzimuth = m_satellitesInView.at(iter).attribute(QGeoSatelliteInfo::Azimuth); + break; + } + } + for (int iter = 0; iter < m_satellitesInUse.count(); iter++) { + if (m_satellitesInUse.at(iter).prnNumber() == index) { + inUse = true; + break; + } + } + + /* Display only visible satellites */ + if (satelliteElevation >= 0) { + int satellite_width = 30; + int satellite_height = 30; + double temp = (180 - satelliteElevation) * (double) area.width() / 360.0; + double satellite_x = temp * qCos((satelliteAzimuth - 90) * M_PI / 180.0) + + center_x - (double) (satellite_width / 2.0); + double satellite_y = temp * qSin((satelliteAzimuth - 90) * M_PI / 180.0) + + center_y - (double) (satellite_height / 2.0); + QRectF satelliteArea(satellite_x, satellite_y, satellite_width, satellite_height); + + /* Draw a small circle with PRN number inside */ + painter.setPen(m_satelliteBorderColor); + if (inUse) + painter.setBrush(m_satelliteInUseColor); + else + painter.setBrush(m_satellitehInViewColor); + painter.drawChord(satelliteArea, 0, 5760); + + int panel_width = 10; + painter.setBrush(m_satelliteSolarPanelColor); + QRectF solarPanelLArea(satellite_x - panel_width, satellite_y, + panel_width, satellite_height); + painter.drawRect(solarPanelLArea); + + QRectF solarPanelRArea(satellite_x + satellite_width, satellite_y, + panel_width, satellite_height); + painter.drawRect(solarPanelRArea); + + /* Satellite's PRN must be painter over the satellite circle */ + QFont font = QApplication::font(); + font.setPixelSize(12); + painter.setFont(font); + painter.setPen(m_satelliteBorderColor); + painter.drawText(satelliteArea, Qt::AlignCenter, QString::number(index)); + } +} + +SatelliteView::SatelliteView(QWidget *parent) : QWidget(parent) +{ + m_graphGridColor = QColor(74, 69, 66); + m_satelliteBorderColor = QColor(0, 0, 0); + m_satelliteSolarPanelColor = QColor(0, 75, 255); + m_satellitehInViewColor = QColor(153, 153, 153); + m_satelliteInUseColor = QColor(51, 191, 51); +} diff --git a/src/satelliteview.h b/src/satelliteview.h new file mode 100644 index 0000000..d4f1387 --- /dev/null +++ b/src/satelliteview.h @@ -0,0 +1,59 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SATELLITEVIEW_H +#define SATELLITEVIEW_H + +#include + +#include + +QTM_USE_NAMESPACE + +class SatelliteView : public QWidget +{ + Q_OBJECT + +public: + SatelliteView(QWidget *parent = 0); + + void updateWidget(const QList &satellites, bool inUseList); + +private: + static const int m_margin = 8; + static const int m_numOfSatellites = 32; + + QColor m_graphGridColor; + QColor m_satelliteBorderColor; + QColor m_satelliteSolarPanelColor; + QColor m_satellitehInViewColor; + QColor m_satelliteInUseColor; + + QList m_satellitesInView; + QList m_satellitesInUse; + + void paintLabels(QPainter &painter, const QRectF &area); + void paintGrid(QPainter &painter, const QRectF &area); + void paintSatellite(QPainter &painter, const QRectF &area, int index); + +protected: + void paintEvent(QPaintEvent *event); +}; + +#endif // SATELLITEVIEW_H diff --git a/src/satelliteviewwindow.cpp b/src/satelliteviewwindow.cpp new file mode 100644 index 0000000..c0cdcdf --- /dev/null +++ b/src/satelliteviewwindow.cpp @@ -0,0 +1,90 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "satelliteviewwindow.h" + +SatelliteViewWindow::SatelliteViewWindow(QWidget *parent) : QMainWindow(parent) +{ + m_screenLocked = false; + + createUi(); + + connect(parent, SIGNAL(screenLocked(bool)), this, SLOT(onScreenLocked(bool))); +} + +void SatelliteViewWindow::createUi() +{ +#if defined(Q_OS_SYMBIAN) + setAttribute(Qt::WA_DeleteOnClose); +#elif defined(Q_WS_MAEMO_5) + setAttribute(Qt::WA_Maemo5PortraitOrientation, true); + setWindowFlags(Qt::Dialog); +#endif + + setWindowTitle(tr("Satellite view")); + + m_satelliteView = new SatelliteView(); +#ifdef Q_WS_MAEMO_5 + m_satelliteView->setMinimumSize(480, 480); +#endif + setCentralWidget(m_satelliteView); + +#ifdef Q_OS_SYMBIAN + QAction* backSoftkey = new QAction(tr("Back"), this); + backSoftkey->setSoftKeyRole(QAction::NegativeSoftKey); + connect(backSoftkey, SIGNAL(triggered()), this, SLOT(close())); + addAction(backSoftkey); +#endif +} + +void SatelliteViewWindow::onScreenLocked(bool locked) +{ + m_screenLocked = locked; +} + +void SatelliteViewWindow::onSatellitesInViewUpdated(const QList &satellites) +{ + if (m_screenLocked) + return; + + m_satelliteView->updateWidget(satellites, false); +} + +void SatelliteViewWindow::onSatellitesInUseUpdated(const QList &satellites) +{ + if (m_screenLocked) + return; + + m_satelliteView->updateWidget(satellites, true); +} + +void SatelliteViewWindow::setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource) +{ + m_satellite = satelliteInfoSource; + if (m_satellite) { + connect(m_satellite, SIGNAL(satellitesInViewUpdated(const QList &)), this, + SLOT(onSatellitesInViewUpdated(const QList &))); + connect(m_satellite, SIGNAL(satellitesInUseUpdated(const QList &)), this, + SLOT(onSatellitesInUseUpdated(const QList &))); + + m_satellite->requestUpdate(); + } +} diff --git a/src/satelliteviewwindow.h b/src/satelliteviewwindow.h new file mode 100644 index 0000000..b942b15 --- /dev/null +++ b/src/satelliteviewwindow.h @@ -0,0 +1,57 @@ +/* + * GPSData for Maemo. + * Copyright (C) 2011 Roman Moravcik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SATELLITEVIEWWINDOW_H +#define SATELLITEVIEWWINDOW_H + +#include +#include + +#include + +#include "satelliteview.h" + +QTM_USE_NAMESPACE + +class SatelliteViewWindow : public QMainWindow +{ + Q_OBJECT + +public: + SatelliteViewWindow(QWidget *parent = 0); + + void setSatelliteInfoSource(QGeoSatelliteInfoSource *satelliteInfoSource); + +private slots: + void onScreenLocked(bool locked); + void onSatellitesInViewUpdated(const QList &satellites); + void onSatellitesInUseUpdated(const QList &satellites); + +private: + void createUi(); + +private: + bool m_screenLocked; + + QGeoSatelliteInfoSource *m_satellite; + + SatelliteView *m_satelliteView; +}; + +#endif // SATELLITEVIEWWINDOW_H -- 1.7.9.5