Skip to content
Snippets Groups Projects
Commit 85ff0d8e authored by Fabian Reister's avatar Fabian Reister
Browse files

Merge branch 'feature/arviz_scoped_client' into 'master'

Feature/arviz scoped client

See merge request ArmarX/RobotAPI!155
parents e7951fc6 2bffd0d3
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ set(SOURCES
Client/elements/Robot.cpp
Client/elements/RobotHand.cpp
Client/drawer/ArVizDrawerBase.cpp
Client/ScopedClient.cpp
Coin/ElementVisualizer.cpp
......@@ -65,6 +66,7 @@ set(HEADERS
Client/Layer.h
Client/Elements.h
Client/Client.h
Client/ScopedClient.h
Client/ClientCGALExtensions.h
Client/Color.h
......
......@@ -51,7 +51,7 @@ namespace armarx::viz
// ////////////////////////////////////////////////////////////////// //
//layer
Layer layer(std::string const& name) const
virtual Layer layer(std::string const& name) const
{
return Layer(componentName, name);
}
......
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Fabian Reister ( fabian dot reister at kit dot edu )
* @date 2021
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include "ScopedClient.h"
namespace armarx::viz
{
Layer ScopedClient::layer(std::string const& name) const
{
layers.insert(name);
return Client::layer(name);
}
ScopedClient::~ScopedClient()
{
for (const auto& layer : layers)
{
Client::commitDeleteLayer(layer);
}
}
} // namespace armarx::viz
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Fabian Reister ( fabian dot reister at kit dot edu )
* @date 2021
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include <set>
#include "Client.h"
namespace armarx::viz
{
/**
* @brief `viz::Client` that will delete (clear) committed layers when destroyed.
*
* Note that, as a consequence, a network call be performed in the destructor.
*
* This might be useful if you have a class `MyTask` perform visualizing while performing some task,
* but whose visualization should be removed when the task finished.
* In this case, `MyTask` can have a `viz::ScopedClient` (which can be created from a regular `viz::Client`).
* When destructing the instance of `MyTask`, all visualization done by `MyTask` will be cleared
* (as `viz::ScopedClient` will go out of scope as well).
*
*/
class ScopedClient: virtual public Client
{
public:
using Client::Client;
Layer layer(std::string const& name) const override;
virtual ~ScopedClient();
private:
mutable std::set<std::string> layers;
};
} // namespace armarx::viz
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment