18#ifndef _GAZEBO_GUI_CONFIGWIDGET_HH_
19#define _GAZEBO_GUI_CONFIGWIDGET_HH_
26#include <ignition/math/Color.hh>
27#include <ignition/math/Pose3.hh>
28#include <ignition/math/Vector3.hh>
39 class FieldDescriptor;
47 class ConfigWidgetPrivate;
64 public: std::string
key;
110 private slots:
void OnGeometryTypeChanged(
const QString &_text);
114 private slots:
void OnGeometrySizeChanged(
const double _value);
117 private slots:
void OnSelectFile();
142 private slots:
void OnComboBoxChanged(
const QString &_text);
146 private slots:
void OnSpinBoxChanged(
const QString &_text);
159 private:
double density;
174 private slots:
void EnumChanged(
const QString &_value);
188 private slots:
void Toggle(
bool _checked);
205 public:
void Load(
const google::protobuf::Message *_msg);
209 public: google::protobuf::Message *
Msg();
224 const std::string &_jointType =
"")
const;
232 double &_min,
double &_max)
const;
288 const std::string &_value);
295 const ignition::math::Vector3d &_value);
302 const ignition::math::Color &_value);
309 const ignition::math::Pose3d &_value);
317 const std::string &_value,
318 const ignition::math::Vector3d &_dimensions,
319 const std::string &_uri =
"");
326 const double _value);
333 const std::string &_value);
340 const std::string &_itemText);
347 const std::string &_itemText);
383 const std::string &_name)
const;
389 const std::string &_name)
const;
395 const std::string &_name)
const;
403 ignition::math::Vector3d &_dimensions, std::string &_uri)
const;
429 const int _level = 0);
436 const int _level = 0);
443 const int _level = 0);
451 const int _level = 0,
const std::string &_type =
"line");
458 const int _level = 0);
465 const int _level = 0);
472 const int _level = 0);
479 const int _level = 0);
486 const int _level = 0);
494 const std::vector<std::string> &_values,
const int _level = 0);
501 const int _level = 0);
524 const std::string &_name)
const;
538 const int _level = 0);
542 public:
static const std::vector<QString>
bgColors;
565 private: QWidget *Parse(google::protobuf::Message *_msg,
566 bool _update =
false,
const std::string &_name =
"",
567 const int _level = 0);
572 private: ignition::math::Vector3d ParseVector3d(
573 const google::protobuf::Message *_msg)
const;
578 private:
void UpdateMsg(google::protobuf::Message *_msg,
579 const std::string &_name =
"");
585 private:
void UpdateVector3dMsg(google::protobuf::Message *_msg,
586 const ignition::math::Vector3d &_value);
593 const unsigned int _value);
607 const double _value);
614 const std::string &_value);
628 const ignition::math::Vector3d &_value);
635 const ignition::math::Color &_value);
642 const ignition::math::Pose3d &_value);
651 const std::string &_value,
652 const ignition::math::Vector3d &_dimensions,
653 const std::string &_uri =
"");
660 const std::string &_value);
667 const double _value);
697 private: ignition::math::Vector3d Vector3dWidgetValue(
703 private: ignition::math::Color ColorWidgetValue(
709 private: ignition::math::Pose3d PoseWidgetValue(
718 ignition::math::Vector3d &_dimensions, std::string &_uri)
const;
728 private slots:
void OnItemSelection(QTreeWidgetItem *_item,
732 private slots:
void OnUIntValueChanged();
735 private slots:
void OnIntValueChanged();
738 private slots:
void OnDoubleValueChanged();
741 private slots:
void OnBoolValueChanged();
744 private slots:
void OnStringValueChanged();
747 private slots:
void OnVector3dValueChanged();
751 private slots:
void OnVector3dPresetChanged(
const int _index);
754 private slots:
void OnColorValueChanged();
759 private slots:
void OnColorValueChanged(
const QColor _value);
762 private slots:
void OnPoseValueChanged();
765 private slots:
void OnGeometryValueChanged();
769 private slots:
void OnGeometryValueChanged(
const int _value);
773 private slots:
void OnEnumValueChanged(
const QString &_value);
777 private slots:
void OnCustomColorDialog();
783 const unsigned int _value);
794 const double _value);
808 const std::string &_value);
814 const ignition::math::Vector3d &_value);
820 const ignition::math::Color &_value);
826 const ignition::math::Pose3d &_pose);
834 const std::string &_value,
835 const ignition::math::Vector3d &_dimensions,
836 const std::string &_uri);
842 const QString &_value);
854 private slots:
void OnDensityValueChanged(
const double _value);
858 private slots:
void OnMassValueChanged(
const double _value);
861 private slots:
void OnGeometryChanged();
870 private:
bool eventFilter(QObject *_obj, QEvent *_event);
874 private: std::unique_ptr<ConfigWidgetPrivate> dataPtr;
#define NULL
Definition CommonTypes.hh:31
gui
Definition KeyEventHandler.hh:29
bool SetDoubleWidgetValue(const std::string &_name, double _value)
Set a double value to a child widget.
std::string UnitFromKey(const std::string &_key, const std::string &_jointType="") const
Returns the unit for a given key.
void EnumValueChanged(const QString &_name, const QString &_value)
Signal that an enum config widget's enum value has changed.
static const QString redColor
Red color used for "red" or "x" fields.
Definition ConfigWidget.hh:548
void StringValueChanged(const QString &_name, const std::string &_value)
Signal that a string config widget's value has changed.
ConfigChildWidget * CreateVector3dWidget(const std::string &_key, const int _level=0)
Create a widget for configuring a vector3 value.
QComboBox * comboBox
A combo box for selecting a material density.
Definition ConfigWidget.hh:153
bool SetVector3dWidgetValue(const std::string &_name, const ignition::math::Vector3d &_value)
Set a vector3 value to a child widget.
std::vector< QWidget * > widgets
List of widgets holding values, such as Spins and LineEdits.
Definition ConfigWidget.hh:70
void EnumValueChanged(const QString &_value)
brief Signal an enum value change event.
ConfigWidget()
Constructor.
std::string StringWidgetValue(const std::string &_name) const
Get a string value from a child widget.
static const QString blueColor
Blue color used for "blue" or "z" fields.
Definition ConfigWidget.hh:554
static const std::vector< QString > bgColors
List of colors used for the background of widgets according to their level.
Definition ConfigWidget.hh:542
void UIntValueChanged(const QString &_name, const unsigned int _value)
Signal that a uint config widget's value has changed.
ConfigChildWidget * CreateEnumWidget(const std::string &_key, const std::vector< std::string > &_values, const int _level=0)
Create a widget for configuring an enum value.
void SetDensity(const double _density)
Updates the widget's density value.
void PoseValueChanged(const QString &_name, const ignition::math::Pose3d &_pose)
Signal that a pose config widget's value has changed.
static QString StyleSheet(const std::string &_type, const int _level=0)
Get a style sheet in string format, to be applied to a child config widget with setStyleSheet.
ConfigChildWidget * CreateGeometryWidget(const std::string &_key, const int _level=0)
Create a widget for configuring a geometry value.
double DoubleWidgetValue(const std::string &_name) const
Get a double value from a child widget.
bool WidgetVisible(const std::string &_name) const
Get whether a child widget is visible.
bool SetEnumWidgetValue(const std::string &_name, const std::string &_value)
Set an enum value to a child widget.
ConfigChildWidget * CreateUIntWidget(const std::string &_key, const int _level=0)
Create a widget for configuring an unsigned integer value.
ignition::math::Color ColorWidgetValue(const std::string &_name) const
Get a color value from a child widget.
QWidget * geomFilenameLineEdit
A line edit for editing the mesh filename.
Definition ConfigWidget.hh:100
ConfigChildWidget * ConfigChildWidgetByName(const std::string &_name) const
Get a config child widget by its name.
void DoubleValueChanged(const QString &_name, const double _value)
Signal that a double config widget's value has changed.
int IntWidgetValue(const std::string &_name) const
Get an integer value from a child widget.
QWidget * geomLengthLabel
A label for the length widget.
Definition ConfigWidget.hh:94
bool ClearEnumWidget(const std::string &_name)
Remove all items from a child enum widget.
std::map< QWidget *, QLabel * > mapWidgetToUnit
Map a widget to the label holding its unit value.
Definition ConfigWidget.hh:73
ConfigChildWidget * CreateIntWidget(const std::string &_key, const int _level=0)
Create a widget for configuring an integer value.
static std::string HumanReadableKey(const std::string &_key)
Create a human readable key, capitalizing the first letter and removing characters like "_".
void ColorValueChanged(const QString &_name, const ignition::math::Color &_value)
Signal that a color config widget's value has changed.
QWidget * geomFilenameButton
A button for selecting the mesh filename.
Definition ConfigWidget.hh:106
void BoolValueChanged(const QString &_name, const bool _value)
Signal that a bool config widget's value has changed.
double Density() const
Accessor for the widget's density value.
void SetWidgetReadOnly(const std::string &_name, bool _readOnly)
Set whether a child widget should be read-only.
void Load(const google::protobuf::Message *_msg)
Load from a google protobuf message.
static const std::vector< QString > widgetColors
List of colors used for widget areas according to their level.
Definition ConfigWidget.hh:545
bool AddItemEnumWidget(const std::string &_name, const std::string &_itemText)
Add an item to a child enum widget.
ConfigChildWidget()
Constructor;.
Definition ConfigWidget.hh:61
ConfigChildWidget * CreateColorWidget(const std::string &_key, const int _level=0)
Create a widget for configuring a color value.
google::protobuf::Message * Msg()
Get the updated message.
void InsertLayout(QLayout *_layout, int _pos)
Insert a layout into the config widget's layout at a specific position.
bool AddConfigChildWidget(const std::string &_name, ConfigChildWidget *_child)
Register a child widget as a child of this widget, so it can be updated.
ConfigChildWidget * CreatePoseWidget(const std::string &_key, const int _level=0)
Create a widget for configuring a pose value.
ConfigChildWidget * CreateDoubleWidget(const std::string &_key, const int _level=0)
Create a widget for configuring a double value.
ignition::math::Vector3d Vector3dWidgetValue(const std::string &_name) const
Get a vector3 value from a child widget.
QWidget * geomLengthUnitLabel
A label for the unit of the length widget.
Definition ConfigWidget.hh:97
void UpdateFromMsg(const google::protobuf::Message *_msg)
Update the widgets from a message.
bool SetGeometryWidgetValue(const std::string &_name, const std::string &_value, const ignition::math::Vector3d &_dimensions, const std::string &_uri="")
Set a geometry value to a child widget.
QDoubleSpinBox * spinBox
A spin box for entering a density value.
Definition ConfigWidget.hh:156
QWidget * geomLengthSpinBox
A spin box for configuring the length of the geometry.
Definition ConfigWidget.hh:91
bool BoolWidgetValue(const std::string &_name) const
Get a bool value from a child widget.
bool RemoveItemEnumWidget(const std::string &_name, const std::string &_itemText)
Remove an item from a child enum widget.
QWidget * geomFilenameLabel
A label for the mesh filename widget.
Definition ConfigWidget.hh:103
std::string key
Widget's key value.
Definition ConfigWidget.hh:64
QStackedWidget * geomDimensionWidget
A stacked widget containing widgets for configuring geometry dimensions.
Definition ConfigWidget.hh:88
ConfigChildWidget * CreateBoolWidget(const std::string &_key, const int _level=0)
Create a widget for configuring a bool value.
void RangeFromKey(const std::string &_key, double &_min, double &_max) const
Returns the range for a given key.
void DensityValueChanged(const double &_value)
Signal emitted when density has changed.
ConfigChildWidget * CreateStringWidget(const std::string &_key, const int _level=0, const std::string &_type="line")
Create a widget for configuring a string value.
bool SetPoseWidgetValue(const std::string &_name, const ignition::math::Pose3d &_value)
Set a pose value to a child widget.
unsigned int ConfigChildWidgetCount() const
Get the number of child widgets.
bool SetColorWidgetValue(const std::string &_name, const ignition::math::Color &_value)
Set a color value to a child widget.
bool SetStringWidgetValue(const std::string &_name, const std::string &_value)
Set a string value to a child widget.
void SetWidgetVisible(const std::string &_name, bool _visible)
Set whether a child widget should be visible.
static const QString greenColor
Green color used for "green" or "y" fields.
Definition ConfigWidget.hh:551
GroupWidget * CreateGroupWidget(const std::string &_name, ConfigChildWidget *_childWidget, const int _level=0)
Create a widget which has a button header which collapses the field widget.
DensityConfigWidget()
Constructor.
QWidget * childWidget
Child widget that can be collapsed or expanded.
Definition ConfigWidget.hh:184
ignition::math::Pose3d PoseWidgetValue(const std::string &_name) const
Get a pose value from a child widget.
std::string GeometryWidgetValue(const std::string &_name, ignition::math::Vector3d &_dimensions, std::string &_uri) const
Get a geometry value from a child widget.
void MassValueChanged(const double &_value)
Signal emitted when mass value changes.
bool SetDensityWidgetValue(const std::string &_name, const double _value)
Set a density value to a child widget.
void GeometryChanged()
Signal emitted when geometry changes.
bool SetIntWidgetValue(const std::string &_name, int _value)
Set an integer value to a child widget.
void IntValueChanged(const QString &_name, const int _value)
Signal that an int config widget's value has changed.
bool SetBoolWidgetValue(const std::string &_name, bool _value)
Set a bool value to a child widget.
~ConfigWidget()
Destructor.
std::string scopedName
Widget's scoped name within parent config widget.
Definition ConfigWidget.hh:67
unsigned int UIntWidgetValue(const std::string &_name) const
Get an unsigned integer value from a child widget.
ConfigChildWidget * CreateDensityWidget(const std::string &_key, const int _level=0)
Create a widget for setting a density value.
void Vector3dValueChanged(const QString &_name, const ignition::math::Vector3d &_value)
Signal that a vector3 config widget's value has changed.
bool SetUIntWidgetValue(const std::string &_name, unsigned int _value)
Set an unsigned integer value to a child widget.
bool WidgetReadOnly(const std::string &_name) const
Get whether a child widget is read-only.
double DensityWidgetValue(const std::string &_name) const
Get a density value from a child widget.
void GeometryValueChanged(const std::string &_name, const std::string &_value, const ignition::math::Vector3d &_dimensions, const std::string &_uri)
Signal that a geometry config widget's value has changed.
std::string EnumWidgetValue(const std::string &_name) const
Get an enum value from a child widget.
GroupWidget * groupWidget
Pointer to group widget.
Definition ConfigWidget.hh:77
Forward declarations for the common classes.
Definition Animation.hh:27
Definition ConfigWidget.hh:34