proper class encapsulation for PGetAsymmetryRunBlockDialog, and adding a skeleton for PGetSingleHistoRunBlockDialog

This commit is contained in:
nemu
2009-03-14 18:03:20 +00:00
parent e427a55283
commit aa99881488
7 changed files with 633 additions and 220 deletions

View File

@@ -161,103 +161,90 @@ void PSubTextEdit::insertAsymRunBlock()
PGetAsymmetryRunBlockDialog *dlg = new PGetAsymmetryRunBlockDialog();
if (dlg->exec() == QDialog::Accepted) {
QString str, workStr;
bool valid = true, present = true;
// check if there is already a run block present, necessary because of the '####' line
// STILL MISSING
// add run line
str += "RUN " + dlg->fRunFileName_lineEdit->text() + " ";
str += dlg->fBeamline_lineEdit->text().upper() + " ";
str += dlg->fInstitute_comboBox->currentText() + " ";
str += dlg->fFileFormat_comboBox->currentText() + " (name beamline institute data-file-format)\n";
str += dlg->GetRunHeaderInfo();
// add fittype
str += "fittype 2 (asymmetry fit)\n";
// add alpha if present
workStr = dlg->fAlpha_lineEdit->text();
if (!workStr.isEmpty()) {
str += "alpha " + workStr + "\n";
workStr = dlg->GetAlphaParameter(present);
if (present) {
str += workStr;
}
// add beta if present
workStr = dlg->fBeta_lineEdit->text();
if (!workStr.isEmpty()) {
str += "beta " + workStr + "\n";
// add alpha if present
workStr = dlg->GetBetaParameter(present);
if (present) {
str += workStr;
}
// add map
str += "map " + dlg->fMap_lineEdit->text() + "\n";
workStr = dlg->GetMap(valid);
if (valid) {
str += workStr;
} else {
QMessageBox::critical(this, "**ERROR**",
"Given map not valid, will add a default map line",
QMessageBox::Ok, QMessageBox::NoButton);
str += "map 0 0 0 0 0 0 0 0 0 0\n";
}
// add forward
str += "forward " + dlg->fForward_lineEdit->text() + "\n";
str += dlg->GetForward();
// add backward
str += "backward " + dlg->fBackward_lineEdit->text() + "\n";
str += dlg->GetBackward();
// check that either background or background.fix is given
if (dlg->fBackgroundForwardStart_lineEdit->text().isEmpty() && dlg->fBackgroundForwardEnd_lineEdit->text().isEmpty() &&
dlg->fBackgroundBackwardStart_lineEdit->text().isEmpty() && dlg->fBackgroundBackwardEnd_lineEdit->text().isEmpty() &&
dlg->fBackgroundForwardFix_lineEdit->text().isEmpty() && dlg->fBackgroundBackwardFix_lineEdit->text().isEmpty()) {
// add background or backgr.fix
workStr = dlg->GetBackground(valid);
str += workStr;
if (!valid) {
QMessageBox::critical(this, "**ERROR**",
"Either Background or Background.Fix is needed!\nWill set Background to 0..10, please correct!",
QMessageBox::Ok, QMessageBox::NoButton);
str += "background 0 10 0 10\n";
} else {
if (!dlg->fBackgroundForwardStart_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ...
str += "background ";
str += dlg->fBackgroundForwardStart_lineEdit->text() + " ";
str += dlg->fBackgroundForwardEnd_lineEdit->text() + " ";
str += dlg->fBackgroundBackwardStart_lineEdit->text() + " ";
str += dlg->fBackgroundBackwardEnd_lineEdit->text() + "\n";
}
if (!dlg->fBackgroundForwardFix_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ...
str += "backgr.fix ";
str += dlg->fBackgroundForwardFix_lineEdit->text() + " ";
str += dlg->fBackgroundBackwardFix_lineEdit->text() + "\n";
}
}
// add data
if (dlg->fDataForwardStart_lineEdit->text().isEmpty() || dlg->fDataForwardEnd_lineEdit->text().isEmpty() ||
dlg->fDataBackwardStart_lineEdit->text().isEmpty() || dlg->fDataBackwardEnd_lineEdit->text().isEmpty()) {
workStr = dlg->GetData(valid);
if (valid) {
str += workStr;
} else {
QMessageBox::critical(this, "**ERROR**",
"Not all Data entries are present.Fix is needed!\nWill not set anything!",
QMessageBox::Ok, QMessageBox::NoButton);
} else {
str += "data ";
str += dlg->fDataForwardStart_lineEdit->text() + " ";
str += dlg->fDataForwardEnd_lineEdit->text() + " ";
str += dlg->fDataBackwardStart_lineEdit->text() + " ";
str += dlg->fDataBackwardEnd_lineEdit->text() + "\n";
}
// add t0 if present
if (!dlg->fT0Forward_lineEdit->text().isEmpty() && !dlg->fT0Forward_lineEdit->text().isEmpty()) {
str += "t0 ";
str += dlg->fT0Forward_lineEdit->text() + " ";
str += dlg->fT0Backward_lineEdit->text() + "\n";
workStr = dlg->GetT0(present);
if (present) {
str += workStr;
} else {
QMessageBox::warning(this, "**ERROR**",
"T0's not given, assume that they are present in the data file!",
QMessageBox::Ok, QMessageBox::NoButton);
}
// add fit range
if (dlg->fFitRangeStart_lineEdit->text().isEmpty() || dlg->fFitRangeEnd_lineEdit->text().isEmpty()) {
workStr = dlg->GetFitRange(valid);
str += workStr;
if (!valid) {
QMessageBox::critical(this, "**ERROR**",
"No valid fit range is given.Fix is needed!\nWill add a default one!",
QMessageBox::Ok, QMessageBox::NoButton);
str += "fit 0.0 10.0\n";
} else {
str += "fit ";
str += dlg->fFitRangeStart_lineEdit->text() + " ";
str += dlg->fFitRangeEnd_lineEdit->text() + "\n";
}
// add packing
if (dlg->fPacking_lineEdit->text().isEmpty()) {
workStr = dlg->GetPacking(present);
str += workStr;
if (!present) {
QMessageBox::critical(this, "**ERROR**",
"No valid packing/binning is given.Fix is needed!\nWill add a default one!",
QMessageBox::Ok, QMessageBox::NoButton);
str += "packing 1\n";
} else {
str += "packing " + dlg->fPacking_lineEdit->text() + "\n\n";
}
// insert Asymmetry Run Block at the current cursor position