-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Porting GUI to Qt-5 #13
Open
bowang
wants to merge
8
commits into
ros-perception:master
Choose a base branch
from
bowang:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
439066c
Ported GUI to Qt-5
bowang e650a9e
Replace self-defined max double with DBL_MAX
bowang cd0b134
gfs_simplegui runs on Qt-5
bowang 8324637
Reformated source code in the gui folder
bowang 3690017
Re-enabled configfile_test
bowang 8dff628
Reformatted configfile
bowang f51e24d
Added back configfile/test.ini
bowang 1760a58
Re-enabled particlefilter_test and range_bearing
bowang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
*.o | ||
bin/ | ||
lib/ | ||
.project | ||
.cproject | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include_directories(../include/gmapping) | ||
add_library(configfile configfile.cpp) | ||
install(TARGETS configfile DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) | ||
|
||
add_executable(configfile_test configfile_test.cpp) | ||
target_link_libraries(configfile_test configfile) | ||
install(TARGETS configfile_test DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,331 @@ | ||
/***************************************************************** | ||
* | ||
* This file is part of the GMAPPING project | ||
* | ||
* GMAPPING Copyright (c) 2004 Giorgio Grisetti, | ||
* Cyrill Stachniss, and Wolfram Burgard | ||
* | ||
* This software is licensed under the "Creative Commons | ||
* License (Attribution-NonCommercial-ShareAlike 2.0)" | ||
* and is copyrighted by Giorgio Grisetti, Cyrill Stachniss, | ||
* and Wolfram Burgard. | ||
* | ||
* Further information on this license can be found at: | ||
* http://creativecommons.org/licenses/by-nc-sa/2.0/ | ||
* | ||
* GMAPPING is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. | ||
* | ||
*****************************************************************/ | ||
|
||
#include <configfile/configfile.h> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <string> | ||
#include <sstream> | ||
#include <iostream> | ||
#include <ctype.h> | ||
|
||
namespace GMapping | ||
{ | ||
|
||
using namespace std; | ||
|
||
AutoVal::AutoVal(std::string const& value) | ||
{ | ||
m_value = value; | ||
} | ||
|
||
AutoVal::AutoVal(const char* c) | ||
{ | ||
m_value = c; | ||
} | ||
|
||
AutoVal::AutoVal(double d) | ||
{ | ||
std::stringstream s; | ||
s << d; | ||
m_value = s.str(); | ||
} | ||
|
||
AutoVal::AutoVal(bool d) | ||
{ | ||
std::stringstream s; | ||
if (d) | ||
s << "on"; | ||
else | ||
s << "off"; | ||
m_value = s.str(); | ||
} | ||
|
||
AutoVal::AutoVal(int i) | ||
{ | ||
std::stringstream s; | ||
s << i; | ||
m_value = s.str(); | ||
} | ||
|
||
AutoVal::AutoVal(unsigned int i) | ||
{ | ||
std::stringstream s; | ||
s << i; | ||
m_value = s.str(); | ||
} | ||
|
||
AutoVal::AutoVal(AutoVal const& other) | ||
{ | ||
m_value = other.m_value; | ||
} | ||
|
||
AutoVal& AutoVal::operator=(AutoVal const& other) | ||
{ | ||
m_value = other.m_value; | ||
return *this; | ||
} | ||
|
||
AutoVal& AutoVal::operator=(double d) | ||
{ | ||
std::stringstream s; | ||
s << d; | ||
m_value = s.str(); | ||
return *this; | ||
} | ||
|
||
AutoVal& AutoVal::operator=(bool d) | ||
{ | ||
std::stringstream s; | ||
if (d) | ||
s << "on"; | ||
else | ||
s << "off"; | ||
m_value = s.str(); | ||
return *this; | ||
} | ||
|
||
AutoVal& AutoVal::operator=(int i) | ||
{ | ||
std::stringstream s; | ||
s << i; | ||
m_value = s.str(); | ||
return *this; | ||
} | ||
|
||
AutoVal& AutoVal::operator=(unsigned int i) | ||
{ | ||
std::stringstream s; | ||
s << i; | ||
m_value = s.str(); | ||
return *this; | ||
} | ||
|
||
AutoVal& AutoVal::operator=(std::string const& s) | ||
{ | ||
m_value = s; | ||
return *this; | ||
} | ||
|
||
AutoVal::operator std::string() const | ||
{ | ||
return m_value; | ||
} | ||
|
||
AutoVal::operator double() const | ||
{ | ||
return atof(m_value.c_str()); | ||
} | ||
|
||
AutoVal::operator int() const | ||
{ | ||
return atoi(m_value.c_str()); | ||
} | ||
|
||
AutoVal::operator unsigned int() const | ||
{ | ||
return (unsigned int) atoi(m_value.c_str()); | ||
} | ||
|
||
AutoVal::operator bool() const | ||
{ | ||
// stupid c++ does not allow compareNoCase... | ||
if (toLower(m_value) == "on" || atoi(m_value.c_str()) == 1) | ||
return true; | ||
return false; | ||
} | ||
|
||
std::string AutoVal::toLower(std::string const& source) const | ||
{ | ||
std::string result(source); | ||
char c = '\0'; | ||
for (unsigned int i = 0; i < result.length(); i++) { | ||
c = result[i]; | ||
c = ::tolower(c); | ||
result[i] = c; | ||
} | ||
return result; | ||
} | ||
|
||
////////////////////////////////////////////////////////// | ||
|
||
ConfigFile::ConfigFile() | ||
{ | ||
} | ||
|
||
ConfigFile::ConfigFile(std::string const& configFile) | ||
{ | ||
read(configFile); | ||
} | ||
|
||
bool ConfigFile::read(std::string const& configFile) | ||
{ | ||
std::ifstream file(configFile.c_str()); | ||
|
||
if (!file || file.eof()) | ||
return false; | ||
|
||
std::string line; | ||
std::string name; | ||
std::string val; | ||
std::string inSection; | ||
while (std::getline(file, line)) { | ||
|
||
if (!line.length()) | ||
continue; | ||
// cute the comments | ||
if (line[0] == '#') | ||
continue; | ||
line = truncate(line, "#"); | ||
line = trim(line); | ||
if (!line.length()) | ||
continue; | ||
|
||
if (line[0] == '[') { | ||
inSection = trim(line.substr(1, line.find(']') - 1)); | ||
continue; | ||
} | ||
|
||
istringstream lineStream(line); | ||
lineStream >> name; | ||
lineStream >> val; | ||
insertValue(inSection, name, val); | ||
} | ||
return true; | ||
} | ||
|
||
void ConfigFile::insertValue(std::string const& section, std::string const& entry, std::string const& thevalue) | ||
{ | ||
m_content[toLower(section) + '/' + toLower(entry)] = AutoVal(thevalue); | ||
} | ||
|
||
AutoVal const& ConfigFile::value(std::string const& section, std::string const& entry) const | ||
{ | ||
|
||
std::map<std::string, AutoVal>::const_iterator ci = | ||
m_content.find(toLower(section) + '/' + toLower(entry)); | ||
if (ci == m_content.end()) | ||
throw "entry does not exist"; | ||
|
||
return ci->second; | ||
} | ||
|
||
AutoVal const& ConfigFile::value(std::string const& section, std::string const& entry, double def) | ||
{ | ||
try { | ||
return value(section, entry); | ||
} | ||
catch (const char *) { | ||
return m_content.insert(std::make_pair(section + '/' + entry, AutoVal(def))).first->second; | ||
} | ||
} | ||
|
||
AutoVal const& ConfigFile::value(std::string const& section, std::string const& entry, bool def) | ||
{ | ||
try { | ||
return value(section, entry); | ||
} | ||
catch (const char *) { | ||
return m_content.insert(std::make_pair(section + '/' + entry, AutoVal(def))).first->second; | ||
} | ||
} | ||
|
||
AutoVal const& ConfigFile::value(std::string const& section, std::string const& entry, int def) | ||
{ | ||
try { | ||
return value(section, entry); | ||
} | ||
catch (const char *) { | ||
return m_content.insert(std::make_pair(section + '/' + entry, AutoVal(def))).first->second; | ||
} | ||
} | ||
|
||
AutoVal const& ConfigFile::value(std::string const& section, std::string const& entry, unsigned int def) | ||
{ | ||
try { | ||
return value(section, entry); | ||
} | ||
catch (const char *) { | ||
return m_content.insert(std::make_pair(section + '/' + entry, AutoVal(def))).first->second; | ||
} | ||
} | ||
|
||
AutoVal const& ConfigFile::value(std::string const& section, std::string const& entry, std::string const& def) | ||
{ | ||
try { | ||
return value(section, entry); | ||
} | ||
catch (const char *) { | ||
return m_content.insert(std::make_pair(section + '/' + entry, AutoVal(def))).first->second; | ||
} | ||
} | ||
|
||
void ConfigFile::dumpValues(std::ostream& out) | ||
{ | ||
|
||
for (std::map<std::string, AutoVal>::const_iterator it = m_content.begin(); | ||
it != m_content.end(); it++) { | ||
out << (std::string) it->first << " " << (std::string) it->second << std::endl; | ||
} | ||
} | ||
|
||
std::string ConfigFile::trim(std::string const& source, char const* delims) const | ||
{ | ||
std::string result(source); | ||
std::string::size_type index = result.find_last_not_of(delims); | ||
if (index != std::string::npos) | ||
result.erase(++index); | ||
|
||
index = result.find_first_not_of(delims); | ||
if (index != std::string::npos) | ||
result.erase(0, index); | ||
else | ||
result.erase(); | ||
return result; | ||
} | ||
|
||
std::string ConfigFile::truncate(std::string const& source, const char* atChar) const | ||
{ | ||
std::string::size_type index = source.find_first_of(atChar); | ||
|
||
if (index == 0) | ||
return ""; | ||
else if (index == std::string::npos) { | ||
return source; | ||
} | ||
return | ||
source.substr(0, index); | ||
} | ||
|
||
std::string ConfigFile::toLower(std::string const& source) const | ||
{ | ||
std::string result(source); | ||
char c = '\0'; | ||
for (unsigned int i = 0; i < result.length(); i++) { | ||
c = result[i]; | ||
c = ::tolower(c); | ||
result[i] = c; | ||
} | ||
return result; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this library an INI parser ? Why not used the standard boost property tree? http://www.boost.org/doc/libs/1_55_0/doc/html/boost_propertytree/parsers.html#boost_propertytree.parsers.ini_parser