msr2data global option handling completed.

This commit is contained in:
nemu 2010-06-28 06:31:35 +00:00
parent 20bb0e05a6
commit acc389a96d
4 changed files with 94 additions and 82 deletions

View File

@ -276,21 +276,6 @@ void PMsr2DataDialog::fitOnlyChanged(int buttonState)
} }
} }
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT: called when the 'Global' QCheckBox under 'Options' is activated.
* Sets at the same time the fit-only flag to false.
*
* \param buttonState state of the button.
*/
void PMsr2DataDialog::globalChanged(int buttonState)
{
if (buttonState == Qt::Checked) {
fFitOnly_checkBox->setChecked(false);
fOpenFilesAfterFitting_checkBox->setChecked(false);
}
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
/** /**
* <p>Generates a help content window showing the description for msr2data. * <p>Generates a help content window showing the description for msr2data.

View File

@ -60,7 +60,6 @@ class PMsr2DataDialog : public QDialog, private Ui::PMsr2DataDialog
void templateRunEntered(const QString&); void templateRunEntered(const QString&);
void createMsrFileOnlyChanged(int); void createMsrFileOnlyChanged(int);
void fitOnlyChanged(int); void fitOnlyChanged(int);
void globalChanged(int);
void helpContent(); void helpContent();
private: private:

View File

@ -1904,48 +1904,28 @@ void PTextEdit::musrMsr2Data()
QFile *file; QFile *file;
QTextStream *stream; QTextStream *stream;
switch(dlg->getRunTag()) { if (!fMsr2DataParam->global) { // standard fits
case 0: // first run / last run list
if (fMsr2DataParam->firstRun != -1) {
for (int i=fMsr2DataParam->firstRun; i<=fMsr2DataParam->lastRun; i++) {
if (fMsr2DataParam->msrFileExtension.isEmpty())
fln = QString("%1").arg(i) + ".msr";
else
fln = QString("%1").arg(i) + fMsr2DataParam->msrFileExtension + ".msr";
load(fln); switch(dlg->getRunTag()) {
case 0: // first run / last run list
if (fMsr2DataParam->firstRun != -1) {
for (int i=fMsr2DataParam->firstRun; i<=fMsr2DataParam->lastRun; i++) {
if (fMsr2DataParam->msrFileExtension.isEmpty())
fln = QString("%1").arg(i) + ".msr";
else
fln = QString("%1").arg(i) + fMsr2DataParam->msrFileExtension + ".msr";
load(fln);
}
} }
} break;
break; case 1: // run list
case 1: // run list end = 0;
end = 0; while (!runList.section(' ', end, end).isEmpty()) {
while (!runList.section(' ', end, end).isEmpty()) { end++;
end++; }
} for (int i=0; i<end; i++) {
for (int i=0; i<end; i++) { fln = runList.section(' ', i, i);
fln = runList.section(' ', i, i);
if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr";
else
fln += fMsr2DataParam->msrFileExtension + ".msr";
load(fln);
}
break;
case 2: // run list file
file = new QFile(fMsr2DataParam->runListFileName);
if (!file->open(QIODevice::ReadOnly)) {
str = QString("Couldn't open run list file %1, sorry.").arg(fMsr2DataParam->runListFileName);
QMessageBox::critical(this, "**ERROR**", str.toLatin1(), QMessageBox::Ok, QMessageBox::NoButton);
return;
}
stream = new QTextStream(file);
while ( !stream->atEnd() ) {
str = stream->readLine(); // line of text excluding '\n'
str.trimmed();
if (!str.isEmpty() && !str.startsWith("#")) {
fln = str.section(' ', 0, 0);
if (fMsr2DataParam->msrFileExtension.isEmpty()) if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr"; fln += ".msr";
else else
@ -1953,16 +1933,80 @@ void PTextEdit::musrMsr2Data()
load(fln); load(fln);
} }
} break;
case 2: // run list file
file = new QFile(fMsr2DataParam->runListFileName);
if (!file->open(QIODevice::ReadOnly)) {
str = QString("Couldn't open run list file %1, sorry.").arg(fMsr2DataParam->runListFileName);
QMessageBox::critical(this, "**ERROR**", str.toLatin1(), QMessageBox::Ok, QMessageBox::NoButton);
return;
}
file->close(); stream = new QTextStream(file);
while ( !stream->atEnd() ) {
str = stream->readLine(); // line of text excluding '\n'
str.trimmed();
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) {
fln = str.section(' ', 0, 0);
if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr";
else
fln += fMsr2DataParam->msrFileExtension + ".msr";
// clean up load(fln);
delete stream; }
delete file; }
break;
default: file->close();
break;
// clean up
delete stream;
delete file;
break;
default:
break;
}
} else { // global tag set
// get the first run number needed to build the global fit file name
fln = QString("");
switch(dlg->getRunTag()) {
case 0: // first/last run
fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break;
case 1: // run list
fln = runList.section(" ", 0, 0) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break;
case 2: // run list file name
file = new QFile(fMsr2DataParam->runListFileName);
if (!file->open(QIODevice::ReadOnly)) {
str = QString("Couldn't open run list file %1, sorry.").arg(fMsr2DataParam->runListFileName);
QMessageBox::critical(this, "**ERROR**", str.toLatin1(), QMessageBox::Ok, QMessageBox::NoButton);
return;
}
stream = new QTextStream(file);
while ( !stream->atEnd() ) {
str = stream->readLine(); // line of text excluding '\n'
str.trimmed();
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) {
fln = str.section(' ', 0, 0);
break;
}
}
file->close();
fln += QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
// clean up
delete stream;
delete file;
break;
default:
break;
}
load(fln);
} }
} }
} }

View File

@ -369,7 +369,7 @@
<property name="title"> <property name="title">
<string>Options</string> <string>Options</string>
</property> </property>
<widget class="QWidget" name=""> <widget class="QWidget" name="layoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -700,7 +700,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>547</x> <x>547</x>
<y>442</y> <y>440</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>150</x> <x>150</x>
@ -708,22 +708,6 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>fGlobal_checkBox</sender>
<signal>stateChanged(int)</signal>
<receiver>PMsr2DataDialog</receiver>
<slot>globalChanged(int)</slot>
<hints>
<hint type="sourcelabel">
<x>398</x>
<y>479</y>
</hint>
<hint type="destinationlabel">
<x>372</x>
<y>520</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>helpContent()</slot> <slot>helpContent()</slot>