TrimSPGUI ported to Perl-Qt4. Still needs testing.

This commit is contained in:
salman 2013-01-31 14:49:26 +00:00
parent a1dad1c0c0
commit fce7e9075a
16 changed files with 6865 additions and 0 deletions

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

636
trimsp/TrimSPGUI4/Chem.pm Normal file
View File

@ -0,0 +1,636 @@
# This file is part of TrimSPGUI.
#
# TrimSPGUI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# TrimSPGUI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2009 by Zaher Salman and the LEM Group.
package Chem;
sub parse_formula {
my ($formula) = @_;
# print STDOUT "formula=$formula\n";
my (%elements);
#check balancing
return %elements if (!ParensBalanced($formula));
# replace other grouping with normal parens
$formula =~ tr/<>{}[]/()()()/;
# get rid of any spaces
$formula =~ s/\s+//g;
# perform macro expansion
foreach (keys(%macros)) {
$formula =~ s/$_/$macros{$_}/g;
}
# determine initial compound coeficent
my $coef = ($formula =~ s/^(\d+\.?\d*)//) ? $1 : 1.0;
# recursively process rest of formula
return internal_formula_parser($formula, $coef, %elements);
}
sub internal_formula_parser {
use Text::Balanced qw(extract_bracketed);
my ($formula, $coef, %form) = @_;
my $tmp_coef;
my ($extract, $remainder, $prefix) =
extract_bracketed($formula, '()', '[^(]*');
if (defined($extract) and $extract ne '') {
$extract =~ s/^\((.*)\)$/$1/;
if ($remainder =~ s/^(\d+\.?\d*)(.*)$/$2/) {
$tmp_coef = $1 * $coef;
} else {
$tmp_coef = $coef;
}
# get formula of prefix ( it has no parens)
%form = add_formula_strings($prefix, $coef, %form) if ($prefix ne '');
# check remainder for more parens
%form = internal_formula_parser($remainder, $coef, %form)
if ($remainder ne '');
# check extract for more parens
%form =
internal_formula_parser($extract, $tmp_coef, %form);
## we already know this is ne ''
} else { # get formula of complete string
%form = add_formula_strings($remainder, $coef, %form)
if ($remainder ne '');
}
return %form;
}
sub add_formula_strings {
my ($formula, $coef, %elements) = @_;
# print "Getting Formula of $formula\n";
$formula =~ /^(?:([A-Z][a-z]*)(\d+\.?\d*)?)+$/o # XXX new
or die "Invalid Portion of Formula $formula";
while ($formula =~ m/([A-Z][a-z]*)(\d+\.?\d*)?/go) { # XXX new
my ($elm, $count) = ($1, $2);
$count = 1 unless defined $count;
if (defined $elements{$elm}) {
$elements{$elm} += $count * $coef;
} else {
$elements{$elm} = $count * $coef;
}
}
return %elements;
}
sub ParensBalanced {
my ($form) = @_;
my @stack = ();
my %pairs = (
'<' => '>',
'{' => '}',
'[' => ']',
'(' => ')'
);
while ($form =~ m/([<>(){}\]\[])/go) {
my $current = $1;
if ($current =~ /[<({\[]/) {
push(@stack, $current);
next;
}
return 0 if (scalar(@stack) == 0);
return 0 if ($current ne $pairs{ pop @stack});
}
return @stack ? 0 : 1;
}
sub Zof {
my ($El) = @_;
my %ElementsZ = (
"Muon",1,
"Li8", 3,
"B12", 5,
"H",1,
"He", 2,
"Li", 3,
"Be", 4,
"B", 5,
"C", 6,
"N", 7,
"O", 8,
"F", 9,
"Ne", 10,
"Na", 11,
"Mg", 12,
"Al", 13,
"Si", 14,
"P", 15,
"S", 16,
"Cl", 17,
"Ar", 18,
"K", 19,
"Ca", 20,
"Sc", 21,
"Ti", 22,
"V", 23,
"Cr", 24,
"Mn", 25,
"Fe", 26,
"Co", 27,
"Ni", 28,
"Cu", 29,
"Zn", 30,
"Ga", 31,
"Ge", 32,
"As", 33,
"Se", 34,
"Br", 35,
"Kr", 36,
"Rb", 37,
"Sr", 38,
"Y", 39,
"Zr", 40,
"Nb", 41,
"Mo", 42,
"Tc", 43,
"Ru", 44,
"Rh", 45,
"Pd", 46,
"Ag", 47,
"Cd", 48,
"In", 49,
"Sn", 50,
"Sb", 51,
"Te", 52,
"I", 53,
"Xe", 54,
"Cs", 55,
"Ba", 56,
"La", 57,
"Ce", 58,
"Pr", 59,
"Nd", 60,
"Pm", 61,
"Sm", 62,
"Eu", 63,
"Gd", 64,
"Tb", 65,
"Dy", 66,
"Ho", 67,
"Er", 68,
"Tm", 69,
"Yb", 70,
"Lu", 71,
"Hf", 72,
"Ta", 73,
"W", 74,
"Re", 75,
"Os", 76,
"Ir", 77,
"Pt", 78,
"Au", 79,
"Hg", 80,
"Tl", 81,
"Pb", 82,
"Bi", 83,
"Po", 84,
"At", 85,
"Rn", 86,
"Fr", 87,
"Ra", 88,
"Ac", 89,
"Th", 90,
"Pa", 91,
"U", 92,
"", 0.0000
);
return $ElementsZ{$El};
}
sub Massof {
my ($El) = @_;
my %ElementsA = (
"Muon",0.113,
"Li8", 8.0,
"B12", 12.0,
"H", 1.00800,
"He", 4.00300,
"Li", 6.93900,
"Be", 9.01200,
"B", 10.81100,
"C", 12.01100,
"N", 14.00700,
"O", 15.99900,
"F", 18.99800,
"Ne", 20.18300,
"Na", 22.99000,
"Mg", 24.31200,
"Al", 26.98200,
"Si", 28.08600,
"P", 30.97400,
"S", 32.06400,
"Cl", 35.45300,
"Ar", 39.94800,
"K", 39.10200,
"Ca", 40.08000,
"Sc", 44.95600,
"Ti", 47.90000,
"V", 50.94200,
"Cr", 51.99600,
"Mn", 54.93800,
"Fe", 55.84700,
"Co", 58.93300,
"Ni", 58.71000,
"Cu", 63.54000,
"Zn", 65.37000,
"Ga", 69.72000,
"Ge", 72.59000,
"As", 74.92200,
"Se", 78.96000,
"Br", 79.90900,
"Kr", 83.80000,
"Rb", 85.47000,
"Sr", 87.62000,
"Y", 88.90500,
"Zr", 91.22000,
"Nb", 92.90600,
"Mo", 95.94000,
"Tc", 98.00000,
"Ru", 101.07000,
"Rh", 102.90500,
"Pd", 106.40000,
"Ag", 107.87000,
"Cd", 112.40000,
"In", 114.82000,
"Sn", 118.69000,
"Sb", 121.75000,
"Te", 127.60000,
"I", 126.90400,
"Xe", 131.30000,
"Cs", 132.90500,
"Ba", 137.34000,
"La", 138.91000,
"Ce", 140.12000,
"Pr", 140.90700,
"Nd", 144.24001,
"Pm", 147.00000,
"Sm", 150.35001,
"Eu", 151.96001,
"Gd", 157.25000,
"Tb", 158.92400,
"Dy", 162.50000,
"Ho", 164.92999,
"Er", 167.25999,
"Tm", 168.93401,
"Yb", 173.03999,
"Lu", 174.97000,
"Hf", 178.49001,
"Ta", 180.94800,
"W", 183.85001,
"Re", 186.20000,
"Os", 190.20000,
"Ir", 192.20000,
"Pt", 195.09000,
"Au", 196.96700,
"Hg", 200.59000,
"Tl", 204.37000,
"Pb", 207.19000,
"Bi", 208.98000,
"Po", 210.00000,
"At", 210.00000,
"Rn", 222.00000,
"Fr", 223.00000,
"Ra", 226.00000,
"Ac", 227.00000,
"Th", 232.03799,
"Pa", 231.00000,
"U", 238.03000,
"", 0.0000
);
return $ElementsA{$El};
}
sub Dichteof {
my ($El) = @_;
my %Dichte = (
"H", 0.08,
"He", 0.12,
"Li", 0.53,
"Be", 1.85,
"B", 2.35,
"C", 3.51,
"N", 1.03,
"O", 2.00,
"F", 1.11,
"Ne", 1.50,
"Na", 0.97,
"Mg", 1.74,
"Al", 2.70,
"Si", 2.33,
"P", 1.00,
"S", 2.07,
"Cl", 2.03,
"Ar", 1.77,
"K", 0.86,
"Ca", 1.54,
"Sc", 2.99,
"Ti", 4.51,
"V", 6.09,
"Cr", 7.14,
"Mn", 7.44,
"Fe", 7.87,
"Co", 8.89,
"Ni", 8.91,
"Cu", 8.92,
"Zn", 7.14,
"Ga", 5.91,
"Ge", 5.32,
"As", 5.72,
"Se", 4.19,
"Br", 3.14,
"Kr", 3.10,
"Rb", 1.53,
"Sr", 2.63,
"Y", 4.47,
"Zr", 6.51,
"Nb", 8.58,
"Mo", 10.28,
"Tc", 11.49,
"Ru", 12.45,
"Rh", 12.41,
"Pd", 12.02,
"Ag", 10.49,
"Cd", 8.64,
"In", 7.31,
"Sn", 7.29,
"Sb", 6.69,
"Te", 6.25,
"I", 4.94,
"Xe", 3.80,
"Cs", 1.90,
"Ba", 3.65,
"La", 6.16,
"Ce", 6.77,
"Pr", 6.48,
"Nd", 7.00,
"Pm", 7.22,
"Sm", 7.54,
"Eu", 5.25,
"Gd", 7.89,
"Tb", 8.25,
"Dy", 8.56,
"Ho", 8.78,
"Er", 9.05,
"Tm", 9.32,
"Yb", 6.97,
"Lu", 9.84,
"Hf", 13.31,
"Ta", 16.68,
"W", 19.26,
"Re", 21.03,
"Os", 22.61,
"Ir", 22.65,
"Pt", 21.45,
"Au", 19.32,
"Hg", 13.55,
"Tl", 11.85,
"Pb", 11.34,
"Bi", 9.80,
"Po", 9.20,
"At", 0.10,
"Rn", 0.10,
"Fr", 0.10,
"Ra", 5.50,
"Ac", 10.07,
"Th", 11.72,
"Pa", 15.37,
"U", 18.97,
"", 0.0000
);
return $Dichte{$El};
}
sub Elastof {
my ($El) = @_;
my %Elast = (
"H", 0.10000,
"He", 0.10000,
"Li", 1.63000,
"Be", 3.32000,
"B", 5.77000,
"C", 7.37000,
"N", 4.92000,
"O", 2.60000,
"F", 0.84000,
"Ne", 0.02000,
"Na", 1.11000,
"Mg", 1.51000,
"Al", 3.39000,
"Si", 4.63000,
"P", 3.43000,
"S", 2.85000,
"Cl", 1.40000,
"Ar", 0.08000,
"K", 0.93000,
"Ca", 1.84000,
"Sc", 3.90000,
"Ti", 4.85000,
"V", 5.31000,
"Cr", 4.10000,
"Mn", 2.92000,
"Fe", 4.28000,
"Co", 4.39000,
"Ni", 4.44000,
"Cu", 3.49000,
"Zn", 1.35000,
"Ga", 2.81000,
"Ge", 3.85000,
"As", 2.96000,
"Se", 2.25000,
"Br", 1.22000,
"Kr", 0.12000,
"Rb", 0.85000,
"Sr", 1.72000,
"Y", 4.37000,
"Zr", 6.25000,
"Nb", 7.57000,
"Mo", 6.82000,
"Tc", 6.85000,
"Ru", 6.74000,
"Rh", 5.75000,
"Pd", 3.89000,
"Ag", 2.95000,
"Cd", 1.16000,
"In", 2.52000,
"Sn", 3.14000,
"Sb", 2.75000,
"Te", 2.23000,
"I", 1.11000,
"Xe", 0.16000,
"Cs", 0.80000,
"Ba", 1.90000,
"La", 4.47000,
"Ce", 4.32000,
"Pr", 3.70000,
"Nd", 3.40000,
"Pm", 0.10000,
"Sm", 2.14000,
"Eu", 1.86000,
"Gd", 4.14000,
"Tb", 4.05000,
"Dy", 3.04000,
"Ho", 3.14000,
"Er", 3.29000,
"Tm", 2.42000,
"Yb", 1.60000,
"Lu", 4.43000,
"Hf", 6.44000,
"Ta", 8.10000,
"W", 8.90000,
"Re", 8.03000,
"Os", 8.17000,
"Ir", 6.94000,
"Pt", 5.84000,
"Au", 3.81000,
"Hg", 0.67000,
"Tl", 1.88000,
"Pb", 2.03000,
"Bi", 2.18000,
"Po", 1.50000,
"At", 0.10000,
"Rn", 0.20000,
"Fr", 0.10000,
"Ra", 1.66000,
"Ac", 4.25000,
"Th", 6.20000,
"Pa", 0.10000,
"U", 5.55000,
"", 0.00000
);
return $Elast{$El};
}
sub Stopicru {
my ($El) = @_;
my %Stopicru = (
"H", "1.25400,1.44000,242.60001,12000.00000,0.11590",
"He", "1.22900,1.39700,484.50000,5873.00000,0.05225",
"Li", "1.41100,1.60000,725.59998,3013.00000,0.04578",
"Be", "2.24800,2.59000,966.00000,153.80000,0.03475",
"B", "2.47400,2.81500,1206.00000,1060.00000,0.02855",
"C", "2.60100,2.60100,1701.00000,1279.00000,0.01638",
"N", "2.95400,3.35000,1683.00000,1900.00000,0.02513",
"O", "2.65200,3.00000,1920.00000,2000.00000,0.02230",
"F", "2.08500,2.35200,2157.00000,2634.00000,0.01816",
"Ne", "1.95100,2.19900,2393.00000,2699.00000,0.01568",
"Na", "2.54200,2.86900,2628.00000,1854.00000,0.01472",
"Mg", "3.79100,4.29300,2862.00000,1009.00000,0.01397",
"Al", "4.15400,4.73900,2766.00000,164.50000,0.02023",
"Si", "4.91400,5.59800,3193.00000,232.70000,0.01419",
"P", "3.23200,3.64700,3561.00000,1560.00000,0.01267",
"S", "3.44700,3.89100,3792.00000,1219.00000,0.01211",
"Cl", "5.30100,6.00800,3969.00000,645.09998,0.01183",
"Ar", "5.73100,6.50000,4253.00000,530.00000,0.01123",
"K", "5.15200,5.83300,4482.00000,545.70001,0.01129",
"Ca", "5.52100,6.25200,4710.00000,553.29999,0.01120",
"Sc", "5.20100,5.88400,4938.00000,560.90002,0.01000",
"Ti", "4.85800,5.48900,5260.00000,651.09998,0.00893",
"V", "4.47900,5.05500,5391.00000,952.29999,0.00912",
"Cr", "3.98300,4.48900,5616.00000,1336.00000,0.00841",
"Mn", "3.46900,3.90700,5725.00000,1461.00000,0.00883",
"Fe", "3.51900,3.96300,6065.00000,1243.00000,0.00778",
"Co", "3.14000,3.53500,6288.00000,1372.00000,0.00736",
"Ni", "3.55300,4.00400,6205.00000,555.09998,0.00876",
"Cu", "3.69600,4.19400,4649.00000,81.13000,0.02242",
"Zn", "4.21000,4.75000,6953.00000,295.20001,0.00681",
"Ga", "5.04100,5.69700,7137.00000,202.60001,0.00673",
"Ge", "5.55400,6.30000,6496.00000,110.00000,0.00969",
"As", "5.32300,6.01200,7611.00000,292.50000,0.00645",
"Se", "5.87400,6.65600,7395.00000,117.50000,0.00768",
"Br", "6.65800,7.53600,7694.00000,222.30000,0.00651",
"Kr", "6.41300,7.24000,11850.00000,153.70000,0.00288",
"Rb", "5.69400,6.42900,8478.00000,292.89999,0.00609",
"Sr", "6.33900,7.15900,8693.00000,330.29999,0.00600",
"Y", "6.40700,7.23400,8907.00000,367.79999,0.00589",
"Zr", "6.73400,7.60300,9120.00000,405.20001,0.00576",
"Nb", "6.90100,7.79100,9333.00000,442.70001,0.00559",
"Mo", "6.42400,7.24800,9545.00000,480.20001,0.00538",
"Tc", "6.79900,7.67100,9756.00000,517.59998,0.00532",
"Ru", "6.10900,6.88700,9966.00000,555.09998,0.00515",
"Rh", "5.92400,6.67700,10180.00000,592.50000,0.00492",
"Pd", "5.23800,5.90000,10380.00000,630.00000,0.00476",
"Ag", "5.34500,6.03800,6790.00000,397.79999,0.01676",
"Cd", "5.81400,6.55400,10800.00000,355.50000,0.00463",
"In", "6.22900,7.02400,11010.00000,370.89999,0.00454",
"Sn", "6.40900,7.22700,11210.00000,386.39999,0.00447",
"Sb", "7.50000,8.48000,8608.00000,348.00000,0.00907",
"Te", "6.97900,7.87100,11620.00000,392.39999,0.00440",
"I", "7.72500,8.71600,11830.00000,394.79999,0.00438",
"Xe", "8.33700,9.42500,10510.00000,269.60001,0.00621",
"Cs", "7.28700,8.21800,12230.00000,399.70001,0.00445",
"Ba", "7.89900,8.91100,12430.00000,402.10001,0.00451",
"La", "8.04100,9.07100,12630.00000,404.50000,0.00454",
"Ce", "7.48800,8.44400,12830.00000,406.89999,0.00442",
"Pr", "7.29100,8.21900,13030.00000,409.29999,0.00430",
"Nd", "7.09800,8.00000,13230.00000,411.79999,0.00418",
"Pm", "6.90900,7.78600,13430.00000,414.20001,0.00406",
"Sm", "6.72800,7.58000,13620.00000,416.60001,0.00398",
"Eu", "6.55100,7.38000,13820.00000,419.00000,0.00388",
"Gd", "6.73900,7.59200,14020.00000,421.39999,0.00386",
"Tb", "6.21200,6.99600,14210.00000,423.89999,0.00372",
"Dy", "5.51700,6.21000,14400.00000,426.29999,0.00363",
"Ho", "5.22000,5.87400,14600.00000,428.70001,0.00350",
"Er", "5.07100,5.70600,14790.00000,433.00000,0.00341",
"Tm", "4.92600,5.54200,14980.00000,433.50000,0.00334",
"Yb", "4.78800,5.38600,15170.00000,435.89999,0.00329",
"Lu", "4.89300,5.50500,15360.00000,438.29999,0.00324",
"Hf", "5.02800,5.65700,15550.00000,440.79999,0.00320",
"Ta", "4.73800,5.32900,15740.00000,443.20001,0.00319",
"W", "4.58700,5.16000,15410.00000,415.29999,0.00341",
"Re", "5.20100,5.85100,16120.00000,441.60001,0.00312",
"Os", "5.07100,5.70400,16300.00000,440.89999,0.00308",
"Ir", "4.94600,5.56300,16490.00000,440.10001,0.00296",
"Pt", "4.47700,5.03400,16670.00000,439.29999,0.00287",
"Au", "4.84400,5.45800,7852.00000,975.79999,0.02077",
"Hg", "4.30700,4.84300,17040.00000,487.79999,0.00288",
"Tl", "4.72300,5.31100,17220.00000,537.00000,0.00291",
"Pb", "5.31900,5.98200,17400.00000,586.29999,0.00287",
"Bi", "5.95600,6.70000,17800.00000,677.00000,0.00266",
"Po", "6.15800,6.92800,17770.00000,586.29999,0.00281",
"At", "6.20300,6.97900,17950.00000,586.29999,0.00278",
"Rn", "6.18100,6.95400,18120.00000,586.29999,0.00275",
"Fr", "6.94900,7.82000,18300.00000,586.29999,0.00274",
"Ra", "7.50600,8.44800,18480.00000,586.29999,0.00273",
"Ac", "7.64800,8.60900,18660.00000,586.29999,0.00270",
"Th", "7.71100,8.67900,18830.00000,586.29999,0.00264",
"Pa", "7.40700,8.33600,19010.00000,586.29999,0.00260",
"U", "7.29000,8.20400,19180.00000,586.29999,0.00267",
"", "0.00000,0.00000,0.00000,0.00000,0.00000"
);
return $Stopicru{$El};
}
1;

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

6
trimsp/TrimSPGUI4/TrimSP Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
# Copyright 2009-2013 by Zaher Salman and the LEM Group.
export TRIMBIN=$HOME/bin/trimsp7l
export PERLLIB=$HOME/LEM/simulation/trimsp/TrimSPGUI4
perl $HOME/LEM/simulation/trimsp/TrimSPGUI4/TrimSPGUI.pl

View File

@ -0,0 +1,50 @@
[Layers]
numLayer=1
layer1Comp=SrTiO3
layer1rho=5.12
layer1d=200
layer2Comp=
layer2rho=
layer2d=
layer3Comp=
layer3rho=
layer3d=
layer4Comp=
layer4rho=
layer4d=
layer5Comp=
layer5rho=
layer5d=
layer6Comp=
layer6rho=
layer6d=
layer7Comp=
layer7rho=
layer7d=
[ProjectileParameters]
projType=0
numberProj= 10000
z0= 0.00
dz= 10.00
valEnergy= 2000.00
sigEnergy= 450.00
valAngle= 0.00
sigAngle= 15.00
ranSeed= 78741.
[Files]
fileNamePrefix=SrTiO3
workPath=./
[ScanSequence]
scanSeq=
comboScano=
radioList=
scanList=1000,6000,10000
scanListdz=
radioLoop=1
scanFrom=1000
scanTo=28000
scanStep=1000

17
trimsp/TrimSPGUI4/TrimSP.pl Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/perl
use strict;
use warnings;
use QtCore4;
use QtGui4;
use TrimSPGUI4;
sub main {
my $app = Qt::Application(\@ARGV);
my $calculator = TrimSPGUI4();
$calculator->show();
exit $app->exec();
}
exit main();

View File

@ -0,0 +1,932 @@
package TrimSPGUI4;
use strict;
#use warnings;
use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::MainWindow );
use QtCore4::isa qw( Qt::Widget );
use Ui_TrimSPGUI4;
use QtCore4::slots
# test => [],
ToggleScanSingle => [],
PrepLayers => [],
ProjSmartDefaults => [],
helpAboutAction => [],
helpContentsAction => [],
CollectValues => [],
CreateInpFile => [],
StartSequenceOne => [],
DirectoryBrowse => [],
ConfirmQuit => [],
PlotProfiles => [],
PlotFraction => [],
OpenFile => [],
SaveFile => [],
SaveFileAs => [];
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
sub child {
# Take type and name from input
my ( $object, $name ) = @_;
my $Attrib = this->findChildren($object, $name);
$Attrib = @{$Attrib}[0];
# Return handle on widget
return $Attrib
}
# Subroutine: Toggle between scan/single run mode and setup scans tab
sub ToggleScanSingle()
{
# First collect some information
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();
$All{"radioList"}=this->{ui}->radioList->isChecked();
$All{"radioLoop"}=this->{ui}->radioLoop->isChecked();
# Enable everything
this->{ui}->valEnergy->setDisabled(0);
this->{ui}->sigEnergy->setDisabled(0);
this->{ui}->valAngle->setDisabled(0);
this->{ui}->sigAngle->setDisabled(0);
this->{ui}->numberProj->setDisabled(0);
this->{ui}->scandL->setHidden(1);
if ($All{"comboScan"}==5) {
this->{ui}->scandL->setHidden(0);
this->{ui}->scandL->setDisabled(0);
}
# Enable depth increment for Energy scan
if ($All{"radioList"}) {
this->{ui}->scanList->setDisabled(0);
this->{ui}->scanFrom->setDisabled(1);
this->{ui}->scanTo->setDisabled(1);
this->{ui}->scanStep->setDisabled(1);
if ($All{"comboScan"}==0) {
this->{ui}->dzListLabel->setHidden(0);
this->{ui}->scanListdz->setHidden(0);
this->{ui}->dzListLabel->setDisabled(0);
this->{ui}->scanListdz->setDisabled(0);
this->{ui}->dzListLabel->setText("Corresponding depth increment (optional)");
# Enable energy change sigma angle scans
} elsif ($All{"comboScan"}==3) {
this->{ui}->dzListLabel->setHidden(0);
this->{ui}->scanListdz->setHidden(0);
this->{ui}->dzListLabel->setDisabled(0);
this->{ui}->scanListdz->setDisabled(0);
this->{ui}->dzListLabel->setText("Corresponding energy");
} else {
# Otherwise keep it hidden
this->{ui}->dzListLabel->setHidden(1);
this->{ui}->scanListdz->setHidden(1);
this->{ui}->dzListLabel->setDisabled(1);
this->{ui}->scanListdz->setDisabled(1);
}
} elsif ($All{"radioLoop"}) {
this->{ui}->scanList->setDisabled(1);
this->{ui}->scanFrom->setDisabled(0);
this->{ui}->scanTo->setDisabled(0);
this->{ui}->scanStep->setDisabled(0);
this->{ui}->dzListLabel->setHidden(1);
this->{ui}->scanListdz->setHidden(1);
this->{ui}->dzListLabel->setDisabled(1);
this->{ui}->scanListdz->setDisabled(1);
}
# Start by enabling everything on the first tab
this->{ui}->valEnergy->setDisabled(0);
this->{ui}->sigEnergy->setDisabled(0);
this->{ui}->valAngle->setDisabled(0);
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);
}
if ($All{"scanSeq"}) {
# Change title of tab to say enabled
this->{ui}->tabs->setTabText(2,"Scans (Enabled)");
# If scanning layer thickness make sure it is actually defined
if ($All{"scandL"} > $All{"numLayer"}) {
Qt::MessageBox::warning( this, "Warning!","Define layers first!");
}
# Disable the appropriate box in the first tab.
if ($All{"comboScan"}==0) {
this->{ui}->valEnergy->setDisabled(1);
} elsif ($All{"comboScan"}==1) {
this->{ui}->sigEnergy->setDisabled(1);
} elsif ($All{"comboScan"}==2) {
this->{ui}->valAngle->setDisabled(1);
} elsif ($All{"comboScan"}==3) {
this->{ui}->sigAngle->setDisabled(1);
} 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);
}
} else {
# Otherwise the title of the tab says disabled
this->{ui}->tabs->setTabText(2,"Scans (Disabled)");
}
}
# Subroutine: Enable layers up to required and disable the rest
sub PrepLayers()
{
my %All=();
# Get number of layers to define
$All{"numLayer"}=this->{ui}->numLayer->value();
# Enable required number
for (my $i=2;$i<=7;$i++) {
my $LayerName = "boxL".$i;
my $LayerAttrib = child("Qt::GroupBox",$LayerName);
if ($i<=$All{"numLayer"}) {
$LayerAttrib->setDisabled(0);
} else {
$LayerAttrib->setDisabled(1);
}
}
}
# Subroutine: Set sane default values for projectile energy distribution and angles
sub ProjSmartDefaults()
{
my %All=();
# Get typeof projectile
$All{"projComboBox"}=this->{ui}->projComboBox->currentIndex();
if ($All{"projComboBox"}==0) {
# For a muon set Sigma E=450 eV and Sigman angle=15 degrees by default
this->{ui}->sigEnergy->setText("450");
this->{ui}->sigAngle->setText("15");
} else {
# For Li8 (or ions) set Sigma E=0 eV and Sigam angle=0 degrees by default
this->{ui}->sigEnergy->setText("0");
this->{ui}->sigAngle->setText("0");
}
}
# Function: Returns a hash with all the values collected from the GUI.
sub CollectValues()
{
my %All=();
$All{"numLayer"}=this->{ui}->numLayer->value();
# Collect layers parameters
for (my $i=1;$i<=$All{"numLayer"};$i++) {
my $LComp = "layer".$i."Comp";
my $Lrho="layer".$i."rho";
my $Ld="layer".$i."d";
my $LCompAttrib = child("Qt::LineEdit",$LComp);
my $LrhoAttrib = child("Qt::LineEdit",$Lrho);
my $LdAttrib = child("Qt::LineEdit",$Ld);
$All{"$LComp"}=$LCompAttrib->text();
$All{"$Lrho"}=$LrhoAttrib->text();
$All{"$Ld"}=$LdAttrib->text();
}
# Collect projectile parameters
$All{"projComboBox"}=this->{ui}->projComboBox->currentIndex();
$All{"numberProj"}=this->{ui}->numberProj->text();
if ($All{"numberProj"}==0) {
$All{"numberProj"}=10000;
this->{ui}->numberProj->setText("10000");
}
$All{"z0"}=this->{ui}->z0->text();
$All{"dz"}=this->{ui}->dz->text();
$All{"valEnergy"}=this->{ui}->valEnergy->text();
$All{"sigEnergy"}=this->{ui}->sigEnergy->text();
$All{"valAngle"}=this->{ui}->valAngle->text();
$All{"sigAngle"}=this->{ui}->sigAngle->text();
$All{"ranSeed"}=this->{ui}->ranSeed->text();
# Format projectile parameters
$All{"numberProj"}=sprintf("%8d",$All{"numberProj"});
$All{"z0"}=sprintf("%6.2f",$All{"z0"});
$All{"dz"}=sprintf("%6.2f",$All{"dz"});
$All{"valEnergy"}=sprintf("%11.2f",$All{"valEnergy"});
$All{"sigEnergy"}=sprintf("%8.2f",$All{"sigEnergy"});
$All{"valAngle"}=sprintf("%8.2f",$All{"valAngle"});
$All{"sigAngle"}=sprintf("%8.2f",$All{"sigAngle"});
$All{"ranSeed"}=sprintf("%6.0f.",$All{"ranSeed"});
# Collect the additional parameters
$All{"parEF"}=this->{ui}->parEF->text();
$All{"parESB"}=this->{ui}->parESB->text();
$All{"parSHEATH"}=this->{ui}->parSHEATH->text();
$All{"parERC"}=this->{ui}->parERC->text();
$All{"parRD"}=this->{ui}->parRD->text();
$All{"parCA"}=this->{ui}->parCA->text();
$All{"parKK0"}=this->{ui}->parKK0->text();
$All{"parKK0R"}=this->{ui}->parKK0R->text();
$All{"parKDEE1"}=this->{ui}->parKDEE1->text();
$All{"parKDEE2"}=this->{ui}->parKDEE2->text();
$All{"parIPOT"}=this->{ui}->parIPOT->text();
$All{"parIPOTR"}=this->{ui}->parIPOTR->text();
$All{"parIRL"}=this->{ui}->parIRL->text();
# format additional parameters
$All{"parEF"}=sprintf("%8.2f",$All{"parEF"});
$All{"parESB"}=sprintf("%8.2f",$All{"parESB"});
$All{"parSHEATH"}=sprintf("%8.2f",$All{"parSHEATH"});
$All{"parERC"}=sprintf("%8.2f",$All{"parERC"});
$All{"parRD"}=sprintf("%5.0f.",$All{"parRD"});
$All{"parCA"}=sprintf("%6.2f",$All{"parCA"});
$All{"parKK0"}=sprintf("%3d",$All{"parKK0"});
$All{"parKK0R"}=sprintf("%3d",$All{"parKK0R"});
$All{"parKDEE1"}=sprintf("%3d",$All{"parKDEE1"});
$All{"parKDEE2"}=sprintf("%3d",$All{"parKDEE2"});
$All{"parIPOT"}=sprintf("%3d",$All{"parIPOT"});
$All{"parIPOTR"}=sprintf("%3d",$All{"parIPOTR"});
$All{"parIRL"}=sprintf("%2d",$All{"parIRL"});
# Filenames etc. The filename should not have white spaces
$All{"fileNamePrefix"}=this->{ui}->fileNamePrefix->text();
$All{"fileNamePrefix"}=~ s/\s+//g;
$All{"workPath"}=this->{ui}->workPath->text();
# Scan parameters only if selected
$All{"scanSeq"}=this->{ui}->scanSeq->isChecked();
$All{"comboScan"}=this->{ui}->comboScan->currentIndex();
$All{"scandL"}=this->{ui}->scandL->value();
$All{"radioList"}=this->{ui}->radioList->isChecked();
$All{"radioLoop"}=this->{ui}->radioLoop->isChecked();
$All{"scanList"}=this->{ui}->scanList->text();
# Remove any white spaces
$All{"scanList"} =~ s/\s+//g;
$All{"scanListdz"}=this->{ui}->scanListdz->text();
# Remove any white spaces
$All{"scanListdz"} =~ s/\s+//g;
# These should be numeric
$All{"scanFrom"}=this->{ui}->scanFrom->text();
$All{"scanTo"}=this->{ui}->scanTo->text();
$All{"scanStep"}=this->{ui}->scanStep->text();
$All{"scanFrom"}=1*$All{"scanFrom"};
$All{"scanTo"}=1*$All{"scanTo"};
$All{"scanStep"}=1*$All{"scanStep"};
# Return values to caller
return %All;
}
# Function: Create and return input file for the Trim.SP simulation
# binary
sub CreateInpFile()
{
# use lib '$ENV{HOME}/Projects/TrimSPGUI/Chem';
# push @INC, "$ENV{HOME}/Projects/TrimSPGUI";
use Chem;
# The proper way I think is not to have scan sequences implimented
# here but rather call this multiple times to generate the scan. To
# achieve this, the function CreateInpFile will expect a unique
# thickness for each layer, one energy value, one energy sigma and one
# projectile number. These will be stored in keys layer1/2/3/4/5/6/7d,
# valEnergy, sigEnergy and numberProj, respectively.
# Chemical formulas will be parsed on the fly for each layer. However,
# I will check if all the layers have inputs for composition,
# thickness and density. If not complain and stop :)
# Values of Z,A as well as other needed parameters are obtained from
# Chem.pm.
# This is the form of the input file:
my $TemplateFile=
" ProjZ ProjAM valEnergy sigEnergy valAngle sigAngle parEF parESB parSHEATH parERC
numberProj ranSeed ranSeed ranSeed z0 parRD dz parCA parKK0 parKK0R parKDEE1 parKDEE2 parIPOT parIPOTR parIRL
layer1d layer2d layer3d layer4d layer5d layer6d layer7d layer1rho layer2rho layer3rho layer4rho layer5rho layer6rho layer7rho L1CK L2CK L3CK L4CK L5CK L6CK L7CK
L1ELZ1 L1ELZ2 L1ELZ3 L1ELZ4 L1ELZ5
L1ELW1 L1ELW2 L1ELW3 L1ELW4 L1ELW5
L1ELC1 L1ELC2 L1ELC3 L1ELC4 L1ELC5
L1ELE1 L1ELE2 L1ELE3 L1ELE4 L1ELE5
L10301 L10302 L10303 L10304 L10305
0.0000 0.0000 0.0000 0.0000 0.0000
L1ELST11 L1ELST21 L1ELST31 L1ELST41 L1ELST51
L1ELST12 L1ELST22 L1ELST32 L1ELST42 L1ELST52
L1ELST13 L1ELST23 L1ELST33 L1ELST43 L1ELST53
L1ELST14 L1ELST24 L1ELST34 L1ELST44 L1ELST54
L1ELST15 L1ELST25 L1ELST35 L1ELST45 L1ELST55
L2ELZ1 L2ELZ2 L2ELZ3 L2ELZ4 L2ELZ5
L2ELW1 L2ELW2 L2ELW3 L2ELW4 L2ELW5
L2ELC1 L2ELC2 L2ELC3 L2ELC4 L2ELC5
L2ELE1 L2ELE2 L2ELE3 L2ELE4 L2ELE5
L20301 L20302 L20303 L20304 L20305
0.0000 0.0000 0.0000 0.0000 0.0000
L2ELST11 L2ELST21 L2ELST31 L2ELST41 L2ELST51
L2ELST12 L2ELST22 L2ELST32 L2ELST42 L2ELST52
L2ELST13 L2ELST23 L2ELST33 L2ELST43 L2ELST53
L2ELST14 L2ELST24 L2ELST34 L2ELST44 L2ELST54
L2ELST15 L2ELST25 L2ELST35 L2ELST45 L2ELST55
L3ELZ1 L3ELZ2 L3ELZ3 L3ELZ4 L3ELZ5
L3ELW1 L3ELW2 L3ELW3 L3ELW4 L3ELW5
L3ELC1 L3ELC2 L3ELC3 L3ELC4 L3ELC5
L3ELE1 L3ELE2 L3ELE3 L3ELE4 L3ELE5
L30301 L30302 L30303 L30304 L30305
0.0000 0.0000 0.0000 0.0000 0.0000
L3ELST11 L3ELST21 L3ELST31 L3ELST41 L3ELST51
L3ELST12 L3ELST22 L3ELST32 L3ELST42 L3ELST52
L3ELST13 L3ELST23 L3ELST33 L3ELST43 L3ELST53
L3ELST14 L3ELST24 L3ELST34 L3ELST44 L3ELST54
L3ELST15 L3ELST25 L3ELST35 L3ELST45 L3ELST55
L4ELZ1 L4ELZ2 L4ELZ3 L4ELZ4 L4ELZ5
L4ELW1 L4ELW2 L4ELW3 L4ELW4 L4ELW5
L4ELC1 L4ELC2 L4ELC3 L4ELC4 L4ELC5
L4ELE1 L4ELE2 L4ELE3 L4ELE4 L4ELE5
L40301 L40302 L40303 L40304 L40305
0.0000 0.0000 0.0000 0.0000 0.0000
L4ELST11 L4ELST21 L4ELST31 L4ELST41 L4ELST51
L4ELST12 L4ELST22 L4ELST32 L4ELST42 L4ELST52
L4ELST13 L4ELST23 L4ELST33 L4ELST43 L4ELST53
L4ELST14 L4ELST24 L4ELST34 L4ELST44 L4ELST54
L4ELST15 L4ELST25 L4ELST35 L4ELST45 L4ELST55
L5ELZ1 L5ELZ2 L5ELZ3 L5ELZ4 L5ELZ5
L5ELW1 L5ELW2 L5ELW3 L5ELW4 L5ELW5
L5ELC1 L5ELC2 L5ELC3 L5ELC4 L5ELC5
L5ELE1 L5ELE2 L5ELE3 L5ELE4 L5ELE5
L50301 L50302 L50303 L50304 L50305
0.0000 0.0000 0.0000 0.0000 0.0000
L5ELST11 L5ELST21 L5ELST31 L5ELST41 L5ELST51
L5ELST12 L5ELST22 L5ELST32 L5ELST42 L5ELST52
L5ELST13 L5ELST23 L5ELST33 L5ELST43 L5ELST53
L5ELST14 L5ELST24 L5ELST34 L5ELST44 L5ELST54
L5ELST15 L5ELST25 L5ELST35 L5ELST45 L5ELST55
L6ELZ1 L6ELZ2 L6ELZ3 L6ELZ4 L6ELZ5
L6ELW1 L6ELW2 L6ELW3 L6ELW4 L6ELW5
L6ELC1 L6ELC2 L6ELC3 L6ELC4 L6ELC5
L6ELE1 L6ELE2 L6ELE3 L6ELE4 L6ELE5
L60301 L60302 L60303 L60304 L60305
0.0000 0.0000 0.0000 0.0000 0.0000
L6ELST11 L6ELST21 L6ELST31 L6ELST41 L6ELST51
L6ELST12 L6ELST22 L6ELST32 L6ELST42 L6ELST52
L6ELST13 L6ELST23 L6ELST33 L6ELST43 L6ELST53
L6ELST14 L6ELST24 L6ELST34 L6ELST44 L6ELST54
L6ELST15 L6ELST25 L6ELST35 L6ELST45 L6ELST55
L7ELZ1 L7ELZ2 L7ELZ3 L7ELZ4 L7ELZ5
L7ELW1 L7ELW2 L7ELW3 L7ELW4 L7ELW5
L7ELC1 L7ELC2 L7ELC3 L7ELC4 L7ELC5
L7ELE1 L7ELE2 L7ELE3 L7ELE4 L7ELE5
L70301 L70302 L70303 L70304 L70305
0.0000 0.0000 0.0000 0.0000 0.0000
L7ELST11 L7ELST21 L7ELST31 L7ELST41 L7ELST51
L7ELST12 L7ELST22 L7ELST32 L7ELST42 L7ELST52
L7ELST13 L7ELST23 L7ELST33 L7ELST43 L7ELST53
L7ELST14 L7ELST24 L7ELST34 L7ELST44 L7ELST54
L7ELST15 L7ELST25 L7ELST35 L7ELST45 L7ELST55
";
# Get values from form
my %All = CollectValues();
my $projComboBox=$All{"projComboBox"};
$All{"ProjZ"}=sprintf("%6.2f",Chem::Zof($projComboBox));
$All{"ProjAM"}=sprintf("%6.2f",Chem::Massof($projComboBox));
# This is the flag for checking layers
my $Check=0;
# Loop over layers an create appropriate values
for (my $i=1;$i<=7;$i++){
$Check=0;
# Composition of layers
my $LComp="layer".$i."Comp";
my $LCompAttrib = child("Qt::LineEdit",$LComp);
my $Comp = $LCompAttrib->text();
my %LElComp=Chem::parse_formula($Comp);
if ($Comp eq "") {$Check++;}
# Densities of layers
my $Lrho="layer".$i."rho";
my $LrhoAttrib = child("Qt::LineEdit",$Lrho);
my $rho = 1*$LrhoAttrib->text();
$All{$Lrho}=sprintf("%6.2f",$rho);
if ($rho eq "") {$Check++;}
# Thickness of layers
my $Ld ="layer".$i."d";
my $LdAttrib = child("Qt::LineEdit",$Ld);
my $d = $LdAttrib->text();
$All{$Ld}=sprintf("%8.2f",$d);
if ($d eq "") {$Check++;}
# Sanity check, is the layer supposed to have value? are they all there?
if ($Check!=0 & $i<=$All{"numLayer"}) {
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";
}
my $tmp = "L".$i."CK";
$All{$tmp}=sprintf("%6.2f",1.0);
my $Sum = 0;
foreach (keys %LElComp) {
$Sum=$Sum+$LElComp{$_};
}
if ($Sum==0) {$Sum=1;}
# print STDOUT "Layer: ".$i."\n";
# print STDOUT "Composition: ".$Comp."\n";
my @Els = keys %LElComp;
for (my $NEl=1;$NEl<=5;$NEl++) {
my $El = $Els[$NEl-1];
my $LEkey = "L".$i."EL";
my $ElZ = Chem::Zof($El);
my $ElW = Chem::Massof($El);
my $ElC = $LElComp{$El}/$Sum;
my $ElE = Chem::Elastof($El);
my $El030 = 30;
if ($El eq "") { $El030 = 0.0;}
# print STDOUT "$El, ElC=$ElC ElZ=$ElZ ElW=$ElW ElE=$ElE\n";
$All{$LEkey."Z".$NEl}=sprintf("%8.4f",$ElZ);
$All{$LEkey."W".$NEl}=sprintf("%8.4f",$ElW);
$All{$LEkey."C".$NEl}=sprintf("%8.4f",$ElC);
$All{$LEkey."E".$NEl}=sprintf("%8.4f",$ElE);
$All{"L".$i."030".$NEl}=sprintf("%8.4f",$El030);
my $ElST = Chem::Stopicru($El);
my @ElSTs = split (/,/,$ElST);
my $j=1;
foreach (@ElSTs) {
$LEkey = "L".$i."ELST".$NEl.$j;
$j++;
$All{$LEkey}=sprintf("%11.6f",$_);
}
}
}
foreach my $key (keys %All) {
# 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;
}
# Subroutine: Start the simulation with the current parameters
sub StartSequenceOne()
{
my %All = CollectValues();
my @SValues=();
my @SdzValues=();
my $cmd="";
# Cleanup from old files
if (-e "ausgabe1.inp") {
system("rm -f ausgabe*");
}
my $Progress=0;
if ($All{"scanSeq"}) {
if ($All{"radioList"}) {
@SValues=split(/,/,$All{"scanList"});
@SdzValues=split(/,/,$All{"scanListdz"});
if ($#SValues == $#SdzValues) {$All{"SdzFlag"}=1;}
} elsif ($All{"radioLoop"}) {
for (my $Val=$All{"scanFrom"};$Val<=$All{"scanTo"};$Val=$Val+$All{"scanStep"}) {
@SValues=(@SValues,$Val);
}
}
my $ScanName = "";
my $ScanVar = "";
if ($All{"comboScan"}==0) {
$ScanName = "E";
$ScanVar = "valEnergy";
} elsif ($All{"comboScan"}==1) {
$ScanName = "SigE";
$ScanVar = "sigEnergy";
} elsif ($All{"comboScan"}==2) {
$ScanName = "Angle";
$ScanVar = "valAngle";
} elsif ($All{"comboScan"}==3) {
$ScanName = "SigAngle";
$ScanVar = "sigAngle";
} elsif ($All{"comboScan"}==4) {
$ScanName = "N";
$ScanVar = "numberProj";
} elsif ($All{"comboScan"}==5) {
$ScanName = "Ld".$All{"scandL"};
$ScanVar = "layer".$All{"scandL"}."d";
}
my $ScanAttrib = child("Qt::LineEdit",$ScanVar);
my $iScan=0;
foreach (@SValues) {
$ScanAttrib->setText($_);
if ( $All{"SdzFlag"} == 1) {
if ($All{"comboScan"}==0) {
this->{ui}->dz->setText($SdzValues[$iScan]);
} elsif ($All{"comboScan"}==3) {
this->valEnergy->setText($SdzValues[$iScan]);
}
}
my $eingabe1=CreateInpFile();
if ($eingabe1 eq "ERROR") {return 0;}
my $FILENAME=$All{"fileNamePrefix"}."_".$ScanName.$_;
open (INPF,q{>}, "$FILENAME.inp" );
print INPF $eingabe1;
close(INPF);
# Use windoz version
# system("cp $FILENAME.inp eingabe1.inp; wine TrimSP7L.exe");
# Use Linux version
$Progress=$Progress+90/$#SValues;
this->{ui}->progress->setValue($Progress);
this->{ui}->progress->update();
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
system($cmd);
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;}
my $FILENAME=$All{"fileNamePrefix"};
open (INPF,q{>}, "$FILENAME.inp" );
print INPF $eingabe1;
close(INPF);
$Progress=20;
this->{ui}->progress->setValue($Progress);
# Use windoz version
# system("cp $FILENAME.inp eingabe1.inp; wine TrimSP7L.exe");
# Use Linux version
$cmd = "cp $FILENAME.inp eingabe1.inp; ".$ENV{'TRIMBIN'};
system($cmd);
foreach ("err","out","rge") {
system("mv -f ausgabe1.$_ $FILENAME.$_");
}
$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;
}
# Subroutine: Select or create work directory
sub DirectoryBrowse()
{
my $Path = this->{ui}->workPath->text();
my $FileBrowser = Qt::FileDialog::getExistingDirectory(
this,
"Choose a directory",
$Path,
1);
if ($FileBrowser ne "") {
this->{ui}->workPath->setText($FileBrowser);
}
# Create a subdirectory where all input/output files are saved
my $cmd="";
if (-d $FileBrowser) {
# Directory exists, do nothing
} else {
$cmd="mkdir $FileBrowser";
system($cmd);
}
# Change work directory accordingly
chdir ("$FileBrowser");
}
# Subroutine: Quit dialog with confirmation
sub ConfirmQuit()
{
my $Ans = Qt::MessageBox::question( this, "Quit?","Are you sure you want to quit?","&Yes","&No","",0,1);
if ($Ans==0) {
# Then quit
Qt::Application::exit( 0 );
}
# Otherwize go back
}
# From here it is all menu actions
# Subroutine: Open a configuration file
sub OpenFile()
{
# Types of different input
my %Types = ();
$Types{"numLayer"}="Qt::SpinBox";
$Types{"projComboBox"}="Qt::ComboBox";
$Types{"scanSeq"}="Qt::RadioButton";
$Types{"comboScan"}="Qt::ComboBox";
$Types{"scandL"}="Qt::SpinBox";
$Types{"radioList"}="Qt::RadioButton";
$Types{"scanListdz"}="Qt::LineEdit";
$Types{"radioLoop"}="Qt::RadioButton";
$Types{"scanSeq"}="Qt::GroupBox";
my $file=Qt::FileDialog::getOpenFileName(
this,
"Choose an initialization file",
".",
"Initialization file (.* *.*)");
# If the user gave a valid filename try to read it
if ($file ne "") {
open (INF,q{<},"$file" );
my @lines = <INF>;
close(INF);
my $Attrib="";
foreach my $line (@lines) {
# Remove white spaces
$line =~ s/\s+//g;
my @InitPar = split (/=/,$line);
# Check it is not empty or title line
if ($InitPar[0] || $InitPar[1]) {
if (!$Types{$InitPar[0]}) {
$Types{$InitPar[0]}="Qt::LineEdit";
}
# Get widget by name
$Attrib = child($Types{$InitPar[0]},$InitPar[0]);
# if the widget exists
if ($Attrib){
if ($Types{$InitPar[0]} eq "Qt::SpinBox") {
$Attrib->setValue($InitPar[1]);
} elsif ($Types{$InitPar[0]} eq "Qt::RadioButton" || $Types{$InitPar[0]} eq "Qt::GroupBox") {
if($InitPar[1]) {
$Attrib->setChecked(1);
} else {
$Attrib->setChecked(0);
}
} elsif ($Types{$InitPar[0]} eq "Qt::ComboBox") {
$Attrib-> setCurrentIndex($InitPar[1]);
} else {
$Attrib->setText($InitPar[1]);
}
}
}
}
}
}
# Subroutine: Save configuration file to TrimSP.cfg
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'}
[ProjectileParameters]
projComboBox=$All{'projComboBox'}
numberProj=$All{'numberProj'}
z0=$All{'z0'}
dz=$All{'dz'}
valEnergy=$All{'valEnergy'}
sigEnergy=$All{'sigEnergy'}
valAngle=$All{'valAngle'}
sigAngle=$All{'sigAngle'}
ranSeed=$All{'ranSeed'}
[Files]
fileNamePrefix=$All{'fileNamePrefix'}
workPath=$All{'workPath'}
[ScanSequence]
scanSeq=$All{'scanSeq'}
comboScan=$All{'comboScan'}
radioList=$All{'radioList'}
scanList=$All{'scanList'}
scanListdz=$All{'scanListdz'}
radioLoop=$All{'radioLoop'}
scanFrom=$All{'scanFrom'}
scanTo=$All{'scanTo'}
scanStep=$All{'scanStep'}
";
# Save to default file name "TriumSP.cfg"
my $file = "TrimSP.cfg";
open (OUTF,q{>},"$file" );
print OUTF (" $InitFile");
close(OUTF);
}
# Subroutine: Save As configuration file
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'}
[ProjectileParameters]
projComboBox=$All{'projComboBox'}
numberProj=$All{'numberProj'}
z0=$All{'z0'}
dz=$All{'dz'}
valEnergy=$All{'valEnergy'}
sigEnergy=$All{'sigEnergy'}
valAngle=$All{'valAngle'}
sigAngle=$All{'sigAngle'}
ranSeed=$All{'ranSeed'}
[Files]
fileNamePrefix=$All{'fileNamePrefix'}
workPath=$All{'workPath'}
[ScanSequence]
scanSeq=$All{'scanSeq'}
comboScan=$All{'comboScan'}
radioList=$All{'radioList'}
scanList=$All{'scanList'}
scanListdz=$All{'scanListdz'}
radioLoop=$All{'radioLoop'}
scanFrom=$All{'scanFrom'}
scanTo=$All{'scanTo'}
scanStep=$All{'scanStep'}
";
my $file=Qt::FileDialog::getSaveFileName(
this,
"Choose a filename to save",
"TrimSP.cfg",
"TrimSP GUI Initialization file (*.cfg)");
# If the user gave a filename the copy to it
if ($file ne "") {
open (OUTF,q{>},"$file" );
print OUTF (" $InitFile");
close(OUTF);
}
}
# Subroutine: Plot implantation profiles using root macro
sub PlotProfiles()
{
my $Path=this->{ui}->workPath->text();
my $files_ref=Qt::FileDialog::getOpenFileNames(
this,
"Select RGE files to plot",
$Path,
"RGE Files (*.rge)");
my @files_tmp = @$files_ref;
# Do "natural" sorting on the file name list
# This will produce (hopefully) a plot with largest needed depth scale
my @files = grep {s/(^|\D)0+(\d)/$1$2/g,1} sort grep {s/(\d+)/sprintf"%06.6d",$1/ge,1} @files_tmp;
my $filenames=join(",",@files);
if ($filenames ne "" ) {
my $TrimPath = $ENV{'PERLLIB'};
# Now that we have the file list send it to root macro for plotting.
my $cmd='root -n -l "'.$TrimPath.'/plotRge.C(\"'.$filenames.'\")"&';
my $pid=system($cmd);
}
}
# Subroutine: Plot implantation fractions in the different layers using
# a root macro
sub PlotFraction()
{
my $Path=this->{ui}->workPath->text();
my $file=Qt::FileDialog::getOpenFileName(
this,
"Choose a sequence data file",
$Path,
"Implantation sequence file (*.dat)");
if ($file ne "" ) {
my $TrimPath = $ENV{'PERLLIB'};
# Now that we have the file name send it to root macro for plotting.
my $cmd='root -n -l "'.$TrimPath.'/plotFrc.C(\"'.$file.'\")"&';
my $pid=system($cmd);
}
}
# Subroutine: Help window contents
sub helpContentsAction()
{
my $HelpText="
This is a GUI that uses the Trim.SP simulation binary to calculate the implantation profiles of implanted projectiles in a multilayer thin film structure.
Usage:
Initially define your multilayer structure in the 'Layers' tab. This can be formed of a maximum of 7 layers. Each layer is defined by giving its chemical formula, its density in units of g/cm^3, and its thickness in Ångström.
Next, choose the type of projectile to be implanted in the structure from the drop-down menu. Set the 'Number of projectiles' to be implanted, were a higher number will give better statistics. Finally define the rest of the projectile parameters such as implantation energy, energy spread, etc.
In the 'File names prefix' give a string which will be used to construct the input/output file names of the simulation. These files will be collected and saved in the subdirectory provided in 'Save in subdirectory' box.
The 'Additional Parameters' tab allows you to change additional parameters in the simulation. Change these only if you know what you are doing, and have read the original documentation of the Trim.SP simulation.
The 'Scans' tabs provides the ability to change the value of a certain parameter in the simulation, such as implantation energy, spread in energy, number of implanted projectiles, and the thickness of one layer. The values of this parameter can be changed by a regualr step size ('Loop' checkbox and parameters), or following a set of values ('List of values' checkbox and the comma separated values). In the second case, in addition to the scanned parameter, the user may be given an option to change another parameter. For example, when scanning through a list of energies, the user may give a corresponding depth increment for each energy value.
Copyright 2009-2013 (C) by Zaher Salman.
Last modified 29 Jan. 2013
";
my $HelpWindow = Qt::MessageBox::information( this, "TrimSP GUI Help Window",$HelpText);
}
# Subroutine: About window contents
sub helpAboutAction()
{
my $HelpText="TrimSPGUI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
TrimSPGUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with TrimSPGUI. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009-2013 by Zaher Salman.
<zaher.salman\@psi.ch>
";
my $HelpWindow = Qt::MessageBox::about( this, "About TrimSP GUI",$HelpText);
}
# Subroutine: keep for tests and debugging
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";
}
1;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
% list of densities in gr/cm^3
NbN,8.47
Bi2Se3,7.51
N2,1.145
ZnO,5.61
SiO2,2.65
TiO2,4.26
KTaO3,6.967
LaAlO3,6.70
Al2O3,3.98
SrTiO3,5.12
NbSe2,6.30
MgO,3.58
YBa2Cu3O7,6.54
GaAs,5.32
Si,2.33
Mn12-Acetate,1.65
C60,1.65

