QXRD  0.11.16
qcepmatrix3x3property.cpp
Go to the documentation of this file.
2 #include "qcepmutexlocker.h"
3 #include "qcepdebug.h"
4 #include "qcepsettingssaver.h"
5 
6 QcepMatrix3x3Property::QcepMatrix3x3Property(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, QcepMatrix3x3 value, QString toolTip) :
7  QcepProperty(saver, parent, name, toolTip),
8  m_Default(value),
9  m_Value(value)
10 {
11 }
12 
14  double r0c0, double r0c1, double r0c2,
15  double r1c0, double r1c1, double r1c2,
16  double r2c0, double r2c1, double r2c2,
17  QString toolTip) :
18  QcepProperty(saver, parent, name, toolTip),
19  m_Default(),
20  m_Value()
21 {
22  QcepMatrix3x3 val;
23 
24  val(0,0) = r0c0; val(0,1) = r0c1; val(0,2) = r0c2;
25  val(1,0) = r1c0; val(1,1) = r1c1; val(1,2) = r1c2;
26  val(2,0) = r2c0; val(2,1) = r2c1; val(2,2) = r2c2;
27 
28  m_Default = val;
29  m_Value = val;
30 }
31 
33 {
34  qRegisterMetaType< QcepMatrix3x3 >("QcepMatrix3x3");
35 
36  qRegisterMetaTypeStreamOperators< QcepMatrix3x3 >("QcepMatrix3x3");
37 }
38 
40 {
41  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
42 
43  return m_Value;
44 }
45 
47 {
48  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
49 
50  return m_Default;
51 }
52 
54 {
55  if (debug()) {
56  printMessage(tr("%1 QcepMatrix3x3Property::setValue(QcepMatrix3x3 %2, int %3) [%4]")
57  .arg(name()).arg(toString(val)).arg(index).arg(this->index()));
58  }
59 
60  if (index == this->index()) {
61  setValue(val);
62  }
63 }
64 
66 {
67  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
68 
69  if (qcepDebug(DEBUG_PROPERTIES) || debug()) {
70  printMessage(tr("%1: QcepMatrix3x3Property::incValue(QcepMatrix3x3 %2...)")
71  .arg(name()).arg(toString(step)));
72  }
73 
74  m_Value += step;
75 
77 
78  if (saver) {
79  saver->changed(this);
80  }
81 
82  emit valueChanged(m_Value, incIndex(1));
83 }
84 
86 {
87  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
88 
89  QString res = "[";
90 
91  for (int row=0; row<3; row++) {
92  res += " [ ";
93  for (int col=0; col<3; col++) {
94  res += tr("%1 ").arg(val(row, col));
95  }
96  res += "]";
97  }
98 
99  res += "]";
100 
101  return res;
102 }
103 
105 {
106  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
107 
109  printMessage(tr("%1 QcepMatrix3x3Property::setValue(QcepMatrix3x3 %2)")
110  .arg(name()).arg(toString(val)));
111  }
112 
113  if (val != m_Value) {
114  if (debug()) {
115  printMessage(tr("%1: QcepMatrix3x3Property::setValue(QcepMatrix3x3 %2) [%3]")
116  .arg(name()).arg(toString(val)).arg(index()));
117  }
118 
119  m_Value = val;
120 
122 
123  if (saver) {
124  saver->changed(this);
125  }
126 
127  emit valueChanged(m_Value, incIndex(1));
128  }
129 }
130 
132 {
133  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
134 
135  m_Default = val;
136 }
137 
139 {
141  printMessage(tr("%1: QcepMatrix3x3Property::resetValue").arg(name()));
142  }
143 
145 }
146 
147 
QcepMatrix3x3 value() const
void incValue(QcepMatrix3x3 step)
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
void valueChanged(QcepMatrix3x3 val, int index)
QMutex m_Mutex
Definition: qcepproperty.h:69
void setDefaultValue(QcepMatrix3x3 val)
int incIndex(int step)
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime())
QcepMatrix3x3Property(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, QcepMatrix3x3 value, QString toolTip)
void setValue(QcepMatrix3x3 val, int index)
QString name() const
QSharedPointer< QcepSettingsSaver > QcepSettingsSaverPtr
int debug() const
QString toString(const QcepMatrix3x3 &mat)
QcepMatrix3x3 defaultValue() const
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr
QcepSettingsSaverWPtr m_Saver
Definition: qcepproperty.h:70