Template file option added.

This commit is contained in:
2012-05-04 08:35:32 +00:00
parent 45209156fa
commit 477b82008d
3 changed files with 272 additions and 201 deletions

View File

@ -181,7 +181,7 @@ void QmuSRSim::CreateAllInput()
my %All=();
my @AllParams= ("L1","L3","TL","BFIELD","RA_T","RA_B","RA_R","RA_L","SR_B","SR_E","ENERGY","NMuon",
"L1_2","L2_2","L3_2","BFIELD_2","RA_T_2","RA_B_2","RA_R_2","RA_L_2","ENERGY_2",
"MAC","musrSim","Geant4","ROOTSYS");
"MAC","musrSim","Geant4","ROOTSYS","TEMPL");
foreach my $Param (@AllParams) {
my $Child = child($Param);
my $Value = $Child->text;
@ -223,8 +223,8 @@ void QmuSRSim::StartCalc()
my $Page = Tabs->currentPageIndex;
my %ToReplace=();
my @SpaceHolder=();
# my $FName="SRBeamLine.mac";
my $FName="SRBeamLine_Bend.mac";
my $FName= $All{"TEMPL"};
# 0 for spin rotator and 1 for current.
if ($Page == 0) {
%ToReplace= (
@ -242,8 +242,8 @@ void QmuSRSim::StartCalc()
"ENERGY"=>"ENERGY",
"MIRRFIELD"=>"MIRRFIELD"
);
# Use the following template
$FName="SRBeamLine_Bend.mac";
# Use the default template
if ($FName eq "") {$FName="SRBeamLine_Bend.mac";}
} elsif ($Page == 1) {
%ToReplace= (
"L1_2"=>"L1VOLTAGE",
@ -258,8 +258,8 @@ void QmuSRSim::StartCalc()
"ENERGY_2"=>"ENERGY",
"MIRRFIELD_2"=>"MIRRFIELD"
);
# Use the following template
$FName="CBeamLine.mac";
# Use the default template
if ($FName eq "") {$FName="CBeamLine.mac";}
}
open(MACF,"$FName");
@ -298,9 +298,20 @@ void QmuSRSim::GetPATH()
my $name = $sender->name();
$name =~ s/Button//g;
my $RETVAL = "";
if ($name eq "TEMPL") {
# Get template file name
$RETVAL = Qt::FileDialog::getOpenFileName(
"./",
"MAC file (*.mac)",
this,
"Select template file dialog",
"Choose a template file");
} else {
# Get the requested path
my $RETVAL = Qt::FileDialog::getExistingDirectory("./",this,"get existing directory","Choose a directory",1);
# Now submit the path into the lineEdit
$RETVAL = Qt::FileDialog::getExistingDirectory("./",this,"get existing directory","Choose a directory",1);
}
# Now submit the path or file name into the lineEdit
if ($RETVAL ne "") {
child($name)->setText($RETVAL);
}