QXRD  0.11.16
qcepvector3dproperty.cpp
Go to the documentation of this file.
1 #include "qcepvector3dproperty.h"
2 #include "qcepmutexlocker.h"
3 #include "qcepdebug.h"
4 #include "qcepsettingssaver.h"
5 
6 QcepVector3DProperty::QcepVector3DProperty(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, QcepVector3D value, QString toolTip) :
7  QcepProperty(saver, parent, name, toolTip),
8  m_Default(value),
9  m_Value(value)
10 {
11 }
12 
13 QcepVector3DProperty::QcepVector3DProperty(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, double x, double y, double z, QString toolTip) :
14  QcepProperty(saver, parent, name, toolTip),
15  m_Default(x,y,z),
16  m_Value(x,y,z)
17 {
18 }
19 
21 {
22  qRegisterMetaType< QcepVector3D >("QcepVector3D");
23 
24  qRegisterMetaTypeStreamOperators< QcepVector3D >("QcepVector3D");
25 }
26 
28 {
29  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
30 
31  return m_Value;
32 }
33 
35 {
36  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
37 
38  return m_Default;
39 }
40 
42 {
43  if (debug()) {
44  printMessage(tr("%1 QcepVector3DProperty::setValue(QcepVector3D %2, int %3) [%4]")
45  .arg(name()).arg(toString(val)).arg(index).arg(this->index()));
46  }
47 
48  if (index == this->index()) {
49  setValue(val);
50  }
51 }
52 
54 {
55  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
56 
57  if (qcepDebug(DEBUG_PROPERTIES) || debug()) {
58  printMessage(tr("%1: QcepVector3DProperty::incValue(QcepVector3D %2...)")
59  .arg(name()).arg(toString(step)));
60  }
61 
62  m_Value += step;
63 
65 
66  if (saver) {
67  saver->changed(this);
68  }
69 
70  emit valueChanged(m_Value, incIndex(1));
71 }
72 
74 {
75  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
76 
77  QString res = tr("[ %1 %2 %3 ]").arg(val.x()).arg(val.y()).arg(val.z());
78 
79  return res;
80 }
81 
83 {
84  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
85 
87  printMessage(tr("%1 QcepVector3DProperty::setValue(QcepVector3D %2)")
88  .arg(name()).arg(toString(val)));
89  }
90 
91  if (val != m_Value) {
92  if (debug()) {
93  printMessage(tr("%1: QcepVector3DProperty::setValue(QcepVector3D %2) [%3]")
94  .arg(name()).arg(toString(val)).arg(index()));
95  }
96 
97  m_Value = val;
98 
100 
101  if (saver) {
102  saver->changed(this);
103  }
104 
105  emit valueChanged(m_Value, incIndex(1));
106  }
107 }
108 
110 {
111  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
112 
113  m_Default = val;
114 }
115 
117 {
119  printMessage(tr("%1: QcepVector3DProperty::resetValue").arg(name()));
120  }
121 
123 }
124 
125 
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QcepVector3D defaultValue() const
QMutex m_Mutex
Definition: qcepproperty.h:69
void setValue(QcepVector3D val, int index)
int incIndex(int step)
QcepVector3D value() const
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime())
void incValue(QcepVector3D step)
QString name() const
QSharedPointer< QcepSettingsSaver > QcepSettingsSaverPtr
int debug() const
QString toString(const QcepVector3D &mat)
QcepVector3DProperty(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, QcepVector3D value, QString toolTip)
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr
QcepSettingsSaverWPtr m_Saver
Definition: qcepproperty.h:70
void valueChanged(QcepVector3D val, int index)
void setDefaultValue(QcepVector3D val)