-
Notifications
You must be signed in to change notification settings - Fork 65
/
xcharts2.cpp
1719 lines (1542 loc) · 56.3 KB
/
xcharts2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** Astrolog (Version 7.70) File: xcharts2.cpp
**
** IMPORTANT NOTICE: Astrolog and all chart display routines and anything
** not enumerated below used in this program are Copyright (C) 1991-2024 by
** Walter D. Pullen (Astara@msn.com, http://www.astrolog.org/astrolog.htm).
** Permission is granted to freely use, modify, and distribute these
** routines provided these credits and notices remain unmodified with any
** altered or distributed versions of the program.
**
** The main ephemeris databases and calculation routines are from the
** library SWISS EPHEMERIS and are programmed and copyright 1997-2008 by
** Astrodienst AG. Use of that source code is subject to license for Swiss
** Ephemeris Free Edition at https://www.astro.com/swisseph/swephinfo_e.htm.
** This copyright notice must not be changed or removed by any user of this
** program.
**
** Additional 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@astro.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.
**
** The original planetary calculation routines used in this program have
** been copyrighted and the initial core of this program was mostly a
** conversion to C of the routines created by James Neely as listed in
** 'Manual of Computer Programming for Astrologers', by Michael Erlewine,
** available from Matrix Software.
**
** Atlas composed using data from https://www.geonames.org/ licensed under a
** Creative Commons Attribution 4.0 License. Time zone changes composed using
** public domain TZ database: https://data.iana.org/time-zones/tz-link.html
**
** The PostScript code within the core graphics routines are programmed
** and Copyright (C) 1992-1993 by Brian D. Willoughby (brianw@sounds.wa.com).
**
** More formally: 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 and inspiring, 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, a copy of which is in the
** LICENSE.HTM file included with Astrolog, and at http://www.gnu.org
**
** Initial programming 8/28-30/1991.
** X Window graphics initially programmed 10/23-29/1991.
** PostScript graphics initially programmed 11/29-30/1992.
** Last code change made 4/22/2024.
*/
#include "astrolog.h"
#ifdef GRAPH
/*
******************************************************************************
** Chart Graphics Utility Procedures.
******************************************************************************
*/
// Return whether the specified object should be displayed in the current
// graphics chart type. For example, don't include the Moon in the solar
// system charts when ephemeris files are off, don't include house cusps
// in astro-graph charts, and so on, in addition to checking restrictions.
flag FProper(int i)
{
flag f;
int j;
f = !ignore[i];
if (gi.nMode == gWheel || gi.nMode == gHouse) {
if (gs.fMoonWheel) {
// Planetary moons will be drawn separately, so don't display here.
j = ObjOrbit(i);
if (!ignore[j] && FHasMoon(j) && j != us.objCenter)
f = fFalse;
}
} else if (gi.nMode == gOrbit)
f &= FThing(i) && (us.fEphemFiles || !FGeo(i));
else if (fMap || gi.nMode == gGlobe || gi.nMode == gPolar)
f &= FThing2(i);
else if (gi.nMode == gEphemeris)
f &= !(gs.fAlt && (i == oMoo || i == oFor));
else if (gi.nMode == gTraTraGra || gi.nMode == gTraNatGra)
f &= FProperGraph(i);
return f;
}
// Adjust an array of zodiac positions so that no two positions are within a
// certain orb of each other. This is used by the wheel drawing chart routines
// in order to make sure that planet glyphs aren't drawn on top of each other.
// Later draw the glyphs at the adjusted positions.
void FillSymbolRing(real *symbol, real factor)
{
real orb = DEFORB*256.0/(real)gs.yWin*(real)gi.nScale*factor, orb1, orb2,
ratio, k1, k2, temp;
int i, j, j1, j2, l;
flag rgf[oPlu+1], fMoved = fTrue;
// Determine which planets will be drawn with moons orbiting them.
if (gs.fMoonWheel) {
ratio = gs.nScale <= 100 ? 1.2 : (gs.nScale == 200 ? 0.65 :
(gs.nScale == 300 ? 0.50 : 0.40));
ClearB((pbyte)rgf, sizeof(rgf));
for (i = moonsLo; i <= moonsHi; i++) if (!ignore[i]) {
j = ObjOrbit(i);
if (FBetween(j, oMar, oPlu))
rgf[j] = fTrue;
}
rgf[oEar] = !ignore[oMoo];
}
// Keep adjusting as long as can still make changes, or until 'n' rounds are
// done. (With many objects, there just may not be enough room for all.)
for (l = 0; fMoved && l < us.nDivision*2; l++) {
fMoved = fFalse;
for (i = 0; i <= is.nObj; i++) if (FProper(i)) {
// For each object, determine who is closest on either side.
k1 = rLarge; k2 = -rLarge; j1 = j2 = oSun;
for (j = 0; j <= is.nObj; j++) if (FProper(j) && i != j) {
temp = symbol[j]-symbol[i];
if (RAbs(temp) > rDegHalf)
temp -= rDegMax*RSgn(temp);
if (temp < k1 && temp > 0.0) {
k1 = temp; j1 = j;
} else if (temp > k2 && temp <= 0.0) {
k2 = temp; j2 = j;
}
}
// Determine the orb to allow on either size of the object. If current
// and/or adjacent bodies are orbited by moons, that will widen the orb.
orb1 = orb2 = orb;
if (gs.fMoonWheel) {
if (i <= oPlu && rgf[i] && i != us.objCenter)
orb1 = orb2 = orb + orb*ratio;
if (j1 <= oPlu && rgf[j1] && j1 != us.objCenter)
orb1 += orb*ratio;
if (j2 <= oPlu && rgf[j2] && j2 != us.objCenter)
orb2 += orb*ratio;
}
// If an object's too close on one side, then move in other direction.
if (k2 > -orb2 && k1 > orb1) {
fMoved = fTrue; symbol[i] = Mod(symbol[i]+orb2*0.51+k2*0.49);
} else if (k1 < orb1 && k2 < -orb2) {
fMoved = fTrue; symbol[i] = Mod(symbol[i]-orb1*0.51+k1*0.49);
// If object bracketed by close objects on both sides, then move it to
// the midpoint, so it's as far away as possible from either one.
} else if (k2 > -orb2 && k1 < orb1) {
fMoved = fTrue; symbol[i] = Mod(symbol[i]+(k1+k2)*(orb2/(orb2+orb1)));
}
}
}
}
// Like FillSymbolRing() but a simplified version used for distributing
// planetary moons around a planet, used when the -X8 setting is in effect.
void FillSymbolRingM(int obj, real *symbol, real factor)
{
real orb = DEFORB*factor, k1, k2, temp;
int i, j, l;
flag fMoved = fTrue;
for (l = 0; fMoved && l < us.nDivision*2; l++) {
fMoved = fFalse;
for (i = custLo; i <= custHi; i++) {
if (ignore[i] || ObjOrbit(i) != obj)
continue;
k1 = rLarge; k2 = -rLarge;
for (j = custLo; j <= custHi; j++) {
if (ignore[j] || i == j || ObjOrbit(j) != obj)
continue;
temp = symbol[j]-symbol[i];
if (RAbs(temp) > rDegHalf)
temp -= rDegMax*RSgn(temp);
if (temp < k1 && temp > 0.0)
k1 = temp;
else if (temp > k2 && temp <= 0.0)
k2 = temp;
}
if (k2 > -orb && k1 > orb) {
fMoved = fTrue; symbol[i] = Mod(symbol[i]+orb*0.51+k2*0.49);
} else if (k1 < orb && k2 < -orb) {
fMoved = fTrue; symbol[i] = Mod(symbol[i]-orb*0.51+k1*0.49);
} else if (k2 > -orb && k1 < orb) {
fMoved = fTrue; symbol[i] = Mod(symbol[i]+(k1+k2)*0.5);
}
}
}
}
// Adjust an array of longitude positions so that no two are within a certain
// orb of each other. This is used by the astro-graph routine to make sure no
// planet glyphs marking the lines are drawn on top of each other. This is
// almost identical to the FillSymbolRing() routine used by the wheel charts,
// however there the glyphs are placed in a continuous ring, while here the
// left and right screen edges are present. Also, here are placing two sets of
// planets at the same time.
void FillSymbolLine(real *symbol)
{
real orb = DEFORB*1.35*(real)gi.nScale, max = rDegMax, k1, k2, temp;
int i, j, l, tot = is.nObj*2+1;
flag fMoved = fTrue;
if (gi.nMode != gEphemeris)
max *= (real)gi.nScale;
else
orb *= rDegMax/(real)gs.xWin;
// Keep adjusting as long as can still make changes.
for (l = 0; fMoved && l < us.nDivision*2; l++) {
fMoved = fFalse;
for (i = 0; i <= tot; i++)
if (FProper(i >> 1) && symbol[i] >= 0.0) {
// For each object, determine who is closest to the left and right.
k1 = max-symbol[i]; k2 = -symbol[i];
for (j = 0; j <= tot; j++) {
if (FProper(j >> 1) && i != j) {
temp = symbol[j]-symbol[i];
if (temp < k1 && temp > 0.0)
k1 = temp;
else if (temp > k2 && temp <= 0.0)
k2 = temp;
}
}
// If an object's too close on one side, then move in other direction.
if (k2 > -orb && k1 > orb) {
fMoved = fTrue; symbol[i] = symbol[i]+orb*0.51+k2*0.49;
} else if (k1 < orb && k2 < -orb) {
fMoved = fTrue; symbol[i] = symbol[i]-orb*0.51+k1*0.49;
} else if (k2 > -orb && k1 < orb) {
fMoved = fTrue; symbol[i] = symbol[i]+(k1+k2)*0.5;
}
}
}
}
// Given a zodiac position, return the degree on the current wheel chart
// circle where that position falls, rotating based on the Ascendant and
// adding in the opposite direction for Vedic mode wheels.
real PlaceInX(real deg)
{
if (us.fIndian)
deg = -chouse[1]*(gi.nMode != gWheel)*2.0-deg-60.0;
return Mod(rDegHalf-deg+gi.rAsc);
}
// Given a zodiac degree, adjust it if need be to account for the expanding
// and compacting of parts the zodiac that happen when displaying a graphic
// wheel chart such that all the houses appear the same size.
real HousePlaceInX(real deg, real degalt)
{
int in;
real rIn;
if (us.fHouse3D && degalt != 0.0) {
rIn = RHousePlaceIn3D(deg, degalt) / 30.0;
in = (int)rIn + 1;
deg = Mod(chouse[in] +
(rIn - RFloor(rIn)) * MinDistance(chouse[in], chouse[Mod12(in+1)]));
}
if (gi.nMode == gWheel) // Only adjust for the -w -X combination.
return deg;
in = NHousePlaceIn2D(deg);
return Mod(ZFromS(in)+MinDistance(chouse[in], deg)/
MinDistance(chouse[in], chouse[Mod12(in+1)])*30.0);
}
// Draw lines connecting planets between two charts that have aspects. Used
// when creating bi-wheels and beyond.
void DrawAspectRelation(int n1, int n2, real obj1[objMax], real obj2[objMax],
int cx, int cy, real rz)
{
CP cpA, cpB;
real rx = (real)cx, ry = (real)cy;
int i, j;
// Put the two sets of chart data to compare in cp1 and cp2.
if (n1 != 1) {
cpA = cp1;
cp1 = *rgpcp[n1];
}
if (n2 != 2) {
cpB = cp2;
cp2 = *rgpcp[n2];
}
// Compute and draw the aspect lines.
if (!FCreateGridRelation(fFalse))
goto LExit;
for (j = is.nObj; j >= 0; j--)
for (i = is.nObj; i >= 0; i--)
if (grid->n[i][j] && FProper2(i) && FProper(j) &&
obj1[j] >= 0.0 && obj2[i] >= 0.0)
DrawAspectLine(i, j, cx, cy, obj1[j], obj2[i], rx, ry, rz);
LExit:
if (n1 != 1)
cp1 = cpA;
if (n2 != 2)
cp2 = cpB;
}
/*
******************************************************************************
** Multiple Chart Graphics Routines.
******************************************************************************
*/
// Draw another wheel chart, however this time there are two rings of planets
// because this is a bi-wheel relationship chart between two sets of data.
// This chart is obtained when the -r0 is combined with the -X switch.
void XChartWheelRelation()
{
real xsign[cSign+1], xhouse1[cSign+1], xplanet1[objMax], xplanet2[objMax],
symbol[objMax];
byte ignoreT[objMax];
int cx, cy, i;
real unitx, unity;
// Set up variables and temporarily automatically decrease the horizontal
// chart size to leave room for the sidebar if that mode is in effect.
if (gs.fText && !us.fVelocity)
gs.xWin -= xSideT;
cx = gs.xWin/2 - 1; cy = gs.yWin/2 - 1;
unitx = (real)cx; unity = (real)cy;
gi.rAsc = gs.objLeft ? cp1.obj[NAbs(gs.objLeft)-1] +
rDegQuad*(gs.objLeft < 0) : cp1.cusp[1];
if (us.fIndian)
gi.rAsc = gs.objLeft ? (gs.objLeft < 0 ? 120.0 : -60.0)-gi.rAsc : 0.0;
// Fill out arrays with the degree of each object, cusp, and sign glyph.
if (gi.nMode == gWheel) {
for (i = 1; i <= cSign; i++)
xhouse1[i] = PZ(cp1.cusp[i]);
} else {
gi.rAsc -= cp1.cusp[1];
for (i = 1; i <= cSign; i++)
xhouse1[i] = PZ(ZFromS(i));
}
for (i = 1; i <= cSign; i++)
xsign[i] = PZ(HousePlaceInX(ZFromS(i), 0.0));
for (i = 0; i <= is.nObj; i++)
xplanet1[i] = PZ(HousePlaceInX(cp1.obj[i], cp1.alt[i]));
for (i = 0; i <= is.nObj; i++)
xplanet2[i] = PZ(HousePlaceInX(cp2.obj[i], cp2.alt[i]));
// Go draw the outer sign and house rings. We are drawing only the houses
// of one of the two charts in the relationship, however.
if (gs.fColor) {
DrawColor(kDkGreenB);
DrawCircle(cx, cy, (int)(unitx*0.55+rRound), (int)(unity*0.55+rRound));
}
DrawWheel(xsign, xhouse1, cx, cy, unitx, unity, 0.70, 0.78, 0.82);
// Draw the outer ring of planets (based on the planets in the chart which
// the houses do not reflect - the houses belong to the inner ring below).
// Draw each glyph, a line from it to its actual position point in the outer
// ring, and then draw another line from this point to a another dot at the
// same position in the inner ring as well.
if (us.nRel <= rcTransit)
for (i = 0; i <= is.nObj; i++) {
ignoreT[i] = ignore[i];
ignore[i] = ignore2[i];
}
DrawRing(2, 2 /* so lines are dotted */ + 1, xplanet2, symbol, cx, cy,
0.41, 0.43, 0.54, 0.56, 0.58, 0.61, 0.65, 1.0);
if (us.nRel <= rcTransit)
for (i = 0; i <= is.nObj; i++)
ignore[i] = ignoreT[i];
// Now draw the inner ring of planets. If it weren't for the outer ring,
// this would be just like the standard non-relationship wheel chart with
// only one set of planets. Again, draw glyph, and a line to the true point.
DrawRing(1, 2, xplanet1, symbol, cx, cy,
0.0, 0.0, 0.0, 0.41, 0.43, 0.46, 0.50, 1.1);
FProcessCommandLine(szWheelX[0]);
// Draw lines connecting planets between the two charts that have aspects.
if (!gs.fEquator)
DrawAspectRelation(1, 2, xplanet1, xplanet2, cx, cy, 0.40);
// Draw sidebar with chart information and positions if need be.
DrawSidebar();
}
// Draw a tri-wheel chart or quad-wheel chart, in which there are three or
// four rings, among three or four sets of chart data being compared. This
// chart is obtained when the -r3 or -r4 switch is combined with -X switch.
void XChartWheelMulti()
{
real xsign[cSign+1], xhouse1[cSign+1], xplanet1[objMax], xplanet2[objMax],
xplanet3[objMax], xplanet4[objMax], xplanet5[objMax], xplanet6[objMax],
symbol[objMax], ri2, rp, rl1, rl2, rg, rT;
CP *pcp[cRing+1];
real *pxp[cRing+1];
int cx, cy, i, fQuad, fQuin, fHexa, nRing;
real unitx, unity, base, base2, off;
// Set up variables and temporarily automatically decrease the horizontal
// chart size to leave room for the sidebar if that mode is in effect.
if (gs.fText && !us.fVelocity)
gs.xWin -= xSideT;
cx = gs.xWin/2 - 1; cy = gs.yWin/2 - 1;
unitx = (real)cx; unity = (real)cy;
gi.rAsc = gs.objLeft ? cp1.obj[NAbs(gs.objLeft)-1] +
rDegQuad*(gs.objLeft < 0) : cp1.cusp[1];
if (us.fIndian)
gi.rAsc = gs.objLeft ? (gs.objLeft < 0 ? 120.0 : -60.0)-gi.rAsc : 0.0;
fHexa = (us.nRel == rcHexaWheel);
fQuin = fHexa || (us.nRel == rcQuinWheel);
fQuad = fQuin || (us.nRel == rcQuadWheel);
nRing = 3 + fQuad + fQuin + fHexa;
base = (fHexa ? 0.11 : (fQuin ? 0.22 : (fQuad ? 0.23 : 0.36)));
base2 = base + (fQuin ? 0.01 : 0.02);
off = fQuin ? 0.11 : 0.13;
pxp[1] = xplanet6; pxp[2] = xplanet5; pxp[3] = xplanet4;
pxp[4] = xplanet3; pxp[5] = xplanet2; pxp[6] = xplanet1;
for (i = 1; i <= nRing; i++) {
pcp[i] = rgpcp[nRing+1 - i];
pxp[i] = pxp[i + cRing - nRing];
}
// Fill out arrays with the degrees of the cusps and sign glyphs, and the
// positions of the planet rings.
if (gi.nMode == gWheel) {
for (i = 1; i <= cSign; i++)
xhouse1[i] = PZ(cp1.cusp[i]);
} else {
gi.rAsc -= cp1.cusp[1];
for (i = 1; i <= cSign; i++)
xhouse1[i] = PZ(ZFromS(i));
}
for (i = 1; i <= cSign; i++)
xsign[i] = PZ(HousePlaceInX(ZFromS(i), 0.0));
for (i = 0; i <= is.nObj; i++) {
xplanet1[i] = PZ(HousePlaceInX(pcp[1]->obj[i], pcp[1]->alt[i]));
xplanet2[i] = PZ(HousePlaceInX(pcp[2]->obj[i], pcp[2]->alt[i]));
xplanet3[i] = PZ(HousePlaceInX(pcp[3]->obj[i], pcp[3]->alt[i]));
if (fQuad) {
xplanet4[i] = PZ(HousePlaceInX(pcp[4]->obj[i], pcp[4]->alt[i]));
if (fQuin) {
xplanet5[i] = PZ(HousePlaceInX(pcp[5]->obj[i], pcp[5]->alt[i]));
if (fHexa)
xplanet6[i] = PZ(HousePlaceInX(pcp[6]->obj[i], pcp[6]->alt[i]));
}
}
}
// Go draw the outer sign and house rings. We are drawing the houses of only
// the outermost ring of the wheel, however.
if (gs.fColor) {
DrawColor(kDkGreenB);
rT = fQuin ? 0.64 : 0.61;
DrawCircle(cx, cy, (int)(unitx*rT+rRound), (int)(unity*rT+rRound));
rT -= off;
DrawCircle(cx, cy, (int)(unitx*rT+rRound), (int)(unity*rT+rRound));
if (fQuad) {
rT -= off;
DrawCircle(cx, cy, (int)(unitx*rT+rRound), (int)(unity*rT+rRound));
if (fQuin) {
rT -= off;
DrawCircle(cx, cy, (int)(unitx*rT+rRound), (int)(unity*rT+rRound));
if (fHexa)
rT -= off;
DrawCircle(cx, cy, (int)(unitx*rT+rRound), (int)(unity*rT+rRound));
}
}
}
if (fQuin)
DrawWheel(xsign, xhouse1, cx, cy, unitx, unity, 0.76, 0.82, 0.86);
else
DrawWheel(xsign, xhouse1, cx, cy, unitx, unity, 0.745, 0.815, 0.84);
// Draw the outer ring of planets (i.e. the one the house cusps reflect).
// Draw each glyph, a line from it to its actual position point in the outer
// ring, and then draw another line from this point to a another dot at the
// same position on the innermost ring as well.
if (fQuin) {
ri2 = 0.62; rp = 0.65; rl1 = 0.66; rl2 = 0.68; rg = 0.72;
} else {
ri2 = 0.59; rp = 0.62; rl1 = 0.63; rl2 = 0.66; rg = 0.70;
}
DrawRing(1, nRing, xplanet1, symbol, cx, cy,
base, base2, ri2, rp, rl1, rl2, rg, 0.9);
// Now draw the second to outermost ring of planets. Again, draw each glyph,
// a line to its true point, and a line to the innermost ring.
ri2 -= off; rp -= off; rl1 -= off; rl2 -= off; rg -= off;
DrawRing(2, nRing, xplanet2, symbol, cx, cy,
base, base2, ri2, rp, rl1, rl2, rg, 1.1);
// The third ring is next. Chart was cast earlier, and draw the glyphs and
// lines to true point. If a fourth ring is being done, first finish the
// third one by drawing lines from the true positions to the inner ring.
ri2 -= off; rp -= off; rl1 -= off; rl2 -= off; rg -= off;
DrawRing(3, nRing, xplanet3, symbol, cx, cy,
base, base2, ri2, rp, rl1, rl2, rg, 1.4);
if (fQuad) {
// If the fourth ring is being done, take the chart that was cast earlier,
// and draw glyphs and lines to the true positions. If a fifth ring is
// being done, first finish the fourth one by drawing lines from the true
// positions to the inner ring.
ri2 -= off; rp -= off; rl1 -= off; rl2 -= off; rg -= off;
DrawRing(4, nRing, xplanet4, symbol, cx, cy,
base, base2, ri2, rp, rl1, rl2, rg, 1.8);
if (fQuin) {
// If the fifth ring is being done, take the chart that was cast
// earlier, and draw glyphs and lines to the true positions. If a sixth
// ring is being done, first finish the fifth one by drawing lines from
// the true positions to the inner ring.
ri2 -= off; rp -= off; rl1 -= off; rl2 -= off; rg -= off;
DrawRing(5, nRing, xplanet5, symbol, cx, cy,
base, base2, ri2, rp, rl1, rl2, rg, 2.3);
if (fHexa) {
// If the sixth (innermost) ring is being done, take the chart that was
// cast earlier, and draw glyphs and lines to the true positions.
ri2 -= off; rp -= off; rl1 -= off; rl2 -= off; rg -= off;
DrawRing(6, nRing, xplanet6, symbol, cx, cy,
base, base2, ri2, rp, rl1, rl2, rg, 3.8);
}
}
}
FProcessCommandLine(szWheelX[0]);
// Draw lines connecting planets between the charts that have aspects.
if (!gs.fEquator) {
base -= 0.02;
DrawAspectRelation(1, 2, pxp[1], pxp[2], cx, cy, base);
DrawAspectRelation(1, 3, pxp[1], pxp[3], cx, cy, base);
DrawAspectRelation(2, 3, pxp[2], pxp[3], cx, cy, base);
if (fQuad) {
DrawAspectRelation(1, 4, pxp[1], pxp[4], cx, cy, base);
DrawAspectRelation(2, 4, pxp[2], pxp[4], cx, cy, base);
DrawAspectRelation(3, 4, pxp[3], pxp[4], cx, cy, base);
if (fQuin) {
DrawAspectRelation(1, 5, pxp[1], pxp[5], cx, cy, base);
DrawAspectRelation(2, 5, pxp[2], pxp[5], cx, cy, base);
DrawAspectRelation(3, 5, pxp[3], pxp[5], cx, cy, base);
DrawAspectRelation(4, 5, pxp[4], pxp[5], cx, cy, base);
if (fHexa) {
DrawAspectRelation(1, 6, pxp[1], pxp[6], cx, cy, base);
DrawAspectRelation(2, 6, pxp[2], pxp[6], cx, cy, base);
DrawAspectRelation(3, 6, pxp[3], pxp[6], cx, cy, base);
DrawAspectRelation(4, 6, pxp[4], pxp[6], cx, cy, base);
DrawAspectRelation(5, 6, pxp[5], pxp[6], cx, cy, base);
}
}
}
}
// Draw sidebar with chart information and positions if need be.
ciCore = ciMain;
DrawSidebar();
}
// Draw an aspect (or midpoint) grid in the window, between the planets in two
// different charts, with the planets labeled at the top and side. This chart
// is done when the -g switch is combined with the -r0 and -X switches. Like
// the text version, the chart has a (definable) fixed number of cells.
void XChartGridRelation()
{
char sz[cchSzDef], szT[cchSzDef];
int nScale, unit, siz, x, y, i, j, i0, j0, k;
KI c;
nScale = gi.nScale/gi.nScaleT;
unit = CELLSIZE*gi.nScale; siz = (gi.nGridCell+1)*unit;
*szT = chNull;
i = us.fSmartCusp; us.fSmartCusp = fFalse;
j = us.objRequire; us.objRequire = -1;
if (!FCreateGridRelation(gs.fAlt != us.fGridMidpoint))
return;
us.fSmartCusp = i; us.objRequire = j;
// Loop through each cell in each row and column of grid.
for (y = 0, j0 = -2; y <= gi.nGridCell; y++) {
do {
j0++;
j = rgobjList[j0];
} while (j0 >= 0 && ignore[j] && j0 <= is.nObj);
DrawColor(gi.kiGray);
DrawDash(0, (y+1)*unit, siz, (y+1)*unit, !gs.fColor);
DrawDash((y+1)*unit, 0, (y+1)*unit, siz, !gs.fColor);
DrawColor(gi.kiLite);
DrawEdge(0, y*unit, unit, (y+1)*unit);
DrawEdge(y*unit, 0, (y+1)*unit, unit);
DrawEdge(y*unit, y*unit, (y+1)*unit, (y+1)*unit);
if (j0 <= is.nObj) for (x = 0, i0 = -2; x <= gi.nGridCell; x++) {
do {
i0++;
i = rgobjList[i0];
} while (i0 >= 0 && ignore[i] && i0 <= is.nObj);
// Again, are looping through each cell in each row and column.
if (i0 <= is.nObj) {
gi.xTurtle = x*unit+unit/2;
gi.yTurtle = y*unit+unit/2 - (nScale > 2 ? 5*gi.nScaleT : 0);
k = (i >= 0 && j >= 0 ? grid->n[i][j] : 0);
// If current cell is on top row or left hand column, draw glyph of
// planet owning the particular row or column in question.
if (y == 0 || x == 0) {
if (gs.fLabelAsp) {
DrawColor(kDkBlueB);
DrawBlock(x*unit+1, y*unit+1, (x+1)*unit-1, (y+1)*unit-1);
}
if (x+y > 0)
DrawObject(y == 0 ? i : j, gi.xTurtle, gi.yTurtle);
} else {
// Otherwise, draw glyph of aspect in effect, or glyph of sign of
// midpoint, between the two planets in question.
if (gs.fAlt == us.fGridMidpoint) {
if (k) {
DrawColor(c = kAspB[k]);
DrawAspect(k, gi.xTurtle, gi.yTurtle);
}
} else {
DrawColor(c = kSignB(grid->n[i][j]));
DrawSign(grid->n[i][j], gi.xTurtle, gi.yTurtle);
}
}
// When scale size is 300+, print some text in current cell.
if (nScale > 2 && gs.fLabel) {
// For top and left edges, print sign and degree of the planet.
if (y == 0 || x == 0) {
if (x > 0 || y > 0) {
c = FormatGridCell(sz, -2-(y == 0), y == 0 ? i : j, 0,
nScale > 3 && us.fSeconds);
} else {
// For extreme upper left corner, print some little arrows
// pointing out chart1's planets and chart2's planets.
c = gi.kiLite;
sprintf(sz, "1v 2->");
}
} else {
// Print aspect or midpoint cells.
c = FormatGridCell(sz, i, j, 1 + (gs.fAlt != us.fGridMidpoint),
nScale > 3 && us.fSeconds);
}
if (c >= 0)
DrawColor(c);
DrawSz(sz, x*unit+unit/2, (y+1)*unit-3*gi.nScaleT, dtBottom);
}
}
}
}
}
// Draw a chart showing a graphical ephemeris for the given month, year, or
// range of years, with the date on the vertical axis and the zodiac on the
// horizontal, as done when the -E is combined with the -X switch.
void XChartEphemeris()
{
real symbol[cObj*2+2], objSav[objMax], rT;
char sz[cchSzDef];
int cYea, unit = 6*gi.nScale, daytot, d = 1, dd, day, mon, yea, monsiz,
mon0, day0, yea0, x1, y1, x2, y2, xs, ys, m, n, u,
v = 0, vold = nNegative, i, j, dx;
flag fSav;
cYea = us.nEphemYears; // Is -EY on to do multiple years at once?
if (!us.fProgress) {
mon0 = Mon; day0 = Day; yea0 = Yea;
} else {
mon0 = MonT; day0 = DayT; yea0 = YeaT;
}
if (cYea) {
daytot = 0;
for (i = 0; i < cYea; i++)
daytot += DayInYear(yea0 + i);
day = 1; mon = 1; yea = yea0; monsiz = 31;
} else
daytot = DayInMonth(mon0, yea0);
x1 = (3 + Min(cYea, 2))*xFontT; y1 = unit*2;
x2 = gs.xWin - x1;
y2 = gs.yWin - y1 - gs.fText*yFontT;
xs = x2 - x1; ys = y2 - y1;
dd = (daytot / ys + 2) * (2 - us.fSeconds);
dd = Min(dd, 28);
// Display glyphs of the zodiac along the bottom axis.
if (!us.fParallel)
for (i = 1; i <= cSign+1; i++) {
m = x1 + NMultDiv(xs, i-1, 12);
j = i > cSign ? 1 : i;
DrawColor(kSignB(j));
DrawSign(j, m, y2 + unit);
if (!gs.fColorSign)
DrawColor(gi.kiGray);
DrawDash(m, y1, m, y2, 2);
}
else {
dx = gs.nRayWidth / 10; dx = Min(dx, 90); dx = Max(dx, 1);
for (i = -90; i <= 90; i += (dx > 30 ? 10 : (dx > 6 ? 5 : 1))) {
if (i < -dx || i > dx)
continue;
m = x1 + NMultDiv(xs, i+dx, dx << 1);
j = i > cSign ? 1 : i;
DrawColor(i ? gi.kiLite : gi.kiOn);
sprintf(sz, "%s%d", i > 0 ? "+" : "", i);
DrawSz(sz, m, y2+2, dtTop | dtScale2);
DrawColor(gi.kiGray);
DrawDash(m, y1, m, y2, 2);
}
}
// Loop and display planet movements for one day segment.
while (d <= daytot + 1) {
n = v;
if (gs.fLabel &&
(cYea ? (mon == mon0 && day == 1 && yea == yea0) : (d == day0))) {
// Marker line for specific day.
if (cYea)
v = y1 + NMultDiv(ys, d-2+day0, daytot);
else
v = y1 + NMultDiv(ys, (d-1)*24 + (int)Tim, daytot*24);
DrawColor(kDkGreenB);
DrawLine(x1, v, x2, v);
}
v = y1 + NMultDiv(ys, d-1, daytot);
if (!gs.fEquator && (!cYea || day == 1)) {
// Marker line for day or month.
DrawColor(gi.kiGray);
DrawDash(x1, v, x2, v, cYea <= 1 || mon == 1 ? 1 : 3);
}
if (d > 1)
for (i = 0; i <= is.nObj; i++)
objSav[i] = planet[i];
ciCore = ciMain;
if (cYea) {
MM = mon; DD = day; YY = yea;
} else {
MM = mon0; DD = d; YY = yea0;
}
if (us.fProgress) {
is.JDp = MdytszToJulian(MM, DD, YY, TT, SS, ZZ);
ciCore = ciMain;
}
CastChart(-1);
if (us.fParallel)
for (i = 0; i <= is.nObj; i++) {
rT = (planetalt[i] * rDegHalf / (real)dx) + rDegHalf;
rT = Min(rT, rDegMax);
rT = Max(rT, 0.0);
planet[i] = rT;
}
// Draw planet glyphs along top of chart.
if (d <= 1) {
for (i = 0; i <= is.nObj; i++) {
j = !FProperEphem2(i);
symbol[i*2] = (j || us.nRel > rcDual) ? -rLarge : cp2.obj[i];
j = !FProper(i);
symbol[i*2+1] = (j ? -rLarge : planet[i]);
}
FillSymbolLine(symbol);
fSav = gs.fLabel; gs.fLabel = fTrue;
for (i = is.nObj*2+1; i >= 0; i--) {
j = i >> 1;
if (symbol[i] >= 0.0)
DrawObject(j, x1 + (int)((real)xs * symbol[i] / rDegMax), unit);
}
gs.fLabel = fSav;
if (us.nRel <= rcDual) {
for (i = is.nObj; i >= 0; i--) {
if (!FProperEphem2(i))
continue;
j = x1 + (int)((real)xs * cp2.obj[i] / rDegMax);
DrawColor(kObjB[i]);
DrawDash(j, y1, j, y2, 1);
}
}
// Draw a line segment for each object during this time section.
} else
for (i = is.nObj; i >= 0; i--) {
if (!FProper(i))
continue;
m = x1 + (int)((real)xs * objSav[i] / rDegMax);
u = x1 + (int)((real)xs * planet[i] / rDegMax);
DrawColor(kObjB[i]);
DrawWrap(m, n, u, v,
!us.fParallel && ret[i] > 0.0 && i != oFor ? -x1 : x1, x2);
}
// Label months or days in the month along the left and right edges.
if (d <= daytot && (!cYea || (day == 1 && (cYea <= 1 || mon == 1))) &&
v-vold > (yFont-2)*gi.nScaleTextT) {
if (cYea) {
if (cYea <= 1)
sprintf(sz, "%.3s", szMonth[mon]);
else
sprintf(sz, "%4d", yea);
i = (cYea <= 1 ? mon == mon0 : yea == yea0);
} else {
sprintf(sz, "%2d", d);
i = (d == day0);
}
DrawColor(gs.fLabel && i ? gi.kiOn : gi.kiLite);
DrawSz(sz, xFontT/2, v + (yFont-2)*gi.nScaleTextT,
dtLeft | dtBottom | dtScale2);
DrawSz(sz, x2 + xFontT/2, v + (yFont-2)*gi.nScaleTextT,
dtLeft | dtBottom | dtScale2);
vold = v;
}
// Now increment the day counter. For a month always go up by one.
// For a year go up by four or until the end of the month reached.
if (cYea) {
day += dd;
if (day > monsiz) {
d += dd - (day-monsiz-1);
if (d <= daytot + 1) {
mon++;
if (mon > cSign) {
yea++;
mon = 1;
}
monsiz = DayInMonth(mon, yea);
day = 1;
}
} else
d += dd;
} else
d++;
}
DrawColor(gi.kiLite);
DrawEdge(x1, y1, x2, y2);
ciCore = ciMain; // Recast original chart.
CastChart(1);
}
// Draw a chart showing a graphical ephemeris of Ray influences for the given
// month or year, with the date on the vertical axis and each Ray on the
// horizontal, as done when the -7 is combined with the -X switch.
void XChartEsoteric()
{
real rRay[cRay+2], rRaySav[cRay+2], power1[objMax], power2[objMax],
power[oNorm+1];
char sz[cchSzDef];
int cYea, daytot, d = 1, dd, day, mon, yea, monsiz,
x1, y1, x2, y2, xs, ys, m, n, u, v = 0, i, j, k;
EnsureRay();
cYea = us.nEphemYears; // Is -EY on to do multiple years at once?
if (cYea) {
daytot = 0;
for (i = 0; i < cYea; i++)
daytot += DayInYear(Yea + i);
day = 1; mon = 1; yea = Yea; monsiz = 31;
} else
daytot = DayInMonth(Mon, Yea);
x1 = (3 + Min(cYea, 2))*xFontT; y1 = 12*gi.nScaleTextT;
x2 = gs.xWin - x1; y2 = gs.yWin - y1;
xs = x2 - x1; ys = y2 - y1;
dd = (daytot / ys + 1) * (2 - us.fSeconds);
dd = Min(dd, 28);
// Label Rays along the top axis.
for (i = 1; i <= cRay+1; i++) {
m = x1 + NMultDiv(xs, i-1, cRay+1);
DrawColor(gi.kiGray);
DrawDash(m, y1, m, y2, 2);
if (i <= cRay)
sprintf(sz, "Ray %d", i);
else
sprintf(sz, "Average");
DrawColor(i <= cRay ? kRayB[i] : gi.kiOn);
DrawSz(sz, x1 + xs*(i-1)/8, y1 - 3*gi.nScaleTextT,
dtLeft | dtBottom | dtScale2);
}
// Loop and display Ray influences for one day segment.
while (d <= daytot + 1) {
n = v;
if (gs.fLabel &&
(cYea ? (mon == Mon && day == 1 && yea == Yea) : (d == Day))) {
// Marker line for specific day.
if (cYea)
v = y1 + NMultDiv(ys, d-2+Day, daytot);
else
v = y1 + NMultDiv(ys, (d-1)*24 + (int)Tim, daytot*24);
DrawColor(kDkCyanB);
DrawLine(x1, v, x2, v);
}
v = y1 + NMultDiv(ys, d-1, daytot);
if (!gs.fEquator && (!cYea || day == 1)) {
// Marker line for day or month.
DrawColor(gi.kiGray);
DrawDash(x1, v, x2, v, cYea <= 1 || mon == 1 ? 1 : 3);
}
if (d > 1)
for (i = 1; i <= cRay+1; i++)
rRaySav[i] = rRay[i];
ciCore = ciMain;
if (cYea) {
MM = mon; DD = day; YY = yea;
} else
DD = d;
CastChart(-1);
// Compute Ray influences for current day.
for (i = 0; i <= cRay+1; i++)
rRay[i] = 0.0;
ComputeInfluence(power1, power2);
for (i = 0; i <= oNorm; i++) {
power[i] = power1[i] + power2[i];
if (FIgnore(i))
continue;
k = SFromZ(planet[i]);
for (j = 1; j <= cRay; j++)
if (rgSignRay2[k][j]) {
if (!gs.fAlt)
rRay[j] += power[i];
else
rRay[j] += power[i] / (420 / rgSignRay2[k][j]);
}
}
for (i = 0; i <= cRay; i++)
rRay[cRay+1] += rRay[i] / 7.0;
// Draw a line segment for each Ray during this time section.
if (d > 1)
for (i = 1; i <= cRay+1; i++) {
k = x1 + (i-1)*xs/8;
m = k + (int)((real)xs * rRaySav[i] / 8.0 / (real)gs.nRayWidth);