From aab2c7a7177bed3792fafd39f8c63befbb43e4e1 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Mon, 14 Sep 2009 11:40:24 +0000 Subject: [PATCH] Finished implementing basic export capability. --- src/external/MuSRFitGUI/MSR.pm | 16 +++++++++++++++ src/external/MuSRFitGUI/MuSRFit.pl | 30 ++++++++++++++-------------- src/external/MuSRFitGUI/MuSRFit.ui.h | 26 ++++++++++++------------ 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/src/external/MuSRFitGUI/MSR.pm b/src/external/MuSRFitGUI/MSR.pm index 4d80834e..da00280e 100755 --- a/src/external/MuSRFitGUI/MSR.pm +++ b/src/external/MuSRFitGUI/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/MuSRFit.pl b/src/external/MuSRFitGUI/MuSRFit.pl index 7f9c438e..3df12a47 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: Sun Sep 13 23:09:01 2009 +# Created: Mon Sep 14 13:39:32 2009 # by: The PerlQt User Interface Compiler (puic) # # WARNING! All changes made in this file will be lost! @@ -576,7 +576,7 @@ sub NEW setName("MuSRFitform" ); } setSizePolicy(Qt::SizePolicy(3, 3, 1, 1, this->sizePolicy()->hasHeightForWidth()) ); - setMinimumSize(Qt::Size(21, 227) ); + setMinimumSize(Qt::Size(23, 246) ); setIcon($image0 ); setCentralWidget(Qt::Widget(this, "qt_central_widget")); @@ -2041,6 +2041,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", @@ -2052,7 +2054,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); } } @@ -2060,9 +2064,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, @@ -2071,17 +2077,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/MuSRFit.ui.h b/src/external/MuSRFitGUI/MuSRFit.ui.h index 01b95cc9..52445461 100755 --- a/src/external/MuSRFitGUI/MuSRFit.ui.h +++ b/src/external/MuSRFitGUI/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); }