예제 #1
0
// Loading and saving the flags
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//
// Tools with a fixed set of Property objects representing adjustable
// parameters are typically just created in the tool's constructor and
// added to the Property container (getPropertyContainer()).  In that
// case, the Tool subclass does not need to override load() and save()
// because the default behavior is to read all the Properties in the
// container from the Config object.
//
// Here however, we have a list of named flag positions of unknown
// length, so we need to implement save() and load() ourselves.
//
// We first save the class ID to the config object so the
// rviz::ToolManager will know what to instantiate when the config
// file is read back in.
void FlagTool3D::save( rviz::Config config ) const
{
    config.mapSetValue( "Class", getClassId() );

    // The top level of this tool's Config is a map, but our flags
    // should go in a list, since they may or may not have unique keys.
    // Therefore we make a child of the map (``flags_config``) to store
    // the list.
    rviz::Config flags_config = config.mapMakeChild( "Flags" );

    // To read the positions and names of the flags, we loop over the
    // the children of our Property container:
    rviz::Property* container = getPropertyContainer();
    int num_children = container->numChildren();
    for( int i = 0; i < num_children; i++ )
    {
        rviz::Property* position_prop = container->childAt( i );
        // For each Property, we create a new Config object representing a
        // single flag and append it to the Config list.
        rviz::Config flag_config = flags_config.listAppendNew();
        // Into the flag's config we store its name:
        flag_config.mapSetValue( "Name", position_prop->getName() );
        // ... and its position.
        position_prop->save( flag_config );
    }
}
예제 #2
0
  void CancelAction::save( rviz::Config config ) const
  {
    rviz::Panel::save( config );

    rviz::Config topic_list_config = config.mapMakeChild( "topics" );

    std::vector<topicListLayout>::const_iterator it = topic_list_layouts_.begin();
    while( it != topic_list_layouts_.end()){
      topic_list_config.listAppendNew().setValue( it->topic_name_->text() );
      it ++;
    }
    config.mapSetValue( "Topic", output_topic_ );
  }