Browse Source

add ivxlnt for load xlsx.

yuchuli 2 years ago
parent
commit
a41bbd2bde

+ 67 - 0
src/common/ivxlnt/ivxlnt.cpp

@@ -0,0 +1,67 @@
+#include "ivxlnt.h"
+
+#include "xlnt/xlnt.hpp"
+
+class  Ivxlnt_Impl
+{
+
+public:
+    Ivxlnt_Impl(std::string strfilepath)
+    {
+        mwb.load(strfilepath);
+        mws = mwb.active_sheet();
+    }
+    std::string getcellvalue(unsigned int column,unsigned int row)
+    {
+        return mws.cell(xlnt::cell_reference(column,row)).to_string();
+    }
+private:
+    xlnt::workbook mwb;
+    xlnt::worksheet mws ;
+};
+
+class  Ivxlnt
+{
+public:
+    Ivxlnt(std::string strfilepath);
+    ~Ivxlnt();
+    std::string getcellvalue(unsigned int column,unsigned int row);
+private:
+    void * mpimpl;
+};
+
+
+Ivxlnt::Ivxlnt(std::string strfilepath)
+{
+    mpimpl = new Ivxlnt_Impl(strfilepath);
+}
+
+std::string Ivxlnt::getcellvalue(unsigned int column,unsigned int row)
+{
+    Ivxlnt_Impl  * p = (Ivxlnt_Impl * )mpimpl;
+    return p->getcellvalue(column,row);
+}
+
+Ivxlnt::~Ivxlnt()
+{
+    Ivxlnt_Impl  * p = (Ivxlnt_Impl * )mpimpl;
+    delete p;
+}
+
+void * Openxlsx(std::string strfilepath)
+{
+    void * p = new Ivxlnt(strfilepath);
+    return p;
+}
+
+std::string getcellvalue(void * pxlsxhanle,unsigned int column,unsigned int row)
+{
+    Ivxlnt * p = (Ivxlnt * )pxlsxhanle;
+    return p->getcellvalue(column,row);
+}
+
+void Closexlsx(void * pxlsxhanle)
+{
+    Ivxlnt * p = (Ivxlnt * )pxlsxhanle;
+    delete p;
+}

+ 14 - 0
src/common/ivxlnt/ivxlnt.h

@@ -0,0 +1,14 @@
+#ifndef IVXLNT_H
+#define IVXLNT_H
+
+#include <string>
+
+
+
+
+
+void * Openxlsx(std::string strfilepath);
+std::string getcellvalue(void * pxlsxhanle,unsigned int column,unsigned int row);
+void Closexlsx(void * pxlsxhanle);
+
+#endif // IVXLNT_H

+ 54 - 0
src/common/ivxlnt/ivxlnt.pro

@@ -0,0 +1,54 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2022-08-17T13:41:47
+#
+#-------------------------------------------------
+
+QT       -= core gui
+
+TARGET = ivxlnt
+TEMPLATE = lib
+
+DEFINES += IVXLNT_LIBRARY
+
+CONFIG += plugin
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+        ivxlnt.cpp
+
+HEADERS += \
+        ivxlnt.h
+
+unix {
+    target.path = /usr/lib
+    INSTALLS += target
+}
+
+INCLUDEPATH += $$PWD/../../../thirdpartylib/xlnt/include
+
+unix:LIBS += -L$$PWD/../../../thirdpartylib/xlnt/lib
+
+unix:LIBS += -lxlnt
+
+DISTFILES += \
+    ../map_lanetoxodr/TinyXML/TinyXML.pri
+
+win32: LIBS += -L$$PWD/../../../thirdpartylib/xlnt/lib/win10/ -llibxlnt.dll
+
+INCLUDEPATH += $$PWD/../../../thirdpartylib/xlnt/lib/win10
+DEPENDPATH += $$PWD/../../../thirdpartylib/xlnt/lib/win10
+
+win32:!win32-g++: PRE_TARGETDEPS += $$PWD/../../../thirdpartylib/xlnt/lib/win10/libxlnt.dll.lib
+else:win32-g++: PRE_TARGETDEPS += $$PWD/../../../thirdpartylib/xlnt/lib/win10/libxlnt.dll.a
+

+ 30 - 0
src/tool/map_lanetoxodr/dialogaddroadfromcda.cpp

