QXRD  0.11.16
qxrdacquisitiondialog.cpp
Go to the documentation of this file.
2 #include "qxrdwindow.h"
3 #include "qxrdacquisition.h"
4 #include "qxrdapplication.h"
5 #include "qxrdexperiment.h"
6 #include <QFileDialog>
7 #include <QDir>
8 
10  QxrdWindowWPtr win,
13  QWidget *parent) :
14  QDockWidget(parent),
15  m_Experiment(doc),
16  m_Window(win),
17  m_Acquisition(acq),
18  m_DataProcessor(proc)
19 {
20  setupUi(this);
21 
23 
24  if (acqp) {
25  QxrdAcquisition *acq = acqp.data();
26 
27  connect(m_ActionAcquire, &QAction::triggered, this, &QxrdAcquisitionDialog::doAcquire);
28  connect(m_ActionCancel, &QAction::triggered, this, &QxrdAcquisitionDialog::doCancel);
29  connect(m_ActionAcquireDark, &QAction::triggered, this, &QxrdAcquisitionDialog::doAcquireDark);
30  connect(m_ActionTrigger, &QAction::triggered, acq, &QxrdAcquisition::trigger);
31 
32  connect(m_BrowseLogFileButton, &QAbstractButton::clicked, this, &QxrdAcquisitionDialog::browseLogFile);
33  connect(m_BrowseScanFileButton, &QAbstractButton::clicked, this, &QxrdAcquisitionDialog::browseScanFile);
34 
35  connect(m_AcquireButton, &QAbstractButton::clicked, m_ActionAcquire, &QAction::triggered);
36  connect(m_CancelButton, &QAbstractButton::clicked, m_ActionCancel, &QAction::triggered);
37  connect(m_TriggerButton, &QAbstractButton::clicked, m_ActionTrigger, &QAction::triggered);
38  connect(m_DarkAcquireButton, &QAbstractButton::clicked, m_ActionAcquireDark, &QAction::triggered);
39 
40  connect(m_ClearDroppedButton, &QAbstractButton::clicked, acq, &QxrdAcquisition::clearDropped);
41 
44 
45  acq -> prop_ExposureTime() -> linkTo(this -> m_ExposureTime);
46  acq -> prop_SummedExposures() -> linkTo(this -> m_SummedExposures);
47  acq -> prop_SkippedExposures() -> linkTo(this -> m_SkippedExposures);
48  acq -> prop_SkippedExposuresAtStart() -> linkTo(this -> m_SkippedExposuresAtStart);
49  acq -> prop_DarkSummedExposures() -> linkTo(this -> m_DarkSummedExposures);
50  acq -> prop_FilePattern() -> linkTo(this -> m_FilePattern);
51  acq -> prop_FileIndex() -> linkTo(this -> m_FileIndex);
52  acq -> prop_PhasesInGroup() -> linkTo(this -> m_PhasesInGroup);
53  acq -> prop_PreTriggerFiles() -> linkTo(this -> m_PreTriggerFiles);
54  acq -> prop_PostTriggerFiles() -> linkTo(this -> m_PostTriggerFiles);
55  acq -> prop_DroppedFrames() -> linkTo(this -> m_DroppedFrames);
56 
57  acq -> prop_UserComment1() -> linkTo(this -> m_UserComment1);
58  acq -> prop_UserComment2() -> linkTo(this -> m_UserComment2);
59  acq -> prop_UserComment3() -> linkTo(this -> m_UserComment3);
60  acq -> prop_UserComment4() -> linkTo(this -> m_UserComment4);
61 
62  acq -> prop_LiveViewAtIdle() -> linkTo(this -> m_LiveViewAtIdle);
63  acq -> prop_AcquisitionCancelsLiveView() -> linkTo(this -> m_AcquisitionCancelsLiveView);
64  acq -> prop_RetryDropped() -> linkTo(this -> m_RetryDropped);
65  } else {
66  printf("acq == NULL in QxrdAcquisitionDialog::QxrdAcquisitionDialog");
67  }
68 
70 
71  if (expp) {
72  QxrdExperiment *exp = expp.data();
73 
74  exp -> prop_ExperimentDirectory() -> linkTo(this -> m_ExperimentDirectory);
75  exp -> prop_LogFileName() -> linkTo(this -> m_LogFileName);
76  exp -> prop_DataDirectory() -> linkTo(this -> m_DataDirectory);
77  exp -> prop_ScanFileName() -> linkTo(this -> m_ScanFileName);
78 // exp -> prop_DetectorTypeName() -> linkTo(this -> m_DetectorTypeNameLabel);
79 // exp -> prop_DetectorNumber() -> linkTo(this -> m_DetectorNumber);
80 
81  connect(m_LogFileName, &QLineEdit::editingFinished, exp, &QxrdExperiment::openNewLogFile);
82  }
83 
85 
86  if (procp) {
87  procp -> prop_Average() -> linkTo(this -> m_AverageDisplay);
88  procp -> prop_CorrectionQueueLength() -> linkTo(this -> m_CorrectionBacklog);
89  procp -> prop_IntegrationQueueLength() -> linkTo(this -> m_IntegrationBacklog);
90  procp -> prop_SaverQueueLength() -> linkTo(this -> m_SaverBacklog);
91  }
92 
94 
95  if (wp) {
96  connect(m_DetectorOptionsButton, &QAbstractButton::clicked, wp.data(), &QxrdWindow::doEditDetectorPreferences);
97  connect(m_AcquireOptionsButton, &QAbstractButton::clicked, wp.data(), &QxrdWindow::doEditPreferences);
98  }
99 }
100 
102 {
103 }
104 
106 {
107  menu->addSeparator();
108  menu->addAction(m_ActionAcquire);
109  menu->addAction(m_ActionTrigger);
110  menu->addAction(m_ActionAcquireDark);
111  menu->addAction(m_ActionCancel);
112 }
113 
115 {
117 
118  if (acqp) {
119  acqp -> setupExposureMenu(this -> m_ExposureTime);
120  }
121 }
122 
124 {
125  QString dir = QFileDialog::getExistingDirectory(this, "Output Directory", m_ExperimentDirectory->text(), QFileDialog::ShowDirsOnly);
126 
127  if (dir != "") {
128  m_ExperimentDirectory->setText(dir);
129  }
130 }
131 
133 {
134  QDir pwd(m_ExperimentDirectory->text());
135  QFileInfo initial(pwd, m_LogFileName->text());
136 
137  QString file = QFileDialog::getSaveFileName(this, "Log File", initial.absoluteFilePath());
138 
139  if (file != "") {
140  m_LogFileName->setText(pwd.relativeFilePath(file));
141  }
142 }
143 
145 {
146  QDir pwd(m_ExperimentDirectory->text());
147  QFileInfo initial(pwd, m_ScanFileName->text());
148 
149  QString file = QFileDialog::getSaveFileName(this, "Scan File", initial.absoluteFilePath());
150 
151  if (file != "") {
152  m_ScanFileName->setText(pwd.relativeFilePath(file));
153  }
154 }
155 
157 {
158  QDockWidget::changeEvent(e);
159  switch (e->type()) {
160  case QEvent::LanguageChange:
161  retranslateUi(this);
162  break;
163  default:
164  break;
165  }
166 }
167 
169 {
171 
172  if (acqp) {
173  acqp -> acquire();
174  }
175 }
176 
178 {
180 
181  if (acqp) {
182  acqp -> acquireDark();
183  }
184 }
185 
187 {
189 
190  if (acqp) {
191  acqp -> cancel();
192  }
193 }
194 
196 {
197  m_AcquireButton -> setEnabled(true);
198  m_ActionAcquire -> setEnabled(true);
199 
200  m_TriggerButton -> setEnabled(false);
201  m_ActionTrigger -> setEnabled(false);
202 
203  m_CancelButton -> setEnabled(false);
204  m_ActionCancel -> setEnabled(false);
205 
206  m_DarkAcquireButton -> setEnabled(true);
207  m_ActionAcquireDark -> setEnabled(true);
208 }
209 
211 {
213 
214  if (acq) {
215  m_AcquireButton -> setEnabled(false);
216  m_ActionAcquire -> setEnabled(false);
217 
218  if (acq -> get_PreTriggerFiles() > 0) {
219  m_TriggerButton -> setEnabled(true);
220  m_ActionTrigger -> setEnabled(true);
221  } else {
222  m_TriggerButton -> setEnabled(false);
223  m_ActionTrigger -> setEnabled(false);
224  }
225 
226  m_CancelButton -> setEnabled(true);
227  m_ActionCancel -> setEnabled(true);
228 
229  m_DarkAcquireButton -> setEnabled(false);
230  m_ActionAcquireDark -> setEnabled(false);
231  }
232 }
233 
235 {
236  m_AcquireButton -> setEnabled(true);
237  m_ActionAcquire -> setEnabled(true);
238 
239  m_TriggerButton -> setEnabled(false);
240  m_ActionTrigger -> setEnabled(false);
241 
242  m_CancelButton -> setEnabled(false);
243  m_ActionCancel -> setEnabled(false);
244 
245  m_DarkAcquireButton -> setEnabled(true);
246  m_ActionAcquireDark -> setEnabled(true);
247 }
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
QxrdDataProcessorWPtr m_DataProcessor
QSharedPointer< QxrdWindow > QxrdWindowPtr
Definition: qxrdwindow-ptr.h:6
QWeakPointer< QxrdDataProcessor > QxrdDataProcessorWPtr
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
void openNewLogFile() const
QxrdAcquisitionDialog(QxrdExperimentWPtr doc, QxrdWindowWPtr win, QxrdAcquisitionWPtr acq, QxrdDataProcessorWPtr proc, QWidget *parent)
QSharedPointer< QxrdDataProcessor > QxrdDataProcessorPtr
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
void doEditPreferences()
QxrdAcquisitionWPtr m_Acquisition
QWeakPointer< QxrdWindow > QxrdWindowWPtr
Definition: qxrdwindow-ptr.h:9
void setupAcquireMenu(QMenu *menu)
QxrdExperimentWPtr m_Experiment
QWeakPointer< QxrdAcquisition > QxrdAcquisitionWPtr
void doEditDetectorPreferences()