cctw  0.2.1
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CctwDoubleMatrix3x3Property Class Reference

#include <cctwdoublematrix3x3property.h>

Inheritance diagram for CctwDoubleMatrix3x3Property:
Inheritance graph
Collaboration diagram for CctwDoubleMatrix3x3Property:
Collaboration graph

Public Slots

void setValue (CctwDoubleMatrix3x3 val, int index)
 
void setValue (CctwDoubleMatrix3x3 val)
 
void incValue (CctwDoubleMatrix3x3 step)
 
void setDefaultValue (CctwDoubleMatrix3x3 val)
 
void resetValue ()
 
void setSubValue (int row, int col, double value, int index)
 
void setSubValue (int row, int col, double value)
 

Signals

void valueChanged (CctwDoubleMatrix3x3 val, int index)
 
void subValueChanged (int row, int col, double val, int index)
 

Public Member Functions

 CctwDoubleMatrix3x3Property (QcepSettingsSaverWPtr saver, QObject *parent, const char *name, CctwDoubleMatrix3x3 value, QString toolTip)
 
 CctwDoubleMatrix3x3Property (QcepSettingsSaverWPtr saver, QObject *parent, const char *name, double r0c0, double r0c1, double r0c2, double r1c0, double r1c1, double r1c2, double r2c0, double r2c1, double r2c2, QString toolTip)
 
CctwDoubleMatrix3x3 value () const
 
CctwDoubleMatrix3x3 defaultValue () const
 
QString toString (const CctwDoubleMatrix3x3 &mat)
 
double subValue (int row, int col) const
 
void linkTo (int row, int col, QDoubleSpinBox *spinBox)
 

Static Public Member Functions

static void registerMetaTypes ()
 
static QScriptValue toScriptValue (QScriptEngine *engine, const CctwDoubleMatrix3x3 &mat)
 
static void fromScriptValue (const QScriptValue &obj, CctwDoubleMatrix3x3 &mat)
 

Private Attributes

CctwDoubleMatrix3x3 m_Default
 
CctwDoubleMatrix3x3 m_Value
 

Detailed Description

Definition at line 7 of file cctwdoublematrix3x3property.h.

Constructor & Destructor Documentation

CctwDoubleMatrix3x3Property::CctwDoubleMatrix3x3Property ( QcepSettingsSaverWPtr  saver,
QObject *  parent,
const char *  name,
CctwDoubleMatrix3x3  value,
QString  toolTip 
)
explicit

Definition at line 8 of file cctwdoublematrix3x3property.cpp.

10  :
11  QcepProperty(saver, parent, name, toolTip),
12  m_Default(value),
13  m_Value(value)
14 {
15 }
CctwDoubleMatrix3x3Property::CctwDoubleMatrix3x3Property ( QcepSettingsSaverWPtr  saver,
QObject *  parent,
const char *  name,
double  r0c0,
double  r0c1,
double  r0c2,
double  r1c0,
double  r1c1,
double  r1c2,
double  r2c0,
double  r2c1,
double  r2c2,
QString  toolTip 
)
explicit

Definition at line 17 of file cctwdoublematrix3x3property.cpp.

References m_Default, and m_Value.

21  :
22  QcepProperty(saver, parent, name, toolTip),
23  m_Default(),
24  m_Value()
25 {
27 
28  val(0,0) = r0c0; val(0,1) = r0c1; val(0,2) = r0c2;
29  val(1,0) = r1c0; val(1,1) = r1c1; val(1,2) = r1c2;
30  val(2,0) = r2c0; val(2,1) = r2c1; val(2,2) = r2c2;
31 
32  m_Default = val;
33  m_Value = val;
34 }

Member Function Documentation

CctwDoubleMatrix3x3 CctwDoubleMatrix3x3Property::defaultValue ( ) const

Definition at line 52 of file cctwdoublematrix3x3property.cpp.

References m_Default.

Referenced by resetValue().

53 {
54  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
55 
56  return m_Default;
57 }
void CctwDoubleMatrix3x3Property::fromScriptValue ( const QScriptValue &  obj,
CctwDoubleMatrix3x3 mat 
)
static

Definition at line 200 of file cctwdoublematrix3x3property.cpp.

Referenced by CctwScriptEngine::CctwScriptEngine().

201 {
202  for (int r=0; r<3; r++) {
203  for (int c=0; c<3; c++) {
204  mat(r,c)=obj.property(r).property(c).toNumber();
205 // mat(r,c) = obj.property(tr("r%1c%2").arg(r).arg(c)).toNumber();
206  }
207  }
208 }
void CctwDoubleMatrix3x3Property::incValue ( CctwDoubleMatrix3x3  step)
slot

