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< CctwDoubleVector3D >(
"CctwDoubleVector3D");
26 qRegisterMetaTypeStreamOperators< CctwDoubleVector3D >(
"CctwDoubleVector3D");
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 CctwqtDoubleVector3DProperty::setValue(CctwDoubleVector3D %2, int %3) [%4]")
56 .arg(name()).arg(
toString(val)).arg(index).arg(this->index()));
59 if (index == this->index()) {
71 if (index == this->index()) {
78 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
81 int newIndex = incIndex(1);
93 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
95 QString res = tr(
"[ %1 %2 %3 ]").arg(val.
x()).arg(val.
y()).arg(val.
z());
102 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
104 if (qcepDebug(DEBUG_PROPERTIES)) {
105 printMessage(tr(
"%1 CctwqtDoubleVector3DProperty::setValue(CctwDoubleVector3D %2)")
110 int newIndex = incIndex(1);
113 printMessage(tr(
"%1: CctwqtDoubleVector3DProperty::setValue(CctwDoubleVector3D %2) [%3]")
114 .arg(name()).arg(
toString(val)).arg(index()));
117 for (
int axis=0; axis<3; axis++) {
118 if (val(axis) !=
m_Value(axis)) {
125 QcepSettingsSaverPtr saver(m_Saver);
128 saver->changed(
this);
137 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
144 if (qcepDebug(DEBUG_PROPERTIES)) {
145 printMessage(tr(
"%1: CctwqtDoubleVector3DProperty::resetValue").arg(name()));
153 QScriptValue obj = engine->newArray(3);
155 obj.setProperty(0, vec.
x());
156 obj.setProperty(1, vec.
y());
157 obj.setProperty(2, vec.
z());
164 vec.
x() = obj.property(0).toNumber();
165 vec.
y() = obj.property(1).toNumber();
166 vec.
z() = obj.property(2).toNumber();
186 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
191 helper->moveToThread(spinBox->thread());
195 spinBox -> setKeyboardTracking(
false);
197 setWidgetToolTip(spinBox);
206 m_DoubleSpinBox(spinBox),
207 m_Property(property),
214 CONNECT_CHECK(QObject::connect(
m_DoubleSpinBox, SIGNAL(valueChanged(
double)),
this, SLOT(
setValue(
double)), Qt::DirectConnection));
235 #ifndef QT_NO_DATASTREAM
239 for (
int i = 0; i < 3; ++i) {
249 for (
int i = 0; i < 3; ++i) {
CctwDoubleVector3DProperty(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, CctwDoubleVector3D value, QString toolTip)
CctwDoubleVector3D m_Value
void valueChanged(CctwDoubleVector3D val, int index)
void setValue(double value)
void setSubValue(int axis, double value, int index)
static void registerMetaTypes()
QDataStream & operator>>(QDataStream &stream, CctwDoubleVector3D &vec)
CctwDoubleVector3D m_Default
void setValue(CctwDoubleVector3D val, int index)
void linkTo(QDoubleSpinBox *xSpinBox, QDoubleSpinBox *ySpinBox, QDoubleSpinBox *zSpinBox)
void subValueChanged(int axis, double value, int index)
static QScriptValue toScriptValue(QScriptEngine *engine, const CctwDoubleVector3D &vec)
CctwDoubleVector3DPropertyDoubleSpinBoxHelper(QDoubleSpinBox *spinBox, CctwDoubleVector3DProperty *property, int axis)
static void fromScriptValue(const QScriptValue &obj, CctwDoubleVector3D &vec)
double subValue(int axis) const
void incValue(CctwDoubleVector3D step)
void setSubValue(int axis, double value, int index)
CctwDoubleVector3D value() const
QDataStream & operator<<(QDataStream &stream, const CctwDoubleVector3D &vec)
void subValueChanged(int axis, double val, int index)
CctwDoubleVector3D defaultValue() const
static void customSaver(const QVariant &val, QSettings *settings, QString name)
void setDefaultValue(CctwDoubleVector3D val)
QString toString(const CctwDoubleVector3D &mat)
CctwDoubleVector3DProperty * m_Property
QDoubleSpinBox * m_DoubleSpinBox