⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 charts.c

📁 占星术4.0源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
** Astrolog (Version 4.00) File: charts.c
**
** IMPORTANT NOTICE: the graphics database and chart display routines
** used in this program are Copyright (C) 1991-1993 by Walter D. Pullen
** (cruiser1@stein.u.washington.edu). Permission is granted to freely
** use and distribute these routines provided one doesn't sell,
** restrict, or profit from them in any way. Modification is allowed
** provided these notices remain with any altered or edited versions of
** the program.
**
** The main planetary calculation routines used in this program have
** been Copyrighted and the core of this program is basically a
** conversion to C of the routines created by James Neely as listed in
** Michael Erlewine's 'Manual of Computer Programming for Astrologers',
** available from Matrix Software. The copyright gives us permission to
** use the routines for personal use but not to sell them or profit from
** them in any way.
**
** The PostScript code within the core graphics routines are programmed
** and Copyright (C) 1992-1993 by Brian D. Willoughby
** (brianw@sounds.wa.com). Conditions are identical to those above.
**
** The extended accurate ephemeris databases and formulas are from the
** calculation routines in the program "Placalc" and are programmed and
** Copyright (C) 1989,1991,1993 by Astrodienst AG and Alois Treindl
** (alois@azur.ch). The use of that source code is subject to
** regulations made by Astrodienst Zurich, and the code is not in the
** public domain. This copyright notice must not be changed or removed
** by any user of this program.
**
** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991.
** X Window graphics initially programmed 10/23-29/1991.
** PostScript graphics initially programmed 11/29-30/1992.
** Last code change made 12/31/1993.
*/

#include "astrolog.h"


/*
******************************************************************************
** Single Chart Display Subprograms.
******************************************************************************
*/

/* Fill out tables based on the number of unrestricted planets in signs by  */
/* element, signs by mode, as well as other values such as the number of    */
/* objects in yang vs. yin signs, in various house hemispheres (north/south */
/* and east/west), and the number in first six signs vs. second six signs.  */
/* This is used by the -v chart listing and the sidebar in graphics charts. */

void CreateElemTable(elemode, elem, mo, tot, pos, abo, lef, lea)
int elemode[4][3], *elem, *mo, *tot, *pos, *abo, *lef, *lea;
{
  int i, j;

  *tot = *pos = *abo = *lef = *lea = 0;    /* Initialize arrays     */
  for (i = 0; i < 4; i++)                  /* and variables to zero */
    elem[i] = 0;
  for (j = 0; j < 3; j++)
    mo[j] = 0;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 3; j++)
      elemode[i][j] = 0;

  /* Calculate number of objects in each element, mode, hemisphere, etc. */

  for (i = 1; i <= total; i++) if (!ignore[i]) {
    (*tot)++;
    j = ZTOS(planet[i]);
    elemode[(j-1)&3][(j-1)%3]++;
    elem[(j-1)&3]++; mo[(j-1)%3]++;
    *pos += (j & 1);
    *lea += (j < _LIB);
    j = inhouse[i];
    *abo += (j >= _LIB);
    *lef += (j < _CAN || j >= _CAP);
  }
}


/* Print the straight listing of planet and house positions and specified */
/* by the -v switch, along with the element table, etc.                   */

void ChartLocation()
{
  int elemode[4][3], elem[4], mo[3], pos, abo, lef, lea;
  int count, i, j, k;

  CreateElemTable(elemode, elem, mo, &count, &pos, &abo, &lef, &lea);

  /* Print header showing time and date of the chart being displayed. */

  AnsiColor(WHITE);
  fprintf(S, "%s %s chart ", appname, VERSION);
  if (Mon == -1)
    fprintf(S, "(no time or space)\n");
  else if (relation == DASHrc)
    fprintf(S, "(composite)\n");
  else {
    i = (int) (FRACT(dabs(Tim))*100.0+ROUND);
    j = (int) (FRACT(dabs(Zon))*100.0+ROUND);
    fprintf(S, "for %s %s",
      CharDate(Mon, Day, Yea, TRUE), CharTime((int)Tim, i));
    fprintf(S, " (%c%.0f:%02d GMT) ",
      Zon > 0.0 ? '-' : '+', dabs(Zon), j);
    fprintf(S, "%s\n", CharLocation(Lon, Lat, 100.0));
  }

#ifdef INTERPRET
  if (interpret) {            /* Print an interpretation if -I in effect. */
    if (relation == DASHr)
      InterpretSynastry();    /* Print synastry interpretaion for -r -I.  */
    else
      InterpretLocation();    /* Do normal interpretation for just -v -I. */
    return;
  }
#endif
  AnsiColor(DEFAULT);
  fprintf(S, "Body  Locat. Ret. Decl. Rul.      House  Rul. Veloc.    ");
  fprintf(S, "%s Houses.\n\n", systemname[housesystem]);

  /* Ok, now print out each location of each object. */

  for (i = 1, j = 1; i <= BASE; i++, j++) {
    if (i > OBJECTS && (i <= C_HI || ignore[i]))
      continue;
    while (i <= OBJECTS && j <= OBJECTS && ignore[j])
      j++;
    if (i <= OBJECTS && j > OBJECTS)
      PrintTab(' ', 51);
    else {
      if (i > OBJECTS)
        j = i;
      AnsiColor(objectansi[j]);
      fprintf(S, "%-4.4s: ", objectname[j]);
      PrintZodiac(planet[j]);
      fprintf(S, " %c ", ret[j] >= 0.0 ? ' ' : 'R');
      if (j <= THINGS || j > OBJECTS)
        PrintAltitude(planetalt[i]);
      else
        fprintf(S, "_______");
      fprintf(S, " (%c)", Dignify(j, ZTOS(planet[i])));
      k = inhouse[j];
      AnsiColor(signansi(k));
      fprintf(S, " [%2d%c%c house]", k, post[k][0], post[k][1]);
      AnsiColor(DEFAULT);
      fprintf(S, " [%c] ", Dignify(j, k));
      if ((j != _MOO || placalc) && (IsObject(j) || (j == _NOD && placalc)))
        fprintf(S, RTOD(dabs(ret[j])) < 10.0 ? "%c%5.3f" : "%c%5.2f",
          ret[i] < 0.0 ? '-' : '+', RTOD(dabs(ret[j])));
      else
        fprintf(S, "______");
    }

    /* For some lines, we have to append the house cusp positions. */

    if (i <= SIGNS) {
      fprintf(S, "  -  ");
      AnsiColor(signansi(i));
      fprintf(S, "House cusp %2d: ", i);
      PrintZodiac(house[i]);
    }

    /* For some lines, we have to append the element table information. */

    if (i == SIGNS+2)
      fprintf(S, "     Car Fix Mut TOT");
    else if (i > SIGNS+2 && i < SIGNS+7) {
      k = i-(SIGNS+2)-1;
      AnsiColor(elemansi[k]);
      fprintf(S, "  %c%c%c%3d %3d %3d %3d",
        element[k][0], element[k][1], element[k][2],
        elemode[k][0], elemode[k][1], elemode[k][2], elem[k]);
      AnsiColor(DEFAULT);
    } else if (i == SIGNS+7)
      fprintf(S, "  TOT %2d %3d %3d %3d", mo[0], mo[1], mo[2], count);
    else if (i == OBJECTS)
      PrintTab(' ', 23);
    else if (i >= U_LO)
      fprintf(S, "  Uranian #%d", i-U_LO+1);
    switch (i-SIGNS-1) {
    case 1: fprintf(S, "   +:%2d", pos);       break;
    case 2: fprintf(S, "   -:%2d", count-pos); break;
    case 3: fprintf(S, "   M:%2d", abo);       break;
    case 4: fprintf(S, "   N:%2d", count-abo); break;
    case 5: fprintf(S, "   A:%2d", lef);       break;
    case 6: fprintf(S, "   D:%2d", count-lef); break;
    case 7: fprintf(S,    "<:%2d", lea);       break;
    }
    printl();
  }

  /* Do another loop to print out the stars in their specified order. */

  if (universe) for (i = S_LO; i <= S_HI; i++) if (!ignore[i]) {
    j = BASE+starname[i-BASE];
    AnsiColor(objectansi[j]);
    fprintf(S, "%.4s: ", objectname[j]);
    PrintZodiac(planet[j]);
    fprintf(S, "   ");
    PrintAltitude(planetalt[j]);
    k = inhouse[j];
    AnsiColor(signansi(k));
    fprintf(S, "     [%2d%c%c house]", k, post[k][0], post[k][1]);
    AnsiColor(DEFAULT);
    fprintf(S, "     ______  Star #%2d: %5.2f\n", i-BASE, starbright[j-BASE]);
  }
}


/* Print out the aspect and midpoint grid for a chart, as specified with the */
/* -g switch. (Each grid row takes up 4 lines of text.)                      */

