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

#include <cctwdoublevector3dproperty.h>

Inheritance diagram for CctwDoubleVector3DProperty:
Inheritance graph
Collaboration diagram for CctwDoubleVector3DProperty:
Collaboration graph

Public Slots

void setValue (CctwDoubleVector3D val, int index)
 
void setValue (CctwDoubleVector3D val)
 
void incValue (CctwDoubleVector3D step)
 
void setDefaultValue (CctwDoubleVector3D val)
 
void resetValue ()
 
void setSubValue (int axis, double value, int index)
 
void setSubValue (int axis, double value)
 

Signals

void valueChanged (CctwDoubleVector3D val, int index)
 
void subValueChanged (int axis, double val, int index)
 

Public Member Functions

 CctwDoubleVector3DProperty (QcepSettingsSaverWPtr saver, QObject *parent, const char *name, CctwDoubleVector3D value, QString toolTip)
 
 CctwDoubleVector3DProperty (QcepSettingsSaverWPtr saver, QObject *parent, const char *name, double x, double y, double z, QString toolTip)
 
CctwDoubleVector3D value () const
 
CctwDoubleVector3D defaultValue () const
 
QString toString (const CctwDoubleVector3D &mat)
 
double subValue (int axis) const
 
void linkTo (QDoubleSpinBox *xSpinBox, QDoubleSpinBox *ySpinBox, QDoubleSpinBox *zSpinBox)
 
void linkTo (int axis, QDoubleSpinBox *spinBox)
 

Static Public Member Functions

static void registerMetaTypes ()
 
static QScriptValue toScriptValue (QScriptEngine *engine, const CctwDoubleVector3D &vec)
 
static void fromScriptValue (const QScriptValue &obj, CctwDoubleVector3D &vec)
 

Private Attributes

CctwDoubleVector3D m_Default
 
CctwDoubleVector3D m_Value
 

Detailed Description

Definition at line 7 of file cctwdoublevector3dproperty.h.

Constructor & Destructor Documentation

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

Definition at line 8 of file cctwdoublevector3dproperty.cpp.

8  :
9  QcepProperty(saver, parent, name, toolTip),
10  m_Default(value),
11  m_Value(value)
12 {
13 }
CctwDoubleVector3DProperty::CctwDoubleVector3DProperty ( QcepSettingsSaverWPtr  saver,
QObject *  parent,
const char *  name,
double  x,
double  y,
double  z,
QString  toolTip 
)
explicit

Definition at line 15 of file cctwdoublevector3dproperty.cpp.

15  :
16  QcepProperty(saver, parent, name, toolTip),
19 {
20 }
CctwVector3D< double > CctwDoubleVector3D
Definition: cctwvector3d.h:71

Member Function Documentation

CctwDoubleVector3D CctwDoubleVector3DProperty::defaultValue ( ) const

Definition at line 38 of file cctwdoublevector3dproperty.cpp.

References m_Default.

Referenced by resetValue().

39 {
40  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
41 
42  return m_Default;
43 }
void CctwDoubleVector3DProperty::fromScriptValue ( const QScriptValue &  obj,
CctwDoubleVector3D vec 
)
static

Definition at line 162 of file cctwdoublevector3dproperty.cpp.

References CctwVector3D< T >::x(), CctwVector3D< T >::y(), and CctwVector3D< T >::z().

Referenced by CctwScriptEngine::CctwScriptEngine().

163 {
164  vec.x() = obj.property(0).toNumber();
165  vec.y() = obj.property(1).toNumber();
166  vec.z() = obj.property(2).toNumber();
167 }
T x() const
Definition: cctwvector3d.h:17
T z() const
Definition: cctwvector3d.h:19
T y() const
Definition: cctwvector3d.h:18
void CctwDoubleVector3DProperty::incValue ( CctwDoubleVector3D  step)
slot

Definition at line 64 of file cctwdoublevector3dproperty.cpp.

References m_Value, and setValue().

65 {
66  setValue(m_Value + step);
67 }
void setValue(CctwDoubleVector3D val, int index)
void CctwDoubleVector3DProperty::linkTo ( QDoubleSpinBox *  xSpinBox,
QDoubleSpinBox *  ySpinBox,
QDoubleSpinBox *  zSpinBox 
)

