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

#include <cctwunitcellproperty.h>

Inheritance diagram for CctwUnitCellProperty:
Inheritance graph
Collaboration diagram for CctwUnitCellProperty:
Collaboration graph

Public Slots

void setValue (CctwUnitCell val, int index)
 
void setValue (CctwUnitCell val)
 
void setDefaultValue (CctwUnitCell val)
 
void resetValue ()
 

Signals

void valueChanged (CctwUnitCell val, int index)
 

Public Member Functions

 CctwUnitCellProperty (QcepSettingsSaverWPtr saver, QObject *parent, const char *name, CctwUnitCell value, QString toolTip)
 
 CctwUnitCellProperty (QcepSettingsSaverWPtr saver, QObject *parent, const char *name, double a, double b, double c, double alpha, double beta, double gamma, QString toolTip)
 
CctwUnitCell value () const
 
CctwUnitCell defaultValue () const
 
QString toString (const CctwUnitCell &mat)
 

Static Public Member Functions

static void registerMetaTypes ()
 
static QScriptValue toScriptValue (QScriptEngine *engine, const CctwUnitCell &cell)
 
static void fromScriptValue (const QScriptValue &obj, CctwUnitCell &cell)
 

Private Attributes

CctwUnitCell m_Default
 
CctwUnitCell m_Value
 

Detailed Description

Definition at line 7 of file cctwunitcellproperty.h.

Constructor & Destructor Documentation

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

Definition at line 7 of file cctwunitcellproperty.cpp.

11  :
12  QcepProperty(saver, parent, name, toolTip),
13  m_Default(value),
14  m_Value(value)
15 {
16 }
CctwUnitCellProperty::CctwUnitCellProperty ( QcepSettingsSaverWPtr  saver,
QObject *  parent,
const char *  name,
double  a,
double  b,
double  c,
double  alpha,
double  beta,
double  gamma,
QString  toolTip 
)
explicit

Definition at line 18 of file cctwunitcellproperty.cpp.

24  :
25  QcepProperty(saver, parent, name, toolTip),
26  m_Default(CctwUnitCell(a,b,c,alpha,beta,gamma)),
27  m_Value(CctwUnitCell(a,b,c,alpha,beta,gamma))
28 {
29 }

Member Function Documentation

CctwUnitCell CctwUnitCellProperty::defaultValue ( ) const

Definition at line 47 of file cctwunitcellproperty.cpp.

References m_Default.

Referenced by resetValue().

48 {
49  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
50 
51  return m_Default;
52 }
void CctwUnitCellProperty::fromScriptValue ( const QScriptValue &  obj,
CctwUnitCell cell 
)
static

Definition at line 161 of file cctwunitcellproperty.cpp.

References CctwUnitCell::a(), CctwUnitCell::alpha(), CctwUnitCell::b(), CctwUnitCell::beta(), CctwUnitCell::c(), and CctwUnitCell::gamma().

Referenced by CctwScriptEngine::CctwScriptEngine().

162 {
163  cell.a() = obj.property(0).toNumber();
164  cell.b() = obj.property(1).toNumber();
165  cell.c() = obj.property(2).toNumber();
166  cell.alpha() = obj.property(3).toNumber();
167  cell.beta() = obj.property(4).toNumber();
168  cell.gamma() = obj.property(5).toNumber();
169 }
double beta() const
double b() const
double a() const
double alpha() const
double gamma() const
double c() const
void CctwUnitCellProperty::registerMetaTypes ( )
static

Definition at line 31 of file cctwunitcellproperty.cpp.

References CctwUnitCell::customSaver().

Referenced by CctwApplication::CctwApplication().

32 {
33  qRegisterMetaType< CctwUnitCell >("CctwUnitCell");
34 
35  qRegisterMetaTypeStreamOperators< CctwUnitCell >("CctwUnitCell");
36 
37  registerCustomSaver("CctwUnitCell", CctwUnitCell::customSaver);
38 }
static void customSaver(const QVariant &val, QSettings *settings, QString name)
void CctwUnitCellProperty::resetValue ( )
slot

