Finished implementing basic export capability.

This commit is contained in:
salman 2009-09-14 11:39:12 +00:00
parent 4b9ae9fe4d
commit d1e7cc82ba
4 changed files with 46 additions and 30 deletions

View File

@ -1241,6 +1241,7 @@ sub ExportParams {
my $Shared = 0; my $Shared = 0;
my $TABLE=""; my $TABLE="";
my $HEADER="RUN";
my %All = %{$_[0]}; my %All = %{$_[0]};
my @RUNS = (); my @RUNS = ();
@ -1300,6 +1301,10 @@ sub ExportParams {
if ( $#FitTypes != 0 && ( $Param ne "Alpha" ) ){ if ( $#FitTypes != 0 && ( $Param ne "Alpha" ) ){
$Param = join( "", $Param, "_", "$Component" ); $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"}; $Shared = $All{"Sh_$Param"};
if ( $Shared!=1 || $iRun == 1 ) { if ( $Shared!=1 || $iRun == 1 ) {
@ -1312,6 +1317,13 @@ sub ExportParams {
$line=join("\t",$line,$value,$error); $line=join("\t",$line,$value,$error);
$PCount++; $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++; $NP++;
} }
$Component++; $Component++;
@ -1361,6 +1373,10 @@ sub ExportParams {
} }
$TABLE=$TABLE."$line\n" $TABLE=$TABLE."$line\n"
} }
if ($All{"Header"}) {
$TABLE=$HEADER."\n".$TABLE;
}
return $TABLE; return $TABLE;
} }

View File

@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'MuSRFit.ui' # 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) # by: The PerlQt User Interface Compiler (puic)
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -585,7 +585,7 @@ sub NEW
setName("MuSRFitform" ); setName("MuSRFitform" );
} }
setSizePolicy(Qt::SizePolicy(3, 3, 1, 1, this->sizePolicy()->hasHeightForWidth()) ); setSizePolicy(Qt::SizePolicy(3, 3, 1, 1, this->sizePolicy()->hasHeightForWidth()) );
setMinimumSize(Qt::Size(23, 246) ); setMinimumSize(Qt::Size(21, 251) );
setIcon($image0 ); setIcon($image0 );
setCentralWidget(Qt::Widget(this, "qt_central_widget")); setCentralWidget(Qt::Widget(this, "qt_central_widget"));
@ -2198,6 +2198,8 @@ sub parametersExport
{ {
my %All=CreateAllInput(); my %All=CreateAllInput();
# Add also a flag for header
$All{"Header"}=1;
my $FILENAME=$All{"FILENAME"}.".dat"; my $FILENAME=$All{"FILENAME"}.".dat";
my $file=Qt::FileDialog::getSaveFileName( my $file=Qt::FileDialog::getSaveFileName(
"$FILENAME", "$FILENAME",
@ -2209,7 +2211,9 @@ sub parametersExport
# If the user gave a filename the copy to it # If the user gave a filename the copy to it
if ($file ne "") { if ($file ne "") {
my $Text = MSR::ExportParams(\%All); my $Text = MSR::ExportParams(\%All);
print $Text; open( DATF,q{>},"$file" );
print DATF $Text;
close(DATF);
} }
} }
@ -2218,8 +2222,10 @@ sub parametersAppend
{ {
my %All=CreateAllInput(); my %All=CreateAllInput();
# Add also a flag for header
$All{"Header"}=0;
my $FILENAME=$All{"FILENAME"}.".dat"; my $FILENAME=$All{"FILENAME"}.".dat";
my $file=Qt::FileDialog::getOpneFileName( my $file=Qt::FileDialog::getOpenFileName(
"./", "./",
"Data Files (*.dat)", "Data Files (*.dat)",
this, this,
@ -2228,17 +2234,11 @@ sub parametersAppend
# If the user gave a filename the copy to it # If the user gave a filename the copy to it
if ($file ne "") { if ($file ne "") {
if (-e $FILENAME) { my $Text = MSR::ExportParams(\%All);
my $Text = MSR::ExportParams(\%All); open( DATF,q{>>},"$file" );
print $Text; print DATF $Text;
} else { close(DATF);
if ($file ne "") {
my $Warning = "Warning: No data file found yet!";
my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
}
}
} }
MSR::ExportParams(\%All);
} }

View File

@ -22,8 +22,8 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>23</width> <width>21</width>
<height>246</height> <height>251</height>
</size> </size>
</property> </property>
<property name="caption"> <property name="caption">

View File

@ -96,6 +96,8 @@ void Form1::fileExit()
void Form1::parametersExport() void Form1::parametersExport()
{ {
my %All=CreateAllInput(); my %All=CreateAllInput();
# Add also a flag for header
$All{"Header"}=1;
my $FILENAME=$All{"FILENAME"}.".dat"; my $FILENAME=$All{"FILENAME"}.".dat";
my $file=Qt::FileDialog::getSaveFileName( my $file=Qt::FileDialog::getSaveFileName(
"$FILENAME", "$FILENAME",
@ -107,7 +109,9 @@ void Form1::parametersExport()
# If the user gave a filename the copy to it # If the user gave a filename the copy to it
if ($file ne "") { if ($file ne "") {
my $Text = MSR::ExportParams(\%All); my $Text = MSR::ExportParams(\%All);
print $Text; open( DATF,q{>},"$file" );
print DATF $Text;
close(DATF);
} }
} }
@ -115,8 +119,10 @@ void Form1::parametersExport()
void Form1::parametersAppend() void Form1::parametersAppend()
{ {
my %All=CreateAllInput(); my %All=CreateAllInput();
# Add also a flag for header
$All{"Header"}=0;
my $FILENAME=$All{"FILENAME"}.".dat"; my $FILENAME=$All{"FILENAME"}.".dat";
my $file=Qt::FileDialog::getOpneFileName( my $file=Qt::FileDialog::getOpenFileName(
"./", "./",
"Data Files (*.dat)", "Data Files (*.dat)",
this, this,
@ -125,17 +131,11 @@ void Form1::parametersAppend()
# If the user gave a filename the copy to it # If the user gave a filename the copy to it
if ($file ne "") { if ($file ne "") {
if (-e $FILENAME) { my $Text = MSR::ExportParams(\%All);
my $Text = MSR::ExportParams(\%All); open( DATF,q{>>},"$file" );
print $Text; print DATF $Text;
} else { close(DATF);
if ($file ne "") {
my $Warning = "Warning: No data file found yet!";
my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
}
}
} }
MSR::ExportParams(\%All);
} }