wk 1 year ago
parent
commit
be5cbef6e3
3 changed files with 34 additions and 12 deletions
  1. 8 8
      CMakeLists.txt
  2. 14 3
      mainwindow.cpp
  3. 12 1
      proto.sh

+ 8 - 8
CMakeLists.txt

@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 3.5)
 
-project(PCLRegistrationTool VERSION 0.1 LANGUAGES CXX)
+project(PLCRegistrationTool VERSION 0.1 LANGUAGES CXX)
 
 set(CMAKE_AUTOUIC ON)
 set(CMAKE_AUTOMOC ON)
@@ -61,36 +61,36 @@ set(PROJECT_SOURCES
 )
 
 if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
-    qt_add_executable(PCLRegistrationTool
+	qt_add_executable(PLCRegistrationTool
         MANUAL_FINALIZATION
         ${PROJECT_SOURCES}
     )
 # Define target properties for Android with Qt 6 as:
-#    set_property(TARGET PCLRegistrationTool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
+#    set_property(TARGET PLCRegistrationTool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
 #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
 # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
 else()
     if(ANDROID)
-        add_library(PCLRegistrationTool SHARED
+	    add_library(PLCRegistrationTool SHARED
             ${PROJECT_SOURCES}
         )
 # Define properties for Android with Qt 5 after find_package() calls as:
 #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
     else()
-        add_executable(PCLRegistrationTool
+	    add_executable(PLCRegistrationTool
             ${PROJECT_SOURCES}
         )
     endif()
 endif()
 
-target_link_libraries(PCLRegistrationTool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
+target_link_libraries(PLCRegistrationTool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
     ${PROTOBUF_LIBRARIES}
     -lgflags
     glog::glog
     snap7
 )
 
-set_target_properties(PCLRegistrationTool PROPERTIES
+set_target_properties(PLCRegistrationTool PROPERTIES
     MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
     MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
     MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
@@ -98,7 +98,7 @@ set_target_properties(PCLRegistrationTool PROPERTIES
     WIN32_EXECUTABLE TRUE
 )
 
-install(TARGETS PCLRegistrationTool
+install(TARGETS PLCRegistrationTool
     BUNDLE DESTINATION .
     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

+ 14 - 3
mainwindow.cpp

@@ -27,6 +27,8 @@ bool MainWindow::init(const std::string &filename) {
         return false;
     }
 
+    record_id = 0;
+    record_id_max = 0;
     ui->Forward->setChecked(true);
     ui->EntranceComboBox->clear();
 
@@ -107,8 +109,14 @@ void MainWindow::on_ComputeButton_clicked()
         wd.forward = false;
     }
 
-    m_distance_map.insert(std::pair<int, WheelDistance>(record_id, wd));
-//    auto iter = m_ground_region_map.find(ui->EntranceComboBox->currentText().toInt());
+    
+    auto iter = m_distance_map.find(record_id);
+    if (iter != m_distance_map.end()) {
+        iter->second = wd;
+    } else {
+        m_distance_map.insert(std::pair<int, WheelDistance>(record_id, wd));
+    }
+    
     int region_index = findRegionIndex(ui->EntranceComboBox->currentText().toInt());
 
     /**************** 作计算处理 ****************/
@@ -166,9 +174,12 @@ void MainWindow::on_ComputeButton_clicked()
 
 void MainWindow::on_EntranceComboBox_currentTextChanged(const QString &arg1)
 {
+    if (arg1.isEmpty()) {
+        return;
+    }
     int region_index = findRegionIndex(ui->EntranceComboBox->currentText().toInt());
     if (region_index == -1) {
-        ui->textEdit->append("find region id error");
+        ui->textEdit->append("find region id error: " + arg1);
         return;
     } else {
 //        ui->textEdit->append("on_EntranceComboBox_currentTextChanged "+ arg1);

+ 12 - 1
proto.sh

@@ -6,5 +6,16 @@
  # @FilePath: /puai_wj_2021/proto.sh
  # @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 ### 
-protoc -I=./ velodyne_config.proto --cpp_out=./
+
+#!/bin/bash
+proto_source_path=""
+
+if [ -n "$1" ]; then
+  proto_source_path=$1
+else
+  echo "can't find input path param, exit 0."
+  exit 0
+fi
+
+protoc -I=${proto_source_path}/ velodyne_config.proto --cpp_out=${proto_source_path}/