void ChartGrid()
{
  int x, y, r, x1, y1, temp;

#ifdef INTERPRET
  if (interpret) {    /* Print interpretation instead if -I in effect. */
    InterpretGrid();
    return;
  }
#endif

  for (y1 = 0, y = 1; y <= total; y++) if (!ignore[y])
    for (r = 1; r <= 4; r++) {
      for (x1 = 0, x = 1; x <= total; x++) if (!ignore[x]) {
        if (y1 > 0 && x1 > 0 && y+r > 2)
          printc(r > 1 ? BOXV : BOXC);
        if (r > 1) {
          temp = grid->n[x][y];

          /* Print aspect rows. */

          if (x < y) {
            if (temp);
              AnsiColor(aspectansi[temp]);
            if (r == 2)
              fprintf(S, "%s", temp ? aspectabbrev[temp] : "   ");
            else if (!temp)
              fprintf(S, "   ");
            else {
              if (r == 3) {
                if (grid->v[x][y] < 600)
                  fprintf(S, "%c%2d", exdisplay & DASHga ?
                    (grid->v[x][y] < 0 ? 'a' : 's') :
                    (grid->v[x][y] < 0 ? '-' : '+'), abs(grid->v[x][y])/60);
                else
                  fprintf(S, "%3d", abs(grid->v[x][y])/60);
              } else
                fprintf(S, "%02d'", abs(grid->v[x][y])%60);
            }

          /* Print midpoint rows. */

          } else if (x > y) {
            AnsiColor(signansi(temp));
            if (r == 2) {
              temp = grid->n[x][y];
              fprintf(S, "%c%c%c", SIGNAM(temp));
            } else if (r == 3) {
              fprintf(S, "%2d%c", grid->v[x][y]/60, DEGR2);
            } else
              fprintf(S, "%02d'", grid->v[x][y]%60);

          /* Print the diagonal of object names. */

          } else {
            AnsiColor(REVERSE);
            if (r == 2) {
              AnsiColor(objectansi[y]);
              fprintf(S, "%c%c%c", OBJNAM(y));
            } else {
              temp = ZTOS(planet[y]);
              AnsiColor(signansi(temp));
              if (r == 3)
                fprintf(S, "%2d%c", (int)planet[y] - (temp-1)*30, DEGR2);
              else
                fprintf(S, "%c%c%c", SIGNAM(temp));
            }
          }
          AnsiColor(DEFAULT);
        } else
          if (y1 > 0)
            PrintTab(BOXH, 3);
        x1++;
        if (column80 && x1 >= 20)
          x = total;
      }
      if (y+r > 2)
        printl();
      y1++;
    }
}


/* This is a subprocedure of DisplayGrands(). Here we print out one aspect */
/* configuration found by the parent procedure.                            */

void PrintGrand(nam, i1, i2, i3, i4)
char nam;
int i1, i2, i3, i4;
{
  switch (nam) {
  case '.': AnsiColor(aspectansi[_CON]); fprintf(S, "Stellium   "); break;
  case 't': AnsiColor(aspectansi[_TRI]); fprintf(S, "Grand Trine"); break;
  case 's': AnsiColor(aspectansi[_OPP]); fprintf(S, "T-Square   "); break;
  case 'y': AnsiColor(aspectansi[_INC]); fprintf(S, "Yod        "); break;
  case 'g': AnsiColor(aspectansi[_SQU]); fprintf(S, "Grand Cross"); break;
  case 'c': AnsiColor(aspectansi[_SEX]); fprintf(S, "Cradle     "); break;
  default: ;
  }
  AnsiColor(DEFAULT);
  fprintf(S, " %s ", nam == '.' || nam == 't' || nam == 'g' ? "with" : "from");
  AnsiColor(objectansi[i1]);
  fprintf(S, "%c%c%c: ", OBJNAM(i1));
  PrintZodiac(planet[i1]);
  fprintf(S, " %s ", nam == '.' || nam == 't' ? "and" : "to ");
  AnsiColor(objectansi[i2]);
  fprintf(S, "%c%c%c: ", OBJNAM(i2));
  PrintZodiac(planet[i2]);
  fprintf(S, " %s ", nam == 'g' || nam == 'c' ? "to " : "and");
  AnsiColor(objectansi[i3]);
  fprintf(S, "%c%c%c: ", OBJNAM(i3));
  PrintZodiac(planet[i3]);
  if (nam == 'g' || nam == 'c') {
    fprintf(S, " to ");
    AnsiColor(objectansi[i4]);
    fprintf(S, "%c%c%c: ", OBJNAM(i4));
    PrintZodiac(planet[i4]);
  }
  printl();
}


/* Scan the aspect grid of a chart and print out any major configurations, */
/* as specified with the -g0 switch.                                       */

void DisplayGrands()
{
  int count = 0, i, j, k, l;

  for (i = 1; i <= total; i++) if (!ignore[i])

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -