QXRD  0.11.16
Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
QxrdDetectorConfigurationDialog Class Reference

#include <qxrddetectorconfigurationdialog.h>

Inheritance diagram for QxrdDetectorConfigurationDialog:
Inheritance graph
[legend]
Collaboration diagram for QxrdDetectorConfigurationDialog:
Collaboration graph
[legend]

Public Member Functions

 QxrdDetectorConfigurationDialog (QxrdDetectorProxyPtr proxy, QWidget *parent=0)
 
virtual ~QxrdDetectorConfigurationDialog ()
 
void accept ()
 
void appendProperty (int type, QString name, QString description, QVariant value)
 
QVariant propertyValue (int propType, int i)
 

Protected Member Functions

void changeEvent (QEvent *e)
 

Private Slots

void browseToDirectory (int i)
 
void browseToFilename (int i)
 

Private Attributes

QxrdDetectorProxyPtr m_Proxy
 
int m_CurrentRow
 
QVector< QWidget * > m_Widgets
 

Detailed Description

Definition at line 8 of file qxrddetectorconfigurationdialog.h.

Constructor & Destructor Documentation

QxrdDetectorConfigurationDialog::QxrdDetectorConfigurationDialog ( QxrdDetectorProxyPtr  proxy,
QWidget *  parent = 0 
)
explicit

Definition at line 20 of file qxrddetectorconfigurationdialog.cpp.

References GUI_THREAD_CHECK, and m_Proxy.

20  :
21  QDialog(parent),
22  m_Proxy(proxy),
23  m_CurrentRow(0)
24 {
26 
27  setupUi(this);
28 
29  if (m_Proxy) {
30  int detNum = m_Proxy->property("detectorNumber").toInt();
31 
32  setWindowTitle(tr("Configure Det %1: %2 \"%3\" ")
33  .arg(detNum).arg(m_Proxy->detectorTypeName()).arg(m_Proxy->detectorName()));
34 
35  m_Proxy->pushPropertiesToDialog(this);
36  }
37 }
#define GUI_THREAD_CHECK
Definition: qcepmacros.h:10
QxrdDetectorConfigurationDialog::~QxrdDetectorConfigurationDialog ( )
virtual

Definition at line 39 of file qxrddetectorconfigurationdialog.cpp.

40 {
41 }

Member Function Documentation

void QxrdDetectorConfigurationDialog::accept ( )

Definition at line 55 of file qxrddetectorconfigurationdialog.cpp.

References m_Proxy.

56 {
57  if (m_Proxy) {
58  m_Proxy->pullPropertiesFromDialog(this);
59  }
60 
61  QDialog::accept();
62 }
void QxrdDetectorConfigurationDialog::appendProperty ( int  type,
QString  name,
QString  description,
QVariant  value 
)

Definition at line 64 of file qxrddetectorconfigurationdialog.cpp.

References QxrdDetectorThread::binningModeNamesPE(), QxrdDetectorProxy::BooleanProperty, browseToDirectory(), browseToFilename(), QxrdDetectorProxy::DetectorNumberProperty, QxrdDetectorThread::detectorSubTypeNamesPE(), QxrdDetectorThread::detectorTypeName(), QxrdDetectorProxy::DetectorTypeProperty, QxrdDetectorProxy::DirectoryProperty, QxrdDetectorProxy::DoubleProperty, QxrdDetectorProxy::ExtensionProperty, QxrdDetectorProxy::FilenameProperty, QxrdDetectorProxy::FixedIntegerProperty, QxrdDetectorThread::gainModeNamesPE(), QxrdDetectorProxy::IntegerProperty, m_CurrentRow, m_Widgets, QxrdDetectorProxy::PEBinningProperty, QxrdDetectorProxy::PEDetNumProperty, QxrdDetectorProxy::PEGainProperty, QxrdDetectorProxy::PESubTypeProperty, QxrdDetectorProxy::PilatusModeProperty, and QxrdDetectorProxy::StringProperty.

Referenced by QxrdDetectorProxy::pushPropertiesToDialog().

