Gazebo Gazebo

API Reference

6.18.0
gz/sim/rendering/RenderUtil.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_GAZEBO_RENDERUTIL_HH_
18 #define GZ_GAZEBO_RENDERUTIL_HH_
19 
20 #include <memory>
21 #include <set>
22 #include <string>
23 #include <vector>
24 
25 #include <sdf/Sensor.hh>
26 
27 #include <gz/sim/config.hh>
28 #include <gz/sim/rendering/Export.hh>
29 #include <gz/sim/System.hh>
30 
33 
34 
35 namespace ignition
36 {
37 namespace gazebo
38 {
39 // Inline bracket to help doxygen filtering.
40 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
41  // forward declaration
42  class RenderUtilPrivate;
43 
45  class IGNITION_GAZEBO_RENDERING_VISIBLE RenderUtil
46  {
48  public: explicit RenderUtil();
49 
51  public: ~RenderUtil();
52 
54  public: void Init();
55 
61  public: int PendingSensors() const;
62 
64  public: void Update();
65 
68  public: rendering::ScenePtr Scene() const;
69 
73  public: void UpdateECM(const UpdateInfo &_info,
75 
77  public: void UpdateFromECM(const UpdateInfo &_info,
78  const EntityComponentManager &_ecm);
79 
86  const std::set<Entity> &_entities);
87 
90  public: void SetEngineName(const std::string &_engineName);
91 
94  public: std::string EngineName() const;
95 
98  public: void SetHeadlessRendering(const bool &_headless);
99 
102  public: bool HeadlessRendering() const;
103 
106  public: void SetSceneName(const std::string &_sceneName);
107 
110  public: std::string SceneName() const;
111 
114  public: void SetScene(const rendering::ScenePtr &_scene);
115 
119  public: void SetBackgroundColor(const math::Color &_color);
120 
124  public: void SetAmbientLight(const math::Color &_ambient);
125 
128  public: void SetSkyEnabled(bool _enabled);
129 
131  public: void ShowGrid();
132 
135  public: void SetUseCurrentGLContext(bool _enable);
136 
139  public: void SetWinID(const std::string &_winID);
140 
146  public: void SetEnableSensors(bool _enable, std::function<
147  std::string(const gazebo::Entity &, const sdf::Sensor &,
148  const std::string &)> _createSensorCb = {});
149 
153  public : void SetRemoveSensorCb(
154  std::function<void(const gazebo::Entity &)> _removeSensorCb);
155 
158  public: void ViewTransparent(const Entity &_entity);
159 
162  public: void ViewCOM(const Entity &_entity);
163 
166  public: void ViewInertia(const Entity &_entity);
167 
170  public: void ViewJoints(const Entity &_entity);
171 
174  public: void ViewWireframes(const Entity &_entity);
175 
178  public: void ViewCollisions(const Entity &_entity);
179 
182  public: class SceneManager &SceneManager();
183 
186  public: class MarkerManager &MarkerManager();
187 
191  public: std::chrono::steady_clock::duration SimTime() const;
192 
195  public: void SetSelectedEntity(const rendering::NodePtr &_node);
196 
199  public: const std::vector<Entity> &SelectedEntities() const;
200 
202  public: void DeselectAllEntities();
203 
207 
211  private: std::vector<Entity> FindChildLinks(const Entity &_entity);
212 
215  private: void HideWireboxes(const Entity &_entity);
216 
219  public: void SetTransformActive(bool _active);
220 
223  public: void SetEventManager(EventManager *_mgr);
224 
226  private: std::unique_ptr<RenderUtilPrivate> dataPtr;
227  };
228 }
229 }
230 }
231 #endif
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:67
The EventManager is used to send/receive notifications of simulator events.
Definition: gz/sim/EventManager.hh:55
Creates, deletes, and maintains marker visuals. Only the Scene class should instantiate and use this ...
Definition: gz/sim/rendering/MarkerManager.hh:39
Definition: gz/sim/rendering/RenderUtil.hh:46
void SetHeadlessRendering(const bool &_headless)
Set the headless mode.
class SceneManager & SceneManager()
Get the scene manager Returns reference to the scene manager.
void Init()
Initialize the renderer. Must be called in the rendering thread.
void ViewWireframes(const Entity &_entity)
View wireframes of specified entity.
class MarkerManager & MarkerManager()
Get the marker manager Returns reference to the marker manager.
void SetWinID(const std::string &_winID)
Set the Window ID.
void SetScene(const rendering::ScenePtr &_scene)
Set the scene to use.
void SetEngineName(const std::string &_engineName)
Set the rendering engine to use.
std::string EngineName() const
Get the name of the rendering engine used.
void SetUseCurrentGLContext(bool _enable)
Set whether to use the current GL context.
std::chrono::steady_clock::duration SimTime() const
Get simulation time that the current rendering state corresponds to.
void SetSkyEnabled(bool _enabled)
Set whether to enable sky in the scene.
void ViewCOM(const Entity &_entity)
View center of mass of specified entity.
void ViewJoints(const Entity &_entity)
View joints of specified entity.
void CreateVisualsForEntities(const EntityComponentManager &_ecm, const std::set< Entity > &_entities)
Helper function to create visuals for new entities created in ECM. This function is intended to be us...
void ViewTransparent(const Entity &_entity)
View an entity as transparent.
void SetEnableSensors(bool _enable, std::function< std::string(const gazebo::Entity &, const sdf::Sensor &, const std::string &)> _createSensorCb={})
Set whether to create rendering sensors.
void ShowGrid()
Show grid view in the scene.
void SetEventManager(EventManager *_mgr)
Set the event manager to use.
void UpdateECM(const UpdateInfo &_info, EntityComponentManager &_ecm)
Helper Update function for updating the scene.
rendering::ScenePtr Scene() const
Get a pointer to the scene.
const std::vector< Entity > & SelectedEntities() const
Get the entities currently selected, in order of selection.
void DeselectAllEntities()
Clears the set of selected entities and lowlights all of them.
void ViewCollisions(const Entity &_entity)
View collisions of specified entity which are shown in orange.
void SetBackgroundColor(const math::Color &_color)
Set background color of render window. This will override other sources, such as from SDF.
void UpdateFromECM(const UpdateInfo &_info, const EntityComponentManager &_ecm)
Helper PostUpdate function for updating the scene.
void SetAmbientLight(const math::Color &_ambient)
Set ambient light of render window. This will override other sources, such as from SDF.
void SetSceneName(const std::string &_sceneName)
Set the scene to use.
void SetRemoveSensorCb(std::function< void(const gazebo::Entity &)> _removeSensorCb)
Set the callback function for removing the sensors.
int PendingSensors() const
Count of pending sensors. Must be called in the rendering thread.
void ViewInertia(const Entity &_entity)
View inertia of specified entity.
bool HeadlessRendering() const
Get the headless mode.
void SetTransformActive(bool _active)
Set whether the transform controls are currently being dragged.
void Update()
Main update function. Must be called in the rendering thread.
std::string SceneName() const
Get the name of the rendering scene used.
void InitRenderEnginePluginPaths()
Init render engine plugins paths. This lets gz-rendering know paths to find render engine plugins.
void SetSelectedEntity(const rendering::NodePtr &_node)
Set the entity being selected.
Scene manager class for loading and managing objects in the scene.
Definition: gz/sim/rendering/SceneManager.hh:94
Component< NoData, class SensorTag > Sensor
A component that identifies an entity as being a sensor.
Definition: gz/sim/components/Sensor.hh:35
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:58
This library is part of the Gazebo project.
Definition: gz/sim/Actor.hh:34
Information passed to systems on the update callback.
Definition: include/gz/sim/Types.hh:39