Definition at line 110 of file cctwunitcellproperty.cpp.

References defaultValue(), and setValue().

111 {
112  if (qcepDebug(DEBUG_PROPERTIES)) {
113  printMessage(tr("%1: CctwqtUnitCellProperty::resetValue").arg(name()));
114  }
115 
117 }
CctwUnitCell defaultValue() const
void setValue(CctwUnitCell val, int index)
void CctwUnitCellProperty::setDefaultValue ( CctwUnitCell  val)
slot

Definition at line 103 of file cctwunitcellproperty.cpp.

References m_Default.

104 {
105  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
106 
107  m_Default = val;
108 }
void CctwUnitCellProperty::setValue ( CctwUnitCell  val,
int  index 
)
slot

Definition at line 54 of file cctwunitcellproperty.cpp.

References toString().

Referenced by resetValue().

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

Definition at line 76 of file cctwunitcellproperty.cpp.

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

77 {
78  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
79 
80  if (qcepDebug(DEBUG_PROPERTIES)) {
81  printMessage(tr("%1 CctwqtUnitCellProperty::setValue(CctwUnitCell %2)")
82  .arg(name()).arg(toString(val)));
83  }
84 
85  if (val != m_Value) {
86  if (debug()) {
87  printMessage(tr("%1: CctwqtUnitCellProperty::setValue(CctwUnitCell %2) [%3]")
88  .arg(name()).arg(toString(val)).arg(index()));
89  }
90 
91  m_Value = val;
92 
93  QcepSettingsSaverPtr saver(m_Saver);
94 
95  if (saver) {
96  saver->changed(this);
97  }
98 
99  emit valueChanged(m_Value, incIndex(1));
100  }
101 }
QString toString(const CctwUnitCell &mat)
void valueChanged(CctwUnitCell val, int index)
QScriptValue CctwUnitCellProperty::toScriptValue ( QScriptEngine *  engine,
const CctwUnitCell cell 
)
static

Definition at line 147 of file cctwunitcellproperty.cpp.

References CctwUnitCell::a(), CctwUnitCell::alpha(), CctwUnitCell::b(), CctwUnitCell::beta(), CctwUnitCell::c(), and CctwUnitCell::gamma().

Referenced by CctwScriptEngine::CctwScriptEngine().

148 {
149  QScriptValue obj = engine->newArray(6);
150 
151  obj.setProperty(0, cell.a());
152  obj.setProperty(1, cell.b());
153  obj.setProperty(2, cell.c());
154  obj.setProperty(3, cell.alpha());
155  obj.setProperty(4, cell.beta());
156  obj.setProperty(5, cell.gamma());
157 
158  return obj;
159 }
double beta() const
double b() const
double a() const
double alpha() const
double gamma() const
double c() const
QString CctwUnitCellProperty::toString ( const CctwUnitCell mat)

Definition at line 66 of file cctwunitcellproperty.cpp.

References CctwUnitCell::a(), CctwUnitCell::alpha(), CctwUnitCell::b(), CctwUnitCell::beta(), CctwUnitCell::c(), and CctwUnitCell::gamma().

Referenced by setValue().

67 {
68  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
69 
70  QString res = tr("[ %1 %2 %3 %4 %5 %6 ]").arg(val.a()).arg(val.b()).arg(val.c())
71  .arg(val.alpha()).arg(val.beta()).arg(val.gamma());
72 
73  return res;
74 }
CctwUnitCell CctwUnitCellProperty::value ( ) const

Definition at line 40 of file cctwunitcellproperty.cpp.

References m_Value.

41 {
42  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
43 
44  return m_Value;
45 }
void CctwUnitCellProperty::valueChanged ( CctwUnitCell  val,
int  index 
)
signal

Referenced by setValue().

Member Data Documentation

CctwUnitCell CctwUnitCellProperty::m_Default
private

Definition at line 42 of file cctwunitcellproperty.h.

Referenced by defaultValue(), and setDefaultValue().

CctwUnitCell CctwUnitCellProperty::m_Value
private

Definition at line 43 of file cctwunitcellproperty.h.

Referenced by setValue(), and value().


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