BIN
trimsp/TrimSPGUI4/icon.odg Normal file

Binary file not shown.

BIN
trimsp/TrimSPGUI4/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

232
trimsp/TrimSPGUI4/plotFrc.C Normal file
View File

@ -0,0 +1,232 @@
// File: plotFrc.C
// Author: Zaher Salman
// Date: 11/01/2012
// Purpose: ROOT macro to read and plot implantation fractions in layers from trimsp calculation
// Assume following file Format:
//
// $Id$
//
// Energy SigmaE Alpha SigAlpha ntot imp backsc trans tried negE impL1 impL2 impL3 impL4 impL5 impL6 impL7 range straggeling Eback sigEback Etrans SigEtrans red. E PRC
// 15.00 0.45 0.00 15.00 100000 98362 1638 0 100000 0 98362 0 0 0 0 0 0 0.6664E+03 0.1799E+03 0.4980E+04 0.4250E+04 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
// plotFrc(file_name)
void plotFrc(char *FileName)
{
TObjString *ostr;
TString str,xlab,ylab;
TString line, label, treeLabel;
TString rootFileName;
TObjArray *token,*labels;
TObjString *strtoken;
Int_t nPars = 0;
Int_t ntokens = 0;
Int_t i = 0;
Int_t nline=0;
Int_t intNorm=0;
Ssiz_t pos;
Double_t x[100],yl1[100],yl2[100],yl3[100],yl4[100],yl5[100],yl6[100],yl7[100],bck[100];
Int_t Flag[7]=0;
FILE *fp = fopen(FileName,"r");
if ( fp == NULL ){
printf("File %s does not exist!\n", FileName);
return;
}
while (line.Gets(fp)){
if ( nline==0 ){
// First line, get data labels
nline++;
labels = line.Tokenize(" ");
ntokens = labels->GetEntries();
nPars=ntokens;
ostr = dynamic_cast<TObjString*>(labels->At(0));
xlab = ostr->GetString();
ylab = ostr->GetString();
} else {
token = line.Tokenize(" ");
ntokens = token->GetEntries();
strtoken = (TObjString*) token->At(0);
label = strtoken->GetName();
x[i] = label.Atof();
// Plot all layers for now. Maybe stop when sum is zero in the future
// Layers start from column # 10 up to 16.
// for (col=10;col<17;col++) {
strtoken = (TObjString*) token->At(6);
label = strtoken->GetName();
bck[i] = label.Atof();
if (bck[i]>0) {
Flag[7]=1;
intNorm = intNorm++;
}
strtoken = (TObjString*) token->At(10);
label = strtoken->GetName();
yl1[i] = label.Atof();
if (yl1[i]>0) {
Flag[0]=1;
intNorm = intNorm++;
}
strtoken = (TObjString*) token->At(11);
label = strtoken->GetName();
yl2[i] = label.Atof();
if (yl2[i]>0) {
Flag[1]=1;
intNorm = intNorm++;
}
strtoken = (TObjString*) token->At(12);
label = strtoken->GetName();
yl3[i] = label.Atof();
if (yl3[i]>0) {
Flag[2]=1;
intNorm = intNorm++;
}
strtoken = (TObjString*) token->At(13);
label = strtoken->GetName();
yl4[i] = label.Atof();
if (yl4[i]>0) {
Flag[3]=1;
intNorm = intNorm++;
}
strtoken = (TObjString*) token->At(14);
label = strtoken->GetName();
yl5[i] = label.Atof();
if (yl5[i]>0) {
Flag[4]=1;
intNorm = intNorm++;
}
strtoken = (TObjString*) token->At(15);
label = strtoken->GetName();
yl6[i] = label.Atof();
if (yl6[i]>0) {
Flag[5]=1;
intNorm = intNorm++;
}
strtoken = (TObjString*) token->At(16);
label = strtoken->GetName();
yl7[i] = label.Atof();
if (yl7[i]>0) {
Flag[6]=1;
intNorm = intNorm++;
}
//}
nline++;
i++;
}
}
TCanvas *c = new TCanvas("c",str);
c->Show();
TLegend *legend = new TLegend(0.8, 0.8, 0.95, 0.95);
legend->SetFillColor(TColor::GetColor(255,255,255)); // white
TMultiGraph *mg = new TMultiGraph();
if (Flag[0]==1){
TGraph *gr1 = new TGraph(i-1,x,yl1);
gr1->GetXaxis()->SetTitle(xlab);
gr1->GetYaxis()->SetTitle("Implanted Fraction");
// gr1->Draw("APC");
gr1->SetMarkerStyle(20);
gr1->SetMarkerColor(TColor::kRed);
gr1->SetLineColor(TColor::kRed);
legend->AddEntry(gr1,"Layer 1");
mg->Add(gr1);
}
if (Flag[1]==1){
TGraph *gr2 = new TGraph(i-1,x,yl2);
gr2->SetMarkerStyle(20);
gr2->SetMarkerColor(TColor::kGreen);
gr2->SetLineColor(TColor::kGreen);
// gr2->Draw("PC");
legend->AddEntry(gr2,"Layer 2");
mg->Add(gr2);
}
if (Flag[2]==1){
TGraph *gr3 = new TGraph(i-1,x,yl3);
gr3->SetMarkerStyle(20);
gr3->SetMarkerColor(TColor::kBlue);
gr3->SetLineColor(TColor::kBlue);
// gr3->Draw("PC");
legend->AddEntry(gr3,"Layer 3");
mg->Add(gr3);
}
if (Flag[3]==1){
TGraph *gr4 = new TGraph(i-1,x,yl4);
gr4->SetMarkerStyle(20);
gr4->SetMarkerColor(TColor::kMagenta);
gr4->SetLineColor(TColor::kMagenta);
// gr4->Draw("PC");
legend->AddEntry(gr4,"Layer 4");
mg->Add(gr4);
}
if (Flag[4]==1){
TGraph *gr5 = new TGraph(i-1,x,yl5);
gr5->SetMarkerStyle(20);
gr5->SetMarkerColor(TColor::kOrange);
gr5->SetLineColor(TColor::kOrange);
// gr5->Draw("PC");
legend->AddEntry(gr5,"Layer 5");
mg->Add(gr5);
}
if (Flag[5]==1){
TGraph *gr6 = new TGraph(i-1,x,yl6);
gr6->SetMarkerStyle(20);
gr6->SetMarkerColor(TColor::kViolet);
gr6->SetLineColor(TColor::kViolet);
// gr6->Draw("PC");
legend->AddEntry(gr6,"Layer 6");
mg->Add(gr6);
}
if (Flag[6]==1){
TGraph *gr7 = new TGraph(i-1,x,yl7);
gr7->SetMarkerStyle(20);
gr7->SetMarkerColor(TColor::kAzure+7);
gr7->SetLineColor(TColor::kAzure+7);
// gr7->Draw("PC");
legend->AddEntry(gr7,"Layer 7");
mg->Add(gr7);
}
if (Flag[7]==1){
TGraph *gr8 = new TGraph(i-1,x,bck);
gr8->SetMarkerStyle(20);
gr8->SetMarkerColor(TColor::kAzure+7);
gr8->SetLineColor(TColor::kAzure+7);
// gr8->Draw("PC");
legend->AddEntry(gr8,"Back Scat.");
mg->Add(gr8);
}
mg->Draw("APC");
mg->GetXaxis()->SetTitle("Energy [keV]");
mg->GetYaxis()->SetTitle("Implanted Particles");
legend->Draw();
// I am not sure what this does, but it waits until canvas is closed
c->WaitPrimitive(" ");
cout << endl << "Canvas Closed" << endl ;
// Then quit root cleanly
gApplication->Terminate();
}

