New development branch.

This commit is contained in:
salman 2009-09-24 16:21:30 +00:00
parent 41267b9fef
commit b3c85ef61a
2 changed files with 2158 additions and 2077 deletions

File diff suppressed because it is too large Load Diff

View File

@ -90,8 +90,13 @@ void Form1::filePrint()
void Form1::fileExit()
{
my $Ans = Qt::MessageBox::question( this, "Quit?","Are you sure you want to quit?","&Yes","&No","",0,1);
if ($Ans==0) {
# Then quit
Qt::Application::exit( 0 );
}
# Otherwize go back
}
void Form1::parametersExport()
{
@ -207,31 +212,56 @@ void Form1::helpAbout()
void MuSRFitform::CreateAllInput()
{
# TODO: Need to deliver shared parameters also
# TODO: Need to automatically generage years list depending on beamline
my %All=();
# From RUNS Tab
$All{"TITLE"}= TITLE->text;
$All{"FILENAME"}= FILENAME->text;
# Run data file
$All{"RunNumbers"} = RunNumbers->text;
$All{"RunFiles"} = RunFiles->text;
$All{"BeamLine"} = BeamLine->currentText;
$All{"RUNSType"} = ManualFile->isOn();
$All{"optionsFourier"} = optionsFourier->isOn();
$All{"optionsT0"} = optionsT0->isOn();
$All{"YEAR"} =YEAR->currentText;
# Time range and BINS
$All{"Tis"} = Tis->text;
$All{"Tfs"} = Tfs->text;
$All{"BINS"} = BINS->text;
$All{"FitAsyType"} = FitAsyType->currentText;
$All{"LRBF"} = LRBF->text;
my @Hists = split(/,/, $All{"LRBF"} );
# Lifetime corrections in enabled/visible only for SingleHis fits
if ( $All{"FitAsyType"} eq "Asymmetry" ) {
ltc->setHidden(1);
}
elsif ( $All{"FitAsyType"} eq "SingleHist" ) {
ltc->setHidden(0);
}
# From Fitting Tab
# Plot range
$All{"Xi"}=Xi->text;
$All{"Xf"}=Xf->text;
$All{"Yi"}=Yi->text;
$All{"Yf"}=Yf->text;
# Life time correction
if (ltc->isChecked()) {
$All{"ltc"}="y";
} else {
$All{"ltc"}="n";
}
# Minuit commands
if ( $All{"go"} eq "" ) {
$All{"go"}="PLOT";
}
# Get minimization process
$All{"Minimization"} = Minimization->currentText();
$All{"go"}=$All{"Minimization"};
# Get Error calculation process
$All{"ErrorCalc"} = ErrorCalc->currentText();
$All{"go"}=$All{"ErrorCalc"};
RunSelectionToggle();
my @RUNS = ();
@ -242,12 +272,17 @@ void MuSRFitform::CreateAllInput()
@RUNS = split( /,/, $All{"RunNumbers"} );
}
my @Hists = split(/,/, $All{"LRBF"} );
# From MSR File Tab
$All{"TITLE"}= TITLE->text;
$All{"FILENAME"}= FILENAME->text;
# From Fourier Tab
$All{"FUNITS"}= FUnits->currentText;
$All{"FAPODIZATION"}= FApodization->currentText;
$All{"FPLOT"}= FPlot->currentText;
# Fourier range
$All{"FrqMin"}=FrqMin->text;
$All{"FrqMax"}=FrqMax->text;
# Get values of t0 and Bg/Data bins if given
my $NHist = 1;
@ -379,17 +414,7 @@ void MuSRFitform::CreateAllInput()
$All{"FILENAME"}="TMP";
}
if ( $All{"go"} eq "" ) {
$All{"go"}="PLOT";
}
# Get minimization process
$All{"Minimization"} = Minimization->currentText();
$All{"go"}=$All{"Minimization"};
# Get Error calculation process
$All{"ErrorCalc"} = ErrorCalc->currentText();
$All{"go"}=$All{"ErrorCalc"};
# Return Hash with all important values
return %All;
@ -399,7 +424,27 @@ void MuSRFitform::CallMSRCreate()
{
use MSR;
my %All=CreateAllInput();
# Check if the option for checking for existing files is selected
my $FileExistCheck= FileExistCheck->isOn();
my $FILENAME=$All{"FILENAME"}.".msr";
my $Answer=0;
if ($All{"RunNumbers"} ne "" || $All{"RunFiles"} ne "") {
if ( $FileExistCheck==1 ) {
if (-e $FILENAME) {
# Warning: MSR file exists
# my $Warning = "Warning: MSR file $FILENAME Already exists!\nIf you continue it will overwriten.";
my $Warning = "Warning: MSR file $FILENAME Already exists!\nDo you want to overwrite it?";
# my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
# $Answer =1,0 for yes and no
$Answer= Qt::MessageBox::warning( this, "Warning",$Warning, "&No", "&Yes", undef, 1,1);
}
} else {
# Just overwrite file
$Answer=1;
}
if ($Answer) {
if ( $All{"FitAsyType"} eq "Asymmetry" ) {
my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateMSR(\%All);
}
@ -409,6 +454,8 @@ void MuSRFitform::CallMSRCreate()
UpdateMSRFileInitTable();
}
}
return $Answer;
}
void MuSRFitform::UpdateMSRFileInitTable()
{
@ -603,24 +650,8 @@ void MuSRFitform::InitializeTab()
void MuSRFitform::TabChanged()
{
# TODO: First check if there are some runs given, otherwise disbale
# TODO: Check if the MSR file exists and decide whether to use it or not
my %All=CreateAllInput();
my $SlectedTab = musrfit_tabs->currentPageIndex;
# Check if the option for checking for existing files is selected
my $FileExistCheck= FileExistCheck->isOn();
my $FILENAME=$All{"FILENAME"}.".msr";
if ($All{"RunNumbers"} ne "" && $SlectedTab==4 && $FileExistCheck==1) {
if (-e $FILENAME) {
# Warning: MSR file exists
my $Warning = "Warning: MSR file $FILENAME Already exists!\nIf you continue it will overwriten.";
my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
# my $Answer= Qt::MessageBox::warning( this, "Warning",$Warning, "&No", "&Yes", undef, 1,1);
# $Answer =1,0 for yes and no
# print "Answer=$Answer\n";
}
}
# First make sure we have sharing initialized
ActivateShComp();
InitializeTab();
@ -634,14 +665,14 @@ void MuSRFitform::GoFit()
{
my %All=CreateAllInput();
musrfit_tabs->setCurrentPage(1);
CallMSRCreate();
my $Answer=CallMSRCreate();
if ($Answer) {
my $FILENAME=$All{"FILENAME"}.".msr";
if (-e $FILENAME) {
my $cmd="musrfit -t $FILENAME";
my $pid = open(FTO,"$cmd 2>&1 |");
while (<FTO>) {
FitTextOutput->append("$_");
# print "line= ".$_;
}
close(FTO);
$cmd="musrview $FILENAME &";
@ -652,14 +683,18 @@ void MuSRFitform::GoFit()
FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------");
# update MSR File tab and initialization table
UpdateMSRFileInitTable();
}
return;
}
void MuSRFitform::GoPlot()
{
my %All=CreateAllInput();
CallMSRCreate();
my $Answer=CallMSRCreate();
my $FILENAME=$All{"FILENAME"}.".msr";
if ($Answer) {
if (-e $FILENAME) {
my $cmd="musrview $FILENAME &";
my $pid = system($cmd);
@ -667,6 +702,7 @@ void MuSRFitform::GoPlot()
FitTextOutput->append("Cannot find MSR file!");
FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------");
}
}
return;
}
@ -676,7 +712,9 @@ void MuSRFitform::ShowMuSRT0()
my %All=CreateAllInput();
musrfit_tabs->setCurrentPage(6);
# Create MSR file and then run musrt0
CallMSRCreate();
my $Answer=CallMSRCreate();
if ($Answer) {
my $FILENAME=$All{"FILENAME"}.".msr";
if (-e $FILENAME) {
my $cmd="musrt0 $FILENAME &";
@ -684,6 +722,7 @@ void MuSRFitform::ShowMuSRT0()
} else {
print STDERR "Cannot find MSR file!\n";
}
}
return;
}
@ -725,6 +764,20 @@ void MuSRFitform::RunSelectionToggle()
RUNSAuto->setEnabled(1);
RUNSAuto->setHidden(0);
}
# Also use this for other options
# Fourier toggle
my $Fourier=optionsFourier->isOn();
if ($Fourier) {
# Fourier tab visible
# musrfit_tabs->addTab(FourierPage,"Fourier");
# musrfit_tabs->showPage(FourierPage);
# FourierPage->hide();
} else {
# Fourier tab invisible
# musrfit_tabs->removePage(FourierPage);
# FourierPage->show();
}
}
void MuSRFitform::fileBrowse()
@ -747,4 +800,3 @@ void MuSRFitform::fileBrowse()
}
RunFiles->setText($RunFiles);
}