cctw  0.2.1
cctwdoublematrix3x3property.h
Go to the documentation of this file.
1 #ifndef CCTWDOUBLEMATRIX3X3PROPERTY_H
2 #define CCTWDOUBLEMATRIX3X3PROPERTY_H
3 
4 #include "qcepproperty.h"
5 #include "cctwmatrix3x3.h"
6 
7 class CctwDoubleMatrix3x3Property : public QcepProperty
8 {
9  Q_OBJECT
10 public:
11  explicit CctwDoubleMatrix3x3Property(QcepSettingsSaverWPtr saver, QObject *parent, const char *name,
12  CctwDoubleMatrix3x3 value, QString toolTip);
13  explicit CctwDoubleMatrix3x3Property(QcepSettingsSaverWPtr saver, QObject *parent, const char *name,
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 
19  CctwDoubleMatrix3x3 value() const;
21  QString toString(const CctwDoubleMatrix3x3& mat);
22  double subValue(int row, int col) const;
23 
24  static void registerMetaTypes();
25  static QScriptValue toScriptValue(QScriptEngine *engine, const CctwDoubleMatrix3x3 &mat);
26  static void fromScriptValue(const QScriptValue &obj, CctwDoubleMatrix3x3 &mat);
27 
28  void linkTo(int row, int col, QDoubleSpinBox *spinBox);
29 
30 public slots:
31  void setValue(CctwDoubleMatrix3x3 val, int index);
32  void setValue(CctwDoubleMatrix3x3 val);
33  void incValue(CctwDoubleMatrix3x3 step);
35  void resetValue();
36  void setSubValue(int row, int col, double value, int index);
37  void setSubValue(int row, int col, double value);
38 
39 signals:
40  void valueChanged(CctwDoubleMatrix3x3 val, int index);
41  void subValueChanged(int row, int col, double val, int index);
42 
43 private:
46 };
47 
49  Q_OBJECT
50 
51 public:
52  CctwDoubleMatrix3x3PropertyDoubleSpinBoxHelper(QDoubleSpinBox *spinBox,
54  int row, int col);
55  void connect();
56 
57 public slots:
58  void setSubValue(int row, int col, double value, int index);
59  void setValue(double value);
60 
61 signals:
62  void subValueChanged(int row, int col, double value, int index);
63 
64 private:
65  QDoubleSpinBox *m_DoubleSpinBox;
67  int m_Row;
68  int m_Col;
69 };
70 
71 #define CCTW_DOUBLEMATRIX3X3_PROPERTY(propname) \
72 public: \
73 CctwDoubleMatrix3x3 get_##propname() const \
74 { \
75  return m_##propname.value(); \
76 } \
77 \
78 void set_##propname(CctwDoubleMatrix3x3 val) \
79 { \
80  m_##propname.setValue(val); \
81 } \
82 \
83 CctwDoubleMatrix3x3 def_##propname() const \
84 { \
85  return m_##propname.defaultValue(); \
86 } \
87 \
88 void setdef_##propname(CctwDoubleMatrix3x3 val) \
89 { \
90  m_##propname.setDefaultValue(val); \
91 } \
92 \
93 void reset_##propname() \
94 { \
95  m_##propname.resetValue(); \
96 } \
97 \
98 CctwDoubleMatrix3x3Property *prop_##propname() { \
99  return &m_##propname; \
100 } \
101 \
102 private: \
103 CctwDoubleMatrix3x3Property m_##propname;
104 
105 #ifndef QT_NO_DATASTREAM
106 
107 template <typename T>
108 QDataStream &operator<<(QDataStream &stream, const CctwMatrix3x3<T> &matrix)
109 {
110  for (int row = 0; row < 3; ++row)
111  for (int col = 0; col < 3; ++col)
112  stream << double(matrix(row, col));
113  return stream;
114 }
115 
116 template <typename T>
117 QDataStream &operator>>(QDataStream &stream, CctwMatrix3x3<T> &matrix)
118 {
119  double x;
120  for (int row = 0; row < 3; ++row) {
121  for (int col = 0; col < 3; ++col) {
122  stream >> x;
123  matrix(row, col) = T(x);
124  }
125  }
126  return stream;
127 }
128 
129 #endif
130 
131 #endif // CCTWDOUBLEMATRIX3X3PROPERTY_H
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 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)
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)
QDataStream & operator>>(QDataStream &stream, CctwMatrix3x3< T > &matrix)
void linkTo(int row, int col, QDoubleSpinBox *spinBox)