68 {
69  QLabel *propertyLabel = new QLabel();
70 
71  propertyLabel -> setText(description);
72 
73  QWidget *propertyEditor = NULL;
74  QWidget *button = NULL;
75 
77  propertyEditor = new QLabel(value.toString());
78  } else if (type == QxrdDetectorProxy::DetectorTypeProperty) {
79  propertyEditor = new QLabel(QxrdDetectorThread::detectorTypeName(value.toInt()));
80 
81  } else if (type == QxrdDetectorProxy::StringProperty) {
82  propertyEditor = new QLineEdit(value.toString());
83 
84  } else if (type == QxrdDetectorProxy::BooleanProperty) {
85  QCheckBox *cb = new QCheckBox();
86  cb->setCheckable(true);
87  cb->setChecked(value.toBool());
88 
89  propertyEditor = cb;
90 
91  } else if (type == QxrdDetectorProxy::FixedIntegerProperty) {
92  propertyEditor = new QLabel(value.toString());
93 
94  } else if (type == QxrdDetectorProxy::DirectoryProperty) {
95  QLineEdit *le = new QLineEdit(value.toString());
96  QPushButton *pb = new QPushButton("Browse");
97 
98  QSignalMapper *mapper = new QSignalMapper(pb);
99 
100  connect(pb, &QPushButton::clicked, mapper, (void (QSignalMapper::*)()) &QSignalMapper::map);
101  mapper->setMapping(pb, m_CurrentRow);
102  connect(mapper, (void (QSignalMapper::*)(int)) &QSignalMapper::mapped,
104 
105  propertyEditor = le;
106  button = pb;
107 
108  } else if (type == QxrdDetectorProxy::FilenameProperty) {
109  QLineEdit *le = new QLineEdit(value.toString());
110  QPushButton *pb = new QPushButton("Browse");
111 
112  QSignalMapper *mapper = new QSignalMapper(pb);
113 
114  connect(pb, &QPushButton::clicked, mapper, (void (QSignalMapper::*)()) &QSignalMapper::map);
115  mapper->setMapping(pb, m_CurrentRow);
116  connect(mapper, (void (QSignalMapper::*)(int)) &QSignalMapper::mapped,
118 
119  propertyEditor = le;
120  button = pb;
121 
122  } else if (type == QxrdDetectorProxy::ExtensionProperty) {
123  QComboBox *cb = new QComboBox();
124  cb -> addItem("tiff");
125  cb -> addItem("cbf");
126  cb -> setCurrentText(value.toString());
127 
128  propertyEditor = cb;
129 
130  } else if (type == QxrdDetectorProxy::PEDetNumProperty) {
131  QSpinBox *sb = new QSpinBox();
132  sb -> setMinimum(-1);
133  sb -> setMaximum(64);
134  sb -> setValue(value.toInt());
135 
136  propertyEditor = sb;
137 
138  } else if (type == QxrdDetectorProxy::PESubTypeProperty) {
139  QComboBox *cb = new QComboBox();
141  cb -> addItems(sl);
142  cb -> setCurrentIndex(value.toInt());
143 
144  propertyEditor = cb;
145 
146  } else if (type == QxrdDetectorProxy::PEGainProperty) {
147  QComboBox *cb = new QComboBox();
148  QStringList sl = QxrdDetectorThread::gainModeNamesPE();
149  cb -> addItems(sl);
150  cb -> setCurrentIndex(value.toInt());
151 
152  propertyEditor = cb;
153 
154  } else if (type == QxrdDetectorProxy::PEBinningProperty) {
155  QComboBox *cb = new QComboBox();
156  QStringList sl = QxrdDetectorThread::binningModeNamesPE();
157  cb -> addItems(sl);
158  cb -> setCurrentIndex(value.toInt());
159 
160  propertyEditor = cb;
161 
162  } else if (type == QxrdDetectorProxy::IntegerProperty) {
163  QSpinBox *sb = new QSpinBox();
164  sb -> setMinimum(-100000);
165  sb -> setMaximum(+100000);
166  sb -> setValue(value.toInt());
167 
168  propertyEditor = sb;
169 
170  } else if (type == QxrdDetectorProxy::DoubleProperty) {
171  QDoubleSpinBox *sb = new QDoubleSpinBox();
172  sb -> setMinimum(-100000);
173  sb -> setMaximum(+100000);
174  sb -> setValue(value.toDouble());
175 
176  propertyEditor = sb;
177 
178  } else if (type == QxrdDetectorProxy::PilatusModeProperty) {
179  QComboBox *cb = new QComboBox();
180  cb -> addItem("Internal Triggering");
181  cb -> addItem("External Trigger");
182  cb -> addItem("External Enable");
183  cb -> setCurrentIndex(value.toInt());
184 
185  propertyEditor = cb;
186 
187  } else {
188  printf("Unknown property type\n");
189  }
190 
191  if (propertyEditor) {
192  m_DetectorConfigGrid->addWidget(propertyLabel, m_CurrentRow, 0);
193 
194  if (button) {
195  m_DetectorConfigGrid->addWidget(propertyEditor, m_CurrentRow, 1);
196  m_DetectorConfigGrid->addWidget(button, m_CurrentRow, 2);
197  } else {
198  m_DetectorConfigGrid->addWidget(propertyEditor, m_CurrentRow, 1, 1, 2);
199  }
200 
201  m_CurrentRow++;
202  }
203 
204  m_Widgets.append(propertyEditor);
205 }
static QStringList binningModeNamesPE()
static QStringList gainModeNamesPE()
static QStringList detectorSubTypeNamesPE()
static QString detectorTypeName(int detectorType)

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdDetectorConfigurationDialog::browseToDirectory ( int  i)
privateslot

Definition at line 248 of file qxrddetectorconfigurationdialog.cpp.

References m_Widgets.

Referenced by appendProperty().

249 {
250  QLineEdit *le = qobject_cast<QLineEdit*>(m_Widgets.value(i));
251 
252  if (le) {
253  QString newPath = QFileDialog::getExistingDirectory(this, "Browse to Directory", le->text());
254 
255  if (newPath.length() > 0) {
256  le->setText(newPath);
257  }
258  }
259 }

Here is the caller graph for this function:

void QxrdDetectorConfigurationDialog::browseToFilename ( int  i)
privateslot

Definition at line 261 of file qxrddetectorconfigurationdialog.cpp.

References m_Widgets.

Referenced by appendProperty().

262 {
263  QLineEdit *le = qobject_cast<QLineEdit*>(m_Widgets.value(i));
264 
265  if (le) {
266  QString newPath = QFileDialog::getOpenFileName(this, "Browse to File", le->text());
267 
268  if (newPath.length() > 0) {
269  le->setText(newPath);
270  }
271  }
272 }

Here is the caller graph for this function:

void QxrdDetectorConfigurationDialog::changeEvent ( QEvent *  e)
protected

Definition at line 43 of file qxrddetectorconfigurationdialog.cpp.

44 {
45  QDialog::changeEvent(e);
46  switch (e->type()) {
47  case QEvent::LanguageChange:
48  retranslateUi(this);
49  break;
50  default:
51  break;
52  }
53 }
QVariant QxrdDetectorConfigurationDialog::propertyValue ( int  propType,
int  i 
)

Definition at line 207 of file qxrddetectorconfigurationdialog.cpp.

References QxrdDetectorProxy::ExtensionProperty, and m_Widgets.

Referenced by QxrdDetectorProxy::pullPropertiesFromDialog().

208 {
209  QObject *w = m_Widgets.value(i);
210 
211  QLineEdit *le = qobject_cast<QLineEdit*>(w);
212 
213  if (le) {
214  return le->text();
215  }
216 
217  QCheckBox *cb = qobject_cast<QCheckBox*>(w);
218 
219  if (cb) {
220  return cb->isChecked();
221  }
222 
223  QSpinBox *sb = qobject_cast<QSpinBox*>(w);
224 
225  if (sb) {
226  return sb->value();
227  }
228 
229  QDoubleSpinBox *ds = qobject_cast<QDoubleSpinBox*>(w);
230 
231  if (ds) {
232  return ds->value();
233  }
234 
235  QComboBox *bx = qobject_cast<QComboBox*>(w);
236 
237  if (bx) {
238  if (propType == QxrdDetectorProxy::ExtensionProperty) {
239  return bx->currentText();
240  } else {
241  return bx->currentIndex();
242  }
243  }
244 
245  return QVariant();
246 }

Here is the caller graph for this function:

Member Data Documentation

int QxrdDetectorConfigurationDialog::m_CurrentRow
private

Definition at line 34 of file qxrddetectorconfigurationdialog.h.

Referenced by appendProperty().

QxrdDetectorProxyPtr QxrdDetectorConfigurationDialog::m_Proxy
private

Definition at line 33 of file qxrddetectorconfigurationdialog.h.

Referenced by accept(), and QxrdDetectorConfigurationDialog().

QVector<QWidget*> QxrdDetectorConfigurationDialog::m_Widgets
private

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