Definition at line 78 of file cctwdoublematrix3x3property.cpp.

References m_Value, and setValue().

79 {
80  setValue(m_Value + step);
81 }
void setValue(CctwDoubleMatrix3x3 val, int index)
void CctwDoubleMatrix3x3Property::linkTo ( int  row,
int  col,
QDoubleSpinBox *  spinBox 
)

Definition at line 225 of file cctwdoublematrix3x3property.cpp.

References CctwDoubleMatrix3x3PropertyDoubleSpinBoxHelper::connect(), setSubValue(), setValue(), subValue(), and subValueChanged().

226 {
227  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
228 
230  = new CctwDoubleMatrix3x3PropertyDoubleSpinBoxHelper(spinBox, this, row, col);
231 
232  helper->moveToThread(spinBox->thread());
233  helper->connect();
234 
235  spinBox -> setValue(subValue(row, col));
236  spinBox -> setKeyboardTracking(false);
237 
238  setWidgetToolTip(spinBox);
239 
240  connect(this, SIGNAL(subValueChanged(int,int,double,int)), helper, SLOT(setSubValue(int,int,double,int)));
241  connect(helper, SIGNAL(subValueChanged(int,int,double,int)), this, SLOT(setSubValue(int,int,double,int)));
242 }
void subValueChanged(int row, int col, double val, int index)
double subValue(int row, int col) const
void setValue(CctwDoubleMatrix3x3 val, int index)
void setSubValue(int row, int col, double value, int index)
void CctwDoubleMatrix3x3Property::registerMetaTypes ( )
static

Definition at line 36 of file cctwdoublematrix3x3property.cpp.

Referenced by CctwApplication::CctwApplication().

37 {
38  qRegisterMetaType< CctwDoubleMatrix3x3 >("CctwDoubleMatrix3x3");
39 
40  qRegisterMetaTypeStreamOperators< CctwDoubleMatrix3x3 >("CctwDoubleMatrix3x3");
41 
42  registerCustomSaver("CctwDoubleMatrix3x3", CctwMatrix3x3<double>::customSaver);
43 }
void CctwDoubleMatrix3x3Property::resetValue ( )
slot

Definition at line 168 of file cctwdoublematrix3x3property.cpp.

References defaultValue(), and setValue().

169 {
170  if (qcepDebug(DEBUG_PROPERTIES)) {
171  printMessage(tr("%1: CctwqtDoubleMatrix3x3Property::resetValue").arg(name()));
172  }
173 
175 }
CctwDoubleMatrix3x3 defaultValue() const
void setValue(CctwDoubleMatrix3x3 val, int index)
void CctwDoubleMatrix3x3Property::setDefaultValue ( CctwDoubleMatrix3x3  val)
slot

Definition at line 161 of file cctwdoublematrix3x3property.cpp.

References m_Default.

162 {
163  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
164 
165  m_Default = val;
166 }
void CctwDoubleMatrix3x3Property::setSubValue ( int  row,
int  col,
double  value,
int  index 
)
slot

Definition at line 83 of file cctwdoublematrix3x3property.cpp.

Referenced by linkTo().

84 {
85  if (index == this->index()) {
86  setSubValue(row, col, value);
87  }
88 }
CctwDoubleMatrix3x3 value() const
void setSubValue(int row, int col, double value, int index)
void CctwDoubleMatrix3x3Property::setSubValue ( int  row,
int  col,
double  value 
)
slot

Definition at line 90 of file cctwdoublematrix3x3property.cpp.

References m_Value, subValueChanged(), value(), and valueChanged().

91 {
92  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
93 
94  if (value != m_Value(row, col)) {
95  int newIndex = incIndex(1);
96 
97  emit subValueChanged(row, col, value, newIndex);
98 
99  m_Value(row, col) = value;
100 
101  emit valueChanged(m_Value, newIndex);
102  }
103 }
void subValueChanged(int row, int col, double val, int index)
CctwDoubleMatrix3x3 value() const
void valueChanged(CctwDoubleMatrix3x3 val, int index)
void CctwDoubleMatrix3x3Property::setValue ( CctwDoubleMatrix3x3  val,
int  index 
)
slot

Definition at line 66 of file cctwdoublematrix3x3property.cpp.

References toString().

Referenced by incValue(), linkTo(), and resetValue().