@@ -0,0 +1,30 @@
+#include "dialogaddroadfromcda.h"
+#include "ui_dialogaddroadfromcda.h"
+
+#include <QLibrary>
+#include <iostream>
+
+DialogAddRoadFromCDA::DialogAddRoadFromCDA(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogAddRoadFromCDA)
+{
+    ui->setupUi(this);
+
+    QLibrary xlib("./libxlnt.so.1.5.0");
+    xlib.load();
+
+    QLibrary qlib("./libivxlnt.so");
+    if(qlib.load())
+    {
+        std::cout<<" lib load."<<std::endl;
+    }
+    else
+    {
+        std::cout<<" load libivxlnt fail."<<qlib.errorString().toStdString()<< std::endl;
+    }
+}
+
+DialogAddRoadFromCDA::~DialogAddRoadFromCDA()
+{
+    delete ui;
+}

+ 22 - 0
src/tool/map_lanetoxodr/dialogaddroadfromcda.h

@@ -0,0 +1,22 @@
+#ifndef DIALOGADDROADFROMCDA_H
+#define DIALOGADDROADFROMCDA_H
+
+#include <QDialog>
+
+namespace Ui {
+class DialogAddRoadFromCDA;
+}
+
+class DialogAddRoadFromCDA : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogAddRoadFromCDA(QWidget *parent = 0);
+    ~DialogAddRoadFromCDA();
+
+private:
+    Ui::DialogAddRoadFromCDA *ui;
+};
+
+#endif // DIALOGADDROADFROMCDA_H

+ 19 - 0
src/tool/map_lanetoxodr/dialogaddroadfromcda.ui

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogAddRoadFromCDA</class>
+ <widget class="QDialog" name="DialogAddRoadFromCDA">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>579</width>
+    <height>397</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 6 - 0
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -5981,3 +5981,9 @@ void MainWindow::on_CreateAfter_triggered()
         UpdateScene();
     }
 }
+
+void MainWindow::on_actionAdd_Road_From_CDA_triggered()
+{
+    DialogAddRoadFromCDA cda;//(&mxodr,strroadid,this);
+    cda.exec();
+}

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

@@ -55,6 +55,7 @@
 #include "dialogdrawroad.h"
 #include "dialogroadnoavoid.h"
 #include "dialogaddroadfromnds.h"
+#include "dialogaddroadfromcda.h"
 
 #include "filebackup.h"
 
@@ -238,6 +239,8 @@ private slots:
 
     void on_CreateAfter_triggered();
 
+    void on_actionAdd_Road_From_CDA_triggered();
+
 private:
 
 

+ 9 - 3
src/tool/map_lanetoxodr/mainwindow.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>670</width>
-    <height>443</height>
+    <width>785</width>
+    <height>540</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -23,7 +23,7 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>670</width>
+     <width>785</width>
      <height>28</height>
     </rect>
    </property>
@@ -60,6 +60,7 @@
     <addaction name="actionAdd_Road_From_NDS"/>
     <addaction name="CreateBefore"/>
     <addaction name="CreateAfter"/>
+    <addaction name="actionAdd_Road_From_CDA"/>
    </widget>
    <widget class="QMenu" name="menuView">
     <property name="title">
@@ -206,6 +207,11 @@
     <string>Create a road after this road</string>
    </property>
   </action>
+  <action name="actionAdd_Road_From_CDA">
+   <property name="text">
+    <string>Add Road From CDA</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources>

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

@@ -91,7 +91,8 @@ SOURCES += \
     xodrmake.cpp \
     view/xodrscenfunc.cpp \
     function/createextendroad.cpp \
-    function/autoconnect.cpp
+    function/autoconnect.cpp \
+    dialogaddroadfromcda.cpp
 
 HEADERS += \
     function/autoroadcontact.h \
@@ -153,7 +154,8 @@ HEADERS += \
     xodrmake.h \
     view/xodrscenfunc.h \
     function/createextendroad.h \
-    function/autoconnect.h
+    function/autoconnect.h \
+    dialogaddroadfromcda.h
 
 FORMS += \
         ui/dialogaddroadfromnds.ui \
@@ -191,7 +193,8 @@ FORMS += \
         ui/speeddialog.ui \
         ui/trafficlightdialog.ui \
         ui/trafficlightlanevaliditydialog.ui \
-        ui/trafficlightpositiondialog.ui
+        ui/trafficlightpositiondialog.ui \
+    dialogaddroadfromcda.ui
 
 
 !include(../../common/common/xodr/OpenDrive/OpenDrive.pri ) {