From 79dd2cf4a93e47b14a7f353309c41188ee6094b3 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Wed, 28 Sep 2011 13:53:13 +0000 Subject: [PATCH] Added check for correct number of histograms for asymmetry fit. --- src/external/MuSRFitGUI/MuSRFit.pl | 74 +++++++++++++--------- src/external/MuSRFitGUI/MuSRFit.ui.h | 74 +++++++++++++--------- src/external/MuSRFitGUI/devel/MuSRFit.ui.h | 74 +++++++++++++--------- 3 files changed, 135 insertions(+), 87 deletions(-) diff --git a/src/external/MuSRFitGUI/MuSRFit.pl b/src/external/MuSRFitGUI/MuSRFit.pl index 8d8bd5c7..dba9fde0 100755 --- a/src/external/MuSRFitGUI/MuSRFit.pl +++ b/src/external/MuSRFitGUI/MuSRFit.pl @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'MuSRFit.ui' # -# Created: Wed May 25 16:46:00 2011 +# Created: Wed Sep 28 15:51:27 2011 # by: The PerlQt User Interface Compiler (puic) # # WARNING! All changes made in this file will be lost! @@ -4181,27 +4181,35 @@ sub GoFit { my %All=CreateAllInput(); - musrfit_tabs->setCurrentPage(1); - 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 () { - FitTextOutput->append("$_"); +# Check here is the number of histograms makes sense +# other wise give error. + my @Hists = split( /,/, $All{"LRBF"} ); + if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) { +# we have a problem here send error message + my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!"; + my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning); + } else { + musrfit_tabs->setCurrentPage(1); + 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 () { + FitTextOutput->append("$_"); + } + close(FTO); + $cmd="musrview $FILENAME &"; + $pid = system($cmd); + } else { + FitTextOutput->append("Cannot find MSR file!"); } - close(FTO); - $cmd="musrview $FILENAME &"; - $pid = system($cmd); - } else { - FitTextOutput->append("Cannot find MSR file!"); - } - FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); + FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); # update MSR File tab and initialization table - UpdateMSRFileInitTable(); + UpdateMSRFileInitTable(); + } } - return; } @@ -4210,16 +4218,24 @@ sub GoPlot { my %All=CreateAllInput(); - my $Answer=CallMSRCreate(); - my $FILENAME=$All{"FILENAME"}.".msr"; - - if ($Answer) { - if (-e $FILENAME) { - my $cmd="musrview $FILENAME &"; - my $pid = system($cmd); - } else { - FitTextOutput->append("Cannot find MSR file!"); - FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); +# Check here is the number of histograms makes sense +# other wise give error. + my @Hists = split( /,/, $All{"LRBF"} ); + if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) { +# we have a problem here send error message + my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!"; + my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning); + } else { + my $Answer=CallMSRCreate(); + my $FILENAME=$All{"FILENAME"}.".msr"; + if ($Answer) { + if (-e $FILENAME) { + my $cmd="musrview $FILENAME &"; + my $pid = system($cmd); + } else { + FitTextOutput->append("Cannot find MSR file!"); + FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); + } } } return; diff --git a/src/external/MuSRFitGUI/MuSRFit.ui.h b/src/external/MuSRFitGUI/MuSRFit.ui.h index e8d9c919..a45bab55 100755 --- a/src/external/MuSRFitGUI/MuSRFit.ui.h +++ b/src/external/MuSRFitGUI/MuSRFit.ui.h @@ -6,7 +6,7 @@ ** ** You should not define a constructor or destructor in this file. ** Instead, write your code in functions called init() and destroy(). -** These will automatically be called by the form's constructor and +** These will automatically be called by theform's constructor and ** destructor. *****************************************************************************/ @@ -701,43 +701,59 @@ void MuSRFitform::TabChanged() void MuSRFitform::GoFit() { my %All=CreateAllInput(); - musrfit_tabs->setCurrentPage(1); - 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 () { - FitTextOutput->append("$_"); +# Check here is the number of histograms makes sense +# other wise give error. + my @Hists = split( /,/, $All{"LRBF"} ); + if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) { +# we have a problem here send error message + my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!"; + my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning); + } else { + musrfit_tabs->setCurrentPage(1); + 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 () { + FitTextOutput->append("$_"); + } + close(FTO); + $cmd="musrview $FILENAME &"; + $pid = system($cmd); + } else { + FitTextOutput->append("Cannot find MSR file!"); } - close(FTO); - $cmd="musrview $FILENAME &"; - $pid = system($cmd); - } else { - FitTextOutput->append("Cannot find MSR file!"); - } - FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); + FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); # update MSR File tab and initialization table - UpdateMSRFileInitTable(); + UpdateMSRFileInitTable(); + } } - return; } void MuSRFitform::GoPlot() { my %All=CreateAllInput(); - my $Answer=CallMSRCreate(); - my $FILENAME=$All{"FILENAME"}.".msr"; - - if ($Answer) { - if (-e $FILENAME) { - my $cmd="musrview $FILENAME &"; - my $pid = system($cmd); - } else { - FitTextOutput->append("Cannot find MSR file!"); - FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); +# Check here is the number of histograms makes sense +# other wise give error. + my @Hists = split( /,/, $All{"LRBF"} ); + if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) { +# we have a problem here send error message + my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!"; + my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning); + } else { + my $Answer=CallMSRCreate(); + my $FILENAME=$All{"FILENAME"}.".msr"; + if ($Answer) { + if (-e $FILENAME) { + my $cmd="musrview $FILENAME &"; + my $pid = system($cmd); + } else { + FitTextOutput->append("Cannot find MSR file!"); + FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); + } } } return; diff --git a/src/external/MuSRFitGUI/devel/MuSRFit.ui.h b/src/external/MuSRFitGUI/devel/MuSRFit.ui.h index 3953e2c1..60e5e46e 100755 --- a/src/external/MuSRFitGUI/devel/MuSRFit.ui.h +++ b/src/external/MuSRFitGUI/devel/MuSRFit.ui.h @@ -6,7 +6,7 @@ ** ** You should not define a constructor or destructor in this file. ** Instead, write your code in functions called init() and destroy(). -** These will automatically be called by the form's constructor and +** These will automatically be called by theform's constructor and ** destructor. *****************************************************************************/ @@ -703,43 +703,59 @@ void MuSRFitform::TabChanged() void MuSRFitform::GoFit() { my %All=CreateAllInput(); - musrfit_tabs->setCurrentPage(1); - 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 () { - FitTextOutput->append("$_"); +# Check here is the number of histograms makes sense +# other wise give error. + my @Hists = split( /,/, $All{"LRBF"} ); + if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) { +# we have a problem here send error message + my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!"; + my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning); + } else { + musrfit_tabs->setCurrentPage(1); + 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 () { + FitTextOutput->append("$_"); + } + close(FTO); + $cmd="musrview $FILENAME &"; + $pid = system($cmd); + } else { + FitTextOutput->append("Cannot find MSR file!"); } - close(FTO); - $cmd="musrview $FILENAME &"; - $pid = system($cmd); - } else { - FitTextOutput->append("Cannot find MSR file!"); - } - FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); + FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); # update MSR File tab and initialization table - UpdateMSRFileInitTable(); + UpdateMSRFileInitTable(); + } } - return; } void MuSRFitform::GoPlot() { my %All=CreateAllInput(); - my $Answer=CallMSRCreate(); - my $FILENAME=$All{"FILENAME"}.".msr"; - - if ($Answer) { - if (-e $FILENAME) { - my $cmd="musrview $FILENAME &"; - my $pid = system($cmd); - } else { - FitTextOutput->append("Cannot find MSR file!"); - FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); +# Check here is the number of histograms makes sense +# other wise give error. + my @Hists = split( /,/, $All{"LRBF"} ); + if ($All{"FitAsyType"} eq "Asymmetry" && $#Hists != 1) { +# we have a problem here send error message + my $Warning = "Error: The number of histograms should be 2 for an asymmetry fit!"; + my $WarningWindow = Qt::MessageBox::information( this, "Error",$Warning); + } else { + my $Answer=CallMSRCreate(); + my $FILENAME=$All{"FILENAME"}.".msr"; + if ($Answer) { + if (-e $FILENAME) { + my $cmd="musrview $FILENAME &"; + my $pid = system($cmd); + } else { + FitTextOutput->append("Cannot find MSR file!"); + FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------"); + } } } return;