Definition at line 169 of file cctwdoublevector3dproperty.cpp.

170 {
171  if (xSpinBox) {
172  linkTo(0, xSpinBox);
173  }
174 
175  if (ySpinBox) {
176  linkTo(1, ySpinBox);
177  }
178 
179  if (zSpinBox) {
180  linkTo(2, zSpinBox);
181  }
182 }
void linkTo(QDoubleSpinBox *xSpinBox, QDoubleSpinBox *ySpinBox, QDoubleSpinBox *zSpinBox)
void CctwDoubleVector3DProperty::linkTo ( int  axis,
QDoubleSpinBox *  spinBox 
)

Definition at line 184 of file cctwdoublevector3dproperty.cpp.

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

185 {
186  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
187 
189  = new CctwDoubleVector3DPropertyDoubleSpinBoxHelper(spinBox, this, axis);
190 
191  helper->moveToThread(spinBox->thread());
192  helper->connect();
193 
194  spinBox -> setValue(subValue(axis));
195  spinBox -> setKeyboardTracking(false);
196 
197  setWidgetToolTip(spinBox);
198 
199  connect(this, SIGNAL(subValueChanged(int,double,int)), helper, SLOT(setSubValue(int,double,int)));
200  connect(helper, SIGNAL(subValueChanged(int,double,int)), this, SLOT(setSubValue(int,double,int)));
201 }
void setValue(CctwDoubleVector3D val, int index)
void setSubValue(int axis, double value, int index)
void subValueChanged(int axis, double val, int index)
void CctwDoubleVector3DProperty::registerMetaTypes ( )
static

Definition at line 22 of file cctwdoublevector3dproperty.cpp.

References CctwVector3D< double >::customSaver().

Referenced by CctwApplication::CctwApplication().

23 {
24  qRegisterMetaType< CctwDoubleVector3D >("CctwDoubleVector3D");
25 
26  qRegisterMetaTypeStreamOperators< CctwDoubleVector3D >("CctwDoubleVector3D");
27 
28  registerCustomSaver("CctwDoubleVector3D", CctwDoubleVector3D::customSaver);
29 }
static void customSaver(const QVariant &val, QSettings *settings, QString name)
void CctwDoubleVector3DProperty::resetValue ( )
slot

Definition at line 142 of file cctwdoublevector3dproperty.cpp.

References defaultValue(), and setValue().

143 {
144  if (qcepDebug(DEBUG_PROPERTIES)) {
145  printMessage(tr("%1: CctwqtDoubleVector3DProperty::resetValue").arg(name()));
146  }
147 
149 }
void setValue(CctwDoubleVector3D val, int index)
CctwDoubleVector3D defaultValue() const
void CctwDoubleVector3DProperty::setDefaultValue ( CctwDoubleVector3D  val)
slot

Definition at line 135 of file cctwdoublevector3dproperty.cpp.

References m_Default.

136 {
137  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
138 
139  m_Default = val;
140 }
void CctwDoubleVector3DProperty::setSubValue ( int  axis,
double  value,
int  index 
)
slot

Definition at line 69 of file cctwdoublevector3dproperty.cpp.

Referenced by linkTo().

70 {
71  if (index == this->index()) {
72  setSubValue(axis, value);
73  }
74 }
void setSubValue(int axis, double value, int index)
CctwDoubleVector3D value() const
void CctwDoubleVector3DProperty::setSubValue ( int  axis,
double  value 
)
slot

Definition at line 76 of file cctwdoublevector3dproperty.cpp.

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

77 {
78  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
79 
80  if (value != m_Value(axis)) {
81  int newIndex = incIndex(1);
82 
83  emit subValueChanged(axis, value, newIndex);
84 
85  m_Value(axis) = value;
86 
87  emit valueChanged(m_Value, newIndex);
88  }
89 }
void valueChanged(CctwDoubleVector3D val, int index)
CctwDoubleVector3D value() const
void subValueChanged(int axis, double val, int index)
void CctwDoubleVector3DProperty::setValue ( CctwDoubleVector3D  val,
int  index 
)
slot

Definition at line 52 of file cctwdoublevector3dproperty.cpp.

References toString().

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

53 {
54  if (debug()) {
55  printMessage(tr("%1 CctwqtDoubleVector3DProperty::setValue(CctwDoubleVector3D %2, int %3) [%4]")
56  .arg(name()).arg(toString(val)).arg(index).arg(this->index()));
57  }
58 
59  if (index == this->index()) {
60  setValue(val);
61  }
62 }
void setValue(CctwDoubleVector3D val, int index)
QString toString(const CctwDoubleVector3D &mat)
void CctwDoubleVector3DProperty::setValue ( CctwDoubleVector3D  val)
slot

Definition at line 100 of file cctwdoublevector3dproperty.cpp.

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

101 {
102  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
103 
104  if (qcepDebug(DEBUG_PROPERTIES)) {
105  printMessage(tr("%1 CctwqtDoubleVector3DProperty::setValue(CctwDoubleVector3D %2)")
106  .arg(name()).arg(toString(val)));
107  }
108 
109  if (val != m_Value) {
110  int newIndex = incIndex(1);
111 
112  if (debug()) {
113  printMessage(tr("%1: CctwqtDoubleVector3DProperty::setValue(CctwDoubleVector3D %2) [%3]")
114  .arg(name()).arg(toString(val)).arg(index()));
115  }
116 
117  for (int axis=0; axis<3; axis++) {
118  if (val(axis) != m_Value(axis)) {
119  emit subValueChanged(axis, val(axis), newIndex);
120  }
121  }
122 
123  m_Value = val;
124 
125  QcepSettingsSaverPtr saver(m_Saver);
126 
127  if (saver) {
128  saver->changed(this);
129  }
130 
131  emit valueChanged(m_Value, newIndex);
132  }
133 }
void valueChanged(CctwDoubleVector3D val, int index)
void subValueChanged(int axis, double val, int index)
QString toString(const CctwDoubleVector3D &mat)
double CctwDoubleVector3DProperty::subValue ( int  axis) const

Definition at line 45 of file cctwdoublevector3dproperty.cpp.

References m_Value.

Referenced by linkTo().

46 {
47  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
48 
49  return m_Value(axis);
50 }
void CctwDoubleVector3DProperty::subValueChanged ( int  axis,
double  val,
int  index 
)
signal

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

QScriptValue CctwDoubleVector3DProperty::toScriptValue ( QScriptEngine *  engine,
const CctwDoubleVector3D vec 
)
static

Definition at line 151 of file cctwdoublevector3dproperty.cpp.

References CctwVector3D< T >::x(), CctwVector3D< T >::y(), and CctwVector3D< T >::z().

Referenced by CctwScriptEngine::CctwScriptEngine().

152 {
153  QScriptValue obj = engine->newArray(3);
154 
155  obj.setProperty(0, vec.x());
156  obj.setProperty(1, vec.y());
157  obj.setProperty(2, vec.z());
158 
159  return obj;
160 }
T x() const
Definition: cctwvector3d.h:17
T z() const
Definition: cctwvector3d.h:19
T y() const
Definition: cctwvector3d.h:18
QString CctwDoubleVector3DProperty::toString ( const CctwDoubleVector3D mat)

Definition at line 91 of file cctwdoublevector3dproperty.cpp.

References CctwVector3D< T >::x(), CctwVector3D< T >::y(), and CctwVector3D< T >::z().

Referenced by setValue().

92 {
93  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
94 
95  QString res = tr("[ %1 %2 %3 ]").arg(val.x()).arg(val.y()).arg(val.z());
96 
97  return res;
98 }
CctwDoubleVector3D CctwDoubleVector3DProperty::value ( ) const

Definition at line 31 of file cctwdoublevector3dproperty.cpp.

References m_Value.

Referenced by setSubValue().

32 {
33  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
34 
35  return m_Value;
36 }
void CctwDoubleVector3DProperty::valueChanged ( CctwDoubleVector3D  val,
int  index 
)
signal

Referenced by setSubValue(), and setValue().

Member Data Documentation

CctwDoubleVector3D CctwDoubleVector3DProperty::m_Default
private

Definition at line 40 of file cctwdoublevector3dproperty.h.

Referenced by defaultValue(), and setDefaultValue().

CctwDoubleVector3D CctwDoubleVector3DProperty::m_Value
private

Definition at line 41 of file cctwdoublevector3dproperty.h.

Referenced by incValue(), setSubValue(), setValue(), subValue(), and value().


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