2 #include "qcepmutexlocker.h"
4 #include "qcepsettingssaver.h"
5 #include <QScriptEngine>
9 QObject *parent,
const char *name,
11 QcepProperty(saver, parent, name, toolTip),
18 double r0c0,
double r0c1,
double r0c2,
19 double r1c0,
double r1c1,
double r1c2,
20 double r2c0,
double r2c1,
double r2c2,
22 QcepProperty(saver, parent, name, toolTip),
28 val(0,0) = r0c0; val(0,1) = r0c1; val(0,2) = r0c2;
29 val(1,0) = r1c0; val(1,1) = r1c1; val(1,2) = r1c2;
30 val(2,0) = r2c0; val(2,1) = r2c1; val(2,2) = r2c2;
38 qRegisterMetaType< CctwDoubleMatrix3x3 >(
"CctwDoubleMatrix3x3");
40 qRegisterMetaTypeStreamOperators< CctwDoubleMatrix3x3 >(
"CctwDoubleMatrix3x3");
47 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
54 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
61 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
69 printMessage(tr(
"%1 CctwqtDoubleMatrix3x3Property::setValue(CctwDoubleMatrix3x3 %2, int %3) [%4]")
70 .arg(name()).arg(
toString(val)).arg(index).arg(this->index()));
73 if (index == this->index()) {
85 if (index == this->index()) {
92 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
94 if (value !=
m_Value(row, col)) {
95 int newIndex = incIndex(1);
107 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
111 for (
int row=0; row<3; row++) {
113 for (
int col=0; col<3; col++) {
114 res += tr(
"%1 ").arg(val(row, col));
126 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
128 if (qcepDebug(DEBUG_PROPERTIES)) {
129 printMessage(tr(
"%1 CctwqtDoubleMatrix3x3Property::setValue(CctwDoubleMatrix3x3 %2)")
134 int newIndex = incIndex(1);
137 printMessage(tr(
"%1: CctwqtDoubleMatrix3x3Property::setValue(CctwDoubleMatrix3x3 %2) [%3]")
138 .arg(name()).arg(
toString(val)).arg(index()));
141 for (
int row=0; row<3; row++) {
142 for (
int col=0; col<3; col++) {
143 if(val(row,col) !=
m_Value(row,col)) {
151 QcepSettingsSaverPtr saver(m_Saver);
154 saver->changed(
this);
163 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
170 if (qcepDebug(DEBUG_PROPERTIES)) {
171 printMessage(tr(
"%1: CctwqtDoubleMatrix3x3Property::resetValue").arg(name()));
179 QScriptValue obj = engine->newArray(3);
181 for (
int i=0; i<3; i++) {
182 obj.setProperty(i, engine->newArray(3));
185 for (
int r=0; r<3; r++) {
186 for (
int c=0; c<3; c++) {
187 obj.property(r).setProperty(c, mat(r,c));
202 for (
int r=0; r<3; r++) {
203 for (
int c=0; c<3; c++) {
204 mat(r,c)=obj.property(r).property(c).toNumber();
227 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
232 helper->moveToThread(spinBox->thread());
236 spinBox -> setKeyboardTracking(
false);
238 setWidgetToolTip(spinBox);
247 m_DoubleSpinBox(spinBox),
248 m_Property(property),
256 CONNECT_CHECK(QObject::connect(
m_DoubleSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
setValue(
double)), Qt::DirectConnection));
void incValue(CctwDoubleMatrix3x3 step)
static void fromScriptValue(const QScriptValue &obj, CctwDoubleMatrix3x3 &mat)
CctwDoubleMatrix3x3Property(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, CctwDoubleMatrix3x3 value, QString toolTip)
void setValue(double value)
static void registerMetaTypes()
void subValueChanged(int row, int col, double val, int index)
double subValue(int row, int col) const
void setDefaultValue(CctwDoubleMatrix3x3 val)
void setSubValue(int row, int col, double value, int index)
QDoubleSpinBox * m_DoubleSpinBox
CctwDoubleMatrix3x3Property * m_Property
CctwDoubleMatrix3x3 value() const
CctwDoubleMatrix3x3 defaultValue() const
void setValue(CctwDoubleMatrix3x3 val, int index)
void setSubValue(int row, int col, double value, int index)
void valueChanged(CctwDoubleMatrix3x3 val, int index)
CctwDoubleMatrix3x3PropertyDoubleSpinBoxHelper(QDoubleSpinBox *spinBox, CctwDoubleMatrix3x3Property *property, int row, int col)
static QScriptValue toScriptValue(QScriptEngine *engine, const CctwDoubleMatrix3x3 &mat)
QString toString(const CctwDoubleMatrix3x3 &mat)
void subValueChanged(int row, int col, double value, int index)
CctwDoubleMatrix3x3 m_Default
void linkTo(int row, int col, QDoubleSpinBox *spinBox)
CctwDoubleMatrix3x3 m_Value