Jelajahi Sumber

Change RemoteCtrl_h264. add multi language support.

yuchuli 3 tahun lalu
induk
melakukan
a15bbceef6

+ 27 - 0
src/common/common/xodr/xodrfunc/xodrdijkstra.cpp

@@ -4,8 +4,10 @@
 #include <iostream>
 #include <memory>
 
+#ifndef NOTINPILOT
 extern iv::Ivlog *givlog;
 extern iv::Ivfault *gfault;
+#endif
 
 namespace iv {
    struct xodrtreeunit
@@ -136,7 +138,9 @@ xodrdijkstra::xodrdijkstra(OpenDrive  * pxodr)
         {
             if(px->GetLaneSection(j)->GetLaneCount()<2)
             {
+#ifndef NOTINPILOT
                 givlog->info("road %s lanesection %d: no lane",px->GetRoadId().data(),j);
+#endif
                 continue;
             }
 
@@ -283,8 +287,10 @@ xodrdijkstra::xodrdijkstra(OpenDrive  * pxodr)
 //                       road_to,pjll->GetTo(),fromedge,toedge,pjc->GetContactPoint().data());
                 if((fromedge == -1)||(toedge == -1))
                 {
+                    #ifndef NOTINPILOT
                     givlog->debug("from %d %d to %d %d fromedge %d toedge %d %s",road_from, pjll->GetFrom(),
                            road_to,pjll->GetTo(),fromedge,toedge,pjc->GetContactPoint().data());
+                    #endif
                     continue;
                 }
 
@@ -434,7 +440,9 @@ xodrdijkstra::xodrdijkstra(OpenDrive  * pxodr)
         }
     }
 
+    #ifndef NOTINPILOT
     givlog->debug("After Junction vertex same is %d ",xvertexsame.size());
+    #endif
 
 
 
@@ -1017,12 +1025,16 @@ xodrdijkstra::xodrdijkstra(OpenDrive  * pxodr)
 
     }
 
+    #ifndef NOTINPILOT
     givlog->debug("vertex same is %d ",xvertexsame.size());
+    #endif
 
     for(i=0;i<xvertexsame.size();i++)
     {
         qDebug("%d: %d %d",i,xvertexsame[i].ma,xvertexsame[i].mb);
+        #ifndef NOTINPILOT
         givlog->debug("%d: %d %d",i,xvertexsame[i].ma,xvertexsame[i].mb);
+        #endif
     }
 
 
@@ -1136,7 +1148,9 @@ xodrdijkstra::xodrdijkstra(OpenDrive  * pxodr)
     {
         qDebug("%d %d %d: %d %d",mroadedge[i].mroadid,mroadedge[i].mnleftright,mroadedge[i].mnsectionid, mroadedge[i].mvertexstart,mroadedge[i].mvertexend);
 
+        #ifndef NOTINPILOT
         givlog->debug("%d %d %d: %d %d",mroadedge[i].mroadid,mroadedge[i].mnleftright,mroadedge[i].mnsectionid,  mroadedge[i].mvertexstart,mroadedge[i].mvertexend);
+        #endif
     }
 
 
@@ -1218,7 +1232,9 @@ xodrdijkstra::xodrdijkstra(OpenDrive  * pxodr)
     for(i=0;i<mroadedge.size();i++)
     {
         qDebug("%d %d %d: %d %d",mroadedge[i].mroadid,mroadedge[i].mnleftright,mroadedge[i].mnsectionid, mroadedge[i].mvertexstart,mroadedge[i].mvertexend);
+        #ifndef NOTINPILOT
         givlog->debug("%d %d %d: %d %d",mroadedge[i].mroadid,mroadedge[i].mnleftright,mroadedge[i].mnsectionid, mroadedge[i].mvertexstart,mroadedge[i].mvertexend);
+        #endif
     }
 
 
@@ -1390,8 +1406,11 @@ std::vector<int> xodrdijkstra::getpath(int srcroadid, int nsrclr, int dstroadid,
 //    int dstvertex = mroadedge[dstedge].mvertexend;
     int dstvertex = mroadedge[dstedge].mvertexstart;
     if(srcedge == dstedge)dstvertex = mroadedge[dstedge].mvertexstart;
+
+    #ifndef NOTINPILOT
     givlog->debug("src edge is %d vertex is %d",srcedge,vs);
     givlog->debug("dst vertex is %d ",dstvertex);
+    #endif
 
     // 初始化
     for (i = 0; i < nvertexnum; i++)
@@ -1431,7 +1450,9 @@ std::vector<int> xodrdijkstra::getpath(int srcroadid, int nsrclr, int dstroadid,
         if(k == -1)
         {
             qDebug("i = %d not found k",i);
+            #ifndef NOTINPILOT
             givlog->debug("i = %d not found k",i);
+            #endif
             break;
         }
         // 标记"顶点k"为已经获取到最短路径
@@ -1484,7 +1505,9 @@ std::vector<int> xodrdijkstra::getpath(int srcroadid, int nsrclr, int dstroadid,
             int nedge = getroadedgefromvertex(nstart,nend);
             if(nedge<0)
             {
+                #ifndef NOTINPILOT
                 givlog->error("prev path error.");
+                #endif
                 break;
             }
             rtnpath.push_back(nedge);
@@ -1506,8 +1529,10 @@ std::vector<int> xodrdijkstra::getpath(int srcroadid, int nsrclr, int dstroadid,
 
     for(i=0;i<rtnpath.size();i++)
     {
+        #ifndef NOTINPILOT
         givlog->debug("%d %d %d %d",i,mroadedge[rtnpath[rtnpath.size()-1-i]].mroadid,mroadedge[rtnpath[rtnpath.size()-1-i]].mnleftright,
                 mroadedge[rtnpath[rtnpath.size()-1-i]].mnsectionid);
+        #endif
 //        qDebug("%d %d %d %f",i,mroadedge[rtnpath[rtnpath.size()-1-i]].mroadid,mroadedge[rtnpath[rtnpath.size()-1-i]].mnleftright,
 //                mroadedge[rtnpath[rtnpath.size()-1-i]].mlen);
         rtnpath2.push_back(rtnpath[rtnpath.size()-1-i]);
@@ -1515,7 +1540,9 @@ std::vector<int> xodrdijkstra::getpath(int srcroadid, int nsrclr, int dstroadid,
 
 /*    if(srcedge == dstedge)*/rtnpath2.push_back(dstedge);
 
+    #ifndef NOTINPILOT
     givlog->debug("rt = %d ",rtnpath.size());
+    #endif
     //gfault->SetFaultState(0,0,"ok");
 
     return rtnpath2;

+ 2 - 0
src/common/common/xodr/xodrfunc/xodrdijkstra.h

@@ -7,8 +7,10 @@
 
 #include "OpenDrive/OpenDrive.h"
 
+#ifdef INPILOT
 #include "ivfault.h"
 #include "ivlog.h"
+#endif
 
 #include "xodrfunc.h"
 

+ 3 - 0
src/tool/RemoteCtrl_h264/RemoteCtrl_h264.pro

@@ -130,6 +130,9 @@ LIBS += -lQt5WebEngineWidgets
 RESOURCES += \
     remotectrl.qrc
 
+TRANSLATIONS = zh_CN.ts\
+            en_CN.ts
+
 LIBS += -lboost_system
 
 INCLUDEPATH += $$PWD/../../../thirdpartylib/grpc/include

+ 15 - 0
src/tool/RemoteCtrl_h264/dialogsetting.cpp

@@ -23,6 +23,12 @@ DialogSetting::DialogSetting(QWidget *parent) :
     ui->lineEdit_queryinterval->setText(mstrinterval.data());
     ui->lineEdit_VIN->setText(mstrVIN.data());
 
+    ui->comboBox_language->addItem("Chinese");
+    ui->comboBox_language->addItem("English");
+
+    if(ServiceRCIni.GetLanguage() == "Chinese")ui->comboBox_language->setCurrentIndex(0);
+    else ui->comboBox_language->setCurrentIndex(1);
+
 
     setWindowTitle("Set Server");
 
@@ -45,6 +51,15 @@ void DialogSetting::on_pushButton_Set_clicked()
     ServiceRCIni.SetInterval(mstrinterval);
     ServiceRCIni.SetVIN(mstrVIN);
 
+    if(ui->comboBox_language->currentIndex() == 0)
+    {
+        ServiceRCIni.SetLanguase("Chinese");
+    }
+    else
+    {
+        ServiceRCIni.SetLanguase("English");
+    }
+
     this->accept();
 }
 

+ 29 - 6
src/tool/RemoteCtrl_h264/dialogsetting.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>594</width>
-    <height>361</height>
+    <width>617</width>
+    <height>384</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,8 +16,8 @@
   <widget class="QPushButton" name="pushButton_Set">
    <property name="geometry">
     <rect>
-     <x>110</x>
-     <y>277</y>
+     <x>70</x>
+     <y>320</y>
      <width>111</width>
      <height>41</height>
     </rect>
@@ -29,8 +29,8 @@
   <widget class="QPushButton" name="pushButton_Close">
    <property name="geometry">
     <rect>
-     <x>360</x>
-     <y>281</y>
+     <x>350</x>
+     <y>320</y>
      <width>111</width>
      <height>41</height>
     </rect>
@@ -131,6 +131,29 @@
     <string>车辆识别码</string>
    </property>
   </widget>
+  <widget class="QLabel" name="label_6">
+   <property name="geometry">
+    <rect>
+     <x>50</x>
+     <y>260</y>
+     <width>101</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Language</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_language">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>260</y>
+     <width>211</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
  </widget>
  <resources/>
  <connections/>

TEMPAT SAMPAH
src/tool/RemoteCtrl_h264/en_CN.qm


+ 17 - 0
src/tool/RemoteCtrl_h264/mainwindow.cpp

@@ -147,6 +147,23 @@ MainWindow::MainWindow(QWidget *parent)
     , ui(new Ui::MainWindow)
 {
 
+    m_translator = new QTranslator(this);
+    QString strLanguageFile = ":/zh_CN.qm";
+    if(ServiceRCIni.GetLanguage() == "Chinese")
+    {
+        strLanguageFile = ":/zh_CN.qm";
+    }
+    else
+    {
+        strLanguageFile = ":/en_CN.qm";
+    }
+    if (QFile(strLanguageFile).exists())
+    {
+        m_translator->load(strLanguageFile);
+        qApp->installTranslator(m_translator);
+    }
+
+
     gpaframe = iv::modulecomm::RegisterSend("h264frame",1000000,1);
     gw = this;
 

+ 4 - 0
src/tool/RemoteCtrl_h264/mainwindow.h

@@ -6,6 +6,8 @@
 
 #include <QMainWindow>
 
+#include <QTranslator>
+
 #include <QtWidgets>
 #include <QtWebEngineWidgets/QtWebEngineWidgets>
 #include <QSet>
@@ -243,5 +245,7 @@ private:
     QMutex mMutexCam[NUM_CAM];
 
     int mnVehMode = 1; //1 Speed Mode  2 AccBrakeMode
+
+    QTranslator * m_translator;
 };
 #endif // MAINWINDOW_H

+ 2 - 0
src/tool/RemoteCtrl_h264/remotectrl.qrc

@@ -1,5 +1,7 @@
 <RCC>
     <qresource prefix="/">
         <file>remotectrl.png</file>
+        <file>zh_CN.qm</file>
+        <file>en_CN.qm</file>
     </qresource>
 </RCC>

+ 19 - 0
src/tool/RemoteCtrl_h264/remotectrlini.cpp

@@ -43,6 +43,12 @@ RemoteCtrlIni::RemoteCtrlIni()
         mstrctrlMD5 = "5d41402abc4b2a76b9719d911017c592";
     }
 
+    mstrlanguage = configini->value("setting/language").toString().toStdString();
+    if(mstrlanguage == "")
+    {
+        mstrlanguage = "Chinese";
+    }
+
     delete configini;
 
     std::string strclientid;
@@ -141,3 +147,16 @@ std::string RemoteCtrlIni::GetClientID()
 {
     return mstrclientid;
 }
+
+std::string RemoteCtrlIni::GetLanguage()
+{
+    return mstrlanguage;
+}
+
+void RemoteCtrlIni::SetLanguase(std::string strlanguase)
+{
+    mstrlanguage = strlanguase;
+    QSettings * configini = new QSettings(mstrinipath,QSettings::IniFormat);
+    configini->setValue("setting/language",strlanguase.data());
+    delete configini;
+}

+ 5 - 0
src/tool/RemoteCtrl_h264/remotectrlini.h

@@ -34,6 +34,9 @@ public:
 
     std::string GetClientID();
 
+    std::string GetLanguage();
+    void SetLanguase(std::string strlanguase);
+
 private:
     QString mstrinipath;
 
@@ -46,6 +49,8 @@ private:
     std::string mstrctrlMD5 = "5d41402abc4b2a76b9719d911017c592";
 
     std::string mstrclientid = "test";
+
+    std::string mstrlanguage = "Chinese";
 };
 
 #define ServiceRCIni RemoteCtrlIni::Inst()

TEMPAT SAMPAH
src/tool/RemoteCtrl_h264/zh_CN.qm


+ 11 - 2
src/tool/map_lanetoxodr/main.cpp

@@ -7,7 +7,10 @@
 
 #ifndef ANDROID
 
+#ifdef INPILOT
 #include "ivbacktrace.h"
+#endif
+
 
 #endif
 
@@ -51,9 +54,10 @@ bool requestPermission() {
 
 #endif
 
-
+#ifdef INPILOT
 #include "ivlog.h"
 iv::Ivlog *givlog;
+#endif
 
 int main(int argc, char *argv[])
 {
@@ -61,8 +65,10 @@ int main(int argc, char *argv[])
     //Call License
     //Wait
 #ifndef ANDROID
-
+#ifdef INPILOT
     RegisterIVBackTrace();
+#endif
+
 #endif
     QApplication a(argc, argv);
 
@@ -84,7 +90,10 @@ int main(int argc, char *argv[])
         return 0;
     }
 #endif
+#ifdef INPILOT
     givlog = new iv::Ivlog("map_lanetoxodr");
+#endif
+
     MainWindow w;
 #endif
     w.show();

+ 4 - 0
src/tool/map_lanetoxodr/mainwindow.h

@@ -37,8 +37,12 @@
 
 #include "OpenDrive/OpenDriveXmlParser.h"
 
+#ifdef INPILOT
+
 #include "modulecomm.h"
 
+#endif
+
 #include "geofit.h"
 #include "autoconnect.h"
 #include "speeddialog.h"

+ 15 - 3
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -200,9 +200,7 @@ FORMS += \
     error( "Couldn't find the xodrfunc.pri file!" )
 }
 
-!include(../../common/common/license/adclicense.pri ) {
-    error( "Couldn't find the adclicense.pri file!" )
-}
+
 
 unix:LIBS += -lboost_thread -lboost_system -lboost_serialization -lprotobuf
 
@@ -214,10 +212,24 @@ windows: LIBS += -L$$PWD/../../../thirdpartylib/boost/lib -lboost_system-mgw73-m
 
 QMAKE_CXXFLAGS +=  -g
 
+
+#DEFINES += INPILOT
+
+if(contains(DEFINES,INPILOT)){
 !include(../../../include/common.pri ) {
     error( "Couldn't find the common.pri file!" )
 }
 
+!include(../../common/common/license/adclicense.pri ) {
+    error( "Couldn't find the adclicense.pri file!" )
+}
+
+}
+else
+{
+DEFINES += NOTINPILOT
+}
+
 INCLUDEPATH += $$PWD/../../include/msgtype
 
 INCLUDEPATH += $$PWD/../../common/common/xodr