configuration.hh
Go to the documentation of this file.
1 // Copyright (c) 2015-2018, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef GEPETTO_GUI_CONFIGURATION_DIALOG_HH
18 #define GEPETTO_GUI_CONFIGURATION_DIALOG_HH
19 
20 #include <QDialog>
21 
23 
24 class QDoubleSpinBox;
25 class QLineEdit;
26 
27 namespace gepetto {
28 namespace gui {
29 
31 /*
32  * README The MOC tool from Qt does not expand macros. Thus, the code in comment below
33  * does not work because the classes are not mocced.
34  * The remaining of the file, after this comment, correspond to the macro
35  * expansion at the time of writing.
36 
37 #define DECLARE_PROPERTY_EDITOR(Name, Type) \
38  class Name : public QDialog { \
39  Q_OBJECT \
40  \
41  public: \
42  Name(viewer::Property* prop, QWidget* parent = 0); \
43  \
44  void setValueFromProperty(viewer::Property* prop); \
45  \
46  signals: \
47  void valueChanged(const Type& config); \
48  \
49  public slots: \
50  void set(const Type& v); \
51  \
52  private slots: \
53  void updateValue(); \
54  \
55  private: \
56  void setPyValue(); \
57  \
58  QVector<QDoubleSpinBox*> spinBoxes; \
59  QLineEdit* pyValue; \
60  }
61 
62 DECLARE_PROPERTY_EDITOR(Vector2Dialog, osgVector2);
63 DECLARE_PROPERTY_EDITOR(Vector3Dialog, osgVector3);
64 DECLARE_PROPERTY_EDITOR(Vector4Dialog, osgVector4);
65 DECLARE_PROPERTY_EDITOR(ConfigurationDialog, Configuration);
66 
67 #undef DECLARE_PROPERTY_EDITOR
68 */
69 
70 class Vector2Dialog : public QDialog {
71  Q_OBJECT
72 public:
73  Vector2Dialog(viewer::Property* prop, QWidget* parent = 0);
75 signals:
76  void valueChanged(const osgVector2& config);
77 public slots:
78  void set(const osgVector2& v);
79 private slots:
80  void updateValue();
81 private:
82  void setPyValue();
83  QVector<QDoubleSpinBox*> spinBoxes;
84  QLineEdit* pyValue;
85 };
86 class Vector3Dialog : public QDialog {
87  Q_OBJECT
88 public:
89  Vector3Dialog(viewer::Property* prop, QWidget* parent = 0);
91 signals:
92  void valueChanged(const osgVector3& config);
93 public slots:
94  void set(const osgVector3& v);
95 private slots:
96  void updateValue();
97 private:
98  void setPyValue();
99  QVector<QDoubleSpinBox*> spinBoxes;
100  QLineEdit* pyValue;
101 };
102 class Vector4Dialog : public QDialog {
103  Q_OBJECT
104 public:
105  Vector4Dialog(viewer::Property* prop, QWidget* parent = 0);
107 signals:
108  void valueChanged(const osgVector4& config);
109 public slots:
110  void set(const osgVector4& v);
111 private slots:
112  void updateValue();
113 private:
114  void setPyValue();
115  QVector<QDoubleSpinBox*> spinBoxes;
116  QLineEdit* pyValue;
117 };
118 class ConfigurationDialog : public QDialog {
119  Q_OBJECT
120 public:
121  ConfigurationDialog(viewer::Property* prop, QWidget* parent = 0);
123 signals:
124  void valueChanged(const Configuration& config);
125 public slots:
126  void set(const Configuration& v);
127 private slots:
128  void updateValue();
129 private:
130  void setPyValue();
131  QVector<QDoubleSpinBox*> spinBoxes;
132  QLineEdit* pyValue;
133 };
134 
135 } // namespace gui
136 } // namespace gepetto
137 
138 #endif // GEPETTO_GUI_CONFIGURATION_DIALOG_HH
Definition: configuration.hh:70
viewer::Configuration Configuration
Definition: configuration.hh:30
::osg::Vec3f osgVector3
Definition: config-osg.h:109
Definition: configuration.hh:102
Definition: configuration.hh:86
::osg::Vec2f osgVector2
Definition: config-osg.h:108
Definition: configuration.hh:118
::osg::Vec4f osgVector4
Definition: config-osg.h:110
Definition: action-search-bar.hh:27
void valueChanged(const osgVector2 &config)
Definition: config-osg.h:144
Abstract base class for runtime properties of Node.
Definition: node-property.h:71
void setValueFromProperty(viewer::Property *prop)
Vector2Dialog(viewer::Property *prop, QWidget *parent=0)