work/0000775000000000000000000000000014023445763006740 5ustar work/Changes.xbs0000664000000000000000000000054014023445763011025 0ustar Changes to the xbs program 06.09.97 The program now plots additional straight lines, typically the edges of the unit cell. Input in the .bs file is like this: line 0.0 0.0 0.0 1.0 0.0 0.0 Plotting of the lines (continuous, dashed or off) is toggled by key L (that is: shift-l) in the program. work/License0000664000000000000000000004307614023445763010257 0ustar GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. END OF TERMS AND CONDITIONS Appendix: 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 convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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 2 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This 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 Library General Public License instead of this License. work/Makefile0000664000000000000000000000023514023445763010400 0ustar CC = gcc CFLAGS = -O3 LIBS = -lX11 -lm LIBPATH = -L/usr/X11R6/lib all: xbs.c $(CC) $(CFLAGS) -o xbs xbs.c $(LIBPATH) $(LIBS) clean: -rm *.o xbs work/README0000664000000000000000000002054214023445763007623 0ustar ============================================================== xbs ball-and-sticks plotting program (M. Methfessel Nov. 1995) ============================================================== This program uses X-window graphics to produce ball-and-sticks plots. It reads coordinates and other data from an input file (ie. ch4.bs) and possibly different "frames" with shifted coordinates from an auxillary move file (ie. ch4.mv). The default files are in.bs and in.mv. ----- INSTALLATION ----- Compile by command 'cx xbs'. This compiles the C program together with the X-Window includes and libraries. If everything works properly, you can do 'cx -O xbs' in a second step to optimize. Possibly the settings inside cx have to be changed for some operating systems. Presently cx is set up for IBM AIX. There is a second version called cx.sgi which is set up for Silicon Graphics workstations. ----- INPUT ----- In a simple case, a file ch4.bs could look like this: atom C 0.000 0.000 0.000 atom H 1.155 1.155 1.155 atom H -1.155 -1.155 1.155 atom H 1.155 -1.155 -1.155 atom H -1.155 1.155 -1.155 spec C 1.000 0.7 spec H 0.700 1.00 bonds C C 0.000 4.000 0.109 1.00 bonds C H 0.000 3.400 0.109 1.00 bonds H H 0.000 2.800 0.109 1.00 This sets the coordinates in the format atom species x y z and how to draw each atomic species, in the format spec name radius color and how to draw bonds, in the format bonds name1 name2 min-length max-length radius color A move file contains additional frames like this: frame This is frame number two 0.000 0.000 0.000 1.155 1.155 1.155 -1.155 -1.155 1.155 1.155 -1.155 -1.155 -1.155 1.155 -1.155 After the keyword 'frame' comes an indentifying string, then come the coordinates for all the atoms. Line breaks can appear anywhere between the coordinates. Other input lines are also possible, namely the lines which set parameters (see below). Example: 'inc 5' sets the increment for the rotation to 5 degrees. In both files, lines starting with * and blank lines are comments. ----- USAGE ----- After starting the program with 'xbs ch4' the plot can be controlled directly by selected keys. For example, to rotate the molecule use the cursor keys and the keys "," and "." The last two were chosen because they are below "<" and ">" whch look like arrows. To step through the frames to show a "movie", use keys '[' and ']'. A number of other keys are defined to function directly. More complicated functions are done by pressing 'i' to get an input line and then typing a command. Use 'xbs -hh' to get information on keys and commands. Sizing: Keys '+' and '-' make the plot bigger or smaller. Perspective: Key p switches the perspective. Default is off. For pseudoperspective, the sphere sizes depend on the distance to the viewer but the positions on the page are unchanged. For true perspective, the sizes and the positions both change. The strength of the perspective effect depends on the distance to the viewer, which is shown in the status line. It is changed with keys 'd' and 'D' or can be set directly with command 'dist'. (Note: if you come too close and put the viewpoint inside an atom, the program will try to color the whole universe, which takes very long). Lighting: command 'gramp slope middle' greys out the atoms in the back by an exponential ramp. Command 'light x y z' shades the atoms somewhat as if light shines along vector (x,y,z). These commands only work in black/white mode. To switch back to normal coloring, enter 'gramp' or 'light' without arguments. Positioning: Keypad keys 8,6,4,2 move the plot about by an increment dpos (which can be set by the command 'dpos'). Keypad key '*' saves the current position as 'home' (or use command 'pos' to set the home position directly). Keypad key 7 moves the plot home. Positions are relative to the center of the window. Saving: command 'save' writes the data to a file (default Save.bs). If there are multiple frames, a move file is also written. The 'save' command has some options, see below. Printing: the command 'print' writes output to a postscript file, by default the file 'Bs.ps'. A print file stays open until it is explicitly closed. In this way several plots can be superimposed on the same page, using the keypad cursor keys to shift the subplots on the page. The 'print' command has some options, see below. ----- GETTING HELP ----- Typing 'xbs -h' and 'xbs -hh' gives short respectively long help. After starting xbs, key 'h' toggles an overview. This is the same information as is obtained with 'xbs -hh'. On the input line, use 'help print' or 'print ?' or even 'print -h' to get help on a specific command such as (in this case) print. This help also shows any possible options for the command. The space bar toggles extra information about the plot written into the window. ----- SOME MORE DETAILS AND RECENT CHANGES ----- 1. Color: - A color is specified either as a number between 0 and 1 (gray value), three numbers between 0 and 1 (red, green, blue values or RGB), or as a color name from the file /usr/lib/X11/rgb.txt (or similar). - In the input file, the color of each species or bond is set in these three ways. - The following xbs options are related to color: -color enable colors (default) -bw uses greys only -st uses grays only, stippled from a few values -rv reverse all colors -auto choose own colors. You can change these interactively with the update command. For consistency, black is now 0 and white is 1. The -rv option switches this. The only reason for using -bw or -st is that the commands 'light' and 'gramp' do not work with colors. - The '-auto' option is used to color the atoms in some standard way. These colors are set in routine 'set_auto_colors' in file subs.h. Starting from the species label (ie. Pd3 or Mg-a) the leading alpha part is extracted and capitalized (ie. PD or MG) and this string is used to select a color. The idea is to put one's favorite colors into the routine and then recompile xbs. - The command 'color' changes the colors of atoms interactively, ie. 'color C* green' changes the color of all matching species. To show the color of a species, use the command without specifying a color (ie. 'color C1' or 'color C-a'). - When data is saved with the 'save' command, the current colors (as set with 'color') are saved as a string. With 'save -rgb' the RGB values are written instead of color names. If the -rv option is used, the reversed colors are saved as RGB values. 2. Some commands have options, eg. print, save, update. For example: print -T print and add some info as title print -t 'text .... ' print and put text as title update -rv update but switch on reversing update +rv update but switch off reversing update -bw update but switch to black/white save -rgb save with colors as rgb values save -step n save with only every n'th frame (good to compress a big .mv file). Use 'help update' etc on the input line to see the options. 3. Pattern matching for atom labels: * matches any string, + any char. This can be used in the 'color' command and in the 'bonds' lines in the input file (which determine what bonds are drawn). For example, 'bonds C* H* ...' selects all bonds between atoms like C1 and H34 etc. and 'bonds * * ...' selects all pairs. 4. Other miscellaneous changes: - Key 'a' displays the axis directions. - Key 'n' shows atom names or numbers. Key 'c' shows the coordinates. - To close a postscript print file, use command 'close'. - Command 'dup x y z' duplicates all atoms shifted by (x,y,z). - Command 'cut x y z a b' cuts to those atoms between a and b along the vector (x,y,z). - The input line has a history list to retrieve old commands. Use the up and down arrows when the input line is active. - On some systems, the backspace key does not work to edit the input line. Therefore the left-arrow key was defined to have the backspace function also. work/TAR0000775000000000000000000000052114023445763007312 0ustar #!/bin/csh -f # makes a tar file BS.tar.Z with all relevant files echo 'Making tar file for xbs...' rm -f BS.tar.Z rm -f BS.tar # tar -cvf BS.tar README xbs.c *.h bs_icon *.bs *.mv cx tar -cvf BS.tar README License TAR xbs.c *.h bs_icon *.bs *.mv cx* Cha* ls -l BS.* compress BS.tar ls -l BS.* exit work/alfa.bs0000664000000000000000000000307614023445763010177 0ustar * date Mon Sep 8 11:47:32 1997 * alat 9.28990 * basis 1.00000 .00000 .00000 * basis -.50000 .86603 .00000 * basis .00000 .00000 1.09960 line .0000 .0000 .0000 1.0000 .0000 .0000 line 1.0000 .0000 .0000 .5000 .8660 .0000 line .5000 .8660 .0000 -.5000 .8660 .0000 line -.5000 .8660 .0000 .0000 .0000 .0000 line .0000 .0000 1.0996 1.0000 .0000 1.0996 line 1.0000 .0000 1.0996 .5000 .8660 1.0996 line .5000 .8660 1.0996 -.5000 .8660 1.0996 line -.5000 .8660 1.0996 .0000 .0000 1.0996 line .0000 .0000 .0000 .0000 .0000 1.0996 line 1.0000 .0000 .0000 1.0000 .0000 1.0996 line -.5000 .8660 .0000 -.5000 .8660 1.0996 line .5000 .8660 .0000 .5000 .8660 1.0996 atom Si -.2349 -.4068 .3665 atom Si .4697 .0000 .0000 atom Si -.2349 .4068 .7331 atom O .2800 .2311 .1310 atom O .0601 -.3581 .4975 atom O -.3402 .1270 .8640 atom O .2801 -.2311 -.1310 atom O .0602 .3581 .6021 atom O -.3402 -.1270 .2356 spec Si .2153 .78 spec O .1076 .86 bonds Si Si .0000 .5597 .0015 1.00 bonds Si O .0000 .4198 .0015 1.00 bonds O O .0000 .2799 .0015 1.00 scale 60 dist 8 inc 5 work/bi2201.bs0000664000000000000000000001717614023445763010201 0ustar atom cu 0.000 0.000 0.000 atom sr 0.500 0.500 0.460 atom sr 0.500 0.500 -0.460 atom bi 0.000 0.000 1.193 atom bi 0.000 0.000 -1.193 atom o1 0.000 0.000 0.668 atom o1 0.000 0.000 -0.668 atom o2 0.500 0.000 0.000 atom o2 0.000 0.500 0.000 atom o3 0.500 0.500 1.203 atom o3 0.500 0.500 -1.203 atom sr 0.000 1.000 2.783 atom bi -0.500 0.500 2.050 atom o1 -0.500 0.500 2.575 atom o3 0.000 1.000 2.040 atom sr 1.000 0.000 -2.783 atom bi 0.500 -0.500 -2.050 atom o1 0.500 -0.500 -2.575 atom o3 1.000 0.000 -2.040 atom sr 1.000 0.000 2.783 atom bi 0.500 -0.500 2.050 atom o1 0.500 -0.500 2.575 atom o3 1.000 0.000 2.040 atom cu 1.000 -1.000 0.000 atom sr 1.500 -0.500 0.460 atom sr 1.500 -0.500 -0.460 atom bi 1.000 -1.000 1.193 atom bi 1.000 -1.000 -1.193 atom o1 1.000 -1.000 0.668 atom o1 1.000 -1.000 -0.668 atom o2 1.500 -1.000 0.000 atom o2 1.000 -0.500 0.000 atom o3 1.500 -0.500 1.203 atom o3 1.500 -0.500 -1.203 atom sr 0.000 1.000 -2.783 atom bi -0.500 0.500 -2.050 atom o1 -0.500 0.500 -2.575 atom o3 0.000 1.000 -2.040 atom cu -1.000 1.000 0.000 atom sr -0.500 1.500 0.460 atom sr -0.500 1.500 -0.460 atom bi -1.000 1.000 1.193 atom bi -1.000 1.000 -1.193 atom o1 -1.000 1.000 0.668 atom o1 -1.000 1.000 -0.668 atom o2 -0.500 1.000 0.000 atom o2 -1.000 1.500 0.000 atom o3 -0.500 1.500 1.203 atom o3 -0.500 1.500 -1.203 atom sr 1.000 1.000 -2.783 atom bi 0.500 0.500 -2.050 atom o1 0.500 0.500 -2.575 atom o3 1.000 1.000 -2.040 atom cu 0.000 1.000 0.000 atom sr 0.500 1.500 0.460 atom sr 0.500 1.500 -0.460 atom bi 0.000 1.000 1.193 atom bi 0.000 1.000 -1.193 atom o1 0.000 1.000 0.668 atom o1 0.000 1.000 -0.668 atom o2 0.500 1.000 0.000 atom o2 0.000 1.500 0.000 atom o3 0.500 1.500 1.203 atom o3 0.500 1.500 -1.203 atom cu 1.000 0.000 0.000 atom sr 1.500 0.500 0.460 atom sr 1.500 0.500 -0.460 atom bi 1.000 0.000 1.193 atom bi 1.000 0.000 -1.193 atom o1 1.000 0.000 0.668 atom o1 1.000 0.000 -0.668 atom o2 1.500 0.000 0.000 atom o2 1.000 0.500 0.000 atom o3 1.500 0.500 1.203 atom o3 1.500 0.500 -1.203 atom sr 1.000 1.000 2.783 atom bi 0.500 0.500 2.050 atom o1 0.500 0.500 2.575 atom o3 1.000 1.000 2.040 atom sr 2.000 0.000 -2.783 atom bi 1.500 -0.500 -2.050 atom o1 1.500 -0.500 -2.575 atom o3 2.000 0.000 -2.040 atom sr 0.000 2.000 -2.783 atom bi -0.500 1.500 -2.050 atom o1 -0.500 1.500 -2.575 atom o3 0.000 2.000 -2.040 atom sr 0.000 0.000 2.783 atom bi -0.500 -0.500 2.050 atom o1 -0.500 -0.500 2.575 atom o3 0.000 0.000 2.040 atom cu 0.000 -1.000 0.000 atom sr 0.500 -0.500 0.460 atom sr 0.500 -0.500 -0.460 atom bi 0.000 -1.000 1.193 atom bi 0.000 -1.000 -1.193 atom o1 0.000 -1.000 0.668 atom o1 0.000 -1.000 -0.668 atom o2 0.500 -1.000 0.000 atom o2 0.000 -0.500 0.000 atom o3 0.500 -0.500 1.203 atom o3 0.500 -0.500 -1.203 atom sr 1.000 -1.000 2.783 atom bi 0.500 -1.500 2.050 atom o1 0.500 -1.500 2.575 atom o3 1.000 -1.000 2.040 atom cu -1.000 0.000 0.000 atom sr -0.500 0.500 0.460 atom sr -0.500 0.500 -0.460 atom bi -1.000 0.000 1.193 atom bi -1.000 0.000 -1.193 atom o1 -1.000 0.000 0.668 atom o1 -1.000 0.000 -0.668 atom o2 -0.500 0.000 0.000 atom o2 -1.000 0.500 0.000 atom o3 -0.500 0.500 1.203 atom o3 -0.500 0.500 -1.203 atom sr -1.000 1.000 2.783 atom bi -1.500 0.500 2.050 atom o1 -1.500 0.500 2.575 atom o3 -1.000 1.000 2.040 atom sr 0.000 0.000 -2.783 atom bi -0.500 -0.500 -2.050 atom o1 -0.500 -0.500 -2.575 atom o3 0.000 0.000 -2.040 spec cu 0.265 0.37 spec sr 0.349 0.43 spec bi 0.293 0.62 spec o1 0.216 0.14 spec o2 0.216 0.14 spec o3 0.216 0.14 bonds cu cu 0.000 0.689 0.037 0.00 bonds cu sr 0.000 0.797 0.037 0.00 bonds cu bi 0.000 0.725 0.037 0.00 bonds cu o1 0.000 0.625 0.037 0.00 bonds cu o2 0.000 0.625 0.037 0.00 bonds cu o3 0.000 0.625 0.037 0.00 bonds sr sr 0.000 0.906 0.037 0.00 bonds sr bi 0.000 0.834 0.037 0.00 bonds sr o1 0.000 0.734 0.037 0.00 bonds sr o2 0.000 0.734 0.037 0.00 bonds sr o3 0.000 0.734 0.037 0.00 bonds bi bi 0.000 0.761 0.037 0.00 bonds bi o1 0.000 0.661 0.037 0.00 bonds bi o2 0.000 0.661 0.037 0.00 bonds bi o3 0.000 0.661 0.037 0.00 bonds o1 o1 0.000 0.562 0.037 0.00 bonds o1 o2 0.000 0.562 0.037 0.00 bonds o1 o3 0.000 0.562 0.037 0.00 bonds o2 o2 0.000 0.562 0.037 0.00 bonds o2 o3 0.000 0.562 0.037 0.00 bonds o3 o3 0.000 0.562 0.037 0.00 tmat 0.707 -0.707 0.000 0.000 0.000 1.000 -0.707 -0.707 0.000 dist 1000.000 inc 90.000 scale 50.000 rfac 1.00 bfac 1.00 switches 0 2 1 0 0 1 1 1 0 work/bs_icon0000664000000000000000000000434114023445763010301 0ustar #define bs_icon_width 50 #define bs_icon_height 50 static char bs_icon_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x01, 0x00, 0x00, 0xf8, 0x03, 0x80, 0x00, 0x02, 0x00, 0x00, 0xac, 0x06, 0x40, 0x00, 0x04, 0x00, 0x00, 0x57, 0x1d, 0x40, 0x00, 0x04, 0x00, 0x00, 0xab, 0x1a, 0x20, 0x00, 0x08, 0x00, 0x80, 0x55, 0x35, 0x20, 0x00, 0x08, 0x00, 0xc0, 0xaa, 0x6a, 0x20, 0x06, 0x08, 0x00, 0x40, 0x55, 0x55, 0xfe, 0x01, 0x08, 0x00, 0xc0, 0xaa, 0xea, 0x21, 0x00, 0x08, 0x00, 0x40, 0x55, 0x55, 0x40, 0x00, 0x04, 0x00, 0xc0, 0xaa, 0x6a, 0x40, 0x00, 0x04, 0x00, 0x40, 0xd5, 0x55, 0x80, 0x00, 0x02, 0x00, 0xc0, 0xaa, 0x6a, 0x00, 0x83, 0x01, 0x00, 0x80, 0xd5, 0x35, 0x00, 0x7c, 0x00, 0x00, 0x00, 0xab, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; work/c60.bs0000664000000000000000000000627114023445763007664 0ustar atom C -0.047 0.000 0.245 atom C 0.047 0.000 0.245 atom C 0.245 -0.047 0.000 atom C 0.245 0.047 0.000 atom C 0.000 0.245 0.047 atom C 0.000 0.245 -0.047 atom C 0.047 0.000 -0.245 atom C -0.047 0.000 -0.245 atom C -0.245 0.047 0.000 atom C -0.245 -0.047 0.000 atom C 0.000 -0.245 -0.047 atom C 0.000 -0.245 0.047 atom C 0.099 0.084 0.212 atom C 0.084 0.212 0.099 atom C 0.212 0.099 0.084 atom C -0.099 0.084 0.212 atom C -0.212 0.099 0.084 atom C -0.084 0.212 0.099 atom C -0.099 -0.084 0.212 atom C -0.212 -0.099 0.084 atom C -0.084 -0.212 0.099 atom C 0.099 -0.084 0.212 atom C 0.084 -0.212 0.099 atom C 0.212 -0.099 0.084 atom C -0.099 -0.084 -0.212 atom C -0.084 -0.212 -0.099 atom C -0.212 -0.099 -0.084 atom C 0.099 -0.084 -0.212 atom C 0.212 -0.099 -0.084 atom C 0.084 -0.212 -0.099 atom C 0.099 0.084 -0.212 atom C 0.212 0.099 -0.084 atom C 0.084 0.212 -0.099 atom C -0.099 0.084 -0.212 atom C -0.084 0.212 -0.099 atom C -0.212 0.099 -0.084 atom C 0.052 0.160 0.183 atom C 0.183 0.052 0.160 atom C 0.160 0.183 0.052 atom C -0.183 0.052 0.160 atom C -0.052 0.160 0.183 atom C -0.160 0.183 0.052 atom C -0.183 -0.052 0.160 atom C -0.052 -0.160 0.183 atom C -0.160 -0.183 0.052 atom C 0.052 -0.160 0.183 atom C 0.160 -0.183 0.052 atom C 0.183 -0.052 0.160 atom C -0.052 -0.160 -0.183 atom C -0.183 -0.052 -0.160 atom C -0.160 -0.183 -0.052 atom C 0.183 -0.052 -0.160 atom C 0.052 -0.160 -0.183 atom C 0.160 -0.183 -0.052 atom C 0.183 0.052 -0.160 atom C 0.052 0.160 -0.183 atom C 0.160 0.183 -0.052 atom C -0.052 0.160 -0.183 atom C -0.160 0.183 -0.052 atom C -0.183 0.052 -0.160 spec C 0.030 0.50 bonds C C 0.000 0.150 0.005 1.0 tmat -0.014 1.000 0.000 0.009 0.000 1.001 1.000 0.014 -0.008 dist 15.450 inc 5.000 scale 436.575 rfac 1.00 bfac 1.40 pos 0.000 0.000 light 0.000 0.000 0.000 switches 1 0 1 0 0 1 1 0 0 work/ch4.bs0000664000000000000000000000126714023445763007752 0ustar * Saved Tue Nov 14 13:45:05 1995 from ../xbs-bw/ch4.bs atom C 0.000 0.000 0.000 atom H 1.155 1.155 1.155 atom H -1.155 -1.155 1.155 atom H 1.155 -1.155 -1.155 atom H -1.155 1.155 -1.155 spec C 1.000 0.7 spec H 0.700 1.00 bonds C C 0.000 4.000 0.109 1.00 bonds C H 0.000 3.400 0.109 1.00 bonds H H 0.000 2.800 0.109 1.00 tmat 1.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 1.000 dist 12.000 inc 5.000 scale 20.000 rfac 1.00 bfac 1.00 pos 0.000 0.000 switches 1 0 1 0 0 1 1 0 0 work/cx0000775000000000000000000000117614023445763007305 0ustar #!/bin/csh -f # compile and link with xwindow routines if ($#argv == 0) goto help set n = $#argv set p = $argv[$n] @ m = $n - 1 set ops = ( $argv[1-$m] ) if (X$p == X-h) goto help if (! -e $p.c) then echo 'Not found:' $p.c exit 2 endif set echo rm -f $p.o # ------ compile ------- set i1 = ' ' set i2 = ' ' # gcc -c $i1 $i2 $p.c cc -c $ops $i1 $i2 $p.c # ------ link ---------- set LX = '-L/usr/X11R6/lib' set libs = '-lX11 -lm' # gcc -o $p $p.o $LX $libs cc -o $p $p.o $LX $libs exit help: echo "Usage: cx [ops] prog -- compile and link with X-window routines" echo " opt -O to optimize" exit work/cx.sgi0000775000000000000000000000141014023445763010055 0ustar #!/bin/csh -f etc # compile and link with xwindow routines - SGI version if ($#argv == 0) goto help set n = $#argv set p = $argv[$n] @ m = $n - 1 set ops = ( $argv[1-$m] ) if (X$p == X-h) goto help if (! -e $p.c) then echo 'Not found:' $p.c exit 2 endif set echo rm -f $p.o # ------ compile ------- set i1 = '-I/usr/include/X11' set i2 = "" # gcc -c -O2 $i1 $i2 $p.c cc -c $ops $i1 $i2 $p.c # ------ link ---------- #set LX = '-L/usr/lpp/X11/lib' set LX = '-L/usr/lib/X11' #set libs = '-lX11 -lXm -lXt -lm' set libs = '-lX11 -lXm -lXt -lm -lU77' set lmath = '-lm' #gcc -o $p $p.o $LX $libs cc -o $p $p.o $LX $libs exit help: echo "Usage: cx [ops] prog -- compile and link with X-window routines" echo " opt -O to optimize" exit work/debian/0000775000000000000000000000000014023445763010162 5ustar work/debian/README.examples0000664000000000000000000000044214023445763012657 0ustar run the script 'runex' from this directory . When you are finished playing with each model, hit 'Q' to go to the next one. Some of the examples have multiple frames. To step through the frames to show a "movie", use keys '[' and ']' On line help is toggled on and off with the 'h' key. work/debian/changelog0000664000000000000000000000572714023445763012047 0ustar xbs (0-11) unstable; urgency=medium * patch from Nilesh Patra to make build reproducible (fix mode of runex) (Closes: #985219) -- Matthew Vernon Sun, 14 Mar 2021 17:46:27 +0000 xbs (0-10) unstable; urgency=low * patch from Colin Watson to move to dh-based packaging. Thanks! (Closes: #792988) -- Matthew Vernon Wed, 29 Jul 2015 17:36:35 +0100 xbs (0-9) unstable; urgency=low * patch from Sylvestre Ledru to make this build with clang (Closes: #710387) * patch from Chris Lamb to make builds reproducible (add -n to gzip invocations) (Closes: #777007) -- Matthew Vernon Sat, 07 Mar 2015 22:59:59 +0000 xbs (0-8) unstable; urgency=low * update Build-Dep from x-dev to x11proto-core-dev (Closes: #515516) * move to newer Standards-Version * tidy up copyright file (thanks to Jari Aalto) * correct typo in man-page (Closes: #354711) * correct hyphens in man-page (thanks to Jari Aalto) * don't strip if DEB_BUILD_OPTIONS=nostrip set (Closes: #438287) * #include in xbs.c (thanks to Jari Aalto) -- Matthew Vernon Thu, 13 May 2010 17:30:49 +0100 xbs (0-7.3) unstable; urgency=low * Fix Build-Depends for new X layout (Closes: #346761) -- Matthew Vernon Sat, 14 Jan 2006 15:39:00 +0000 xbs (0-7.2) unstable; urgency=low * Remove incorrect Build-Depends on debmakr (Closes: #288979) * Tidy up rules to use POSIX chown syntax -- Matthew Vernon Sat, 15 Jan 2005 18:10:29 +0000 xbs (0-7.1) unstable; urgency=low * NMU. * Add Build-Depends on debmake and xlibs-dev. Closes: #190623. * Remove /usr/doc/xbs symlink. -- Daniel Schepler Thu, 21 Aug 2003 00:32:31 -0700 xbs (0-7) unstable; urgency=low * #include in subs.h (Closes: #126658) * Add several more #includes... * Tidy up a few lintian things (Closes: #126923) -- Matthew Vernon Sat, 5 Jan 2002 08:06:04 +0000 xbs (0-6) unstable; urgency=low * runex now looks in the correct directory (closes: #102414) -- Matthew Vernon Wed, 27 Jun 2001 20:23:52 +0100 xbs (0-5) unstable; urgency=low * Change section to science -- Matthew Vernon Tue, 10 Apr 2001 02:55:18 +0100 xbs (0-4) unstable; urgency=low * Move to /usr/share/doc (closes: #91716) * Move to /usr/share/man (closes: #91093) -- Matthew Vernon Mon, 09 Apr 2001 15:34:56 +0100 xbs (0-3) unstable; urgency=low * Change compiler to gcc (closes: #61587) -- Matthew Vernon Fri, 17 Nov 2000 20:32:51 +0000 xbs (0-2) unstable; urgency=low * New Maintainer -- Matthew Vernon Tue, 07 Dec 1999 16:22:46 +0000 xbs (0-1) unstable; urgency=low * Initial Release. -- John Lapeyre Mon, 3 Aug 1998 01:37:50 -0700 work/debian/compat0000664000000000000000000000000214023445763011360 0ustar 9 work/debian/control0000664000000000000000000000106714023445763011571 0ustar Source: xbs Section: science Priority: optional Maintainer: Matthew Vernon Build-Depends: debhelper (>= 9~), libx11-dev, x11proto-core-dev Standards-Version: 3.8.4 Package: xbs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: 3-d models and movies of molecules xbs ball-and-sticks plotting program can create still and moving three dimensional models of molecules. X11 and PostScript output are available. Models can be rotated, scaled, etc. Various labeling, shading, lighting, coloring options are available. work/debian/copyright0000664000000000000000000000072414023445763012120 0ustar This debian package was created by John Lapeyre on 3 Aug 1998 01:37:50 -0700 The source code was obtained from http://www.ihp-ffo.de/ By 2010-05-08, this URL no longer existed. Refer to: http://web.archive.org/web/*/http://www.ihp-ffo.de/~msm/ Copyright: Copyright (C) 1995 M. Methfessel License: This package is distributed under the terms of the GPL, which on most Debian systems can be found in /usr/share/common-licenses/GPL work/debian/examples0000664000000000000000000000005614023445763011724 0ustar debian/README.examples debian/runex *.bs *.mv work/debian/install0000664000000000000000000000001414023445763011546 0ustar xbs usr/bin work/debian/manpages0000664000000000000000000000001514023445763011674 0ustar debian/xbs.1 work/debian/rules0000775000000000000000000000054114023445763011242 0ustar #!/usr/bin/make -f %: dh $@ override_dh_installchangelogs: dh_installchangelogs Changes.xbs override_dh_installexamples: dh_installexamples chmod u=rwx,g=rx,o=x debian/xbs/usr/share/doc/xbs/examples/runex override_dh_compress: # Leave these uncompressed so that runex works. dh_compress -X.bs -X.mv override_dh_fixperms: dh_fixperms -Xrunex work/debian/runex0000664000000000000000000000032314023445763011244 0ustar #!/usr/bin/perl $dir = '/usr/share/doc/xbs/examples'; @exs = qw( in alfa bi2201 c60 gray grpht hIII pd8_10 ring serp stb tic ); foreach (@exs) { system "xbs $dir/$_"; } work/debian/xbs.10000664000000000000000000002053214023445763011042 0ustar .TH XBS 1 "August 3, 1998" .SH NAME xbs - ball and stick molecule modeling .SH SYNOPSIS .TP 8 .B xbs [-\fIid\fP] [\-h] [\-geo \fPgg\fP] .na [\-sc \fPx\fP] [\-color] .br [\-t \fPtitle\fP] [\-bw] [\-st] [\-rv] [\-autocolor] .br [\-hh] .ad .SH DESCRIPTION .LP \fBxbs\fP uses X-window graphics to produce ball-and-stick plots. It reads coordinates and other data from an input file \fBid\fP.bs (e.g. ch4.bs) and possibly different "frames" with shifted coordinates from an auxillary move file \fBIid\fP.mv (e.g. ch4.mv). The default files are in.bs and in.mv In the Debian distribution, see the example input files and script in /usr/share/doc/xbs/examples. .LP .LP .RS .ta 1i .nf .SH OPTIONS .TP 5 .B \-geo gg set window geometry .TP 5 .B \-sc x set scale factor .TP 5 .B \-t title set window title .TP 5 .B \-color use color .TP 5 .B \-bw b/w with smooth grays .TP 5 .B \-st b/w with stippled grays .TP 5 .B \-rv reverse colors .TP 5 .B \-autocolor chose own colors .TP 5 .B \-hh long help .TP 5 .B \-geo gg set window geometry .fi .RE .LP .SH INPUT FORMAT In a simple case, a file ch4.bs could look like this: atom C 0.000 0.000 0.000 atom H 1.155 1.155 1.155 atom H \-1.155 \-1.155 1.155 atom H 1.155 \-1.155 \-1.155 atom H \-1.155 1.155 \-1.155 spec C 1.000 0.7 spec H 0.700 1.00 bonds C C 0.000 4.000 0.109 1.00 bonds C H 0.000 3.400 0.109 1.00 bonds H H 0.000 2.800 0.109 1.00 This sets the coordinates in the format atom species x y z and how to draw each atomic species, in the format spec name radius color and how to draw bonds, in the format bonds name1 name2 min-length max-length radius color A move file contains additional frames like this: frame This is frame number two .br 0.000 0.000 0.000 1.155 1.155 1.155 \-1.155 \-1.155 1.155 1.155 \-1.155 \-1.155 \-1.155 1.155 \-1.155 After the keyword 'frame' comes an indentifying string, then come the coordinates for all the atoms. Line breaks can appear anywhere between the coordinates. Other input lines are also possible, namely the lines which set parameters (see below). Example: 'inc 5' sets the increment for the rotation to 5 degrees. In both files, lines starting with * and blank lines are comments. .SH USAGE After starting the program with 'xbs ch4' the plot can be controlled directly by selected keys. For example, to rotate the molecule use the cursor keys and the keys "," and "." The last two were chosen because they are below "<" and ">" whch look like arrows. To step through the frames to show a "movie", use keys '[' and ']'. A number of other keys are defined to function directly. More complicated functions are done by pressing 'i' to get an input line and then typing a command. Use 'xbs \-hh' to get information on keys and commands. Sizing: Keys '+' and '-' make the plot bigger or smaller. Perspective: Key p switches the perspective. Default is off. For pseudoperspective, the sphere sizes depend on the distance to the viewer but the positions on the page are unchanged. For true perspective, the sizes and the positions both change. The strength of the perspective effect depends on the distance to the viewer, which is shown in the status line. It is changed with keys 'd' and 'D' or can be set directly with command 'dist'. (Note: if you come too close and put the viewpoint inside an atom, the program will try to color the whole universe, which takes very long). Lighting: command 'gramp slope middle' greys out the atoms in the back by an exponential ramp. Command 'light x y z' shades the atoms somewhat as if light shines along vector (x,y,z). These commands only work in black/white mode. To switch back to normal coloring, enter 'gramp' or 'light' without arguments. Positioning: Keypad keys 8,6,4,2 move the plot about by an increment dpos (which can be set by the command 'dpos'). Keypad key '*' saves the current position as 'home' (or use command 'pos' to set the home position directly). Keypad key 7 moves the plot home. Positions are relative to the center of the window. Saving: command 'save' writes the data to a file (default Save.bs). If there are multiple frames, a move file is also written. The 'save' command has some options, see below. Printing: the command 'print' writes output to a postscript file, by default the file 'Bs.ps'. A print file stays open until it is explicitly closed. In this way several plots can be superimposed on the same page, using the keypad cursor keys to shift the subplots on the page. The 'print' command has some options, see below. .SH ONLINE HELP Typing 'xbs \-h' and 'xbs \-hh' gives short respectively long help. After starting xbs, key 'h' toggles an overview. This is the same information as is obtained with 'xbs \-hh'. On the input line, use 'help print' or 'print ?' or even 'print \-h' to get help on a specific command such as (in this case) print. This help also shows any possible options for the command. The space bar toggles extra information about the plot written into the window. .SH COMMANDS 1. Color: - A color is specified either as a number between 0 and 1 (gray value), three numbers between 0 and 1 (red, green, blue values or RGB), or as a color name from the file /usr/lib/X11/rgb.txt (or similar). - In the input file, the color of each species or bond is set in these three ways. - The following xbs options are related to color: \-color enable colors (default) bw uses greys only \-st uses grays only, stippled from a few values \-rv reverse all colors \-auto choose own colors. You can change these interactively with the update command. For consistency, black is now 0 and white is 1. The \-rv option switches this. The only reason for using \-bw or \-st is that the commands 'light' and 'gramp' do not work with colors. - The '\-auto' option is used to color the atoms in some standard way. These colors are set in routine 'set_auto_colors' in file subs.h. Starting from the species label (ie. Pd3 or Mg-a) the leading alpha part is extracted and capitalized (ie. PD or MG) and this string is used to select a color. The idea is to put one's favorite colors into the routine and then recompile xbs. - The command 'color' changes the colors of atoms interactively, ie. 'color C* green' changes the color of all matching species. To show the color of a species, use the command without specifying a color (ie. 'color C1' or 'color C-a'). - When data is saved with the 'save' command, the current colors (as set with 'color') are saved as a string. With 'save \-rgb' the RGB values are written instead of color names. If the \-rv option is used, the reversed colors are saved as RGB values. 2. Some commands have options, eg. print, save, update. For example: .TP 5 print \-T print and add some info as title .TP 5 print \-t 'text .... ' print and put text as title .TP 5 update \-rv update but switch on reversing .TP 5 update +rv update but switch off reversing .TP 5 update \-bw update but switch to black/white .TP 5 save \-rgb save with colors as rgb values .TP 5 save \-step n save with only every n'th frame (good to compress a big .mv file). .TP 5 Use 'help update' etc on the input line to see the options. .br .TP 5 3. Pattern matching for atom labels: * matches any string, + any char. This can be used in the 'color' command and in the 'bonds' lines in the input file (which determine what bonds are drawn). For example, 'bonds C* H* ...' selects all bonds between atoms like C1 and H34 etc. and 'bonds * * ...' selects all pairs. .TP 5 4. Other miscellaneous changes: - Key 'a' displays the axis directions. - Key 'n' shows atom names or numbers. Key 'c' shows the coordinates. - To close a postscript print file, use command 'close'. - Command 'dup x y z' duplicates all atoms shifted by (x,y,z). - Command 'cut x y z a b' cuts to those atoms between a and b along the vector (x,y,z). - The input line has a history list to retrieve old commands. Use the up and down arrows when the input line is active. - On some systems, the backspace key does not work to edit the input line. Therefore the left-arrow key was defined to have the backspace function also. .SH AUTHOR M. Methfessel .SH FILES \fI/usr/lib/xbs/in.bs\fP default data file .ta work/gray.bs0000664000000000000000000000401014023445763010223 0ustar atom Ti1 0.000 0.000 0.000 atom Ti2 2.000 0.000 0.000 atom Ti3 4.000 0.000 0.000 atom Ti4 6.000 0.000 0.000 atom Ti5 8.000 0.000 0.000 atom Ti6 10.000 0.000 0.000 atom Ti7 12.000 0.000 0.000 atom Ti8 14.000 0.000 0.000 atom Ti9 16.000 0.000 0.000 atom Ti10 18.000 0.000 0.000 atom Ti11 0.000 2.000 0.000 atom Ti12 2.000 2.000 0.000 atom Ti13 4.000 2.000 0.000 atom Ti14 6.000 2.000 0.000 atom Ti15 8.000 2.000 0.000 atom Ti16 10.000 2.000 0.000 atom Ti17 12.000 2.000 0.000 atom Ti18 14.000 2.000 0.000 atom Ti19 16.000 2.000 0.000 atom Ti20 18.000 2.000 0.000 atom Ti21 20.000 2.000 0.000 spec Ti1 0.900 0.00 spec Ti2 0.900 0.05 spec Ti3 0.900 0.10 spec Ti4 0.900 0.15 spec Ti5 0.900 0.20 spec Ti6 0.900 0.25 spec Ti7 0.900 0.30 spec Ti8 0.900 0.35 spec Ti9 0.900 0.40 spec Ti10 0.900 0.45 spec Ti11 0.900 0.50 spec Ti12 0.900 0.55 spec Ti13 0.900 0.60 spec Ti14 0.900 0.65 spec Ti15 0.900 0.70 spec Ti16 0.900 0.75 spec Ti17 0.900 0.80 spec Ti18 0.900 0.85 spec Ti19 0.900 0.90 spec Ti20 0.900 0.95 spec Ti21 0.900 1.00 bonds Ti Ti 1.000 3.000 0.200 0.20 tmat 1.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 1.000 dist 15.000 inc 3.000 scale 15.0 rfac 1.00 bfac 1.00 tauxy 380.000 310.000 gramp 0.000 0.000 switches 1 0 1 0 0 1 1 0 0 work/grpht.bs0000664000000000000000000001021614023445763010412 0ustar * graphite atom C 0.000 0.000 0.000 atom C 0.000 0.577 0.000 atom C1 0.000 0.000 1.362 atom C1 0.500 0.289 1.362 atom C 1.000 0.000 0.000 atom C 1.000 0.577 0.000 atom C1 1.000 0.000 1.362 atom C1 1.500 0.289 1.362 atom C -1.000 0.000 0.000 atom C -1.000 0.577 0.000 atom C1 -1.000 0.000 1.362 atom C1 -0.500 0.289 1.362 atom C -0.500 0.866 0.000 atom C -0.500 1.443 0.000 atom C1 -0.500 0.866 1.362 atom C1 0.000 1.155 1.362 atom C 0.500 0.866 0.000 atom C 0.500 1.443 0.000 atom C1 0.500 0.866 1.362 atom C1 1.000 1.155 1.362 atom C -1.500 0.866 0.000 atom C -1.500 1.443 0.000 atom C1 -1.500 0.866 1.362 atom C1 -1.000 1.155 1.362 atom C 0.500 -0.866 0.000 atom C 0.500 -0.289 0.000 atom C1 0.500 -0.866 1.362 atom C1 1.000 -0.577 1.362 atom C 1.500 -0.866 0.000 atom C 1.500 -0.289 0.000 atom C1 1.500 -0.866 1.362 atom C1 2.000 -0.577 1.362 atom C -0.500 -0.866 0.000 atom C -0.500 -0.289 0.000 atom C1 -0.500 -0.866 1.362 atom C1 0.000 -0.577 1.362 atom C2 0.000 0.000 2.724 atom C2 0.000 0.577 2.724 atom C3 0.000 0.000 4.086 atom C3 0.500 0.289 4.086 atom C2 1.000 0.000 2.724 atom C2 1.000 0.577 2.724 atom C3 1.000 0.000 4.086 atom C3 1.500 0.289 4.086 atom C2 -1.000 0.000 2.724 atom C2 -1.000 0.577 2.724 atom C3 -1.000 0.000 4.086 atom C3 -0.500 0.289 4.086 atom C2 -0.500 0.866 2.724 atom C2 -0.500 1.443 2.724 atom C3 -0.500 0.866 4.086 atom C3 0.000 1.155 4.086 atom C2 0.500 0.866 2.724 atom C2 0.500 1.443 2.724 atom C3 0.500 0.866 4.086 atom C3 1.000 1.155 4.086 atom C2 -1.500 0.866 2.724 atom C2 -1.500 1.443 2.724 atom C3 -1.500 0.866 4.086 atom C3 -1.000 1.155 4.086 atom C2 0.500 -0.866 2.724 atom C2 0.500 -0.289 2.724 atom C3 0.500 -0.866 4.086 atom C3 1.000 -0.577 4.086 atom C2 1.500 -0.866 2.724 atom C2 1.500 -0.289 2.724 atom C3 1.500 -0.866 4.086 atom C3 2.000 -0.577 4.086 atom C2 -0.500 -0.866 2.724 atom C2 -0.500 -0.289 2.724 atom C3 -0.500 -0.866 4.086 atom C3 0.000 -0.577 4.086 spec C 0.288 0.89 0.89 0.89 spec C1 0.288 0.89 0.89 0.89 spec C2 0.288 0.89 0.89 0.89 spec C3 0.288 0.89 0.89 0.89 bonds C C 0.000 0.750 0.041 1.00 1.00 1.00 bonds C1 C1 0.000 0.750 0.041 1.00 1.00 1.00 bonds C2 C2 0.000 0.750 0.041 1.00 1.00 1.00 bonds C3 C3 0.000 0.750 0.041 1.00 1.00 1.00 bonds C C1 0.000 1.370 0.041 1.00 1.00 1.00 bonds C1 C2 0.000 1.370 0.041 1.00 1.00 1.00 bonds C2 C3 0.000 1.370 0.041 1.00 1.00 1.00 bonds C3 C 0.000 1.370 0.041 1.00 1.00 1.00 tmat 0.950 0.313 0.006 -0.111 0.321 0.941 0.293 -0.894 0.340 dist 10.000 inc 3.000 scale 45.000 rfac 0.40 bfac 0.70 pos 0.000 0.000 switches 1 0 1 1 0 1 1 0 1 work/grsubs.h0000664000000000000000000003320014023445763010414 0ustar #include #include /* procedures for graphics */ #define MAXRGB 65535 #define HIGHGRAY 65535 /* top of gray scale */ #define LOWGRAY 0 /* bottom of gray scale */ /* ------- parse_color ------- */ int parse_color (str, rval, gval, bval, gray) char str[]; float *rval, *gval, *bval, *gray; { int isname,i,j,j0,rc; XColor color,exact; float r,g,b; char cname[81]; rc=1; strcpy (cname, str); j0=0; isname=0; for (j=0;j0) cname[j0+1]=0; if (j0>0) str[j0+1]=0; if (XLookupColor (dpy, cmap, cname, &exact, &color)) { r=exact.red / (float) MAXRGB; g=exact.green / (float) MAXRGB; b=exact.blue / (float) MAXRGB; } else { /* printf("parse_color: Cannot look up color <%s>\n", cname); */ r=g=b=1.0; rc=0; } } else { r=b=g=999.9; sscanf (cname, "%f %f %f", &r, &g, &b); if (r>999.0) r=0.0; if (g>999.0) g=r; if (b>999.0) b=r; } if (reverse) { r=1.0-r; g=1.0-g; b=1.0-b; } *rval=r; *gval=g; *bval=b; *gray=(r+g+b)/3.0; /* printf ("parse_color: rgb %.3f %.3f %.3f gray %.3f <%s>\n", *rval, *gval, *bval, *gray, cname); */ return rc; } /* ------- GetColorGC ------- */ int GetColorGC (gpixel) unsigned long gpixel; { int i,j,j0,icol; j0=-1; for (j=0;j=0) { /* printf("GetColorGC: already have pixel %d in slot %d\n",gpixel,j0); */ return j0; } if (ncol>=NCOL) { sprintf(emsg, "no more room for colors.. increase dimension NCOL"); return 0; } /* find a slot and make a graphics context */ icol=ncol; for (j=0;j rgb %.2f %.2f %.2f", spec[i].lab, spec[i].cname, spec[i].r, spec[i].g, spec[i].b); return 0; } if (! parse_color(cname, &spec[i].r, &spec[i].g, &spec[i].b, &spec[i].gray)) { sprintf (emsg, "Cannot identify color <%s>", cname); return 0; } strcpy (spec[i].cname, cname); if (color) { col1.red = spec[i].r*MAXRGB; col1.green = spec[i].g*MAXRGB; col1.blue = spec[i].b*MAXRGB; col2=col1; if (XAllocColor(dpy, cmap, &col1)) gpixel = col1.pixel; else { sprintf(emsg, "Cannot allocate color <%s>", cname); return 0; } icol=spec[i].col; spec[i].col=-1; FreeColorGC (icol); icol=GetColorGC (gpixel); spec[i].col=icol; } } } if (nmatch==0 && (strlen(cname)==0)) { sprintf (emsg, "No species matches \'%s\'", pat); return 0; } f=MAXRGB; sprintf (gmsg, "%s <%s> rgb %.2f %.2f %.2f shown as %.2f %.2f %.2f", list, cname, col2.red/f,col2.green/f,col2.blue/f, col1.red/f,col1.green/f,col1.blue/f); if (nmatch==0) return 0; return 1; } /* ------- SetSmoothGrays --- --- */ void SetSmoothGrays () { int i,allocated[NCOL]; int lastgnum; unsigned long gpixel; XColor color; int g1,g2,gnum; float dg; ngray=21; g1=HIGHGRAY; g2=LOWGRAY; dg=(g2-g1)/(ngray-1.0); lastgnum=0; for (i=0;ingray-1) igray=ngray-1; if (igray<0) igray=0; return graygc[igray]; } } /* ------ showline ------ */ void showline(drawable, x, y, s1, s2, s3) Drawable drawable; int x,y; char s1[],s2[],s3[]; { char sx[1001]; strcpy (sx, s1); strcat (sx, s2); strcat (sx, s3); XFillRectangle(dpy, drawable, gcbg, x, igh-y-9, x+6*strlen(sx), 12); XDrawString (dpy, drawable, labelgc, x, igh-y, sx, strlen(sx)); } /* ------ clearline ------ */ void clearline(drawable, x, y) Drawable drawable; int x,y; { XFillRectangle(dpy, drawable, gcbg, x, igh-y-11, igw-x-20, 14); } /* ------ DrawArrow ------ */ void DrawArrow(x0, y0, x1, y1, rad, str) float x0,y0,x1,y1,rad; char str[]; { int xx1,yy1,xx0,yy0,xx,yy,dd; xx1=midx+PSFAC*x1; yy1=midy-PSFAC*y1; xx0=midx+PSFAC*x0; yy0=midy-PSFAC*y0; xx=0.9*xx0+0.1*xx1; yy=0.9*yy0+0.1*yy1; XDrawLine (dpy, drw, shadowgc, xx, yy, xx1, yy1); XDrawLine (dpy, drw, gc, xx0, yy0, xx1, yy1); xx=xx1+0.3*(xx1-xx0); yy=yy1+0.3*(yy1-yy0)+4; dd=strlen(str)*6; XDrawLine (dpy, drw, labbggc, xx+2-dd/2, yy-4, xx+dd/2-2, yy-4); XDrawString (dpy, drw, labelgc, xx-dd/2, yy, str, strlen(str)); } /* ------ DrawLine ------ */ void DrawLine(x0, y0, x1, y1, thegc) float x0,y0,x1,y1; GC thegc; { int xx1,yy1,xx0,yy0; xx1=midx+PSFAC*x1; yy1=midy-PSFAC*y1; xx0=midx+PSFAC*x0; yy0=midy-PSFAC*y0; XDrawLine (dpy, drw, thegc, xx0, yy0, xx1, yy1); } /* ------ DrawBall ------ */ void DrawBall(gray, col0, x, y, rad) float gray,x,y,rad; int col0; { int xx,yy,rr,icol; GC gcfill; rr=PSFAC*rad; xx=midx+PSFAC*x; yy=midy-PSFAC*y; if (shadow) XDrawArc (dpy, drw, shadowgc, xx-rr, yy-rr, 2*rr, 2*rr, 0, 360*64); if (! wire) { gcfill=ChooseColor(gray,col0); XFillArc (dpy, drw, gcfill, xx-rr, yy-rr, 2*rr, 2*rr, 0, 360*64); } XDrawArc (dpy, drw, gc, xx-rr, yy-rr, 2*rr, 2*rr, 0, 360*64); } /* ------ DrawStick ------ */ void DrawStick(gray, col0, m1, m2) float gray, m1[6], m2[6]; int col0; { int x1,y1,x2,y2,i,igray; float x,y; XPoint pp[NPOINTS*2+1]; GC gcfill; if (bline) { x1=midx+PSFAC*m1[4]; y1=midy-PSFAC*m1[5]; x2=midx+PSFAC*m2[4]; y2=midy-PSFAC*m2[5]; if (shadow) XDrawLine (dpy, drw, shadowgc, x1, y1, x2, y2); XDrawLine (dpy, drw, gc, x1, y1, x2, y2); return; } for (i=0;i /* strchr(3), strstr(3) */ /* ----- various useful routines ------- */ void rx(char *msg) { printf("Error: %s\n", msg); exit(1); } void cross(float a[3], float b[3], float c[3]) { c[0]=a[1]*b[2]-a[2]*b[1]; c[1]=a[2]*b[0]-a[0]*b[2]; c[2]=a[0]*b[1]-a[1]*b[0]; return; } float sp(float a[3], float b[3]) { float sp1; sp1=a[0]*b[0]+a[1]*b[1]+a[2]*b[2]; return sp1; } void vscal(float a[3], float ca, float v[3]) { v[0]=a[0]*ca; v[1]=a[1]*ca; v[2]=a[2]*ca; return; } void vsum(float a[3], float b[3], float ca, float cb, float v[3]) { v[0]=ca*a[0]+cb*b[0]; v[1]=ca*a[1]+cb*b[1]; v[2]=ca*a[2]+cb*b[2]; return; } int parse_args (str,w) char str[],w[8][41]; { int i, num, reading, quoted; char *p; p=str; reading=quoted=0; num=-1; while (*p != 0) { if (reading) { if ((quoted&&(*p=='\'')) || ((!quoted) && (*p==' ')) ) { i++; w[num][i]=0; reading=0; } else { i++; w[num][i]=*p; } } else { if (*p != ' ') { num++; if (*p == '\'') { quoted=1; i=-1; } else { i=0; w[num][i]=*p; } reading=1; } } p++; } if (reading) { i++; w[num][i]=0; } num++; return num; } void strip (str1,str) char str[],str1[]; { int l,i,i1,i2; l=strlen(str); i1=0; for (i=0; i=0; i--) if ((str[i]!=' ') && (str[i]!='\n')) { i2=i+1; break; } for (i=i1;i <%s>\n", l, i1, i2, str, str1);*/ } int abbrev (str,ab,nchar) char str[],ab[]; int nchar; { int i,nc; if (strlen(str) > strlen(ab)) return 0; nc=strlen(str); if (nc0) q++; *q = 0; strcat(fid1,ext); } /* ----- match ------- */ int match (str, pat) char str[], pat[]; { char *p,*s; p=pat; s=str; while (*p != 0) { if (*p == '*') { /* found wildcard '*' in pattern */ p++; while (*p == '*') p++; if (*p == 0) return 1; /* trailing '*' matches all */ for (;;) { /* find match to char after '*' */ if (*s == 0) return 0; if ((*s == *p) || (*p == '+')) if (match(s+1,p+1)) return 1; /* ok if rest matches */ s++; } return 0; /* tried all cases but none worked */ } else { /* no wildcard -- char must match */ if (*s == 0) return 0; if ((*p != *s) && (*p != '+')) return 0; s++; } p++; } if (*s != 0) return 0; /* pattern but not string exhausted */ return 1; } /* ----- get_extent ----- */ void get_extent(xx1,xx2,yy1,yy2,zz1,zz2) float *xx1,*xx2,*yy1,*yy2,*zz1,*zz2; { float big,x1,x2,y1,y2,z1,z2; int i; big=1000000; if(nbas==0) big=0; x1=y1=z1=big; x2=y2=z2=-big; for (i=0;ix2) x2=p[i][0]; if (p[i][1]y2) y2=p[i][1]; if (p[i][2]z2) z2=p[i][2]; } *xx1=x1+center[0]; *xx2=x2+center[0]; *yy1=y1+center[1]; *yy2=y2+center[1]; *zz1=z1+center[2]; *zz2=z2+center[2]; } /* ----- atompos: position and radius on paper for an atom --- */ void atompos( float fac, float p[3], float rad, float zp[2], float *zr) { float y[3],q[3],v1[3],v2[3]; float xxx,za1,za2,zb1,zb2,a,b; if (pmode==1) { zp[0]=fac*p[0]; zp[1]=fac*p[1]; *zr=fac*rad; *zr=MAXRAD; if (dist0-p[2]>0) *zr=fac*rad*dist0/(dist0-p[2]); if (*zr > MAXRAD) *zr=MAXRAD; return; } vscal(p, 1.0, q); q[2] = q[2]-dist; vscal(p, 1.0, y); xxx = -sp(y,q)/sp(q,q); vsum(y, q, 1.0, xxx, y); if(sp(y,y)<=1e-3) { y[0]=1.0; y[1]=0.0; y[2]=0.0; } a = -rad*rad / sp(q,q); b = rad*sqrt((1.0+a) / sp(y,y)); vsum(q, y, a, b, v1); vsum(q, y, a, -b, v2); vsum(p, v1, 1.0, 1.0, v1); vsum(p, v2, 1.0, 1.0, v2); za1 = fac*v1[0]*dist / (dist-v1[2]); za2 = fac*v1[1]*dist / (dist-v1[2]); zb1 = fac*v2[0]*dist / (dist-v2[2]); zb2 = fac*v2[1]*dist / (dist-v2[2]); zp[0] = 0.5*(za1+zb1); zp[1] = 0.5*(za2+zb2); *zr = (zb1-za1)*(zb1-za1) + (zb2-za2)*(zb2-za2); *zr = 0.5 * sqrt(*zr); } /* ----- readclusterdata ---- */ int readclusterdata(char infile[]) { FILE *fp; char str[257],token[81]; char xxx [81]; char *p; int l,i,nn; if((fp = fopen (infile,"r")) == NULL) return 0; fgets(str, 257, fp); while(!feof(fp)) { l=strlen(str); str[l+1]='\0'; strcpy(token,"SNOT"); sscanf(str,"%s",token); if (p=strstr(str,"frame")) { if (nframe*nbas>FBMAX) rx("increase internal dimension FBMAX"); if (nframe>NFRMAX) rx("increase internal dimension NFRMAX"); p=p+6; sprintf(frstr[nframe], "%-80s", p); for (i=0;iNSPMAX) rx("increase internal dimension NSPMAX"); return 2; } if(!strcmp(token,"atom")) { atom[nbas].pol[0]=0; atom[nbas].pol[1]=0; atom[nbas].pol[2]=0; sscanf(str,"%*s %s %f %f %f %f %f %f", atom[nbas].lab, &atom[nbas].pos[0], &atom[nbas].pos[1], &atom[nbas].pos[2], &atom[nbas].pol[0], &atom[nbas].pol[1], &atom[nbas].pol[2]); nbas++; if (nbas>NAMAX) rx("increase internal dimension NAMAX"); return 2; } if(!strcmp(token,"bonds")) { sscanf(str,"%*s %s %s %f %f %f %n", bonds[nbonds].lab1, bonds[nbonds].lab2, &bonds[nbonds].min, &bonds[nbonds].max, &bonds[nbonds].rad, &n); strip (bonds[nbonds].cname, str+n); nbonds++; if (nbonds>NBTMAX) rx("increase internal dimension NBTMAX"); return 2; } if(!strcmp(token,"line")) { sscanf(str, "%*s %f %f %f %f %f %f", &xline[nxline].a[0],&xline[nxline].a[1],&xline[nxline].a[2], &xline[nxline].b[0],&xline[nxline].b[1],&xline[nxline].b[2]); nxline++; if (nxline>NLNMAX) rx("increase internal dimension NLNMAX"); return 1; } if(!strcmp(token,"tmat")) { sscanf(str, "%*s %f %f %f %f %f %f %f %f %f", &tmat[0][0], &tmat[0][1], &tmat[0][2], &tmat[1][0], &tmat[1][1], &tmat[1][2], &tmat[2][0], &tmat[2][1], &tmat[2][2]); return 1; } if(!strcmp(token,"dist") || !strcmp(token,"d")) { sscanf(str, "%*s %f", &dist0); return 1; } if(!strcmp(token,"inc")) {sscanf(str, "%*s %f", &dalfa); return 3;} if(!strcmp(token,"frm")) { sscanf(str, "%*s %d", &nn); if (nn>nframe || nn<1) { sprintf (emsg, "No frame %d available", nn); return 0; } if (iframe==nn-1) return 0; iframe=nn-1; return 2; } if(!strcmp(token,"light")) { light[0]=light[1]=light[2]=0.0; sscanf(str,"%*s %f %f %f", &light[0], &light[1], &light[2]); if (light[0]*light[0]+light[1]*light[1]+light[2]*light[2]<.01) { sprintf (gmsg, "Use standard coloring"); gmode=G_STD;; return 2; } if (color) { sprintf(emsg, "light: only works in b/w mode"); return 0; } gmode=G_LIGHT; return 2; } if(!strcmp(token,"step")) {sscanf(str,"%*s %d", &fstep); return 1;} if(!strcmp(token,"scale")) { sscanf(str,"%*s %f", &scale); scale=scale*igs; return 1; } if(!strcmp(token,"rfac")) {sscanf(str,"%*s %f", &radfac); return 1;} if(!strcmp(token,"bfac")) {sscanf(str,"%*s %f", &bndfac); return 1;} if(!strcmp(token,"amp")) {sscanf(str,"%*s %f", &); return 2;} if(!strcmp(token,"pos")) {sscanf(str,"%*s %f %f", &taux, &tauy); return 1;} if(!strcmp(token,"dpos")) { sscanf(str,"%*s %f", &dtaux); dtauy=dtaux; chginfo=1; return 0;} if(!strcmp(token,"gramp")) { gslope=gz0=0; sscanf(str, "%*s %f %f", &gslope, &gz0); if (gslope*gslope<0.1) { sprintf (gmsg, "Use standard coloring"); gmode=G_STD; return 2; } if (color) { sprintf(emsg, "gramp: only works in b/w mode"); return 0; } gmode=G_RAMP; return 2; } if(!strcmp(token,"switches")) { sscanf(str, "%*s %d %d %d %d %d %d %d %d %d", &usepixmap,&numbers,&grayvalues,&bline,&wire, &withbonds,&recenter,&pmode,&shadow); return 2; } sprintf(emsg,"Undefined command: %s", token); if (startup) printf ("Cannot understand line: %s\n", str); return 0; } /* ----- writeclusterdata ---- */ void writeclusterdata(char outfile[], int svstep, int svrgb) { FILE *fp; char nm[81]; int i,nn,n,nfrm; time_t ltime; char timestr[41]; if((fp = fopen (outfile,"w")) == NULL) { sprintf(emsg, "Cannot open file %s\n", outfile); return;} time(<ime); strcpy (timestr, ctime(<ime)); timestr[24]=0; fprintf (fp, "* Saved %s from %s\n\n", timestr, inf); for (i=0;i1) { strext (nm, outfile, "mv", 1); if((fp = fopen (nm,"w")) == NULL) { sprintf(emsg,"Cannot open file %s\n", nm); return;} nfrm=1; for (i=1;itop) top=sp; if (sp-1) { dis=0.0; for (m=0;m<3;m++) { dd = ball[k].pos[m] - ball[l].pos[m]; dis=dis+dd*dd; } dis=alat*sqrt(dis); if( (dis>=bonds[kb].min) && (dis<=bonds[kb].max) ) { i++; if (i>NBMAX) rx("increase internal dimension NBMAX"); stick[i].start = k; stick[i].end = l; stick[i].rad = bonds[kb].rad; stick[i].gray = bonds[kb].gray; stick[i].col = bonds[kb].col; } } } nbond=i+1; return nbond; } /* ----- duplicate_atoms ---- */ int duplicate_atoms(sh,helpme) float sh[3][6]; int helpme; { int k,l,iv,nbas1,ndup,fr,nn,nn1; float cx,cy,cz; if (helpme) { sprintf (gmsg,"Usage: dup vx vy vz - duplicate shifted by vector"); return 0; } ndup=0; for (iv=0;iv<6;iv++) { cx=sh[0][iv]; cy=sh[1][iv]; cz=sh[2][iv]; if (cx*cx+cy*cy+cz*cz>0.001) ndup++; } if (ndup==0) { sprintf (emsg, "Cannot dup for (0,0,0)"); return 0; } nbas1=nbas*(ndup+1); if (nframe*nbas1>FBMAX) { sprintf(emsg,"Cannot dup, internal dimension FBMAX too small"); return 0; } if (nbas*(ndup+1)>NAMAX) { sprintf(emsg,"Cannot dup, internal dimension NAMAX too small"); return 0; } for (iv=0;iv=0; fr--) { for (k=0;k\n", 1, frstr[0]); if (nframe>1) printf ("frame %-5d <%s>\n", 2, frstr[1]); if (nframe>2) printf ("frame %-5d <%s>\n", nframe, frstr[nframe-1]); return; } /* ----- draw_lines ----- */ void draw_lines (dash) int dash; { float p[3],q[3],fac,zp1[2],zp2[2],rad,r0; int n,m; fac=scale; for(n=0;n xtop) xtop=zp[k][0]+zr[k]; if (zp[k][1]-zr[k] < ybot) ybot=zp[k][1]-zr[k]; if (zp[k][1]+zr[k] > ytop) ytop=zp[k][1]+zr[k]; } /* printf ("bounds x %.3f %.3f y %.3f %.3f\n", xbot,xtop,ybot,ytop); */ /* ------- start loop over atoms; plot ball first ----- */ for (n=0;n=0) { br = bndfac*stick[ib].rad; bx = zp[kk][0]-zp[k][0]; by = zp[kk][1]-zp[k][1]; xx = sqrt(bx*bx+by*by); if ( xx*xx < 0.0001 ) continue; bx=bx/xx; by=by/xx; vsum(d, p[k], 1.0, -1.0, q1); vsum(d, p[kk], 1.0, -1.0, q2); vsum( p[kk], p[k], 1.0, -1.0, b); cth1 = sp(q1,b) / sqrt(sp(q1,q1)*sp(b,b)); cth2 = -sp(q2,b) / sqrt(sp(q2,q2)*sp(b,b)); th1=acos(cth1); th2=acos(cth2); crit1 = asin(br/rk) * fudgefac; if (crit1<0.0) crit1=0.0; crit2 = asin(br/rkk) * fudgefac; if (crit2<0.0) crit2=0.0; note=0; if(th2-0.5*PI>crit2 && kkk) note=2; /* if(th2-0.5*PI>crit2 && nnn) note=2; */ /* ------- plot a stick ------ */ if (note==1 || note==2) { w = sqrt(rk*rk - br*br); sth1 = sqrt(1.0-cth1*cth1); ww = w*sth1*zr[k]/rk; bb = br*zr[k]/rk; aa = br*cth1*zr[k]/rk; m1[0]=bx*aa; m1[1]=by*aa; m1[2]=-by*bb; m1[3]=bx*bb; m1[4]=zp[k][0]+bx*ww+taux; m1[5]=zp[k][1]+by*ww+tauy; w = sqrt(rkk*rkk-br*br); sth2 = sqrt(1.0-cth2*cth2); ww=w*sth2*zr[kk]/rkk; bb=br*zr[kk]/rkk; aa=br*cth2*zr[kk]/rkk; m2[0]=bx*aa; m2[1]=by*aa; m2[2]=-by*bb; m2[3]=bx*bb; m2[4]=zp[kk][0]-bx*ww+taux; m2[5]=zp[kk][1]-by*ww+tauy; beta=exp(gslope*(0.5*(p[k][2]+p[kk][2])-gz0)*gslope); if (grayvalues) { if (gmode==G_STD) gray = stick[ib].gray; else if (gmode==G_LIGHT) gray=0.5*(ball[k].gray+ball[kk].gray); else if(gmode==G_RAMP) gray=beta*stick[ib].gray+(1-beta)*GRAY0; } else gray=1.0; if (grayvalues && bline && gray>0.7) gray=0.7; if (!grayvalues && bline) gray=0.0; if (grayvalues && wire) gray=0.0; if (bline) gray=0.0; /* overrides... black if lines */ if (ball[k].special) dbond(1.0, m2, m1); else if(ball[kk].special) dbond(1.0, m1, m2); else { if(hardcopy) hardcopy_stick(gray, m1, m2); else /* printf ("draw stick %d col0=%d\n", ib, stick[ib].col); */ DrawStick(gray, stick[ib].col, m1, m2); } /* next part writes bond lengths onto the sticks */ if (bondnums) { bmidx=0.5*(zp[k][0]+zp[kk][0])+taux; bmidy=0.5*(zp[k][1]+zp[kk][1])+tauy; dd=0; for (m=0;m<3;m++) dd=dd+pow(ball[k].pos[m]-ball[kk].pos[m],2); dd=sqrt(dd); sprintf(label, "%.2f", dd); if(hardcopy) hardcopy_label (bmidx, bmidy, label); else LabelBG (bmidx, bmidy, 0.0, 1.0, label); } } } /* if (ib!=0) */ } /* end loop over nn */ } /* end loop over n */ if (showaxes) draw_axes(); if (showlines==1) draw_lines(0); if (showlines==2) draw_lines(1); } work/tic.bs0000664000000000000000000000247014023445763010050 0ustar atom Ti 2.481 2.481 1.806 atom Ti -2.481 -2.481 1.806 atom Ti -2.484 2.484 3.471 atom Ti 2.484 -2.484 3.471 atom Ti -2.484 -2.484 -3.471 atom Ti 2.484 2.484 -3.471 atom Ti -2.481 2.481 -1.806 atom Ti 2.481 -2.481 -1.806 atom C 0.894 0.894 4.968 atom C -0.894 -0.894 4.968 atom C 0.894 -0.894 -4.968 atom C -0.894 0.894 -4.968 atom C 4.751 0.730 -1.053 atom C 4.751 -0.730 1.053 atom C -4.751 0.730 1.053 atom C -4.751 -0.730 -1.053 atom C 0.730 4.751 -1.053 atom C -0.730 4.751 1.053 atom C 0.730 -4.751 1.053 atom C -0.730 -4.751 -1.053 spec Ti 1.800 0.80 spec C 0.800 0.6 bonds Ti Ti 1.000 6.000 0.200 1.0 bonds C C 1.000 4.000 0.150 0.6 tmat 1.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 1.000 dist 15.000 inc 3.000 scale 20.101 rfac 1.00 bfac 1.00 switches 1 0 1 0 0 1 1 0 0 work/xbs.c0000664000000000000000000010126114023445763007701 0ustar /* * xbs: an X-Window ball&sticks plotting program. * Copyright (C) 1995 Michael Methfessel * * 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 2 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, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * The author can be contacted as follows: * * Michael Methfessel * methfessel@ihp-ffo.de * Institute for Semiconductor Physics, PO Box 409, * D-15204 Frankfurt (Oder), Germany */ #include #include #include #include #include "X11/Xlib.h" #include #include #include #include #include #define W_HEIGHT 450 /* startup size */ #define W_WIDTH 550 #define NAMAX 2000 #define NBMAX 8000 #define NBTMAX 200 #define NSPMAX 50 #define NLNMAX 50 #define PI 3.1415926 #define MAXRAD 100.0 #define GRAY0 0.5 #define PSFAC 1.42 #define NPOINTS 5 #define NCOL 31 /* max number of colors to be allocated */ #define FONT "8x13" #define LABFONT "6x10" #define SHADOW 5 #define BELL_LEVEL 30 #define SVINP 10 #define FBMAX 70000 /* max for atoms times frames */ #define NFRMAX 8000 /* max num of frames */ /* return codes for interpret_keypress routine */ #define K_NOP 0 #define K_QUIT 1 #define K_REPLOT 2 #define K_RESETUP 3 #define K_UPDATE 4 #define K_READ_MORE 5 #define K_READ_DONE 6 /* codes for gray modes */ #define G_STD 0 #define G_RAMP 1 #define G_LIGHT 2 struct ballstr { float pos[3]; float rad; float gray; float r,g,b; int col; int special; char lab[21]; }; struct stickstr { int start; int end; float rad; float gray; int col; }; /* ----- global variables ------- */ struct { char lab[21]; float rad; float r,g,b; char cname[81]; int col; float gray; } spec[NSPMAX]; struct { char lab[21]; float pos[3]; float pol[3]; } atom[NAMAX]; struct { char lab1[21]; char lab2[21]; float min; float max; float rad; float r,g,b; char cname[81]; int col; float gray; } bonds [NBTMAX]; struct { float a[3],b[3]; } xline [NLNMAX]; /* for extra lines */ int natom,nbond; struct ballstr ball[NAMAX]; struct stickstr stick[NBMAX]; float arc[NPOINTS][2],xbot,xtop,ybot,ytop; Display *dpy; Window win; Drawable drw; Pixmap pixmap,bgrmap; GC gc,gcbg,graygc[NCOL],shadowgc,labelgc,labbggc,lngc; unsigned long fground, bground, gpx[NCOL]; int screen,depth,ncol; Screen *screenptr; Colormap cmap; float p[NAMAX][3]; int nspec,nbas,nbonds,ngray,nxline; int count; int ipr=10; int igeo,igx,igy,igw,igh; float igs; int midx,midy; float alat,dist,dist0,amp,dalfa,scale,tmat[3][3],radfac,bndfac; float taux,tauy,dtaux,dtauy,taux0,tauy0,bg; float gslope,gz0,light[3]; float center[3]; float frame[3][FBMAX]; char frstr[NFRMAX][81]; int nframe,iframe,saveframe; FILE *outfp; /* for PS output file */ int hardcopy,usepixmap,numbers,grayvalues,wrinfo,fstep,wrhelp; int bline,wire,withbonds,recenter,pmode,gmode,shadow,bondnums; int color,autocolor,reverse,coords,stippled; int showaxes,showlines; int replot,resetup,startup,chginfo; int num_print; float pr_xoff,pr_yoff; int lnum,xln; char inf[81]="in.bs", outf[81]="Save.bs", prf[81]="Bs.ps"; char inmv[81],prfsave[81],wname[81],curf[81]; char gmsg[101], emsg[101]; char svinput[SVINP][257]; int svline,nsvline=1; /* forward declarations */ void WriteStatus (Drawable draw); void WriteInfo (Drawable draw); void WriteHelp (); #include "grsubs.h" #include "hardcopy.h" #include "subs.h" /* ----- do_ConfigureNotify ---- */ int do_ConfigureNotify (eventp) XEvent *eventp; { XConfigureEvent *e = (XConfigureEvent *) eventp; int x1,x2,y1,y2,mmx,mmy,h1,w1,xx; /* x1=midx+PSFAC*(taux+xbot); x2=midx+PSFAC*(taux+xtop); y1=midy+PSFAC*(tauy+ybot); y2=midy+PSFAC*(tauy+ytop); printf ("old area: X %d %d Y %d %d\n", x1,x2,y1,y2); */ mmx=midx; mmy=midy; w1=igw; h1=igh; if ( (e->height!=igh) || (e->width!=igw)) { igw=e->width; igh=e->height; midx=igw/2; midy=igh/2-20; /* make new pixmaps but save contents of bgrmap */ XCopyArea(dpy, bgrmap, pixmap, gc, 0, 0, w1, h1, 0, 0); XFreePixmap (dpy, bgrmap); bgrmap = XCreatePixmap (dpy, win, igw, igh, depth); XFillRectangle(dpy, bgrmap, gcbg, 0, 0, igw, igh); XCopyArea(dpy, pixmap, bgrmap, gc, 0, 0, w1, h1, 0, 0); XFreePixmap (dpy, pixmap); pixmap = XCreatePixmap (dpy, win, igw, igh, depth); if (num_print == 0) { /* normally put back to middle on resize */ taux=taux0=0; tauy=tauy0=0; } else { /* but don't move plot about if building a print */ taux=taux-(midx-mmx)/PSFAC; taux0=taux0-(midx-mmx)/PSFAC; tauy=tauy-(midy-mmy-igh+h1)/PSFAC; tauy0=tauy0-(midy-mmy-igh+h1)/PSFAC; } return 1; } else return 0; } /* ----- close_print ---- */ int close_print(helpme) int helpme; { if (helpme) { sprintf (gmsg,"Usage: close - close current print file"); return 0; } if (num_print==0) { sprintf (emsg, "close: no print file is open"); return 0; } hardcopy_close(); XFillRectangle(dpy, bgrmap, gcbg, 0, 0, igw, igh); num_print=0; } /* ----- handle_print ---- */ int handle_print(msg1,msg2,helpme) char msg1[], msg2[]; int helpme; { char xx[81]; float x,y,x1,y1,z1,x2,y2,z2; int ix,iy,dd; Drawable drw1; if (helpme) { sprintf (gmsg,"Usage: print [-T] [-t title] [file] - print to PS file"); return 0; } sprintf (gmsg,"Print:"); if (num_print>0 && strcmp(prf,prfsave)) { close_print(0); sprintf (xx, " %s closed,", prfsave); strcat (gmsg, xx); replot=1; } if (num_print==0) { hardcopy_init(prf); sprintf (xx, " %s opened,", prf); strcat (gmsg, xx); pr_xoff=0; pr_yoff=ybot-15; } else { hardcopy_redefine(); } num_print++; strcpy (prfsave,prf); hardcopy=1; bs_transform(natom, ball); bs_kernel(natom, ball, nbond, stick); hardcopy=0; drw=bgrmap; bs_kernel(natom, ball, nbond, stick); if (strlen(msg1)>0) { x=pr_xoff+taux; y=pr_yoff+tauy; hardcopy_label (x, y, msg1); ix=midx+PSFAC*x; iy=midy-PSFAC*y; dd=strlen(msg1)*6; XDrawString (dpy, win, labelgc, ix-dd/2, iy, msg1, strlen(msg1)); XDrawString (dpy, bgrmap, labelgc, ix-dd/2, iy, msg1, strlen(msg1)); } if (strlen(msg2)>0) { x=pr_xoff+taux; y=pr_yoff+tauy-10; hardcopy_label (x, y, msg2); ix=midx+PSFAC*x; iy=midy-PSFAC*y; dd=strlen(msg2)*6; XDrawString (dpy, win, labelgc, ix-dd/2, iy, msg2, strlen(msg2)); XDrawString (dpy, bgrmap, labelgc, ix-dd/2, iy, msg2, strlen(msg2)); } fflush (outfp); sprintf(xx," write(%d) to %s", num_print, prf); strcat (gmsg, xx); } /* ----- update_from_file---- */ int update_from_file () { char msg1[81],msg2[81],str[81],pat[81],w[8][41]; char *p; float sh[3][6],cut[3],cut1,cut2; int i,j,n,rc,nw,svstep,svrgb,helpme; nbas=0; nbonds=0; nspec=0; nframe=1; if (!readclusterdata(inf)) { sprintf (emsg, "Cannot update from file %s", inf); return 0; } sprintf (curf, "%s ", inf); clearline (win, 10, 8); showline (win, 10, 8, "Reading ", inmv, " .. please wait"); XFlush(dpy); sprintf(gmsg,"Updated from %s ", inf); if(readclusterdata(inmv)) { sprintf(gmsg,"Updated from %s and %s", inf, inmv); sprintf(frstr[0], "%s", "start ..\0"); strcat (curf, inmv); } for (i=0;i0) strip(msg2, frstr[iframe]); } else if (w[i][0]=='-') { sprintf (emsg, "print: unknown flag %s", w[i]); return 0; } else { strext (prf, w[i], "ps", 0); } i++; } handle_print (msg1, msg2, helpme); } } else if (abbrev(w[0],"close",2)) { if (!helpme) sprintf(gmsg, "Print: %s closed after %d write%s", prf, num_print, num_print==1 ? "" : "s"); close_print (helpme); replot=1; } else if (abbrev(w[0],"dup",3)) { for (i=0;i<3;i++) for (j=0;j<6;j++) sh[i][j]=0; sscanf(inp, "%*s %f %f %f %f %f %f %f %f %f %f %f %f", &sh[0][0],&sh[1][0],&sh[2][0],&sh[0][1],&sh[1][1],&sh[2][1], &sh[0][2],&sh[1][2],&sh[2][2],&sh[0][3],&sh[1][3],&sh[2][3], &sh[0][4],&sh[1][4],&sh[2][4],&sh[0][5],&sh[1][5],&sh[2][5]); if (duplicate_atoms (sh,helpme)) resetup=2; } else if (abbrev(w[0],"cut",3)) { cut[0]=cut[1]=cut[2]=cut1=cut2=0; sscanf(inp, "%*s %f %f %f %f %f", &cut[0], &cut[1], &cut[2], &cut1, &cut2); if (cut_atoms (cut, cut1, cut2, helpme)) resetup=2; } else if (abbrev(w[0],"color",3)) { strcpy (pat,""); sscanf(inp, "%*s %s %n", pat, &n); for (i=n;i-1) strcpy (wname, argv[k]); if (igeo & WidthValue) hint.width=igw; else igw=hint.width; if (igeo & HeightValue) hint.height=igh; else igh=hint.height; if (igeo & XValue) hint.x=igx; if (igeo & YValue) hint.y=igy; /* need next line to make +0+0 work */ if ((igeo & XValue) && (hint.x==0) && (hint.y==0)) hint.x=1; if (j==1) { printf ("\nUsage: xbs [flags] id -- ball-and-sticks plotting program\n" "Data is read from files id.bs and id.mv\n" "\nFlags: -geo gg set window geometry \n" " -sc x set scale factor\n" " -t title set window title\n" " -color use color\n" " -bw b/w with smooth grays\n" " -st b/w with stippled grays\n" " -rv reverse colors\n" " -autocolor chose own colors\n" " -hh long help\n" "\nHelp: Enter 'xbs -hh' to get an overview.\n" "For on-line help, press key 'h' for the overview or use\n" "'help ' or ' ?' in the input line for information\n" "on a specific command (including possible options).\n" "Request the input line with key 'i'.\n" ); printf ("\nSettings: geometry %dx%d%+d%+d, scale %.2f,\n" "color %s, autocolor %s, stippled %s, reverse %s\n ", hint.width,hint.height,hint.x,hint.y, igs, yn[color], yn[autocolor], yn[stippled], yn[reverse] ); exit (0); } if (!strstr(inf,".")) strcat(inf, ".bs"); /* ----- read data file ------ */ sprintf (curf,"%s ", inf); nframe=1; strext (inmv, inf, "mv", 1); if (! readclusterdata(inf)) { printf ("Could not open input file %s\n", inf); exit (1); } if (natom<=80) usepixmap=1; /* ----- setup ---- */ dpy = XOpenDisplay (""); if (! dpy) { printf ("Error: could not open display\n"); exit(1); } screen = DefaultScreen (dpy); screenptr = DefaultScreenOfDisplay(dpy); bground = WhitePixel (dpy, screen); fground = BlackPixel (dpy, screen); if ((igeo & XValue) && (igeo & XNegative)) hint.x=igx+WidthOfScreen(screenptr)-hint.width-18; if ((igeo & YValue) && (igeo & YNegative)) hint.y=igy+HeightOfScreen(screenptr)-hint.height-34; hint.flags = PPosition | PSize; win = XCreateSimpleWindow (dpy, DefaultRootWindow(dpy), hint.x, hint.y, hint.width, hint.height, 0, 0, bground); midx=igw/2; midy=igh/2-20; iconmap = XCreateBitmapFromData(dpy, win, bs_icon_bits, bs_icon_width, bs_icon_height); XSetStandardProperties (dpy, win, wname, wname, iconmap, argv, argc, &hint); gc = XCreateGC (dpy, win, 0, 0); XSetBackground (dpy, gc, bground); XSetForeground (dpy, gc, fground); XSelectInput (dpy, win, (KeyPressMask|ExposureMask|StructureNotifyMask)); XMapRaised (dpy, win); drw=win; /* ----- additional setup for graphics ---- */ font=XLoadFont (dpy, FONT); XSetFont (dpy, gc, font); gcbg = XCreateGC (dpy, win, 0, 0); XSetForeground (dpy, gcbg, bground); shadowgc = XCreateGC (dpy, win, 0, 0); XSetLineAttributes (dpy, shadowgc, SHADOW, LineSolid, CapRound, JoinBevel); XSetForeground (dpy, shadowgc, bground); labelgc = XCreateGC (dpy, win, 0, 0); XSetForeground (dpy, labelgc, fground); font=XLoadFont (dpy, LABFONT); XSetFont (dpy, labelgc, font); labbggc = XCreateGC (dpy, win, 0, 0); XSetLineAttributes (dpy, labbggc, 13, LineSolid, CapRound, JoinMiter); XSetForeground (dpy, labbggc, bground); lngc = XCreateGC (dpy, win, 0, 0); XSetLineAttributes (dpy, lngc, 1, LineOnOffDash, CapRound, JoinBevel); cmap = XDefaultColormap (dpy, screen); for (i=0;i0) WriteHelp (); } else replot=1; } break; case ConfigureNotify: if (do_ConfigureNotify (&ev)) replot=1; if (startup) replot=0; break; /* ----- process keypress events ----- */ case KeyPress: strcpy (gmsg, ""); strcpy (emsg, ""); keytype=interpret_keypress (&ev, &inpmode, input, &ixyz, &alfa); switch (keytype) { case K_QUIT: finished = 1; break; case K_REPLOT: replot=1; break; case K_RESETUP: resetup=1; break; case K_READ_MORE: clearline (win, 10, 8); showline (win, 10, 8, "Input: ", input, "_ "); break; case K_READ_DONE: clearline(win, 10, 8); if (strlen(input)>0) { for (k=SVINP-1; k>1; k--) strcpy(svinput[k],svinput[k-1]); strcpy(svinput[1],input); nsvline++; } interpret_input (input); break; case K_UPDATE: update_from_file(); break; } break; } /* switch (ev.type) */ /* ----- repeat the setup steps ------- */ if (resetup) { natom = ball_list (ball, 0); getframe (ball, iframe); nbond = stick_list (ball, stick); replot=1; } /* ----- redraw the plot -------- */ if (replot) { rotmat (ixyz, alfa*PI/180.0); bs_transform (natom, ball); if (usepixmap) { drw=pixmap; XCopyArea(dpy, bgrmap, pixmap, gc, 0, 0, igw, igh, 0, 0); } else { drw=win; if (wrinfo) WriteInfo (drw); if (wrhelp>0) WriteHelp (); XCopyArea(dpy, bgrmap, win, gc, 0, 0, igw, igh, 0, 0); } showline(win, 10, 8, "Busy ", " "," "); bs_kernel(natom, ball, nbond, stick); if (startup) showline(win, 10, 8, "Reading ", inmv, " .."); WriteStatus (drw); if (wrinfo) WriteInfo (drw); if (wrhelp>0) WriteHelp (); if (usepixmap) XCopyArea(dpy, pixmap, win, gc, 0, 0, igw, igh, 0, 0); if (startup) { showline(win, 10, 8, "Reading ", inmv, " .. please wait"); XFlush(dpy); k=nframe; if (readclusterdata(inmv)) { sprintf(frstr[0], "%s", "start ..\0"); sprintf (gmsg, "%d frames were read from %s", nframe-k, inmv); strcat (curf, inmv); WriteStatus (win); } else sprintf (gmsg, "No frames in %s", inmv); startup=0; } if (! usepixmap) XCopyArea(dpy, win, pixmap, gc, 0, 0, igw, igh, 0, 0); showline(win, 10, 8, "Done ", ""," "); /* Discard extra keypress events so that rotation stops after key is released. Leave one for smooth motion. */ i=0; while (XCheckTypedEvent(dpy, KeyPress, &ev1)) {i=1;} if (i==1) XPutBackEvent(dpy, &ev1); } /* ----- handle messages, update info if needed -------- */ if (strlen(emsg)>0) { clearline (win, 10, 8); showline(win, 10, 8, "+++ ", emsg, ""); showline(pixmap, 10, 8, "+++ ", emsg, ""); XBell (dpy, BELL_LEVEL); } else if (strlen(gmsg)>0) { clearline (win, 10, 8); showline(win, 10, 8, gmsg, "", ""); showline(pixmap, 10, 8, gmsg, "", ""); } if ( (!replot) && wrinfo && chginfo) WriteInfo (win); } /* while */ /* ----- clean up and exit -------- */ if (num_print>0) hardcopy_close(); XFreeGC (dpy, gc); XDestroyWindow (dpy, win); XCloseDisplay (dpy); } /* ------- intepret_keypress subroutine ------ */ int interpret_keypress (XEvent *ev, int *inpmode, char input[], int *ixyz, float *alfa) { int count,l; char buff[8],msg[81]; KeySym key; count = XLookupString (&ev->xkey, buff, 8, &key, 0); if(*inpmode) { l=strlen(input); if (key==XK_Up) { if (svline==0) strcpy (svinput[0], input); if (svline0) svline--; strcpy (input, svinput[svline]); return K_READ_MORE; } if (key==XK_Down) {strcpy (input, ""); return K_READ_MORE; } if (key==XK_Return) { *inpmode=0; return K_READ_DONE; } if (key==XK_BackSpace || key==XK_Left) { if(l>0) input[l-1]='\0'; return K_READ_MORE; } if (count>0) {input[l]=buff[0]; input[l+1]='\0';} return K_READ_MORE; } if (key==XK_bracketright) { if (iframe==nframe-1) { sprintf(gmsg,"Last frame"); return K_NOP; } iframe=iframe+fstep; if (iframe>=nframe) iframe=nframe-1; return K_RESETUP; } if (key==XK_bracketleft) { if (iframe==0) {sprintf(gmsg,"First frame"); return K_NOP; } iframe=iframe-fstep; if (iframe<=0) iframe=0; return K_RESETUP; } if (key==XK_backslash) { saveframe=iframe; sprintf(gmsg,"Marked frame %d", saveframe+1); return K_NOP; } if (key==XK_bar) { if (saveframe==-99) {sprintf(emsg,"No frame was marked"); return K_NOP; } if (saveframe<0 || saveframe>=nframe) { sprintf(emsg,"Marked frame %d does not exist", saveframe+1); return K_NOP; } if (iframe==saveframe) {sprintf(gmsg,"Already at frame %d", saveframe+1); return K_NOP; } iframe=saveframe; sprintf(gmsg,"Go back to frame %d", saveframe+1); return K_RESETUP; } if (key==XK_braceleft) {iframe=0; return K_RESETUP; } if (key==XK_braceright) {iframe=nframe-1; return K_RESETUP; } if (key==XK_Q) return K_QUIT; if (key==XK_U) return K_UPDATE; if (key==XK_h) { wrhelp=1-wrhelp; return K_REPLOT;} if (key==XK_i) {strcpy(input, ""); *inpmode = 1; svline=0; return K_READ_MORE; } *alfa=0; *ixyz=0; if (key==XK_Right) {*alfa = dalfa; *ixyz=1; return K_REPLOT;} if (key==XK_Left) {*alfa = -dalfa; *ixyz=1; return K_REPLOT;} if (key==XK_Up) {*alfa = -dalfa; *ixyz=2; return K_REPLOT;} if (key==XK_Down) {*alfa = dalfa; *ixyz=2; return K_REPLOT;} if (key==XK_comma) {*alfa = dalfa; *ixyz=3; return K_REPLOT;} if (key==XK_period) {*alfa = -dalfa; *ixyz=3; return K_REPLOT;} if (key==XK_p) {pmode++; if (pmode==3) pmode=0; return K_REPLOT;} if (key==XK_P) {pmode--; if (pmode==-1) pmode=2; return K_REPLOT;} if (key==XK_d) {dist0 = dist0*1.05 ; return K_REPLOT;} if (key==XK_D) {dist0 = dist0/1.05 ; return K_REPLOT;} if (key==XK_r) {return K_REPLOT;} if (key==XK_plus || key==XK_KP_Add) {scale = scale*1.05; return K_REPLOT;} if (key==XK_minus || key==XK_KP_Subtract) {scale = scale/1.05; return K_REPLOT;} if (key==XK_KP_6) {taux = taux + dtaux; return K_REPLOT;} if (key==XK_KP_4) {taux = taux - dtaux; return K_REPLOT;} if (key==XK_KP_8) {tauy = tauy + dtauy; return K_REPLOT;} if (key==XK_KP_2) {tauy = tauy - dtauy; return K_REPLOT;} if (key==XK_KP_7) {taux = taux0; tauy = tauy0; return K_REPLOT;} if (key==XK_KP_Multiply) { taux0 = taux; tauy0 = tauy; sprintf(gmsg, "New home position: %.2f %.2f", taux0, tauy0); chginfo=1; return K_NOP; } if (key==XK_l) { bline=1-bline; if (withbonds) return K_REPLOT; chginfo=1; if (bline) sprintf (gmsg, "Bonds as lines "); else sprintf (gmsg, "Bonds as cylinders "); return K_NOP; } if (key==XK_L) { showlines=showlines+1; if (showlines==3) showlines=0; chginfo=1; if (showlines==1) sprintf (gmsg, "Draw extra lines lines "); if (showlines==2) sprintf (gmsg, "Dash extra lines lines "); if (showlines==0) sprintf (gmsg, "Supress extra lines lines "); if (nxline>0) return K_REPLOT; } if (key==XK_s) { shadow=1-shadow; return K_REPLOT; } if (key==XK_a) { showaxes=1-showaxes; return K_REPLOT; } if (key==XK_w) { wire=1-wire; return K_REPLOT; } if (key==XK_x) { chginfo=1; usepixmap=1-usepixmap; if(usepixmap) sprintf (gmsg, "Draw to pixmap buffer"); else sprintf (gmsg, "Draw to screen"); chginfo=1; return K_NOP; } if (key==XK_space) {wrinfo=1-wrinfo; return K_REPLOT; } if (key==XK_b) { withbonds=1-withbonds; return K_REPLOT; } if (key==XK_n) { numbers=numbers+1; if (numbers==3) numbers=0; return K_REPLOT; } if (key==XK_c) { coords=1-coords; return K_REPLOT; } if (key==XK_N) { bondnums=1-bondnums; return K_REPLOT;} if (key==XK_g) { grayvalues=1-grayvalues; return K_REPLOT;} return K_NOP; } /* ------- wln ----------------- */ void wln (char x[]) { int xx; if (!startup) { xx=xln; if (xx<1) xx=1; XDrawString (dpy, drw, labelgc,xx, 10*lnum, x, strlen(x)); lnum++; } else printf ("%s\n", x); } /* ------- WriteHelp ----------------- */ void WriteHelp () { lnum=1; /* commands */ xln=igw-250; wln(" "); wln("COMMANDS for input line:"); wln(" help cmd - on-line help"); wln(" inc degrees - rotation increment"); wln(" pos x y - set position"); wln(" dpos dxy - shift increment"); wln(" dist d - set distance"); wln(" rfac fac - scale all radii"); wln(" bfac fac - scale all bonds"); wln(" scale fac - scale plot"); wln(" gramp slope mid - gray ramp"); wln(" light x y z - light direction"); wln(" step n - set frame step"); wln(" dup x y z - duplicate"); wln(" cut x y z a b - planar cut"); wln(" frm n - go to frame"); wln(" color pat cname - query or set color"); wln(" save fname - save data"); wln(" update fname - update from file"); wln(" print fname - postscript output"); wln(" close - close print file"); /* keys */ xln=igw-200; wln(" "); wln("KEYS (KP=Keypad):"); wln(" i activate input line"); wln(" h help"); wln(" space info"); wln(" cursor rotate R/L, U/D"); wln(" , . rotate in plane"); wln(" + - zoom"); wln(" KP 8642 shift plot"); wln(" KP 7 shift home"); wln(" KP * set home"); wln(" r redraw"); wln(" n atom numbers"); wln(" c coordinates"); wln(" N bond lengths"); wln(" w wire mode"); wln(" g gray/bw"); wln(" b bonds"); wln(" l cylinders/lines"); wln(" L extra lines"); wln(" p perspective"); wln(" a show axes"); wln(" s line shadows"); wln(" x pixmap buffer"); wln(" d D distance"); wln(" [ ] step frames fw/bk"); wln(" { } first/last frame"); wln(" \\ | mark/goto frame"); wln(" U update from file"); wln(" Q quit"); /* input */ xln=igw-250; wln(" "); wln("INPUT data format:"); wln(" atom label x y z "); wln(" spec label radius color"); wln(" bonds lab1 lab2 min max radius color"); wln(" frame str x1 .. - add frame"); wln(" tmat t1 .. t9 - viewpoint"); wln("Also commands which set parameters"); } /* ------- WriteInfo ----------------- */ void WriteInfo (Drawable draw) { int i; float x1,x2,y1,y2,z1,z2; char str[201],stt[201]; char gmd[3][8] = {"std","ramp","light"}; get_extent(&x1,&x2,&y1,&y2,&z1,&z2); if (natom==1) sprintf(str,"%d atom, ", natom); else sprintf(str,"%d atoms, ", natom); if (nbond==1) sprintf(stt,"%d bond ", nbond); else sprintf(stt,"%d bonds", nbond); showline(draw, 10, igh-20, "", str, stt); sprintf(str, "extent x %.2f to %.2f, y %.2f to %.2f, z %.2f to %.2f", x1,x2,y1,y2,z1,z2); showline(draw, 10, igh-30, "", str, ""); sprintf(str, "tmat %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f", tmat[0][0], tmat[0][1], tmat[0][2], tmat[1][0], tmat[1][1], tmat[1][2], tmat[2][0], tmat[2][1], tmat[2][2]); showline(draw, 10, igh-40, "", str, ""); sprintf(str, "dist %.2f, scale %.2f, rfac %.2f, bfac %.2f", dist0,scale,radfac,bndfac); showline(draw, 10, igh-50, "", str, ""); sprintf(str, "gmode %s, ramp,slope %.2f %.2f, light %.2f %.2f %.2f", gmd[gmode], gslope, gz0, light[0],light[1],light[2]); showline(draw, 10, igh-60, "", str, ""); sprintf(str, "pos (%.1f,%.1f), dpos %.1f, home (%.1f,%.1f)", taux, tauy, dtaux, taux0, tauy0); showline(draw, 10, igh-70, "", str, ""); sprintf(str, "color %d, reverse %d, stippled %d, pixmap %d, gray %d, " "bonds %d, lines %d", color, reverse, stippled, usepixmap, grayvalues, withbonds, bline); showline(draw, 10, igh-80, "", str, ""); sprintf(str, "input %s %s, save %s, print %s, nprint=%d", inf,inmv,outf,prf,num_print); showline(draw, 10, igh-90, "", str, ""); } /* ------- WriteStatus ----------------- */ void WriteStatus (Drawable draw) { char pers[3][8] = {"off","pseudo","true"}; char str[201]; sprintf(str," %5.2f %5.2f %5.2f inc=%.1f" " d=%.2f p=%s", tmat[2][0],tmat[2][1],tmat[2][2], dalfa, dist0, pers[pmode]); showline(draw, 10, 20, "View:", str, ""); sprintf(str,"Frame %3d of %d (step %d) <%s>", iframe+1, nframe, fstep, frstr[iframe]); showline(draw, 10, 44, "Files: ", curf, ""); showline(draw, 10, 32, str, "", ""); }