182
trimsp/TrimSPGUI4/plotRge.C Normal file
View File

@ -0,0 +1,182 @@
// File: plotRge.C
// Author: Zaher Salman, originally by Andreas Suter
// Date: 03/06/2009
// Purpose: ROOT macro to read and plot Range data from trimsp calculation
// Assume following file Format:
//
// $Id$
//
// DEPTH PARTICLES
// 15. 260
// 45. 595
// 75. 820
// 105. 1179
//
// plotRge(names), e.g.
// plotRge("InSne_E2500, InSne_E4000");
// will read files
void plotRge(TString &names)
{
if (names.CompareTo("help", TString::kIgnoreCase) == 0) {
cout << endl << "usage: plotRge(<names>) or plotRge(\"help\")";
cout << endl << " <names> is a list of rge-files";
cout << endl << endl;
return;
}
TObjArray *tokens;
TObjString *ostr;
TString str;
char cstr[128];
Int_t i, j;
Int_t nStep = 0;
Int_t nStepmax = 0;
Double_t *depth;
Double_t *nStop;
Double_t *depthmax;
Double_t *nStopmax;
Double_t norm;
Double_t intNorm;
Double_t normStop[1000];
Double_t normStopmax[1000];
TString pathname;
int sep;
TString path;
TString name,legtit;
Int_t col;
Int_t color[1000];
for (i=0; i<1000; i++)
color[i] = -1;
color[0] = TColor::kRed;
color[1] = TColor::kGreen;
color[2] = TColor::kBlue;
color[3] = TColor::kMagenta;
color[4] = TColor::kOrange;
color[5] = TColor::kViolet;
color[6] = TColor::kAzure+7;
color[7] = TColor::kOrange+4;
color[8] = TColor::kBlue-7;
TGraph *rge[1000];
TMultiGraph *mg = new TMultiGraph();
TLegend *legend = new TLegend(0.7, 0.7, 0.95, 0.95);
legend->SetFillColor(TColor::GetColor(255,255,255)); // white
tokens = names.Tokenize(" \t,;");
Double_t min = 0, max = 0, xmax = 0, xmin = 0;
Int_t imax;
// Loop over file names
for (i=0; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
cout << endl << i << ": read " << str.Data();
TGraph *fileGraph = new TGraph(str);
if ( fileGraph->IsZombie() ){
cout << endl;
cout << "File " << str << " does not exist!!!" << endl << endl;
return;
}
depth = fileGraph->GetX();
nStop = fileGraph->GetY();
nStep = fileGraph->GetN(); // Number of points in range
// calculate step size in nm (convert from AA)
norm = (depth[1] - depth[0])/10;
// intNorm is the total stopping particles
intNorm = 0.0;
for (j=0; j<nStep; j++) {
intNorm += nStop[j];
}
for (j=0; j<nStep; j++) {
// Calculate normalized stopping profile
if (norm > 0.) {
// devide original profile by (step size * total particles) in %
normStop[j] = 100*nStop[j]/(norm*intNorm);
} else {
normStop[j] = -1.;
}
// rescale depth to nm
depth[j] = depth[j]/10.;
}
rge[i] = new TGraph(nStep, depth, normStop);
if (color[i] >= 0) {
rge[i]->SetMarkerColor(color[i]);
rge[i]->SetLineColor(color[i]);
} else {
TRandom *rand = new TRandom(i);
col = TColor::GetColor((Int_t)rand->Integer(255),(Int_t)rand->Integer(255),(Int_t)rand->Integer(255));
rge[i]->SetMarkerColor(col);
rge[i]->SetLineColor(col);
delete rand;
}
rge[i]->SetMarkerStyle(20);
mg->Add(rge[i]);
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString() + ", ";
sprintf(cstr, "%.1lf", ostr->GetString().Atof() /1000.0);
str += cstr;
// remove path
sep = str.Last('/');
path = str(0,sep);
name = str(sep+1,str.Length()-sep-1);
// remove comma etc.
sep = name.Last(',');
name = name(0,sep);
// remove extension etc.
sep = name.Last('.');
name = name(0,sep);
// remove ????_ etc.
sep = name.Last('_');
path = name(sep+1);
name = name(sep+2,name.Length()-sep-1);
legtit = "";
legtit += path;
legtit += "=";
legtit += name;
legtit += " (eV)";
cout << endl << legtit << endl ;
rge[i]->SetTitle(str.Data());
rge[i]->SetFillColor(TColor::kWhite);
legend->AddEntry(rge[i], legtit);
delete fileGraph;
}
cout << endl;
mg->Draw("APC");
mg->GetXaxis()->SetTitle("Depth [nm]");
mg->GetYaxis()->SetTitle("Normalized Stopping Profile [%/nm]");
legend->Draw();
delete tokens;
// I am not sure what this does, but it waits until canvas is closed
c1->WaitPrimitive(" ");
cout << endl << "Canvas Closed" << endl ;
// Then quit root cleanly
gApplication->Terminate();
}

