QXRD  0.11.16
qxrddetectorproxy.cpp
Go to the documentation of this file.
1 #include "qxrddetectorproxy.h"
2 #include "qxrdacquisition.h"
3 #include "qxrddetector.h"
4 #include "qxrddetectorthread.h"
6 #include "qcepproperty.h"
7 #include <QLineEdit>
8 #include <QCheckBox>
9 
11  QxrdDetectorPtr det,
13  : QcepObject("detectorProxy", acq.data()),
14  m_Acquisition(acq),
15  m_DetectorThread(thr),
16  m_Detector(det),
18  m_SettingsChanged(false),
19  m_Initialized(false)
20 {
21 
22  if (det) {
23  setEnabled(det->get_Enabled());
24  m_DetectorType = det->get_DetectorType();
25  }
26 }
27 
29  : QcepObject("detectorProxy", acq.data()),
30  m_Acquisition(acq),
32  m_Detector(),
33  m_DetectorType(detectorType),
34  m_SettingsChanged(false),
35  m_Initialized(false)
36 {
37  setEnabled(true);
38 }
39 
41 {
42  if (!m_Initialized) {
43  if (sharedFromThis()) {
44  if (m_Detector) {
45  m_Detector->pushPropertiesToProxy(sharedFromThis());
46  } else {
48  }
49 
50  m_Initialized = true;
51  } else {
52  printf("Proxy initialize failed\n");
53  }
54  }
55 }
56 
58 {
59  return property("enabled").toBool();
60 }
61 
63 {
64  setProperty("enabled", a);
65 }
66 
68 {
69  return property("detectorNumber").toInt();
70 }
71 
73 {
74  return property("detectorType").toInt();
75 }
76 
78 {
80 }
81 
83 {
84  return property("detectorName").toString();
85 }
86 
88 {
89  setProperty("detectorName", name);
90 }
91 
93 {
94  return m_DetectorThread;
95 }
96 
98 {
99  return m_Detector;
100 }
101 
103 {
104  if (m_Detector) {
105  m_Detector->pushPropertiesToProxy(sharedFromThis());
106  } else {
108  }
109 
111  new QxrdDetectorConfigurationDialog(sharedFromThis());
112 
113  if (d->exec() == QDialog::Accepted) {
114  m_SettingsChanged = true;
115  }
116 
117  delete d;
118 
119  return m_SettingsChanged;
120 }
121 
123 {
124  return m_SettingsChanged;
125 }
126 
128 {
129  m_PropertyTypes.clear();
130  m_PropertyNames.clear();
131  m_PropertyDescriptions.clear();
132  m_PropertyValues.clear();
133 }
134 
135 void QxrdDetectorProxy::pushProperty(PropertyType type, QString name, QString description, QVariant value)
136 {
137  m_PropertyTypes.append(type);
138  m_PropertyNames.append(name);
139  m_PropertyDescriptions.append(description);
140  m_PropertyValues.append(value);
141 
142  setProperty(qPrintable(name), value);
143 }
144 
146 {
147  if (dialog) {
148  int nProps = m_PropertyTypes.count();
149 
150  for (int i = 0; i<nProps; i++) {
151  dialog->appendProperty(m_PropertyTypes.value(i),
152  m_PropertyNames.value(i),
153  m_PropertyDescriptions.value(i),
154  m_PropertyValues.value(i));
155  }
156  }
157 }
158 
160 {
161  if (dialog) {
162  int nProps = m_PropertyTypes.count();
163 
164  for (int i=0; i<nProps; i++) {
165  int propType = m_PropertyTypes.value(i);
166  QString propName = m_PropertyNames.value(i);
167  QVariant propVal = dialog->propertyValue(propType, i);
168 
169  if (propVal.isValid()) {
170  setProperty(qPrintable(propName), propVal);
171  }
172  }
173 
174  clearProperties();
175  }
176 }
QxrdDetectorPtr detector()
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
QxrdDetectorThreadPtr m_DetectorThread
QxrdDetectorProxy(QxrdDetectorThreadPtr thr, QxrdDetectorPtr det, QxrdAcquisitionPtr acq)
void appendProperty(int type, QString name, QString description, QVariant value)
void pushPropertiesToDialog(QxrdDetectorConfigurationDialog *dialog)
void setDetectorName(QString name)
QVector< QString > m_PropertyDescriptions
QVector< QString > m_PropertyNames
static void pushDefaultsToProxy(int detectorType, QxrdDetectorProxyPtr proxy)
void pushProperty(PropertyType type, QString name, QString description, QVariant value)
QString name
Definition: qcepobject.h:49
QxrdAcquisitionPtr m_Acquisition
void pullPropertiesFromDialog(QxrdDetectorConfigurationDialog *dialog)
QSharedPointer< QxrdDetectorThread > QxrdDetectorThreadPtr
QSharedPointer< QxrdDetector > QxrdDetectorPtr
QxrdDetectorPtr m_Detector
static QString detectorTypeName(int detectorType)
QVector< QVariant > m_PropertyValues
QVector< PropertyType > m_PropertyTypes
QxrdDetectorThreadPtr detectorThread()