From d1e7cc82ba3ae81aa2a7a2f757627f468cad81e1 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Mon, 14 Sep 2009 11:39:12 +0000 Subject: [PATCH] Finished implementing basic export capability. --- src/external/MuSRFitGUI/devel/MSR.pm | 16 ++++++++++++ src/external/MuSRFitGUI/devel/MuSRFit.pl | 30 +++++++++++----------- src/external/MuSRFitGUI/devel/MuSRFit.ui | 4 +-- src/external/MuSRFitGUI/devel/MuSRFit.ui.h | 26 +++++++++---------- 4 files changed, 46 insertions(+), 30 deletions(-) diff --git a/src/external/MuSRFitGUI/devel/MSR.pm b/src/external/MuSRFitGUI/devel/MSR.pm index 4d80834e..da00280e 100755 --- a/src/external/MuSRFitGUI/devel/MSR.pm +++ b/src/external/MuSRFitGUI/devel/MSR.pm @@ -1241,6 +1241,7 @@ sub ExportParams { my $Shared = 0; my $TABLE=""; + my $HEADER="RUN"; my %All = %{$_[0]}; my @RUNS = (); @@ -1300,6 +1301,10 @@ sub ExportParams { if ( $#FitTypes != 0 && ( $Param ne "Alpha" ) ){ $Param = join( "", $Param, "_", "$Component" ); } + # $All{"Header"} - 0/1 for with/without header + if ($All{"Header"} && $iRun == 1) { + $HEADER=join("\t",$HEADER,$Param,"$erradd$Param"); + } $Shared = $All{"Sh_$Param"}; if ( $Shared!=1 || $iRun == 1 ) { @@ -1312,6 +1317,13 @@ sub ExportParams { $line=join("\t",$line,$value,$error); $PCount++; } + elsif ($Shared==1) { +# The parameter is shared, take the value from the first run + $Param=$Param."_1"; + $value = $All{"$Param"}; + $error = $All{"$erradd$Param"}; + $line=join("\t",$line,$value,$error); + } $NP++; } $Component++; @@ -1361,6 +1373,10 @@ sub ExportParams { } $TABLE=$TABLE."$line\n" } + if ($All{"Header"}) { + $TABLE=$HEADER."\n".$TABLE; + } + return $TABLE; } diff --git a/src/external/MuSRFitGUI/devel/MuSRFit.pl b/src/external/MuSRFitGUI/devel/MuSRFit.pl index 2e7eb760..02a5df7e 100755 --- a/src/external/MuSRFitGUI/devel/MuSRFit.pl +++ b/src/external/MuSRFitGUI/devel/MuSRFit.pl @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'MuSRFit.ui' # -# Created: Sun Sep 13 23:02:53 2009 +# Created: Mon Sep 14 13:29:17 2009 # by: The PerlQt User Interface Compiler (puic) # # WARNING! All changes made in this file will be lost! @@ -585,7 +585,7 @@ sub NEW setName("MuSRFitform" ); } setSizePolicy(Qt::SizePolicy(3, 3, 1, 1, this->sizePolicy()->hasHeightForWidth()) ); - setMinimumSize(Qt::Size(23, 246) ); + setMinimumSize(Qt::Size(21, 251) ); setIcon($image0 ); setCentralWidget(Qt::Widget(this, "qt_central_widget")); @@ -2198,6 +2198,8 @@ sub parametersExport { my %All=CreateAllInput(); +# Add also a flag for header + $All{"Header"}=1; my $FILENAME=$All{"FILENAME"}.".dat"; my $file=Qt::FileDialog::getSaveFileName( "$FILENAME", @@ -2209,7 +2211,9 @@ sub parametersExport # If the user gave a filename the copy to it if ($file ne "") { my $Text = MSR::ExportParams(\%All); - print $Text; + open( DATF,q{>},"$file" ); + print DATF $Text; + close(DATF); } } @@ -2217,9 +2221,11 @@ sub parametersExport sub parametersAppend { - my %All=CreateAllInput(); + my %All=CreateAllInput(); +# Add also a flag for header + $All{"Header"}=0; my $FILENAME=$All{"FILENAME"}.".dat"; - my $file=Qt::FileDialog::getOpneFileName( + my $file=Qt::FileDialog::getOpenFileName( "./", "Data Files (*.dat)", this, @@ -2228,17 +2234,11 @@ sub parametersAppend # If the user gave a filename the copy to it if ($file ne "") { - if (-e $FILENAME) { - my $Text = MSR::ExportParams(\%All); - print $Text; - } else { - if ($file ne "") { - my $Warning = "Warning: No data file found yet!"; - my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning); - } - } + my $Text = MSR::ExportParams(\%All); + open( DATF,q{>>},"$file" ); + print DATF $Text; + close(DATF); } - MSR::ExportParams(\%All); } diff --git a/src/external/MuSRFitGUI/devel/MuSRFit.ui b/src/external/MuSRFitGUI/devel/MuSRFit.ui index 9db41c1e..f64f954f 100755 --- a/src/external/MuSRFitGUI/devel/MuSRFit.ui +++ b/src/external/MuSRFitGUI/devel/MuSRFit.ui @@ -22,8 +22,8 @@ - 23 - 246 + 21 + 251 diff --git a/src/external/MuSRFitGUI/devel/MuSRFit.ui.h b/src/external/MuSRFitGUI/devel/MuSRFit.ui.h index c664e47c..45108864 100755 --- a/src/external/MuSRFitGUI/devel/MuSRFit.ui.h +++ b/src/external/MuSRFitGUI/devel/MuSRFit.ui.h @@ -96,6 +96,8 @@ void Form1::fileExit() void Form1::parametersExport() { my %All=CreateAllInput(); +# Add also a flag for header + $All{"Header"}=1; my $FILENAME=$All{"FILENAME"}.".dat"; my $file=Qt::FileDialog::getSaveFileName( "$FILENAME", @@ -107,16 +109,20 @@ void Form1::parametersExport() # If the user gave a filename the copy to it if ($file ne "") { my $Text = MSR::ExportParams(\%All); - print $Text; + open( DATF,q{>},"$file" ); + print DATF $Text; + close(DATF); } } void Form1::parametersAppend() { - my %All=CreateAllInput(); + my %All=CreateAllInput(); +# Add also a flag for header + $All{"Header"}=0; my $FILENAME=$All{"FILENAME"}.".dat"; - my $file=Qt::FileDialog::getOpneFileName( + my $file=Qt::FileDialog::getOpenFileName( "./", "Data Files (*.dat)", this, @@ -125,17 +131,11 @@ void Form1::parametersAppend() # If the user gave a filename the copy to it if ($file ne "") { - if (-e $FILENAME) { - my $Text = MSR::ExportParams(\%All); - print $Text; - } else { - if ($file ne "") { - my $Warning = "Warning: No data file found yet!"; - my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning); - } - } + my $Text = MSR::ExportParams(\%All); + open( DATF,q{>>},"$file" ); + print DATF $Text; + close(DATF); } - MSR::ExportParams(\%All); }