home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff253.lzh / Elements / Source / support.c < prev   
C/C++ Source or Header  |  1989-10-19  |  15KB  |  449 lines

  1. #include "elements.h"
  2.  
  3. extern struct IntuiText CAMMText, TextText, ElementText;
  4.  
  5. display_subpart()
  6. {
  7.    struct Window *window;
  8.    struct RastPort *rp;
  9.    static int vertlines[] = {136,248,360,480,560};
  10.    static int boxwidth[] = {0,112,112,120,80,56};
  11.    register USHORT i;
  12.    long x, y;
  13.    static char *text0[] = {"","Symbol","Rest mass (kg)","Rel. atomic mass",
  14.       "Charge (C)","Radius (m)","Spin quantum #","Magnetic Moment!"};
  15.    static char *text1[] = {"Neutron","Proton","Electron*","Neutrino*","Photon"};
  16.    static char *text2[] = {"n","p","e (e-)","v","y"};
  17.    static char *data0[] = {"1.67495x10-+2+7","1.67265x10-+2+7","9.1095x10-+3+1","~0","0"};
  18.    static char *data1[] = {"1.008665","1.007276","5.48580x10-+4","~0","0"};
  19.    static char *data2[] = {"0","1.60219x10-+1+9","-1.60219x10-+1+9","0","0"};
  20.    static char *data3[] = {"8x10-+1+6","8x10-+1+6","<1x10-+1+6","~0","0"};
  21.    static char *data4[] = {"1/2","1/2","1/2","1/2","1/2","1"};
  22.    static char *data5[] = {"-1.913uN","2.793uN","1.001uB","0","0"};
  23.    static char *infotext[] = {
  24.    "  * The positron (e+) has properties similar to those of the (negative)",
  25.    "electron or beta particle except that its charge has opposite sign (+).",
  26.    "The antineutrino (v) has properties similar to those of the neutrino",
  27.    "except that its spin (or rotation) is opposite in relation to its direc-",
  28.    "tion of propogation.",
  29.    "    An antineutrino accompanies release of an electron in radioactive B",
  30.    "(particle) decay, whereas a neutrino accompanies the release of a posi-",
  31.    "tron in B+ decay.","",
  32.    " !uB = Bohr magneton and uN = Nuclear magneton."};
  33.    char text[20];
  34.  
  35.    *(text0[7]+15) = 0x8A;
  36.    *(text2[2]+4) = 0x8E;
  37.    *(text2[3]) = 0x93;
  38.    *(text2[4]) = 0x94;
  39.    *(data5[0]+6) = 0x90;
  40.    *(data5[0]+7) = 0x92;
  41.    *(data5[1]+5) = 0x90;
  42.    *(data5[1]+6) = 0x92;
  43.    *(data5[2]+5) = 0x90;
  44.    *(data5[2]+6) = 0x91;
  45.    *(infotext[0]+19) = 0x8F;
  46.    *(infotext[2]+18) = 0x93;
  47.    *(infotext[5]+70) = 0x8D;
  48.    *(infotext[7]+8) = 0x8D;
  49.    *(infotext[7]+9) = 0x8F;
  50.    *(infotext[9]+1) = 0x8A;
  51.    *(infotext[9]+2) = 0x90;
  52.    *(infotext[9]+3) = 0x91;
  53.    *(infotext[9]+25) = 0x90;
  54.    *(infotext[9]+26) = 0x92;
  55.  
  56.    if (!(window = get_window(12,100,616,197,"Info")))
  57.       return(NULL);
  58.    rp = window->RPort;
  59.  
  60.    ElementText.FrontPen = GREENTEXT;
  61.    ElementText.IText = (UBYTE *)"Data Concerning The More Stable Elementary (Subatomic) Particles";
  62.    i = .5 * (616-IntuiTextLength(&ElementText));
  63.    PrintIText(rp, &ElementText, (long)i, 13L);
  64.  
  65.    SetAPen(rp, (long)BOX_COLOR);
  66.    for (y = 30; y < 110; y += 10)
  67.    {
  68.       Move(rp, 0L, y);
  69.       Draw(rp, 616L, y);
  70.    }
  71.    Move(rp, 0L, 111L);
  72.    Draw(rp, 616L, 111L);
  73.  
  74.    for (i = 0; i < 5; i++)
  75.    {
  76.       Move(rp, (long)vertlines[i], 31L);
  77.       Draw(rp, (long)vertlines[i], 111L);
  78.    }
  79.    TextText.FrontPen = GREENTEXT;
  80.    for (y = 1; y < 8; y++)
  81.    {
  82.       TextText.IText = (UBYTE *)text0[y];
  83.       PrintIText(rp, &TextText, 3L, (long)(y*10+32));
  84.    }
  85.    for (x = 0; x < 5; x++)
  86.    {
  87.       TextText.IText = (UBYTE *)text1[x];
  88.       i = .5 * (boxwidth[x+1]-IntuiTextLength(&TextText)) + 1;
  89.       PrintIText(rp, &TextText, (long)(vertlines[x]+i), 32L);
  90.    }
  91.    TextText.FrontPen = BLUETEXT;
  92.    for (x = 0; x < 5; x++)
  93.    {
  94.       TextText.IText = (UBYTE *)text2[x];
  95.       i = .5 * (boxwidth[x+1]-IntuiTextLength(&TextText)) + 1;
  96.       PrintIText(rp, &TextText, (long)vertlines[x]+i, 41L);
  97.    }
  98.    TextText.FrontPen = REDTEXT;
  99.  
  100.    for (y = 0; y < 6; y++)
  101.       for (x = 0; x < 5; x++)
  102.       {
  103.          if (y == 0) convert_super(data0[x], text);
  104.          if (y == 1) convert_super(data1[x], text);
  105.          if (y == 2) convert_super(data2[x], text);
  106.          if (y == 3) convert_super(data3[x], text);
  107.          if (y == 4) convert_super(data4[x], text);
  108.          if (y == 5) convert_super(data5[x], text);
  109.          for (i = 1; text[i] != '\0'; i++)
  110.             if (text[i] == '-')
  111.                text[i] = 0x8E;
  112.          TextText.IText = (UBYTE *)text;
  113.          i = .5 * (boxwidth[x+1]-IntuiTextLength(&TextText)) + 2;
  114.          PrintIText(rp, &TextText, (long)(vertlines[x]+i), (long)(y*10+52));
  115.       }
  116.    TextText.FrontPen = GREENTEXT;
  117.    for (y = 0; y < 10; y++)
  118.    {
  119.       TextText.IText = (UBYTE *)infotext[y];
  120.       PrintIText(rp, &TextText, 21L, (long)(y*8+114));
  121.    }
  122.    return(TRUE);
  123. }
  124.  
  125. display_radioiso()
  126. {
  127.    struct Window *window1, *window2;
  128.    struct RastPort *rp;
  129.    FILE *file;
  130.    char isotope[40], text[40];
  131.    register USHORT i;
  132.    long x, y;
  133.    BOOL par, nat;
  134.    static char *infotext[] = {
  135.    "Naturally occurring radioactive isotopes",
  136.    "are designated by a mass number in blue",
  137.    "(although some are also manufactured).",
  138.    "Letter m indicates an isomer of another",
  139.    "isotope of the same mass number. Half-",
  140.    "lives follow in parenthesis,where s,min,",
  141.    "h,d,and y stand respectively for seconds,",
  142.    "minutes,hours,days,and years. The table",
  143.    "includes mainly the longer-lived radio-",
  144.    "active isotopes; many others have been",
  145.    "prepared. Isotopes known to be radioact-",
  146.    "ive but with half-lives exceeding 1012y",
  147.    "have not been included. Symbols describ-",
  148.    "ing the principle mode(or modes)of decay",
  149.    "are as follows (these processes are gen-",
  150.    "erally accompanied by gamma radiation.","",
  151.    "a  alpha particle emission",
  152.    "B- beta particle (electron) emission",
  153.    "B+ positron emission",
  154.    "EC orbital electron capture",
  155.    "IT isomeric transition from upper/lower",
  156.    "SF spontaneous fission"
  157.    };
  158.    *(infotext[11]+36) += 0x50;
  159.    *(infotext[11]+37) += 0x50;
  160.    *(infotext[17]) = 0x8C;
  161.    *(infotext[18]) = 0x8D;
  162.    *(infotext[18]+1) = 0x8E;
  163.    *(infotext[19]) = 0x8D;
  164.    *(infotext[19]+1) = 0x8F;
  165.  
  166.    if (!(file = fopen(ISOTOPES_FILE, "r")))
  167.       return(NULL);
  168.  
  169.    if (!(window1 = get_window(0,0,640,400,"Table of Selected Radioactive Isotopes")))
  170.       return(NULL);
  171.  
  172.    if (!(window2 = get_window(100,100,337,216,"Info")))
  173.    {
  174.       close_window(window1);
  175.       return(NULL);
  176.    }
  177.    rp = window2->RPort;
  178.  
  179.    ElementText.FrontPen = BLUETEXT;
  180.    ElementText.IText = (UBYTE *)"Selected Radioactive Isotopes";
  181.    y = .5 * (337-IntuiTextLength(&ElementText));
  182.    PrintIText(rp, &ElementText, y, 12L);
  183.  
  184.    TextText.FrontPen = GREENTEXT;
  185.    for (y = 0; y < 23; y++)
  186.    {
  187.       strcpy(text, infotext[y]);
  188.       TextText.IText = (UBYTE *)text;
  189.       PrintIText(rp, &TextText, 5L, (long)(y*8+26));
  190.       if (y > 16)
  191.       {
  192.          *(text+2) = '\0';
  193.          TextText.FrontPen = REDTEXT;
  194.          PrintIText(rp, &TextText, 5L, (long)(y*8+26));
  195.          TextText.FrontPen = GREENTEXT;
  196.       }
  197.    }
  198.    rp = window1->RPort;
  199.  
  200.    x = 4; y = 12;
  201.    TextText.FrontPen = GREENTEXT;
  202.  
  203.    while (fscanf(file, "%s", &text) != EOF)
  204.    {
  205.       par = NULL;
  206.       nat = NULL;
  207.       if (text[0] == '_')
  208.          text[0] = ' ';
  209.       if (text[1] == '_')
  210.          text[1] = ' ';
  211.       for (i = 2; text[i] != '\0'; i++)
  212.       {
  213.          if (text[i] == ')')
  214.             par = TRUE;
  215.          if (text[i] == '_')
  216.             text[i] = ' ';
  217.          if (text[i] == 'a')
  218.             text[i] = 0x8C;
  219.          if (text[i] == 'B')
  220.             text[i] = 0x8D;
  221.          if (text[i] == '-')
  222.             text[i] = 0x8E;
  223.          if ((text[i] == '+') && par)
  224.             text[i] = 0x8F;
  225.          if (text[i] == '*')
  226.          {
  227.             text[i] = '\0';
  228.             nat = TRUE;
  229.          }
  230.       }
  231.       convert_super(text, isotope);
  232.       TextText.FrontPen = GREENTEXT;
  233.       TextText.IText = (UBYTE *)isotope;
  234.       PrintIText(rp, &TextText, x, y);
  235.       if (isotope[0] == '1')
  236.          isotope[3] = '\0';
  237.       else isotope[2] = '\0';
  238.       TextText.FrontPen = REDTEXT;
  239.       PrintIText(rp, &TextText, x, y);
  240.       if (nat)
  241.       {
  242.          sprintf(isotope, "%c%c%c", text[2], text[3], text[4]);
  243.          TextText.IText = (UBYTE *)isotope;
  244.          TextText.FrontPen = BLUETEXT;
  245.          PrintIText(rp, &TextText, x+16L, y);
  246.       }
  247.       y += 9;
  248.       if (y > 390)
  249.       {
  250.          y = 12;
  251.          x += 160;
  252.       }
  253.    }
  254.    fclose(file);
  255.  
  256.    return(TRUE);
  257. }
  258.  
  259. display_ionichar()
  260. {
  261.    register USHORT i;
  262.    long x = 0;
  263.    struct Window *window;
  264.    struct RastPort *rp;
  265.    static float diff[] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,
  266.                           1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,
  267.                           2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2};
  268.    static USHORT percent[] = {0,1,2,4,6,9,12,15,19,22,26,30,34,39,43,47,51,
  269.                               55,59,63,67,70,74,76,79,82,84,86,88,89,91,92};
  270.    char difftext[25], perctext[4];
  271.  
  272.    if (!(window = get_window(30,150,578,71,"Info")))
  273.       return(NULL);
  274.    rp = window->RPort;
  275.  
  276.    ElementText.FrontPen = GREENTEXT;
  277.    ElementText.IText = (UBYTE *)"Percent Ionic Character of a Single Chemical Bond";
  278.    x = .5 * (578-IntuiTextLength(&ElementText));
  279.    PrintIText(rp, &ElementText, x, 13L);
  280.  
  281.    TextText.FrontPen = BLUETEXT;
  282.    TextText.IText = (UBYTE *)"Difference in electronegativity:";
  283.    PrintIText(rp, &TextText, 5L, 30L);
  284.  
  285.    TextText.FrontPen = REDTEXT;
  286.    TextText.IText = (UBYTE *)"Percent ionic character %";
  287.    PrintIText(rp, &TextText, 5L, 60L);
  288.  
  289.    SetAPen(rp, (long)BOX_COLOR);
  290.    for (x = 0; x < 32; x++)
  291.    {
  292.       Move(rp, x*18L, 41L);
  293.       Draw(rp, x*18L, 55L);
  294.    }
  295.    Move(rp,0L,40L); Draw(rp,x*18L,40L);
  296.    Move(rp,0L,48L); Draw(rp,x*18L,48L);
  297.    Move(rp,0L,56L); Draw(rp,x*18L,56L);
  298.  
  299.    for (i = 0; i < 32; i++)
  300.    {
  301.       sprintf(difftext, "%1f", diff[i]);
  302.       difftext[3] = '\0';
  303.       CAMMText.FrontPen = BLUETEXT;
  304.       CAMMText.IText = (UBYTE *)difftext;
  305.       x = .5 * (18-IntuiTextLength(&CAMMText)) + 1;
  306.       PrintIText(rp, &CAMMText, (long)(i*18+x), 42L);
  307.  
  308.       sprintf(perctext, "%d", percent[i]);
  309.       CAMMText.FrontPen = REDTEXT;
  310.       CAMMText.IText = (UBYTE *)perctext;
  311.       if (i == 0)
  312.          CAMMText.IText = (UBYTE *)"0.5";
  313.       x = .5 * (18-IntuiTextLength(&CAMMText)) + 1;
  314.       PrintIText(rp, &CAMMText, (long)(i*18+x), 50L);
  315.    }
  316.    return(TRUE);
  317. }
  318.  
  319. display_notes()
  320. {
  321.    struct Window *window;
  322.    struct RastPort *rp;
  323.    register USHORT i;
  324.    static char *text[] = {
  325.    "The A & B subgroup designations, applicable to elements in rows 4,5,6,and 7,",
  326.    "are those recommended by the International Union of Pure and Applied Chem-",
  327.    "istry. It should be noted that some authors and organizations use the oppo-",
  328.    "site convention in distinguishing these subgroups.",
  329.    "",
  330.    "  The names and symbols of elements 104-106 are those recommended by IUPAC",
  331.    "as systematic alternatives to those suggested by the purported discoverers.",
  332.    "Berkeley (USA) researchers have proposed Rutherfordium, Rf, for element 104",
  333.    "and Hahnium, Ha, for element 105. Dubna (USSR) researchers, who also claim",
  334.    "the discovery of these elements have proposed different names (and symbols).",
  335.    "",
  336.    "The Elements:",
  337.    "",
  338.    "  Atomic Symbol:",
  339.    "  Atomic Weight is based upon carbon-12. () indicates most stable or best-",
  340.    "known isotope.",
  341.    "  Densities of the gaseous elements refer to the gaseous state at 273K and",
  342.    "1 atm and are given in units of g/l.",
  343.    "  Thermal Conductivity and Specific Heat Capacity are at 300K (27°C).",
  344.    "  Heat of Vaporization is at boiling point.",
  345.    "  Heat of Fusion is at melting point.",
  346.    "  Electrical Conductivity is generally at 293K (20°C).",
  347.    "  Atomic Radius is the quantum mechanical value for free atom.",
  348.    "  Atomic Volume is from density at 300K (27°C) for liquid and solid elem-",
  349.    "ents; values for gaseous elements refer to liquid state at boiling point.",
  350.    "",
  351.    "  This information was obtained from Sargent-Welch Scientific Company,",
  352.    "7300 Linder Avenue, Skokie, Illinois 60077 with express prior written",
  353.    "permission."
  354.    };
  355.    static char *hightext[] = {
  356.    "Atomic Symbol","Atomic Weight","","Densities","","Thermal Conductivity",
  357.    "Heat of Vaporization","Heat of Fusion","Electrical Conductivity",
  358.    "Atomic Radius","Atomic Volume"
  359.    };
  360.  
  361.    if (!(window = get_window(10,50,620,291,"Info")))
  362.       return(NULL);
  363.    rp = window->RPort;
  364.  
  365.    ElementText.FrontPen = REDTEXT;
  366.    ElementText.IText = (UBYTE *)"Notes concerning the Table";
  367.    i = .5 * (620-IntuiTextLength(&ElementText));
  368.    PrintIText(rp, &ElementText, (long)i, 12L);
  369.  
  370.    TextText.FrontPen = GREENTEXT;
  371.    for (i = 0; i < 29; i++)
  372.    {
  373.       if (i > 25) TextText.FrontPen = BLUETEXT;
  374.  
  375.       TextText.IText = (UBYTE *)text[i];
  376.       PrintIText(rp, &TextText, 5L, (long)(i*9+27));
  377.    }
  378.    TextText.FrontPen = REDTEXT;
  379.    for (i = 0; i < 11; i++)
  380.    {
  381.       TextText.IText = (UBYTE *)hightext[i];
  382.       PrintIText(rp, &TextText, 21L, (long)(i*9+144));
  383.    }
  384.    ElementText.FrontPen = GREENTEXT;
  385.    ElementText.IText = (UBYTE *)"SOLID";
  386.    PrintIText(rp, &ElementText, 150L, 138L);
  387.    ElementText.FrontPen = BLUETEXT;
  388.    ElementText.IText = (UBYTE *)"LIQUID";
  389.    PrintIText(rp, &ElementText, 220L, 138L);
  390.    ElementText.FrontPen = REDTEXT;
  391.    ElementText.IText = (UBYTE *)"GAS";
  392.    PrintIText(rp, &ElementText, 300L, 138L);
  393.    ElementText.IText = (UBYTE *)"SYNTHETICALLY PREPARED";
  394.    outline(rp, &ElementText, 370L, 138L, (long)GREENTEXT);
  395.  
  396.    return(TRUE);
  397. }
  398.  
  399. display_info()
  400. {
  401.    struct Window *window;
  402.    struct RastPort *rp;
  403.    register USHORT i;
  404.    long x;
  405.    static char *text[] = {
  406.    "This program is ShareWare. It was written",
  407.    "as part of a larger molecular modeling",
  408.    "application. You may copy this program",
  409.    "and share it with your friends as much",
  410.    "as you like. If you find this program",
  411.    "exceptionally useful, please feel free",
  412.    "to send me a small donation to help me",
  413.    "offset my development time (And perhaps",
  414.    "help pay my way through college. A good",
  415.    "education is expensive!). If you send a",
  416.    "disk and a donation of $10 or more, I'll",
  417.    "gladly send you the source, and a demo",
  418.    "of my CAMM v1.0 & v2.0 modeling software.",
  419.    "",
  420.    "Send donations/disks to:",
  421.    "Paul Thomas Miller",
  422.    "129 Orchard Avenue",
  423.    "Rocky Mount, VA 24151",
  424.    "(703) 483-8219"
  425.    };
  426.  
  427.    if (!(window = get_window(150,50,350,222,"Some more info...")))
  428.       return(NULL);
  429.    rp = window->RPort;
  430.  
  431.    for (i = 0; i < 19; i++)
  432.    {
  433.       TextText.IText = (UBYTE *)text[i];
  434.       x = .5 * (350-IntuiTextLength(&TextText));
  435.       if (i < 14)
  436.          TextText.FrontPen = GREENTEXT;
  437.       if (i == 14)
  438.          TextText.FrontPen = BLUETEXT;
  439.       if (i > 14)
  440.          TextText.FrontPen = REDTEXT;
  441.       PrintIText(rp, &TextText, x, (long)(i*10)+12L);
  442.    }
  443.    ElementText.IText = (UBYTE *)"S h a r e  a n d  E n j o y !";
  444.    x = .5 * (350-IntuiTextLength(&ElementText));
  445.    outline(rp, &ElementText, (long)x, 205L, (long)GREENTEXT);
  446.  
  447.    return(NULL);
  448. }
  449.