View File

@ -0,0 +1,88 @@
// File: readAscii.C
// Author: Thomas Prokscha
// Date: 24/04/2005
// Purpose: ROOT macro to read ASCII data from file FileName
// Assume sections
// Comment:
// and
// Data:
// label1 label2 ...
// value1 value2 ...
//
// gROOT->Reset();
void readAscii(char *FileName, Int_t Col1, Int_t Col2)
{
TObjString *ostr;
TString str,xlab,ylab;
TString line, label, treeLabel;
TString rootFileName;
TObjArray *token;
TObjString *strtoken;
Int_t nPars = 0;
Int_t ntokens = 0;
Int_t i = 0;
Int_t nline=0;
Ssiz_t pos;
Double_t x[100],y[100];
FILE *fp = fopen(FileName,"r");
if ( fp == NULL ){
printf("File %s does not exist!\n", FileName);
return;
}
while (line.Gets(fp)){
if ( nline==0 ){
// First line, get data labels
nline++;
token = line.Tokenize(" ");
ntokens = token->GetEntries();
nPars=ntokens;
ostr = dynamic_cast<TObjString*>(token->At(Col1));
xlab = ostr->GetString();
ostr = dynamic_cast<TObjString*>(token->At(Col2));
ylab = ostr->GetString();
} else {
token = line.Tokenize(" ");
ntokens = token->GetEntries();
// if ( ntokens != nPars) {
// // We have a problems
// printf("The number of columns found is: %d not equal to %d\n",ntokens,nPars);
// }
strtoken = (TObjString*) token->At(Col1);
label = strtoken->GetName();
x[i] = label.Atof();
strtoken = (TObjString*) token->At(Col2);
label = strtoken->GetName();
y[i] = label.Atof();
printf("(x,y)[%d]= (%f,%f)\n",i,x[i],y[i]);
nline++;
i++;
}
}
TGraph *gr = new TGraph(i-1,x,y);
TCanvas *c = new TCanvas("c",str);
gr->GetXaxis()->SetTitle(xlab);
gr->GetYaxis()->SetTitle(ylab);
gr->Draw("AC*");
c->Show();
delete token;
// I am not sure what this does, but it waits until canvas is closed
c->WaitPrimitive(" ");
cout << endl << "Canvas Closed" << endl ;
// Then quit root cleanly
gApplication->Terminate();
}