2 #include "qcepmutexlocker.h"
4 #include "qcepsettingssaver.h"
5 #include <QScriptEngine>
12 QcepProperty(saver, parent, name, toolTip),
19 QcepSettingsSaverWPtr saver,
22 double a,
double b,
double c,
23 double alpha,
double beta,
double gamma,
25 QcepProperty(saver, parent, name, toolTip),
33 qRegisterMetaType< CctwUnitCell >(
"CctwUnitCell");
35 qRegisterMetaTypeStreamOperators< CctwUnitCell >(
"CctwUnitCell");
42 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
49 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
57 printMessage(tr(
"%1 CctwqtUnitCellProperty::setValue(CctwUnitCell %2, int %3) [%4]")
58 .arg(name()).arg(
toString(val)).arg(index).arg(this->index()));
61 if (index == this->index()) {
68 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
70 QString res = tr(
"[ %1 %2 %3 %4 %5 %6 ]").arg(val.
a()).arg(val.
b()).arg(val.
c())
78 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
80 if (qcepDebug(DEBUG_PROPERTIES)) {
81 printMessage(tr(
"%1 CctwqtUnitCellProperty::setValue(CctwUnitCell %2)")
87 printMessage(tr(
"%1: CctwqtUnitCellProperty::setValue(CctwUnitCell %2) [%3]")
88 .arg(name()).arg(
toString(val)).arg(index()));
93 QcepSettingsSaverPtr saver(m_Saver);
105 QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
112 if (qcepDebug(DEBUG_PROPERTIES)) {
113 printMessage(tr(
"%1: CctwqtUnitCellProperty::resetValue").arg(name()));
119 #ifndef QT_NO_DATASTREAM
126 stream << cell.
alpha();
127 stream << cell.
beta();
128 stream << cell.
gamma();
138 stream >> cell.
alpha();
139 stream >> cell.
beta();
140 stream >> cell.
gamma();
149 QScriptValue obj = engine->newArray(6);
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());
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();
void setDefaultValue(CctwUnitCell val)
static void registerMetaTypes()
QDataStream & operator<<(QDataStream &stream, const CctwUnitCell &cell)
CctwUnitCellProperty(QcepSettingsSaverWPtr saver, QObject *parent, const char *name, CctwUnitCell value, QString toolTip)
QString toString(const CctwUnitCell &mat)
void valueChanged(CctwUnitCell val, int index)
static QScriptValue toScriptValue(QScriptEngine *engine, const CctwUnitCell &cell)
CctwUnitCell defaultValue() const
void setValue(CctwUnitCell val, int index)
QDataStream & operator>>(QDataStream &stream, CctwUnitCell &cell)
static void customSaver(const QVariant &val, QSettings *settings, QString name)
CctwUnitCell value() const
static void fromScriptValue(const QScriptValue &obj, CctwUnitCell &cell)