RViz汉化

本文介绍了如何汉化RViz,包括编译、运行过程以及详细修改步骤,如全屏模式下不隐藏可停靠面板、工具栏、主界面、菜单和帮助文档的汉化,同时涉及image viewer plugin、points_map_loader和vector_map_loader等插件的汉化内容。
摘要由CSDN通过智能技术生成

 

目录

编译

运行 

修改

全屏时不隐藏可停靠面板

工具栏

主界面、菜单、帮助

image viewer plugin 

points_map_loader

 vector_map_loader

 


编译

cd src
git clone https://github.com/ros-visualization/rviz
cd rviz
git checkout melodic-devel
cd ../..
source install/setup.bash
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --paths src/rviz

运行 

source install/setup.bash
rviz

修改

全屏时不隐藏可停靠面板

--- a/src/rviz/panel_dock_widget.cpp
+++ b/src/rviz/panel_dock_widget.cpp
@@ -152,7 +152,7 @@ void PanelDockWidget::setVisible(bool visible)

 void PanelDockWidget::overrideVisibility(bool hidden)
 {
-  forced_hidden_ = hidden;
+  //forced_hidden_ = hidden;
   setVisible(requested_visibility_);
 }

工具栏

--- a/src/rviz/default_plugin/tools/goal_tool.cpp
+++ b/src/rviz/default_plugin/tools/goal_tool.cpp
@@ -52,7 +52,7 @@ void GoalTool::onInitialize()
 {
   PoseTool::onInitialize();
   arrow_->setColor(1.0f, 0.0f, 1.0f, 1.0f);
-  setName("2D Nav Goal");
+  //setName("2D Nav Goal");
   updateTopic();
 }

--- a/src/rviz/default_plugin/tools/initial_pose_tool.cpp
+++ b/src/rviz/default_plugin/tools/initial_pose_tool.cpp
@@ -61,7 +61,7 @@ InitialPoseTool::InitialPoseTool()
 void InitialPoseTool::onInitialize()
 {
   PoseTool::onInitialize();
-  setName("2D Pose Estimate");
+  //setName("2D Pose Estimate");
   updateTopic();
 }

--- a/src/rviz/tool_manager.cpp
+++ b/src/rviz/tool_manager.cpp
@@ -55,6 +55,11 @@ ToolManager::ToolManager(DisplayContext* context)
   , default_tool_(nullptr)
 {
   connect(property_tree_model_, SIGNAL(configChanged()), this, SIGNAL(configChanged()));
+  tool_name_map_[QString("Measure")] = QString("测距");
+  tool_name_map_[QString("SetInitialPose")] = "起始位置";
+  tool_name_map_[QString("SetGoal")] = "目的地";
+  tool_name_map_[QString("PublishPoint")] = "发布位置";
+  tool_name_map_[QString("Interact")] = "交互";
 }

 ToolManager::~ToolManager()
@@ -223,6 +228,8 @@ void rviz::ToolManager::closeTool()
 Tool* ToolManager::addTool(const QString& class_id)
 {
   QString error;
+  QString cname;
+  QString tname;
   bool failed = false;
   Tool* tool = factory_->make(class_id, &error);
   if (!tool)
@@ -231,8 +238,18 @@ Tool* ToolManager::addTool(const QString& class_id)
     failed = true;
   }

+  cname = factory_->getClassName(class_id);
+  if (tool_name_map_.find(cname) != tool_name_map_.end())
+  {
+    tname = tool_name_map_[cname];
+  }
+  else
+  {
+    tname = cname;
+  }
+
   tools_.append(tool);
-  tool->setName(addSpaceToCamelCase(factory_->getClassName(class_id)));
+  tool->setName(addSpaceToCamelCase(tname));
   tool->setIcon(factory_->getIcon(class_id));
   tool->initialize(context_);

--- a/src/rviz/tool_manager.h
+++ b/src/rviz/tool_manager.h
@@ -166,6 +166,7 @@ private:
   Tool* current_tool_;
   Tool* default_tool_;
   std::map<int, Tool*> shortkey_to_tool_map_;
+  std::map<QString, QString> tool_name_map_;
 };

 } // end namespace rviz

主界面、菜单、帮助

--- a/src/rviz/visualization_frame.cpp
+++ b/src/rviz/visualization_frame.cpp
@@ -57,6 +57,7 @@
 #include <boost/filesystem.hpp>
 
 #include <ros/console.h>
+#include <ros/ros.h>
 #include <ros/package.h>
 #include <ros/init.h>
 
@@ -145,7 +146,7 @@ VisualizationFrame::VisualizationFrame(QWidget* parent)
       QString::fromStdString((fs::path(package_path_) / "images/splash.png").BOOST_FILE_STRING());
 
   QToolButton* reset_button = new QToolButton();
-  reset_button->setText("Reset");
+  reset_button->setText("复位");
   reset_button->setContentsMargins(0, 0, 0, 0);
   statusBar()->addPermanentWidget(reset_button, 0);
   connect(reset_button, SIGNAL(clicked(bool)), this, SLOT(reset()));
@@ -160,7 +161,7 @@ VisualizationFrame::VisualizationFrame(QWidget* parent)
   statusBar()->addPermanentWidget(fps_label_, 0);
   original_status_bar_ = statusBar();
 
-  setWindowTitle("RViz[*]");
+  setWindowTitle("低速无人车[*]");
 }
 
 VisualizationFrame::~VisualizationFrame()
@@ -385,7 +386,7 @@ void VisualizationFrame::initialize(const QString& display_config_file)
 
   manager_->startUpdate();
   initialized_ = true;
-  Q_EMIT statusUpdate("RViz is ready.");
+  Q_EMIT statusUpdate("准备就绪.");
 
   connect(manager_, SIGNAL(preUpdate()), this, SLOT(updateFps()));
   connect(manager_, SIGNAL(statusUpdate(const QString&)), this, SIGNAL(statusUpdate(const QString&)));
@@ -429,6 +430,14 @@ void VisualizationFrame::loadPersistentSettings()
       last_image_dir_ = last_image_dir.toStdString();
     }
 
+    QString last_pmap_dir, last_vmap_dir;
+    if (config.mapGetString("Last Points Map Dir", &last_pmap_dir) &&
+        config.mapGetString("Last Vector Map Dir", &last_vmap_dir))
+    {
+      last_pmap_dir_ = last_pmap_dir.toStdString();
+      last_vmap_dir_ = last_vmap_dir.toStdString();
+    }
+
     Config recent_configs_list = config.mapGetChild("Recent Configs");
     recent_configs_.clear();
     int num_recent = recent_configs_list.listLength();
@@ -448,6 +457,8 @@ void VisualizationFrame::savePersistentSettings()
   Config config;
   config.mapSetValue("Last Config Dir", QString::fromStdString(last_config_dir_));
   config.mapSetValue("Last Image Dir", QString::fromStdString(last_image_dir_));
+  config.mapSetValue("Last Points Map Dir", QString::fromStdString(last_pmap_dir_));
+  config.mapSetValue("Last Vector Map Dir", QString::fromStdString(last_vmap_dir_));
   Config recent_configs_list = config.mapMakeChild("Recent Configs");
   for (D_string::iterator it = recent_configs_.begin(); it != recent_configs_.end(); ++it)
   {
@@ -465,50 +476,62 @@ void VisualizationFrame::savePersistentSettings()
 
 void VisualizationFrame::initMenus()
 {
-  file_menu_ = menuBar()->addMenu("&File");
+  file_menu_ = menuBar()->addMenu("文件(&F)");
 
   QAction* file_menu_open_action =
-      file_menu_->addAction("&Open Config", this, SLOT(onOpen()), QKeySequence("Ctrl+O"));
+      file_menu_->addAction("打开配置(&O)", this, SLOT(onOpen()), QKeySequence("Ctrl+O"));
   this->addAction(file_menu_open_action);
   QAction* file_menu_save_action =
-      file_menu_->addAction("&Save Config", this, SLOT(onSave()), QKeySequence("Ctrl+S"));
+      file_menu_->addAction("保存配置(&S)", this, SLOT(onSave()), QKeySequence("Ctrl+S"));
   this->addAction(file_menu_save_action);
   QAction* file_menu_save_as_action =
-      file_menu_->addAction("Save Config &As", this, SLOT(onSaveAs()), QKeySequence("Ctrl+Shift+S"));
+      file_menu_->addAction("配置另存为(&A)", this, SLOT(onSaveAs()), QKeySequence("Ctrl+Shift+S"));
   this->addAction(file_menu_save_as_action);
 
-  recent_configs_menu_ = file_menu_->addMenu("&Recent Configs");
-  file_menu_->addAction("Save &Image", this, SLOT(onSaveImage()));
+  recent_configs_menu_ = file_menu_->addMenu("最近使用配置(&R)");
+  file_menu_->addAction("保存图像(&I)", this, SLOT(onSaveImage()));
   if (show_choose_new_master_option_)
   {
     file_menu_->addSeparator();
     file_menu_->addAction("Change &Master", this, SLOT(changeMaster()));
   }
   file_menu_->addSeparator();
-  file_menu_->addAction("&Preferences", this, SLOT(openPreferencesDialog()), QKeySequence("Ctrl+P"));
+  file_menu_->addAction("设置(&P)", this, SLOT(openPreferencesDialog()), QKeySequence("Ctrl+P"));
 
   QAction* file_menu_quit_action =
-      file_menu_->addAction("&Quit", this, SLOT(close()), QKeySequence("Ctrl+Q"));
+      file_menu_->addAction("退出(&Q)", this, SLOT(close()), QKeySequence("Ctrl+Q"));
   this->addAction(file_menu_quit_action);
 
-  view_menu_ = menuBar()->addMenu("&Panels");
-  view_menu_->addAction("Add &New Panel", this, SLOT(openNewPanelDialog()));
-  delete_view_menu_ = view_menu_->addMenu("&Delete Panel");
+  view_menu_ = menuBar()->addMenu("面板(&P)");
+  view_menu_->addAction("添加(&N)", this, SLOT(openNewPanelDialog()));
+  delete_view_menu_ = view_menu_->addMenu("删除(&D)");
   delete_view_menu_->setEnabled(false);
 
   QAction* fullscreen_action =
-      view_menu_->addAction("&Fullscreen", this, SLOT(setFullScreen(bool)), Qt::Key_F11);
+      view_menu_->addAction("全屏(&F)", this, SLOT(setFullScreen(bool)), Qt::Key_F11);
   fullscreen_action->setCheckable(true);
   this->addAction(
       fullscreen_action); // Also add to window, or the shortcut doest work when the menu is hidden.
   connect(this, SIGNAL(fullS
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值