-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdodecatemoriawnd.py
More file actions
234 lines (195 loc) · 10.4 KB
/
dodecatemoriawnd.py
File metadata and controls
234 lines (195 loc) · 10.4 KB
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
# -*- coding: utf-8 -*-
import wx
import os
import astrology
import chart
import houses
import planets
import common
import commonwnd
import Image, ImageDraw, ImageFont
import util
import mtexts
import dodek_converter
import dodecacalcframe
class DodecatemoriaWnd(commonwnd.CommonWnd):
def __init__(self, parent, chrt, options, mainfr, id = -1, size = wx.DefaultSize):
commonwnd.CommonWnd.__init__(self, parent, chrt, options, id, size)
self.parent = parent
self.ants = chrt.antiscia
self.options = options
self.mainfr = mainfr
self.bw = self.options.bw
self.ID_DODEK_CONV = wx.NewId()
self.pmenu.Insert(0, self.ID_DODEK_CONV, mtexts.txts["DodecatemoriaCalculator"])
self.Bind(wx.EVT_MENU, self.on_open_dodek_converter, id=self.ID_DODEK_CONV)
#wx.CallAfter(self.on_open_dodek_converter, None)
self.FONT_SIZE = int(21*self.options.tablesize) #Change fontsize to change the size of the table!
self.COLUMN_NUM = 2
self.SPACE = self.FONT_SIZE/2
self.LINE_HEIGHT = (self.SPACE+self.FONT_SIZE+self.SPACE)
self.SMALL_CELL_WIDTH = 3*self.FONT_SIZE
self.CELL_WIDTH = 8*self.FONT_SIZE
self.TITLE_HEIGHT = 2*self.LINE_HEIGHT
self.TITLE_WIDTH = self.COLUMN_NUM*self.CELL_WIDTH
self.SPACE_TITLEY = 0
self.LINE_NUM = 15
if self.options.intables:
if not self.options.transcendental[chart.Chart.TRANSURANUS]:
self.LINE_NUM -= 1
if not self.options.transcendental[chart.Chart.TRANSNEPTUNE]:
self.LINE_NUM -= 1
if not self.options.transcendental[chart.Chart.TRANSPLUTO]:
self.LINE_NUM -= 1
if not self.options.showlof:
self.LINE_NUM -= 1
if not self.options.shownodes:
self.LINE_NUM -= 2
self.TABLE_HEIGHT = (self.TITLE_HEIGHT+self.SPACE_TITLEY+self.LINE_NUM*(self.LINE_HEIGHT))
self.TABLE_WIDTH = (self.SMALL_CELL_WIDTH+self.COLUMN_NUM*(self.CELL_WIDTH))
self.WIDTH = int(commonwnd.CommonWnd.BORDER+self.TABLE_WIDTH+commonwnd.CommonWnd.BORDER)
self.HEIGHT = int(commonwnd.CommonWnd.BORDER+self.TABLE_HEIGHT+commonwnd.CommonWnd.BORDER)
self.SetVirtualSize((self.WIDTH, self.HEIGHT))
self.clrs = [self.options.clrdomicil, self.options.clrexal, self.options.clrperegrin, self.options.clrcasus, self.options.clrexil]
self.fntMorinus = ImageFont.truetype(common.common.symbols, int(self.FONT_SIZE))
self.fntSymbol = ImageFont.truetype(common.common.symbols, int(3*self.FONT_SIZE/2))
self.fntText = ImageFont.truetype(common.common.abc, int(self.FONT_SIZE))
self.signs = common.common.Signs1
if not self.options.signs:
self.signs = common.common.Signs2
self.deg_symbol = u'\u00b0'
self.drawBkg()
def getExt(self):
return mtexts.txts['Dodecatemorion']
def drawBkg(self):
if self.bw:
self.bkgclr = (255,255,255)
else:
self.bkgclr = self.options.clrbackground
self.SetBackgroundColour(self.bkgclr)
tableclr = self.options.clrtable
if self.bw:
tableclr = (0,0,0)
img = Image.new('RGB', (self.WIDTH, self.HEIGHT), self.bkgclr)
draw = ImageDraw.Draw(img)
BOR = commonwnd.CommonWnd.BORDER
#Title
draw.rectangle(((BOR+self.SMALL_CELL_WIDTH, BOR),(BOR+self.SMALL_CELL_WIDTH+self.TITLE_WIDTH, BOR+self.TITLE_HEIGHT)), outline=(tableclr), fill=(self.bkgclr))
txtclr = (0,0,0)
if not self.bw:
txtclr = self.options.clrtexts
txt = (mtexts.txts['Dodecatemorion'], "")
for i in range(len(txt)):
w,h = draw.textsize(txt[i], self.fntText)
offs = 0
if i == 1:
offs = self.CELL_WIDTH
draw.text((BOR+self.SMALL_CELL_WIDTH+self.CELL_WIDTH/2+offs+self.CELL_WIDTH*i+(self.CELL_WIDTH-w)/2, BOR+(self.LINE_HEIGHT-h)/2), txt[i], fill=txtclr, font=self.fntText)
txt = (mtexts.txts['Longitude'], mtexts.txts['Latitude'])
for i in range(len(txt)):
w,h = draw.textsize(txt[i], self.fntText)
draw.text((BOR+self.SMALL_CELL_WIDTH+self.CELL_WIDTH*i+(self.CELL_WIDTH-w)/2, BOR+self.LINE_HEIGHT+(self.LINE_HEIGHT-h)/2), txt[i], fill=txtclr, font=self.fntText)
x = BOR
y = BOR+self.TITLE_HEIGHT+self.SPACE_TITLEY
draw.line((x, y, x+self.TABLE_WIDTH, y), fill=tableclr)
txts = (common.common.Planets[0], common.common.Planets[1], common.common.Planets[2], common.common.Planets[3], common.common.Planets[4], common.common.Planets[5], common.common.Planets[6], common.common.Planets[7], common.common.Planets[8], common.common.Planets[9], common.common.Planets[10], common.common.Planets[11], common.common.fortune, '0', '1')
# ##################################
# Roberto V 8.0.1
# Latitude set to zero. To decide if replace with a pseudo-astronomical one or if remove the whole column.
#data = ((self.ants.pldodecatemoria[0].lon, 0.0), (self.ants.pldodecatemoria[1].lon, self.ants.pldodecatemoria[1].lat), (self.ants.pldodecatemoria[2].lon, self.ants.pldodecatemoria[2].lat), (self.ants.pldodecatemoria[3].lon, self.ants.pldodecatemoria[3].lat), (self.ants.pldodecatemoria[4].lon, self.ants.pldodecatemoria[4].lat), (self.ants.pldodecatemoria[5].lon, self.ants.pldodecatemoria[5].lat), (self.ants.pldodecatemoria[6].lon, self.ants.pldodecatemoria[6].lat), (self.ants.pldodecatemoria[7].lon, self.ants.pldodecatemoria[7].lat), (self.ants.pldodecatemoria[8].lon, self.ants.pldodecatemoria[8].lat), (self.ants.pldodecatemoria[9].lon, self.ants.pldodecatemoria[9].lat), (self.ants.pldodecatemoria[10].lon, self.ants.pldodecatemoria[10].lat), (self.ants.pldodecatemoria[11].lon, self.ants.pldodecatemoria[11].lat), (self.ants.lofdodec.lon, self.ants.lofdodec.lat), (self.ants.ascmcdodec[0].lon, self.ants.ascmcdodec[0].lat), (self.ants.ascmcdodec[1].lon, self.ants.ascmcdodec[1].lat))
data = ((self.ants.pldodecatemoria[0].lon, 0.0), (self.ants.pldodecatemoria[1].lon, 0.0), (self.ants.pldodecatemoria[2].lon, 0.0), (self.ants.pldodecatemoria[3].lon, 0.0), (self.ants.pldodecatemoria[4].lon, 0.0), (self.ants.pldodecatemoria[5].lon, 0.0), (self.ants.pldodecatemoria[6].lon, 0.0), (self.ants.pldodecatemoria[7].lon, 0.0), (self.ants.pldodecatemoria[8].lon, 0.0), (self.ants.pldodecatemoria[9].lon, 0.0), (self.ants.pldodecatemoria[10].lon, self.ants.pldodecatemoria[10].lat), (self.ants.pldodecatemoria[11].lon, self.ants.pldodecatemoria[11].lat), (self.ants.lofdodec.lon, self.ants.lofdodec.lat), (self.ants.ascmcdodec[0].lon, self.ants.ascmcdodec[0].lat), (self.ants.ascmcdodec[1].lon, self.ants.ascmcdodec[1].lat))
# ##################################
i = 0
for j in range(len(txts)):
ascmc = False
if j > 12:
ascmc = True
if self.options.intables and ((j == astrology.SE_URANUS and not self.options.transcendental[chart.Chart.TRANSURANUS]) or (j == astrology.SE_NEPTUNE and not self.options.transcendental[chart.Chart.TRANSNEPTUNE]) or (j == astrology.SE_PLUTO and not self.options.transcendental[chart.Chart.TRANSPLUTO]) or (j == astrology.SE_MEAN_NODE and not self.options.shownodes) or (j == astrology.SE_TRUE_NODE and not self.options.shownodes) or (j== astrology.SE_TRUE_NODE+1 and not self.options.showlof)):
continue
self.drawline(draw, x, y+i*self.LINE_HEIGHT, txts[j], tableclr, data[j], j, ascmc)
i += 1
wxImg = wx.Image(img.size[0], img.size[1])
wxImg.SetData(img.tobytes())
self.buffer = wx.Bitmap(wxImg)
def drawline(self, draw, x, y, txt, clr, data, idx, AscMC):
#bottom horizontal line
draw.line((x, y+self.LINE_HEIGHT, x+self.TABLE_WIDTH, y+self.LINE_HEIGHT), fill=clr)
#vertical lines
offs = (0, self.SMALL_CELL_WIDTH, self.CELL_WIDTH, self.CELL_WIDTH, self.CELL_WIDTH, self.CELL_WIDTH)
summa = 0
for i in range(self.COLUMN_NUM+1+1):#+1 is the leftmost column
draw.line((x+summa+offs[i], y, x+summa+offs[i], y+self.LINE_HEIGHT), fill=clr)
summa += offs[i]
#draw symbols
clr = (0,0,0)
if not self.bw:
if not AscMC:
# ##################################
# Elias V 8.0.0
# Roberto V 8.0.1
objidx = idx
if objidx >= len(common.common.Planets)-1:
objidx -= 1
if self.options.useplanetcolors:
clr = self.options.clrindividual[objidx]
else:
clr = self.clrs[self.chart.dignity(objidx)]
# ##################################
else:
clr = self.options.clrtexts
# ##################################
fnt = self.fntMorinus
if AscMC:
fnt = self.fntSymbol
w,h = draw.textsize(txt, fnt)
offset = (self.SMALL_CELL_WIDTH-w)/2
draw.text((x+offset, y+(self.LINE_HEIGHT-h)/2), txt, fill=clr, font=fnt)
#data
offs = (self.CELL_WIDTH, self.CELL_WIDTH, self.CELL_WIDTH, self.CELL_WIDTH)
summa = 0
for i in range(len(data)):
d,m,s = util.decToDeg(data[i])
if i == 0 or i == 2:
# dodecatemoria는 antiscia.calcDodecatemoria()에서 이미
# self.options.ayanamsha에 따라 시데럴로 계산됨.
# 표시 단계에서 아야남샤를 다시 적용하지 않는다.
d, m, s = util.decToDeg(util.normalize(data[i]))
sign = int(d/chart.Chart.SIGN_DEG)
pos = d%chart.Chart.SIGN_DEG
wsp,hsp = draw.textsize(' ', self.fntText)
wsg,hsg = draw.textsize(self.signs[sign], self.fntMorinus)
txt = (str(pos)).rjust(2)+self.deg_symbol+(str(m)).zfill(2)+"'"+(str(s)).zfill(2)+'"'
w,h = draw.textsize(txt, self.fntText)
offset = (offs[i]-(w+wsp+wsg))/2
draw.text((x+self.SMALL_CELL_WIDTH+summa+offset, y+(self.LINE_HEIGHT-h)/2), txt, fill=clr, font=self.fntText)
draw.text((x+self.SMALL_CELL_WIDTH+summa+offset+w+wsp, y+(self.LINE_HEIGHT-hsg)/2), self.signs[sign], fill=clr, font=self.fntMorinus)
else:
sign = ''
if data[i] < 0.0:
sign = '-'
txt = sign+(str(d)).rjust(2)+self.deg_symbol+(str(m)).zfill(2)+"'"+(str(s)).zfill(2)+'"'
w,h = draw.textsize(txt, self.fntText)
offset = (offs[i]-w)/2
draw.text((x+self.SMALL_CELL_WIDTH+summa+offset, y+(self.LINE_HEIGHT-h)/2), txt, fill=clr, font=self.fntText)
summa += offs[i]
def on_open_dodek_converter(self, evt):
# Dodecatemoria Calculator 프레임 호출
try:
# 메인 프레임 타이틀의 차트 타입명을 "Dodecatemoria" 로 대체 (morin.onDodecatemoria 방식과 동일 컨벤션)
try:
calc_title = self.mainfr.title.replace(
mtexts.typeList[self.chart.horoscope.htype],
mtexts.txts.get('DodecatemoriaCalculator', 'Dodecatemoria')
)
except Exception:
# title 치환 실패 시 기본값
calc_title = mtexts.txts.get('DodecatemoriaCalculator', 'Dodecatemoria')
fr = dodecacalcframe.DodecaCalcFrame(self.mainfr, calc_title, self.chart, self.options)
fr.Show(True)
except Exception:
# 타이틀 구성 등에서 문제가 나도 계산기 띄우기는 보장
fr = dodecacalcframe.DodecaCalcFrame(self.mainfr, mtexts.txts.get('DodecatemoriaCalculator', 'Dodecatemoria'), self.chart, self.options)
fr.Show(True)
def _on_dodek_close(self, evt):
self._dlg_dodek.Destroy()
self._dlg_dodek = None