Extract densities from database if found.

This commit is contained in:
salman 2013-03-12 09:03:34 +00:00
parent 7d9c2dbcc9
commit 75b6071c53
4 changed files with 254 additions and 164 deletions

View File

@ -637,7 +637,7 @@ sub Stopicru {
sub Densities {
# Database of densities for different compounds
my ($Compound) = @_;
my %Densities = (
"NbN",8.47,
"Bi2Se3",7.51,

View File

@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'TrimSPGUI.ui'
#
# Created: Tue Feb 5 15:53:55 2013
# Created: Tue Mar 12 10:01:24 2013
# by: The PerlQt User Interface Compiler (puic)
#
# WARNING! All changes made in this file will be lost!
@ -30,7 +30,8 @@ use Qt::slots
SaveFile => [],
SaveFileAs => [],
GUIPath => [],
TrimBin => [];
TrimBin => [],
findDensity => [];
use Qt::attributes qw(
Progress
tabs
@ -42,13 +43,13 @@ use Qt::attributes qw(
textLabel3
textLabel4
BoxL1
L1Comp
L1rho
L1d
L1Comp
BoxL2
L2Comp
L2rho
L2d
L2Comp
BoxL3
L3Comp
L3rho
@ -1362,29 +1363,29 @@ sub NEW
BoxL1 = Qt::GroupBox($LayoutWidget, "BoxL1");
BoxL1->setMargin( int(0) );
L1Comp = Qt::LineEdit(BoxL1, "L1Comp");
L1Comp->setGeometry( Qt::Rect(10, 20, 180, 25) );
L1rho = Qt::LineEdit(BoxL1, "L1rho");
L1rho->setGeometry( Qt::Rect(200, 20, 111, 25) );
L1d = Qt::LineEdit(BoxL1, "L1d");
L1d->setGeometry( Qt::Rect(320, 20, 85, 25) );
L1d->setSizePolicy( Qt::SizePolicy(0, 0, 0, 0, L1d->sizePolicy()->hasHeightForWidth()) );
L1Comp = Qt::LineEdit(BoxL1, "L1Comp");
L1Comp->setGeometry( Qt::Rect(10, 20, 180, 25) );
$layout27->addWidget(BoxL1);
BoxL2 = Qt::GroupBox($LayoutWidget, "BoxL2");
BoxL2->setEnabled( 0 );
L2Comp = Qt::LineEdit(BoxL2, "L2Comp");
L2Comp->setGeometry( Qt::Rect(10, 20, 180, 25) );
L2rho = Qt::LineEdit(BoxL2, "L2rho");
L2rho->setGeometry( Qt::Rect(200, 20, 111, 25) );
L2d = Qt::LineEdit(BoxL2, "L2d");
L2d->setGeometry( Qt::Rect(320, 20, 85, 25) );
L2d->setSizePolicy( Qt::SizePolicy(0, 0, 0, 0, L2d->sizePolicy()->hasHeightForWidth()) );
L2Comp = Qt::LineEdit(BoxL2, "L2Comp");
L2Comp->setGeometry( Qt::Rect(10, 20, 180, 25) );
$layout27->addWidget(BoxL2);
BoxL3 = Qt::GroupBox($LayoutWidget, "BoxL3");
@ -1896,32 +1897,39 @@ sub NEW
resize( $resize );
clearWState( &Qt::WState_Polished );
Qt::Object::connect(fileChangeDirAction, SIGNAL "activated()", this, SLOT "DirectoryBrowse()");
Qt::Object::connect(fileQuitAction, SIGNAL "activated()", this, SLOT "ConfirmQuit()");
Qt::Object::connect(helpContentsAction, SIGNAL "activated()", this, SLOT "OpenHelpWindow()");
Qt::Object::connect(ScanSeq, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(Start, SIGNAL "clicked()", this, SLOT "StartSequenceOne()");
Qt::Object::connect(ERadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(SigERadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(NProjRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(ScandL, SIGNAL "valueChanged(int)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(dRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(NL, SIGNAL "valueChanged(int)", this, SLOT "PrepLayers()");
Qt::Object::connect(ProjType, SIGNAL "activated(int)", this, SLOT "ProjSmartDefaults()");
Qt::Object::connect(Browse, SIGNAL "clicked()", this, SLOT "DirectoryBrowse()");
Qt::Object::connect(Quit, SIGNAL "clicked()", this, SLOT "ConfirmQuit()");
Qt::Object::connect(ListRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(fileStartAction, SIGNAL "activated()", this, SLOT "StartSequenceOne()");
Qt::Object::connect(plotProfilesAction, SIGNAL "activated()", this, SLOT "PlotProfiles()");
Qt::Object::connect(helpAboutAction, SIGNAL "activated()", this, SLOT "OpenAboutWindow()");
Qt::Object::connect(fileOpenAction, SIGNAL "activated()", this, SLOT "OpenFile()");
Qt::Object::connect(fileSaveAction, SIGNAL "activated()", this, SLOT "SaveFile()");
Qt::Object::connect(fileSaveAsAction, SIGNAL "activated()", this, SLOT "SaveFileAs()");
Qt::Object::connect(AngleRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(SigAngleRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(plotFractionsAction, SIGNAL "activated()", this, SLOT "PlotFraction()");
Qt::Object::connect(GUIPathBrowse, SIGNAL "clicked()", this, SLOT "GUIPath()");
Qt::Object::connect(L1Comp, SIGNAL "textChanged(const QString&)", this, SLOT "findDensity()");
Qt::Object::connect(TrimBinBrowse, SIGNAL "clicked()", this, SLOT "TrimBin()");
Qt::Object::connect(GUIPathBrowse, SIGNAL "clicked()", this, SLOT "GUIPath()");
Qt::Object::connect(plotFractionsAction, SIGNAL "activated()", this, SLOT "PlotFraction()");
Qt::Object::connect(SigAngleRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(AngleRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(fileSaveAsAction, SIGNAL "activated()", this, SLOT "SaveFileAs()");
Qt::Object::connect(fileSaveAction, SIGNAL "activated()", this, SLOT "SaveFile()");
Qt::Object::connect(fileOpenAction, SIGNAL "activated()", this, SLOT "OpenFile()");
Qt::Object::connect(helpAboutAction, SIGNAL "activated()", this, SLOT "OpenAboutWindow()");
Qt::Object::connect(plotProfilesAction, SIGNAL "activated()", this, SLOT "PlotProfiles()");
Qt::Object::connect(fileStartAction, SIGNAL "activated()", this, SLOT "StartSequenceOne()");
Qt::Object::connect(ListRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(Quit, SIGNAL "clicked()", this, SLOT "ConfirmQuit()");
Qt::Object::connect(Browse, SIGNAL "clicked()", this, SLOT "DirectoryBrowse()");
Qt::Object::connect(ProjType, SIGNAL "activated(int)", this, SLOT "ProjSmartDefaults()");
Qt::Object::connect(NL, SIGNAL "valueChanged(int)", this, SLOT "PrepLayers()");
Qt::Object::connect(dRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(ScandL, SIGNAL "valueChanged(int)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(NProjRadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(SigERadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(ERadio, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(Start, SIGNAL "clicked()", this, SLOT "StartSequenceOne()");
Qt::Object::connect(ScanSeq, SIGNAL "toggled(bool)", this, SLOT "ToggleScanSingle()");
Qt::Object::connect(helpContentsAction, SIGNAL "activated()", this, SLOT "OpenHelpWindow()");
Qt::Object::connect(fileQuitAction, SIGNAL "activated()", this, SLOT "ConfirmQuit()");
Qt::Object::connect(fileChangeDirAction, SIGNAL "activated()", this, SLOT "DirectoryBrowse()");
Qt::Object::connect(L2Comp, SIGNAL "textChanged(const QString&)", this, SLOT "findDensity()");
Qt::Object::connect(L3Comp, SIGNAL "textChanged(const QString&)", this, SLOT "findDensity()");
Qt::Object::connect(L4Comp, SIGNAL "textChanged(const QString&)", this, SLOT "findDensity()");
Qt::Object::connect(L5Comp, SIGNAL "textChanged(const QString&)", this, SLOT "findDensity()");
Qt::Object::connect(L6Comp, SIGNAL "textChanged(const QString&)", this, SLOT "findDensity()");
Qt::Object::connect(L7Comp, SIGNAL "textChanged(const QString&)", this, SLOT "findDensity()");
setTabOrder(tabs, NL);
setTabOrder(NL, L1Comp);
@ -1998,13 +2006,13 @@ sub languageChange
textLabel3->setText( trUtf8("Density [g/cm<sup>3</sup>]") );
textLabel4->setText( trUtf8("Thickness [Å]") );
BoxL1->setTitle( trUtf8("Layer 1") );
L1Comp->setText( trUtf8("SrTiO3") );
Qt::ToolTip::add(L1Comp, trUtf8("Chemical formula of L1"));
Qt::WhatsThis::add(L1Comp, trUtf8("Insert the chemical formula here as you would write it."));
L1rho->setText( trUtf8("5.12") );
Qt::WhatsThis::add(L1rho, trUtf8("Insert the density of the layer here."));
L1d->setText( trUtf8("200") );
Qt::WhatsThis::add(L1d, trUtf8("Insert the thickness of the layer here."));
L1Comp->setText( trUtf8("SrTiO3") );
Qt::ToolTip::add(L1Comp, trUtf8("Chemical formula of L1"));
Qt::WhatsThis::add(L1Comp, trUtf8("Insert the chemical formula here as you would write it."));
BoxL2->setTitle( trUtf8("Layer 2") );
BoxL3->setTitle( trUtf8("Layer 3") );
BoxL4->setTitle( trUtf8("Layer 4") );
@ -3157,6 +3165,26 @@ sub TrimBin
}
sub findDensity
{
use Chem;
# Get sender name to know which layer
my $sender = sender()->name();
# Generate the name of the density field
my $rhoSender = substr($sender,0,2)."rho";
# Get the compound formula
my $Compound = sender() -> text();
# See if you have the density
my $Density=Chem::Densities($Compound);
if ($Density ne "") {
# If the density is in the database submit it
my $rho = child($rhoSender);
$rho -> setText($Density);
}
}
1;

View File

@ -222,28 +222,6 @@
<property name="title">
<string>Layer 1</string>
</property>
<widget class="QLineEdit">
<property name="name">
<cstring>L1Comp</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>180</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>SrTiO3</string>
</property>
<property name="toolTip" stdset="0">
<string>Chemical formula of L1</string>
</property>
<property name="whatsThis" stdset="0">
<string>Insert the chemical formula here as you would write it.</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>L1rho</cstring>
@ -290,6 +268,28 @@
<string>Insert the thickness of the layer here.</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>L1Comp</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>180</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>SrTiO3</string>
</property>
<property name="toolTip" stdset="0">
<string>Chemical formula of L1</string>
</property>
<property name="whatsThis" stdset="0">
<string>Insert the chemical formula here as you would write it.</string>
</property>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
@ -301,19 +301,6 @@
<property name="title">
<string>Layer 2</string>
</property>
<widget class="QLineEdit">
<property name="name">
<cstring>L2Comp</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>180</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>L2rho</cstring>
@ -348,6 +335,19 @@
</sizepolicy>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>L2Comp</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>180</width>
<height>25</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
@ -2662,49 +2662,109 @@
</images>
<connections>
<connection>
<sender>fileChangeDirAction</sender>
<signal>activated()</signal>
<sender>L1Comp</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>TrimSPGUI</receiver>
<slot>DirectoryBrowse()</slot>
<slot>findDensity()</slot>
</connection>
<connection>
<sender>fileQuitAction</sender>
<signal>activated()</signal>
<sender>TrimBinBrowse</sender>
<signal>clicked()</signal>
<receiver>TrimSPGUI</receiver>
<slot>ConfirmQuit()</slot>
<slot>TrimBin()</slot>
</connection>
<connection>
<sender>helpContentsAction</sender>
<signal>activated()</signal>
<sender>GUIPathBrowse</sender>
<signal>clicked()</signal>
<receiver>TrimSPGUI</receiver>
<slot>OpenHelpWindow()</slot>
<slot>GUIPath()</slot>
</connection>
<connection>
<sender>ScanSeq</sender>
<sender>plotFractionsAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>PlotFraction()</slot>
</connection>
<connection>
<sender>SigAngleRadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>Start</sender>
<signal>clicked()</signal>
<sender>AngleRadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>fileSaveAsAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>SaveFileAs()</slot>
</connection>
<connection>
<sender>fileSaveAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>SaveFile()</slot>
</connection>
<connection>
<sender>fileOpenAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>OpenFile()</slot>
</connection>
<connection>
<sender>helpAboutAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>OpenAboutWindow()</slot>
</connection>
<connection>
<sender>plotProfilesAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>PlotProfiles()</slot>
</connection>
<connection>
<sender>fileStartAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>StartSequenceOne()</slot>
</connection>
<connection>
<sender>ERadio</sender>
<sender>ListRadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>SigERadio</sender>
<signal>toggled(bool)</signal>
<sender>Quit</sender>
<signal>clicked()</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
<slot>ConfirmQuit()</slot>
</connection>
<connection>
<sender>NProjRadio</sender>
<sender>Browse</sender>
<signal>clicked()</signal>
<receiver>TrimSPGUI</receiver>
<slot>DirectoryBrowse()</slot>
</connection>
<connection>
<sender>ProjType</sender>
<signal>activated(int)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ProjSmartDefaults()</slot>
</connection>
<connection>
<sender>NL</sender>
<signal>valueChanged(int)</signal>
<receiver>TrimSPGUI</receiver>
<slot>PrepLayers()</slot>
</connection>
<connection>
<sender>dRadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
@ -2716,106 +2776,88 @@
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>dRadio</sender>
<sender>NProjRadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>NL</sender>
<signal>valueChanged(int)</signal>
<receiver>TrimSPGUI</receiver>
<slot>PrepLayers()</slot>
</connection>
<connection>
<sender>ProjType</sender>
<signal>activated(int)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ProjSmartDefaults()</slot>
</connection>
<connection>
<sender>Browse</sender>
<signal>clicked()</signal>
<receiver>TrimSPGUI</receiver>
<slot>DirectoryBrowse()</slot>
</connection>
<connection>
<sender>Quit</sender>
<signal>clicked()</signal>
<receiver>TrimSPGUI</receiver>
<slot>ConfirmQuit()</slot>
</connection>
<connection>
<sender>ListRadio</sender>
<sender>SigERadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>fileStartAction</sender>
<signal>activated()</signal>
<sender>ERadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>Start</sender>
<signal>clicked()</signal>
<receiver>TrimSPGUI</receiver>
<slot>StartSequenceOne()</slot>
</connection>
<connection>
<sender>plotProfilesAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>PlotProfiles()</slot>
</connection>
<connection>
<sender>helpAboutAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>OpenAboutWindow()</slot>
</connection>
<connection>
<sender>fileOpenAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>OpenFile()</slot>
</connection>
<connection>
<sender>fileSaveAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>SaveFile()</slot>
</connection>
<connection>
<sender>fileSaveAsAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>SaveFileAs()</slot>
</connection>
<connection>
<sender>AngleRadio</sender>
<sender>ScanSeq</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>SigAngleRadio</sender>
<signal>toggled(bool)</signal>
<receiver>TrimSPGUI</receiver>
<slot>ToggleScanSingle()</slot>
</connection>
<connection>
<sender>plotFractionsAction</sender>
<sender>helpContentsAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>PlotFraction()</slot>
<slot>OpenHelpWindow()</slot>
</connection>
<connection>
<sender>GUIPathBrowse</sender>
<signal>clicked()</signal>
<sender>fileQuitAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>GUIPath()</slot>
<slot>ConfirmQuit()</slot>
</connection>
<connection>
<sender>TrimBinBrowse</sender>
<signal>clicked()</signal>
<sender>fileChangeDirAction</sender>
<signal>activated()</signal>
<receiver>TrimSPGUI</receiver>
<slot>TrimBin()</slot>
<slot>DirectoryBrowse()</slot>
</connection>
<connection>
<sender>L2Comp</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>TrimSPGUI</receiver>
<slot>findDensity()</slot>
</connection>
<connection>
<sender>L3Comp</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>TrimSPGUI</receiver>
<slot>findDensity()</slot>
</connection>
<connection>
<sender>L4Comp</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>TrimSPGUI</receiver>
<slot>findDensity()</slot>
</connection>
<connection>
<sender>L5Comp</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>TrimSPGUI</receiver>
<slot>findDensity()</slot>
</connection>
<connection>
<sender>L6Comp</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>TrimSPGUI</receiver>
<slot>findDensity()</slot>
</connection>
<connection>
<sender>L7Comp</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>TrimSPGUI</receiver>
<slot>findDensity()</slot>
</connection>
</connections>
<tabstops>
@ -2900,6 +2942,7 @@
<slot>SaveFileAs()</slot>
<slot>GUIPath()</slot>
<slot>TrimBin()</slot>
<slot>findDensity()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -1009,3 +1009,22 @@ void TrimSPGUI::TrimBin()
TRIMBIN->setText($file);
return $file;
}
void TrimSPGUI::findDensity()
{
use Chem;
# Get sender name to know which layer
my $sender = sender()->name();
# Generate the name of the density field
my $rhoSender = substr($sender,0,2)."rho";
# Get the compound formula
my $Compound = sender() -> text();
# See if you have the density
my $Density=Chem::Densities($Compound);
if ($Density ne "") {
# If the density is in the database submit it
my $rho = child($rhoSender);
$rho -> setText($Density);
}
}