Gazebo Sim

API Reference

8.6.0
ResourceSpawner Class Reference

Provides interface for communicating to backend for generation of local models. More...

#include <ResourceSpawner.hh>

Public Slots

void DisplayResources ()
 Displays the resources to the qml grid abiding by all search and sort criteria. More...
 
void OnDownloadFuelResource (const QString &_path, const QString &_name, const QString &_owner, int index)
 Callback when a request is made to download a fuel resource. More...
 
void OnOwnerClicked (const QString &_owner)
 Callback when a fuel owner is selected, will clear the currently loaded resources and load the ones belonging to the specified owner. More...
 
void OnPathClicked (const QString &_path)
 Callback when a resource path is selected, will clear the currently loaded resources and load the ones at the specified path. More...
 
void OnResourceSpawn (const QString &_sdfPath)
 Callback when a resource is selected. More...
 
void OnSearchEntered (const QString &_searchKeyword)
 Callback when a search request is made. More...
 
void OnSortChosen (const QString &_sortType)
 Callback when a sort request is made. More...
 

Signals

void resourceSpawnerError (const QString &_errorMsg)
 Signal emitted when an error is encountered regarding an owner. More...
 

Public Member Functions

 ResourceSpawner ()
 Constructor. More...
 
 ~ResourceSpawner () override
 Destructor. More...
 
Q_INVOKABLE bool AddOwner (const QString &_owner)
 Add owner to the list of owners whose resources would be fetched from Fuel. More...
 
void AddPath (const std::string &_path)
 Adds a path to the path list model. More...
 
void FilterResources (std::vector< Resource > &_resources)
 Filters the vector of resources by the previously entered search keyword. More...
 
std::vector< ResourceFuelResources (const std::string &_owner)
 Returns the fuel resources as a vector belonging to the passed in owner. More...
 
Q_INVOKABLE bool IsDefaultOwner (const QString &_owner) const
 Determine if owner is the default owner. More...
 
void LoadConfig (const tinyxml2::XMLElement *_pluginElem) override
 
Resource LocalResource (const std::string &_path)
 Returns the resource corresponding to the model.config file. More...
 
std::vector< ResourceLocalResources (const std::string &_path)
 Returns the local resources as a vector located under the passed in path. More...
 
Q_INVOKABLE void RemoveOwner (const QString &_owner)
 Remove owner from the list of owners whose resources would be fetched from Fuel. More...
 
void Resources (std::vector< Resource > &_resources)
 Populates the passed in _resources vector with the currently selected group of resources. More...
 
void SetThumbnail (const std::string &_thumbnailPath, Resource &_resource)
 Finds a thumbnail on the provided thumbnail path and sets the model's thumbnail path attribute to it, no action is taken if no thumbnail is found. More...
 
void SortResources (std::vector< Resource > &_resources)
 Sorts the vector of resources by the previously entered sort method. The sorting types as a string, are "Most Recent", "A - Z", "Z - A", and "Downloaded." The sort defaults to "Most Recent.". More...
 
Q_INVOKABLE void UpdateOwnerListModel (Resource _resource)
 Called form a download thread to update the GUI's list of resources. More...
 
- Public Member Functions inherited from Plugin
 Plugin ()
 
virtual ~Plugin ()
 
QQuickItem * CardItem () const
 
virtual std::string ConfigStr ()
 
QQmlContext * Context () const
 
bool DeleteLaterRequested () const
 
void Load (const tinyxml2::XMLElement *_pluginElem)
 
QQuickItem * PluginItem () const
 
void PostParentChanges ()
 
virtual std::string Title () const
 

Additional Inherited Members

- Protected Member Functions inherited from Plugin
void DeleteLater ()
 
- Protected Attributes inherited from Plugin
std::string configStr
 
std::string title
 

Detailed Description

Provides interface for communicating to backend for generation of local models.

Constructor & Destructor Documentation

◆ ResourceSpawner()

Constructor.

◆ ~ResourceSpawner()

~ResourceSpawner ( )
override

Destructor.

Member Function Documentation

◆ AddOwner()

Q_INVOKABLE bool AddOwner ( const QString &  _owner)

Add owner to the list of owners whose resources would be fetched from Fuel.

Parameters
[in]_ownerName of owner.
Returns
True if the owner was successfully added.

◆ AddPath()

void AddPath ( const std::string _path)

Adds a path to the path list model.

Parameters
[in]_pathThe path to add

◆ DisplayResources

void DisplayResources ( )
slot

