--- /dev/null
+[gerrit]
+host=gerrit.automotivelinux.org
+port=29418
+project=apps/navigation
+defaultbranch=master
\r
Item {\r
Button {\r
- id: btn_enlarge\r
width: 100\r
height: 100\r
\r
- function doSomething() {\r
- // ...\r
+ function zoomUp() {\r
+ map.zoomLevel += 1\r
}\r
\r
- onClicked: { doSomething() }\r
+ onClicked: { zoomUp() }\r
\r
Image {\r
id: image\r
height: 92\r
anchors.verticalCenter: parent.verticalCenter\r
anchors.horizontalCenter: parent.horizontalCenter\r
- source: "images/Enlarge_button.bmp"\r
+ source: "images/240px-Antu_kdenlive-zoom-large.svg.png"\r
}\r
}\r
}\r
--- /dev/null
+import QtQuick 2.0\r
+import QtQuick.Controls 1.5\r
+import QtLocation 5.9\r
+import QtPositioning 5.6\r
+\r
+Item {\r
+ id: btn_guidance\r
+\r
+ // 0: idle\r
+ // 1: routing\r
+ // 2: on guide\r
+ property int sts_guide: 0\r
+\r
+ onSts_guideChanged: {\r
+ console.log("onSts_guideChanged")\r
+ switch(btn_guidance.sts_guide){\r
+ case 0:\r
+ positionTimer.stop();\r
+ break\r
+ case 1:\r
+ break\r
+ case 2:\r
+ positionTimer.start();\r
+ break\r
+ default:\r
+ break\r
+ }\r
+ }\r
+\r
+ function startGuidance() {\r
+ btn_present_position.state = "Flowing"\r
+ btn_guidance.sts_guide = 2\r
+ btn_guidance.state = "onGuide"\r
+ }\r
+\r
+ function discardWaypoints() {\r
+ map.initDestination()\r
+\r
+ if(btn_guidance.sts_guide != 0){\r
+ map.qmlSignalStopDemo()\r
+ }\r
+\r
+ if(map.center !== map.currentpostion){\r
+ btn_present_position.state = "Optional"\r
+ }\r
+\r
+ btn_guidance.sts_guide = 0\r
+ btn_guidance.state = "Idle"\r
+ }\r
+\r
+ Timer {\r
+ id: positionTimer\r
+ interval: fileOperation.getInterval() // set millisecond\r
+ running: false\r
+ repeat: true\r
+ onTriggered: map.updatePositon()\r
+ }\r
+\r
+ Button {\r
+ id: discard\r
+ width: 100\r
+ height: 100\r
+\r
+ visible: false\r
+\r
+ onClicked: discardWaypoints()\r
+\r
+ Image {\r
+ id: discard_image\r
+ width: 92\r
+ height: 92\r
+ anchors.verticalCenter: parent.verticalCenter\r
+ anchors.horizontalCenter: parent.horizontalCenter\r
+ source: "images/200px-Black_close_x.svg.png"\r
+ }\r
+ }\r
+\r
+ Button {\r
+ id: guidance\r
+ width: 100\r
+ height: 100\r
+\r
+ visible: false\r
+\r
+ onClicked: { startGuidance() }\r
+\r
+ Image {\r
+ id: guidance_image\r
+ width: 92\r
+ height: 92\r
+ anchors.verticalCenter: parent.verticalCenter\r
+ anchors.horizontalCenter: parent.horizontalCenter\r
+ source: "images/124px-Pictograms-nps-land-driving_tour-2.svg.png"\r
+ }\r
+\r
+ }\r
+ states: [\r
+ State {\r
+ name: "Idle"\r
+ PropertyChanges { target: discard; visible: false }\r
+ PropertyChanges { target: guidance; visible: false }\r
+ PropertyChanges { target: guidance; x: 0 }\r
+ PropertyChanges { target: progress_next_cross; state: "invisible" }\r
+ PropertyChanges { target: img_destination_direction; state: "invisible" }\r
+ },\r
+ State {\r
+ name: "Routing"\r
+ PropertyChanges { target: discard; visible: true }\r
+ PropertyChanges { target: guidance; visible: true }\r
+ PropertyChanges { target: guidance; x: -150 }\r
+ PropertyChanges { target: progress_next_cross; state: "invisible" }\r
+ PropertyChanges { target: img_destination_direction; state: "invisible" }\r
+ },\r
+ State {\r
+ name: "onGuide"\r
+ PropertyChanges { target: discard; visible: true }\r
+ PropertyChanges { target: guidance; visible: false }\r
+ PropertyChanges { target: guidance; x: 0 }\r
+ PropertyChanges { target: progress_next_cross; state: "visible" }\r
+ PropertyChanges { target: img_destination_direction; state: "0" }\r
+ }\r
+ ]\r
+\r
+ transitions: Transition {\r
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }\r
+ NumberAnimation { properties: "visible"; easing.type: Easing.InOutQuad }\r
+ }\r
+}\r
import QtQuick.Controls 1.5\r
\r
Item {\r
- Button {\r
+ Button {\r
id: btn_map_direction\r
width: 100\r
height: 100\r
\r
function settleState() {\r
- if(btn_map_direction.state == "HeadingUp"){\r
- btn_map_direction.state = "NorthUp";\r
+ if(root.st_heading_up){\r
+ btn_map_direction.state = "NorthUp"\r
+ car_position_mapitem.state = "NorthUp"\r
+ root.st_heading_up = false\r
} else {\r
- btn_map_direction.state = "HeadingUp";\r
+ btn_map_direction.state = "HeadingUp"\r
+ car_position_mapitem.state = "HeadingUp"\r
+ root.st_heading_up = true\r
}\r
- }\r
+ map.rotateMapSmooth()\r
+ }\r
\r
onClicked: { settleState() }\r
\r
height: 92\r
anchors.verticalCenter: parent.verticalCenter\r
anchors.horizontalCenter: parent.horizontalCenter\r
- source: "images/Direction_Hup.jpeg"\r
+ source: "images/202px-Compass-icon_bb_N.svg.png"\r
}\r
\r
states: [\r
State {\r
name: "HeadingUp"\r
- PropertyChanges { target: image; source: "images/Direction_Hup.jpeg" }\r
+ PropertyChanges { target: image; source: "images/240px-Compass_icon_NE.svg.png" }\r
},\r
State {\r
name: "NorthUp"\r
- PropertyChanges { target: image; source: "images/Direction_Nup.jpeg" }\r
- }\r
+ PropertyChanges { target: image; source: "images/202px-Compass-icon_bb_N.svg.png" }\r
+ }\r
]\r
- }\r
+ }\r
}\r
import QtQuick.Controls 1.5\r
\r
Item {\r
- Button {\r
- id: btn_present_position\r
+ id: btn_present_position\r
+\r
+ Button {\r
+ id: btn_present_position_\r
width: 100\r
height: 100\r
+ visible: false\r
\r
- function doSomething() {\r
- // ...\r
- }\r
+ function present_position_clicked() {\r
+ map.center = map.currentpostion\r
+// map.zoomLevel = root.default_zoom_level\r
+ btn_present_position.state = "Flowing"\r
+ }\r
+ onClicked: { present_position_clicked() }\r
\r
- onClicked: { doSomething() }\r
+ Image {\r
+ id: image_present_position\r
+ width: 48\r
+ height: 92\r
+ anchors.verticalCenter: parent.verticalCenter\r
+ anchors.horizontalCenter: parent.horizontalCenter\r
+ source: "images/207px-Car_icon_top.svg.png"\r
+ }\r
+ }\r
+ states: [\r
+ State{\r
+ name: "Flowing"\r
+ PropertyChanges { target: btn_present_position_; visible: false }\r
+ },\r
+ State{\r
+ name: "Optional"\r
+ PropertyChanges { target: btn_present_position_; visible: true }\r
+ }\r
+ ]\r
\r
- Image {\r
- id: image\r
- width: 92\r
- height: 92\r
- anchors.verticalCenter: parent.verticalCenter\r
- anchors.horizontalCenter: parent.horizontalCenter\r
- source: "images/thum500_t002_0_ip_0175.jpg"\r
- }\r
- }\r
}\r
width: 100\r
height: 100\r
\r
- function doSomething() {\r
- // ...\r
+ function zoomDown() {\r
+ map.zoomLevel -= 1\r
}\r
\r
- onClicked: { doSomething() }\r
+ onClicked: { zoomDown() }\r
\r
Image {\r
id: image\r
height: 92\r
anchors.verticalCenter: parent.verticalCenter\r
anchors.horizontalCenter: parent.horizontalCenter\r
- source: "images/Shrink_button.bmp"\r
+ source: "images/240px-Antu_file-zoom-out.svg.png"\r
}\r
}\r
}\r
\r
Item {\r
id: img_destination_direction\r
+ width: 100\r
+ height: 100\r
+ visible: false\r
\r
- width: childrenRect.width\r
- height: childrenRect.height\r
+ Rectangle {\r
+ width: parent.width\r
+ height: parent.height\r
+ color: "#a0a0a0"\r
\r
- function settleState() {\r
- if(img_destination_direction.state == "1"){\r
- img_destination_direction.state = "2";\r
- } else if(img_destination_direction.state == "2"){\r
- img_destination_direction.state = "3";\r
- } else if(img_destination_direction.state == "3"){\r
- img_destination_direction.state = "4";\r
- } else if(img_destination_direction.state == "4"){\r
- img_destination_direction.state = "5";\r
- } else if(img_destination_direction.state == "5"){\r
- img_destination_direction.state = "6";\r
- } else if(img_destination_direction.state == "6"){\r
- img_destination_direction.state = "7";\r
- } else if(img_destination_direction.state == "7"){\r
- img_destination_direction.state = "8";\r
- } else if(img_destination_direction.state == "8"){\r
- img_destination_direction.state = "9";\r
- } else {\r
- img_destination_direction.state = "1";\r
- }\r
- }\r
-\r
- Image {\r
- id: direction\r
- x: 0\r
- y: 0\r
- width: 100\r
- height: 100\r
- source: "images/1_uturn.png"\r
-\r
- MouseArea {\r
- anchors.fill: parent\r
- onClicked: { settleState() }\r
- }\r
- }\r
+ Image {\r
+ id: direction\r
+ anchors.fill: parent\r
+ anchors.margins: 1\r
+ source: "images/SW_Patern_3.bmp"\r
+ }\r
+ }\r
\r
states: [\r
- State {\r
- name: "1"\r
- PropertyChanges { target: direction; source: "images/1_uturn.png" }\r
+ State {\r
+ name: "0" // NoDirection\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/SW_Patern_3.bmp" }\r
+ },\r
+ State {\r
+ name: "1" // DirectionForward\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/5_straight.png" }\r
},\r
State {\r
- name: "2"\r
- PropertyChanges { target: direction; source: "images/2_sharp_right.png" }\r
+ name: "2" // DirectionBearRight\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/11_2_bear_right_112px-Signal_C117a.svg.png" }\r
},\r
State {\r
- name: "3"\r
- PropertyChanges { target: direction; source: "images/3_right.png" }\r
+ name: "3" // DirectionLightRight\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/4_slight_right.png" }\r
},\r
State {\r
- name: "4"\r
- PropertyChanges { target: direction; source: "images/4_slight_right.png" }\r
+ name: "4" // DirectionRight\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/3_right.png" }\r
},\r
State {\r
- name: "5"\r
- PropertyChanges { target: direction; source: "images/5_straight.png" }\r
+ name: "5" // DirectionHardRight\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/2_sharp_right.png" }\r
},\r
State {\r
- name: "6"\r
- PropertyChanges { target: direction; source: "images/6_slight_left.png" }\r
+ name: "6" // DirectionUTurnRight\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ //PropertyChanges { target: direction; source: "images/1_uturn.png" }\r
+ PropertyChanges { target: direction; source: "images/9_7_uturn_left.png" } // no u-turn right in CES2019\r
},\r
State {\r
- name: "7"\r
- PropertyChanges { target: direction; source: "images/7_left.png" }\r
+ name: "7" // DirectionUTurnLeft\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/9_7_uturn_left.png" }\r
},\r
State {\r
- name: "8"\r
- PropertyChanges { target: direction; source: "images/8_sharp_left.png" }\r
+ name: "8" // DirectionHardLeft\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/8_sharp_left.png" }\r
},\r
State {\r
- name: "9"\r
- PropertyChanges { target: direction; source: "images/Dest_Flag.jpg" }\r
- }\r
+ name: "9" // DirectionLeft\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/7_left.png" }\r
+ },\r
+ State {\r
+ name: "10" // DirectionLightLeft\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/6_slight_left.png" }\r
+ },\r
+ State {\r
+ name: "11" // DirectionBearLeft\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/10_11_bear_left_112px-Signal_C117a.svg.png" }\r
+ },\r
+ State {\r
+ name: "12" // arrived at your destination\r
+ PropertyChanges { target: img_destination_direction; visible: true }\r
+ PropertyChanges { target: direction; source: "images/Dest_Flag.jpg" }\r
+ },\r
+ State {\r
+ name: "invisible"\r
+ PropertyChanges { target: img_destination_direction; visible: false }\r
+ }\r
+\r
]\r
}\r
import QtQuick 2.0\r
import QtQuick.Controls 1.5\r
+import QtQuick.Controls.Styles 1.4\r
\r
Item {\r
id: progress_next_cross\r
\r
- function move() {\r
- if(progress_next_cross.state == "0.1"){\r
- progress_next_cross.state = "0.2"\r
- } else if(progress_next_cross.state == "0.2"){\r
- progress_next_cross.state = "0.3"\r
- } else if(progress_next_cross.state == "0.3"){\r
- progress_next_cross.state = "0.4"\r
- } else if(progress_next_cross.state == "0.4"){\r
- progress_next_cross.state = "0.5"\r
- } else if(progress_next_cross.state == "0.5"){\r
- progress_next_cross.state = "0.6"\r
- } else if(progress_next_cross.state == "0.6"){\r
- progress_next_cross.state = "0.7"\r
- } else if(progress_next_cross.state == "0.7"){\r
- progress_next_cross.state = "0.8"\r
- } else if(progress_next_cross.state == "0.8"){\r
- progress_next_cross.state = "0.9"\r
- } else if(progress_next_cross.state == "0.9"){\r
- progress_next_cross.state = "1.0"\r
- } else {\r
- progress_next_cross.state = "0.1"\r
- }\r
+ visible: false\r
+\r
+ // val [Input]\r
+ // distance to next cross. (unit = meter)\r
+ // when over the ProgressBar.maximumValue/m, progress bar indicates max (same as ProgressBar.maximumValue/m)\r
+ function setProgress(val) {\r
+ if ( (0 < val) && (val < bar.maximumValue ) ) {\r
+ bar.value = val\r
+ }else if ( bar.maximumValue < val ){\r
+ bar.value = bar.maximumValue\r
+ }else{\r
+ bar.value = 0\r
+ }\r
}\r
\r
ProgressBar {\r
id: bar\r
width: 25\r
height: 100\r
- orientation: 0\r
- value: 0.7\r
+ orientation: Qt.Vertical\r
+ value: 0\r
+ minimumValue: 0\r
+ maximumValue: 300\r
\r
- MouseArea {\r
- anchors.fill: parent\r
- onClicked: { move() }\r
- }\r
+ style: ProgressBarStyle {\r
+ progress: Rectangle {\r
+ color: "green"\r
+ }\r
+ }\r
}\r
+ states: [\r
+ State {\r
+ name: "visible"; PropertyChanges { target: progress_next_cross; visible: true }},\r
+ State {\r
+ name: "invisible"; PropertyChanges { target: progress_next_cross; visible: false }}\r
+ ]\r
\r
- states: [\r
- State {\r
- name: "0.1"\r
- PropertyChanges { target: bar; value: 0.1 }\r
- },\r
- State {\r
- name: "0.2"\r
- PropertyChanges { target: bar; value: 0.2 }\r
- },\r
- State {\r
- name: "0.3"\r
- PropertyChanges { target: bar; value: 0.3 }\r
- },\r
- State {\r
- name: "0.4"\r
- PropertyChanges { target: bar; value: 0.4 }\r
- },\r
- State {\r
- name: "0.5"\r
- PropertyChanges { target: bar; value: 0.5 }\r
- },\r
- State {\r
- name: "0.6"\r
- PropertyChanges { target: bar; value: 0.6 }\r
- },\r
- State {\r
- name: "0.7"\r
- PropertyChanges { target: bar; value: 0.7 }\r
- },\r
- State {\r
- name: "0.8"\r
- PropertyChanges { target: bar; value: 0.8 }\r
- },\r
- State {\r
- name: "0.9"\r
- PropertyChanges { target: bar; value: 0.9 }\r
- },\r
- State {\r
- name: "1.0"\r
- PropertyChanges { target: bar; value: 1.0 }\r
- }\r
- ]\r
}\r
TARGET = navigation
-QT = quick aglextras qml
+QT = quick qml
+
+QT += aglextras
+PKGCONFIG += qlibhomescreen qlibwindowmanager
+
+QT += positioning
+QT += dbus
+QT += core
CONFIG += c++11 link_pkgconfig
-#PKGCONFIG +=
-#HEADERS +=
+HEADERS += \
+ markermodel.h \
+ dbus_server.h \
+ guidance_module.h \
+ file_operation.h
-SOURCES += main.cpp
+SOURCES += main.cpp \
+ dbus_server.cpp
RESOURCES += \
- testqt.qrc \
+ navigation.qrc \
images/images.qrc
+DBUS_ADAPTORS += dbusinterface/org.agl.naviapi.xml
+DBUS_INTERFACES += dbusinterface/org.agl.naviapi.xml
+
include(app.pri)
+
--- /dev/null
+#include"dbus_server.h"
+#include <QDebug>
+
+DBus_Server::DBus_Server(const QString &pathName,
+ const QString &objName,
+ const QString &serverName,
+ QObject *parent) :
+ m_serverName(serverName),
+ m_pathName(pathName + serverName),
+ m_objName(objName + serverName)
+{
+ initDBus();
+ initAPIs(parent);
+}
+DBus_Server::~DBus_Server(){}
+
+void DBus_Server::initDBus(){
+
+ new NaviapiAdaptor(this);
+
+ if (!QDBusConnection::sessionBus().registerService(m_pathName))
+ qDebug() << m_pathName << "registerService() failed";
+
+ if (!QDBusConnection::sessionBus().registerObject(m_objName, this))
+ qDebug() << m_objName << "registerObject() failed";
+
+ QDBusConnection sessionBus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_serverName);
+ if (!sessionBus.isConnected()) {
+ qDebug() << m_serverName << "connectToBus() failed";
+ }
+
+ //for receive dbus signal
+ org::agl::naviapi *mInterface;
+ mInterface = new org::agl::naviapi(QString(),QString(),QDBusConnection::sessionBus(),this);
+ if (!connect(mInterface,SIGNAL(getRouteInfo()),this,SLOT(getRouteInfoSlot()))){
+ qDebug() << m_serverName << "sessionBus.connect():getRouteInfoSlot failed";
+ }
+
+}
+
+void DBus_Server::initAPIs(QObject *parent){
+
+ if(!QObject::connect(this,SIGNAL(doAddPOI(QVariant,QVariant,QVariant)),
+ parent,SLOT(addPoiIconSLOT(QVariant,QVariant,QVariant)))) {
+ qDebug() << m_serverName << "cppSIGNAL:doAddPOI to qmlSLOT:addPoiIcon connect is failed";
+ }
+
+ if(!QObject::connect(this,SIGNAL(doRemovePOIs(QVariant)),
+ parent,SLOT(removePoiIconsSLOT(QVariant)))) {
+ qDebug() << m_serverName << "cppSIGNAL:doRemovePOIs to qmlSLOT:removePoiIcons connect is failed";
+ }
+
+ if(!QObject::connect(this,SIGNAL(doGetRouteInfo()),
+ parent,SLOT(doGetRouteInfoSlot()))) {
+ qDebug() << m_serverName << "cppSIGNAL:doGetRouteInfo to qmlSLOT:doGetRouteInfoSlot connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalRouteInfo(double,double,double,double)),
+ this,SLOT(sendSignalRouteInfo(double,double,double,double)))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalRouteInfo to cppSLOT:sendSignalRouteInfo connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalPosInfo(double,double,double,double)),
+ this,SLOT(sendSignalPosInfo(double,double,double,double)))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalPosInfo to cppSLOT:sendSignalPosInfo connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalStopDemo()),
+ this,SLOT(sendSignalStopDemo()))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalStopDemo to cppSLOT:sendSignalStopDemo connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalArrvied()),
+ this,SLOT(sendSignalArrvied()))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalArrvied to cppSLOT:sendSignalArrvied connect is failed";
+ }
+}
+
+void DBus_Server::getRouteInfoSlot(){
+ qDebug() << "call getRouteInfoSlot ";
+ emit doGetRouteInfo();
+ return;
+}
+
+// Signal
+void DBus_Server::sendSignalRouteInfo(double srt_lat, double srt_lon, double end_lat, double end_lon){
+ qDebug() << "call sendSignalRouteInfo ";
+ QDBusMessage message = QDBusMessage::createSignal(m_objName,
+ org::agl::naviapi::staticInterfaceName(),
+ "signalRouteInfo");
+ message << srt_lat << srt_lon << end_lat << end_lon;
+ QDBusConnection::sessionBus().send(message);
+ return;
+}
+
+void DBus_Server::sendSignalPosInfo(double lat, double lon, double drc, double dst){
+// qDebug() << "call sendSignalPosInfo ";
+ QDBusMessage message = QDBusMessage::createSignal(m_objName,
+ org::agl::naviapi::staticInterfaceName(),
+ "signalPosInfo");
+ message << lat << lon << drc << dst;
+ QDBusConnection::sessionBus().send(message);
+ return;
+}
+
+void DBus_Server::sendSignalStopDemo(){
+ qDebug() << "call sendSignalStopDemo ";
+ QDBusMessage message = QDBusMessage::createSignal(m_objName,
+ org::agl::naviapi::staticInterfaceName(),
+ "signalStopDemo");
+ QDBusConnection::sessionBus().send(message);
+ return;
+}
+
+void DBus_Server::sendSignalArrvied(){
+ qDebug() << "call sendSignalArrvied ";
+ QDBusMessage message = QDBusMessage::createSignal(m_objName,
+ org::agl::naviapi::staticInterfaceName(),
+ "signalArrvied");
+ QDBusConnection::sessionBus().send(message);
+ return;
+}
+
+// Method
+void DBus_Server::addPOI(uint category_id, double poi_Lat, double poi_Lon){
+ qDebug() << "call addPOI category_id: " << category_id << " poi_Lat: " << poi_Lat << " poi_Lon: " << poi_Lon;
+ emit doAddPOI(poi_Lat,poi_Lon,category_id);
+ return;
+}
+void DBus_Server::removePOIs(uint category_id){
+ qDebug() << "call removePOIs category_id: " << category_id;
+ emit doRemovePOIs(category_id);
+ return;
+}
--- /dev/null
+#ifndef DBUS_SERVER_H
+#define DBUS_SERVER_H
+#include "naviapi_interface.h"
+#include "naviapi_adaptor.h"
+#include <QtQml/QQmlApplicationEngine>
+
+class DBus_Server : public QObject{
+
+ Q_OBJECT
+
+ QString m_serverName;
+ QString m_pathName;
+ QString m_objName;
+
+public:
+ DBus_Server(const QString &pathName,
+ const QString &objName,
+ const QString &serverName,
+ QObject *parent = nullptr);
+ ~DBus_Server();
+
+private:
+ void initDBus();
+ void initAPIs(QObject*);
+
+signals:
+ void doAddPOI(QVariant,QVariant,QVariant);
+ void doRemovePOIs(QVariant);
+ void doGetRouteInfo();
+
+public slots:
+ void addPOI(uint category_id, double poi_Lat, double poi_Lon);
+ void removePOIs(uint category_id);
+ void getRouteInfoSlot();
+ void sendSignalRouteInfo(double srt_lat,double srt_lon,double end_lat,double end_lon);
+ void sendSignalPosInfo(double lat,double lon,double drc,double dst);
+ void sendSignalStopDemo();
+ void sendSignalArrvied();
+};
+#endif // DBUS_SERVER_H
--- /dev/null
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.agl.naviapi">
+ <method name="addPOI">
+ <arg direction="in" name="category_id" type="u"/>
+ <arg direction="in" name="poi_Lat" type="d"/>
+ <arg direction="in" name="poi_Lon" type="d"/>
+ </method>
+ <method name="removePOIs">
+ <arg direction="in" name="category_id" type="u"/>
+ </method>
+ <!-- void signalRouteInfo() -->
+ <signal name="signalRouteInfo">
+ <arg name="start_latitude" type="d" direction="out"/>
+ <arg name="start_longitude" type="d" direction="out"/>
+ <arg name="end_latitude" type="d" direction="out"/>
+ <arg name="end_longitude" type="d" direction="out"/>
+ </signal>
+ <!-- void signalPosInfo() -->
+ <signal name="signalPosInfo">
+ <arg name="latitude" type="d" direction="out"/>
+ <arg name="longitude" type="d" direction="out"/>
+ <arg name="direction" type="d" direction="out"/>
+ <arg name="distance" type="d" direction="out"/>
+ </signal>
+ <!-- void signalStopDemo() -->
+ <signal name="signalStopDemo">
+ </signal>
+ <!-- void signalArrvied() -->
+ <signal name="signalArrvied">
+ </signal>
+ <!-- void getRouteInfo() -->
+ <signal name="getRouteInfo">
+ </signal>
+ </interface>
+</node>
--- /dev/null
+#ifndef FILE_OPERATION_H
+#define FILE_OPERATION_H
+#include <QObject>
+#include <QString>
+#include <QFile>
+#include <QFile>
+#include <QJsonObject>
+#include <QJsonDocument>
+
+/******************************************************
+ * Write access token of mapbox in /etc/mapAccessToken
+ ******************************************************/
+#define MAP_ACCESS_TOKEN_FILEPATH "/etc/mapAccessToken"
+
+class File_Operation: public QObject{
+
+ Q_OBJECT
+public:
+ Q_INVOKABLE QString getMapAccessToken() {
+ #if 0
+ char buf[512];
+ QString mapAccessToken = "";
+
+ FILE* filep = fopen(qPrintable(MAP_ACCESS_TOKEN_FILEPATH), "r");
+ if (!filep) {
+ fprintf(stderr,"Failed to open mapAccessToken file \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ return mapAccessToken;
+ }
+ if (!fgets(buf, 512, filep)) {
+ fprintf(stderr,"Failed to read mapAccessToken from mapAccessToken file \"%s\"", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ fclose(filep);
+ return mapAccessToken;
+ }
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n') {
+ buf[strlen(buf)-1] = '\0';
+ }
+ mapAccessToken = QString(buf);
+
+ fclose(filep);
+
+ return mapAccessToken;
+ #else
+ QString mapAccessToken = "";
+ QFile file(MAP_ACCESS_TOKEN_FILEPATH);
+ if (!file.open(QIODevice::ReadOnly)){
+ fprintf(stderr,"Failed to open mapAccessToken file \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ return mapAccessToken;
+ }
+ QByteArray data = file.readAll();
+ QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
+ QJsonObject jsonObj(jsonDoc.object());
+ if(jsonObj.contains("mapAccessToken")){
+ mapAccessToken = jsonObj["mapAccessToken"].toString();
+ }else{
+ fprintf(stderr,"Failed to find mapAccessToken data \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ }
+
+ file.close();
+ return mapAccessToken;
+ #endif
+ }
+
+ Q_INVOKABLE double getSpeed() {
+ double speed = 60; // km/h
+ QFile file(MAP_ACCESS_TOKEN_FILEPATH);
+ if (!file.open(QIODevice::ReadOnly)){
+ fprintf(stderr,"Failed to open mapAccessToken file \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ return speed;
+ }
+ QByteArray data = file.readAll();
+ QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
+ QJsonObject jsonObj(jsonDoc.object());
+ if(jsonObj.contains("speed")){
+ speed = jsonObj["speed"].toDouble();
+ }else{
+ fprintf(stderr,"Failed to find speed data \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ }
+
+ file.close();
+ return speed;
+ }
+
+ Q_INVOKABLE int getInterval() {
+ int interval = 15; // ms
+ QFile file(MAP_ACCESS_TOKEN_FILEPATH);
+ if (!file.open(QIODevice::ReadOnly)){
+ fprintf(stderr,"Failed to open mapAccessToken file \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ return interval;
+ }
+ QByteArray data = file.readAll();
+ QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
+ QJsonObject jsonObj(jsonDoc.object());
+ if(jsonObj.contains("interval")){
+ interval = (int)jsonObj["interval"].toDouble();
+ }else{
+ fprintf(stderr,"Failed to find interval data \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ }
+
+ file.close();
+ return interval;
+ }
+
+ Q_INVOKABLE double getLatitude() {
+ double latitude = 36.136261;
+ QFile file(MAP_ACCESS_TOKEN_FILEPATH);
+ if (!file.open(QIODevice::ReadOnly)){
+ fprintf(stderr,"Failed to open mapAccessToken file \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ return latitude;
+ }
+ QByteArray data = file.readAll();
+ QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
+ QJsonObject jsonObj(jsonDoc.object());
+ if(jsonObj.contains("latitude")){
+ latitude = jsonObj["latitude"].toDouble();
+ }else{
+ fprintf(stderr,"Failed to find latitude data \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ }
+
+ file.close();
+ return latitude;
+ }
+
+ Q_INVOKABLE double getLongitude() {
+ double longitute = -115.151254;
+ QFile file(MAP_ACCESS_TOKEN_FILEPATH);
+ if (!file.open(QIODevice::ReadOnly)){
+ fprintf(stderr,"Failed to open mapAccessToken file \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ return longitute;
+ }
+ QByteArray data = file.readAll();
+ QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
+ QJsonObject jsonObj(jsonDoc.object());
+ if(jsonObj.contains("longitute")){
+ longitute = jsonObj["longitute"].toDouble();
+ }else{
+ fprintf(stderr,"Failed to find longitute data \"%s\": %m", qPrintable(MAP_ACCESS_TOKEN_FILEPATH));
+ }
+
+ file.close();
+ return longitute;
+ }
+};
+
+#endif // FILE_OPERATION_H
--- /dev/null
+#include <sys/stat.h>
+#include <QObject>
+#include <QString>
+#include <QDebug>
+
+#define SYS_LANGUAGE_INIT 0
+#define SYS_LANGUAGE_JP 1
+#define SYS_LANGUAGE_EN 2
+#define TTSMAX (2048)
+
+class Guidance_Module : public QObject
+{
+ Q_OBJECT
+public:
+ int g_voicelanguage = SYS_LANGUAGE_INIT;
+ QString g_voice_module = "";
+ Q_INVOKABLE void guidance(const QString &text){
+ char tts_voice[TTSMAX];
+ int len = 0;
+ memset(tts_voice,0,TTSMAX);
+
+ strncat(tts_voice, "sh flite '", (TTSMAX - len - 1));
+
+ len = strlen(tts_voice);
+ strncat(tts_voice, text.toUtf8().data(), (TTSMAX - len - 1));
+
+ len = strlen(tts_voice);
+ strncat(tts_voice, "'&", (TTSMAX - len - 1));
+
+ system(tts_voice);
+ }
+};
-<RCC>
- <qresource prefix="/images">
- <file>SW_Patern_1.bmp</file>
- <file>SW_Patern_2.bmp</file>
- <file>SW_Patern_3.bmp</file>
- <file>Enlarge_button.bmp</file>
- <file>Direction_Hup.jpeg</file>
- <file>Direction_Nup.jpeg</file>
- <file>thum500_t002_0_ip_0175.jpg</file>
- <file>Shrink_button.bmp</file>
- <file>1_uturn.png</file>
- <file>2_sharp_right.png</file>
- <file>3_right.png</file>
- <file>4_slight_right.png</file>
- <file>5_straight.png</file>
- <file>6_slight_left.png</file>
- <file>7_left.png</file>
- <file>8_sharp_left.png</file>
- <file>Dest_Flag.jpg</file>
- <file>car_icon.svg</file>
- <file>nmea.txt</file>
- </qresource>
-</RCC>
+<RCC>\r
+ <qresource prefix="/images">\r
+ <file>91px-MUTCD_M6-1L.svg.png</file>\r
+ <file>91px-MUTCD_M6-1R.svg.png</file>\r
+ <file>91px-MUTCD_M6-2aL.svg.png</file>\r
+ <file>91px-MUTCD_M6-2aR.svg.png</file>\r
+ <file>91px-MUTCD_M6-2L.svg.png</file>\r
+ <file>91px-MUTCD_M6-2R.svg.png</file>\r
+ <file>91px-MUTCD_M6-3.svg.png</file>\r
+ <file>124px-Pictograms-nps-land-driving_tour-2.svg.png</file>\r
+ <file>200px-Black_close_x.svg.png</file>\r
+ <file>202px-Compass-icon_bb_N.svg.png</file>\r
+ <file>240px-Antu_file-zoom-out.svg.png</file>\r
+ <file>240px-Antu_kdenlive-zoom-large.svg.png</file>\r
+ <file>240px-Compass_icon_NE.svg.png</file>\r
+ <file>240px-Red_Arrow_Up.svg.png</file>\r
+ <file>240px-HEB_project_flow_icon_04_checkered_flag.svg.png</file>\r
+ <file>207px-Car_icon_top.svg.png</file>\r
+ <file>181px-u-turn.svg.png</file>\r
+ <file>Dest_Flag.jpg</file>\r
+ <file>1_uturn.png</file>\r
+ <file>2_sharp_right.png</file>\r
+ <file>3_right.png</file>\r
+ <file>4_slight_right.png</file>\r
+ <file>5_straight.png</file>\r
+ <file>6_slight_left.png</file>\r
+ <file>7_left.png</file>\r
+ <file>8_sharp_left.png</file>\r
+ <file>9_7_uturn_left.png</file>\r
+ <file>10_11_bear_left_112px-Signal_C117a.svg.png</file>\r
+ <file>11_2_bear_right_112px-Signal_C117a.svg.png</file>\r
+ <file>SW_Patern_3.bmp</file>\r
+ <file>Map_symbol_location_02.png</file>\r
+ <file>Map_marker_icon_–_Nicolas_Mollet_–_Flag_–_Tourism_–_Classic.png</file>\r
+ <file>RestaurantMapIcon.png</file>\r
+ <file>SupermarketMapIcon.png</file>\r
+ <file>BuildingIcon.png</file>\r
+ <file>ChurchIcon.png</file>\r
+ <file>Flag-export_lightblue.png</file>\r
+ </qresource>\r
+</RCC>\r
-/*
- * Copyright (C) 2016 The Qt Company Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <QtAGLExtras/AGLApplication>
-#include <QtCore/QDebug>
-#include <QtCore/QCommandLineParser>
-#include <QtCore/QUrlQuery>
-#include <QtCore/QSettings>
-#include <QtGui/QGuiApplication>
-#include <QtQml/QQmlApplicationEngine>
-#include <QtQml/QQmlContext>
-#include <QtQuickControls2/QQuickStyle>
-#include <QQuickWindow>
-
-int main(int argc, char *argv[])
-{
- AGLApplication app(argc, argv);
- app.setApplicationName("navigation");
- app.setupApplicationRole("navigation");
-
- app.load(QUrl(QStringLiteral("qrc:/testqt.qml")));
- return app.exec();
-}
-
+/*\r
+ * Copyright (C) 2016 The Qt Company Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#define USE_QTAGLEXTRAS 0\r
+#define USE_QLIBWINDOWMANAGER 1\r
+\r
+#if USE_QTAGLEXTRAS\r
+#include <QtAGLExtras/AGLApplication>\r
+#elif USE_QLIBWINDOWMANAGER\r
+#include <qlibwindowmanager.h>\r
+#include <qlibhomescreen.h>\r
+#include <string>\r
+#include <ilm/ivi-application-client-protocol.h>\r
+#include <wayland-client.h>\r
+#endif\r
+#include <QtCore/QDebug>\r
+#include <QtCore/QCommandLineParser>\r
+#include <QtCore/QUrlQuery>\r
+#include <QtCore/QSettings>\r
+#include <QtGui/QGuiApplication>\r
+#include <QtQml/QQmlApplicationEngine>\r
+#include <QtQml/QQmlContext>\r
+#include <QtQuickControls2/QQuickStyle>\r
+#include <QQuickWindow>\r
+#include <QtDBus/QDBusConnection>\r
+#include "markermodel.h"\r
+#include "dbus_server.h"\r
+#include "guidance_module.h"\r
+#include "file_operation.h"\r
+\r
+int main(int argc, char *argv[])\r
+{\r
+ \r
+ // for dbusIF\r
+ QString pathBase = "org.agl.";\r
+ QString objBase = "/org/agl/";\r
+ QString serverName = "naviapi";\r
+\r
+ if (!QDBusConnection::sessionBus().isConnected()) {\r
+ qWarning("Cannot connect to the D-Bus session bus.\n"\r
+ "Please check your system settings and try again.\n");\r
+ return 1;\r
+ }\r
+ \r
+#if USE_QTAGLEXTRAS\r
+ AGLApplication app(argc, argv);\r
+ app.setApplicationName("navigation");\r
+ app.setupApplicationRole("navigation");\r
+ app.load(QUrl(QStringLiteral("qrc:/navigation.qml")));\r
+ \r
+#elif USE_QLIBWINDOWMANAGER\r
+ QGuiApplication app(argc, argv);\r
+ QString myname = QString("navigation");\r
+ int port = 1700;\r
+ QString token = "hello";\r
+ QCoreApplication::setOrganizationDomain("LinuxFoundation");\r
+ QCoreApplication::setOrganizationName("AutomotiveGradeLinux");\r
+ QCoreApplication::setApplicationName(myname);\r
+ QCoreApplication::setApplicationVersion("0.1.0");\r
+ QCommandLineParser parser;\r
+ parser.addPositionalArgument("port", app.translate("main", "port for binding"));\r
+ parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));\r
+ parser.addHelpOption();\r
+ parser.addVersionOption();\r
+ parser.process(app);\r
+ QStringList positionalArguments = parser.positionalArguments();\r
+ if (positionalArguments.length() == 2) {\r
+ port = positionalArguments.takeFirst().toInt();\r
+ token = positionalArguments.takeFirst();\r
+ }\r
+ fprintf(stderr, "[navigation]app_name: %s, port: %d, token: %s.\n",\r
+ myname.toStdString().c_str(),\r
+ port,\r
+ token.toStdString().c_str());\r
+ // QLibWM\r
+ QLibWindowmanager* qwmHandler = new QLibWindowmanager();\r
+ int res;\r
+ if((res = qwmHandler->init(port,token)) != 0){\r
+ fprintf(stderr, "[navigation]init qlibwm err(%d)\n", res);\r
+ return -1;\r
+ }\r
+ if((res = qwmHandler->requestSurface(myname)) != 0) {\r
+ fprintf(stderr, "[navigation]request surface err(%d)\n", res);\r
+ return -1;\r
+ }\r
+ qwmHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw, [qwmHandler, myname](json_object *object) {\r
+ qwmHandler->endDraw(myname);\r
+ });\r
+ qwmHandler->set_event_handler(QLibWindowmanager::Event_Visible, [qwmHandler, myname](json_object *object) {\r
+ ;\r
+ });\r
+ qwmHandler->set_event_handler(QLibWindowmanager::Event_Invisible, [qwmHandler, myname](json_object *object) {\r
+ ;\r
+ });\r
+ // QLibHS\r
+ QLibHomeScreen* qhsHandler = new QLibHomeScreen();\r
+ qhsHandler->init(port, token.toStdString().c_str());\r
+ qhsHandler->set_event_handler(QLibHomeScreen::Event_TapShortcut, [qwmHandler, myname](json_object *object){\r
+ json_object *appnameJ = nullptr;\r
+ if(json_object_object_get_ex(object, "application_name", &appnameJ))\r
+ {\r
+ const char *appname = json_object_get_string(appnameJ);\r
+ if(QString::compare(myname, appname, Qt::CaseInsensitive) == 0)\r
+ {\r
+ qDebug("Surface %s got tapShortcut\n", appname);\r
+ json_object *para, *area;\r
+ json_object_object_get_ex(object, "parameter", ¶);\r
+ json_object_object_get_ex(para, "area", &area);\r
+ const char *displayArea = json_object_get_string(area);\r
+ qDebug("Surface %s got tapShortcut area\n", displayArea);\r
+ qwmHandler->activateWindow(myname, QString(QLatin1String(displayArea)));\r
+ }\r
+ }\r
+ });\r
+ // Load qml\r
+ QQmlApplicationEngine engine;\r
+\r
+ MarkerModel model;\r
+ engine.rootContext()->setContextProperty("markerModel", &model);\r
+\r
+ Guidance_Module guidance;\r
+ engine.rootContext()->setContextProperty("guidanceModule", &guidance);\r
+\r
+ File_Operation file;\r
+ engine.rootContext()->setContextProperty("fileOperation", &file);\r
+\r
+ engine.load(QUrl(QStringLiteral("qrc:/navigation.qml")));\r
+ QObject *root = engine.rootObjects().first();\r
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root);\r
+ QObject::connect(window, SIGNAL(frameSwapped()), qwmHandler, SLOT(slotActivateSurface()));\r
+ QObject *map = engine.rootObjects().first()->findChild<QObject*>("map");\r
+ DBus_Server dbus(pathBase,objBase,serverName,map);\r
+\r
+#else // for only libwindowmanager\r
+ QGuiApplication app(argc, argv);\r
+ app.setApplicationName("navigation");\r
+\r
+ // Load qml\r
+ QQmlApplicationEngine engine;\r
+\r
+ MarkerModel model;\r
+ engine.rootContext()->setContextProperty("markerModel", &model);\r
+\r
+ Guidance_Module guidance;\r
+ engine.rootContext()->setContextProperty("guidanceModule", &guidance);\r
+\r
+ File_Operation file;\r
+ engine.rootContext()->setContextProperty("fileOperation", &file);\r
+\r
+ engine.load(QUrl(QStringLiteral("qrc:/navigation.qml")));\r
+ QObject *map = engine.rootObjects().first()->findChild<QObject*>("map");\r
+ DBus_Server dbus(pathBase,objBase,serverName,map);\r
+\r
+#endif\r
+ \r
+ return app.exec();\r
+}\r
+\r
--- /dev/null
+#ifndef MARKERMODEL_H
+#define MARKERMODEL_H
+
+#include <QAbstractListModel>
+#include <QGeoCoordinate>
+
+class MarkerModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ using QAbstractListModel::QAbstractListModel;
+ enum MarkerRoles{positionRole = Qt::UserRole + 1};
+
+ Q_INVOKABLE void addMarker(const QGeoCoordinate &coordinate){
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ m_coordinates.append(coordinate);
+ endInsertRows();
+ }
+
+ Q_INVOKABLE void removeMarker(){
+ beginResetModel();
+ m_coordinates.clear();
+ endResetModel();
+ }
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override{
+ Q_UNUSED(parent)
+ return m_coordinates.count();
+ }
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override{
+ if (index.row() < 0 || index.row() >= m_coordinates.count())
+ return QVariant();
+ if(role== MarkerModel::positionRole)
+ return QVariant::fromValue(m_coordinates[index.row()]);
+ return QVariant();
+ }
+
+ QHash<int, QByteArray> roleNames() const{
+ QHash<int, QByteArray> roles;
+ roles[positionRole] = "position";
+ return roles;
+ }
+
+private:
+ QList<QGeoCoordinate> m_coordinates;
+};
+
+#endif // MARKERMODEL_H
--- /dev/null
+/*
+ * Copyright (C) 2016 The Qt Company Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import QtQuick 2.6
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 2.0
+import QtWebSockets 1.0
+import QtLocation 5.9
+import QtPositioning 5.6
+
+ApplicationWindow {
+ id: root
+ visible: true
+ width: 1080
+ height: 1488
+// height: 680 //debug
+ title: qsTr("navigation")
+
+ property real car_position_lat: fileOperation.getLatitude() // WestGate as default
+ property real car_position_lon: fileOperation.getLongitude()
+ property real car_direction: 0 //North
+ property real car_driving_speed: fileOperation.getSpeed() // set Km/h
+ property real prev_car_direction: 0
+ property bool st_heading_up: false
+ property real default_zoom_level : 18
+ property real default_car_direction : 0
+ property real car_accumulated_distance : 0
+ property real positionTimer_interval : fileOperation.getInterval() // set millisecond
+ property real car_moving_distance : (car_driving_speed / 3.6) / (1000/positionTimer_interval) // Metric unit
+
+ Map{
+ id: map
+ property int pathcounter : 0
+ property int segmentcounter : 0
+ property int waypoint_count: -1
+ property int lastX : -1
+ property int lastY : -1
+ property int pressX : -1
+ property int pressY : -1
+ property int jitterThreshold : 30
+ property variant currentpostion : QtPositioning.coordinate(car_position_lat, car_position_lon)
+ property var poiArray: new Array
+ property int last_segmentcounter : -1
+
+ signal qmlSignalRouteInfo(double srt_lat,double srt_lon,double end_lat,double end_lon);
+ signal qmlSignalPosInfo(double lat,double lon,double drc,double dst);
+ signal qmlSignalStopDemo();
+ signal qmlSignalArrvied();
+
+ width: parent.width
+ height: parent.height
+ plugin: Plugin {
+ name: "mapboxgl"
+ PluginParameter { name: "mapboxgl.access_token";
+ value: fileOperation.getMapAccessToken() }
+ }
+ center: QtPositioning.coordinate(car_position_lat, car_position_lon)
+ zoomLevel: default_zoom_level
+ bearing: 0
+ objectName: "map"
+
+ GeocodeModel {
+ id: geocodeModel
+ plugin: map.plugin
+ onStatusChanged: {
+ if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error))
+ map.geocodeFinished()
+ }
+ onLocationsChanged:
+ {
+ if (count == 1) {
+ map.center.latitude = get(0).coordinate.latitude
+ map.center.longitude = get(0).coordinate.longitude
+ }
+ }
+ //coordinate: poiTheQtComapny.coordinate
+ //anchorPoint: Qt.point(-poiTheQtComapny.sourceItem.width * 0.5,poiTheQtComapny.sourceItem.height * 1.5)
+ }
+ MapItemView {
+ model: geocodeModel
+ delegate: pointDelegate
+ }
+ Component {
+ id: pointDelegate
+
+ MapCircle {
+ id: point
+ radius: 1000
+ color: "#46a2da"
+ border.color: "#190a33"
+ border.width: 2
+ smooth: true
+ opacity: 0.25
+ center: locationData.coordinate
+ }
+ }
+
+ function geocode(fromAddress)
+ {
+ // send the geocode request
+ geocodeModel.query = fromAddress
+ geocodeModel.update()
+ }
+
+ MapQuickItem {
+ id: poi
+ sourceItem: Rectangle { width: 14; height: 14; color: "#e41e25"; border.width: 2; border.color: "white"; smooth: true; radius: 7 }
+ coordinate {
+ latitude: 36.136261
+ longitude: -115.151254
+ }
+ opacity: 1.0
+ anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2)
+ }
+ MapQuickItem {
+ sourceItem: Text{
+ text: "Westgate"
+ color:"#242424"
+ font.bold: true
+ styleColor: "#ECECEC"
+ style: Text.Outline
+ }
+ coordinate: poi.coordinate
+ anchorPoint: Qt.point(-poi.sourceItem.width * 0.5, poi.sourceItem.height * 1.5)
+ }
+ MapQuickItem {
+ id: car_position_mapitem
+ sourceItem: Image {
+ id: car_position_mapitem_image
+ width: 32
+ height: 32
+ source: "images/240px-Red_Arrow_Up.svg.png"
+
+ transform: Rotation {
+ id: car_position_mapitem_image_rotate
+ origin.x: car_position_mapitem_image.width/2
+ origin.y: car_position_mapitem_image.height/2
+ angle: car_direction
+ }
+ }
+ anchorPoint: Qt.point(car_position_mapitem_image.width/2, car_position_mapitem_image.height/2)
+ coordinate: map.currentpostion
+
+
+ states: [
+ State {
+ name: "HeadingUp"
+ PropertyChanges { target: car_position_mapitem_image_rotate; angle: 0 }
+ },
+ State {
+ name: "NorthUp"
+ PropertyChanges { target: car_position_mapitem_image_rotate; angle: root.car_direction }
+ }
+ ]
+ transitions: Transition {
+ RotationAnimation { properties: "angle"; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ MapQuickItem {
+ id: icon_start_point
+ anchorPoint.x: icon_start_point_image.width/2
+ anchorPoint.y: icon_start_point_image.height
+ sourceItem: Image {
+ id: icon_start_point_image
+ width: 32
+ height: 32
+ source: "images/240px-HEB_project_flow_icon_04_checkered_flag.svg.png"
+ }
+ }
+
+ MapQuickItem {
+ id: icon_end_point
+ anchorPoint.x: icon_end_point_image.width/2
+ anchorPoint.y: icon_end_point_image.height
+ sourceItem: Image {
+ id: icon_end_point_image
+ width: 32
+ height: 32
+ source: "images/Map_marker_icon_–_Nicolas_Mollet_–_Flag_–_Tourism_–_Classic.png"
+ }
+ }
+
+ MapQuickItem {
+ id: icon_segment_point
+ anchorPoint.x: icon_segment_point_image.width/2 - 5
+ anchorPoint.y: icon_segment_point_image.height/2 + 25
+ sourceItem: Image {
+ id: icon_segment_point_image
+ width: 64
+ height: 64
+ source: "images/Map_symbol_location_02.png"
+ }
+ }
+
+ RouteModel {
+ id: routeModel
+ plugin: Plugin {
+ name: "mapbox"
+ PluginParameter { name: "mapbox.access_token";
+ value: fileOperation.getMapAccessToken() }
+ }
+ query: RouteQuery {
+ id: routeQuery
+ }
+ onStatusChanged: {
+ if (status == RouteModel.Ready) {
+ switch (count) {
+ case 0:
+ // technically not an error
+ // map.routeError()
+ break
+ case 1:
+ map.pathcounter = 0
+ map.segmentcounter = 0
+// console.log("1 route found")
+// console.log("path: ", get(0).path.length, "segment: ", get(0).segments.length)
+// for(var i = 0; i < get(0).path.length; i++){
+// console.log("", get(0).path[i])
+// }
+ console.log("1st instruction: ", get(0).segments[map.segmentcounter].maneuver.instructionText)
+ for( var i = 0; i < routeModel.get(0).segments.length; i++){
+// console.log("segments[",i,"].maneuver.direction:" ,routeModel.get(0).segments[i].maneuver.direction)
+// console.log("segments[",i,"].maneuver.instructionText:" ,routeModel.get(0).segments[i].maneuver.instructionText)
+// console.log("segments[",i,"].maneuver.path[0]:" ,routeModel.get(0).segments[i].path[0].latitude,",",routeModel.get(0).segments[i].path[0].longitude)
+// markerModel.addMarker(routeModel.get(0).segments[i].path[0]) // for debug
+ }
+ break
+ }
+ } else if (status == RouteModel.Error) {
+ // map.routeError()
+ }
+ }
+ }
+
+ Component {
+ id: routeDelegate
+
+ MapRoute {
+ id: route
+ route: routeData
+ line.color: "#4658da"
+ line.width: 10
+ smooth: true
+ opacity: 0.8
+ }
+ }
+
+ MapItemView {
+ model: routeModel
+ delegate: routeDelegate
+ }
+
+ MapItemView{
+ model: markerModel
+ delegate: mapcomponent
+ }
+
+ Component {
+ id: mapcomponent
+ MapQuickItem {
+ id: icon_destination_point
+ anchorPoint.x: icon_destination_point_image.width/4
+ anchorPoint.y: icon_destination_point_image.height
+ coordinate: position
+
+ sourceItem: Image {
+ id: icon_destination_point_image
+ width: 32
+ height: 32
+ source: "images/200px-Black_close_x.svg.png"
+ }
+ }
+ }
+
+ function addDestination(coord){
+ if( waypoint_count < 0 ){
+ initDestination()
+ }
+
+ if(waypoint_count == 0) {
+ // set icon_start_point
+ icon_start_point.coordinate = currentpostion
+ map.addMapItem(icon_start_point)
+ }
+
+ if(waypoint_count < 9){
+ routeQuery.addWaypoint(coord)
+ waypoint_count += 1
+
+ btn_guidance.sts_guide = 1
+ btn_guidance.state = "Routing"
+
+ var waypointlist = routeQuery.waypoints
+ for(var i=1; i<waypoint_count; i++) {
+ markerModel.addMarker(waypointlist[i])
+
+// map.addPoiIconSLOT(waypointlist[i].latitude,waypointlist[i].longitude,i % 5) // for Debug
+ }
+
+ routeModel.update()
+ map.qmlSignalRouteInfo(car_position_lat, car_position_lon,coord.latitude,coord.longitude)
+
+ // update icon_end_point
+ icon_end_point.coordinate = coord
+ map.addMapItem(icon_end_point)
+ }
+ }
+
+ function initDestination(){
+ routeModel.reset();
+ console.log("initWaypoint")
+
+ // reset currentpostion
+ map.currentpostion = QtPositioning.coordinate(car_position_lat, car_position_lon)
+ car_accumulated_distance = 0
+ map.qmlSignalPosInfo(car_position_lat, car_position_lon,car_direction,car_accumulated_distance)
+
+ routeQuery.clearWaypoints();
+ routeQuery.addWaypoint(map.currentpostion)
+ routeQuery.travelModes = RouteQuery.CarTravel
+ routeQuery.routeOptimizations = RouteQuery.FastestRoute
+ for (var i=0; i<9; i++) {
+ routeQuery.setFeatureWeight(i, 0)
+ }
+ waypoint_count = 0
+ pathcounter = 0
+ segmentcounter = 0
+ routeModel.update();
+ markerModel.removeMarker();
+ map.removeMapItem(markerModel);
+
+ // remove MapItem
+ map.removeMapItem(icon_start_point)
+ map.removeMapItem(icon_end_point)
+ map.removeMapItem(icon_segment_point)
+
+ // for Debug
+// while(poiArray.length>0)
+// map.removeMapItem(poiArray.pop())
+
+ // update car_position_mapitem angle
+ root.car_direction = root.default_car_direction
+
+ }
+
+ function calculateMarkerRoute()
+ {
+ var startCoordinate = QtPositioning.coordinate(car_position_lat, car_position_lon)
+
+ console.log("calculateMarkerRoute")
+ routeQuery.clearWaypoints();
+ routeQuery.addWaypoint(startCoordinate)
+ routeQuery.addWaypoint(mouseArea.lastCoordinate)
+ routeQuery.travelModes = RouteQuery.CarTravel
+ routeQuery.routeOptimizations = RouteQuery.FastestRoute
+ for (var i=0; i<9; i++) {
+ routeQuery.setFeatureWeight(i, 0)
+ }
+ routeModel.update();
+ }
+
+ // Calculate direction from latitude and longitude between two points
+ function calculateDirection(lat1, lon1, lat2, lon2) {
+ var curlat = lat1 * Math.PI / 180;
+ var curlon = lon1 * Math.PI / 180;
+ var taglat = lat2 * Math.PI / 180;
+ var taglon = lon2 * Math.PI / 180;
+
+ var Y = Math.sin(taglon - curlon);
+ var X = Math.cos(curlat) * Math.tan(taglat) - Math.sin(curlat) * Math.cos(Y);
+ var direction = 180 * Math.atan2(Y,X) / Math.PI;
+ if (direction < 0) {
+ direction = direction + 360;
+ }
+ return direction;
+ }
+
+ // Calculate distance from latitude and longitude between two points
+ function calculateDistance(lat1, lon1, lat2, lon2)
+ {
+ var radLat1 = lat1 * Math.PI / 180;
+ var radLon1 = lon1 * Math.PI / 180;
+ var radLat2 = lat2 * Math.PI / 180;
+ var radLon2 = lon2 * Math.PI / 180;
+
+ var r = 6378137.0;
+
+ var averageLat = (radLat1 - radLat2) / 2;
+ var averageLon = (radLon1 - radLon2) / 2;
+ var result = r * 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(averageLat), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(averageLon), 2)));
+ return Math.round(result);
+ }
+
+ // Setting the next car position from the direction and demonstration mileage
+ function setNextCoordinate(curlat,curlon,direction,distance)
+ {
+ var radian = direction * Math.PI / 180
+ var lat_per_meter = 111319.49079327358;
+ var lat_distance = distance * Math.cos(radian);
+ var addlat = lat_distance / lat_per_meter
+ var lon_distance = distance * Math.sin(radian)
+ var lon_per_meter = (Math.cos( (curlat+addlat) / 180 * Math.PI) * 2 * Math.PI * 6378137) / 360;
+ var addlon = lon_distance / lon_per_meter
+ map.currentpostion = QtPositioning.coordinate(curlat+addlat, curlon+addlon);
+ }
+
+ function addPoiIconSLOT(lat,lon,type) {
+ console.log("called addPoiIcon")
+ var poiItem;
+ switch(type){
+ case 0:
+ poiItem = Qt.createQmlObject("
+ import QtQuick 2.0;
+ import QtLocation 5.9;
+ MapQuickItem {
+ id: poi_icon;
+ anchorPoint.x: icon_flag_liteblue_image.width/2;
+ anchorPoint.y: icon_flag_liteblue_image.height;
+ sourceItem: Image {
+ id: icon_flag_liteblue_image;
+ width: 32;
+ height: 37;
+ source: \"images/Flag-export_lightblue.png\";
+ }
+ }
+ ",map,"dynamic");
+ break;
+ case 1:
+ poiItem = Qt.createQmlObject("
+ import QtQuick 2.0;
+ import QtLocation 5.9;
+ MapQuickItem {
+ id: poi_icon;
+ anchorPoint.x: icon_building_image.width/2;
+ anchorPoint.y: icon_building_image.height;
+ sourceItem: Image {
+ id: icon_building_image;
+ width: 32;
+ height: 37;
+ source: \"images/BuildingIcon.png\";
+ }
+ }
+ ",map,"dynamic");
+ break;
+ case 2:
+ poiItem = Qt.createQmlObject("
+ import QtQuick 2.0;
+ import QtLocation 5.9;
+ MapQuickItem {
+ id: poi_icon;
+ anchorPoint.x: icon_church_image.width/2;
+ anchorPoint.y: icon_church_image.height;
+ sourceItem: Image {
+ id: icon_church_image;
+ width: 32;
+ height: 37;
+ source: \"images/ChurchIcon.png\";
+ }
+ }
+ ",map,"dynamic");
+ break;
+ case 3:
+ poiItem = Qt.createQmlObject("
+ import QtQuick 2.0;
+ import QtLocation 5.9;
+ MapQuickItem {
+ id: poi_icon;
+ anchorPoint.x: icon_restaurant_image.width/2;
+ anchorPoint.y: icon_restaurant_image.height;
+ sourceItem: Image {
+ id: icon_restaurant_image;
+ width: 32;
+ height: 37;
+ source: \"images/RestaurantMapIcon.png\";
+ }
+ }
+ ",map,"dynamic");
+ break;
+ case 4:
+ poiItem = Qt.createQmlObject("
+ import QtQuick 2.0;
+ import QtLocation 5.9;
+ MapQuickItem {
+ id: poi_icon;
+ anchorPoint.x: icon_supermarket_image.width/2;
+ anchorPoint.y: icon_supermarket_image.height;
+ sourceItem: Image {
+ id: icon_supermarket_image;
+ width: 32;
+ height: 37;
+ source: \"images/SupermarketMapIcon.png\";
+ }
+ }
+ ",map,"dynamic");
+ break;
+ default:
+ poiItem = null;
+ break;
+ }
+
+ if(poiItem === null) {
+ console.log("error creating object" + poiItem.errorString());
+ return false;
+ }
+
+ poiItem.coordinate = QtPositioning.coordinate(lat, lon);
+ map.addMapItem(poiItem);
+ poiArray.push(poiItem);
+// console.log("success creating object");
+ return true;
+ }
+
+ MouseArea {
+ id: mouseArea
+ property variant lastCoordinate
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ onPressed : {
+ map.lastX = mouse.x
+ map.lastY = mouse.y
+ map.pressX = mouse.x
+ map.pressY = mouse.y
+ lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y))
+ }
+
+ onPositionChanged: {
+ if (mouse.button === Qt.LeftButton) {
+ map.lastX = mouse.x
+ map.lastY = mouse.y
+ }
+ }
+
+ onPressAndHold:{
+ if(btn_guidance.state !== "onGuide")
+ {
+ if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold
+ && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) {
+ map.addDestination(lastCoordinate)
+ }
+ }
+
+ }
+ }
+ gesture.onFlickStarted: {
+ btn_present_position.state = "Optional"
+ }
+ gesture.onPanStarted: {
+ btn_present_position.state = "Optional"
+ }
+ function updatePositon()
+ {
+// console.log("updatePositon")
+ if(pathcounter <= routeModel.get(0).path.length - 1){
+// console.log("path: ", pathcounter, "/", routeModel.get(0).path.length - 1, " segment: ", segmentcounter, "/", routeModel.get(0).segments.length - 1)
+// console.log("from_to:",map.currentpostion.latitude,",",map.currentpostion.longitude,",",routeModel.get(0).path[pathcounter].latitude,",",routeModel.get(0).path[pathcounter].longitude)
+ // calculate distance
+ var next_distance = calculateDistance(map.currentpostion.latitude,
+ map.currentpostion.longitude,
+ routeModel.get(0).path[pathcounter].latitude,
+ routeModel.get(0).path[pathcounter].longitude);
+// console.log("next_distance:",next_distance);
+
+ // calculate direction
+ var next_direction = calculateDirection(map.currentpostion.latitude,
+ map.currentpostion.longitude,
+ routeModel.get(0).path[pathcounter].latitude,
+ routeModel.get(0).path[pathcounter].longitude);
+// console.log("next_direction:",next_direction);
+
+ // calculate next cross distance
+ var next_cross_distance = calculateDistance(map.currentpostion.latitude,
+ map.currentpostion.longitude,
+ routeModel.get(0).segments[segmentcounter].path[0].latitude,
+ routeModel.get(0).segments[segmentcounter].path[0].longitude);
+// console.log("next_cross_distance:",next_cross_distance);
+ // set next coordidnate
+ if(next_distance < (root.car_moving_distance * 1.5))
+ {
+ map.currentpostion = routeModel.get(0).path[pathcounter]
+ if(pathcounter != 0){
+ car_accumulated_distance += next_distance
+ }
+ map.qmlSignalPosInfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance)
+ if(pathcounter < routeModel.get(0).path.length - 1){
+ pathcounter++
+ }
+ else
+ {
+ // Arrive at your destination
+ btn_guidance.sts_guide = 0
+ map.qmlSignalArrvied()
+ }
+ }else{
+ setNextCoordinate(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,root.car_moving_distance)
+ if(pathcounter != 0){
+ car_accumulated_distance += root.car_moving_distance
+ }
+ map.qmlSignalPosInfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance)
+ }
+// console.log("NextCoordinate:",map.currentpostion.latitude,",",map.currentpostion.longitude)
+
+ // car_position_mapitem angle
+ root.prev_car_direction = root.car_direction
+ root.car_direction = next_direction
+
+ if(btn_present_position.state === "Flowing")
+ {
+ // update map.center
+ map.center = map.currentpostion
+
+ rotateMapSmooth()
+ }
+
+ // report a new instruction if current position matches with the head position of the segment
+ if(segmentcounter <= routeModel.get(0).segments.length - 1){
+ if(next_cross_distance < 2){
+// console.log("new segment instruction: ", routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
+ progress_next_cross.setProgress(0)
+ if(segmentcounter < routeModel.get(0).segments.length - 1){
+ segmentcounter++
+ }
+ if(segmentcounter === routeModel.get(0).segments.length - 1){
+ img_destination_direction.state = "12"
+ map.removeMapItem(icon_segment_point)
+ }else{
+ img_destination_direction.state = routeModel.get(0).segments[segmentcounter].maneuver.direction
+ icon_segment_point.coordinate = routeModel.get(0).segments[segmentcounter].path[0]
+ map.addMapItem(icon_segment_point)
+ // console.log(routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
+ // guidanceModule.guidance(routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
+ }
+ }else{
+ if(next_cross_distance <= 330 && last_segmentcounter != segmentcounter) {
+ last_segmentcounter = segmentcounter
+ console.log(routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
+ guidanceModule.guidance(routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
+ }
+ // update progress_next_cross
+ progress_next_cross.setProgress(next_cross_distance)
+ }
+ }
+ }
+ }
+ function removePoiIconsSLOT(category_id){
+ console.log("called removePoiIcons")
+ while(poiArray.length>0)
+ map.removeMapItem(poiArray.pop())
+ }
+
+ function doGetRouteInfoSlot(){
+ if(btn_guidance.sts_guide == 0){ // idle
+ console.log("called doGetRouteInfoSlot sts_guide == idle")
+ map.qmlSignalPosInfo(car_position_lat, car_position_lon,car_direction,car_accumulated_distance);
+ }else if(btn_guidance.sts_guide == 1){ // Routing
+ console.log("called doGetRouteInfoSlot sts_guide == Routing")
+ map.qmlSignalPosInfo(car_position_lat, car_position_lon,car_direction,car_accumulated_distance);
+ map.qmlSignalRouteInfo(car_position_lat, car_position_lon,routeQuery.waypoints[1].latitude,routeQuery.waypoints[1].longitude);
+ }else if(btn_guidance.sts_guide == 2){ // onGuide
+ console.log("called doGetRouteInfoSlot sts_guide == onGuide")
+ map.qmlSignalRouteInfo(car_position_lat, car_position_lon,routeQuery.waypoints[1].latitude,routeQuery.waypoints[1].longitude);
+ }
+ }
+
+ function rotateMapSmooth(){
+ var prev = root.prev_car_direction
+ var now = root.car_direction
+ var diff
+
+ if(root.st_heading_up){
+
+ diff = now - prev
+
+ if ( 180 < diff ){
+ diff = diff - 360.0
+ } else if ( diff < -180 ){
+ diff = diff + 360.0
+ }
+
+ //console.log("prev:", prev, ", now:", now, ", diff:", diff)
+
+ if( 0 < diff ){
+ rot_anim.direction = RotationAnimation.Clockwise
+ } else {
+ rot_anim.direction = RotationAnimation.Counterclockwise
+ }
+
+ map.state = "none"
+ map.state = "smooth_rotate"
+ }else{
+ diff = 0 - prev
+
+ if ( 180 < diff ){
+ diff = diff - 360.0
+ } else if ( diff < -180 ){
+ diff = diff + 360.0
+ }
+
+ //console.log("prev:", prev, ", now:", now, ", diff:", diff)
+ if( 0 < diff ){
+ rot_anim.direction = RotationAnimation.Clockwise
+ } else {
+ rot_anim.direction = RotationAnimation.Counterclockwise
+ }
+
+ map.state = "smooth_rotate_north"
+ }
+ }
+
+ states: [
+ State {
+ name: "none"
+ },
+ State {
+ name: "smooth_rotate"
+ PropertyChanges { target: map; bearing: root.car_direction }
+ },
+ State {
+ name: "smooth_rotate_north"
+ PropertyChanges { target: map; bearing: 0 }
+ }
+ ]
+
+ transitions: Transition {
+ NumberAnimation { properties: "center"; easing.type: Easing.InOutQuad }
+ RotationAnimation {
+ id: rot_anim
+ property: "bearing"
+ easing.type: Easing.InOutQuad
+ duration: 200
+ }
+ }
+ }
+
+ BtnPresentPosition {
+ id: btn_present_position
+ anchors.right: parent.right
+ anchors.rightMargin: 125
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 125
+ }
+
+ BtnMapDirection {
+ id: btn_map_direction
+ anchors.top: parent.top
+ anchors.topMargin: 25
+ anchors.left: parent.left
+ anchors.leftMargin: 25
+ }
+
+ BtnGuidance {
+ id: btn_guidance
+ anchors.top: parent.top
+ anchors.topMargin: 25
+ anchors.right: parent.right
+ anchors.rightMargin: 125
+ }
+
+ BtnShrink {
+ id: btn_shrink
+ anchors.left: parent.left
+ anchors.leftMargin: 25
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 250
+ }
+
+ BtnEnlarge {
+ id: btn_enlarge
+ anchors.left: parent.left
+ anchors.leftMargin: 25
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 125
+ }
+
+ ImgDestinationDirection {
+ id: img_destination_direction
+ anchors.top: parent.top
+ anchors.topMargin: 25
+ anchors.left: parent.left
+ anchors.leftMargin: 150
+ }
+
+ ProgressNextCross {
+ id: progress_next_cross
+ anchors.top: parent.top
+ anchors.topMargin: 25
+ anchors.left: img_destination_direction.right
+ anchors.leftMargin: 20
+ }
+}
--- /dev/null
+<RCC>\r
+ <qresource prefix="/">\r
+ <file>navigation.qml</file>\r
+ <file>BtnMapDirection.qml</file>\r
+ <file>BtnShrink.qml</file>\r
+ <file>BtnEnlarge.qml</file>\r
+ <file>ImgDestinationDirection.qml</file>\r
+ <file>ProgressNextCross.qml</file>\r
+ <file>BtnGuidance.qml</file>\r
+ <file>BtnPresentPosition.qml</file>\r
+ </qresource>\r
+</RCC>\r
+++ /dev/null
-/*
- * Copyright (C) 2016 The Qt Company Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import QtQuick 2.6
-import QtQuick.Layouts 1.1
-import QtQuick.Controls 2.0
-import QtWebSockets 1.0
-import QtLocation 5.9
-import QtPositioning 5.6
-
-ApplicationWindow {
- id: root
- visible: true
- width: 1080
- height: 1488
- title: qsTr("TestQt")
-
- Map{
- id: map
- property variant pathcounter : 0
- property variant segmentcounter : 0
- property int lastX : -1
- property int lastY : -1
- property int pressX : -1
- property int pressY : -1
- property int jitterThreshold : 30
- anchors.fill: parent
- plugin: Plugin {
- name: "mapbox"
- PluginParameter { name: "mapbox.access_token";
- value: "pk.eyJ1IjoiYWlzaW53ZWkiLCJhIjoiY2pqNWg2cG81MGJoazNxcWhldGZzaDEwYyJ9.imkG45PQUKpgJdhO2OeADQ" }
- }
- center: QtPositioning.coordinate(36.131998,-115.1516808)
- zoomLevel: 14
- property variant modepositionfollowing : false
- property variant currentpostion : QtPositioning.coordinate(36.131998,-115.1516808)
-
- MapQuickItem {
- id: poiTheQtComapny
- sourceItem: Rectangle { width: 14; height: 14; color: "#e41e25"; border.width: 2; border.color: "white"; smooth: true; radius: 7 }
- coordinate {
- latitude: 36.131998
- longitude: -115.1516808
- }
- opacity: 1.0
- anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2)
- }
- MapQuickItem {
- sourceItem: Text{
- text: "LAS VEGAS CONVENTION CENTER"
- color:"#242424"
- font.bold: true
- styleColor: "#ECECEC"
- style: Text.Outline
- }
- coordinate: poiTheQtComapny.coordinate
- anchorPoint: Qt.point(-poiTheQtComapny.sourceItem.width * 0.5,poiTheQtComapny.sourceItem.height * 1.5)
- }
- MapQuickItem {
- id: marker
- anchorPoint.x: imageMarker.width/2
- anchorPoint.y: imageMarker.height/2
- sourceItem: Image {
- id: imageMarker
- width: 150
- height: 150
- source: "images/car_icon.svg"
- }
- coordinate: map.currentpostion
- }
-
- RouteModel {
- id: routeModel
- plugin : map.plugin
- query: RouteQuery {
- id: routeQuery
- }
- onStatusChanged: {
- if (status == RouteModel.Ready) {
- switch (count) {
- case 0:
- // technically not an error
- // map.routeError()
- break
- case 1:
- map.pathcounter = 0
- map.segmentcounter = 0
- // report position on route and 1st instruction
- console.log("1 route found")
- console.log("path: ", get(0).path.length, "segment: ", get(0).segments.length)
- for(var i = 0; i < get(0).path.length; i++){
- console.log("", get(0).path[i])
- }
- console.log("1st instruction: ", get(0).segments[map.segmentcounter].maneuver.instructionText)
- break
- }
- } else if (status == RouteModel.Error) {
- // map.routeError()
- }
- }
- }
-
- Component {
- id: routeDelegate
-
- MapRoute {
- id: route
- route: routeData
- line.color: "#4658da"
- line.width: 10
- smooth: true
- opacity: 0.8
- }
- }
-
- MapItemView {
- model: routeModel
- delegate: routeDelegate
- autoFitViewport: true
- }
-
- function calculateMarkerRoute()
- {
- var startCoordinate = QtPositioning.coordinate(36.131998,-115.1516808) // The Qt Company in Oslo
-
- console.log("calculateMarkerRoute")
- routeQuery.clearWaypoints();
- routeQuery.addWaypoint(startCoordinate)
- routeQuery.addWaypoint(mouseArea.lastCoordinate)
- routeQuery.travelModes = RouteQuery.CarTravel
- routeQuery.routeOptimizations = RouteQuery.FastestRoute
- for (var i=0; i<9; i++) {
- routeQuery.setFeatureWeight(i, 0)
- }
- routeModel.update();
- }
- MouseArea {
- id: mouseArea
- property variant lastCoordinate
- anchors.fill: parent
- acceptedButtons: Qt.LeftButton | Qt.RightButton
-
- onPressed : {
- map.lastX = mouse.x
- map.lastY = mouse.y
- map.pressX = mouse.x
- map.pressY = mouse.y
- lastCoordinate = map.toCoordinate(Qt.point(mouse.x, mouse.y))
- }
-
- onPositionChanged: {
- if (mouse.button == Qt.LeftButton) {
- map.lastX = mouse.x
- map.lastY = mouse.y
- }
- }
-
- onPressAndHold:{
- if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold
- && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) {
- map.modepositionfollowing = false
- // arrow.positionTimer.stop();
- map.calculateMarkerRoute();
- }
- }
- }
- gesture.onFlickStarted: {
- map.modepositionfollowing = false
- }
- gesture.onPanStarted: {
- map.modepositionfollowing = false
- }
-
- function updatePositon()
- {
- console.log("updatePositon")
- if(routeModel.status == RouteModel.Ready){
- if(pathcounter < routeModel.get(0).path.length){
- console.log("path: ", pathcounter, "/", routeModel.get(0).path.length, "", routeModel.get(0).path[pathcounter])
- map.currentpostion = routeModel.get(0).path[pathcounter]
- marker.coordinate = map.currentpostion
- if(map.modepositionfollowing == true){
- map.center = map.currentpostion
- }
- // report a new instruction if current position matches with the head position of the segment
- if(segmentcounter < routeModel.get(0).segments.length){
- if(routeModel.get(0).path[pathcounter] == routeModel.get(0).segments[segmentcounter].path[0]){
- console.log("new segment: ", segmentcounter, "/", routeModel.get(0).segments.length)
- console.log("instruction: ", routeModel.get(0).segments[segmentcounter].maneuver.instructionText)
- segmentcounter++
- }
- }
- pathcounter++
- }else{
- pathcounter = 0
- segmentcounter = 0
- map.currentpostion = QtPositioning.coordinate(36.131998,-115.1516808)
- marker.coordinate = map.currentpostion
- if(map.modepositionfollowing == true){
- map.center = map.currentpostion
- }
- }
- }else{
- pathcounter = 0
- segmentcounter = 0
- }
- }
- }
-
- // use external nmea data to simulate current position
-// PositionSource {
-// id: src
-// updateInterval: 500
-// active: true
-// nmeaSource: "images/nmea.txt"
-//
-// onPositionChanged: {
-// var coord = src.position.coordinate;
-// console.log("Coordinate: ", src.position.coordinate);
-// map.currentpostion = src.position.coordinate;
-// }
-// }
-
- Item {
- id: present_position
- x: 942
- y: 1328
-
- Button {
- id: btn_present_position
- width: 100
- height: 100
-
- function present_position_clicked() {
- map.modepositionfollowing = true
- map.center = map.currentpostion
- }
- onClicked: { present_position_clicked() }
-
- Image {
- id: image_present_position
- width: 92
- height: 92
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- source: "images/thum500_t002_0_ip_0175.jpg"
- }
- }
- }
- Item {
- id: arrow
- x: 940
- y: 20
-
- Timer {
- id: positionTimer
- interval: 250; running: false; repeat: true
- onTriggered: map.updatePositon()
- }
-
- Button {
- id: btn_arrow
- width: 100
- height: 100
-
- function arrow_clicked() {
- if(positionTimer.running == false){
- map.modepositionfollowing = true
- positionTimer.start();
- }else{
- map.modepositionfollowing = false
- positionTimer.stop();
- }
- }
-
- onClicked: { arrow_clicked() }
-
- Image {
- id: image_arrow
- width: 92
- height: 92
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- source: "images/SW_Patern_1.bmp"
- }
- }
- }
-
- BtnMapDirection {
- id: btn_map_direction
- x: 15
- y: 20
- }
- BtnShrink {
- id: btn_shrink
- x: 23
- y:1200
- }
- BtnEnlarge {
- id: btn_enlarge
- x: 23
- y: 1330
- }
- ImgDestinationDirection {
- id: img_destination_direction
- x: 120
- y: 20
- }
- ProgressNextCross {
- id: progress_next_cross
- x: 225
- y: 20
- }
-}
+++ /dev/null
-<RCC>
- <qresource prefix="/">
- <file>testqt.qml</file>
- <file>BtnMapDirection.qml</file>
- <file>BtnShrink.qml</file>
- <file>BtnEnlarge.qml</file>
- <file>ImgDestinationDirection.qml</file>
- <file>ProgressNextCross.qml</file>
- </qresource>
-</RCC>
<name>navigation</name>
<icon src="icon.svg"/>
<content src="bin/navigation" type="application/vnd.agl.native"/>
- <description>This is a demo testqt application</description>
+ <description>This is a demo navigation application</description>
<author>Qt</author>
<license>APL 2.0</license>
<feature name="urn:AGL:widget:required-api">
</feature>
<feature name="urn:AGL:widget:required-permission">
<param name="urn:AGL:permission::public:no-htdocs" value="required"/>
+ <param name="http://tizen.org/privilege/internal/dbus" value="required"/>
</feature>
</widget>
--- /dev/null
+#!/bin/sh
+TMP=/tmp/navi.wav
+echo "$1" | flite_hts_engine -m /usr/share/Voice/us/cmu_us_arctic_slt.htsvoice -o $TMP
+4a-play $TMP hw:0,0,3 navigation
+
--- /dev/null
+#!/bin/sh
+TMP=/tmp/navi.wav
+echo "$1" | open_jtalk -ow $TMP -m /usr/share/Voice/mei/mei_normal.htsvoice -x /usr/share/dic/
+4a-play $TMP hw:0,0,3 navigation
+
+
-DISTFILES = icon.svg config.xml
+DISTFILES = icon.svg config.xml \
+ jtalk \
+ flite
copy_icon.target = $$OUT_PWD/root/icon.svg
copy_icon.depends = $$_PRO_FILE_PWD_/icon.svg
QMAKE_EXTRA_TARGETS += copy_config
PRE_TARGETDEPS += $$copy_config.target
+copy_jtalk.target = $$OUT_PWD/root/bin/jtalk
+copy_jtalk.depends = $$_PRO_FILE_PWD_/jtalk
+copy_jtalk.commands = $(COPY_FILE) \"$$replace(copy_jtalk.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_jtalk.target, /, $$QMAKE_DIR_SEP)\"
+QMAKE_EXTRA_TARGETS += copy_jtalk
+PRE_TARGETDEPS += $$copy_jtalk.target
+
+copy_flite.target = $$OUT_PWD/root/bin/flite
+copy_flite.depends = $$_PRO_FILE_PWD_/flite
+copy_flite.commands = $(COPY_FILE) \"$$replace(copy_flite.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_flite.target, /, $$QMAKE_DIR_SEP)\"
+QMAKE_EXTRA_TARGETS += copy_flite
+PRE_TARGETDEPS += $$copy_flite.target
+
wgt.target = package
-wgt.commands = wgtpkg-pack -f -o testqt.wgt root
+wgt.commands = wgtpkg-pack -f -o navigation.wgt root
QMAKE_EXTRA_TARGETS += wgt