Skip to content

Commit

Permalink
Enable rviz -d my_config as shortcut for ~/.rviz/my_config.rviz (ro…
Browse files Browse the repository at this point in the history
  • Loading branch information
v4hn authored and rhaschke committed Sep 8, 2019
1 parent cfcdd4f commit 779cbe8
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/rviz/visualization_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,16 +720,28 @@ void VisualizationFrame::markRecentConfig( const std::string& path )
void VisualizationFrame::loadDisplayConfig( const QString& qpath )
{
std::string path = qpath.toStdString();
std::string actual_load_path = path;
if( !fs::exists( path ) || fs::is_directory( path ) || fs::is_empty( path ))
fs::path actual_load_path = path;
bool valid_load_path = (fs::is_regular_file(actual_load_path) || fs::is_symlink(actual_load_path));

if( !valid_load_path && fs::portable_posix_name(path) )
{
if (actual_load_path.extension() != "." CONFIG_EXTENSION)
actual_load_path += "." CONFIG_EXTENSION;
actual_load_path = fs::path(config_dir_) / actual_load_path;
valid_load_path = (fs::is_regular_file(actual_load_path) || fs::is_symlink(actual_load_path));
}

if( !valid_load_path )
{
actual_load_path = (fs::path(package_path_) / "default.rviz").BOOST_FILE_STRING();
if( !fs::exists( actual_load_path ))
actual_load_path = (fs::path(package_path_) / "default.rviz");
if (!(valid_load_path = (fs::is_regular_file(actual_load_path) || fs::is_symlink(actual_load_path))))
{
ROS_ERROR( "Default display config '%s' not found. RViz will be very empty at first.", actual_load_path.c_str() );
ROS_ERROR( "Default display config '%s' not found. RViz will be very empty at first.",
actual_load_path.BOOST_FILE_STRING().c_str() );
return;
}
}
assert( valid_load_path );

// Check if we have unsaved changes to the current config the same
// as we do during exit, with the same option to cancel.
Expand All @@ -751,7 +763,7 @@ void VisualizationFrame::loadDisplayConfig( const QString& qpath )

YamlConfigReader reader;
Config config;
reader.readFile( config, QString::fromStdString( actual_load_path ));
reader.readFile( config, QString::fromStdString( actual_load_path.BOOST_FILE_STRING() ));
if( !reader.error() )
{
load( config );
Expand Down

0 comments on commit 779cbe8

Please sign in to comment.