51 #include <QGridLayout>
55 #include "matrix4x4Widget.hh"
72 QGridLayout *gL =
new QGridLayout;
74 for (
int i = 0; i < 16; i++)
82 if (_hints.contains (
"default"))
84 QStringList sl = _hints[
"default"].split (
',');
86 if (sl.length () == 16)
88 for (
int i = 0; i < 16 && ok; i++)
89 default_[i] = sl[i].toFloat (&ok);
92 for (
int i = 0; i < 16; i++)
97 for (
int i = 0; i < 16; i++)
98 fields_[i] =
new QLineEdit;
100 for (
int i = 0; i < 4; i++)
102 gL->addWidget (
new QLabel (
"("),i, 0);
103 gL->addWidget (fields_[i], i, 1);
104 gL->addWidget (
new QLabel (
","), i, 2);
105 gL->addWidget (fields_[i + 4], i, 3);
106 gL->addWidget (
new QLabel (
","), i, 4);
107 gL->addWidget (fields_[i + 8], i, 5);
108 gL->addWidget (
new QLabel (
","), i, 6);
109 gL->addWidget (fields_[i + 12], i, 7);
110 gL->addWidget (
new QLabel (
")"), i, 8);
113 for (
int i = 0; i < 16; i++)
115 fields_[i]->setText (QString::number (default_[i]));
116 connect (fields_[i], SIGNAL (editingFinished ()),
this, SLOT (editingFinished ()));
121 for (
int i = 0; i < 16; i++)
122 current_[i] = default_[i];
135 QString rv =
"Matrix4x4 (";
136 for (
int i = 0; i < 16; i++)
137 rv += QString::number (current_[i]) +
",";
139 rv.remove (rv.length () - 1, 1);
149 if (_from.startsWith (
"Matrix4x4 ("))
150 _from.remove (0, 11);
151 if (_from.endsWith (
")"))
152 _from.remove (_from.length () - 1, 1);
154 QStringList sl = _from.split (
',');
159 if (sl.length () == 16)
161 for (
int i = 0; i < 16 && ok; i++)
162 v[i] = sl[i].toFloat (&ok);
165 for (
int i = 0; i < 16; i++)
168 fields_[i]->setText (QString::number (current_[i]));
176 void Matrix4x4Widget::editingFinished ()
180 for (
int i = 0; i < 16; i++)
182 const float v = fields_[i]->text ().toFloat (&ok);
187 fields_[i]->setText (QString::number (current_[i]));
198 for (
int i = 0; i < 16; i++)
200 current_[i] = default_[i];
201 fields_[i]->setText (QString::number (current_[i]));
void fromValue(QString _from)
Read value from string.
Matrix4x4Widget(QMap< QString, QString > &_hints, QString _typeName, QWidget *_parent=NULL)
Constructor.
~Matrix4x4Widget()
Destructor.
void toDefault()
Reset to default.
QString toValue()
Convert current value to string.