diff --git a/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm b/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm
index a0377ed..db27294 100644
--- a/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm
+++ b/trimsp/src/TrimSPGUI4/TrimSPGUI4.pm
@@ -1,7 +1,7 @@
package TrimSPGUI4;
use strict;
-#use warnings;
+use warnings;
use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::MainWindow );
@@ -11,7 +11,7 @@ use QtCore4::isa qw( Qt::Widget );
use Ui_TrimSPGUI4;
use QtCore4::slots
-# test => [],
+ test => [],
ToggleScanSingle => [],
findDensity => [],
PrepLayers => [],
@@ -36,8 +36,6 @@ sub NEW {
my ( $class, $parent ) = @_;
$class->SUPER::NEW($parent);
this->{ui} = Ui_TrimSPGUI4->setupUi(this);
-
-# this->statusBar()->addWidget(Qt::Label(this->tr("")));
}
# Function: return widget attribute given its type and name
@@ -57,8 +55,10 @@ sub ToggleScanSingle()
my %All=();
$All{"scanSeq"}=this->{ui}->scanSeq->isChecked();
$All{"comboScan"}=this->{ui}->comboScan->currentIndex();
- $All{"scandL"}=this->{ui}->scandL->text();
$All{"numLayer"}=this->{ui}->numLayer->text();
+ # Set numLayer as a maximum value for scandL
+ this->{ui}->scandL->setMaximum($All{"numLayer"});
+ $All{"scandL"}=this->{ui}->scandL->text();
$All{"radioList"}=this->{ui}->radioList->isChecked();
$All{"radioLoop"}=this->{ui}->radioLoop->isChecked();
@@ -119,10 +119,9 @@ sub ToggleScanSingle()
this->{ui}->sigAngle->setDisabled(0);
this->{ui}->numberProj->setDisabled(0);
# Also layer thicknesses
- for (my $i=1;$i<=7;$i++) {
- my $LayerThickName = "layer".$i."d";
- my $LayerThickAttrib = child("Qt::LineEdit",$LayerThickName);
- $LayerThickAttrib->setDisabled(0);
+ for (my $i=1;$i<=$All{"numLayer"};$i++) {
+ my $LayerThickAttrib = this->{ui}->layerTable->item($i-1,2);
+# $LayerThickAttrib->setDisabled(1);
}
if ($All{"scanSeq"}) {
@@ -131,7 +130,7 @@ sub ToggleScanSingle()
# If scanning layer thickness make sure it is actually defined
if ($All{"scandL"} > $All{"numLayer"}) {
- Qt::MessageBox::warning( this, "Warning!","Define layers first!");
+ Qt::MessageBox::warning(this, "Warning!","Define layers first!");
}
# Disable the appropriate box in the first tab.
@@ -146,9 +145,8 @@ sub ToggleScanSingle()
} elsif ($All{"comboScan"}==4) {
this->{ui}->numberProj->setDisabled(1);
} elsif($All{"comboScan"}==5) {
- my $LayerThickName = "layer".$All{"scandL"}."d";
- my $LayerThickAttrib = child("Qt::LineEdit",$LayerThickName);
- $LayerThickAttrib->setDisabled(1);
+ my $LayerThickAttrib = this->{ui}->layerTable->item($All{"scandL"}-1,2);
+# $LayerThickAttrib->setDisabled(1);
}
} else {
# Otherwise the title of the tab says disabled
@@ -165,6 +163,9 @@ sub PrepLayers()
$All{"numLayer"}=this->{ui}->numLayer->value();
# Set appropriate number of rows
this->{ui}->layerTable->setRowCount($All{"numLayer"});
+# Insert item (needed only for automatic density update)
+ my $cell = Qt::TableWidgetItem();
+ this->{ui}->layerTable->setItem($All{"numLayer"}-1,1,$cell);
}
# Subroutine: Set sane default values for projectile energy distribution and angles
@@ -280,7 +281,7 @@ sub CollectValues()
$All{"scanStep"}=1*$All{"scanStep"};
# Return values to caller
- return %All;
+ return(%All);
}
# Function: Create and return input file for the Trim.SP simulation
@@ -368,7 +369,7 @@ sub CreateInpFile()
my $ErrMsg="Error: Layer $i is empty. Expecting it to be defined!\n";
print STDERR $ErrMsg;
my $HelpWindow = Qt::MessageBox::information( this, "Error!",$ErrMsg);
- return "ERROR";
+ return("ERROR");
}
my $tmp = "L".$i."CK";
@@ -410,14 +411,14 @@ sub CreateInpFile()
}
foreach my $key (keys %All) {
-# print $key,$All{$key},"\n";
+ print $key,$All{$key},"\n";
if ($All{$key} ne ""){
$TemplateFile =~ s/$key/$All{$key}/;
# Seed repeats three times
if ($key eq "ranSeed") { $TemplateFile =~ s/$key/$All{$key}/g;}
}
}
- return $TemplateFile;
+ return($TemplateFile);
}
@@ -437,7 +438,7 @@ sub TrimBin
$ENV{'TRIMBIN'}=$file;
}
this->{ui}->trimbin->setText($file);
- return $file;
+ return($file);
}
@@ -458,7 +459,7 @@ sub GUIPath
}
this->{ui}->pathTrimGUI->setText($FileBrowser);
# Return a string with the directory name
- return $FileBrowser ;
+ return($FileBrowser);
}
@@ -497,35 +498,30 @@ sub StartSequenceOne()
}
my $ScanName = "";
- my $ScanVar = "";
+ my $ScanAttrib = "";
if ($All{"comboScan"}==0) {
$ScanName = "E";
- $ScanVar = "valEnergy";
+ $ScanAttrib = child("Qt::LineEdit","valEnergy");
} elsif ($All{"comboScan"}==1) {
$ScanName = "SigE";
- $ScanVar = "sigEnergy";
+ $ScanAttrib = child("Qt::LineEdit","sigEnergy");
} elsif ($All{"comboScan"}==2) {
$ScanName = "Angle";
- $ScanVar = "valAngle";
+ $ScanAttrib = child("Qt::LineEdit","valAngle");
} elsif ($All{"comboScan"}==3) {
$ScanName = "SigAngle";
- $ScanVar = "sigAngle";
+ $ScanAttrib = child("Qt::LineEdit","sigAngle");
} elsif ($All{"comboScan"}==4) {
$ScanName = "N";
- $ScanVar = "numberProj";
+ $ScanAttrib = child("Qt::LineEdit","numberProj");
} elsif ($All{"comboScan"}==5) {
$ScanName = "Ld".$All{"scandL"};
- $ScanVar = "layer".$All{"scandL"}."d";
+ $ScanAttrib = this->{ui}->layerTable->item($All{"ScandL"}-1,2);
}
- my $ScanAttrib = child("Qt::LineEdit",$ScanVar);
my $iScan=0;
foreach (@SValues) {
- if ($All{"comboScan"}==5) {
- this->{ui}->layerTable->setText($All{"ScandL"}-1,2,$_);
- } else {
- $ScanAttrib->setText($_);
- }
+ $ScanAttrib->setText($_);
if ( $All{"SdzFlag"} == 1) {
if ($All{"comboScan"}==0) {
this->{ui}->dz->setText($SdzValues[$iScan]);
@@ -534,7 +530,7 @@ sub StartSequenceOne()
}
}
my $eingabe1=CreateInpFile();
- if ($eingabe1 eq "ERROR") {return 0;}
+ if ($eingabe1 eq "ERROR") {return(0);}
my $FILENAME=$All{"fileNamePrefix"}."_".$ScanName.$_;
open (INPF,q{>}, "$FILENAME.inp" );
print INPF $eingabe1;
@@ -549,15 +545,12 @@ sub StartSequenceOne()
foreach ("err","out","rge") {
system("mv -f ausgabe1.$_ $FILENAME.$_");
}
-# Not needed if work path is changed
-# $cmd="mv -f $FILENAME.* ".$All{"workPath"};
-# system($cmd);
$iScan++;
}
} else {
# For a single run
my $eingabe1=CreateInpFile();
- if ($eingabe1 eq "ERROR") {return 0;}
+ if ($eingabe1 eq "ERROR") {return(0);}
my $FILENAME=$All{"fileNamePrefix"};
open (INPF,q{>}, "$FILENAME.inp" );
print INPF $eingabe1;
@@ -573,16 +566,13 @@ sub StartSequenceOne()
}
$Progress=90;
this->{ui}->progress->setValue($Progress);
-# If we change work directory this is not needed
-# $cmd="mv -f $FILENAME.* ".$All{"workPath"};
-# system($cmd);
}
# Move the fort.33 file into the subdirectory and change its name
$cmd="rm -f eingabe1.inp; mv -f fort.33 ".$All{"workPath"}."/".$All{"fileNamePrefix"}."_Seq_Results.dat";
system($cmd);
$Progress=100;
this->{ui}->progress->setValue($Progress);
- return 1;
+ return(1);
}
@@ -657,6 +647,7 @@ sub OpenFile()
# Remove white spaces
$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]}) {
@@ -691,29 +682,21 @@ sub SaveFile()
my %All = CollectValues();
my $InitFile="
[Layers]
-numLayer=$All{'numLayer'}
-layer1Comp=$All{'layer1Comp'}
-layer1rho=$All{'layer1rho'}
-layer1d=$All{'layer1d'}
-layer2Comp=$All{'layer2Comp'}
-layer2rho=$All{'layer2rho'}
-layer2d=$All{'layer2d'}
-layer3Comp=$All{'layer3Comp'}
-layer3rho=$All{'layer3rho'}
-layer3d=$All{'layer3d'}
-layer4Comp=$All{'layer4Comp'}
-layer4rho=$All{'layer4rho'}
-layer4d=$All{'layer4d'}
-layer5Comp=$All{'layer5Comp'}
-layer5rho=$All{'layer5rho'}
-layer5d=$All{'layer5d'}
-layer6Comp=$All{'layer6Comp'}
-layer6rho=$All{'layer6rho'}
-layer6d=$All{'layer6d'}
-layer7Comp=$All{'layer7Comp'}
-layer7rho=$All{'layer7rho'}
-layer7d=$All{'layer7d'}
+numLayer=$All{'numLayer'}";
+ for (my $i=1;$i<=$All{"numLayer"};$i++){
+ my $Li="L".$i;
+ my $LComp=$Li."Comp";
+ my $Lrho=$Li."rho";
+ my $Ld=$Li."d";
+ $InitFile=$InitFile."
+$LComp=$All{$LComp}
+$Lrho=$All{$Lrho}
+$Ld=$All{$Ld}
+";
+ }
+
+ $InitFile=$InitFile."
[ProjectileParameters]
projComboBox=$All{'projComboBox'}
numberProj=$All{'numberProj'}
@@ -754,29 +737,21 @@ sub SaveFileAs()
my %All = CollectValues();
my $InitFile="
[Layers]
-numLayer=$All{'numLayer'}
-layer1Comp=$All{'layer1Comp'}
-layer1rho=$All{'layer1rho'}
-layer1d=$All{'layer1d'}
-layer2Comp=$All{'layer2Comp'}
-layer2rho=$All{'layer2rho'}
-layer2d=$All{'layer2d'}
-layer3Comp=$All{'layer3Comp'}
-layer3rho=$All{'layer3rho'}
-layer3d=$All{'layer3d'}
-layer4Comp=$All{'layer4Comp'}
-layer4rho=$All{'layer4rho'}
-layer4d=$All{'layer4d'}
-layer5Comp=$All{'layer5Comp'}
-layer5rho=$All{'layer5rho'}
-layer5d=$All{'layer5d'}
-layer6Comp=$All{'layer6Comp'}
-layer6rho=$All{'layer6rho'}
-layer6d=$All{'layer6d'}
-layer7Comp=$All{'layer7Comp'}
-layer7rho=$All{'layer7rho'}
-layer7d=$All{'layer7d'}
+numLayer=$All{'numLayer'}";
+ for (my $i=1;$i<=$All{"numLayer"};$i++){
+ my $Li="L".$i;
+ my $LComp=$Li."Comp";
+ my $Lrho=$Li."rho";
+ my $Ld=$Li."d";
+ $InitFile=$InitFile."
+$LComp=$All{$LComp}
+$Lrho=$All{$Lrho}
+$Ld=$All{$Ld}
+";
+ }
+
+ $InitFile=$InitFile."
[ProjectileParameters]
projComboBox=$All{'projComboBox'}
numberProj=$All{'numberProj'}
@@ -929,17 +904,20 @@ sub findDensity()
{
use Chem;
# This is needed only for changes in the first column
- my $col = this->{ui}->layerTable->currentColumn();
- my $row = this->{ui}->layerTable->currentRow();
+ my $layerTable = this->{ui}->layerTable;
+ my $col = $layerTable->currentColumn();
+ my $row = $layerTable->currentRow();
if ($col == 0) {
# Get sender name to know which layer
- my $sender = this->{ui}->layerTable->currentItem();
+ my $sender = $layerTable->currentItem();
# Get the compound formula
my $Compound = $sender->text();
# See if you have the density
my $Density=Chem::Densities($Compound);
# If the density is in the database submit it
- if ($Density != 0 ) {this->{ui}->layerTable->item($row,$col+1)->setText($Density);}
+ if ($Density != 0 ) {
+ $layerTable->item($row,$col+1)->setText($Density);
+ }
}
}
@@ -949,7 +927,7 @@ sub test()
my $att = child("Qt::LineEdit","z0");
my $test2= $att->text();
my $test=this->{ui}->numberProj->text();
- print "numberProj=$test and z0=$test2\n";
+# print "numberProj=$test and z0=$test2\n";
}
1;
diff --git a/trimsp/src/TrimSPGUI4/TrimSPGUI4.ui b/trimsp/src/TrimSPGUI4/TrimSPGUI4.ui
index 9e06119..6a5a1c4 100644
--- a/trimsp/src/TrimSPGUI4/TrimSPGUI4.ui
+++ b/trimsp/src/TrimSPGUI4/TrimSPGUI4.ui
@@ -6,7 +6,7 @@
0
0
- 722
+ 709
622
@@ -1184,7 +1184,7 @@
false
-
+
10
@@ -1252,7 +1252,7 @@
1
- 7
+ 100
@@ -1495,7 +1495,7 @@
0
0
- 722
+ 709
20
@@ -1878,7 +1878,7 @@
542
- 721
+ 706
568
@@ -1942,7 +1942,7 @@
110
- 721
+ 706
129
@@ -1958,7 +1958,7 @@
71
- 721
+ 706
323
@@ -1974,7 +1974,7 @@
91
- 720
+ 706
509
@@ -1990,7 +1990,7 @@
124
- 720
+ 706
540
@@ -2006,7 +2006,7 @@
228
- 720
+ 706
462
@@ -2022,7 +2022,7 @@
94
- 717
+ 706
237
@@ -2038,7 +2038,7 @@
89
- 715
+ 706
230
@@ -2054,7 +2054,7 @@
107
- 721
+ 706
221
@@ -2070,7 +2070,7 @@
162
- 722
+ 706
307
@@ -2086,8 +2086,8 @@
90
- 360
- 310
+ 755
+ 68
@@ -2102,43 +2102,11 @@
332
- 360
+ 432
310
-
- plotMeanAction
- activated()
- TrimSPGUI4
- PlotMean()
-
-
- -1
- -1
-
-
- 360
- 310
-
-
-
-
- numLayer
- valueChanged(int)
- TrimSPGUI4
- PrepLayers()
-
-
- 182
- 94
-
-
- 720
- 358
-
-
-
DirectoryBrowse()
diff --git a/trimsp/src/TrimSPGUI4/Ui_TrimSPGUI4.pm b/trimsp/src/TrimSPGUI4/Ui_TrimSPGUI4.pm
index c6a9a0e..52b5118 100644
--- a/trimsp/src/TrimSPGUI4/Ui_TrimSPGUI4.pm
+++ b/trimsp/src/TrimSPGUI4/Ui_TrimSPGUI4.pm
@@ -5,7 +5,7 @@
#################################################################################
## Form generated from reading UI file 'TrimSPGUI4.ui'
##
-## Created: Mon Feb 23 11:19:21 2015
+## Created: Wed Feb 25 10:05:09 2015
## by: Qt User Interface Compiler version 4.8.6
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
@@ -501,7 +501,7 @@ sub setupUi {
if ( !defined $trimSPGUI4->objectName() ) {
$trimSPGUI4->setObjectName( "trimSPGUI4" );
}
- $trimSPGUI4->resize( 722, 622 );
+ $trimSPGUI4->resize( 709, 622 );
my $sizePolicy = Qt::SizePolicy( Qt::SizePolicy::Fixed(), Qt::SizePolicy::Fixed() );
$self->{$sizePolicy} = $sizePolicy;
$sizePolicy->setHorizontalStretch( 0 );
@@ -1041,7 +1041,7 @@ sub setupUi {
$scandL->setObjectName( "scandL" );
$scandL->setEnabled( 0 );
$scandL->setMinimum( 1 );
- $scandL->setMaximum( 7 );
+ $scandL->setMaximum( 100 );
$horizontalLayout_3->addWidget( $scandL );
@@ -1218,7 +1218,7 @@ sub setupUi {
my $menuBar = Qt::MenuBar( $trimSPGUI4 );
$self->{menuBar} = $menuBar;
$menuBar->setObjectName( "menuBar" );
- $menuBar->setGeometry( Qt::Rect(0, 0, 722, 20) );
+ $menuBar->setGeometry( Qt::Rect(0, 0, 709, 20) );
my $file = Qt::Menu( $menuBar );
$self->{file} = $file;
$file->setObjectName( "file" );
@@ -1308,8 +1308,6 @@ sub setupUi {
Qt::Object::connect($guiPathBrowse, SIGNAL 'clicked()' , $trimSPGUI4, SLOT 'GUIPath()' );
Qt::Object::connect($numLayer, SIGNAL 'valueChanged(int)' , $trimSPGUI4, SLOT 'PrepLayers()' );
Qt::Object::connect($layerTable, SIGNAL 'cellChanged(int,int)' , $trimSPGUI4, SLOT 'findDensity()' );
- Qt::Object::connect($plotMeanAction, SIGNAL 'activated()' , $trimSPGUI4, SLOT 'PlotMean()' );
- Qt::Object::connect($numLayer, SIGNAL 'valueChanged(int)' , $trimSPGUI4, SLOT 'PrepLayers()' );
$tabs->setCurrentIndex( 0 );