67 {
68  if (debug()) {
69  printMessage(tr("%1 CctwqtDoubleMatrix3x3Property::setValue(CctwDoubleMatrix3x3 %2, int %3) [%4]")
70  .arg(name()).arg(toString(val)).arg(index).arg(this->index()));
71  }
72 
73  if (index == this->index()) {
74  setValue(val);
75  }
76 }
void setValue(CctwDoubleMatrix3x3 val, int index)
QString toString(const CctwDoubleMatrix3x3 &mat)
void CctwDoubleMatrix3x3Property::setValue ( CctwDoubleMatrix3x3  val)
slot

Definition at line 124 of file cctwdoublematrix3x3property.cpp.

References m_Value, subValueChanged(), toString(), and valueChanged().

125 {
126  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
127 
128  if (qcepDebug(DEBUG_PROPERTIES)) {
129  printMessage(tr("%1 CctwqtDoubleMatrix3x3Property::setValue(CctwDoubleMatrix3x3 %2)")
130  .arg(name()).arg(toString(val)));
131  }
132 
133  if (val != m_Value) {
134  int newIndex = incIndex(1);
135 
136  if (debug()) {
137  printMessage(tr("%1: CctwqtDoubleMatrix3x3Property::setValue(CctwDoubleMatrix3x3 %2) [%3]")
138  .arg(name()).arg(toString(val)).arg(index()));
139  }
140 
141  for (int row=0; row<3; row++) {
142  for (int col=0; col<3; col++) {
143  if(val(row,col) != m_Value(row,col)) {
144  emit subValueChanged(row, col, val(row,col), newIndex);
145  }
146  }
147  }
148 
149  m_Value = val;
150 
151  QcepSettingsSaverPtr saver(m_Saver);
152 
153  if (saver) {
154  saver->changed(this);
155  }
156 
157  emit valueChanged(m_Value, newIndex);
158  }
159 }
void subValueChanged(int row, int col, double val, int index)
void valueChanged(CctwDoubleMatrix3x3 val, int index)
QString toString(const CctwDoubleMatrix3x3 &mat)
double CctwDoubleMatrix3x3Property::subValue ( int  row,
int  col 
) const

Definition at line 59 of file cctwdoublematrix3x3property.cpp.

References m_Value.

Referenced by linkTo().

60 {
61  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
62 
63  return m_Value(row, col);
64 }
void CctwDoubleMatrix3x3Property::subValueChanged ( int  row,
int  col,
double  val,
int  index 
)
signal

Referenced by linkTo(), setSubValue(), and setValue().

QScriptValue CctwDoubleMatrix3x3Property::toScriptValue ( QScriptEngine *  engine,
const CctwDoubleMatrix3x3 mat 
)
static

Definition at line 177 of file cctwdoublematrix3x3property.cpp.

Referenced by CctwScriptEngine::CctwScriptEngine().

178 {
179  QScriptValue obj = engine->newArray(3);
180 
181  for (int i=0; i<3; i++) {
182  obj.setProperty(i, engine->newArray(3));
183  }
184 
185  for (int r=0; r<3; r++) {
186  for (int c=0; c<3; c++) {
187  obj.property(r).setProperty(c, mat(r,c));
188  }
189  }
190 
191 // for (int r=0; r<3; r++) {
192 // for (int c=0; c<3; c++) {
193 // obj.setProperty(tr("r%1c%2").arg(r).arg(c), mat(r,c));
194 // }
195 // }
196 
197  return obj;
198 }
QString CctwDoubleMatrix3x3Property::toString ( const CctwDoubleMatrix3x3 mat)

Definition at line 105 of file cctwdoublematrix3x3property.cpp.

Referenced by setValue().

106 {
107  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
108 
109  QString res = "[";
110 
111  for (int row=0; row<3; row++) {
112  res += " [ ";
113  for (int col=0; col<3; col++) {
114  res += tr("%1 ").arg(val(row, col));
115  }
116  res += "]";
117  }
118 
119  res += "]";
120 
121  return res;
122 }
CctwDoubleMatrix3x3 CctwDoubleMatrix3x3Property::value ( ) const

Definition at line 45 of file cctwdoublematrix3x3property.cpp.

References m_Value.

Referenced by setSubValue().

46 {
47  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
48 
49  return m_Value;
50 }
void CctwDoubleMatrix3x3Property::valueChanged ( CctwDoubleMatrix3x3  val,
int  index 
)
signal

Referenced by setSubValue(), and setValue().

Member Data Documentation

CctwDoubleMatrix3x3 CctwDoubleMatrix3x3Property::m_Default
private
CctwDoubleMatrix3x3 CctwDoubleMatrix3x3Property::m_Value
private

The documentation for this class was generated from the following files: