mirror of
https://github.com/swri-robotics/mapviz.git
synced 2025-09-15 17:48:34 +08:00
Compare commits
2 Commits
f595a2cbc3
...
4050575f21
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4050575f21 | ||
|
|
3f527c67ac |
@ -349,18 +349,9 @@ protected:
|
|||||||
emitter << YAML::Key << prefix + "qos_durability" << YAML::Value << qos.durability;
|
emitter << YAML::Key << prefix + "qos_durability" << YAML::Value << qos.durability;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// Dealing with YAML frequently requires trimming whitespace from strings
|
||||||
// Collect basic profiling info to know how much time each plugin
|
inline std::string TrimString(const std::string& str)
|
||||||
// spends in Transform(), Paint(), and Draw().
|
{
|
||||||
Stopwatch meas_transform_;
|
|
||||||
Stopwatch meas_paint_;
|
|
||||||
Stopwatch meas_draw_;
|
|
||||||
};
|
|
||||||
typedef std::shared_ptr<MapvizPlugin> MapvizPluginPtr;
|
|
||||||
|
|
||||||
// Dealing with YAML frequently requires trimming whitespace from strings
|
|
||||||
inline std::string TrimString(const std::string& str)
|
|
||||||
{
|
|
||||||
auto begin = str.begin();
|
auto begin = str.begin();
|
||||||
auto end = str.end();
|
auto end = str.end();
|
||||||
|
|
||||||
@ -381,7 +372,16 @@ inline std::string TrimString(const std::string& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return std::string(begin, end);
|
return std::string(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Collect basic profiling info to know how much time each plugin
|
||||||
|
// spends in Transform(), Paint(), and Draw().
|
||||||
|
Stopwatch meas_transform_;
|
||||||
|
Stopwatch meas_paint_;
|
||||||
|
Stopwatch meas_draw_;
|
||||||
|
};
|
||||||
|
typedef std::shared_ptr<MapvizPlugin> MapvizPluginPtr;
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
inline void MapvizPlugin::PrintErrorHelper(QLabel *status_label, const std::string &message,
|
inline void MapvizPlugin::PrintErrorHelper(QLabel *status_label, const std::string &message,
|
||||||
|
|||||||
@ -540,9 +540,7 @@ namespace mapviz_plugins
|
|||||||
LoadQosConfig(node, qos_);
|
LoadQosConfig(node, qos_);
|
||||||
if (node["topic"])
|
if (node["topic"])
|
||||||
{
|
{
|
||||||
std::string topic = node["topic"].as<std::string>();
|
std::string trimmed = TrimString(node["topic"].as<std::string>());
|
||||||
std::string trimmed = topic;
|
|
||||||
trimmed.erase(std::remove_if(trimmed.begin(), trimmed.end(), ::isspace), trimmed.end());
|
|
||||||
ui_.topic->setText(trimmed.c_str());
|
ui_.topic->setText(trimmed.c_str());
|
||||||
TopicEdited();
|
TopicEdited();
|
||||||
}
|
}
|
||||||
@ -666,8 +664,7 @@ namespace mapviz_plugins
|
|||||||
void LaserScanPlugin::SaveConfig(YAML::Emitter& emitter,
|
void LaserScanPlugin::SaveConfig(YAML::Emitter& emitter,
|
||||||
const std::string& path)
|
const std::string& path)
|
||||||
{
|
{
|
||||||
std::string trimmed = ui_.topic->text().toStdString();
|
std::string trimmed = TrimString(ui_.topic->text().toStdString());
|
||||||
trimmed.erase(std::remove_if(trimmed.begin(), trimmed.end(), ::isspace), trimmed.end());
|
|
||||||
|
|
||||||
emitter << YAML::Key << "topic" <<
|
emitter << YAML::Key << "topic" <<
|
||||||
YAML::Value << trimmed;
|
YAML::Value << trimmed;
|
||||||
|
|||||||
@ -698,8 +698,7 @@ namespace mapviz_plugins
|
|||||||
LoadQosConfig(node, qos_);
|
LoadQosConfig(node, qos_);
|
||||||
if (node["topic"])
|
if (node["topic"])
|
||||||
{
|
{
|
||||||
std::string topic = node["topic"].as<std::string>();
|
std::string topic = TrimString(node["topic"].as<std::string>());
|
||||||
topic.erase(std::remove_if(topic.begin(), topic.end(), ::isspace), topic.end());
|
|
||||||
ui_.topic->setText(topic.c_str());
|
ui_.topic->setText(topic.c_str());
|
||||||
|
|
||||||
TopicEdited();
|
TopicEdited();
|
||||||
@ -708,8 +707,7 @@ namespace mapviz_plugins
|
|||||||
|
|
||||||
void MarkerPlugin::SaveConfig(YAML::Emitter& emitter, const std::string& path)
|
void MarkerPlugin::SaveConfig(YAML::Emitter& emitter, const std::string& path)
|
||||||
{
|
{
|
||||||
std::string trimmed = ui_.topic->text().toStdString();
|
std::string trimmed = TrimString(ui_.topic->text().toStdString());
|
||||||
trimmed.erase(std::remove_if(trimmed.begin(), trimmed.end(), ::isspace), trimmed.end());
|
|
||||||
emitter << YAML::Key
|
emitter << YAML::Key
|
||||||
<< "topic"
|
<< "topic"
|
||||||
<< YAML::Value
|
<< YAML::Value
|
||||||
|
|||||||
@ -738,8 +738,7 @@ namespace mapviz_plugins
|
|||||||
|
|
||||||
if (node["topic"])
|
if (node["topic"])
|
||||||
{
|
{
|
||||||
std::string topic = node["topic"].as<std::string>();
|
std::string topic = TrimString(node["topic"].as<std::string>());
|
||||||
topic.erase(std::remove_if(topic.begin(), topic.end(), ::isspace), topic.end());
|
|
||||||
ui_.topic->setText(topic.c_str());
|
ui_.topic->setText(topic.c_str());
|
||||||
TopicEdited();
|
TopicEdited();
|
||||||
}
|
}
|
||||||
@ -864,8 +863,7 @@ namespace mapviz_plugins
|
|||||||
void PointCloud2Plugin::SaveConfig(YAML::Emitter& emitter,
|
void PointCloud2Plugin::SaveConfig(YAML::Emitter& emitter,
|
||||||
const std::string& path)
|
const std::string& path)
|
||||||
{
|
{
|
||||||
std::string topic = ui_.topic->text().toStdString();
|
std::string topic = TrimString(ui_.topic->text().toStdString());
|
||||||
topic.erase(std::remove_if(topic.begin(), topic.end(), ::isspace), topic.end());
|
|
||||||
emitter << YAML::Key << "topic" <<
|
emitter << YAML::Key << "topic" <<
|
||||||
YAML::Value << topic;
|
YAML::Value << topic;
|
||||||
emitter << YAML::Key << "size" <<
|
emitter << YAML::Key << "size" <<
|
||||||
|
|||||||
@ -531,8 +531,7 @@ void TexturedMarkerPlugin::LoadConfig(const YAML::Node & node, const std::string
|
|||||||
{
|
{
|
||||||
LoadQosConfig(node, qos_);
|
LoadQosConfig(node, qos_);
|
||||||
if (node["topic"]) {
|
if (node["topic"]) {
|
||||||
std::string topic = node["topic"].as<std::string>();
|
std::string topic = TrimString(node["topic"].as<std::string>());
|
||||||
topic.erase(std::remove_if(topic.begin(), topic.end(), ::isspace), topic.end());
|
|
||||||
ui_.topic->setText(topic.c_str());
|
ui_.topic->setText(topic.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,8 +540,7 @@ void TexturedMarkerPlugin::LoadConfig(const YAML::Node & node, const std::string
|
|||||||
|
|
||||||
void TexturedMarkerPlugin::SaveConfig(YAML::Emitter & emitter, const std::string & path)
|
void TexturedMarkerPlugin::SaveConfig(YAML::Emitter & emitter, const std::string & path)
|
||||||
{
|
{
|
||||||
std::string topic = ui_.topic->text().toStdString();
|
std::string topic = TrimString(ui_.topic->text().toStdString());
|
||||||
topic.erase(std::remove_if(topic.begin(), topic.end(), ::isspace), topic.end());
|
|
||||||
emitter << YAML::Key << "topic" << YAML::Value << topic;
|
emitter << YAML::Key << "topic" << YAML::Value << topic;
|
||||||
|
|
||||||
SaveQosConfig(emitter, qos_);
|
SaveQosConfig(emitter, qos_);
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
//
|
//
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
|
||||||
|
#include <mapviz/mapviz_plugin.h>
|
||||||
#include <tile_map/tile_map_plugin.h>
|
#include <tile_map/tile_map_plugin.h>
|
||||||
#include <tile_map/tile_source.h>
|
#include <tile_map/tile_source.h>
|
||||||
#include <tile_map/bing_source.h>
|
#include <tile_map/bing_source.h>
|
||||||
@ -399,6 +400,19 @@ namespace tile_map
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string trim_whitespace(const std::string& in)
|
||||||
|
{
|
||||||
|
std::string out;
|
||||||
|
const char* whitespace = " \t";
|
||||||
|
auto begin = in.find_first_not_of(whitespace);
|
||||||
|
if (begin == std::string::npos)
|
||||||
|
{
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
auto end = in.find_last_not_of(whitespace);
|
||||||
|
return in.substr(begin, (end - begin + 1));
|
||||||
|
}
|
||||||
|
|
||||||
void TileMapPlugin::SaveConfig(YAML::Emitter& emitter, const std::string&)
|
void TileMapPlugin::SaveConfig(YAML::Emitter& emitter, const std::string&)
|
||||||
{
|
{
|
||||||
emitter << YAML::Key << CUSTOM_SOURCES_KEY << YAML::Value << YAML::BeginSeq;
|
emitter << YAML::Key << CUSTOM_SOURCES_KEY << YAML::Value << YAML::BeginSeq;
|
||||||
@ -418,14 +432,11 @@ namespace tile_map
|
|||||||
}
|
}
|
||||||
emitter << YAML::EndSeq;
|
emitter << YAML::EndSeq;
|
||||||
|
|
||||||
|
|
||||||
BingSource* bing_source = dynamic_cast<BingSource*>(tile_sources_[BING_NAME].get());
|
BingSource* bing_source = dynamic_cast<BingSource*>(tile_sources_[BING_NAME].get());
|
||||||
std::string bing_key = bing_source->GetApiKey().toStdString();
|
std::string bing_key = TrimString(bing_source->GetApiKey().toStdString());
|
||||||
bing_key.erase(std::remove_if(bing_key.begin(), bing_key.end(), ::isspace), bing_key.end());
|
|
||||||
emitter << YAML::Key << BING_API_KEY << YAML::Value << bing_key;
|
emitter << YAML::Key << BING_API_KEY << YAML::Value << bing_key;
|
||||||
|
|
||||||
std::string combo_str = ui_.source_combo->currentText().toStdString();
|
std::string combo_str = TrimString(ui_.source_combo->currentText().toStdString());
|
||||||
combo_str.erase(std::remove_if(combo_str.begin(), combo_str.end(), ::isspace), combo_str.end());
|
|
||||||
emitter << YAML::Key << SOURCE_KEY << YAML::Value << combo_str;
|
emitter << YAML::Key << SOURCE_KEY << YAML::Value << combo_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user