QXRD  0.11.16
qxrdcalibrantdspacing.cpp
Go to the documentation of this file.
2 
3 QxrdCalibrantDSpacing::QxrdCalibrantDSpacing(int calIndex, int h, int k, int l, int n, double d, double tth) :
4  m_Index(calIndex),
5  m_H(h),
6  m_K(k),
7  m_L(l),
8  m_N(n),
9  m_D(d),
10  m_TTH(tth)
11 {
12 }
13 
15  m_Index(spc.index()),
16  m_H(spc.h()),
17  m_K(spc.k()),
18  m_L(spc.l()),
19  m_N(spc.n()),
20  m_D(spc.d()),
21  m_TTH(spc.tth())
22 {
23 }
24 
26  m_Index(-1),
27  m_H(0),
28  m_K(0),
29  m_L(0),
30  m_N(0),
31  m_D(0),
32  m_TTH(0)
33 {
34 }
35 
37 {
38  return (m_Index >= 0) && (m_H != 0 || m_K != 0 || m_L != 0) && (m_N >= 0) && (m_D > 0.0) && (m_TTH > 0.0);
39 }
40 
42 {
43  return index()==spc.index() && h()==spc.h() && k()==spc.k() && l()==spc.l() && d()==spc.d() && tth()==spc.tth();
44 }
45 
47 {
48  return index()!=spc.index() || h()!=spc.h() || k()!=spc.k() || l()!=spc.l() || d()!=spc.d() || tth()!=spc.tth();
49 }
50 
51 void QxrdCalibrantDSpacing::setSettingsValue(QSettings *settings, QString name)
52 {
53  settings->beginGroup(name);
54  settings->setValue("index", index());
55  settings->setValue("h", h());
56  settings->setValue("k", k());
57  settings->setValue("l", l());
58  settings->setValue("n", n());
59  settings->setValue("d", d());
60  settings->setValue("tth", tth());
61  settings->endGroup();
62 }
63 
64 void QxrdCalibrantDSpacing::customSaver(const QVariant &val, QSettings *settings, QString name)
65 {
67 
68  spc.setSettingsValue(settings, name);
69 }
70 
71 
73 {
74  return QObject::tr("{index:%1, h:%2, k:%3, l:%4, n:%5, d:%6, tth:%7}")
75  .arg(index()).arg(h()).arg(k()).arg(l()).arg(n()).arg(d()).arg(tth());
76 }
77 
79 {
80  qRegisterMetaType<QxrdCalibrantDSpacing>("QxrdCalibrantDSpacing");
81 
82  qRegisterMetaTypeStreamOperators<QxrdCalibrantDSpacing>("QxrdCalibrantDSpacing");
83 
85 }
86 
87 QScriptValue QxrdCalibrantDSpacing::toScriptValue(QScriptEngine *engine, const QxrdCalibrantDSpacing &spc)
88 {
89  QScriptValue obj = engine->newObject();
90 
91  obj.setProperty("index", spc.index());
92  obj.setProperty("h", spc.h());
93  obj.setProperty("k", spc.k());
94  obj.setProperty("l", spc.l());
95  obj.setProperty("n", spc.n());
96  obj.setProperty("d", spc.d());
97  obj.setProperty("tth", spc.tth());
98 
99  return obj;
100 }
101 
103 {
104  spc.index() = obj.property("index").toInteger();
105  spc.h() = obj.property("h").toInteger();
106  spc.k() = obj.property("k").toInteger();
107  spc.l() = obj.property("l").toInteger();
108  spc.n() = obj.property("n").toInteger();
109  spc.d() = obj.property("d").toNumber();
110  spc.tth() = obj.property("tth").toNumber();
111 }
112 
113 #ifndef QT_NO_DATASTREAM
114 
115 QDataStream &operator<<(QDataStream &stream, const QxrdCalibrantDSpacing &pt)
116 {
117  stream << pt.index() << pt.h() << pt.k() << pt.l() << pt.n() << pt.d() << pt.tth();
118 
119  return stream;
120 }
121 
122 QDataStream &operator>>(QDataStream &stream, QxrdCalibrantDSpacing &pt)
123 {
124  stream >> pt.index() >> pt.h() >> pt.k() >> pt.l() >> pt.n() >> pt.d() >> pt.tth();
125 
126  return stream;
127 }
128 
129 #endif
130 
static void fromScriptValue(const QScriptValue &obj, QxrdCalibrantDSpacing &spc)
QDataStream & operator<<(QDataStream &stream, const QxrdCalibrantDSpacing &pt)
static void customSaver(const QVariant &val, QSettings *settings, QString name)
bool operator!=(const QxrdCalibrantDSpacing &spc) const
void setSettingsValue(QSettings *settings, QString name)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdCalibrantDSpacing &spc)
static void registerCustomSaver(QString typeName, CustomSettingsSaver *saver)
bool operator==(const QxrdCalibrantDSpacing &spc) const
QDataStream & operator>>(QDataStream &stream, QxrdCalibrantDSpacing &pt)