All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GuiIface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 _GAZEBO_GUIIFACE_HH_
18 #define _GAZEBO_GUIIFACE_HH_
19 
20 #include <string>
21 #include <boost/property_tree/ptree.hpp>
22 #include <boost/filesystem.hpp>
24 #include "gazebo/util/system.hh"
25 
26 extern GAZEBO_VISIBLE boost::property_tree::ptree g_propTree;
27 namespace gazebo
28 {
29  namespace gui
30  {
34  bool load();
35 
37  void init();
38 
40  bool run(int _argc, char **_argv);
42  void stop();
43 
45  void set_world(const std::string& _name);
47  std::string get_world();
48 
54  void clear_active_camera();
55 
57  unsigned int get_entity_id(const std::string &_name);
59  bool has_entity_name(const std::string &_name);
60 
65  bool loadINI(const boost::filesystem::path &_file);
66 
71  template<typename T>
73  T getINIProperty(const std::string &_key, const T &_default)
74  {
75  try
76  {
77  return g_propTree.get<T>(_key);
78  }
79  catch(...)
80  {
81  }
82 
83  return _default;
84  }
85 
91  template<typename T>
93  bool setINIProperty(const std::string &_key, const T &_value)
94  {
95  g_propTree.put(_key, _value);
96  return true;
97  }
98 
103  bool saveINI(const boost::filesystem::path &_file);
104  }
105 }
106 #endif
GAZEBO_VISIBLE std::string get_world()
GAZEBO_VISIBLE rendering::UserCameraPtr get_active_camera()
GAZEBO_VISIBLE void set_active_camera(rendering::UserCameraPtr _cam)
GAZEBO_VISIBLE bool has_entity_name(const std::string &_name)
GAZEBO_VISIBLE boost::property_tree::ptree g_propTree
GAZEBO_VISIBLE bool run(int _argc, char **_argv)
GAZEBO_VISIBLE bool loadINI(const boost::filesystem::path &_file)
Load an INI configuration file.
GAZEBO_VISIBLE void set_world(const std::string &_name)
GAZEBO_VISIBLE T getINIProperty(const std::string &_key, const T &_default)
Get a property from the GUI INI file.
Definition: GuiIface.hh:73
GAZEBO_VISIBLE bool load()
Load the graphical interface.
GAZEBO_VISIBLE void init()
GAZEBO_VISIBLE unsigned int get_entity_id(const std::string &_name)
GAZEBO_VISIBLE bool setINIProperty(const std::string &_key, const T &_value)
Set a value in the INI property tree.
Definition: GuiIface.hh:93
GAZEBO_VISIBLE void stop()
GAZEBO_VISIBLE bool saveINI(const boost::filesystem::path &_file)
Save the configuration parameters to file.
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:84
GAZEBO_VISIBLE void clear_active_camera()
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48