Gazebo Gui

API Reference

6.8.0
gz/gui/Helpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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_GUI_HELPERS_HH_
18 #define GZ_GUI_HELPERS_HH_
19 
20 #include <string>
21 
22 #include "gz/gui/Enums.hh"
23 #include "gz/gui/Export.hh"
24 
25 namespace ignition
26 {
27  namespace gui
28  {
33  IGNITION_GUI_VISIBLE
35 
43  IGNITION_GUI_VISIBLE
45  const std::string &_type = "");
46 
52  IGNITION_GUI_VISIBLE
53  void rangeFromKey(const std::string &_key, double &_min, double &_max);
54 
59  IGNITION_GUI_VISIBLE
61 
69  IGNITION_GUI_VISIBLE
70  std::string uniqueFilePath(const std::string &_pathAndName,
71  const std::string &_extension);
72 
79  IGNITION_GUI_VISIBLE
81 
89  IGNITION_GUI_VISIBLE
91 
98  IGNITION_GUI_VISIBLE
99  const QString qmlQrcImportPath();
100 
107  template<class T>
108  T findFirstByProperty(const QList<T> _list, const char *_key,
109  QVariant _value)
110  {
111  for (const auto &w : _list)
112  {
113  if (w->property(_key) == _value)
114  return w;
115  }
116  return nullptr;
117  }
118  }
119 }
120 #endif
STL class.
std::string humanReadable(const std::string &_key)
Create a human readable key, capitalizing the first letter and removing characters like "_".
std::string renderEngineName()
The main window's "renderEngine" property may be filled with a string of the render engine gui name....
void rangeFromKey(const std::string &_key, double &_min, double &_max)
Returns the range for a given key. For example, the key "transparency" returns min == 0,...
QStringList worldNames()
The main window's "worldNames" property may be filled with a list of the names of all worlds currentl...
StringType stringTypeFromKey(const std::string &_key)
Returns the string type for a given key. For example, the key "innerxml" has a PLAIN_TEXT type while ...
std::string unitFromKey(const std::string &_key, const std::string &_type="")
Returns the unit for a given key. For example, the key "mass" returns "kg".
StringType
String types.
Definition: gz/gui/Enums.hh:46
std::string uniqueFilePath(const std::string &_pathAndName, const std::string &_extension)
Generates a path for a file which doesn't collide with existing files, by appending numbers to it (i....
const QString qmlQrcImportPath()
Import path for gz-gui QML modules added to the Qt resource system. This helper function returns the ...
T findFirstByProperty(const QList< T > _list, const char *_key, QVariant _value)
Returns the first element on a QList which matches the given property.
Definition: gz/gui/Helpers.hh:108