GuiIface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 GZ_GUI_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>
85  T getINIProperty(const std::string &_key, const T &_default)
86  {
87  try
88  {
89  return g_propTree.get<T>(_key);
90  }
91  catch(...)
92  {
93  }
94 
95  return _default;
96  }
97 
103  template<typename T>
104  bool setINIProperty(const std::string &_key, const T &_value)
105  {
106  g_propTree.put(_key, _value);
107  return true;
108  }
109 
114  bool saveINI(const boost::filesystem::path &_file);
115  }
116 }
117 #endif
GZ_GUI_VISIBLE void set_world(const std::string &_name)
#define GZ_GUI_VISIBLE
Definition: system.hh:284
GZ_GUI_VISIBLE bool loadINI(boost::filesystem::path _file="")
Locate and load the INI configuration file.
GZ_GUI_VISIBLE rendering::UserCameraPtr get_active_camera()
GZ_GUI_VISIBLE void set_active_camera(rendering::UserCameraPtr _cam)
GZ_GUI_VISIBLE bool has_entity_name(const std::string &_name)
GZ_GUI_VISIBLE void init()
GZ_GUI_VISIBLE std::string get_world()
GZ_GUI_VISIBLE bool load()
Load the graphical interface.
GZ_GUI_VISIBLE void clear_active_camera()
GZ_GUI_VISIBLE bool run(int _argc, char **_argv)
GZ_GUI_VISIBLE MainWindow * get_main_window()
Return a pointer to the main graphical window.
GZ_GUI_VISIBLE void stop()
T getINIProperty(const std::string &_key, const T &_default)
Get a property from the GUI INI file.
Definition: GuiIface.hh:85
GZ_GUI_VISIBLE unsigned int get_entity_id(const std::string &_name)
GZ_GUI_VISIBLE boost::property_tree::ptree g_propTree
bool setINIProperty(const std::string &_key, const T &_value)
Set a value in the INI property tree.
Definition: GuiIface.hh:104
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:92
GZ_GUI_VISIBLE bool saveINI(const boost::filesystem::path &_file)
Save the configuration parameters to file.