Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gepetto-viewer-corba
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gepetto
gepetto-viewer-corba
Commits
d3c5fc5c
Commit
d3c5fc5c
authored
8 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use osg::ArgumentParser instead of boost program_option
parent
b27fd880
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
src/gui/settings.cc
+57
-98
57 additions, 98 deletions
src/gui/settings.cc
with
58 additions
and
99 deletions
CMakeLists.txt
+
1
−
1
View file @
d3c5fc5c
...
...
@@ -56,7 +56,7 @@ IF(NOT CLIENT_ONLY)
ADD_REQUIRED_DEPENDENCY
(
"gepetto-viewer"
)
ADD_REQUIRED_DEPENDENCY
(
"urdfdom"
)
SET
(
BOOST_COMPONENTS
program_options
system thread regex
)
SET
(
BOOST_COMPONENTS system thread regex
)
SEARCH_FOR_BOOST
()
FIND_PACKAGE
(
Qt4 REQUIRED QtCore QtGui QtOpenGl QtNetwork
)
...
...
This diff is collapsed.
Click to expand it.
src/gui/settings.cc
+
57
−
98
View file @
d3c5fc5c
...
...
@@ -16,14 +16,13 @@
#include
<gepetto/gui/settings.hh>
#include
<boost/program_options.hpp>
#include
<boost/algorithm/string/split.hpp>
#include
<boost/algorithm/string/classification.hpp>
#include
<QSettings>
#include
<QDir>
#include
<QtDebug>
#include
<osg/DisplaySettings>
#include
<osg/ArgumentParser>
#include
<gepetto/gui/dialog/dialogloadrobot.hh>
#include
<gepetto/gui/dialog/dialogloadenvironment.hh>
#include
<gepetto/gui/mainwindow.hh>
...
...
@@ -32,8 +31,6 @@
# include <gepetto/gui/pythonwidget.hh>
#endif
namespace
po
=
boost
::
program_options
;
namespace
gepetto
{
namespace
gui
{
Settings
::
Settings
(
const
char
*
installDir
)
...
...
@@ -85,104 +82,66 @@ namespace gepetto {
int
Settings
::
fromArgv
(
const
int
argc
,
char
*
const
argv
[])
{
typedef
std
::
vector
<
std
::
string
>
Strings_t
;
bool
help
=
false
;
bool
genAndQuit
=
false
;
int
retVal
=
0
;
// Declare the supported options.
po
::
options_description
desc
(
"Options"
);
desc
.
add_options
()
(
"help,h"
,
"produce help message"
)
(
"verbose,v"
,
"activate verbose output"
)
(
"generate-config-files,g"
,
"generate configuration files and quit"
)
(
"config-file,c"
,
po
::
value
<
std
::
string
>
(
&
configurationFile
),
"set the configuration file (do not include .conf)"
)
(
"predefined-robots"
,
po
::
value
<
std
::
string
>
(
&
predifinedRobotConf
),
"set the predefined robots configuration file (do not include .conf)"
)
(
"predefined-environments"
,
po
::
value
<
std
::
string
>
(
&
predifinedEnvConf
),
"set the predefined environments configuration file (do not include .conf)"
)
(
"add-robot"
,
po
::
value
<
Strings_t
>
(),
"Add a robot (a list of comma sperated string)"
)
(
"add-env"
,
po
::
value
<
Strings_t
>
(),
"Add an environment (a list of comma sperated string)"
)
(
"load-plugin,p"
,
po
::
value
<
Strings_t
>
(),
"load the plugin"
)
(
"load-pyplugin,q"
,
po
::
value
<
Strings_t
>
(),
"load the PythonQt module as a plugin"
)
(
"no-plugin,P"
,
"do not load any plugin"
)
(
"auto-write-settings,w"
,
"write the settings in the configuration file"
)
(
"no-viewer-server"
,
"do not start the Gepetto Viewer server"
)
;
po
::
variables_map
vm
;
po
::
parsed_options
parsed
=
po
::
command_line_parser
(
argc
,
argv
)
.
options
(
desc
)
.
allow_unregistered
()
.
run
();
po
::
store
(
parsed
,
vm
);
po
::
notify
(
vm
);
Strings_t
unrecognized
=
po
::
collect_unrecognized
(
parsed
.
options
,
po
::
exclude_positional
);
help
=
(
vm
.
count
(
"help"
)
>
0
);
if
(
vm
.
count
(
"verbose"
)
>
0
)
verbose
=
true
;
if
(
vm
.
count
(
"no-plugin"
)
>
0
)
noPlugin
=
true
;
if
(
vm
.
count
(
"auto-write-settings"
)
>
0
)
autoWriteSettings
=
true
;
if
(
vm
.
count
(
"generate-config-files"
)
>
0
)
genAndQuit
=
true
;
if
(
vm
.
count
(
"no-viewer-server"
)
>
0
)
startGepettoCorbaServer
=
false
;
if
(
vm
.
count
(
"add-robot"
)
>
0
)
{
const
Strings_t
&
rbts
=
vm
[
"add-robot"
].
as
<
Strings_t
>
();
for
(
Strings_t
::
const_iterator
it
=
rbts
.
begin
();
it
!=
rbts
.
end
();
++
it
)
addRobotFromString
(
*
it
);
}
if
(
vm
.
count
(
"add-env"
)
>
0
)
{
const
Strings_t
&
envs
=
vm
[
"add-env"
].
as
<
Strings_t
>
();
for
(
Strings_t
::
const_iterator
it
=
envs
.
begin
();
it
!=
envs
.
end
();
++
it
)
addEnvFromString
(
*
it
);
}
if
(
vm
.
count
(
"load-plugin"
)
>
0
)
{
const
Strings_t
&
envs
=
vm
[
"load-plugin"
].
as
<
Strings_t
>
();
for
(
Strings_t
::
const_iterator
it
=
envs
.
begin
();
it
!=
envs
.
end
();
++
it
)
addPlugin
(
QString
::
fromStdString
(
*
it
),
!
noPlugin
);
}
if
(
vm
.
count
(
"load-pyplugin"
)
>
0
)
{
const
Strings_t
&
envs
=
vm
[
"load-pyplugin"
].
as
<
Strings_t
>
();
for
(
Strings_t
::
const_iterator
it
=
envs
.
begin
();
it
!=
envs
.
end
();
++
it
)
addPyPlugin
(
QString
::
fromStdString
(
*
it
),
!
noPlugin
);
}
osg
::
ArgumentParser
arguments
((
int
*
)
&
argc
,
(
char
**
)
argv
);
osg
::
ApplicationUsage
*
au
(
arguments
.
getApplicationUsage
());
au
->
setApplicationName
(
arguments
.
getApplicationName
());
au
->
setCommandLineUsage
(
arguments
.
getApplicationName
()
+
" [options]"
);
osg
::
ApplicationUsage
::
Type
help
(
arguments
.
readHelpType
());
au
->
addCommandLineOption
(
"-v or --verbose"
,
"Activate verbose output"
);
au
->
addCommandLineOption
(
"-g or --generate-config-files"
,
"generate configuration files and quit"
);
au
->
addCommandLineOption
(
"-c or --config-file"
,
"set the configuration file (do not include .conf)"
,
configurationFile
);
au
->
addCommandLineOption
(
"--predefined-robots"
,
"set the predefined robots configuration file (do not include .conf)"
,
predifinedRobotConf
);
au
->
addCommandLineOption
(
"--predefined-environments"
,
"set the predefined environments configuration file (do not include .conf)"
,
predifinedEnvConf
);
au
->
addCommandLineOption
(
"--add-robot"
,
"Add a robot (a list of comma sperated string)"
);
au
->
addCommandLineOption
(
"--add-env"
,
"Add an environment (a list of comma sperated string)"
);
au
->
addCommandLineOption
(
"-p or --load-plugin"
,
"load the plugin"
);
au
->
addCommandLineOption
(
"-q or --load-pyplugin"
,
"load the PythonQt module as a plugin"
);
au
->
addCommandLineOption
(
"-P or --no-plugin"
,
"do not load any plugin"
);
au
->
addCommandLineOption
(
"-w or --auto-write-settings"
,
"write the settings in the configuration file"
);
au
->
addCommandLineOption
(
"--no-viewer-server"
,
"do not start the Gepetto Viewer server"
);
osg
::
DisplaySettings
*
ds
=
osg
::
DisplaySettings
::
instance
().
get
();
ds
->
readCommandLine
(
arguments
);
// populate the help message.
verbose
=
(
arguments
.
read
(
"-v"
)
||
arguments
.
read
(
"--verbose"
));
genAndQuit
=
(
arguments
.
read
(
"-g"
)
||
arguments
.
read
(
"--generate-config-files"
));
noPlugin
=
(
arguments
.
read
(
"-P"
)
||
arguments
.
read
(
"--no-plugin"
));
autoWriteSettings
=
(
arguments
.
read
(
"-w"
)
||
arguments
.
read
(
"--auto-write-settings"
));
startGepettoCorbaServer
=
(
arguments
.
read
(
"--no-viewer-server"
));
std
::
string
opt
;
while
(
arguments
.
read
(
"--add-robot"
,
opt
))
addRobotFromString
(
opt
);
while
(
arguments
.
read
(
"--add-env"
,
opt
))
addEnvFromString
(
opt
);
while
(
arguments
.
read
(
"--load-plugin"
,
opt
))
addPlugin
(
QString
::
fromStdString
(
opt
),
!
noPlugin
);
while
(
arguments
.
read
(
"--load-pyplugin"
,
opt
))
addPyPlugin
(
QString
::
fromStdString
(
opt
),
!
noPlugin
);
if
(
arguments
.
read
(
"-c"
,
configurationFile
)
||
arguments
.
read
(
"--config-file"
,
configurationFile
))
{}
if
(
arguments
.
read
(
"--predefined-robots"
,
predifinedRobotConf
))
{}
if
(
arguments
.
read
(
"--predefined-environments"
,
predifinedEnvConf
))
{}
arguments
.
reportRemainingOptionsAsUnrecognized
(
osg
::
ArgumentParser
::
BENIGN
);
if
(
arguments
.
errors
(
osg
::
ArgumentParser
::
CRITICAL
))
{
arguments
.
writeErrorMessages
(
std
::
cout
);
retVal
=
2
;
}
else
if
(
arguments
.
errors
(
osg
::
ArgumentParser
::
BENIGN
))
{
arguments
.
writeErrorMessages
(
std
::
cout
);
}
if
(
help
||
genAndQuit
)
retVal
=
1
;
if
(
unrecognized
.
size
()
>
0
)
{
std
::
cout
<<
"Unrecognized options:
\n
"
;
for
(
std
::
size_t
i
=
0
;
i
<
unrecognized
.
size
();
++
i
)
std
::
cout
<<
unrecognized
[
i
]
<<
"
\n
"
;
std
::
cout
<<
"
\n
"
;
help
=
true
;
verbose
=
true
;
retVal
=
2
;
}
if
(
genAndQuit
&&
retVal
<
1
)
retVal
=
1
;
if
(
help
)
std
::
cout
<<
desc
<<
std
::
endl
;
if
(
help
!=
osg
::
ApplicationUsage
::
NO_HELP
)
{
au
->
write
(
std
::
cout
,
help
,
80
,
true
);
if
(
retVal
<
1
)
retVal
=
1
;
}
if
(
verbose
)
print
(
std
::
cout
)
<<
std
::
endl
;
if
(
genAndQuit
)
writeSettings
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment