18 #ifndef _GAZEBO_GUI_CONFIGWIDGET_HH_
19 #define _GAZEBO_GUI_CONFIGWIDGET_HH_
26 #include <ignition/math/Pose3.hh>
27 #include <ignition/math/Vector3.hh>
38 class FieldDescriptor;
46 class ConfigWidgetPrivate;
63 public: std::string
key;
109 private slots:
void OnGeometryTypeChanged(
const QString &_text);
113 private slots:
void OnGeometrySizeChanged(
const double _value);
116 private slots:
void OnSelectFile();
119 Q_SIGNALS:
void GeometryChanged();
133 public:
void SetDensity(
const double _density);
137 public:
double Density()
const;
141 private slots:
void OnComboBoxChanged(
const QString &_text);
145 private slots:
void OnSpinBoxChanged(
const QString &_text);
149 Q_SIGNALS:
void DensityValueChanged(
const double &_value);
158 private:
double density;
169 Q_SIGNALS:
void EnumValueChanged(
const QString &_value);
173 private slots:
void EnumChanged(
const QString &_value);
187 private slots:
void Toggle(
bool _checked);
204 public:
void Load(
const google::protobuf::Message *_msg);
208 public: google::protobuf::Message *Msg();
214 public:
static std::string HumanReadableKey(
const std::string &_key);
222 public: std::string UnitFromKey(
const std::string &_key,
223 const std::string &_jointType =
"")
const;
230 public:
void RangeFromKey(
const std::string &_key,
231 double &
_min,
double &_max)
const;
236 public:
void SetWidgetVisible(
const std::string &_name,
bool _visible);
241 public:
bool WidgetVisible(
const std::string &_name)
const;
246 public:
void SetWidgetReadOnly(
const std::string &_name,
bool _readOnly);
251 public:
bool WidgetReadOnly(
const std::string &_name)
const;
255 public:
void UpdateFromMsg(
const google::protobuf::Message *_msg);
261 public:
bool SetIntWidgetValue(
const std::string &_name,
int _value);
267 public:
bool SetUIntWidgetValue(
const std::string &_name,
unsigned int
274 public:
bool SetDoubleWidgetValue(
const std::string &_name,
281 public:
bool SetBoolWidgetValue(
const std::string &_name,
bool _value);
286 public:
bool SetStringWidgetValue(
const std::string &_name,
287 const std::string &_value);
293 public:
bool SetVector3dWidgetValue(
const std::string &_name,
294 const ignition::math::Vector3d &_value);
300 public:
bool SetColorWidgetValue(
const std::string &_name,
307 public:
bool SetPoseWidgetValue(
const std::string &_name,
308 const ignition::math::Pose3d &_value);
315 public:
bool SetGeometryWidgetValue(
const std::string &_name,
316 const std::string &_value,
317 const ignition::math::Vector3d &_dimensions,
318 const std::string &_uri =
"");
324 public:
bool SetDensityWidgetValue(
const std::string &_name,
325 const double _value);
331 public:
bool SetEnumWidgetValue(
const std::string &_name,
332 const std::string &_value);
338 public:
bool AddItemEnumWidget(
const std::string &_name,
339 const std::string &_itemText);
345 public:
bool RemoveItemEnumWidget(
const std::string &_name,
346 const std::string &_itemText);
351 public:
bool ClearEnumWidget(
const std::string &_name);
356 public:
int IntWidgetValue(
const std::string &_name)
const;
361 public:
unsigned int UIntWidgetValue(
const std::string &_name)
const;
366 public:
double DoubleWidgetValue(
const std::string &_name)
const;
371 public:
bool BoolWidgetValue(
const std::string &_name)
const;
376 public: std::string StringWidgetValue(
const std::string &_name)
const;
381 public: ignition::math::Vector3d Vector3dWidgetValue(
382 const std::string &_name)
const;
387 public:
common::Color ColorWidgetValue(
const std::string &_name)
const;
392 public: ignition::math::Pose3d PoseWidgetValue(
393 const std::string &_name)
const;
400 public: std::string GeometryWidgetValue(
const std::string &_name,
401 ignition::math::Vector3d &_dimensions, std::string &_uri)
const;
406 public:
double DensityWidgetValue(
const std::string &_name)
const;
411 public: std::string EnumWidgetValue(
const std::string &_name)
const;
419 public:
GroupWidget *CreateGroupWidget(
const std::string &_name,
427 const int _level = 0);
434 const int _level = 0);
441 const int _level = 0);
449 const int _level = 0,
const std::string &_type =
"line");
456 const int _level = 0);
463 const int _level = 0);
470 const int _level = 0);
477 const int _level = 0);
484 const int _level = 0);
492 const std::vector<std::string> &_values,
const int _level = 0);
499 const int _level = 0);
508 public:
bool AddConfigChildWidget(
const std::string &_name,
515 public:
void InsertLayout(QLayout *_layout,
int _pos);
522 const std::string &_name)
const;
526 public:
unsigned int ConfigChildWidgetCount()
const;
535 public:
static QString StyleSheet(
const std::string &_type,
536 const int _level = 0);
540 public:
static const std::vector<QString>
bgColors;
563 private: QWidget *Parse(google::protobuf::Message *_msg,
564 bool _update =
false,
const std::string &_name =
"",
565 const int _level = 0);
570 private: ignition::math::Vector3d ParseVector3d(
571 const google::protobuf::Message *_msg)
const;
576 private:
void UpdateMsg(google::protobuf::Message *_msg,
577 const std::string &_name =
"");
582 private:
void UpdateVector3dMsg(google::protobuf::Message *_msg,
583 const ignition::math::Vector3d &_value);
590 const unsigned int _value);
604 const double _value);
611 const std::string &_value);
625 const ignition::math::Vector3d &_value);
639 const ignition::math::Pose3d &_value);
648 const std::string &_value,
649 const ignition::math::Vector3d &_dimensions,
650 const std::string &_uri =
"");
657 const std::string &_value);
664 const double _value);
694 private: ignition::math::Vector3d Vector3dWidgetValue(
705 private: ignition::math::Pose3d PoseWidgetValue(
714 ignition::math::Vector3d &_dimensions, std::string &_uri)
const;
724 private slots:
void OnItemSelection(QTreeWidgetItem *_item,
728 private slots:
void OnUIntValueChanged();
731 private slots:
void OnIntValueChanged();
734 private slots:
void OnDoubleValueChanged();
737 private slots:
void OnBoolValueChanged();
740 private slots:
void OnStringValueChanged();
743 private slots:
void OnVector3dValueChanged();
747 private slots:
void OnVector3dPresetChanged(
const int _index);
750 private slots:
void OnColorValueChanged();
755 private slots:
void OnColorValueChanged(
const QColor _value);
758 private slots:
void OnPoseValueChanged();
761 private slots:
void OnGeometryValueChanged();
765 private slots:
void OnGeometryValueChanged(
const int _value);
769 private slots:
void OnEnumValueChanged(
const QString &_value);
773 private slots:
void OnCustomColorDialog();
778 Q_SIGNALS:
void UIntValueChanged(
const QString &_name,
779 const unsigned int _value);
784 Q_SIGNALS:
void IntValueChanged(
const QString &_name,
const int _value);
789 Q_SIGNALS:
void DoubleValueChanged(
const QString &_name,
790 const double _value);
795 Q_SIGNALS:
void BoolValueChanged(
const QString &_name,
803 Q_SIGNALS:
void StringValueChanged(
const QString &_name,
804 const std::string &_value);
809 Q_SIGNALS:
void Vector3dValueChanged(
const QString &_name,
810 const ignition::math::Vector3d &_value);
815 Q_SIGNALS:
void ColorValueChanged(
const QString &_name,
821 Q_SIGNALS:
void PoseValueChanged(
const QString &_name,
822 const ignition::math::Pose3d &_pose);
829 Q_SIGNALS:
void GeometryValueChanged(
const std::string &_name,
830 const std::string &_value,
831 const ignition::math::Vector3d &_dimensions,
832 const std::string &_uri);
837 Q_SIGNALS:
void EnumValueChanged(
const QString &_name,
838 const QString &_value);
842 Q_SIGNALS:
void DensityValueChanged(
const double &_value);
846 Q_SIGNALS:
void MassValueChanged(
const double &_value);
850 private slots:
void OnDensityValueChanged(
const double _value);
854 private slots:
void OnMassValueChanged(
const double _value);
857 private slots:
void OnGeometryChanged();
860 Q_SIGNALS:
void GeometryChanged();
866 private:
bool eventFilter(QObject *_obj, QEvent *_event);
870 private: std::unique_ptr<ConfigWidgetPrivate> dataPtr;
T T _min
Definition: Helpers.hh:130
QComboBox * comboBox
A combo box for selecting a material density.
Definition: ConfigWidget.hh:152
GroupWidget * groupWidget
Pointer to group widget.
Definition: ConfigWidget.hh:76
static const std::vector< QString > widgetColors
List of colors used for widget areas according to their level.
Definition: ConfigWidget.hh:543
static const QString greenColor
Green color used for "green" or "y" fields.
Definition: ConfigWidget.hh:549
QWidget * geomFilenameLineEdit
A line edit for editing the mesh filename.
Definition: ConfigWidget.hh:99
static const QString blueColor
Blue color used for "blue" or "z" fields.
Definition: ConfigWidget.hh:552
QWidget * geomLengthSpinBox
A spin box for configuring the length of the geometry.
Definition: ConfigWidget.hh:90
QWidget * geomFilenameButton
A button for selecting the mesh filename.
Definition: ConfigWidget.hh:105
static const std::vector< QString > bgColors
List of colors used for the background of widgets according to their level.
Definition: ConfigWidget.hh:540
QWidget * childWidget
Child widget that can be collapsed or expanded.
Definition: ConfigWidget.hh:183
static const QString redColor
Red color used for "red" or "x" fields.
Definition: ConfigWidget.hh:546
std::string scopedName
Widget's scoped name within parent config widget.
Definition: ConfigWidget.hh:66
QDoubleSpinBox * spinBox
A spin box for entering a density value.
Definition: ConfigWidget.hh:155
#define NULL
Definition: CommonTypes.hh:31
QStackedWidget * geomDimensionWidget
A stacked widget containing widgets for configuring geometry dimensions.
Definition: ConfigWidget.hh:87
Defines a color.
Definition: Color.hh:36
QWidget * geomLengthUnitLabel
A label for the unit of the length widget.
Definition: ConfigWidget.hh:96
std::map< QWidget *, QLabel * > mapWidgetToUnit
Map a widget to the label holding its unit value.
Definition: ConfigWidget.hh:72
QWidget * geomLengthLabel
A label for the length widget.
Definition: ConfigWidget.hh:93
ConfigChildWidget()
Constructor;.
Definition: ConfigWidget.hh:60
QWidget * geomFilenameLabel
A label for the mesh filename widget.
Definition: ConfigWidget.hh:102
std::string key
Widget's key value.
Definition: ConfigWidget.hh:63
std::vector< QWidget * > widgets
List of widgets holding values, such as Spins and LineEdits.
Definition: ConfigWidget.hh:69