GuiIface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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  {
31  class MainWindow;
32 
36  bool load();
37 
39  void init();
40 
42  bool run(int _argc, char **_argv);
44  void stop();
45 
47  void set_world(const std::string& _name);
49  std::string get_world();
50 
56  void clear_active_camera();
57 
60  MainWindow *get_main_window();
61 
63  unsigned int get_entity_id(const std::string &_name);
65  bool has_entity_name(const std::string &_name);
66 
78  bool loadINI(boost::filesystem::path _file = "");
79 
84  template<typename T>
86  T getINIProperty(const std::string &_key, const T &_default)
87  {
88  try
89  {
90  return g_propTree.get<T>(_key);
91  }
92  catch(...)
93  {
94  }
95 
96  return _default;
97  }
98 
104  template<typename T>
106  bool setINIProperty(const std::string &_key, const T &_value)
107  {
108  g_propTree.put(_key, _value);
109  return true;
110  }
111 
116  bool saveINI(const boost::filesystem::path &_file);
117  }
118 }
119 #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 void set_world(const std::string &_name)
GAZEBO_VISIBLE bool loadINI(boost::filesystem::path _file="")
Locate and load the INI configuration file.
GAZEBO_VISIBLE T getINIProperty(const std::string &_key, const T &_default)
Get a property from the GUI INI file.
Definition: GuiIface.hh:86
GAZEBO_VISIBLE bool load()
Load the graphical interface.
GAZEBO_VISIBLE MainWindow * get_main_window()
Return a pointer to the main graphical window.
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:106
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:86
GAZEBO_VISIBLE void clear_active_camera()
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48