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 
35  GZ_GUI_VISIBLE
36  bool load();
37 
38  GZ_GUI_VISIBLE
39  void init();
40 
41  GZ_GUI_VISIBLE
42  bool run(int _argc, char **_argv);
43  GZ_GUI_VISIBLE
44  void stop();
45 
46  GZ_GUI_VISIBLE
47  void set_world(const std::string& _name);
48  GZ_GUI_VISIBLE
49  std::string get_world();
50 
51  GZ_GUI_VISIBLE
53  GZ_GUI_VISIBLE
55  GZ_GUI_VISIBLE
56  void clear_active_camera();
57 
59  GZ_GUI_VISIBLE
60  MainWindow *get_main_window();
61 
62  GZ_GUI_VISIBLE
63  unsigned int get_entity_id(const std::string &_name);
64  GZ_GUI_VISIBLE
65  bool has_entity_name(const std::string &_name);
66 
77  GZ_GUI_VISIBLE
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 
113  GZ_GUI_VISIBLE
114  bool saveINI(const boost::filesystem::path &_file);
115  }
116 }
117 #endif
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:92
void clear_active_camera()
void set_world(const std::string &_name)
unsigned int get_entity_id(const std::string &_name)
void set_active_camera(rendering::UserCameraPtr _cam)
std::string get_world()
MainWindow * get_main_window()
Return a pointer to the main graphical window.
bool run(int _argc, char **_argv)
bool load()
Load the graphical interface.
rendering::UserCameraPtr get_active_camera()
T getINIProperty(const std::string &_key, const T &_default)
Get a property from the GUI INI file.
Definition: GuiIface.hh:85
bool saveINI(const boost::filesystem::path &_file)
Save the configuration parameters to file.
bool has_entity_name(const std::string &_name)
bool loadINI(boost::filesystem::path _file="")
Locate and load the INI configuration file.
bool setINIProperty(const std::string &_key, const T &_value)
Set a value in the INI property tree.
Definition: GuiIface.hh:104
boost::property_tree::ptree g_propTree