Fixed ability to load configuration files with backward compatibility. Development will not be propagated to qt3 branch.
This commit is contained in:
parent
efd0f35f54
commit
8948566ea2
@ -41,8 +41,15 @@ sub NEW {
|
||||
sub child {
|
||||
# Take type and name from input
|
||||
my ( $object, $name ) = @_;
|
||||
my $Attrib = this->findChildren($object, $name);
|
||||
$Attrib = @{$Attrib}[0];
|
||||
|
||||
my $Attrib = this->findChildren($object,$name);
|
||||
if (@$Attrib) {
|
||||
$Attrib = @$Attrib[0];
|
||||
} else {
|
||||
$Attrib = 0;
|
||||
}
|
||||
# print "name = $name and attrib = $Attrib\n";
|
||||
|
||||
# Return handle on widget
|
||||
return($Attrib);
|
||||
}
|
||||
@ -605,8 +612,8 @@ sub StartSequenceOne
|
||||
this->{ui}->progress->update();
|
||||
undef %All;
|
||||
undef $cmd;
|
||||
print "at end\n";
|
||||
sleep(10);
|
||||
# print "at end\n";
|
||||
# sleep(10);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -677,12 +684,19 @@ sub OpenFile
|
||||
open (INF,q{<},"$file" );
|
||||
my @lines = <INF>;
|
||||
close(INF);
|
||||
# Remove comment lines, empty lines and lines starting with "["
|
||||
@lines = grep {!/^\#/} @lines;
|
||||
@lines = grep {/\S/} @lines;
|
||||
@lines = grep {!/^\[/} @lines;
|
||||
@lines = grep {/\s+/} @lines;
|
||||
|
||||
@lines = &ConvertCFG(@lines);
|
||||
|
||||
my $Attrib="";
|
||||
foreach my $line (@lines) {
|
||||
# Remove white spaces
|
||||
$line =~ s/\s+//g;
|
||||
# $line =~ s/\s+//g;
|
||||
my @InitPar = split (/=/,$line);
|
||||
# Possible backward compatibility: NL to numLayer
|
||||
# Check it is not empty or title line
|
||||
if ($InitPar[0] || $InitPar[1]) {
|
||||
if (!$Types{$InitPar[0]}) {
|
||||
@ -702,17 +716,44 @@ sub OpenFile
|
||||
$Attrib->setChecked(0);
|
||||
}
|
||||
} elsif ($Types{$InitPar[0]} eq "Qt::ComboBox") {
|
||||
$Attrib-> setCurrentIndex($InitPar[1]);
|
||||
$Attrib->setCurrentIndex($InitPar[1]);
|
||||
} else {
|
||||
$Attrib->setText($InitPar[1]);
|
||||
}
|
||||
} else {
|
||||
# child not found probably table cell
|
||||
# Identify layers parameters and convert to row column
|
||||
my $col = $InitPar[0];
|
||||
my $row = $InitPar[0];
|
||||
# Flag takes 1 for table item and zero if not
|
||||
my $flag = 0;
|
||||
$col =~ s/\d//g;
|
||||
$row =~ s/[^0-9]//g;
|
||||
if ($col eq "LComp") {
|
||||
$col = 0;
|
||||
$flag = 1;
|
||||
} elsif ($col eq "Lrho") {
|
||||
$col = 1;
|
||||
$flag = 1;
|
||||
} elsif ($col eq "Ld") {
|
||||
$col = 2;
|
||||
$flag = 1;
|
||||
}
|
||||
if ($flag) {
|
||||
my $cell = this->{ui}->layerTable->item($row-1,$col);
|
||||
if (!$cell) {
|
||||
$cell = Qt::TableWidgetItem();
|
||||
this->{ui}->layerTable->setItem($row-1,$col,$cell);
|
||||
}
|
||||
this->{ui}->layerTable->item($row-1,$col)->setText($InitPar[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Subroutine: Save configuration file to TrimSP.cfg
|
||||
# Subroutine: Create configuration file
|
||||
sub GenInitFile
|
||||
{
|
||||
my %All = %{CollectValues()};
|
||||
@ -794,6 +835,66 @@ sub SaveFileAs
|
||||
}
|
||||
}
|
||||
|
||||
# Subroutine: Convert old configuration file to new format
|
||||
sub ConvertCFG
|
||||
{
|
||||
# Get cleaned lines
|
||||
my @lines = @_;
|
||||
|
||||
# Backward compatibility: NL to numLayer
|
||||
my %BackSubs = ("NL","numLayer",
|
||||
"NProj","numberProj",
|
||||
"E","valEnergy",
|
||||
"SigE","sigEnergy",
|
||||
"Angle","valAngle",
|
||||
"SigAngle","sigAngle",
|
||||
"Seed","ranSeed",
|
||||
"FNPre","fileNamePrefix",
|
||||
"Path","workPath",
|
||||
"ScanSeq","scanSeq",
|
||||
"ScanList","scanList",
|
||||
"ListRadio","radioList",
|
||||
"ScanListdz","scanListdz",
|
||||
"LoopRadio","radioLoop",
|
||||
"SFrom","scanFrom",
|
||||
"STo","scanTo",
|
||||
"SStep","scanStep"
|
||||
);
|
||||
|
||||
# Go over all elements of %BackSubs and substitute
|
||||
foreach my $key (keys %BackSubs) {
|
||||
@lines = map {s/^$key=/$BackSubs{$key}=/; $_;} @lines;
|
||||
}
|
||||
|
||||
# deal with ProjType
|
||||
%BackSubs = ("ProjType=Muon","projComboBox=0",
|
||||
"ProjType=Li8","projComboBox=1",
|
||||
"ProjType=B12","projComboBox=2",
|
||||
"ProjType=H","projComboBox=3"
|
||||
);
|
||||
|
||||
# Go over all elements of %BackSubs and substitute
|
||||
foreach my $key (keys %BackSubs) {
|
||||
@lines = map {s/^$key/$BackSubs{$key}/; $_;} @lines;
|
||||
}
|
||||
|
||||
|
||||
# deal with scan radios
|
||||
%BackSubs = ("ERadio=1","comboScan=0",
|
||||
"SigERadio=1","comboScan=1",
|
||||
"AngleRadio=1","comboScan=2",
|
||||
"SigAngleRadio=1","comboScan=3",
|
||||
"NProjRadio=1","comboScan=4",
|
||||
);
|
||||
|
||||
# Go over all elements of %BackSubs and substitute
|
||||
foreach my $key (keys %BackSubs) {
|
||||
@lines = map {s/^$key/$BackSubs{$key}/; $_;} @lines;
|
||||
}
|
||||
|
||||
return(@lines);
|
||||
}
|
||||
|
||||
# Subroutine: Plot implantation profiles using root macro
|
||||
sub PlotProfiles
|
||||
{
|
||||
@ -930,7 +1031,7 @@ sub findDensity
|
||||
# See if you have the density
|
||||
my $Density=Chem::Densities($Compound);
|
||||
# If the density is in the database submit it
|
||||
if ($Density != 0 ) {
|
||||
if ($Density ne "" ) {
|
||||
$layerTable->item($row,$col+1)->setText($Density);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#################################################################################
|
||||
## Form generated from reading UI file 'TrimSPGUI4.ui'
|
||||
##
|
||||
## Created: Wed Jun 24 14:33:41 2015
|
||||
## Created: Thu Aug 27 10:51:18 2015
|
||||
## by: Qt User Interface Compiler version 4.8.6
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
|
Loading…
x
Reference in New Issue
Block a user