2 #include "qcepmutexlocker.h"
4 #include "qcepsettingssaver.h"
5 #include <QScriptEngine>
9 QcepProperty(saver, parent, name, toolTip),
16 QcepProperty(saver, parent, name, toolTip),
24 qRegisterMetaType< CctwIntVector3D >(
"CctwIntVector3D");
26 qRegisterMetaTypeStreamOperators< CctwIntVector3D >(
"CctwIntVector3D");
33 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
40 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
47 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
55 printMessage(tr(
"%1 CctwqtIntVector3DProperty::setValue(CctwIntVector3D %2, int %3) [%4]")
56 .arg(name()).arg(
toString(val)).arg(index).arg(this->index()));
59 if (index == this->index()) {
66 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
68 if (qcepDebug(DEBUG_PROPERTIES) || debug()) {
69 printMessage(tr(
"%1: CctwqtIntVector3DProperty::incValue(CctwIntVector3D %2...)")
75 QcepSettingsSaverPtr saver(m_Saver);
86 if (index == this->index()) {
93 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
96 int newIndex = incIndex(1);
108 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
110 QString res = tr(
"[ %1 %2 %3 ]").arg(val.
x()).arg(val.
y()).arg(val.
z());
117 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
119 if (qcepDebug(DEBUG_PROPERTIES)) {
120 printMessage(tr(
"%1 CctwqtIntVector3DProperty::setValue(CctwIntVector3D %2)")
125 int newIndex = incIndex(1);
128 printMessage(tr(
"%1: CctwqtIntVector3DProperty::setValue(CctwIntVector3D %2) [%3]")
129 .arg(name()).arg(
toString(val)).arg(index()));
132 for (
int axis=0; axis<3; axis++) {
133 if (val(axis) !=
m_Value(axis)) {
140 QcepSettingsSaverPtr saver(m_Saver);
143 saver->changed(
this);
152 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
159 if (qcepDebug(DEBUG_PROPERTIES)) {
160 printMessage(tr(
"%1: CctwqtIntVector3DProperty::resetValue").arg(name()));
168 QScriptValue obj = engine->newArray(3);
170 obj.setProperty(0, vec.
x());
171 obj.setProperty(1, vec.
y());
172 obj.setProperty(2, vec.
z());
179 vec.
x() = obj.property(0).toInteger();
180 vec.
y() = obj.property(1).toInteger();
181 vec.
z() = obj.property(2).toInteger();
201 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
206 helper->moveToThread(spinBox->thread());
210 spinBox -> setKeyboardTracking(
false);
212 setWidgetToolTip(spinBox);
222 m_Property(property),
229 CONNECT_CHECK(QObject::connect(
m_SpinBox, SIGNAL(valueChanged(
int)),
this, SLOT(
setValue(
int)), Qt::DirectConnection));
237 bool block =
m_SpinBox->blockSignals(
true);
250 #ifndef QT_NO_DATASTREAM
254 for (
int i = 0; i < 3; ++i) {
264 for (
int i = 0; i < 3; ++i) {
CctwIntVector3DPropertySpinBoxHelper(QSpinBox *spinBox, CctwIntVector3DProperty *property, int axis)
static void registerMetaTypes()
int subValue(int axis) const
void setSubValue(int axis, int value, int index)
void valueChanged(CctwIntVector3D val, int index)
QDataStream & operator<<(QDataStream &stream, const CctwIntVector3D &vec)
void incValue(CctwIntVector3D step)
void subValueChanged(int axis, int val, int index)
static void fromScriptValue(const QScriptValue &obj, CctwIntVector3D &vec)
void setSubValue(int axis, int value, int index)
CctwIntVector3D value() const
void setValue(CctwIntVector3D val, int index)
void setDefaultValue(CctwIntVector3D val)
void subValueChanged(int axis, int value, int index)
static QScriptValue toScriptValue(QScriptEngine *engine, const CctwIntVector3D &vec)
CctwIntVector3D m_Default
CctwIntVector3DProperty(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, CctwIntVector3D value, QString toolTip)
CctwIntVector3DProperty * m_Property
static void customSaver(const QVariant &val, QSettings *settings, QString name)
QDataStream & operator>>(QDataStream &stream, CctwIntVector3D &vec)
QString toString(const CctwIntVector3D &mat)
CctwIntVector3D defaultValue() const
void linkTo(QSpinBox *xSpinBox, QSpinBox *ySpinBox, QSpinBox *zSpinBox)