Displays the resources to the qml grid abiding by all search and sort criteria.

◆ FilterResources()

void FilterResources ( std::vector< Resource > &  _resources)

Filters the vector of resources by the previously entered search keyword.

Parameters
[in,out]_resourcesThe vector of resources to filter

◆ FuelResources()

std::vector<Resource> FuelResources ( const std::string _owner)

Returns the fuel resources as a vector belonging to the passed in owner.

Parameters
[in]_ownerThe name of the owner
Returns
The vector of resources

◆ IsDefaultOwner()

Q_INVOKABLE bool IsDefaultOwner ( const QString &  _owner) const

Determine if owner is the default owner.

Parameters
[in]_ownerName of owner.

◆ LoadConfig()

void LoadConfig ( const tinyxml2::XMLElement *  _pluginElem)
overridevirtual

Reimplemented from Plugin.

◆ LocalResource()

Resource LocalResource ( const std::string _path)

Returns the resource corresponding to the model.config file.

Parameters
[in]_pathThe path of the model.config file
Returns
The local resource

◆ LocalResources()

std::vector<Resource> LocalResources ( const std::string _path)

Returns the local resources as a vector located under the passed in path.

Parameters
[in]_pathThe path to search
Returns
The vector of resources

◆ OnDownloadFuelResource

void OnDownloadFuelResource ( const QString &  _path,
const QString &  _name,
const QString &  _owner,
int  index 
)
slot

Callback when a request is made to download a fuel resource.

Parameters
[in]_pathURI to the fuel resource
[in]_nameName of the resource
[in]_ownerThe name of the owner
[in]indexThe index of the grid pane to update

◆ OnOwnerClicked

void OnOwnerClicked ( const QString &  _owner)
slot

Callback when a fuel owner is selected, will clear the currently loaded resources and load the ones belonging to the specified owner.

Parameters
[in]_ownerThe name of the owner

◆ OnPathClicked

void OnPathClicked ( const QString &  _path)
slot

Callback when a resource path is selected, will clear the currently loaded resources and load the ones at the specified path.

Parameters
[in]_pathThe path to search resources

◆ OnResourceSpawn

void OnResourceSpawn ( const QString &  _sdfPath)
slot

Callback when a resource is selected.

Parameters
[in]_sdfPathThe absolute path to the resource's sdf file

◆ OnSearchEntered

void OnSearchEntered ( const QString &  _searchKeyword)
slot

Callback when a search request is made.

Parameters
[in]_searchKeywordThe search keyword, applies to either the resource's name or owner

◆ OnSortChosen

void OnSortChosen ( const QString &  _sortType)
slot

Callback when a sort request is made.

Parameters
[in]_sortTypeThe sorting type as a string, accepts "Most Recent", "A - Z", "Z - A", and "Downloaded." Defaults to "Most Recent."

◆ RemoveOwner()

Q_INVOKABLE void RemoveOwner ( const QString &  _owner)

Remove owner from the list of owners whose resources would be fetched from Fuel.

Parameters
[in]_ownerName of owner.

◆ Resources()

void Resources ( std::vector< Resource > &  _resources)

Populates the passed in _resources vector with the currently selected group of resources.

Parameters
[in,out]_resourcesThe vector of resources to populate

◆ resourceSpawnerError

void resourceSpawnerError ( const QString &  _errorMsg)
signal

Signal emitted when an error is encountered regarding an owner.

Parameters
[in]_errorMsgError message to be displayed.

◆ SetThumbnail()

void SetThumbnail ( const std::string _thumbnailPath,
Resource _resource 
)

Finds a thumbnail on the provided thumbnail path and sets the model's thumbnail path attribute to it, no action is taken if no thumbnail is found.

Parameters
[in]_thumbnailPathThe path to search for a thumbnail
[in]_resourceThe model to update with the thumbnail information

◆ SortResources()

void SortResources ( std::vector< Resource > &  _resources)

Sorts the vector of resources by the previously entered sort method. The sorting types as a string, are "Most Recent", "A - Z", "Z - A", and "Downloaded." The sort defaults to "Most Recent.".

Parameters
[in,out]_resourcesThe vector of resources to sort

◆ UpdateOwnerListModel()

Q_INVOKABLE void UpdateOwnerListModel ( Resource  _resource)

Called form a download thread to update the GUI's list of resources.

Parameters
[in]_resourceThe resource fetched from Fuel. Note that it is passed by value as a copy is necessary to update the resource if it's cached.

The documentation for this class was generated from the following file: