Compare commits
868
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fbdd9ad2f | ||
|
|
24539968fd | ||
|
|
f13b356531 | ||
|
|
477594d7bc | ||
|
|
e955a18126 | ||
|
|
adec1c4507 | ||
|
|
172b8a032c | ||
|
|
d6c8008978 | ||
|
|
488ca0fcc5 | ||
|
|
dfd15cadab | ||
|
|
1613257bdc | ||
|
|
1061580118 | ||
|
|
7184828a58 | ||
|
|
0428adff03 | ||
|
|
04246f0a63 | ||
|
|
61df58d651 | ||
|
|
1bd9a440e8 | ||
|
|
d82c8eb945 | ||
|
|
becbad7ea4 | ||
|
|
2335796a28 | ||
|
|
c6330b64f6 | ||
|
|
df57a23512 | ||
|
|
aea71cf0af | ||
|
|
fb54386f8d | ||
|
|
4d931b6109 | ||
|
|
407c7a10f5 | ||
|
|
16fa4d1d17 | ||
|
|
1ecccd43d4 | ||
|
|
2edbb1cf8b | ||
|
|
8dccbe8029 | ||
|
|
031c833e4d | ||
|
|
890cc46825 | ||
|
|
6b0f7e8512 | ||
|
|
7a220921f0 | ||
|
|
7ef9acda5d | ||
|
|
2a6d62e6f7 | ||
|
|
42b50bd7f7 | ||
|
|
2c3f44ae11 | ||
|
|
b7662f16e5 | ||
|
|
5bc535a8d2 | ||
|
|
3ec9c7ae6e | ||
|
|
e326d0c756 | ||
|
|
7c5434a99f | ||
|
|
26d9256ee9 | ||
|
|
053e761d8f | ||
|
|
5861b52cff | ||
|
|
66193d7283 | ||
|
|
dfb07f359e | ||
|
|
6fe1433497 | ||
|
|
01ace109ba | ||
|
|
8e01acaa12 | ||
|
|
7bbec8dbcb | ||
|
|
10375086ed | ||
|
|
dd367daac9 | ||
|
|
27063d0c32 | ||
|
|
80ff0282c3 | ||
|
|
e973e406a3 | ||
|
|
c64776029e | ||
|
|
5d7d0a922d | ||
|
|
c2c96c4219 | ||
|
|
3e9ed08c53 | ||
|
|
b7df9026c0 | ||
|
|
6527c6357b | ||
|
|
fad333256c | ||
|
|
8753811fe1 | ||
|
|
237752ff62 | ||
|
|
743244a69c | ||
|
|
9f89737986 | ||
|
|
508a5c5f66 | ||
|
|
d84394efa0 | ||
|
|
dd613d48bc | ||
|
|
2e8e500d4f | ||
|
|
48f866dcc6 | ||
|
|
ec4d3e4f9b | ||
|
|
38ddfab1e0 | ||
|
|
353b7e4438 | ||
|
|
7076c9a0ff | ||
|
|
2f42a8714c | ||
|
|
fdf6fc32ff | ||
|
|
f2188b33c6 | ||
|
|
f93fead8f2 | ||
|
|
050f3791cc | ||
|
|
94326fd964 | ||
|
|
f26f3b606d | ||
|
|
7cbfa76be4 | ||
|
|
d896e71ae9 | ||
|
|
ca79d99ec4 | ||
|
|
95f77ef81d | ||
|
|
c4e7d26b70 | ||
|
|
ea49a1a07b | ||
|
|
784223c67f | ||
|
|
77aa2c9a9d | ||
|
|
48145fb234 | ||
|
|
49730cadee | ||
|
|
0b197501e1 | ||
|
|
8b0c246a7b | ||
|
|
9c4face1ae | ||
|
|
952e2e6631 | ||
|
|
4766910413 | ||
|
|
3c2f97a8d2 | ||
|
|
f75730f165 | ||
|
|
b596e62a61 | ||
|
|
1349d48339 | ||
|
|
d69ea5fda6 | ||
|
|
9b68062ba7 | ||
|
|
b217019723 | ||
|
|
a37a254a68 | ||
|
|
5258699f20 | ||
|
|
483bebb003 | ||
|
|
8ca8052a8d | ||
|
|
d68b1144b8 | ||
|
|
42c39b6be3 | ||
|
|
bb82b9d168 | ||
|
|
b1f865d461 | ||
|
|
8e75c6be50 | ||
|
|
06a5f9188d | ||
|
|
370a991208 | ||
|
|
6deb77dd4d | ||
|
|
9e3172cb04 | ||
|
|
426c6b9a72 | ||
|
|
d148bdedcd | ||
|
|
23140e3bf7 | ||
|
|
2f023803e7 | ||
|
|
d658b5fc38 | ||
|
|
68cd84c330 | ||
|
|
0bd82a43d3 | ||
|
|
7fdf42b699 | ||
|
|
aeb0e9aac3 | ||
|
|
1099a3bdf0 | ||
|
|
aa3458f69c | ||
|
|
0186cbb7b7 | ||
|
|
fa36e94c4b | ||
|
|
ad83e70cf5 | ||
|
|
4a0377c0a1 | ||
|
|
83a3241830 | ||
|
|
f299b351e3 | ||
|
|
3880e4ef47 | ||
|
|
f205e918d9 | ||
|
|
42b0b9306b | ||
|
|
483659c319 | ||
|
|
add14dd27c | ||
|
|
61516a5e97 | ||
|
|
17418039e1 | ||
|
|
25cae61211 | ||
|
|
db98c7440e | ||
|
|
3783ae2234 | ||
|
|
3e8732b230 | ||
|
|
b39bca9458 | ||
|
|
d263334030 | ||
|
|
b2cea62189 | ||
|
|
d6b886c69b | ||
|
|
38fb9ea41e | ||
|
|
a922aaa68e | ||
|
|
4f2e36ca46 | ||
|
|
f367627cac | ||
|
|
7a7fcf10ad | ||
|
|
b9bd2734eb | ||
|
|
9c7bd4f5d5 | ||
|
|
362d47f91f | ||
|
|
a18792c397 | ||
|
|
0e2ddb2f16 | ||
|
|
bcfadd6657 | ||
|
|
021cf1a2b4 | ||
|
|
acf86be516 | ||
|
|
dd93eb88f2 | ||
|
|
e06f9e35b3 | ||
|
|
c0424aba7e | ||
|
|
b468254d73 | ||
|
|
15e3e92ec2 | ||
|
|
ee403fd83a | ||
|
|
05f266ac10 | ||
|
|
f52c0026dd | ||
|
|
a284107249 | ||
|
|
a2e25e7940 | ||
|
|
d45a0161cf | ||
|
|
c7a5d15e7a | ||
|
|
3cb2241b1d | ||
|
|
b236821661 | ||
|
|
fc75b0bd21 | ||
|
|
a9fc84d568 | ||
|
|
b15c6d887d | ||
|
|
c2f89978ff | ||
|
|
a004153223 | ||
|
|
dde2bbcbe7 | ||
|
|
7bd572f3ec | ||
|
|
486011dceb | ||
|
|
01c45633b7 | ||
|
|
5320d0ecaa | ||
|
|
757ba03918 | ||
|
|
948db69cc9 | ||
|
|
92f363926e | ||
|
|
d0ff144753 | ||
|
|
943efbb3ed | ||
|
|
6962de4b1f | ||
|
|
6f7c0c23d1 | ||
|
|
14eccc70da | ||
|
|
d4b48cec5d | ||
|
|
2d23c5351f | ||
|
|
b5dfaf170a | ||
|
|
c372591f36 | ||
|
|
36d1308aa6 | ||
|
|
b0d6ed3844 | ||
|
|
5818366d92 | ||
|
|
e5bca74b9d | ||
|
|
82dd1e4be9 | ||
|
|
d0b77639c2 | ||
|
|
6edb0f66d5 | ||
|
|
c458c13af7 | ||
|
|
bb7875edd4 | ||
|
|
6f54fb90eb | ||
|
|
4d1e7c536f | ||
|
|
59cc200f92 | ||
|
|
c6093430ae | ||
|
|
23172bcdd0 | ||
|
|
aea2dab0d7 | ||
|
|
4d26e144ab | ||
|
|
c391fcd345 | ||
|
|
ece743342a | ||
|
|
02babbe340 | ||
|
|
e27b6d050c | ||
|
|
86e2de8d10 | ||
|
|
b4526f926d | ||
|
|
14f04878d1 | ||
|
|
830fb3b752 | ||
|
|
9a336da359 | ||
|
|
6cec49ce7e | ||
|
|
6c28edea55 | ||
|
|
d7870d672e | ||
|
|
5bd9228b4a | ||
|
|
6392cf5a2f | ||
|
|
6a2e2b704e | ||
|
|
ecec803388 | ||
|
|
848965e7f0 | ||
|
|
478af5f01e | ||
|
|
14decb7387 | ||
|
|
323d0d5ba0 | ||
|
|
9bfa6ac1a1 | ||
|
|
c8af817eeb | ||
|
|
d24d3ce487 | ||
|
|
60a81dfbd8 | ||
|
|
8896a59dff | ||
|
|
7fe16d99be | ||
|
|
c3af88dfc1 | ||
|
|
5c8f0cc966 | ||
|
|
2a6c50c893 | ||
|
|
7a8d796ac1 | ||
|
|
8b3b71bce3 | ||
|
|
83da4e9248 | ||
|
|
2c879095d9 | ||
|
|
13344fbb62 | ||
|
|
2fe9ad595f | ||
|
|
0f798289f0 | ||
|
|
01104cc1d3 | ||
|
|
d61b5827fd | ||
|
|
d18cc81531 | ||
|
|
c96d7ae226 | ||
|
|
9535aef59b | ||
|
|
82f6fca06f | ||
|
|
627b36a53b | ||
|
|
2af78a3874 | ||
|
|
7c7109edf4 | ||
|
|
0fa23b83e6 | ||
|
|
e53c71543a | ||
|
|
fa64f7b6aa | ||
|
|
eaac3a64f8 | ||
|
|
4eabc45dfc | ||
|
|
5c5e2a0f2f | ||
|
|
559a5d146a | ||
|
|
df46c58cb8 | ||
|
|
1f43132363 | ||
|
|
17369a20de | ||
|
|
c83dae4c70 | ||
|
|
c2f44a51c4 | ||
|
|
3da44d1215 | ||
|
|
f6709e357f | ||
|
|
45d5511fd7 | ||
|
|
198c5d23fd | ||
|
|
c41caeaf64 | ||
|
|
b6c542b0e7 | ||
|
|
2d62275a08 | ||
|
|
971ea81861 | ||
|
|
9e9cc7859c | ||
|
|
8898f5fe52 | ||
|
|
40be69ae8e | ||
|
|
17eec81071 | ||
|
|
c9bbbd18ec | ||
|
|
e08eda18d5 | ||
|
|
d2c03a6651 | ||
|
|
0a1e920659 | ||
|
|
cd58df820e | ||
|
|
1a5467aec8 | ||
|
|
0dcb64dca3 | ||
|
|
b703102d9b | ||
|
|
3c2ef75b50 | ||
|
|
4fa530354d | ||
|
|
eeeb30dc3f | ||
|
|
870fc2e53e | ||
|
|
79ae0da927 | ||
|
|
e179bda57a | ||
|
|
8e0c15e32e | ||
|
|
ff844f6760 | ||
|
|
bc96ac85f4 | ||
|
|
33b328e3d5 | ||
|
|
dcda8d1c7a | ||
|
|
5fd2bd225f | ||
|
|
2db8859076 | ||
|
|
6eff167a28 | ||
|
|
9fecb69b84 | ||
|
|
0539aa38e5 | ||
|
|
fe9caad391 | ||
|
|
ceae2928aa | ||
|
|
0e6934abe5 | ||
|
|
a2e7c92f99 | ||
|
|
643a8717b4 | ||
|
|
f21127fd4a | ||
|
|
0bc8005100 | ||
|
|
67efc1f68f | ||
|
|
dfebf60e68 | ||
|
|
26e7d134ce | ||
|
|
c414242f13 | ||
|
|
33e60725b1 | ||
|
|
f21b0985cc | ||
|
|
71e9548c20 | ||
|
|
fc64abea5c | ||
|
|
413e89c955 | ||
|
|
439041c2f4 | ||
|
|
530de4d809 | ||
|
|
5e45bdeeda | ||
|
|
081eba903f | ||
|
|
0def045611 | ||
|
|
e20cc6a90f | ||
|
|
7dd83dd2d1 | ||
|
|
1240807b9f | ||
|
|
ad7d6624de | ||
|
|
06b089ba13 | ||
|
|
e1302bcf17 | ||
|
|
cfdc7db79a | ||
|
|
50de873453 | ||
|
|
a4ae7b2059 | ||
|
|
d90abdcb44 | ||
|
|
4a31045fd9 | ||
|
|
249155987d | ||
|
|
2ae7fc244b | ||
|
|
fafa70c6bc | ||
|
|
49162a7a64 | ||
|
|
328e6b3e28 | ||
|
|
5441db9b18 | ||
|
|
06bfa4f1a1 | ||
|
|
a530712491 | ||
|
|
3c8cfe9b76 | ||
|
|
57b4ce96e4 | ||
|
|
63c7d64143 | ||
|
|
1784327c47 | ||
|
|
a63ec83d5f | ||
|
|
d661516b02 | ||
|
|
ba020245f9 | ||
|
|
79fefc1ff9 | ||
|
|
eac169b6da | ||
|
|
a60d293759 | ||
|
|
b0063f8db6 | ||
|
|
632abdd87b | ||
|
|
d9b01ca5de | ||
|
|
adb7db9229 | ||
|
|
e4f7aec965 | ||
|
|
768a8c1062 | ||
|
|
318c5000ce | ||
|
|
70f334e1a3 | ||
|
|
279b53a705 | ||
|
|
a72a3ce5f3 | ||
|
|
979aea5212 | ||
|
|
34d3c63384 | ||
|
|
cf4af2692b | ||
|
|
d335ca5a8d | ||
|
|
9cac2c1457 | ||
|
|
523b992b4c | ||
|
|
02be490466 | ||
|
|
45ae3978f6 | ||
|
|
f983194d7e | ||
|
|
ab8373b989 | ||
|
|
4bef2c48eb | ||
|
|
21e2a769eb | ||
|
|
fd8369142a | ||
|
|
5dea221ad5 | ||
|
|
235c29913a | ||
|
|
0870407f65 | ||
|
|
e8156c6bd9 | ||
|
|
e7f9486aa1 | ||
|
|
53b9fd2110 | ||
|
|
4d4e474464 | ||
|
|
a58b41e7d2 | ||
|
|
4db05e97c5 | ||
|
|
3a668232c8 | ||
|
|
d2622a5d86 | ||
|
|
d11db8a67a | ||
|
|
98b6102e56 | ||
|
|
0db8613a21 | ||
|
|
94a6cb2cff | ||
|
|
5b92575ed3 | ||
|
|
47b02c0480 | ||
|
|
691be54ca2 | ||
|
|
22ea8ebe25 | ||
|
|
bd71635c49 | ||
|
|
830bc3eac3 | ||
|
|
2d72bf4308 | ||
|
|
f4e694afa7 | ||
|
|
55610bae70 | ||
|
|
08351e0df2 | ||
|
|
7489771ad2 | ||
|
|
ea8023e51f | ||
|
|
8a9693a28e | ||
|
|
724fba4af9 | ||
|
|
beca1cbf96 | ||
|
|
b74d2ae9fa | ||
|
|
ec82a0154b | ||
|
|
0ea8dbea10 | ||
|
|
a131f44247 | ||
|
|
0423aedffc | ||
|
|
afc89cdd95 | ||
|
|
541606e00d | ||
|
|
c53fd5fc9a | ||
|
|
bc3dd06b26 | ||
|
|
fd39808ed8 | ||
|
|
a1b7cb5330 | ||
|
|
ac27fae712 | ||
|
|
f6270ec395 | ||
|
|
e9c70f8b1c | ||
|
|
50688e1159 | ||
|
|
8417fea3bf | ||
|
|
f5150d32af | ||
|
|
2263823f75 | ||
|
|
a882263033 | ||
|
|
24d2431522 | ||
|
|
fd27e7bd43 | ||
|
|
4dfe36cdc1 | ||
|
|
fc49be1e05 | ||
|
|
d06d94c767 | ||
|
|
66786651b0 | ||
|
|
e9b499b82d | ||
|
|
e6e3e686c6 | ||
|
|
1e6ba0cdc4 | ||
|
|
75db4c29b8 | ||
|
|
914d3e6a2b | ||
|
|
ff678a5ad7 | ||
|
|
46442ef50c | ||
|
|
7d8fde82e6 | ||
|
|
99cf057906 | ||
|
|
59d3d66f91 | ||
|
|
be73c0fe43 | ||
|
|
e5afc6f029 | ||
|
|
8816d0a9ac | ||
|
|
229837b14c | ||
|
|
94b068a40f | ||
|
|
2f0dfc4d74 | ||
|
|
3391c44107 | ||
|
|
35aae588b8 | ||
|
|
c19585e22a | ||
|
|
77946585b1 | ||
|
|
88a35fd162 | ||
|
|
7d8d4a03fb | ||
|
|
1a68d34663 | ||
|
|
72a0ff706d | ||
|
|
420e43d47d | ||
|
|
3c749d4774 | ||
|
|
d4310a7f3b | ||
|
|
f892d88c10 | ||
|
|
d226709836 | ||
|
|
fbfd03fe5c | ||
|
|
f513001798 | ||
|
|
31aa0ddabe | ||
|
|
767184cf3c | ||
|
|
fe86a9ed02 | ||
|
|
9be53e746f | ||
|
|
8b6f50d0cc | ||
|
|
80dc28bfb5 | ||
|
|
983e1abf48 | ||
|
|
ff65b82671 | ||
|
|
0b26c69222 | ||
|
|
904d714d6d | ||
|
|
2aed93a576 | ||
|
|
d1af42e9ad | ||
|
|
9f31addfa5 | ||
|
|
d56ea7e6c4 | ||
|
|
1cbe271ad5 | ||
|
|
33db3c377f | ||
|
|
a0535ef64d | ||
|
|
392ba18ff7 | ||
|
|
e872f9e928 | ||
|
|
04685a8179 | ||
|
|
55fbe68e62 | ||
|
|
f51e1f0cc8 | ||
|
|
d31b62d44d | ||
|
|
9fd90e26f7 | ||
|
|
dbea0c9361 | ||
|
|
201cb61f84 | ||
|
|
71141e830a | ||
|
|
7dc8bf3aa4 | ||
|
|
0fef94cfdb | ||
|
|
a9b45967ce | ||
|
|
0928bca531 | ||
|
|
77f73a79df | ||
|
|
279445d6bc | ||
|
|
54778ee1e1 | ||
|
|
4efcda534d | ||
|
|
45ac5cb2fa | ||
|
|
6d045a9403 | ||
|
|
8c57a77d7e | ||
|
|
1f585d6719 | ||
|
|
6c111f55aa | ||
|
|
b01693f426 | ||
|
|
e37232aeb4 | ||
|
|
1c1c7dad7b | ||
|
|
b70b81f4cc | ||
|
|
e3cf41a666 | ||
|
|
851a307c23 | ||
|
|
183d3749f0 | ||
|
|
3fe513f9e0 | ||
|
|
81bee2bbc6 | ||
|
|
34719da000 | ||
|
|
df8a3d9c60 | ||
|
|
53dea9b069 | ||
|
|
186bae2bd4 | ||
|
|
f83c8828f0 | ||
|
|
509d064286 | ||
|
|
2d039e393a | ||
|
|
9ab88d9387 | ||
|
|
882a2a0e52 | ||
|
|
c6ce1d8c67 | ||
|
|
77e1a2e4be | ||
|
|
b99f53fda3 | ||
|
|
a7f64cf7aa | ||
|
|
8ebc0f2b24 | ||
|
|
5330dc34bc | ||
|
|
4854a9e320 | ||
|
|
71be1a9e28 | ||
|
|
d0ae09c7e2 | ||
|
|
a25bd06138 | ||
|
|
1b55076897 | ||
|
|
5eac7974c9 | ||
|
|
3afd6e9f51 | ||
|
|
05c107ba9c | ||
|
|
99b00daf87 | ||
|
|
8ddb99f62f | ||
|
|
47dec485e5 | ||
|
|
f191b4f35c | ||
|
|
e24e3c0612 | ||
|
|
1dfac0a8b9 | ||
|
|
f5cc151618 | ||
|
|
1ff3a61de6 | ||
|
|
81d5b651d2 | ||
|
|
ea4ed7cdd1 | ||
|
|
e30ea5206f | ||
|
|
c188f6e3cb | ||
|
|
2fb8999ac2 | ||
|
|
9c9bfc1a98 | ||
|
|
f7a87789ab | ||
|
|
7bcf02a0b4 | ||
|
|
fcd1733787 | ||
|
|
c04ec5953f | ||
|
|
63aa16b97c | ||
|
|
cafbf860be | ||
|
|
700b0bc776 | ||
|
|
98ca36e8f5 | ||
|
|
25130e3c82 | ||
|
|
dc463d1c2c | ||
|
|
89d30acbc5 | ||
|
|
be405d2311 | ||
|
|
acbe42775c | ||
|
|
42d8772dd6 | ||
|
|
81ef922f02 | ||
|
|
d6e18c8a35 | ||
|
|
4993a5c6c0 | ||
|
|
052382af89 | ||
|
|
18f7102461 | ||
|
|
ddbb2bea8a | ||
|
|
27131b43cb | ||
|
|
e8c2483432 | ||
|
|
fd495574a4 | ||
|
|
12f85b3d1f | ||
|
|
47d88bcfa7 | ||
|
|
e4dacaf0d2 | ||
|
|
2906a2d007 | ||
|
|
3000fdc33c | ||
|
|
076bde34a2 | ||
|
|
836c563c89 | ||
|
|
78c0419007 | ||
|
|
9dd5b91cea | ||
|
|
b4c8b00c0e | ||
|
|
430e72b424 | ||
|
|
135a8102f0 | ||
|
|
c9cf4ad02a | ||
|
|
3001809bc3 | ||
|
|
9e77ff328e | ||
|
|
efddcb18a3 | ||
|
|
54ff2bec90 | ||
|
|
287ed83de7 | ||
|
|
dd13924a67 | ||
|
|
a050a3b80f | ||
|
|
f1201eaebc | ||
|
|
68dd50ecbc | ||
|
|
2129cf5aa6 | ||
|
|
cf1bdcef46 | ||
|
|
7a879e2abf | ||
|
|
22878b6f89 | ||
|
|
e99064ca18 | ||
|
|
b93661508e | ||
|
|
27ade6c420 | ||
|
|
473249d605 | ||
|
|
62cf65ce0f | ||
|
|
c4f6aa2f90 | ||
|
|
9ca112c362 | ||
|
|
cdcc17ee37 | ||
|
|
4f3e1587b1 | ||
|
|
b18c92f515 | ||
|
|
3270edcf87 | ||
|
|
c0e8dd97ae | ||
|
|
3a0ae3df58 | ||
|
|
d6361dfee4 | ||
|
|
b61692b667 | ||
|
|
2815688c7e | ||
|
|
78a78a17cc | ||
|
|
e202d4e4a5 | ||
|
|
8b585db238 | ||
|
|
e288549c9e | ||
|
|
f71f129e3b | ||
|
|
ee688166ab | ||
|
|
ed66c37de2 | ||
|
|
a5c6f8023b | ||
|
|
c82da8c9c8 | ||
|
|
07d1358e08 | ||
|
|
1212109c03 | ||
|
|
d4db4fcac3 | ||
|
|
1f46c79396 | ||
|
|
199419ae62 | ||
|
|
39a4d55866 | ||
|
|
c84e1d0f0e | ||
|
|
302deeb122 | ||
|
|
b2a6cdec4e | ||
|
|
87676fad4d | ||
|
|
75087095b1 | ||
|
|
d0a5032723 | ||
|
|
2d6a7c2cf7 | ||
|
|
56e9158dee | ||
|
|
3ba312116b | ||
|
|
e6ab3ddb7d | ||
|
|
8ed0fec364 | ||
|
|
ddfdbd75b8 | ||
|
|
00e21af5bb | ||
|
|
51a17a7a0f | ||
|
|
fa58672f09 | ||
|
|
4f7f5023df | ||
|
|
4838a9690e | ||
|
|
edcbfb52eb | ||
|
|
5af8bb7c8e | ||
|
|
3fa835d74c | ||
|
|
035ff3e1ea | ||
|
|
2c54237fe5 | ||
|
|
00c61204a4 | ||
|
|
284aa3a444 | ||
|
|
f0b7a27fd4 | ||
|
|
a781eea10e | ||
|
|
8e42e5bdba | ||
|
|
ad4a9eeaa5 | ||
|
|
190e6b3958 | ||
|
|
8a33223483 | ||
|
|
0e4eab1569 | ||
|
|
9d6e27c85c | ||
|
|
9720f8ca16 | ||
|
|
5b3dccc1f7 | ||
|
|
e0df014acf | ||
|
|
de3d433ead | ||
|
|
3407db3dd6 | ||
|
|
b10a40ff8d | ||
|
|
ec22623f1c | ||
|
|
7e8fb16507 | ||
|
|
a634d7c361 | ||
|
|
aae77a7983 | ||
|
|
3f6f34e7e1 | ||
|
|
eff1541ba3 | ||
|
|
e7e06c89e1 | ||
|
|
a41d5b1609 | ||
|
|
edbea633f3 | ||
|
|
950af5375c | ||
|
|
c6d2e32f05 | ||
|
|
3796ce4d86 | ||
|
|
ffb67f4014 | ||
|
|
d479686804 | ||
|
|
1387f47a79 | ||
|
|
65784896e1 | ||
|
|
e692e7c119 | ||
|
|
23d4628d88 | ||
|
|
38c335c339 | ||
|
|
e69d1b5a82 | ||
|
|
6695b918ea | ||
|
|
2b9072417b | ||
|
|
6cf2224146 | ||
|
|
a1f74729ab | ||
|
|
71443d1c9a | ||
|
|
a83f5deaac | ||
|
|
234e778e8f | ||
|
|
0bdeaeb4e2 | ||
|
|
cc37713a66 | ||
|
|
6129de31f0 | ||
|
|
0908f86714 | ||
|
|
31ed79fe43 | ||
|
|
1af2ad12bf | ||
|
|
44db6d9e44 | ||
|
|
6e662fe4d6 | ||
|
|
067ff4f8ed | ||
|
|
91cf3d4def | ||
|
|
1eb846a93a | ||
|
|
56661afc05 | ||
|
|
655971208f | ||
|
|
d3ab2d3fbc | ||
|
|
65aca6607e | ||
|
|
e44eb39046 | ||
|
|
ab7d2a4bcc | ||
|
|
87c744b88b | ||
|
|
dfc4b1564f | ||
|
|
db6e99f885 | ||
|
|
35681e3adf | ||
|
|
a5ca531aac | ||
|
|
2daf895d00 | ||
|
|
1041445a22 | ||
|
|
f712bc9294 | ||
|
|
2d174d0b14 | ||
|
|
dd54f6938e | ||
|
|
6e0e74a7d9 | ||
|
|
6a90696820 | ||
|
|
f9bf403fc0 | ||
|
|
0c13fb7ae4 | ||
|
|
9a113bdb44 | ||
|
|
69ef461e6d | ||
|
|
4abcf3215f | ||
|
|
4b607d6484 | ||
|
|
fe8ba57c94 | ||
|
|
de191107a9 | ||
|
|
77b8b278ea | ||
|
|
4758447370 | ||
|
|
77909577e4 | ||
|
|
1a835a2e1b | ||
|
|
8d0330675a | ||
|
|
95a9d7a229 | ||
|
|
2fed46e222 | ||
|
|
9ad070871a | ||
|
|
b95fb48a16 | ||
|
|
29462005b7 | ||
|
|
4de05629ee | ||
|
|
2b62411a78 | ||
|
|
6fa4c7e138 | ||
|
|
ece38a6dbf | ||
|
|
a592488f3e | ||
|
|
191675cc79 | ||
|
|
df2e5bf39f | ||
|
|
ac29faf3bb | ||
|
|
94eabf6220 | ||
|
|
40bc0cbd48 | ||
|
|
b55e9df70a | ||
|
|
986d2cc42a | ||
|
|
0b8bfd9ed8 | ||
|
|
eff0c610e2 | ||
|
|
ca97e67511 | ||
|
|
47c2dce26d | ||
|
|
619163d40e | ||
|
|
b11c13fb9f | ||
|
|
a5435b7d8c | ||
|
|
b5fb829468 | ||
|
|
43fceaf3a4 | ||
|
|
8cb8395a24 | ||
|
|
2a2be51b8f | ||
|
|
5a5d65134e | ||
|
|
0a96f4e145 | ||
|
|
ba21713329 | ||
|
|
32ef925a79 | ||
|
|
c62c778c88 | ||
|
|
2f0a6fdb67 | ||
|
|
70ec13e10b | ||
|
|
3693e3600c | ||
|
|
69debc6777 | ||
|
|
84d7488061 | ||
|
|
fbb7c84409 | ||
|
|
a7379c88f4 | ||
|
|
cc8977b83d | ||
|
|
50380bc6c5 | ||
|
|
92074f0d3c | ||
|
|
1e889c4d07 | ||
|
|
617a09d89a | ||
|
|
2af409f54d | ||
|
|
6d3766e913 | ||
|
|
9b130f099f | ||
|
|
20414e6ef4 | ||
|
|
78645169bf | ||
|
|
a276e7e379 | ||
|
|
1dfde64ac2 | ||
|
|
1fa27f2d19 | ||
|
|
2822006d01 | ||
|
|
288e63f0d8 | ||
|
|
66c9187c95 | ||
|
|
cbf8687e3d | ||
|
|
c9a80caff5 | ||
|
|
f9857235fc | ||
|
|
c595a276a0 | ||
|
|
b582cd230e | ||
|
|
ad6c04489c | ||
|
|
ec7e59eda1 | ||
|
|
d929323e93 | ||
|
|
5a96b283f6 | ||
|
|
d393e4a019 | ||
|
|
9700e46e47 | ||
|
|
036c0034c3 | ||
|
|
f5067b058c | ||
|
|
0d9b247da1 | ||
|
|
a2b75e0d7a | ||
|
|
c9165a565b | ||
|
|
49d8b96768 | ||
|
|
5ad6eb937b | ||
|
|
f66e023ea8 | ||
|
|
72f1538ac2 | ||
|
|
4e24095d8b | ||
|
|
1473eabc7c | ||
|
|
11fd888ed8 | ||
|
|
8c78588ee1 | ||
|
|
c74e212494 | ||
|
|
13f96cdcc9 | ||
|
|
86e32035d7 | ||
|
|
80274596df | ||
|
|
2cc5e776b3 | ||
|
|
57a3b0fd1e | ||
|
|
9414874e1d | ||
|
|
9e46820c57 | ||
|
|
3020990121 | ||
|
|
27219e0f58 | ||
|
|
098441f5fb | ||
|
|
a07ca86207 | ||
|
|
e4e3760b3d | ||
|
|
811147d08e | ||
|
|
a563cfd0f2 | ||
|
|
92f7445bb9 | ||
|
|
a72d858034 | ||
|
|
39d45e9e0a | ||
|
|
4fae9039c1 | ||
|
|
124db3da8e | ||
|
|
4bf4091ef7 | ||
|
|
b7fa1d4f02 | ||
|
|
f1c2afacc4 | ||
|
|
8aed0e75df | ||
|
|
cf2619613d | ||
|
|
2a9d39f201 | ||
|
|
ae0b8eb3b3 | ||
|
|
63081c94a1 | ||
|
|
c39926dd72 | ||
|
|
4683e7e9c9 | ||
|
|
dc9163f801 | ||
|
|
42cc699263 | ||
|
|
37457fcb33 | ||
|
|
441dc41715 | ||
|
|
811f156ad1 | ||
|
|
2a0e9d31e1 | ||
|
|
c473cd7213 | ||
|
|
1af8aacd1d | ||
|
|
5eb9acd8b6 | ||
|
|
6bc9eb950f | ||
|
|
593c884f14 | ||
|
|
9d20de068c | ||
|
|
96c2e4d3ab | ||
|
|
165d2ea978 | ||
|
|
0702272097 | ||
|
|
965c8ccfd2 | ||
|
|
b20a49b018 |
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
|
.*
|
||||||
|
*~
|
||||||
Makefile
|
Makefile
|
||||||
INSTALL
|
|
||||||
SimGear.spec
|
|
||||||
*.o
|
*.o
|
||||||
lib*.a
|
lib*.a
|
||||||
.*.swp
|
.*.swp
|
||||||
@@ -12,5 +12,5 @@ CPackSourceConfig.cmake
|
|||||||
cmake_uninstall.cmake
|
cmake_uninstall.cmake
|
||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
build
|
build*
|
||||||
Build
|
Build
|
||||||
|
|||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
if (NOT SYSTEM_EXPAT)
|
||||||
|
add_subdirectory(expat)
|
||||||
|
endif()
|
||||||
|
|
||||||
Vendored
+33
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
configure_file (
|
||||||
|
"${PROJECT_SOURCE_DIR}/3rdparty/expat/expat_config_cmake.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/3rdparty/expat/expat_config.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(expat_sources
|
||||||
|
asciitab.h
|
||||||
|
hashtable.h
|
||||||
|
iasciitab.h
|
||||||
|
latin1tab.h
|
||||||
|
nametab.h
|
||||||
|
utf8tab.h
|
||||||
|
xmldef.h
|
||||||
|
xmlparse.h
|
||||||
|
xmlrole.h
|
||||||
|
xmltok.h
|
||||||
|
xmltok_impl.h
|
||||||
|
hashtable.c
|
||||||
|
xmlparse.c
|
||||||
|
xmlrole.c
|
||||||
|
xmltok.c
|
||||||
|
internal.h
|
||||||
|
ascii.h
|
||||||
|
sg_expat.h
|
||||||
|
sg_expat_external.h
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(s ${expat_sources})
|
||||||
|
set_property(GLOBAL
|
||||||
|
APPEND PROPERTY LOCAL_EXPAT_SOURCES
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${s}")
|
||||||
|
endforeach()
|
||||||
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||||
|
and Clark Cooper
|
||||||
|
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
Vendored
+92
@@ -0,0 +1,92 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ASCII_A 0x41
|
||||||
|
#define ASCII_B 0x42
|
||||||
|
#define ASCII_C 0x43
|
||||||
|
#define ASCII_D 0x44
|
||||||
|
#define ASCII_E 0x45
|
||||||
|
#define ASCII_F 0x46
|
||||||
|
#define ASCII_G 0x47
|
||||||
|
#define ASCII_H 0x48
|
||||||
|
#define ASCII_I 0x49
|
||||||
|
#define ASCII_J 0x4A
|
||||||
|
#define ASCII_K 0x4B
|
||||||
|
#define ASCII_L 0x4C
|
||||||
|
#define ASCII_M 0x4D
|
||||||
|
#define ASCII_N 0x4E
|
||||||
|
#define ASCII_O 0x4F
|
||||||
|
#define ASCII_P 0x50
|
||||||
|
#define ASCII_Q 0x51
|
||||||
|
#define ASCII_R 0x52
|
||||||
|
#define ASCII_S 0x53
|
||||||
|
#define ASCII_T 0x54
|
||||||
|
#define ASCII_U 0x55
|
||||||
|
#define ASCII_V 0x56
|
||||||
|
#define ASCII_W 0x57
|
||||||
|
#define ASCII_X 0x58
|
||||||
|
#define ASCII_Y 0x59
|
||||||
|
#define ASCII_Z 0x5A
|
||||||
|
|
||||||
|
#define ASCII_a 0x61
|
||||||
|
#define ASCII_b 0x62
|
||||||
|
#define ASCII_c 0x63
|
||||||
|
#define ASCII_d 0x64
|
||||||
|
#define ASCII_e 0x65
|
||||||
|
#define ASCII_f 0x66
|
||||||
|
#define ASCII_g 0x67
|
||||||
|
#define ASCII_h 0x68
|
||||||
|
#define ASCII_i 0x69
|
||||||
|
#define ASCII_j 0x6A
|
||||||
|
#define ASCII_k 0x6B
|
||||||
|
#define ASCII_l 0x6C
|
||||||
|
#define ASCII_m 0x6D
|
||||||
|
#define ASCII_n 0x6E
|
||||||
|
#define ASCII_o 0x6F
|
||||||
|
#define ASCII_p 0x70
|
||||||
|
#define ASCII_q 0x71
|
||||||
|
#define ASCII_r 0x72
|
||||||
|
#define ASCII_s 0x73
|
||||||
|
#define ASCII_t 0x74
|
||||||
|
#define ASCII_u 0x75
|
||||||
|
#define ASCII_v 0x76
|
||||||
|
#define ASCII_w 0x77
|
||||||
|
#define ASCII_x 0x78
|
||||||
|
#define ASCII_y 0x79
|
||||||
|
#define ASCII_z 0x7A
|
||||||
|
|
||||||
|
#define ASCII_0 0x30
|
||||||
|
#define ASCII_1 0x31
|
||||||
|
#define ASCII_2 0x32
|
||||||
|
#define ASCII_3 0x33
|
||||||
|
#define ASCII_4 0x34
|
||||||
|
#define ASCII_5 0x35
|
||||||
|
#define ASCII_6 0x36
|
||||||
|
#define ASCII_7 0x37
|
||||||
|
#define ASCII_8 0x38
|
||||||
|
#define ASCII_9 0x39
|
||||||
|
|
||||||
|
#define ASCII_TAB 0x09
|
||||||
|
#define ASCII_SPACE 0x20
|
||||||
|
#define ASCII_EXCL 0x21
|
||||||
|
#define ASCII_QUOT 0x22
|
||||||
|
#define ASCII_AMP 0x26
|
||||||
|
#define ASCII_APOS 0x27
|
||||||
|
#define ASCII_MINUS 0x2D
|
||||||
|
#define ASCII_PERIOD 0x2E
|
||||||
|
#define ASCII_COLON 0x3A
|
||||||
|
#define ASCII_SEMI 0x3B
|
||||||
|
#define ASCII_LT 0x3C
|
||||||
|
#define ASCII_EQUALS 0x3D
|
||||||
|
#define ASCII_GT 0x3E
|
||||||
|
#define ASCII_LSQB 0x5B
|
||||||
|
#define ASCII_RSQB 0x5D
|
||||||
|
#define ASCII_UNDERSCORE 0x5F
|
||||||
|
#define ASCII_LPAREN 0x28
|
||||||
|
#define ASCII_RPAREN 0x29
|
||||||
|
#define ASCII_FF 0x0C
|
||||||
|
#define ASCII_SLASH 0x2F
|
||||||
|
#define ASCII_HASH 0x23
|
||||||
|
#define ASCII_PIPE 0x7C
|
||||||
|
#define ASCII_COMMA 0x2C
|
||||||
Vendored
+41
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
#ifndef EXPAT_CONFIG_H
|
||||||
|
#define EXPAT_CONFIG_H
|
||||||
|
|
||||||
|
#cmakedefine HAVE_WINDOWS_H
|
||||||
|
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
|
||||||
|
#define BYTEORDER 1234
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `bcopy' function. */
|
||||||
|
#cmakedefine HAVE_BCOPY
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
|
#define HAVE_MEMMOVE
|
||||||
|
|
||||||
|
/* Define to 1 if you have a working `mmap' system call. */
|
||||||
|
#cmakedefine HAVE_MMAP
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#cmakedefine HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* whether byteorder is bigendian */
|
||||||
|
#undef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
/* Define to specify how much context to retain around the current parse
|
||||||
|
point. */
|
||||||
|
#define XML_CONTEXT_BYTES 1024
|
||||||
|
|
||||||
|
/* Define to make parameter entity parsing functionality available. */
|
||||||
|
#define XML_DTD
|
||||||
|
|
||||||
|
/* Define to make XML Namespaces functionality available. */
|
||||||
|
#define XML_NS
|
||||||
|
|
||||||
|
#endif /* ifndef EXPAT_CONFIG_H */
|
||||||
Vendored
+73
@@ -0,0 +1,73 @@
|
|||||||
|
/* internal.h
|
||||||
|
|
||||||
|
Internal definitions used by Expat. This is not needed to compile
|
||||||
|
client code.
|
||||||
|
|
||||||
|
The following calling convention macros are defined for frequently
|
||||||
|
called functions:
|
||||||
|
|
||||||
|
FASTCALL - Used for those internal functions that have a simple
|
||||||
|
body and a low number of arguments and local variables.
|
||||||
|
|
||||||
|
PTRCALL - Used for functions called though function pointers.
|
||||||
|
|
||||||
|
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
|
||||||
|
|
||||||
|
inline - Used for selected internal functions for which inlining
|
||||||
|
may improve performance on some platforms.
|
||||||
|
|
||||||
|
Note: Use of these macros is based on judgement, not hard rules,
|
||||||
|
and therefore subject to change.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
|
||||||
|
/* We'll use this version by default only where we know it helps.
|
||||||
|
|
||||||
|
regparm() generates warnings on Solaris boxes. See SF bug #692878.
|
||||||
|
|
||||||
|
Instability reported with egcs on a RedHat Linux 7.3.
|
||||||
|
Let's comment out:
|
||||||
|
#define FASTCALL __attribute__((stdcall, regparm(3)))
|
||||||
|
and let's try this:
|
||||||
|
*/
|
||||||
|
#define FASTCALL __attribute__((regparm(3)))
|
||||||
|
#define PTRFASTCALL __attribute__((regparm(3)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Using __fastcall seems to have an unexpected negative effect under
|
||||||
|
MS VC++, especially for function pointers, so we won't use it for
|
||||||
|
now on that platform. It may be reconsidered for a future release
|
||||||
|
if it can be made more effective.
|
||||||
|
Likely reason: __fastcall on Windows is like stdcall, therefore
|
||||||
|
the compiler cannot perform stack optimizations for call clusters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Make sure all of these are defined if they aren't already. */
|
||||||
|
|
||||||
|
#ifndef FASTCALL
|
||||||
|
#define FASTCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PTRCALL
|
||||||
|
#define PTRCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PTRFASTCALL
|
||||||
|
#define PTRFASTCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XML_MIN_SIZE
|
||||||
|
#if !defined(__cplusplus) && !defined(inline)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define inline __inline
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
#endif
|
||||||
|
#endif /* XML_MIN_SIZE */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define inline inline
|
||||||
|
#else
|
||||||
|
#ifndef inline
|
||||||
|
#define inline
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
Vendored
+1047
File diff suppressed because it is too large
Load Diff
Vendored
+115
@@ -0,0 +1,115 @@
|
|||||||
|
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Expat_External_INCLUDED
|
||||||
|
#define Expat_External_INCLUDED 1
|
||||||
|
|
||||||
|
/* External API definitions */
|
||||||
|
|
||||||
|
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||||
|
#define XML_USE_MSC_EXTENSIONS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Expat tries very hard to make the API boundary very specifically
|
||||||
|
defined. There are two macros defined to control this boundary;
|
||||||
|
each of these can be defined before including this header to
|
||||||
|
achieve some different behavior, but doing so it not recommended or
|
||||||
|
tested frequently.
|
||||||
|
|
||||||
|
XMLCALL - The calling convention to use for all calls across the
|
||||||
|
"library boundary." This will default to cdecl, and
|
||||||
|
try really hard to tell the compiler that's what we
|
||||||
|
want.
|
||||||
|
|
||||||
|
XMLIMPORT - Whatever magic is needed to note that a function is
|
||||||
|
to be imported from a dynamically loaded library
|
||||||
|
(.dll, .so, or .sl, depending on your platform).
|
||||||
|
|
||||||
|
The XMLCALL macro was added in Expat 1.95.7. The only one which is
|
||||||
|
expected to be directly useful in client code is XMLCALL.
|
||||||
|
|
||||||
|
Note that on at least some Unix versions, the Expat library must be
|
||||||
|
compiled with the cdecl calling convention as the default since
|
||||||
|
system headers may assume the cdecl convention.
|
||||||
|
*/
|
||||||
|
#ifndef XMLCALL
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define XMLCALL __cdecl
|
||||||
|
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
|
||||||
|
#define XMLCALL __attribute__((cdecl))
|
||||||
|
#else
|
||||||
|
/* For any platform which uses this definition and supports more than
|
||||||
|
one calling convention, we need to extend this definition to
|
||||||
|
declare the convention used on that platform, if it's possible to
|
||||||
|
do so.
|
||||||
|
|
||||||
|
If this is the case for your platform, please file a bug report
|
||||||
|
with information on how to identify your platform via the C
|
||||||
|
pre-processor and how to specify the same calling convention as the
|
||||||
|
platform's malloc() implementation.
|
||||||
|
*/
|
||||||
|
#define XMLCALL
|
||||||
|
#endif
|
||||||
|
#endif /* not defined XMLCALL */
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
|
||||||
|
#ifndef XML_BUILDING_EXPAT
|
||||||
|
/* using Expat from an application */
|
||||||
|
|
||||||
|
#ifdef XML_USE_MSC_EXTENSIONS
|
||||||
|
#define XMLIMPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif /* not defined XML_STATIC */
|
||||||
|
|
||||||
|
|
||||||
|
/* If we didn't define it above, define it away: */
|
||||||
|
#ifndef XMLIMPORT
|
||||||
|
#define XMLIMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef XML_UNICODE_WCHAR_T
|
||||||
|
#define XML_UNICODE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||||
|
#ifdef XML_UNICODE_WCHAR_T
|
||||||
|
typedef wchar_t XML_Char;
|
||||||
|
typedef wchar_t XML_LChar;
|
||||||
|
#else
|
||||||
|
typedef unsigned short XML_Char;
|
||||||
|
typedef char XML_LChar;
|
||||||
|
#endif /* XML_UNICODE_WCHAR_T */
|
||||||
|
#else /* Information is UTF-8 encoded. */
|
||||||
|
typedef char XML_Char;
|
||||||
|
typedef char XML_LChar;
|
||||||
|
#endif /* XML_UNICODE */
|
||||||
|
|
||||||
|
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||||
|
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
|
||||||
|
typedef __int64 XML_Index;
|
||||||
|
typedef unsigned __int64 XML_Size;
|
||||||
|
#else
|
||||||
|
typedef long long XML_Index;
|
||||||
|
typedef unsigned long long XML_Size;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
typedef long XML_Index;
|
||||||
|
typedef unsigned long XML_Size;
|
||||||
|
#endif /* XML_LARGE_SIZE */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* not Expat_External_INCLUDED */
|
||||||
Vendored
+6403
File diff suppressed because it is too large
Load Diff
Vendored
+1336
File diff suppressed because it is too large
Load Diff
+33
-30
@@ -1,36 +1,16 @@
|
|||||||
/*
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
The contents of this file are subject to the Mozilla Public License
|
See the file COPYING for copying permission.
|
||||||
Version 1.1 (the "License"); you may not use this file except in
|
|
||||||
compliance with the License. You may obtain a copy of the License at
|
|
||||||
http://www.mozilla.org/MPL/
|
|
||||||
|
|
||||||
Software distributed under the License is distributed on an "AS IS"
|
|
||||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
||||||
License for the specific language governing rights and limitations
|
|
||||||
under the License.
|
|
||||||
|
|
||||||
The Original Code is expat.
|
|
||||||
|
|
||||||
The Initial Developer of the Original Code is James Clark.
|
|
||||||
Portions created by James Clark are Copyright (C) 1998, 1999
|
|
||||||
James Clark. All Rights Reserved.
|
|
||||||
|
|
||||||
Contributor(s):
|
|
||||||
|
|
||||||
Alternatively, the contents of this file may be used under the terms
|
|
||||||
of the GNU General Public License (the "GPL"), in which case the
|
|
||||||
provisions of the GPL are applicable instead of those above. If you
|
|
||||||
wish to allow use of your version of this file only under the terms of
|
|
||||||
the GPL and not to allow others to use your version of this file under
|
|
||||||
the MPL, indicate your decision by deleting the provisions above and
|
|
||||||
replace them with the notice and other provisions required by the
|
|
||||||
GPL. If you do not delete the provisions above, a recipient may use
|
|
||||||
your version of this file under either the MPL or the GPL.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef XmlRole_INCLUDED
|
#ifndef XmlRole_INCLUDED
|
||||||
#define XmlRole_INCLUDED 1
|
#define XmlRole_INCLUDED 1
|
||||||
|
|
||||||
|
#ifdef __VMS
|
||||||
|
/* 0 1 2 3 0 1 2 3
|
||||||
|
1234567890123456789012345678901 1234567890123456789012345678901 */
|
||||||
|
#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xmltok.h"
|
#include "xmltok.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -42,16 +22,21 @@ enum {
|
|||||||
XML_ROLE_NONE = 0,
|
XML_ROLE_NONE = 0,
|
||||||
XML_ROLE_XML_DECL,
|
XML_ROLE_XML_DECL,
|
||||||
XML_ROLE_INSTANCE_START,
|
XML_ROLE_INSTANCE_START,
|
||||||
|
XML_ROLE_DOCTYPE_NONE,
|
||||||
XML_ROLE_DOCTYPE_NAME,
|
XML_ROLE_DOCTYPE_NAME,
|
||||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||||
|
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
|
||||||
XML_ROLE_DOCTYPE_CLOSE,
|
XML_ROLE_DOCTYPE_CLOSE,
|
||||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||||
XML_ROLE_PARAM_ENTITY_NAME,
|
XML_ROLE_PARAM_ENTITY_NAME,
|
||||||
|
XML_ROLE_ENTITY_NONE,
|
||||||
XML_ROLE_ENTITY_VALUE,
|
XML_ROLE_ENTITY_VALUE,
|
||||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||||
|
XML_ROLE_ENTITY_COMPLETE,
|
||||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||||
|
XML_ROLE_NOTATION_NONE,
|
||||||
XML_ROLE_NOTATION_NAME,
|
XML_ROLE_NOTATION_NAME,
|
||||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||||
@@ -67,11 +52,13 @@ enum {
|
|||||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||||
|
XML_ROLE_ATTLIST_NONE,
|
||||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||||
|
XML_ROLE_ELEMENT_NONE,
|
||||||
XML_ROLE_ELEMENT_NAME,
|
XML_ROLE_ELEMENT_NAME,
|
||||||
XML_ROLE_CONTENT_ANY,
|
XML_ROLE_CONTENT_ANY,
|
||||||
XML_ROLE_CONTENT_EMPTY,
|
XML_ROLE_CONTENT_EMPTY,
|
||||||
@@ -87,19 +74,35 @@ enum {
|
|||||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||||
|
XML_ROLE_PI,
|
||||||
|
XML_ROLE_COMMENT,
|
||||||
|
#ifdef XML_DTD
|
||||||
|
XML_ROLE_TEXT_DECL,
|
||||||
|
XML_ROLE_IGNORE_SECT,
|
||||||
|
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
||||||
|
#endif /* XML_DTD */
|
||||||
XML_ROLE_PARAM_ENTITY_REF
|
XML_ROLE_PARAM_ENTITY_REF
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct prolog_state {
|
typedef struct prolog_state {
|
||||||
int (*handler)(struct prolog_state *state,
|
int (PTRCALL *handler) (struct prolog_state *state,
|
||||||
int tok,
|
int tok,
|
||||||
const char *ptr,
|
const char *ptr,
|
||||||
const char *end,
|
const char *end,
|
||||||
const ENCODING *enc);
|
const ENCODING *enc);
|
||||||
unsigned level;
|
unsigned level;
|
||||||
|
int role_none;
|
||||||
|
#ifdef XML_DTD
|
||||||
|
unsigned includeLevel;
|
||||||
|
int documentEntity;
|
||||||
|
int inEntityValue;
|
||||||
|
#endif /* XML_DTD */
|
||||||
} PROLOG_STATE;
|
} PROLOG_STATE;
|
||||||
|
|
||||||
void XMLTOKAPI XmlPrologStateInit(PROLOG_STATE *);
|
void XmlPrologStateInit(PROLOG_STATE *);
|
||||||
|
#ifdef XML_DTD
|
||||||
|
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||||
(((state)->handler)(state, tok, ptr, end, enc))
|
(((state)->handler)(state, tok, ptr, end, enc))
|
||||||
+384
-264
File diff suppressed because it is too large
Load Diff
Vendored
+316
@@ -0,0 +1,316 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XmlTok_INCLUDED
|
||||||
|
#define XmlTok_INCLUDED 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following token may be returned by XmlContentTok */
|
||||||
|
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be
|
||||||
|
start of illegal ]]> sequence */
|
||||||
|
/* The following tokens may be returned by both XmlPrologTok and
|
||||||
|
XmlContentTok.
|
||||||
|
*/
|
||||||
|
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
|
||||||
|
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
|
||||||
|
might be part of CRLF sequence */
|
||||||
|
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||||
|
#define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||||
|
#define XML_TOK_INVALID 0
|
||||||
|
|
||||||
|
/* The following tokens are returned by XmlContentTok; some are also
|
||||||
|
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
|
||||||
|
*/
|
||||||
|
#define XML_TOK_START_TAG_WITH_ATTS 1
|
||||||
|
#define XML_TOK_START_TAG_NO_ATTS 2
|
||||||
|
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||||
|
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||||
|
#define XML_TOK_END_TAG 5
|
||||||
|
#define XML_TOK_DATA_CHARS 6
|
||||||
|
#define XML_TOK_DATA_NEWLINE 7
|
||||||
|
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||||
|
#define XML_TOK_ENTITY_REF 9
|
||||||
|
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||||
|
|
||||||
|
/* The following tokens may be returned by both XmlPrologTok and
|
||||||
|
XmlContentTok.
|
||||||
|
*/
|
||||||
|
#define XML_TOK_PI 11 /* processing instruction */
|
||||||
|
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||||
|
#define XML_TOK_COMMENT 13
|
||||||
|
#define XML_TOK_BOM 14 /* Byte order mark */
|
||||||
|
|
||||||
|
/* The following tokens are returned only by XmlPrologTok */
|
||||||
|
#define XML_TOK_PROLOG_S 15
|
||||||
|
#define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||||
|
#define XML_TOK_DECL_CLOSE 17 /* > */
|
||||||
|
#define XML_TOK_NAME 18
|
||||||
|
#define XML_TOK_NMTOKEN 19
|
||||||
|
#define XML_TOK_POUND_NAME 20 /* #name */
|
||||||
|
#define XML_TOK_OR 21 /* | */
|
||||||
|
#define XML_TOK_PERCENT 22
|
||||||
|
#define XML_TOK_OPEN_PAREN 23
|
||||||
|
#define XML_TOK_CLOSE_PAREN 24
|
||||||
|
#define XML_TOK_OPEN_BRACKET 25
|
||||||
|
#define XML_TOK_CLOSE_BRACKET 26
|
||||||
|
#define XML_TOK_LITERAL 27
|
||||||
|
#define XML_TOK_PARAM_ENTITY_REF 28
|
||||||
|
#define XML_TOK_INSTANCE_START 29
|
||||||
|
|
||||||
|
/* The following occur only in element type declarations */
|
||||||
|
#define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||||
|
#define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||||
|
#define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||||
|
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||||
|
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||||
|
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||||
|
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||||
|
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||||
|
#define XML_TOK_COMMA 38
|
||||||
|
|
||||||
|
/* The following token is returned only by XmlAttributeValueTok */
|
||||||
|
#define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||||
|
|
||||||
|
/* The following token is returned only by XmlCdataSectionTok */
|
||||||
|
#define XML_TOK_CDATA_SECT_CLOSE 40
|
||||||
|
|
||||||
|
/* With namespace processing this is returned by XmlPrologTok for a
|
||||||
|
name with a colon.
|
||||||
|
*/
|
||||||
|
#define XML_TOK_PREFIXED_NAME 41
|
||||||
|
|
||||||
|
#ifdef XML_DTD
|
||||||
|
#define XML_TOK_IGNORE_SECT 42
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
#ifdef XML_DTD
|
||||||
|
#define XML_N_STATES 4
|
||||||
|
#else /* not XML_DTD */
|
||||||
|
#define XML_N_STATES 3
|
||||||
|
#endif /* not XML_DTD */
|
||||||
|
|
||||||
|
#define XML_PROLOG_STATE 0
|
||||||
|
#define XML_CONTENT_STATE 1
|
||||||
|
#define XML_CDATA_SECTION_STATE 2
|
||||||
|
#ifdef XML_DTD
|
||||||
|
#define XML_IGNORE_SECTION_STATE 3
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
#define XML_N_LITERAL_TYPES 2
|
||||||
|
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||||
|
#define XML_ENTITY_VALUE_LITERAL 1
|
||||||
|
|
||||||
|
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
|
||||||
|
#define XML_UTF8_ENCODE_MAX 4
|
||||||
|
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
|
||||||
|
#define XML_UTF16_ENCODE_MAX 2
|
||||||
|
|
||||||
|
typedef struct position {
|
||||||
|
/* first line and first column are 0 not 1 */
|
||||||
|
XML_Size lineNumber;
|
||||||
|
XML_Size columnNumber;
|
||||||
|
} POSITION;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
const char *valuePtr;
|
||||||
|
const char *valueEnd;
|
||||||
|
char normalized;
|
||||||
|
} ATTRIBUTE;
|
||||||
|
|
||||||
|
struct encoding;
|
||||||
|
typedef struct encoding ENCODING;
|
||||||
|
|
||||||
|
typedef int (PTRCALL *SCANNER)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *,
|
||||||
|
const char **);
|
||||||
|
|
||||||
|
struct encoding {
|
||||||
|
SCANNER scanners[XML_N_STATES];
|
||||||
|
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||||
|
int (PTRCALL *sameName)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *);
|
||||||
|
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *,
|
||||||
|
const char *);
|
||||||
|
int (PTRFASTCALL *nameLength)(const ENCODING *, const char *);
|
||||||
|
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
|
||||||
|
int (PTRCALL *getAtts)(const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
int attsMax,
|
||||||
|
ATTRIBUTE *atts);
|
||||||
|
int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||||
|
int (PTRCALL *predefinedEntityName)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *);
|
||||||
|
void (PTRCALL *updatePosition)(const ENCODING *,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
POSITION *);
|
||||||
|
int (PTRCALL *isPublicId)(const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const char **badPtr);
|
||||||
|
void (PTRCALL *utf8Convert)(const ENCODING *enc,
|
||||||
|
const char **fromP,
|
||||||
|
const char *fromLim,
|
||||||
|
char **toP,
|
||||||
|
const char *toLim);
|
||||||
|
void (PTRCALL *utf16Convert)(const ENCODING *enc,
|
||||||
|
const char **fromP,
|
||||||
|
const char *fromLim,
|
||||||
|
unsigned short **toP,
|
||||||
|
const unsigned short *toLim);
|
||||||
|
int minBytesPerChar;
|
||||||
|
char isUtf8;
|
||||||
|
char isUtf16;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Scan the string starting at ptr until the end of the next complete
|
||||||
|
token, but do not scan past eptr. Return an integer giving the
|
||||||
|
type of token.
|
||||||
|
|
||||||
|
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||||
|
|
||||||
|
Return XML_TOK_PARTIAL when the string does not contain a complete
|
||||||
|
token; nextTokPtr will not be set.
|
||||||
|
|
||||||
|
Return XML_TOK_INVALID when the string does not start a valid
|
||||||
|
token; nextTokPtr will be set to point to the character which made
|
||||||
|
the token invalid.
|
||||||
|
|
||||||
|
Otherwise the string starts with a valid token; nextTokPtr will be
|
||||||
|
set to point to the character following the end of that token.
|
||||||
|
|
||||||
|
Each data character counts as a single token, but adjacent data
|
||||||
|
characters may be returned together. Similarly for characters in
|
||||||
|
the prolog outside literals, comments and processing instructions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||||
|
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||||
|
|
||||||
|
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#ifdef XML_DTD
|
||||||
|
|
||||||
|
#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
/* This is used for performing a 2nd-level tokenization on the content
|
||||||
|
of a literal that has already been returned by XmlTok.
|
||||||
|
*/
|
||||||
|
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||||
|
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||||
|
|
||||||
|
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||||
|
|
||||||
|
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||||
|
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||||
|
|
||||||
|
#define XmlNameLength(enc, ptr) \
|
||||||
|
(((enc)->nameLength)(enc, ptr))
|
||||||
|
|
||||||
|
#define XmlSkipS(enc, ptr) \
|
||||||
|
(((enc)->skipS)(enc, ptr))
|
||||||
|
|
||||||
|
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||||
|
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||||
|
|
||||||
|
#define XmlCharRefNumber(enc, ptr) \
|
||||||
|
(((enc)->charRefNumber)(enc, ptr))
|
||||||
|
|
||||||
|
#define XmlPredefinedEntityName(enc, ptr, end) \
|
||||||
|
(((enc)->predefinedEntityName)(enc, ptr, end))
|
||||||
|
|
||||||
|
#define XmlUpdatePosition(enc, ptr, end, pos) \
|
||||||
|
(((enc)->updatePosition)(enc, ptr, end, pos))
|
||||||
|
|
||||||
|
#define XmlIsPublicId(enc, ptr, end, badPtr) \
|
||||||
|
(((enc)->isPublicId)(enc, ptr, end, badPtr))
|
||||||
|
|
||||||
|
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||||
|
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||||
|
|
||||||
|
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||||
|
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ENCODING initEnc;
|
||||||
|
const ENCODING **encPtr;
|
||||||
|
} INIT_ENCODING;
|
||||||
|
|
||||||
|
int XmlParseXmlDecl(int isGeneralTextEntity,
|
||||||
|
const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const char **badPtr,
|
||||||
|
const char **versionPtr,
|
||||||
|
const char **versionEndPtr,
|
||||||
|
const char **encodingNamePtr,
|
||||||
|
const ENCODING **namedEncodingPtr,
|
||||||
|
int *standalonePtr);
|
||||||
|
|
||||||
|
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||||
|
const ENCODING *XmlGetUtf8InternalEncoding(void);
|
||||||
|
const ENCODING *XmlGetUtf16InternalEncoding(void);
|
||||||
|
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
|
||||||
|
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||||
|
int XmlSizeOfUnknownEncoding(void);
|
||||||
|
|
||||||
|
|
||||||
|
typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
|
||||||
|
|
||||||
|
ENCODING *
|
||||||
|
XmlInitUnknownEncoding(void *mem,
|
||||||
|
int *table,
|
||||||
|
CONVERTER convert,
|
||||||
|
void *userData);
|
||||||
|
|
||||||
|
int XmlParseXmlDeclNS(int isGeneralTextEntity,
|
||||||
|
const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const char **badPtr,
|
||||||
|
const char **versionPtr,
|
||||||
|
const char **versionEndPtr,
|
||||||
|
const char **encodingNamePtr,
|
||||||
|
const ENCODING **namedEncodingPtr,
|
||||||
|
int *standalonePtr);
|
||||||
|
|
||||||
|
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||||
|
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
|
||||||
|
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
|
||||||
|
ENCODING *
|
||||||
|
XmlInitUnknownEncodingNS(void *mem,
|
||||||
|
int *table,
|
||||||
|
CONVERTER convert,
|
||||||
|
void *userData);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* not XmlTok_INCLUDED */
|
||||||
+225
-188
@@ -1,33 +1,10 @@
|
|||||||
/*
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
The contents of this file are subject to the Mozilla Public License
|
See the file COPYING for copying permission.
|
||||||
Version 1.1 (the "License"); you may not use this file except in
|
|
||||||
compliance with the License. You may obtain a copy of the License at
|
|
||||||
http://www.mozilla.org/MPL/
|
|
||||||
|
|
||||||
Software distributed under the License is distributed on an "AS IS"
|
|
||||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
||||||
License for the specific language governing rights and limitations
|
|
||||||
under the License.
|
|
||||||
|
|
||||||
The Original Code is expat.
|
|
||||||
|
|
||||||
The Initial Developer of the Original Code is James Clark.
|
|
||||||
Portions created by James Clark are Copyright (C) 1998, 1999
|
|
||||||
James Clark. All Rights Reserved.
|
|
||||||
|
|
||||||
Contributor(s):
|
|
||||||
|
|
||||||
Alternatively, the contents of this file may be used under the terms
|
|
||||||
of the GNU General Public License (the "GPL"), in which case the
|
|
||||||
provisions of the GPL are applicable instead of those above. If you
|
|
||||||
wish to allow use of your version of this file only under the terms of
|
|
||||||
the GPL and not to allow others to use your version of this file under
|
|
||||||
the MPL, indicate your decision by deleting the provisions above and
|
|
||||||
replace them with the notice and other provisions required by the
|
|
||||||
GPL. If you do not delete the provisions above, a recipient may use
|
|
||||||
your version of this file under either the MPL or the GPL.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* This file is included! */
|
||||||
|
#ifdef XML_TOK_IMPL_C
|
||||||
|
|
||||||
#ifndef IS_INVALID_CHAR
|
#ifndef IS_INVALID_CHAR
|
||||||
#define IS_INVALID_CHAR(enc, ptr, n) (0)
|
#define IS_INVALID_CHAR(enc, ptr, n) (0)
|
||||||
#endif
|
#endif
|
||||||
@@ -112,12 +89,12 @@ your version of this file under either the MPL or the GPL.
|
|||||||
|
|
||||||
/* ptr points to character following "<!-" */
|
/* ptr points to character following "<!-" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanComment)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr != end) {
|
if (ptr != end) {
|
||||||
if (!CHAR_MATCHES(enc, ptr, '-')) {
|
if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
@@ -128,10 +105,10 @@ int PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
case BT_MINUS:
|
case BT_MINUS:
|
||||||
if ((ptr += MINBPC(enc)) == end)
|
if ((ptr += MINBPC(enc)) == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (CHAR_MATCHES(enc, ptr, '-')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
|
||||||
if ((ptr += MINBPC(enc)) == end)
|
if ((ptr += MINBPC(enc)) == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (!CHAR_MATCHES(enc, ptr, '>')) {
|
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
@@ -150,9 +127,9 @@ int PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
|
|
||||||
/* ptr points to character following "<!" */
|
/* ptr points to character following "<!" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
@@ -197,17 +174,18 @@ int PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, int *tokPtr)
|
PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr,
|
||||||
|
const char *end, int *tokPtr)
|
||||||
{
|
{
|
||||||
int upper = 0;
|
int upper = 0;
|
||||||
*tokPtr = XML_TOK_PI;
|
*tokPtr = XML_TOK_PI;
|
||||||
if (end - ptr != MINBPC(enc)*3)
|
if (end - ptr != MINBPC(enc)*3)
|
||||||
return 1;
|
return 1;
|
||||||
switch (BYTE_TO_ASCII(enc, ptr)) {
|
switch (BYTE_TO_ASCII(enc, ptr)) {
|
||||||
case 'x':
|
case ASCII_x:
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case ASCII_X:
|
||||||
upper = 1;
|
upper = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -215,9 +193,9 @@ int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
}
|
}
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
switch (BYTE_TO_ASCII(enc, ptr)) {
|
switch (BYTE_TO_ASCII(enc, ptr)) {
|
||||||
case 'm':
|
case ASCII_m:
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case ASCII_M:
|
||||||
upper = 1;
|
upper = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -225,9 +203,9 @@ int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
}
|
}
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
switch (BYTE_TO_ASCII(enc, ptr)) {
|
switch (BYTE_TO_ASCII(enc, ptr)) {
|
||||||
case 'l':
|
case ASCII_l:
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case ASCII_L:
|
||||||
upper = 1;
|
upper = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -241,9 +219,9 @@ int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
|
|
||||||
/* ptr points to character following "<?" */
|
/* ptr points to character following "<?" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
int tok;
|
int tok;
|
||||||
const char *target = ptr;
|
const char *target = ptr;
|
||||||
@@ -271,7 +249,7 @@ int PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (CHAR_MATCHES(enc, ptr, '>')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
*nextTokPtr = ptr + MINBPC(enc);
|
*nextTokPtr = ptr + MINBPC(enc);
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
@@ -290,7 +268,7 @@ int PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (CHAR_MATCHES(enc, ptr, '>')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
*nextTokPtr = ptr + MINBPC(enc);
|
*nextTokPtr = ptr + MINBPC(enc);
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
@@ -303,17 +281,18 @@ int PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int PTRCALL
|
||||||
static
|
PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr,
|
||||||
int PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end,
|
const char *end, const char **nextTokPtr)
|
||||||
const char **nextTokPtr)
|
|
||||||
{
|
{
|
||||||
|
static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A,
|
||||||
|
ASCII_T, ASCII_A, ASCII_LSQB };
|
||||||
int i;
|
int i;
|
||||||
/* CDATA[ */
|
/* CDATA[ */
|
||||||
if (end - ptr < 6 * MINBPC(enc))
|
if (end - ptr < 6 * MINBPC(enc))
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
|
for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
|
||||||
if (!CHAR_MATCHES(enc, ptr, "CDATA["[i])) {
|
if (!CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) {
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
@@ -322,9 +301,9 @@ int PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *e
|
|||||||
return XML_TOK_CDATA_SECT_OPEN;
|
return XML_TOK_CDATA_SECT_OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_NONE;
|
return XML_TOK_NONE;
|
||||||
@@ -342,12 +321,12 @@ int PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *en
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (!CHAR_MATCHES(enc, ptr, ']'))
|
if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
|
||||||
break;
|
break;
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (!CHAR_MATCHES(enc, ptr, '>')) {
|
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
ptr -= MINBPC(enc);
|
ptr -= MINBPC(enc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -400,9 +379,9 @@ int PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *en
|
|||||||
|
|
||||||
/* ptr points to character following "</" */
|
/* ptr points to character following "</" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
@@ -431,7 +410,8 @@ int PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
#ifdef XML_NS
|
#ifdef XML_NS
|
||||||
case BT_COLON:
|
case BT_COLON:
|
||||||
/* no need to check qname syntax here, since end-tag must match exactly */
|
/* no need to check qname syntax here,
|
||||||
|
since end-tag must match exactly */
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@@ -448,9 +428,9 @@ int PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
|
|
||||||
/* ptr points to character following "&#X" */
|
/* ptr points to character following "&#X" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr != end) {
|
if (ptr != end) {
|
||||||
switch (BYTE_TYPE(enc, ptr)) {
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
@@ -480,12 +460,12 @@ int PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end
|
|||||||
|
|
||||||
/* ptr points to character following "&#" */
|
/* ptr points to character following "&#" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr != end) {
|
if (ptr != end) {
|
||||||
if (CHAR_MATCHES(enc, ptr, 'x'))
|
if (CHAR_MATCHES(enc, ptr, ASCII_x))
|
||||||
return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
||||||
switch (BYTE_TYPE(enc, ptr)) {
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
case BT_DIGIT:
|
case BT_DIGIT:
|
||||||
@@ -512,8 +492,8 @@ int PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
|
|
||||||
/* ptr points to character following "&" */
|
/* ptr points to character following "&" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
@@ -542,8 +522,8 @@ int PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
|
|
||||||
/* ptr points to character following first character of attribute name */
|
/* ptr points to character following first character of attribute name */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
#ifdef XML_NS
|
#ifdef XML_NS
|
||||||
@@ -598,7 +578,6 @@ int PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
hadColon = 0;
|
hadColon = 0;
|
||||||
#endif
|
#endif
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
@@ -678,7 +657,7 @@ int PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (!CHAR_MATCHES(enc, ptr, '>')) {
|
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
@@ -702,8 +681,8 @@ int PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
|
|
||||||
/* ptr points to character following "<" */
|
/* ptr points to character following "<" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
#ifdef XML_NS
|
#ifdef XML_NS
|
||||||
@@ -720,7 +699,8 @@ int PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
case BT_MINUS:
|
case BT_MINUS:
|
||||||
return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
||||||
case BT_LSQB:
|
case BT_LSQB:
|
||||||
return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc),
|
||||||
|
end, nextTokPtr);
|
||||||
}
|
}
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
@@ -787,7 +767,7 @@ int PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (!CHAR_MATCHES(enc, ptr, '>')) {
|
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
@@ -801,8 +781,8 @@ int PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
@@ -836,12 +816,12 @@ int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_TRAILING_RSQB;
|
return XML_TOK_TRAILING_RSQB;
|
||||||
if (!CHAR_MATCHES(enc, ptr, ']'))
|
if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
|
||||||
break;
|
break;
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_TRAILING_RSQB;
|
return XML_TOK_TRAILING_RSQB;
|
||||||
if (!CHAR_MATCHES(enc, ptr, '>')) {
|
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
ptr -= MINBPC(enc);
|
ptr -= MINBPC(enc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -866,12 +846,12 @@ int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
#undef LEAD_CASE
|
#undef LEAD_CASE
|
||||||
case BT_RSQB:
|
case BT_RSQB:
|
||||||
if (ptr + MINBPC(enc) != end) {
|
if (ptr + MINBPC(enc) != end) {
|
||||||
if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ']')) {
|
if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ptr + 2*MINBPC(enc) != end) {
|
if (ptr + 2*MINBPC(enc) != end) {
|
||||||
if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), '>')) {
|
if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -900,8 +880,8 @@ int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
|
|
||||||
/* ptr points to character following "%" */
|
/* ptr points to character following "%" */
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
@@ -929,8 +909,8 @@ int PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
@@ -953,11 +933,11 @@ int PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return XML_TOK_PARTIAL;
|
return -XML_TOK_POUND_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(scanLit)(int open, const ENCODING *enc,
|
PREFIX(scanLit)(int open, const ENCODING *enc,
|
||||||
const char *ptr, const char *end,
|
const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
@@ -971,7 +951,7 @@ int PREFIX(scanLit)(int open, const ENCODING *enc,
|
|||||||
if (t != open)
|
if (t != open)
|
||||||
break;
|
break;
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return -XML_TOK_LITERAL;
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
switch (BYTE_TYPE(enc, ptr)) {
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
case BT_S: case BT_CR: case BT_LF:
|
case BT_S: case BT_CR: case BT_LF:
|
||||||
@@ -988,8 +968,8 @@ int PREFIX(scanLit)(int open, const ENCODING *enc,
|
|||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **nextTokPtr)
|
const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
int tok;
|
int tok;
|
||||||
@@ -1032,8 +1012,11 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
case BT_CR:
|
case BT_CR:
|
||||||
if (ptr + MINBPC(enc) == end)
|
if (ptr + MINBPC(enc) == end) {
|
||||||
return XML_TOK_TRAILING_CR;
|
*nextTokPtr = end;
|
||||||
|
/* indicate that this might be part of a CR/LF pair */
|
||||||
|
return -XML_TOK_PROLOG_S;
|
||||||
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case BT_S: case BT_LF:
|
case BT_S: case BT_LF:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -1066,11 +1049,11 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
case BT_RSQB:
|
case BT_RSQB:
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return -XML_TOK_CLOSE_BRACKET;
|
||||||
if (CHAR_MATCHES(enc, ptr, ']')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
|
||||||
if (ptr + MINBPC(enc) == end)
|
if (ptr + MINBPC(enc) == end)
|
||||||
return XML_TOK_PARTIAL;
|
return XML_TOK_PARTIAL;
|
||||||
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), '>')) {
|
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) {
|
||||||
*nextTokPtr = ptr + 2*MINBPC(enc);
|
*nextTokPtr = ptr + 2*MINBPC(enc);
|
||||||
return XML_TOK_COND_SECT_CLOSE;
|
return XML_TOK_COND_SECT_CLOSE;
|
||||||
}
|
}
|
||||||
@@ -1083,7 +1066,7 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
case BT_RPAR:
|
case BT_RPAR:
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
return XML_TOK_PARTIAL;
|
return -XML_TOK_CLOSE_PAREN;
|
||||||
switch (BYTE_TYPE(enc, ptr)) {
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
case BT_AST:
|
case BT_AST:
|
||||||
*nextTokPtr = ptr + MINBPC(enc);
|
*nextTokPtr = ptr + MINBPC(enc);
|
||||||
@@ -1213,12 +1196,12 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return XML_TOK_PARTIAL;
|
return -tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
const char *start;
|
const char *start;
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
@@ -1274,9 +1257,9 @@ int PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *
|
|||||||
return XML_TOK_DATA_CHARS;
|
return XML_TOK_DATA_CHARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
|
PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
|
||||||
const char **nextTokPtr)
|
const char *end, const char **nextTokPtr)
|
||||||
{
|
{
|
||||||
const char *start;
|
const char *start;
|
||||||
if (ptr == end)
|
if (ptr == end)
|
||||||
@@ -1294,8 +1277,11 @@ int PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end
|
|||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_DATA_CHARS;
|
return XML_TOK_DATA_CHARS;
|
||||||
case BT_PERCNT:
|
case BT_PERCNT:
|
||||||
if (ptr == start)
|
if (ptr == start) {
|
||||||
return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc),
|
||||||
|
end, nextTokPtr);
|
||||||
|
return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok;
|
||||||
|
}
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_DATA_CHARS;
|
return XML_TOK_DATA_CHARS;
|
||||||
case BT_LF:
|
case BT_LF:
|
||||||
@@ -1326,8 +1312,63 @@ int PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end
|
|||||||
return XML_TOK_DATA_CHARS;
|
return XML_TOK_DATA_CHARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
#ifdef XML_DTD
|
||||||
int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
|
||||||
|
static int PTRCALL
|
||||||
|
PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
|
||||||
|
const char *end, const char **nextTokPtr)
|
||||||
|
{
|
||||||
|
int level = 0;
|
||||||
|
if (MINBPC(enc) > 1) {
|
||||||
|
size_t n = end - ptr;
|
||||||
|
if (n & (MINBPC(enc) - 1)) {
|
||||||
|
n &= ~(MINBPC(enc) - 1);
|
||||||
|
end = ptr + n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (ptr != end) {
|
||||||
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
|
INVALID_CASES(ptr, nextTokPtr)
|
||||||
|
case BT_LT:
|
||||||
|
if ((ptr += MINBPC(enc)) == end)
|
||||||
|
return XML_TOK_PARTIAL;
|
||||||
|
if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) {
|
||||||
|
if ((ptr += MINBPC(enc)) == end)
|
||||||
|
return XML_TOK_PARTIAL;
|
||||||
|
if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) {
|
||||||
|
++level;
|
||||||
|
ptr += MINBPC(enc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BT_RSQB:
|
||||||
|
if ((ptr += MINBPC(enc)) == end)
|
||||||
|
return XML_TOK_PARTIAL;
|
||||||
|
if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
|
||||||
|
if ((ptr += MINBPC(enc)) == end)
|
||||||
|
return XML_TOK_PARTIAL;
|
||||||
|
if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||||
|
ptr += MINBPC(enc);
|
||||||
|
if (level == 0) {
|
||||||
|
*nextTokPtr = ptr;
|
||||||
|
return XML_TOK_IGNORE_SECT;
|
||||||
|
}
|
||||||
|
--level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ptr += MINBPC(enc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return XML_TOK_PARTIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
static int PTRCALL
|
||||||
|
PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
const char **badPtr)
|
const char **badPtr)
|
||||||
{
|
{
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
@@ -1357,7 +1398,7 @@ int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case BT_S:
|
case BT_S:
|
||||||
if (CHAR_MATCHES(enc, ptr, '\t')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) {
|
||||||
*badPtr = ptr;
|
*badPtr = ptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1381,17 +1422,19 @@ int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This must only be called for a well-formed start-tag or empty element tag.
|
/* This must only be called for a well-formed start-tag or empty
|
||||||
Returns the number of attributes. Pointers to the first attsMax attributes
|
element tag. Returns the number of attributes. Pointers to the
|
||||||
are stored in atts. */
|
first attsMax attributes are stored in atts.
|
||||||
|
*/
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
|
PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
|
||||||
int attsMax, ATTRIBUTE *atts)
|
int attsMax, ATTRIBUTE *atts)
|
||||||
{
|
{
|
||||||
enum { other, inName, inValue } state = inName;
|
enum { other, inName, inValue } state = inName;
|
||||||
int nAtts = 0;
|
int nAtts = 0;
|
||||||
int open = 0;
|
int open = 0; /* defined when state == inValue;
|
||||||
|
initialization just to shut up compilers */
|
||||||
|
|
||||||
for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) {
|
for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) {
|
||||||
switch (BYTE_TYPE(enc, ptr)) {
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
@@ -1452,8 +1495,8 @@ int PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
|
|||||||
&& nAtts < attsMax
|
&& nAtts < attsMax
|
||||||
&& atts[nAtts].normalized
|
&& atts[nAtts].normalized
|
||||||
&& (ptr == atts[nAtts].valuePtr
|
&& (ptr == atts[nAtts].valuePtr
|
||||||
|| BYTE_TO_ASCII(enc, ptr) != ' '
|
|| BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE
|
||||||
|| BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ' '
|
|| BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE
|
||||||
|| BYTE_TYPE(enc, ptr + MINBPC(enc)) == open))
|
|| BYTE_TYPE(enc, ptr + MINBPC(enc)) == open))
|
||||||
atts[nAtts].normalized = 0;
|
atts[nAtts].normalized = 0;
|
||||||
break;
|
break;
|
||||||
@@ -1477,28 +1520,32 @@ int PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
|
|||||||
/* not reached */
|
/* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRFASTCALL
|
||||||
int PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
|
PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
/* skip &# */
|
/* skip &# */
|
||||||
ptr += 2*MINBPC(enc);
|
ptr += 2*MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 'x')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_x)) {
|
||||||
for (ptr += MINBPC(enc); !CHAR_MATCHES(enc, ptr, ';'); ptr += MINBPC(enc)) {
|
for (ptr += MINBPC(enc);
|
||||||
|
!CHAR_MATCHES(enc, ptr, ASCII_SEMI);
|
||||||
|
ptr += MINBPC(enc)) {
|
||||||
int c = BYTE_TO_ASCII(enc, ptr);
|
int c = BYTE_TO_ASCII(enc, ptr);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4:
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9:
|
||||||
result <<= 4;
|
result <<= 4;
|
||||||
result |= (c - '0');
|
result |= (c - ASCII_0);
|
||||||
break;
|
break;
|
||||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
case ASCII_A: case ASCII_B: case ASCII_C:
|
||||||
|
case ASCII_D: case ASCII_E: case ASCII_F:
|
||||||
result <<= 4;
|
result <<= 4;
|
||||||
result += 10 + (c - 'A');
|
result += 10 + (c - ASCII_A);
|
||||||
break;
|
break;
|
||||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
case ASCII_a: case ASCII_b: case ASCII_c:
|
||||||
|
case ASCII_d: case ASCII_e: case ASCII_f:
|
||||||
result <<= 4;
|
result <<= 4;
|
||||||
result += 10 + (c - 'a');
|
result += 10 + (c - ASCII_a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result >= 0x110000)
|
if (result >= 0x110000)
|
||||||
@@ -1506,10 +1553,10 @@ int PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (; !CHAR_MATCHES(enc, ptr, ';'); ptr += MINBPC(enc)) {
|
for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) {
|
||||||
int c = BYTE_TO_ASCII(enc, ptr);
|
int c = BYTE_TO_ASCII(enc, ptr);
|
||||||
result *= 10;
|
result *= 10;
|
||||||
result += (c - '0');
|
result += (c - ASCII_0);
|
||||||
if (result >= 0x110000)
|
if (result >= 0x110000)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1517,51 +1564,52 @@ int PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
|
|||||||
return checkCharRefNumber(result);
|
return checkCharRefNumber(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const char *end)
|
PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr,
|
||||||
|
const char *end)
|
||||||
{
|
{
|
||||||
switch ((end - ptr)/MINBPC(enc)) {
|
switch ((end - ptr)/MINBPC(enc)) {
|
||||||
case 2:
|
case 2:
|
||||||
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), 't')) {
|
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) {
|
||||||
switch (BYTE_TO_ASCII(enc, ptr)) {
|
switch (BYTE_TO_ASCII(enc, ptr)) {
|
||||||
case 'l':
|
case ASCII_l:
|
||||||
return '<';
|
return ASCII_LT;
|
||||||
case 'g':
|
case ASCII_g:
|
||||||
return '>';
|
return ASCII_GT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (CHAR_MATCHES(enc, ptr, 'a')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_a)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 'm')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_m)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 'p'))
|
if (CHAR_MATCHES(enc, ptr, ASCII_p))
|
||||||
return '&';
|
return ASCII_AMP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
switch (BYTE_TO_ASCII(enc, ptr)) {
|
switch (BYTE_TO_ASCII(enc, ptr)) {
|
||||||
case 'q':
|
case ASCII_q:
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 'u')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_u)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 'o')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_o)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 't'))
|
if (CHAR_MATCHES(enc, ptr, ASCII_t))
|
||||||
return '"';
|
return ASCII_QUOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case ASCII_a:
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 'p')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_p)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 'o')) {
|
if (CHAR_MATCHES(enc, ptr, ASCII_o)) {
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (CHAR_MATCHES(enc, ptr, 's'))
|
if (CHAR_MATCHES(enc, ptr, ASCII_s))
|
||||||
return '\'';
|
return ASCII_APOS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1570,8 +1618,8 @@ int PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const cha
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (BYTE_TYPE(enc, ptr1)) {
|
switch (BYTE_TYPE(enc, ptr1)) {
|
||||||
@@ -1634,34 +1682,21 @@ int PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
|||||||
/* not reached */
|
/* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRCALL
|
||||||
int PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1,
|
||||||
|
const char *end1, const char *ptr2)
|
||||||
{
|
{
|
||||||
for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
|
for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
|
||||||
|
if (ptr1 == end1)
|
||||||
|
return 0;
|
||||||
if (!CHAR_MATCHES(enc, ptr1, *ptr2))
|
if (!CHAR_MATCHES(enc, ptr1, *ptr2))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
switch (BYTE_TYPE(enc, ptr1)) {
|
return ptr1 == end1;
|
||||||
case BT_LEAD2:
|
|
||||||
case BT_LEAD3:
|
|
||||||
case BT_LEAD4:
|
|
||||||
case BT_NONASCII:
|
|
||||||
case BT_NMSTRT:
|
|
||||||
#ifdef XML_NS
|
|
||||||
case BT_COLON:
|
|
||||||
#endif
|
|
||||||
case BT_HEX:
|
|
||||||
case BT_DIGIT:
|
|
||||||
case BT_NAME:
|
|
||||||
case BT_MINUS:
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int PTRFASTCALL
|
||||||
int PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
|
PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
|
||||||
{
|
{
|
||||||
const char *start = ptr;
|
const char *start = ptr;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -1682,13 +1717,13 @@ int PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return ptr - start;
|
return (int)(ptr - start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static const char * PTRFASTCALL
|
||||||
const char *PREFIX(skipS)(const ENCODING *enc, const char *ptr)
|
PREFIX(skipS)(const ENCODING *enc, const char *ptr)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (BYTE_TYPE(enc, ptr)) {
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
@@ -1703,13 +1738,13 @@ const char *PREFIX(skipS)(const ENCODING *enc, const char *ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void PTRCALL
|
||||||
void PREFIX(updatePosition)(const ENCODING *enc,
|
PREFIX(updatePosition)(const ENCODING *enc,
|
||||||
const char *ptr,
|
const char *ptr,
|
||||||
const char *end,
|
const char *end,
|
||||||
POSITION *pos)
|
POSITION *pos)
|
||||||
{
|
{
|
||||||
while (ptr != end) {
|
while (ptr < end) {
|
||||||
switch (BYTE_TYPE(enc, ptr)) {
|
switch (BYTE_TYPE(enc, ptr)) {
|
||||||
#define LEAD_CASE(n) \
|
#define LEAD_CASE(n) \
|
||||||
case BT_LEAD ## n: \
|
case BT_LEAD ## n: \
|
||||||
@@ -1718,7 +1753,7 @@ void PREFIX(updatePosition)(const ENCODING *enc,
|
|||||||
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
|
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
|
||||||
#undef LEAD_CASE
|
#undef LEAD_CASE
|
||||||
case BT_LF:
|
case BT_LF:
|
||||||
pos->columnNumber = (unsigned)-1;
|
pos->columnNumber = (XML_Size)-1;
|
||||||
pos->lineNumber++;
|
pos->lineNumber++;
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
break;
|
break;
|
||||||
@@ -1727,7 +1762,7 @@ void PREFIX(updatePosition)(const ENCODING *enc,
|
|||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF)
|
if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF)
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
pos->columnNumber = (unsigned)-1;
|
pos->columnNumber = (XML_Size)-1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ptr += MINBPC(enc);
|
ptr += MINBPC(enc);
|
||||||
@@ -1744,3 +1779,5 @@ void PREFIX(updatePosition)(const ENCODING *enc,
|
|||||||
#undef CHECK_NAME_CASES
|
#undef CHECK_NAME_CASES
|
||||||
#undef CHECK_NMSTRT_CASE
|
#undef CHECK_NMSTRT_CASE
|
||||||
#undef CHECK_NMSTRT_CASES
|
#undef CHECK_NMSTRT_CASES
|
||||||
|
|
||||||
|
#endif /* XML_TOK_IMPL_C */
|
||||||
Vendored
+115
@@ -0,0 +1,115 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file is included! */
|
||||||
|
#ifdef XML_TOK_NS_C
|
||||||
|
|
||||||
|
const ENCODING *
|
||||||
|
NS(XmlGetUtf8InternalEncoding)(void)
|
||||||
|
{
|
||||||
|
return &ns(internal_utf8_encoding).enc;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ENCODING *
|
||||||
|
NS(XmlGetUtf16InternalEncoding)(void)
|
||||||
|
{
|
||||||
|
#if BYTEORDER == 1234
|
||||||
|
return &ns(internal_little2_encoding).enc;
|
||||||
|
#elif BYTEORDER == 4321
|
||||||
|
return &ns(internal_big2_encoding).enc;
|
||||||
|
#else
|
||||||
|
const short n = 1;
|
||||||
|
return (*(const char *)&n
|
||||||
|
? &ns(internal_little2_encoding).enc
|
||||||
|
: &ns(internal_big2_encoding).enc);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static const ENCODING * const NS(encodings)[] = {
|
||||||
|
&ns(latin1_encoding).enc,
|
||||||
|
&ns(ascii_encoding).enc,
|
||||||
|
&ns(utf8_encoding).enc,
|
||||||
|
&ns(big2_encoding).enc,
|
||||||
|
&ns(big2_encoding).enc,
|
||||||
|
&ns(little2_encoding).enc,
|
||||||
|
&ns(utf8_encoding).enc /* NO_ENC */
|
||||||
|
};
|
||||||
|
|
||||||
|
static int PTRCALL
|
||||||
|
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
|
const char **nextTokPtr)
|
||||||
|
{
|
||||||
|
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
|
||||||
|
XML_PROLOG_STATE, ptr, end, nextTokPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int PTRCALL
|
||||||
|
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
|
const char **nextTokPtr)
|
||||||
|
{
|
||||||
|
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
|
||||||
|
XML_CONTENT_STATE, ptr, end, nextTokPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
int i = getEncodingIndex(name);
|
||||||
|
if (i == UNKNOWN_ENC)
|
||||||
|
return 0;
|
||||||
|
SET_INIT_ENC_INDEX(p, i);
|
||||||
|
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
|
||||||
|
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
|
||||||
|
p->initEnc.updatePosition = initUpdatePosition;
|
||||||
|
p->encPtr = encPtr;
|
||||||
|
*encPtr = &(p->initEnc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const ENCODING *
|
||||||
|
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
|
||||||
|
{
|
||||||
|
#define ENCODING_MAX 128
|
||||||
|
char buf[ENCODING_MAX];
|
||||||
|
char *p = buf;
|
||||||
|
int i;
|
||||||
|
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
|
||||||
|
if (ptr != end)
|
||||||
|
return 0;
|
||||||
|
*p = 0;
|
||||||
|
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
|
||||||
|
return enc;
|
||||||
|
i = getEncodingIndex(buf);
|
||||||
|
if (i == UNKNOWN_ENC)
|
||||||
|
return 0;
|
||||||
|
return NS(encodings)[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
NS(XmlParseXmlDecl)(int isGeneralTextEntity,
|
||||||
|
const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const char **badPtr,
|
||||||
|
const char **versionPtr,
|
||||||
|
const char **versionEndPtr,
|
||||||
|
const char **encodingName,
|
||||||
|
const ENCODING **encoding,
|
||||||
|
int *standalone)
|
||||||
|
{
|
||||||
|
return doParseXmlDecl(NS(findEncoding),
|
||||||
|
isGeneralTextEntity,
|
||||||
|
enc,
|
||||||
|
ptr,
|
||||||
|
end,
|
||||||
|
badPtr,
|
||||||
|
versionPtr,
|
||||||
|
versionEndPtr,
|
||||||
|
encodingName,
|
||||||
|
encoding,
|
||||||
|
standalone);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* XML_TOK_NS_C */
|
||||||
+177
-37
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6.4)
|
|||||||
include (CheckFunctionExists)
|
include (CheckFunctionExists)
|
||||||
include (CheckIncludeFile)
|
include (CheckIncludeFile)
|
||||||
include (CheckCXXSourceCompiles)
|
include (CheckCXXSourceCompiles)
|
||||||
|
include (CheckCXXCompilerFlag)
|
||||||
|
|
||||||
project(SimGear)
|
project(SimGear)
|
||||||
|
|
||||||
@@ -10,9 +10,19 @@ project(SimGear)
|
|||||||
file(READ version versionFile)
|
file(READ version versionFile)
|
||||||
string(STRIP ${versionFile} SIMGEAR_VERSION)
|
string(STRIP ${versionFile} SIMGEAR_VERSION)
|
||||||
|
|
||||||
|
set(FIND_LIBRARY_USE_LIB64_PATHS ON)
|
||||||
|
|
||||||
# use simgear version also as the SO version (if building SOs)
|
# use simgear version also as the SO version (if building SOs)
|
||||||
SET(SIMGEAR_SOVERSION ${SIMGEAR_VERSION})
|
SET(SIMGEAR_SOVERSION ${SIMGEAR_VERSION})
|
||||||
|
|
||||||
|
# Warning when build is not an out-of-source build.
|
||||||
|
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" InSourceBuild)
|
||||||
|
if(InSourceBuild)
|
||||||
|
message(WARNING "Avoid building inside the source tree!")
|
||||||
|
message(WARNING "Create a separate build directory instead (i.e. 'sgbuild') and call CMake from there: ")
|
||||||
|
message(WARNING " mkdir ../sgbuild && cd ../sgbuild && cmake ${CMAKE_SOURCE_DIR}")
|
||||||
|
endif(InSourceBuild)
|
||||||
|
|
||||||
#packaging
|
#packaging
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
|
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
|
||||||
SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
|
SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
|
||||||
@@ -60,15 +70,44 @@ else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
|
|||||||
endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
|
endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
|
||||||
message(STATUS "Library installation directory: ${CMAKE_INSTALL_LIBDIR}")
|
message(STATUS "Library installation directory: ${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
|
||||||
|
#####################################################################################
|
||||||
|
# Configure library search paths
|
||||||
|
#####################################################################################
|
||||||
|
|
||||||
|
if(NOT "${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
|
||||||
|
# Workaround for Ubuntu/Debian which introduced the "multiarch" library
|
||||||
|
# directory structure, which is unsupported by CMake < 2.8.10, so we need to
|
||||||
|
# add paths manually
|
||||||
|
# see http://www.cmake.org/Bug/view.php?id=12049 and
|
||||||
|
# http://www.cmake.org/Bug/view.php?id=12037
|
||||||
|
list(APPEND ADDITIONAL_LIBRARY_PATHS
|
||||||
|
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
|
||||||
|
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
|
||||||
|
/lib/${CMAKE_LIBRARY_ARCHITECTURE})
|
||||||
|
message(STATUS "additional library directories: ${ADDITIONAL_LIBRARY_PATHS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#####################################################################################
|
||||||
|
|
||||||
|
if (NOT MSVC)
|
||||||
option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
|
option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF)
|
||||||
|
option(SYSTEM_EXPAT "Set to ON to build SimGear using the system libExpat" OFF)
|
||||||
|
else()
|
||||||
|
# Building SimGear DLLs is currently not supported for MSVC.
|
||||||
|
set(SIMGEAR_SHARED OFF)
|
||||||
|
# Using a system expat is currently not supported for MSVC - it would require shared simgear (DLL).
|
||||||
|
set(SYSTEM_EXPAT OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support" OFF)
|
option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support" OFF)
|
||||||
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
|
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
|
||||||
option(ENABLE_LIBSVN "Set to ON to build SimGear with libsvnclient support" ON)
|
|
||||||
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
|
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
|
||||||
option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON)
|
option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON)
|
||||||
|
option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support" ON)
|
||||||
|
option(ENABLE_PKGUTIL "Set to ON to build the sg_pkgutil application (default)" ON)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
|
GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_BINARY_DIR} PATH)
|
||||||
if (CMAKE_CL_64)
|
if (CMAKE_CL_64)
|
||||||
SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty.x64")
|
SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty.x64")
|
||||||
else (CMAKE_CL_64)
|
else (CMAKE_CL_64)
|
||||||
@@ -86,11 +125,13 @@ endif (MSVC)
|
|||||||
if (MSVC AND MSVC_3RDPARTY_ROOT)
|
if (MSVC AND MSVC_3RDPARTY_ROOT)
|
||||||
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
|
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
|
||||||
set( OSG_MSVC "msvc" )
|
set( OSG_MSVC "msvc" )
|
||||||
if (${MSVC_VERSION} EQUAL 1600)
|
if (${MSVC_VERSION} EQUAL 1700)
|
||||||
|
set( OSG_MSVC ${OSG_MSVC}110 )
|
||||||
|
elseif (${MSVC_VERSION} EQUAL 1600)
|
||||||
set( OSG_MSVC ${OSG_MSVC}100 )
|
set( OSG_MSVC ${OSG_MSVC}100 )
|
||||||
else (${MSVC_VERSION} EQUAL 1600)
|
else (${MSVC_VERSION} EQUAL 1700)
|
||||||
set( OSG_MSVC ${OSG_MSVC}90 )
|
set( OSG_MSVC ${OSG_MSVC}90 )
|
||||||
endif (${MSVC_VERSION} EQUAL 1600)
|
endif (${MSVC_VERSION} EQUAL 1700)
|
||||||
if (CMAKE_CL_64)
|
if (CMAKE_CL_64)
|
||||||
set( OSG_MSVC ${OSG_MSVC}-64 )
|
set( OSG_MSVC ${OSG_MSVC}-64 )
|
||||||
set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
|
set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
|
||||||
@@ -98,57 +139,94 @@ if (MSVC AND MSVC_3RDPARTY_ROOT)
|
|||||||
set( MSVC_3RDPARTY_DIR 3rdParty )
|
set( MSVC_3RDPARTY_DIR 3rdParty )
|
||||||
endif (CMAKE_CL_64)
|
endif (CMAKE_CL_64)
|
||||||
|
|
||||||
set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib )
|
set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/lib )
|
||||||
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include)
|
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/include)
|
||||||
set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
|
find_path(BOOST_ROOT boost/version.hpp
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_52_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_51_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_50_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_49_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_48_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_47_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_46_1
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_46_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_45_0
|
||||||
|
${MSVC_3RDPARTY_ROOT}/boost_1_44_0
|
||||||
|
)
|
||||||
|
# set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
|
||||||
message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
|
message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
|
||||||
set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
|
set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
|
||||||
set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
|
|
||||||
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
|
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
|
||||||
endif (MSVC AND MSVC_3RDPARTY_ROOT)
|
endif (MSVC AND MSVC_3RDPARTY_ROOT)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
find_library(CORE_SERVICES_LIBRARY CoreServices)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(Boost REQUIRED)
|
find_package(Boost REQUIRED)
|
||||||
set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
|
set (BOOST_CXX_FLAGS "-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_BIMAP_DISABLE_SERIALIZATION")
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
|
|
||||||
if(SIMGEAR_HEADLESS)
|
if(SIMGEAR_HEADLESS)
|
||||||
message(STATUS "headless mode")
|
message(STATUS "SimGear mode: HEADLESS")
|
||||||
set(NO_OPENSCENEGRAPH_INTERFACE 1)
|
set(ENABLE_SOUND 0)
|
||||||
else()
|
else()
|
||||||
|
message(STATUS "SimGear mode: NORMAL")
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
|
if (ENABLE_SOUND)
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
find_package(ALUT REQUIRED)
|
message(STATUS "Sound support: ENABLED")
|
||||||
find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgUtil)
|
endif(ENABLE_SOUND)
|
||||||
|
|
||||||
|
find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgGA osgUtil)
|
||||||
endif(SIMGEAR_HEADLESS)
|
endif(SIMGEAR_HEADLESS)
|
||||||
|
|
||||||
if(JPEG_FACTORY)
|
if(JPEG_FACTORY)
|
||||||
message(STATUS "JPEG-factory enabled")
|
message(STATUS "JPEG-factory: ENABLED")
|
||||||
find_package(JPEG REQUIRED)
|
find_package(JPEG REQUIRED)
|
||||||
include_directories(${JPEG_INCLUDE_DIR})
|
include_directories(${JPEG_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
message(STATUS "JPEG-factory: DISABLED")
|
||||||
endif(JPEG_FACTORY)
|
endif(JPEG_FACTORY)
|
||||||
|
|
||||||
if(ENABLE_LIBSVN)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(SvnClient)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
if (SYSTEM_EXPAT)
|
||||||
|
message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true")
|
||||||
|
set(SIMGEAR_SHARED ON)
|
||||||
|
find_package(EXPAT REQUIRED)
|
||||||
|
|
||||||
if(LIBSVN_FOUND)
|
|
||||||
message(STATUS "libsvn found, enabling in SimGear")
|
|
||||||
set(HAVE_SVN_CLIENT_H 1)
|
|
||||||
set(HAVE_LIBSVN_CLIENT_1 1)
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Missing libsvn, unable to enable SVN in SimGear")
|
message(STATUS "Using built-in expat code")
|
||||||
endif(LIBSVN_FOUND)
|
# XML_STATIC is important to avoid sg_expat_external.h
|
||||||
endif(ENABLE_LIBSVN)
|
# declaring symbols as declspec(import)
|
||||||
|
add_definitions(-DHAVE_EXPAT_CONFIG_H -DXML_STATIC)
|
||||||
|
set(EXPAT_INCLUDE_DIRS
|
||||||
|
${PROJECT_SOURCE_DIR}/3rdparty/expat
|
||||||
|
${PROJECT_BINARY_DIR}/3rdparty/expat)
|
||||||
|
endif(SYSTEM_EXPAT)
|
||||||
|
|
||||||
|
include_directories(${EXPAT_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
check_include_file(inttypes.h HAVE_INTTYPES_H)
|
||||||
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
||||||
check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
|
check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
|
||||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||||
check_include_file(windows.h HAVE_WINDOWS_H)
|
check_include_file(windows.h HAVE_WINDOWS_H)
|
||||||
|
|
||||||
|
if(HAVE_INTTYPES_H)
|
||||||
|
# ShivaVG needs inttypes.h
|
||||||
|
add_definitions(-DHAVE_INTTYPES_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_RTI)
|
if(ENABLE_RTI)
|
||||||
# See if we have any rti library variant installed
|
# See if we have any rti library variant installed
|
||||||
|
message(STATUS "RTI: ENABLED")
|
||||||
find_package(RTI)
|
find_package(RTI)
|
||||||
|
else()
|
||||||
|
message(STATUS "RTI: DISABLED")
|
||||||
endif(ENABLE_RTI)
|
endif(ENABLE_RTI)
|
||||||
|
|
||||||
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
|
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
|
||||||
@@ -156,6 +234,8 @@ check_function_exists(ftime HAVE_FTIME)
|
|||||||
check_function_exists(timegm HAVE_TIMEGM)
|
check_function_exists(timegm HAVE_TIMEGM)
|
||||||
check_function_exists(rint HAVE_RINT)
|
check_function_exists(rint HAVE_RINT)
|
||||||
check_function_exists(mkdtemp HAVE_MKDTEMP)
|
check_function_exists(mkdtemp HAVE_MKDTEMP)
|
||||||
|
check_function_exists(bcopy HAVE_BCOPY)
|
||||||
|
check_function_exists(mmap HAVE_MMAP)
|
||||||
|
|
||||||
if(HAVE_UNISTD_H)
|
if(HAVE_UNISTD_H)
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
|
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
|
||||||
@@ -172,15 +252,26 @@ endif(HAVE_UNISTD_H)
|
|||||||
|
|
||||||
set(RT_LIBRARY "")
|
set(RT_LIBRARY "")
|
||||||
if(HAVE_CLOCK_GETTIME)
|
if(HAVE_CLOCK_GETTIME)
|
||||||
check_function_exists(clock_gettime CLOCK_GETTIME_IN_LIBC)
|
|
||||||
if(NOT CLOCK_GETTIME_IN_LIBC)
|
|
||||||
check_library_exists(rt clock_gettime "" HAVE_RT)
|
check_library_exists(rt clock_gettime "" HAVE_RT)
|
||||||
if(HAVE_RT)
|
if(HAVE_RT)
|
||||||
set(RT_LIBRARY rt)
|
set(RT_LIBRARY rt)
|
||||||
endif(HAVE_RT)
|
endif(HAVE_RT)
|
||||||
endif(NOT CLOCK_GETTIME_IN_LIBC)
|
|
||||||
endif(HAVE_CLOCK_GETTIME)
|
endif(HAVE_CLOCK_GETTIME)
|
||||||
|
|
||||||
|
set(DL_LIBRARY "")
|
||||||
|
check_cxx_source_compiles(
|
||||||
|
"#include <dlfcn.h>
|
||||||
|
int main(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_DLFCN_H)
|
||||||
|
|
||||||
|
if(HAVE_DLFCN_H)
|
||||||
|
check_library_exists(dl dlerror "" HAVE_DL)
|
||||||
|
set(DL_LIBRARY "dl")
|
||||||
|
endif()
|
||||||
|
|
||||||
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually 'd' on windows")
|
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually 'd' on windows")
|
||||||
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
||||||
SET(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
SET(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
||||||
@@ -192,8 +283,14 @@ check_cxx_source_compiles(
|
|||||||
void f() { isnan(0.0);} "
|
void f() { isnan(0.0);} "
|
||||||
HAVE_ISNAN)
|
HAVE_ISNAN)
|
||||||
|
|
||||||
|
check_cxx_source_compiles(
|
||||||
|
"#include <cmath>
|
||||||
|
void f() { std::isnan(0.0);} "
|
||||||
|
HAVE_STD_ISNAN)
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(WARNING_FLAGS -Wall)
|
set(WARNING_FLAGS_CXX "-Wall")
|
||||||
|
set(WARNING_FLAGS_C "-Wall")
|
||||||
|
|
||||||
# certain GCC versions don't provide the atomic builds, and hence
|
# certain GCC versions don't provide the atomic builds, and hence
|
||||||
# require is to provide them in SGAtomic.cxx
|
# require is to provide them in SGAtomic.cxx
|
||||||
@@ -203,15 +300,35 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||||||
GCC_ATOMIC_BUILTINS_FOUND)
|
GCC_ATOMIC_BUILTINS_FOUND)
|
||||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
set(WARNING_FLAGS_CXX "-Wall -Wno-overloaded-virtual")
|
||||||
|
set(WARNING_FLAGS_C "-Wall")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
# boost goes haywire wrt static asserts
|
||||||
|
check_cxx_compiler_flag(-Wno-unused-local-typedefs HAS_NOWARN_UNUSED_TYPEDEFS)
|
||||||
|
if(HAS_NOWARN_UNUSED_TYPEDEFS)
|
||||||
|
set(WARNING_FLAGS_CXX " ${WARNING_FLAGS_CXX} -Wno-unused-local-typedefs")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|
||||||
|
if(MINGW)
|
||||||
|
add_definitions(-D_WIN32_WINNT=0x501)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# turn off various warnings
|
# turn off various warnings
|
||||||
# foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
|
# foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
|
||||||
# SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
|
# SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
|
||||||
# endforeach(warning)
|
# endforeach(warning)
|
||||||
|
|
||||||
set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /wd4996")
|
set(MSVC_FLAGS "-DWIN32 -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS /wd4996 /wd4250 -Dstrdup=_strdup")
|
||||||
|
if (${MSVC_VERSION} GREATER 1599)
|
||||||
|
set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
|
||||||
|
endif (${MSVC_VERSION} GREATER 1599)
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
# assumed on Windows
|
# assumed on Windows
|
||||||
@@ -221,16 +338,19 @@ if(WIN32)
|
|||||||
set( RT_LIBRARY "winmm" )
|
set( RT_LIBRARY "winmm" )
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS_C} ${MSVC_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_CXX} ${MSVC_FLAGS} ${BOOST_CXX_FLAGS}")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
|
||||||
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR})
|
include_directories(${PROJECT_SOURCE_DIR})
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include)
|
||||||
include_directories(${PROJECT_BINARY_DIR}/simgear)
|
include_directories(${PROJECT_BINARY_DIR}/simgear)
|
||||||
|
|
||||||
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
|
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
|
||||||
${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}
|
${Boost_INCLUDE_DIRS}
|
||||||
${ALUT_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} )
|
${ZLIB_INCLUDE_DIR}
|
||||||
|
${OPENAL_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
add_definitions(-DHAVE_CONFIG_H)
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
|
|
||||||
@@ -243,12 +363,31 @@ configure_file (
|
|||||||
|
|
||||||
if(ENABLE_TESTS)
|
if(ENABLE_TESTS)
|
||||||
# enable CTest / make test target
|
# enable CTest / make test target
|
||||||
|
message(STATUS "Tests: ENABLED")
|
||||||
|
|
||||||
include (Dart)
|
include (Dart)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
else()
|
||||||
|
message(STATUS "Tests: DISABLED")
|
||||||
endif(ENABLE_TESTS)
|
endif(ENABLE_TESTS)
|
||||||
|
|
||||||
|
# always set TEST_LIBS as it is also used by other tools/applications
|
||||||
|
set(TEST_LIBS_INTERNAL_CORE
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${ZLIB_LIBRARY}
|
||||||
|
${WINSOCK_LIBRARY}
|
||||||
|
${RT_LIBRARY}
|
||||||
|
${DL_LIBRARY}
|
||||||
|
${CORE_SERVICES_LIBRARY})
|
||||||
|
set(TEST_LIBS SimGearCore ${TEST_LIBS_INTERNAL_CORE})
|
||||||
|
|
||||||
|
if(NOT SIMGEAR_HEADLESS)
|
||||||
|
set(TEST_LIBS SimGearScene ${OPENGL_LIBRARIES} ${TEST_LIBS})
|
||||||
|
endif()
|
||||||
|
|
||||||
install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/)
|
install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/)
|
||||||
|
|
||||||
|
add_subdirectory(3rdparty)
|
||||||
add_subdirectory(simgear)
|
add_subdirectory(simgear)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -261,3 +400,4 @@ CONFIGURE_FILE(
|
|||||||
ADD_CUSTOM_TARGET(uninstall
|
ADD_CUSTOM_TARGET(uninstall
|
||||||
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
# Locate ALUT
|
|
||||||
# This module defines
|
|
||||||
# ALUT_LIBRARY
|
|
||||||
# ALUT_FOUND, if false, do not try to link to ALUT
|
|
||||||
# ALUT_INCLUDE_DIR, where to find the headers
|
|
||||||
#
|
|
||||||
# $ALUTDIR is an environment variable that would
|
|
||||||
# correspond to the ./configure --prefix=$ALUTDIR
|
|
||||||
# used in building ALUT.
|
|
||||||
#
|
|
||||||
# Created by James Turner. This was influenced by the FindOpenAL.cmake module.
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Copyright 2005-2009 Kitware, Inc.
|
|
||||||
#
|
|
||||||
# Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
# see accompanying file Copyright.txt for details.
|
|
||||||
#
|
|
||||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
# See the License for more information.
|
|
||||||
#=============================================================================
|
|
||||||
# (To distributed this file outside of CMake, substitute the full
|
|
||||||
# License text for the above reference.)
|
|
||||||
|
|
||||||
# Per my request, CMake should search for frameworks first in
|
|
||||||
# the following order:
|
|
||||||
# ~/Library/Frameworks/OpenAL.framework/Headers
|
|
||||||
# /Library/Frameworks/OpenAL.framework/Headers
|
|
||||||
# /System/Library/Frameworks/OpenAL.framework/Headers
|
|
||||||
#
|
|
||||||
# On OS X, this will prefer the Framework version (if found) over others.
|
|
||||||
# People will have to manually change the cache values of
|
|
||||||
# OPENAL_LIBRARY to override this selection or set the CMake environment
|
|
||||||
# CMAKE_INCLUDE_PATH to modify the search paths.
|
|
||||||
|
|
||||||
FIND_PATH(ALUT_INCLUDE_DIR alut.h
|
|
||||||
HINTS
|
|
||||||
$ENV{ALUTDIR}
|
|
||||||
PATH_SUFFIXES include/AL include/ALUT include
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(ALUT_LIBRARY
|
|
||||||
NAMES ALUT alut
|
|
||||||
HINTS
|
|
||||||
$ENV{ALUTDIR}
|
|
||||||
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
SET(ALUT_FOUND "NO")
|
|
||||||
IF(ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
|
|
||||||
SET(ALUT_FOUND "YES")
|
|
||||||
ENDIF(ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
|
|
||||||
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
# Find Subversion client libraries, and dependencies
|
|
||||||
# including APR (Apache Portable Runtime)
|
|
||||||
|
|
||||||
include (CheckFunctionExists)
|
|
||||||
include (CheckIncludeFile)
|
|
||||||
include (CheckLibraryExists)
|
|
||||||
|
|
||||||
macro(find_static_component comp libs)
|
|
||||||
# account for alternative Windows svn distribution naming
|
|
||||||
if(MSVC)
|
|
||||||
set(compLib "lib${comp}")
|
|
||||||
else(MSVC)
|
|
||||||
set(compLib "${comp}")
|
|
||||||
endif(MSVC)
|
|
||||||
|
|
||||||
string(TOUPPER "${comp}" compLibBase)
|
|
||||||
set( compLibName ${compLibBase}_LIBRARY )
|
|
||||||
|
|
||||||
FIND_LIBRARY(${compLibName}
|
|
||||||
NAMES ${compLib}
|
|
||||||
HINTS $ENV{PLIBDIR}
|
|
||||||
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
|
|
||||||
PATHS
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
list(APPEND ${libs} ${${compLibName}})
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
find_program(HAVE_APR_CONFIG apr-1-config)
|
|
||||||
if(HAVE_APR_CONFIG)
|
|
||||||
|
|
||||||
execute_process(COMMAND apr-1-config --cppflags --includes
|
|
||||||
OUTPUT_VARIABLE APR_CFLAGS
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
|
|
||||||
execute_process(COMMAND apr-1-config --link-ld
|
|
||||||
OUTPUT_VARIABLE RAW_APR_LIBS
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
|
|
||||||
# clean up some vars, or other CMake pieces complain
|
|
||||||
string(STRIP "${RAW_APR_LIBS}" APR_LIBS)
|
|
||||||
|
|
||||||
else(HAVE_APR_CONFIG)
|
|
||||||
message(STATUS "apr-1-config not found, implement manual search for APR")
|
|
||||||
endif(HAVE_APR_CONFIG)
|
|
||||||
|
|
||||||
if(HAVE_APR_CONFIG OR MSVC)
|
|
||||||
find_path(LIBSVN_INCLUDE_DIR svn_client.h
|
|
||||||
HINTS
|
|
||||||
$ENV{LIBSVN_DIR}
|
|
||||||
PATH_SUFFIXES include/subversion-1
|
|
||||||
PATHS
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIBSVN_LIBRARIES "")
|
|
||||||
if (MSVC)
|
|
||||||
find_static_component("apr-1" LIBSVN_LIBRARIES)
|
|
||||||
else (MSVC)
|
|
||||||
list(APPEND LIBSVN_LIBRARIES ${APR_LIBS})
|
|
||||||
endif (MSVC)
|
|
||||||
find_static_component("svn_client-1" LIBSVN_LIBRARIES)
|
|
||||||
find_static_component("svn_subr-1" LIBSVN_LIBRARIES)
|
|
||||||
find_static_component("svn_ra-1" LIBSVN_LIBRARIES)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSVN DEFAULT_MSG LIBSVN_LIBRARIES LIBSVN_INCLUDE_DIR)
|
|
||||||
if(NOT LIBSVN_FOUND)
|
|
||||||
set(LIBSVN_LIBRARIES "")
|
|
||||||
endif(NOT LIBSVN_FOUND)
|
|
||||||
endif(HAVE_APR_CONFIG OR MSVC)
|
|
||||||
@@ -1,23 +1,21 @@
|
|||||||
|
|
||||||
macro(simgear_component_common name includePath sourcesList sources headers)
|
macro(simgear_component_common name includePath sourcesList sources headers)
|
||||||
if (SIMGEAR_SHARED)
|
set(fc${sourcesList} ${name})
|
||||||
|
set(fh${sourcesList} ${name})
|
||||||
foreach(s ${sources})
|
foreach(s ${sources})
|
||||||
set_property(GLOBAL
|
set_property(GLOBAL
|
||||||
APPEND PROPERTY ${sourcesList} "${CMAKE_CURRENT_SOURCE_DIR}/${s}")
|
APPEND PROPERTY ${sourcesList} "${CMAKE_CURRENT_SOURCE_DIR}/${s}")
|
||||||
|
set(fc${sourcesList} "${fc${sourcesList}}#${CMAKE_CURRENT_SOURCE_DIR}/${s}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(h ${headers})
|
foreach(h ${headers})
|
||||||
set_property(GLOBAL
|
set_property(GLOBAL
|
||||||
APPEND PROPERTY PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}")
|
APPEND PROPERTY PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}")
|
||||||
|
set(fh${sourcesList} "${fh${sourcesList}}#${CMAKE_CURRENT_SOURCE_DIR}/${h}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
else()
|
set_property(GLOBAL APPEND PROPERTY FG_GROUPS_${sourcesList}_C "${fc${sourcesList}}@")
|
||||||
set(libName "sg${name}")
|
set_property(GLOBAL APPEND PROPERTY FG_GROUPS_${sourcesList}_H "${fh${sourcesList}}@")
|
||||||
add_library(${libName} STATIC ${sources} ${headers})
|
|
||||||
|
|
||||||
install (TARGETS ${libName} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install (FILES ${headers} DESTINATION include/simgear/${includePath})
|
install (FILES ${headers} DESTINATION include/simgear/${includePath})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
@@ -464,7 +464,7 @@ convey the exclusion of warranty; and each file should have at least the
|
|||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with this library; if not, write to the Free
|
License along with this library; if not, write to the Free
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ PROJECT_NAME = SimGear
|
|||||||
# This could be handy for archiving the generated documentation or
|
# This could be handy for archiving the generated documentation or
|
||||||
# if some version control system is used.
|
# if some version control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 2.2.0
|
PROJECT_NUMBER = 2.11.0
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||||
# base path where the generated documentation will be put.
|
# base path where the generated documentation will be put.
|
||||||
@@ -56,7 +56,7 @@ EXTRACT_PRIVATE = NO
|
|||||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
||||||
# will be included in the documentation.
|
# will be included in the documentation.
|
||||||
|
|
||||||
EXTRACT_STATIC = NO
|
EXTRACT_STATIC = YES
|
||||||
|
|
||||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
|
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
|
||||||
# undocumented members of documented classes, files or namespaces.
|
# undocumented members of documented classes, files or namespaces.
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
How to build SimGear
|
||||||
|
====================
|
||||||
|
|
||||||
|
SimGear uses the CMake build system to generate a platform-specific
|
||||||
|
build environment. CMake reads the CMakeLists.txt files that you'll
|
||||||
|
find throughout the source directories, checks for installed
|
||||||
|
dependencies and then generates the appropriate build system.
|
||||||
|
|
||||||
|
If you don't already have CMake installed on your system you can grab
|
||||||
|
it from http://www.cmake.org, use version 2.6.4 or later.
|
||||||
|
|
||||||
|
Under unices (i.e. Linux, Solaris, Free-BSD, HP-Ux, OSX) use the cmake
|
||||||
|
or ccmake command-line utils. Preferably, create an out-of-source
|
||||||
|
build directory and run cmake or ccmake from there. The advantage to
|
||||||
|
this approach is that the temporary files created by CMake won't
|
||||||
|
clutter the source directory, and also makes it possible to have
|
||||||
|
multiple independent build targets by creating multiple build
|
||||||
|
directories. In a directory alongside the SimGear source directory
|
||||||
|
use:
|
||||||
|
|
||||||
|
mkdir sgbuild
|
||||||
|
cd sgbuild
|
||||||
|
cmake ../simgear -DCMAKE_BUILD_TYPE=Release
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
|
||||||
|
Build Dependencies
|
||||||
|
==================
|
||||||
|
SimGear depends on a number of 3rd party libraries, the most notable
|
||||||
|
being:
|
||||||
|
|
||||||
|
* OpenSceneGraph (OSG) - see README.OSG
|
||||||
|
* zlib compression library - see README.zlib
|
||||||
|
* Open Audio Library (OpenAL) - see README.OpenAL
|
||||||
|
* Subversion Client Library (optional dependency)
|
||||||
|
|
||||||
|
|
||||||
|
Further information
|
||||||
|
===================
|
||||||
|
* README.cmake
|
||||||
|
for more detailed CMake instructions
|
||||||
|
|
||||||
|
* README.msvc
|
||||||
|
in the FlightGear source package for more Windows-specific instructions
|
||||||
|
|
||||||
|
* FlightGear Wiki
|
||||||
|
http://wiki.flightgear.org/Building_Flightgear
|
||||||
|
|
||||||
|
* FlightGear Forums
|
||||||
|
For help on building see: http://www.flightgear.org/forums
|
||||||
|
=> Support/Compiling
|
||||||
|
|
||||||
|
* FlightGear Mailing lists
|
||||||
|
http://wiki.flightgear.org/index.php/Mailing_list
|
||||||
|
|
||||||
@@ -1 +1,15 @@
|
|||||||
[ Nothing here at this time. ]
|
SimGear - Simulator Construction Tools
|
||||||
|
======================================
|
||||||
|
http://www.flightgear.org
|
||||||
|
|
||||||
|
SimGear is a set of open-source libraries designed to be used as building
|
||||||
|
blocks for quickly assembling 3d simulations, games, and visualization
|
||||||
|
applications.
|
||||||
|
|
||||||
|
SimGear is developed by the FlightGear project and also provides the base
|
||||||
|
for the FlightGear Flight Simulator.
|
||||||
|
|
||||||
|
Source code for SimGear is released under the GNU Library General Public
|
||||||
|
License (LGPL) - see COPYING for license details.
|
||||||
|
|
||||||
|
See INSTALL file for help on building SimGear.
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
You *must* have OpenSceneGraph (OSG) installed to build this version of
|
You *must* have OpenSceneGraph (OSG) installed to build this version of
|
||||||
FlightGear.
|
FlightGear.
|
||||||
|
|
||||||
Notice that FlightGear 2.6.0 requires at least version 3.0.0.
|
Notice that this version of SimGear/FlightGear requires at least OSG 3.0.0.
|
||||||
|
|
||||||
You can get the latest version of OSG from:
|
You can get the latest version of OSG from:
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,3 @@ ccmake .
|
|||||||
then press 'g' to generate and exit ]
|
then press 'g' to generate and exit ]
|
||||||
|
|
||||||
|
|
||||||
The alut library is also required, but comes separately in the package
|
|
||||||
freelut-1.1.0.tar.gz. This package can be downloaded from the same page
|
|
||||||
(http://connect.creativelabs.com/openal/default.aspx). Download and run:
|
|
||||||
tar xzvf freelut-1.1.0.tar.gz
|
|
||||||
cd freealut-1.1.0
|
|
||||||
./configure
|
|
||||||
make
|
|
||||||
sudo make install
|
|
||||||
|
|
||||||
|
|||||||
+161
@@ -0,0 +1,161 @@
|
|||||||
|
Getting started with CMake
|
||||||
|
==========================
|
||||||
|
|
||||||
|
(These instructions apply to Unix-like systems, including Cygwin and Mac. To
|
||||||
|
build using Visual Studio or some other IDE supported by CMake, most of the
|
||||||
|
information below still applies. Otherwise see
|
||||||
|
http://wiki.flightgear.org/Building_Flightgear for Windows specific build
|
||||||
|
instructions.)
|
||||||
|
|
||||||
|
Always compile in a separate directory to the code. For example, if the
|
||||||
|
code (eg, from Git) is at /home/curt/projects/simgear, you might create
|
||||||
|
/home/curt/projects/sgbuild. Change into the new directory, and run
|
||||||
|
|
||||||
|
cmake ../simgear
|
||||||
|
|
||||||
|
To generate standard Unix Makefiles in sgbuild.
|
||||||
|
|
||||||
|
Probably you want to specify an install prefix:
|
||||||
|
|
||||||
|
cmake ../simgear -DCMAKE_INSTALL_PREFIX=/usr
|
||||||
|
|
||||||
|
Note the install prefix is automatically searched for required libraries
|
||||||
|
and header files, so if you install OpenSceneGraph to the same prefix,
|
||||||
|
most configuration options are unnecessary.
|
||||||
|
|
||||||
|
If for some reason you have a dependency (or several) at a different prefix,
|
||||||
|
you can specify one or more via CMAKE_PREFIX_PATH:
|
||||||
|
|
||||||
|
cmake ../simgear -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs"
|
||||||
|
|
||||||
|
(note the use of semi-colons to specify multiple prefix paths)
|
||||||
|
|
||||||
|
Standard prefixes are searched automatically (/usr, /usr/local, /opt/local)
|
||||||
|
|
||||||
|
Most dependencies also expose an environment variable to specify their
|
||||||
|
installation directory explicitly eg OSG_DIR. Any of the methods
|
||||||
|
described above will work, but specifying an INSTALL_PREFIX or PREFIX_PATH is
|
||||||
|
usually simpler.
|
||||||
|
|
||||||
|
By default, we select a release build. To create a debug build, use
|
||||||
|
|
||||||
|
cmake ../simgear -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
|
||||||
|
(or MinSizeRel, or RelWithDbg)
|
||||||
|
|
||||||
|
Debug builds will automatically use corresponding debug builds of required
|
||||||
|
libraries, if they are available. For example you can install debug builds of
|
||||||
|
OpenSceneGraph, and a debug SimGear build will use them.
|
||||||
|
|
||||||
|
(Debug builds of libraries have the 'd' suffix by default - Release builds
|
||||||
|
have no additional suffix)
|
||||||
|
|
||||||
|
Note most IDE projects (eg Xcode and Visual Studio) support building all the
|
||||||
|
build types from the same project, so you can omit the CMAKE_BUILD_TYPE option
|
||||||
|
when running cmake, and simply pick the build configuration as normal in the
|
||||||
|
IDE.
|
||||||
|
|
||||||
|
It's common to have several build directories with different build
|
||||||
|
configurations, eg
|
||||||
|
|
||||||
|
/home/curt/projects/simgear (the git clone)
|
||||||
|
/home/curt/projects/sgdebug
|
||||||
|
/home/curt/projects/sgrelease
|
||||||
|
/home/curt/projects/sg-with-svn-osg
|
||||||
|
|
||||||
|
To set an optional feature, do
|
||||||
|
|
||||||
|
cmake ../simgear -DFEATURE_NAME=ON
|
||||||
|
|
||||||
|
(or 'OFF' to disable )
|
||||||
|
|
||||||
|
To see the variables that can be configured / are currently defined, you can
|
||||||
|
run one of the GUI front ends, or the following command:
|
||||||
|
|
||||||
|
cmake ../simgear -L
|
||||||
|
|
||||||
|
Add 'A' to see all the options (including advanced options), or 'H' to see
|
||||||
|
the help for each option (similar to running configure --help under autoconf):
|
||||||
|
|
||||||
|
cmake ../simgear -LH
|
||||||
|
|
||||||
|
|
||||||
|
Build Targets
|
||||||
|
=============
|
||||||
|
|
||||||
|
For a Unix makefile build, 'make dist', 'make uninstall' and 'make test' are
|
||||||
|
all available and should work as expected. 'make clean' is also as normal,
|
||||||
|
but there is *no* 'make distclean' target. The equivalent is to completely
|
||||||
|
remove your build directory, and start with a fresh one.
|
||||||
|
|
||||||
|
Adding new files to the build
|
||||||
|
|
||||||
|
Add source files to the SOURCES list, and headers to the HEADERS list. Note
|
||||||
|
technically you only need to add source files, but omitting headers confuses
|
||||||
|
project generation and distribution / packaging targets.
|
||||||
|
|
||||||
|
For target conditional files, you can append to the SOURCES or HEADERS lists
|
||||||
|
inside an if() test, for example:
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
list(APPEND SOURCES extraFile1.cxx extraFile2.cxx)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
Setting include directories
|
||||||
|
|
||||||
|
In any CMakeList.txt, you can do the following:
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/some/path)
|
||||||
|
|
||||||
|
For example, this can be done in particular subdirectory, or at the project
|
||||||
|
root, or an intermediate level.
|
||||||
|
|
||||||
|
Setting target specific compile flags, includes or defines
|
||||||
|
|
||||||
|
Use set_target_property(), for example
|
||||||
|
|
||||||
|
set_target_property(fgfs PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS FOO BAR=1)
|
||||||
|
|
||||||
|
You can set a property on an individual source file:
|
||||||
|
|
||||||
|
set_property(SOURCE myfile.cxx PROPERTY COMPILE_FLAGS "-Wno-unsigned-compare")
|
||||||
|
|
||||||
|
Detecting Features / Libraries
|
||||||
|
|
||||||
|
For most standard libraries (Gtk, wxWidget, Python, GDAL, Qt, libXml, Boost),
|
||||||
|
cmake provides a standard helper. To see the available modules, run:
|
||||||
|
|
||||||
|
cmake --help-module-list
|
||||||
|
|
||||||
|
In the root CMakeLists file, use a statement like:
|
||||||
|
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
|
Each package helper sets various variables such aaa_FOUND, aaa_INCLUDE_DIR,
|
||||||
|
and aaa_LIBRARY. Depending on the complexity of the package, these variables
|
||||||
|
might have different names (eg, OPENSCENEGRAPH_LIBRARIES).
|
||||||
|
|
||||||
|
If there's no standard helper for a library you need, find a similar one, copy
|
||||||
|
it to CMakeModules/FindABC.cmake, and modify the code to fit. Generally this
|
||||||
|
is pretty straightforward. The built-in modules reside in the Cmake 'share'
|
||||||
|
directory, eg /usr/share/cmake/modules on Unix systems.
|
||||||
|
|
||||||
|
Note libraries support by pkg-config can be handled directly, with no need
|
||||||
|
to create a custom FindABC helper.
|
||||||
|
|
||||||
|
Adding a new executable target
|
||||||
|
|
||||||
|
add_executable(myexecutable ${SOURCES} ${HEADERS})
|
||||||
|
target_link_libraries(myexecutable .... libraries ... )
|
||||||
|
install(TARGETS myexecutable RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
|
(If the executable should not be installed, omit the final line above)
|
||||||
|
|
||||||
|
If you add an additional line
|
||||||
|
|
||||||
|
add_test(testname ${EXECUTABLE_OUTPUT_PATH}/myexecutable)
|
||||||
|
|
||||||
|
Then running 'make test' will run your executable as a unit test. The
|
||||||
|
executable should return either a success or failure result code.
|
||||||
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
[This file is mirrored in both the FlightGear and SimGear packages.]
|
|
||||||
|
|
||||||
You *must* have plib version 1.8.5 or later installed on your system
|
|
||||||
to build FlightGear!" Flight Gear is no longer compatible with the
|
|
||||||
earlier versions of the library.
|
|
||||||
|
|
||||||
You can get the latest version of plib from:
|
|
||||||
|
|
||||||
http://plib.sourceforge.net
|
|
||||||
|
|
||||||
Build notes:
|
|
||||||
|
|
||||||
You should be able to just run "./configure" to configure the package
|
|
||||||
and use all of plib's defaults. Then run "make" followed by "make
|
|
||||||
install". By default, plib installs itself into /usr so if you don't
|
|
||||||
like this, be sure to specify an alternate prefix such as --prefix=/usr/local
|
|
||||||
|
|
||||||
As of this writing (2007-11-18), many linux distributions are shipped with a
|
|
||||||
working version of plib, so chances are that this library is already
|
|
||||||
installed. It should be noted, that currently plib version no longer compiles
|
|
||||||
using recent versions of gcc (confirmed on version gcc 4.1.2, as shipped with
|
|
||||||
SuSe 10.2). As a workaround, it is possible to either use plib SVN. Run the
|
|
||||||
following commands:
|
|
||||||
|
|
||||||
|
|
||||||
svn co https://plib.svn.sourceforge.net/svnroot/plib/trunk plib
|
|
||||||
cd plib
|
|
||||||
./autogen.sh
|
|
||||||
./configure
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
03/25/2001 - Resolve location of Sky dome implimentation documentation.
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
Building a SimGear RPM package for Red Hat
|
||||||
|
|
||||||
|
Please see the "package/openSUSE" directory for an
|
||||||
|
example how to build a SimGear RPM package with
|
||||||
|
shared SimGear libraries.
|
||||||
|
|
||||||
|
You may need to adapt the names (exact spelling) of some
|
||||||
|
of the package dependencies in the openSUSE RPM spec,
|
||||||
|
since these may slightly differ for Red Hat.
|
||||||
|
|
||||||
|
(If you have a working and tested Red Hat RPM spec,
|
||||||
|
you're welcome to contribute it to this project.)
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
Building a SimGear RPM package for openSUSE
|
||||||
|
|
||||||
|
(Last tested with openSUSE 11.4+12.1)
|
||||||
|
|
||||||
|
This directory contains the files which, along with
|
||||||
|
the source code tar files, can be used to build
|
||||||
|
an RPM package targeted at an openSUSE Linux system.
|
||||||
|
|
||||||
|
To build SimGear from source do the following:
|
||||||
|
|
||||||
|
1. obtain simgear-2.8.0.tar.bz2 (adapt version if
|
||||||
|
necessary) and copy it into ~/rpmbuild/SOURCES
|
||||||
|
|
||||||
|
2. look in the BuildRequires section of SimGear.spec
|
||||||
|
and check that all the packages referred to are
|
||||||
|
installed (note, some of these packages may be part
|
||||||
|
of openSUSE's "games" repository).
|
||||||
|
|
||||||
|
3. run 'rpmbuild -ba simgear.spec' and find the RPM
|
||||||
|
build result in ~/rpmbuild/RPMS
|
||||||
|
|
||||||
|
That's all!
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
Summary: Simulator Construction Gear
|
||||||
|
Name: SimGear
|
||||||
|
Version: 2.8.0
|
||||||
|
Release: 1
|
||||||
|
License: LGPL
|
||||||
|
URL: http://www.flightgear.org
|
||||||
|
Group: Amusements/Games/3D/Simulation
|
||||||
|
Source: http://mirrors.ibiblio.org/pub/mirrors/flightgear/ftp/Source/simgear-%{version}.tar.bz2
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
|
|
||||||
|
BuildRequires: gcc, gcc-c++, cmake
|
||||||
|
BuildRequires: libopenal1-soft, openal-soft
|
||||||
|
BuildRequires: libOpenSceneGraph-devel >= 3.0
|
||||||
|
BuildRequires: zlib, zlib-devel
|
||||||
|
BuildRequires: libjpeg62, libjpeg62-devel
|
||||||
|
BuildRequires: boost-devel >= 1.37
|
||||||
|
BuildRequires: subversion-devel, libapr1-devel
|
||||||
|
Requires: OpenSceneGraph-plugins >= 3.0
|
||||||
|
|
||||||
|
%description
|
||||||
|
This package contains a tools and libraries useful for constructing
|
||||||
|
simulation and visualization applications such as FlightGear or TerraGear.
|
||||||
|
|
||||||
|
%package devel
|
||||||
|
Group: Development/Libraries/Other
|
||||||
|
Summary: Development header files for SimGear
|
||||||
|
Requires: SimGear = %{version}
|
||||||
|
|
||||||
|
%description devel
|
||||||
|
Development headers and libraries for building applications against SimGear.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -T -q -n simgear-%{version} -b 0
|
||||||
|
|
||||||
|
%build
|
||||||
|
export CFLAGS="$RPM_OPT_FLAGS"
|
||||||
|
export CXXFLAGS="$RPM_OPT_FLAGS"
|
||||||
|
# build SHARED simgear libraries
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} -DSIMGEAR_SHARED:BOOL=ON -DENABLE_TESTS:BOOL=OFF -DJPEG_FACTORY:BOOL=ON
|
||||||
|
make %{?_smp_mflags}
|
||||||
|
|
||||||
|
%install
|
||||||
|
make DESTDIR=%{buildroot} install
|
||||||
|
|
||||||
|
%post -p /sbin/ldconfig
|
||||||
|
|
||||||
|
%postun -p /sbin/ldconfig
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr (-, root, root, -)
|
||||||
|
%doc AUTHORS COPYING ChangeLog NEWS README
|
||||||
|
%{_libdir}/libSimGear*.so.*
|
||||||
|
|
||||||
|
%files devel
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
%dir %{_includedir}/simgear
|
||||||
|
%{_includedir}/simgear/*
|
||||||
|
%{_libdir}/libSimGear*.so
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Mon Jul 02 2012 thorstenb@flightgear.org
|
||||||
|
- Initial version
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
The handmade VS2010 project files have been replaced by the Cmake build system.
|
|
||||||
Please use Cmake to build FlightGear with Visual Studio 2010.
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
*.user
|
|
||||||
Win32
|
|
||||||
x64
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,2 @@
|
|||||||
simgear_config.h
|
simgear_config.h
|
||||||
simgear_config.h.*
|
|
||||||
version.h
|
version.h
|
||||||
|
|||||||
+82
-36
@@ -3,6 +3,7 @@ file(WRITE ${PROJECT_BINARY_DIR}/simgear/version.h "#define SIMGEAR_VERSION ${SI
|
|||||||
|
|
||||||
foreach( mylibfolder
|
foreach( mylibfolder
|
||||||
bucket
|
bucket
|
||||||
|
bvh
|
||||||
debug
|
debug
|
||||||
ephemeris
|
ephemeris
|
||||||
io
|
io
|
||||||
@@ -10,13 +11,14 @@ foreach( mylibfolder
|
|||||||
math
|
math
|
||||||
misc
|
misc
|
||||||
nasal
|
nasal
|
||||||
|
nasal/cppbind
|
||||||
props
|
props
|
||||||
route
|
|
||||||
serial
|
serial
|
||||||
structure
|
structure
|
||||||
threads
|
threads
|
||||||
timing
|
timing
|
||||||
xml
|
xml
|
||||||
|
package
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(${mylibfolder})
|
add_subdirectory(${mylibfolder})
|
||||||
@@ -24,6 +26,7 @@ foreach( mylibfolder
|
|||||||
endforeach( mylibfolder )
|
endforeach( mylibfolder )
|
||||||
|
|
||||||
if(NOT SIMGEAR_HEADLESS)
|
if(NOT SIMGEAR_HEADLESS)
|
||||||
|
add_subdirectory(canvas)
|
||||||
add_subdirectory(environment)
|
add_subdirectory(environment)
|
||||||
add_subdirectory(screen)
|
add_subdirectory(screen)
|
||||||
add_subdirectory(scene)
|
add_subdirectory(scene)
|
||||||
@@ -39,59 +42,102 @@ endif(ENABLE_RTI)
|
|||||||
set(HEADERS compiler.h constants.h sg_inlines.h ${PROJECT_BINARY_DIR}/simgear/version.h)
|
set(HEADERS compiler.h constants.h sg_inlines.h ${PROJECT_BINARY_DIR}/simgear/version.h)
|
||||||
install (FILES ${HEADERS} DESTINATION include/simgear/)
|
install (FILES ${HEADERS} DESTINATION include/simgear/)
|
||||||
|
|
||||||
if(SIMGEAR_SHARED)
|
|
||||||
message(STATUS "building shared library")
|
|
||||||
get_property(coreSources GLOBAL PROPERTY CORE_SOURCES)
|
get_property(coreSources GLOBAL PROPERTY CORE_SOURCES)
|
||||||
get_property(sceneSources GLOBAL PROPERTY SCENE_SOURCES)
|
get_property(sceneSources GLOBAL PROPERTY SCENE_SOURCES)
|
||||||
get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS)
|
get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS)
|
||||||
|
get_property(localExpatSources GLOBAL PROPERTY LOCAL_EXPAT_SOURCES)
|
||||||
|
|
||||||
add_library(SimGearCore SHARED ${coreSources})
|
if(SIMGEAR_SHARED)
|
||||||
set_property(TARGET SimGearCore PROPERTY COMPILE_FLAGS "-DNO_OPENSCENEGRAPH_INTERFACE=1")
|
message(STATUS "Library building mode: SHARED LIBRARIES")
|
||||||
|
add_library(SimGearCore SHARED ${coreSources} ${localExpatSources})
|
||||||
|
|
||||||
# set_property(TARGET SimGearCore PROPERTY FRAMEWORK 1)
|
|
||||||
# message(STATUS "public header: ${publicHeaders}")
|
|
||||||
# set_property(TARGET SimGearCore PROPERTY PUBLIC_HEADER "${publicHeaders}")
|
|
||||||
set_property(TARGET SimGearCore PROPERTY LINKER_LANGUAGE CXX)
|
set_property(TARGET SimGearCore PROPERTY LINKER_LANGUAGE CXX)
|
||||||
|
|
||||||
set_property(TARGET SimGearCore PROPERTY VERSION ${SIMGEAR_VERSION})
|
set_property(TARGET SimGearCore PROPERTY VERSION ${SIMGEAR_VERSION})
|
||||||
set_property(TARGET SimGearCore PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
|
set_property(TARGET SimGearCore PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
|
||||||
|
install(TARGETS SimGearCore EXPORT SimGearCoreConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
target_link_libraries(SimGearCore ${ZLIB_LIBRARY} ${RT_LIBRARY})
|
install(EXPORT SimGearCoreConfig DESTINATION share/SimGearCore)
|
||||||
install(TARGETS SimGearCore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
|
|
||||||
if(NOT SIMGEAR_HEADLESS)
|
if(NOT SIMGEAR_HEADLESS)
|
||||||
if(LIBSVN_FOUND)
|
|
||||||
add_definitions(${APR_CFLAGS})
|
|
||||||
|
|
||||||
IF(APPLE)
|
|
||||||
set_property(SOURCE scene/tsync/terrasync.cxx PROPERTY COMPILE_FLAGS "-iwithsysroot ${LIBSVN_INCLUDE_DIR}")
|
|
||||||
ELSE()
|
|
||||||
include_directories(${LIBSVN_INCLUDE_DIR})
|
|
||||||
ENDIF(APPLE)
|
|
||||||
endif(LIBSVN_FOUND)
|
|
||||||
|
|
||||||
list(APPEND sceneSources scene/util/SGCoreOSGDependant.cxx)
|
|
||||||
|
|
||||||
add_library(SimGearScene SHARED ${sceneSources})
|
add_library(SimGearScene SHARED ${sceneSources})
|
||||||
# set_property(TARGET SimGearScene PROPERTY FRAMEWORK 1)
|
|
||||||
# set_property(TARGET SimGearScene PROPERTY PUBLIC_HEADER "${publicHeaders}")
|
|
||||||
set_property(TARGET SimGearScene PROPERTY LINKER_LANGUAGE CXX)
|
set_property(TARGET SimGearScene PROPERTY LINKER_LANGUAGE CXX)
|
||||||
set_property(TARGET SimGearScene PROPERTY VERSION ${SIMGEAR_VERSION})
|
set_property(TARGET SimGearScene PROPERTY VERSION ${SIMGEAR_VERSION})
|
||||||
set_property(TARGET SimGearScene PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
|
set_property(TARGET SimGearScene PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
|
||||||
|
|
||||||
|
# EXPORT SimGearSceneConfig
|
||||||
|
install(TARGETS SimGearScene LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
|
||||||
|
# install(EXPORT SimGearSceneConfig DESTINATION share/SimGearScene)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(STATUS "Library building mode: STATIC LIBRARIES")
|
||||||
|
|
||||||
|
get_property(FG_GROUPS_CORE_SOURCES_C GLOBAL PROPERTY FG_GROUPS_CORE_SOURCES_C)
|
||||||
|
string(REPLACE "@" ";" groups ${FG_GROUPS_CORE_SOURCES_C} )
|
||||||
|
foreach(g ${groups})
|
||||||
|
string(REPLACE "#" ";" g2 ${g})
|
||||||
|
list(GET g2 0 name)
|
||||||
|
list(REMOVE_AT g2 0)
|
||||||
|
source_group("${name}\\Sources" FILES ${g2})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
get_property(FG_GROUPS_CORE_SOURCES_H GLOBAL PROPERTY FG_GROUPS_CORE_SOURCES_H)
|
||||||
|
string(REPLACE "@" ";" groups ${FG_GROUPS_CORE_SOURCES_H} )
|
||||||
|
foreach(g ${groups})
|
||||||
|
string(REPLACE "#" ";" g2 ${g})
|
||||||
|
list(GET g2 0 name)
|
||||||
|
list(REMOVE_AT g2 0)
|
||||||
|
source_group("${name}\\Headers" FILES ${g2})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_library(SimGearCore STATIC ${coreSources} ${localExpatSources})
|
||||||
|
install(TARGETS SimGearCore ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
|
||||||
|
if(NOT SIMGEAR_HEADLESS)
|
||||||
|
get_property(FG_GROUPS_SCENE_SOURCES_C GLOBAL PROPERTY FG_GROUPS_SCENE_SOURCES_C)
|
||||||
|
string(REPLACE "@" ";" groups ${FG_GROUPS_SCENE_SOURCES_C} )
|
||||||
|
foreach(g ${groups})
|
||||||
|
string(REPLACE "#" ";" g2 ${g})
|
||||||
|
list(GET g2 0 name)
|
||||||
|
list(REMOVE_AT g2 0)
|
||||||
|
source_group("${name}\\Sources" FILES ${g2})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
get_property(FG_GROUPS_SCENE_SOURCES_H GLOBAL PROPERTY FG_GROUPS_SCENE_SOURCES_H)
|
||||||
|
string(REPLACE "@" ";" groups ${FG_GROUPS_SCENE_SOURCES_H} )
|
||||||
|
foreach(g ${groups})
|
||||||
|
string(REPLACE "#" ";" g2 ${g})
|
||||||
|
list(GET g2 0 name)
|
||||||
|
list(REMOVE_AT g2 0)
|
||||||
|
source_group("${name}\\Headers" FILES ${g2})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_library(SimGearScene STATIC ${sceneSources})
|
||||||
|
install(TARGETS SimGearScene ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
endif(NOT SIMGEAR_HEADLESS)
|
||||||
|
endif(SIMGEAR_SHARED)
|
||||||
|
|
||||||
|
target_link_libraries(SimGearCore
|
||||||
|
${ZLIB_LIBRARY}
|
||||||
|
${RT_LIBRARY}
|
||||||
|
${DL_LIBRARY}
|
||||||
|
${EXPAT_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${CORE_SERVICES_LIBRARY})
|
||||||
|
|
||||||
|
if(NOT SIMGEAR_HEADLESS)
|
||||||
target_link_libraries(SimGearScene
|
target_link_libraries(SimGearScene
|
||||||
SimGearCore
|
SimGearCore
|
||||||
${ZLIB_LIBRARY}
|
${ZLIB_LIBRARY}
|
||||||
${OPENSCENEGRAPH_LIBRARIES}
|
${OPENSCENEGRAPH_LIBRARIES}
|
||||||
${OPENAL_LIBRARY} ${ALUT_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${OPENGL_LIBRARY})
|
${OPENGL_LIBRARY}
|
||||||
|
${JPEG_LIBRARY})
|
||||||
if(LIBSVN_FOUND)
|
|
||||||
target_link_libraries(SimGearScene ${LIBSVN_LIBRARIES})
|
|
||||||
endif(LIBSVN_FOUND)
|
|
||||||
|
|
||||||
install(TARGETS SimGearScene LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif(SIMGEAR_SHARED)
|
if(ENABLE_RTI)
|
||||||
|
# Ugly first aid to make hla compile agian
|
||||||
|
set_property(SOURCE hla/RTI13InteractionClass.cxx hla/RTI13ObjectClass.cxx
|
||||||
|
hla/RTI13ObjectInstance.cxx hla/RTI13Federate.cxx
|
||||||
|
hla/RTI13FederateFactory.cxx
|
||||||
|
APPEND PROPERTY COMPILE_FLAGS "-I${RTI_INCLUDE_DIR}")
|
||||||
|
endif(ENABLE_RTI)
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ std::string SGBucket::gen_base_path() const {
|
|||||||
main_lat *= -1;
|
main_lat *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(raw_path, "%c%03d%c%02d/%c%03d%c%02d",
|
snprintf(raw_path, 256, "%c%03d%c%02d/%c%03d%c%02d",
|
||||||
hem, top_lon, pole, top_lat,
|
hem, top_lon, pole, top_lat,
|
||||||
hem, main_lon, pole, main_lat);
|
hem, main_lon, pole, main_lat);
|
||||||
|
|
||||||
@@ -224,17 +224,6 @@ std::string SGBucket::gen_base_path() const {
|
|||||||
|
|
||||||
// return width of the tile in degrees
|
// return width of the tile in degrees
|
||||||
double SGBucket::get_width() const {
|
double SGBucket::get_width() const {
|
||||||
if (lon==-180 && (lat==-89 || lat==88) ) {
|
|
||||||
/* Normally the tile at 180W in 88N and 89S
|
|
||||||
* would cover 184W to 176W and the next
|
|
||||||
* on the east side starts at 176W.
|
|
||||||
* To correct, make this a special tile
|
|
||||||
* from 180W to 176W with 4 degrees width
|
|
||||||
* instead of the normal 8 degrees at
|
|
||||||
* that latitude.
|
|
||||||
*/
|
|
||||||
return 4.0;
|
|
||||||
}
|
|
||||||
return sg_bucket_span( get_center_lat() );
|
return sg_bucket_span( get_center_lat() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,4 +345,13 @@ void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy ) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sgGetBuckets( const SGGeod& min, const SGGeod& max, std::vector<SGBucket>& list ) {
|
||||||
|
double lon, lat, span;
|
||||||
|
|
||||||
|
for (lat = min.getLatitudeDeg(); lat <= max.getLatitudeDeg(); lat += SG_BUCKET_SPAN) {
|
||||||
|
span = sg_bucket_span( lat );
|
||||||
|
for (lon = min.getLongitudeDeg(); lon <= max.getLongitudeDeg(); lon += span) {
|
||||||
|
list.push_back( SGBucket(lon , lat) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include <cstdio> // sprintf()
|
#include <cstdio> // sprintf()
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* standard size of a bucket in degrees (1/8 of a degree)
|
* standard size of a bucket in degrees (1/8 of a degree)
|
||||||
@@ -57,9 +58,7 @@
|
|||||||
// return the horizontal tile span factor based on latitude
|
// return the horizontal tile span factor based on latitude
|
||||||
static double sg_bucket_span( double l ) {
|
static double sg_bucket_span( double l ) {
|
||||||
if ( l >= 89.0 ) {
|
if ( l >= 89.0 ) {
|
||||||
return 360.0;
|
return 12.0;
|
||||||
} else if ( l >= 88.0 ) {
|
|
||||||
return 8.0;
|
|
||||||
} else if ( l >= 86.0 ) {
|
} else if ( l >= 86.0 ) {
|
||||||
return 4.0;
|
return 4.0;
|
||||||
} else if ( l >= 83.0 ) {
|
} else if ( l >= 83.0 ) {
|
||||||
@@ -80,12 +79,10 @@ static double sg_bucket_span( double l ) {
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
} else if ( l >= -86.0 ) {
|
} else if ( l >= -86.0 ) {
|
||||||
return 2.0;
|
return 2.0;
|
||||||
} else if ( l >= -88.0 ) {
|
|
||||||
return 4.0;
|
|
||||||
} else if ( l >= -89.0 ) {
|
} else if ( l >= -89.0 ) {
|
||||||
return 8.0;
|
return 4.0;
|
||||||
} else {
|
} else {
|
||||||
return 360.0;
|
return 12.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,6 +323,15 @@ SGBucket sgBucketOffset( double dlon, double dlat, int x, int y );
|
|||||||
void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy );
|
void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \relates SGBucket
|
||||||
|
* retrieve a list of buckets in the given bounding box
|
||||||
|
* @param min min lon,lat of bounding box in degrees
|
||||||
|
* @param max max lon,lat of bounding box in degrees
|
||||||
|
* @param list standard vector of buckets within the bounding box
|
||||||
|
*/
|
||||||
|
void sgGetBuckets( const SGGeod& min, const SGGeod& max, std::vector<SGBucket>& list );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the bucket lon, lat, x, and y to the output stream.
|
* Write the bucket lon, lat, x, and y to the output stream.
|
||||||
* @param out output stream
|
* @param out output stream
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "BVHVisitor.hxx"
|
#include "BVHVisitor.hxx"
|
||||||
#include "BVHNode.hxx"
|
#include "BVHNode.hxx"
|
||||||
#include "BVHGroup.hxx"
|
#include "BVHGroup.hxx"
|
||||||
|
#include "BVHPageNode.hxx"
|
||||||
#include "BVHTransform.hxx"
|
#include "BVHTransform.hxx"
|
||||||
#include "BVHMotionTransform.hxx"
|
#include "BVHMotionTransform.hxx"
|
||||||
#include "BVHLineGeometry.hxx"
|
#include "BVHLineGeometry.hxx"
|
||||||
@@ -45,6 +46,8 @@ public:
|
|||||||
|
|
||||||
virtual void apply(BVHGroup& node)
|
virtual void apply(BVHGroup& node)
|
||||||
{ expandBy(node.getBoundingSphere()); }
|
{ expandBy(node.getBoundingSphere()); }
|
||||||
|
virtual void apply(BVHPageNode& node)
|
||||||
|
{ expandBy(node.getBoundingSphere()); }
|
||||||
virtual void apply(BVHTransform& node)
|
virtual void apply(BVHTransform& node)
|
||||||
{ expandBy(node.getBoundingSphere()); }
|
{ expandBy(node.getBoundingSphere()); }
|
||||||
virtual void apply(BVHMotionTransform& node)
|
virtual void apply(BVHMotionTransform& node)
|
||||||
+13
-1
@@ -15,7 +15,10 @@
|
|||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <simgear_config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "BVHLineSegmentVisitor.hxx"
|
#include "BVHLineSegmentVisitor.hxx"
|
||||||
|
|
||||||
#include <simgear/math/SGGeometry.hxx>
|
#include <simgear/math/SGGeometry.hxx>
|
||||||
@@ -24,6 +27,7 @@
|
|||||||
|
|
||||||
#include "BVHNode.hxx"
|
#include "BVHNode.hxx"
|
||||||
#include "BVHGroup.hxx"
|
#include "BVHGroup.hxx"
|
||||||
|
#include "BVHPageNode.hxx"
|
||||||
#include "BVHTransform.hxx"
|
#include "BVHTransform.hxx"
|
||||||
#include "BVHMotionTransform.hxx"
|
#include "BVHMotionTransform.hxx"
|
||||||
#include "BVHLineGeometry.hxx"
|
#include "BVHLineGeometry.hxx"
|
||||||
@@ -45,6 +49,14 @@ BVHLineSegmentVisitor::apply(BVHGroup& group)
|
|||||||
group.traverse(*this);
|
group.traverse(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BVHLineSegmentVisitor::apply(BVHPageNode& pageNode)
|
||||||
|
{
|
||||||
|
if (!intersects(_lineSegment, pageNode.getBoundingSphere()))
|
||||||
|
return;
|
||||||
|
pageNode.traverse(*this);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BVHLineSegmentVisitor::apply(BVHTransform& transform)
|
BVHLineSegmentVisitor::apply(BVHTransform& transform)
|
||||||
{
|
{
|
||||||
@@ -20,13 +20,14 @@
|
|||||||
|
|
||||||
#include <simgear/math/SGGeometry.hxx>
|
#include <simgear/math/SGGeometry.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
#include <simgear/scene/material/mat.hxx>
|
|
||||||
|
|
||||||
#include "BVHVisitor.hxx"
|
#include "BVHVisitor.hxx"
|
||||||
#include "BVHNode.hxx"
|
#include "BVHNode.hxx"
|
||||||
|
|
||||||
namespace simgear {
|
namespace simgear {
|
||||||
|
|
||||||
|
class BVHMaterial;
|
||||||
|
|
||||||
class BVHLineSegmentVisitor : public BVHVisitor {
|
class BVHLineSegmentVisitor : public BVHVisitor {
|
||||||
public:
|
public:
|
||||||
BVHLineSegmentVisitor(const SGLineSegmentd& lineSegment,
|
BVHLineSegmentVisitor(const SGLineSegmentd& lineSegment,
|
||||||
@@ -54,12 +55,13 @@ public:
|
|||||||
{ return _linearVelocity; }
|
{ return _linearVelocity; }
|
||||||
const SGVec3d& getAngularVelocity() const
|
const SGVec3d& getAngularVelocity() const
|
||||||
{ return _angularVelocity; }
|
{ return _angularVelocity; }
|
||||||
const SGMaterial* getMaterial() const
|
const BVHMaterial* getMaterial() const
|
||||||
{ return _material; }
|
{ return _material; }
|
||||||
BVHNode::Id getId() const
|
BVHNode::Id getId() const
|
||||||
{ return _id; }
|
{ return _id; }
|
||||||
|
|
||||||
virtual void apply(BVHGroup& group);
|
virtual void apply(BVHGroup& group);
|
||||||
|
virtual void apply(BVHPageNode& node);
|
||||||
virtual void apply(BVHTransform& transform);
|
virtual void apply(BVHTransform& transform);
|
||||||
virtual void apply(BVHMotionTransform& transform);
|
virtual void apply(BVHMotionTransform& transform);
|
||||||
virtual void apply(BVHLineGeometry&);
|
virtual void apply(BVHLineGeometry&);
|
||||||
@@ -87,7 +89,7 @@ private:
|
|||||||
SGVec3d _normal;
|
SGVec3d _normal;
|
||||||
SGVec3d _linearVelocity;
|
SGVec3d _linearVelocity;
|
||||||
SGVec3d _angularVelocity;
|
SGVec3d _angularVelocity;
|
||||||
const SGMaterial* _material;
|
const BVHMaterial* _material;
|
||||||
BVHNode::Id _id;
|
BVHNode::Id _id;
|
||||||
|
|
||||||
bool _haveHit;
|
bool _haveHit;
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
// PathOptions.hxx -- make an osgDB Options object from a path
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
// Copyright (C) 2007 Tim Moore timoore@redhat.com
|
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
// modify it under the terms of the GNU Library General Public
|
||||||
@@ -15,17 +14,22 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
// $Id$
|
|
||||||
|
|
||||||
#ifndef PATHOPTIONSHXX
|
#include "BVHMaterial.hxx"
|
||||||
#define PATHOPTIONSHXX 1
|
|
||||||
|
|
||||||
#include <osgDB/ReaderWriter>
|
namespace simgear {
|
||||||
#include <simgear/misc/sg_path.hxx>
|
|
||||||
|
|
||||||
namespace simgear
|
BVHMaterial::BVHMaterial() :
|
||||||
|
_solid(true),
|
||||||
|
_friction_factor(1),
|
||||||
|
_rolling_friction(0.02),
|
||||||
|
_bumpiness(0),
|
||||||
|
_load_resistance(1e30)
|
||||||
{
|
{
|
||||||
osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath&);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
BVHMaterial::~BVHMaterial()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BVHMaterial_hxx
|
||||||
|
#define BVHMaterial_hxx
|
||||||
|
|
||||||
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
|
|
||||||
|
namespace simgear {
|
||||||
|
|
||||||
|
class BVHMaterial : public SGReferenced {
|
||||||
|
public:
|
||||||
|
BVHMaterial();
|
||||||
|
virtual ~BVHMaterial();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if the surface material is solid, if it is not solid, a fluid
|
||||||
|
* can be assumed, that is usually water.
|
||||||
|
*/
|
||||||
|
bool get_solid () const { return _solid; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the friction factor for that material
|
||||||
|
*/
|
||||||
|
double get_friction_factor () const { return _friction_factor; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the rolling friction for that material
|
||||||
|
*/
|
||||||
|
double get_rolling_friction () const { return _rolling_friction; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bumpines for that material
|
||||||
|
*/
|
||||||
|
double get_bumpiness () const { return _bumpiness; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the load resistance
|
||||||
|
*/
|
||||||
|
double get_load_resistance () const { return _load_resistance; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// True if the material is solid, false if it is a fluid
|
||||||
|
bool _solid;
|
||||||
|
|
||||||
|
// the friction factor of that surface material
|
||||||
|
double _friction_factor;
|
||||||
|
|
||||||
|
// the rolling friction of that surface material
|
||||||
|
double _rolling_friction;
|
||||||
|
|
||||||
|
// the bumpiness of that surface material
|
||||||
|
double _bumpiness;
|
||||||
|
|
||||||
|
// the load resistance of that surface material
|
||||||
|
double _load_resistance;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+9
-2
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "BVHNode.hxx"
|
#include "BVHNode.hxx"
|
||||||
#include "BVHGroup.hxx"
|
#include "BVHGroup.hxx"
|
||||||
|
#include "BVHPageNode.hxx"
|
||||||
#include "BVHTransform.hxx"
|
#include "BVHTransform.hxx"
|
||||||
#include "BVHLineGeometry.hxx"
|
#include "BVHLineGeometry.hxx"
|
||||||
#include "BVHStaticGeometry.hxx"
|
#include "BVHStaticGeometry.hxx"
|
||||||
@@ -52,6 +53,12 @@ public:
|
|||||||
return;
|
return;
|
||||||
leaf.traverse(*this);
|
leaf.traverse(*this);
|
||||||
}
|
}
|
||||||
|
virtual void apply(BVHPageNode& leaf)
|
||||||
|
{
|
||||||
|
if (!intersects(_sphere, leaf.getBoundingSphere()))
|
||||||
|
return;
|
||||||
|
leaf.traverse(*this);
|
||||||
|
}
|
||||||
virtual void apply(BVHTransform& transform)
|
virtual void apply(BVHTransform& transform)
|
||||||
{
|
{
|
||||||
if (!intersects(_sphere, transform.getBoundingSphere()))
|
if (!intersects(_sphere, transform.getBoundingSphere()))
|
||||||
@@ -140,7 +147,7 @@ public:
|
|||||||
{ return _linearVelocity; }
|
{ return _linearVelocity; }
|
||||||
const SGVec3d& getAngularVelocity() const
|
const SGVec3d& getAngularVelocity() const
|
||||||
{ return _angularVelocity; }
|
{ return _angularVelocity; }
|
||||||
const SGMaterial* getMaterial() const
|
const BVHMaterial* getMaterial() const
|
||||||
{ return _material; }
|
{ return _material; }
|
||||||
BVHNode::Id getId() const
|
BVHNode::Id getId() const
|
||||||
{ return _id; }
|
{ return _id; }
|
||||||
@@ -155,7 +162,7 @@ private:
|
|||||||
SGVec3d _point;
|
SGVec3d _point;
|
||||||
SGVec3d _linearVelocity;
|
SGVec3d _linearVelocity;
|
||||||
SGVec3d _angularVelocity;
|
SGVec3d _angularVelocity;
|
||||||
const SGMaterial* _material;
|
const BVHMaterial* _material;
|
||||||
BVHNode::Id _id;
|
BVHNode::Id _id;
|
||||||
|
|
||||||
bool _havePoint;
|
bool _havePoint;
|
||||||
@@ -26,6 +26,7 @@ namespace simgear {
|
|||||||
|
|
||||||
class BVHGroup;
|
class BVHGroup;
|
||||||
class BVHVisitor;
|
class BVHVisitor;
|
||||||
|
class BVHPageNode;
|
||||||
|
|
||||||
// Base for the tree nodes
|
// Base for the tree nodes
|
||||||
class BVHNode : public SGReferenced {
|
class BVHNode : public SGReferenced {
|
||||||
@@ -55,6 +56,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class BVHGroup;
|
friend class BVHGroup;
|
||||||
|
friend class BVHPageNode;
|
||||||
void addParent(BVHNode* parent);
|
void addParent(BVHNode* parent);
|
||||||
void removeParent(BVHNode* parent);
|
void removeParent(BVHNode* parent);
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "BVHPageNode.hxx"
|
||||||
|
|
||||||
|
#include "BVHPager.hxx"
|
||||||
|
|
||||||
|
namespace simgear {
|
||||||
|
|
||||||
|
BVHPageNode::BVHPageNode() :
|
||||||
|
_useStamp(0),
|
||||||
|
_requested(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BVHPageNode::~BVHPageNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BVHPageNode::accept(BVHVisitor& visitor)
|
||||||
|
{
|
||||||
|
visitor.apply(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BVHPageNode_hxx
|
||||||
|
#define BVHPageNode_hxx
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
|
#include "BVHGroup.hxx"
|
||||||
|
#include "BVHVisitor.hxx"
|
||||||
|
|
||||||
|
namespace simgear {
|
||||||
|
|
||||||
|
class BVHPager;
|
||||||
|
class BVHPageRequest;
|
||||||
|
|
||||||
|
class BVHPageNode : public BVHGroup {
|
||||||
|
public:
|
||||||
|
BVHPageNode();
|
||||||
|
virtual ~BVHPageNode();
|
||||||
|
|
||||||
|
virtual void accept(BVHVisitor& visitor);
|
||||||
|
|
||||||
|
/// Return the usage stamp of the last access
|
||||||
|
unsigned getUseStamp() const
|
||||||
|
{ return _useStamp; }
|
||||||
|
|
||||||
|
virtual SGSphered computeBoundingSphere() const = 0;
|
||||||
|
|
||||||
|
virtual BVHPageRequest* newRequest() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void invalidateBound() = 0;
|
||||||
|
|
||||||
|
bool getRequested() const
|
||||||
|
{ return _requested; }
|
||||||
|
void setRequested(bool requested)
|
||||||
|
{ _requested = requested; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class BVHPager;
|
||||||
|
|
||||||
|
std::list<SGSharedPtr<BVHPageNode> >::iterator _iterator;
|
||||||
|
unsigned _useStamp;
|
||||||
|
bool _requested;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "BVHPageRequest.hxx"
|
||||||
|
|
||||||
|
namespace simgear {
|
||||||
|
|
||||||
|
BVHPageRequest::~BVHPageRequest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BVHPageRequest_hxx
|
||||||
|
#define BVHPageRequest_hxx
|
||||||
|
|
||||||
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
|
|
||||||
|
namespace simgear {
|
||||||
|
|
||||||
|
class BVHPageNode;
|
||||||
|
|
||||||
|
class BVHPageRequest : public SGReferenced {
|
||||||
|
public:
|
||||||
|
virtual ~BVHPageRequest();
|
||||||
|
|
||||||
|
/// Happens in the pager thread, do not modify the calling bvh tree
|
||||||
|
virtual void load() = 0;
|
||||||
|
/// Happens in the bvh main thread where the bvh is actually used.
|
||||||
|
/// So inside here it is safe to modify the paged node
|
||||||
|
virtual void insert() = 0;
|
||||||
|
/// The page node this request is for
|
||||||
|
virtual BVHPageNode* getPageNode() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "BVHPager.hxx"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
#include <simgear/threads/SGThread.hxx>
|
||||||
|
#include <simgear/threads/SGGuard.hxx>
|
||||||
|
|
||||||
|
#include "BVHPageNode.hxx"
|
||||||
|
#include "BVHPageRequest.hxx"
|
||||||
|
|
||||||
|
namespace simgear {
|
||||||
|
|
||||||
|
struct BVHPager::_PrivateData : protected SGThread {
|
||||||
|
typedef SGSharedPtr<BVHPageRequest> _Request;
|
||||||
|
typedef std::list<_Request> _RequestList;
|
||||||
|
typedef std::list<SGSharedPtr<BVHPageNode> > _PageNodeList;
|
||||||
|
|
||||||
|
struct _LockedQueue {
|
||||||
|
void _push(const _Request& request)
|
||||||
|
{
|
||||||
|
SGGuard<SGMutex> scopeLock(_mutex);
|
||||||
|
_requestList.push_back(request);
|
||||||
|
}
|
||||||
|
_Request _pop()
|
||||||
|
{
|
||||||
|
SGGuard<SGMutex> scopeLock(_mutex);
|
||||||
|
if (_requestList.empty())
|
||||||
|
return _Request();
|
||||||
|
_Request request;
|
||||||
|
request.swap(_requestList.front());
|
||||||
|
_requestList.pop_front();
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
SGMutex _mutex;
|
||||||
|
_RequestList _requestList;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _WorkQueue {
|
||||||
|
void _stop()
|
||||||
|
{
|
||||||
|
_push(_Request());
|
||||||
|
}
|
||||||
|
void _push(const _Request& request)
|
||||||
|
{
|
||||||
|
SGGuard<SGMutex> scopeLock(_mutex);
|
||||||
|
bool needSignal = _requestList.empty();
|
||||||
|
_requestList.push_back(request);
|
||||||
|
if (needSignal)
|
||||||
|
_waitCondition.signal();
|
||||||
|
}
|
||||||
|
_Request _pop()
|
||||||
|
{
|
||||||
|
SGGuard<SGMutex> scopeLock(_mutex);
|
||||||
|
while (_requestList.empty())
|
||||||
|
_waitCondition.wait(_mutex);
|
||||||
|
_Request request;
|
||||||
|
request.swap(_requestList.front());
|
||||||
|
_requestList.pop_front();
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
SGMutex _mutex;
|
||||||
|
SGWaitCondition _waitCondition;
|
||||||
|
_RequestList _requestList;
|
||||||
|
};
|
||||||
|
|
||||||
|
_PrivateData() :
|
||||||
|
_started(false),
|
||||||
|
_useStamp(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~_PrivateData()
|
||||||
|
{
|
||||||
|
_stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void run()
|
||||||
|
{
|
||||||
|
for (;;) {
|
||||||
|
_Request request = _pendingRequests._pop();
|
||||||
|
// This means stop working
|
||||||
|
if (!request.valid())
|
||||||
|
return;
|
||||||
|
request->load();
|
||||||
|
_processedRequests._push(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _start()
|
||||||
|
{
|
||||||
|
if (_started)
|
||||||
|
return true;
|
||||||
|
if (!start())
|
||||||
|
return false;
|
||||||
|
_started = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stop()
|
||||||
|
{
|
||||||
|
if (!_started)
|
||||||
|
return;
|
||||||
|
// send a stop request ...
|
||||||
|
_pendingRequests._stop();
|
||||||
|
// ... and wait for the thread to finish
|
||||||
|
join();
|
||||||
|
_started = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _use(BVHPageNode& pageNode)
|
||||||
|
{
|
||||||
|
if (pageNode._requested) {
|
||||||
|
// move it forward in the lru list
|
||||||
|
_pageNodeList.splice(_pageNodeList.end(), _pageNodeList,
|
||||||
|
pageNode._iterator);
|
||||||
|
} else {
|
||||||
|
_Request request = pageNode.newRequest();
|
||||||
|
if (!request.valid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
pageNode._iterator = _pageNodeList.insert(_pageNodeList.end(),
|
||||||
|
&pageNode);
|
||||||
|
pageNode._requested = true;
|
||||||
|
|
||||||
|
if (_started) {
|
||||||
|
_pendingRequests._push(request);
|
||||||
|
} else {
|
||||||
|
request->load();
|
||||||
|
request->insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pageNode._useStamp = _useStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _update(unsigned expiry)
|
||||||
|
{
|
||||||
|
// Insert all processed requests
|
||||||
|
for (;;) {
|
||||||
|
SGSharedPtr<BVHPageRequest> request;
|
||||||
|
request = _processedRequests._pop();
|
||||||
|
if (!request.valid())
|
||||||
|
break;
|
||||||
|
request->insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... and throw away stuff that is not used for a long time
|
||||||
|
unsigned useStamp = _useStamp - expiry;
|
||||||
|
_PageNodeList::iterator i = _pageNodeList.begin();
|
||||||
|
while (i != _pageNodeList.end()) {
|
||||||
|
// Ok, this means if the highest bit in the below difference
|
||||||
|
// is set which is aequivalent to having a negative difference
|
||||||
|
// but being wraparound save.
|
||||||
|
unsigned diff = (*i)->_useStamp - useStamp;
|
||||||
|
// test the sign bit of the difference
|
||||||
|
if (!(diff & (~((~0u) >> 1))))
|
||||||
|
break;
|
||||||
|
(*i)->clear();
|
||||||
|
(*i)->_requested = false;
|
||||||
|
i = _pageNodeList.erase(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _started;
|
||||||
|
unsigned _useStamp;
|
||||||
|
_WorkQueue _pendingRequests;
|
||||||
|
_LockedQueue _processedRequests;
|
||||||
|
// Store the rcu list of loaded nodes so that they can expire
|
||||||
|
_PageNodeList _pageNodeList;
|
||||||
|
};
|
||||||
|
|
||||||
|
BVHPager::BVHPager() :
|
||||||
|
_privateData(new _PrivateData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BVHPager::~BVHPager()
|
||||||
|
{
|
||||||
|
delete _privateData;
|
||||||
|
_privateData = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BVHPager::start()
|
||||||
|
{
|
||||||
|
return _privateData->_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BVHPager::stop()
|
||||||
|
{
|
||||||
|
_privateData->_stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BVHPager::use(BVHPageNode& pageNode)
|
||||||
|
{
|
||||||
|
_privateData->_use(pageNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BVHPager::update(unsigned expiry)
|
||||||
|
{
|
||||||
|
_privateData->_update(expiry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BVHPager::setUseStamp(unsigned stamp)
|
||||||
|
{
|
||||||
|
_privateData->_useStamp = stamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned
|
||||||
|
BVHPager::getUseStamp() const
|
||||||
|
{
|
||||||
|
return _privateData->_useStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BVHPager_hxx
|
||||||
|
#define BVHPager_hxx
|
||||||
|
|
||||||
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
|
namespace simgear {
|
||||||
|
|
||||||
|
class BVHPageNode;
|
||||||
|
class BVHPageRequest;
|
||||||
|
|
||||||
|
class BVHPager {
|
||||||
|
public:
|
||||||
|
BVHPager();
|
||||||
|
~BVHPager();
|
||||||
|
|
||||||
|
/// Starts the pager thread
|
||||||
|
bool start();
|
||||||
|
|
||||||
|
/// Stops the pager thread
|
||||||
|
void stop();
|
||||||
|
|
||||||
|
/// Use this page node, if loaded make it as used, if not loaded schedule
|
||||||
|
void use(BVHPageNode& pageNode);
|
||||||
|
|
||||||
|
/// Call this from the main thread to incorporate the processed page
|
||||||
|
/// requests into the bounding volume tree
|
||||||
|
void update(unsigned expiry);
|
||||||
|
|
||||||
|
/// The usage stamp to mark usage of BVHPageNodes
|
||||||
|
void setUseStamp(unsigned stamp);
|
||||||
|
unsigned getUseStamp() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BVHPager(const BVHPager&);
|
||||||
|
BVHPager& operator=(const BVHPager&);
|
||||||
|
|
||||||
|
struct _PrivateData;
|
||||||
|
_PrivateData* _privateData;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -22,11 +22,7 @@
|
|||||||
#include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
#include <simgear/math/SGGeometry.hxx>
|
#include <simgear/math/SGGeometry.hxx>
|
||||||
|
#include "BVHMaterial.hxx"
|
||||||
/// FIXME, the SGMaterial class is too much tied to the scenegraph aspects of
|
|
||||||
/// the materials. Use some class more decribing the
|
|
||||||
/// nature of the surface we live on ...
|
|
||||||
class SGMaterial;
|
|
||||||
|
|
||||||
namespace simgear {
|
namespace simgear {
|
||||||
|
|
||||||
@@ -40,20 +36,20 @@ public:
|
|||||||
{ return _vertices[i]; }
|
{ return _vertices[i]; }
|
||||||
|
|
||||||
|
|
||||||
unsigned addMaterial(const SGMaterial* material)
|
unsigned addMaterial(const BVHMaterial* material)
|
||||||
{ _materials.push_back(material); return _materials.size() - 1; }
|
{ _materials.push_back(material); return _materials.size() - 1; }
|
||||||
const SGMaterial* getMaterial(unsigned i) const
|
const BVHMaterial* getMaterial(unsigned i) const
|
||||||
{ if (_materials.size() <= i) return 0; return _materials[i]; }
|
{ if (_materials.size() <= i) return 0; return _materials[i]; }
|
||||||
|
|
||||||
void trim()
|
void trim()
|
||||||
{
|
{
|
||||||
std::vector<SGVec3f>(_vertices).swap(_vertices);
|
std::vector<SGVec3f>(_vertices).swap(_vertices);
|
||||||
std::vector<const SGMaterial*>(_materials).swap(_materials);
|
std::vector<SGSharedPtr<const BVHMaterial> >(_materials).swap(_materials);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SGVec3f> _vertices;
|
std::vector<SGVec3f> _vertices;
|
||||||
std::vector<const SGMaterial*> _materials;
|
std::vector<SGSharedPtr<const BVHMaterial> > _materials;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
+5
-5
@@ -78,16 +78,16 @@ public:
|
|||||||
typedef std::set<SGVec3<unsigned> > TriangleSet;
|
typedef std::set<SGVec3<unsigned> > TriangleSet;
|
||||||
TriangleSet _triangleSet;
|
TriangleSet _triangleSet;
|
||||||
|
|
||||||
void setCurrentMaterial(const SGMaterial* material)
|
void setCurrentMaterial(const BVHMaterial* material)
|
||||||
{
|
{
|
||||||
_currentMaterial = material;
|
_currentMaterial = material;
|
||||||
_currentMaterialIndex = addMaterial(material);
|
_currentMaterialIndex = addMaterial(material);
|
||||||
}
|
}
|
||||||
const SGMaterial* getCurrentMaterial() const
|
const BVHMaterial* getCurrentMaterial() const
|
||||||
{
|
{
|
||||||
return _currentMaterial;
|
return _currentMaterial;
|
||||||
}
|
}
|
||||||
unsigned addMaterial(const SGMaterial* material)
|
unsigned addMaterial(const BVHMaterial* material)
|
||||||
{
|
{
|
||||||
MaterialMap::const_iterator i = _materialMap.find(material);
|
MaterialMap::const_iterator i = _materialMap.find(material);
|
||||||
if (i != _materialMap.end())
|
if (i != _materialMap.end())
|
||||||
@@ -97,9 +97,9 @@ public:
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::map<const SGMaterial*, unsigned> MaterialMap;
|
typedef std::map<const BVHMaterial*, unsigned> MaterialMap;
|
||||||
MaterialMap _materialMap;
|
MaterialMap _materialMap;
|
||||||
const SGMaterial* _currentMaterial;
|
const BVHMaterial* _currentMaterial;
|
||||||
unsigned _currentMaterialIndex;
|
unsigned _currentMaterialIndex;
|
||||||
|
|
||||||
void addTriangle(const SGVec3f& v1, const SGVec3f& v2, const SGVec3f& v3)
|
void addTriangle(const SGVec3f& v1, const SGVec3f& v2, const SGVec3f& v3)
|
||||||
@@ -59,6 +59,22 @@ BVHSubTreeCollector::apply(BVHGroup& group)
|
|||||||
popNodeList(parentNodeList);
|
popNodeList(parentNodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BVHSubTreeCollector::apply(BVHPageNode& group)
|
||||||
|
{
|
||||||
|
if (!intersects(_sphere, group.getBoundingSphere()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// The _nodeList content is somehow the 'return value' of the subtree.
|
||||||
|
// Set it to zero to see if we have something to collect down there.
|
||||||
|
NodeList parentNodeList;
|
||||||
|
pushNodeList(parentNodeList);
|
||||||
|
|
||||||
|
group.traverse(*this);
|
||||||
|
|
||||||
|
popNodeList(parentNodeList);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BVHSubTreeCollector::apply(BVHTransform& transform)
|
BVHSubTreeCollector::apply(BVHTransform& transform)
|
||||||
{
|
{
|
||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
virtual ~BVHSubTreeCollector();
|
virtual ~BVHSubTreeCollector();
|
||||||
|
|
||||||
virtual void apply(BVHGroup&);
|
virtual void apply(BVHGroup&);
|
||||||
|
virtual void apply(BVHPageNode&);
|
||||||
virtual void apply(BVHTransform&);
|
virtual void apply(BVHTransform&);
|
||||||
virtual void apply(BVHMotionTransform&);
|
virtual void apply(BVHMotionTransform&);
|
||||||
virtual void apply(BVHLineGeometry&);
|
virtual void apply(BVHLineGeometry&);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2008 - 2009 Mathias Froehlich - Mathias.Froehlich@web.de
|
// Copyright (C) 2008 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
// modify it under the terms of the GNU Library General Public
|
||||||
@@ -23,6 +23,7 @@ namespace simgear {
|
|||||||
class BVHStaticData;
|
class BVHStaticData;
|
||||||
|
|
||||||
class BVHGroup;
|
class BVHGroup;
|
||||||
|
class BVHPageNode;
|
||||||
class BVHTransform;
|
class BVHTransform;
|
||||||
class BVHMotionTransform;
|
class BVHMotionTransform;
|
||||||
class BVHStaticGeometry;
|
class BVHStaticGeometry;
|
||||||
@@ -41,6 +42,7 @@ public:
|
|||||||
|
|
||||||
// High level nodes to handle
|
// High level nodes to handle
|
||||||
virtual void apply(BVHGroup&) = 0;
|
virtual void apply(BVHGroup&) = 0;
|
||||||
|
virtual void apply(BVHPageNode&) = 0;
|
||||||
virtual void apply(BVHTransform&) = 0;
|
virtual void apply(BVHTransform&) = 0;
|
||||||
virtual void apply(BVHMotionTransform&) = 0;
|
virtual void apply(BVHMotionTransform&) = 0;
|
||||||
virtual void apply(BVHLineGeometry&) = 0;
|
virtual void apply(BVHLineGeometry&) = 0;
|
||||||
@@ -2,13 +2,15 @@ include (SimGearComponent)
|
|||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
BVHBoundingBoxVisitor.hxx
|
BVHBoundingBoxVisitor.hxx
|
||||||
BVHDebugCollectVisitor.hxx
|
|
||||||
BVHGroup.hxx
|
BVHGroup.hxx
|
||||||
BVHLineGeometry.hxx
|
BVHLineGeometry.hxx
|
||||||
BVHLineSegmentVisitor.hxx
|
BVHLineSegmentVisitor.hxx
|
||||||
BVHMotionTransform.hxx
|
BVHMotionTransform.hxx
|
||||||
BVHNearestPointVisitor.hxx
|
BVHNearestPointVisitor.hxx
|
||||||
BVHNode.hxx
|
BVHNode.hxx
|
||||||
|
BVHPageNode.hxx
|
||||||
|
BVHPageRequest.hxx
|
||||||
|
BVHPager.hxx
|
||||||
BVHStaticBinary.hxx
|
BVHStaticBinary.hxx
|
||||||
BVHStaticData.hxx
|
BVHStaticData.hxx
|
||||||
BVHStaticGeometry.hxx
|
BVHStaticGeometry.hxx
|
||||||
@@ -17,6 +19,7 @@ set(HEADERS
|
|||||||
BVHStaticNode.hxx
|
BVHStaticNode.hxx
|
||||||
BVHStaticTriangle.hxx
|
BVHStaticTriangle.hxx
|
||||||
BVHSubTreeCollector.hxx
|
BVHSubTreeCollector.hxx
|
||||||
|
BVHMaterial.hxx
|
||||||
BVHTransform.hxx
|
BVHTransform.hxx
|
||||||
BVHVisitor.hxx
|
BVHVisitor.hxx
|
||||||
)
|
)
|
||||||
@@ -27,13 +30,23 @@ set(SOURCES
|
|||||||
BVHLineSegmentVisitor.cxx
|
BVHLineSegmentVisitor.cxx
|
||||||
BVHMotionTransform.cxx
|
BVHMotionTransform.cxx
|
||||||
BVHNode.cxx
|
BVHNode.cxx
|
||||||
|
BVHPageNode.cxx
|
||||||
|
BVHPageRequest.cxx
|
||||||
|
BVHPager.cxx
|
||||||
BVHStaticBinary.cxx
|
BVHStaticBinary.cxx
|
||||||
BVHStaticGeometry.cxx
|
BVHStaticGeometry.cxx
|
||||||
BVHStaticLeaf.cxx
|
BVHStaticLeaf.cxx
|
||||||
BVHStaticNode.cxx
|
BVHStaticNode.cxx
|
||||||
BVHStaticTriangle.cxx
|
BVHStaticTriangle.cxx
|
||||||
BVHSubTreeCollector.cxx
|
BVHSubTreeCollector.cxx
|
||||||
|
BVHMaterial.cxx
|
||||||
BVHTransform.cxx
|
BVHTransform.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
simgear_scene_component(bvh scene/bvh "${SOURCES}" "${HEADERS}")
|
simgear_component(bvh bvh "${SOURCES}" "${HEADERS}")
|
||||||
|
|
||||||
|
if(ENABLE_TESTS)
|
||||||
|
add_executable(bvhtest bvhtest.cxx)
|
||||||
|
target_link_libraries(bvhtest SimGearCore)
|
||||||
|
add_test(bvhtest ${EXECUTABLE_OUTPUT_PATH}/bvhtest)
|
||||||
|
endif(ENABLE_TESTS)
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
include (SimGearComponent)
|
||||||
|
|
||||||
|
set(HEADERS
|
||||||
|
canvas_fwd.hxx
|
||||||
|
Canvas.hxx
|
||||||
|
CanvasEvent.hxx
|
||||||
|
CanvasEventManager.hxx
|
||||||
|
CanvasEventTypes.hxx
|
||||||
|
CanvasEventVisitor.hxx
|
||||||
|
CanvasMgr.hxx
|
||||||
|
CanvasObjectPlacement.hxx
|
||||||
|
CanvasPlacement.hxx
|
||||||
|
CanvasSystemAdapter.hxx
|
||||||
|
MouseEvent.hxx
|
||||||
|
ODGauge.hxx
|
||||||
|
VGInitOperation.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
set(SOURCES
|
||||||
|
Canvas.cxx
|
||||||
|
CanvasEvent.cxx
|
||||||
|
CanvasEventManager.cxx
|
||||||
|
CanvasEventVisitor.cxx
|
||||||
|
CanvasMgr.cxx
|
||||||
|
CanvasObjectPlacement.cxx
|
||||||
|
CanvasPlacement.cxx
|
||||||
|
ODGauge.cxx
|
||||||
|
VGInitOperation.cxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(ShivaVG/src)
|
||||||
|
add_subdirectory(elements)
|
||||||
|
|
||||||
|
simgear_scene_component(canvas canvas "${SOURCES}" "${HEADERS}")
|
||||||
@@ -0,0 +1,662 @@
|
|||||||
|
// The canvas for rendering with the 2d API
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#include "Canvas.hxx"
|
||||||
|
#include "CanvasEventManager.hxx"
|
||||||
|
#include "CanvasEventVisitor.hxx"
|
||||||
|
#include <simgear/canvas/MouseEvent.hxx>
|
||||||
|
#include <simgear/canvas/CanvasPlacement.hxx>
|
||||||
|
#include <simgear/scene/util/parse_color.hxx>
|
||||||
|
#include <simgear/scene/util/RenderConstants.hxx>
|
||||||
|
|
||||||
|
#include <osg/Camera>
|
||||||
|
#include <osg/Geode>
|
||||||
|
#include <osgText/Text>
|
||||||
|
#include <osgViewer/Viewer>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Canvas::CullCallback::CullCallback(const CanvasWeakPtr& canvas):
|
||||||
|
_canvas( canvas )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::CullCallback::operator()( osg::Node* node,
|
||||||
|
osg::NodeVisitor* nv )
|
||||||
|
{
|
||||||
|
if( (nv->getTraversalMask() & simgear::MODEL_BIT) && !_canvas.expired() )
|
||||||
|
_canvas.lock()->enableRendering();
|
||||||
|
|
||||||
|
traverse(node, nv);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Canvas::Canvas(SGPropertyNode* node):
|
||||||
|
PropertyBasedElement(node),
|
||||||
|
_canvas_mgr(0),
|
||||||
|
_event_manager(new EventManager),
|
||||||
|
_size_x(-1),
|
||||||
|
_size_y(-1),
|
||||||
|
_view_width(-1),
|
||||||
|
_view_height(-1),
|
||||||
|
_status(node, "status"),
|
||||||
|
_status_msg(node, "status-msg"),
|
||||||
|
_sampling_dirty(false),
|
||||||
|
_render_dirty(true),
|
||||||
|
_visible(true),
|
||||||
|
_render_always(false)
|
||||||
|
{
|
||||||
|
_status = 0;
|
||||||
|
setStatusFlags(MISSING_SIZE_X | MISSING_SIZE_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Canvas::~Canvas()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::onDestroy()
|
||||||
|
{
|
||||||
|
if( _root_group )
|
||||||
|
{
|
||||||
|
_root_group->clearEventListener();
|
||||||
|
_root_group->onDestroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setCanvasMgr(CanvasMgr* canvas_mgr)
|
||||||
|
{
|
||||||
|
_canvas_mgr = canvas_mgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
CanvasMgr* Canvas::getCanvasMgr() const
|
||||||
|
{
|
||||||
|
return _canvas_mgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool Canvas::isInit() const
|
||||||
|
{
|
||||||
|
return _texture.serviceable();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::addParentCanvas(const CanvasWeakPtr& canvas)
|
||||||
|
{
|
||||||
|
if( canvas.expired() )
|
||||||
|
{
|
||||||
|
SG_LOG
|
||||||
|
(
|
||||||
|
SG_GENERAL,
|
||||||
|
SG_WARN,
|
||||||
|
"Canvas::addParentCanvas(" << _node->getPath(true) << "): "
|
||||||
|
"got an expired parent!"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_parent_canvases.insert(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::addChildCanvas(const CanvasWeakPtr& canvas)
|
||||||
|
{
|
||||||
|
if( canvas.expired() )
|
||||||
|
{
|
||||||
|
SG_LOG
|
||||||
|
(
|
||||||
|
SG_GENERAL,
|
||||||
|
SG_WARN,
|
||||||
|
"Canvas::addChildCanvas(" << _node->getPath(true) << "): "
|
||||||
|
" got an expired child!"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_child_canvases.insert(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::removeParentCanvas(const CanvasWeakPtr& canvas)
|
||||||
|
{
|
||||||
|
_parent_canvases.erase(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::removeChildCanvas(const CanvasWeakPtr& canvas)
|
||||||
|
{
|
||||||
|
_child_canvases.erase(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
GroupPtr Canvas::createGroup(const std::string& name)
|
||||||
|
{
|
||||||
|
return _root_group->createChild<Group>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
GroupPtr Canvas::getGroup(const std::string& name)
|
||||||
|
{
|
||||||
|
return _root_group->getChild<Group>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
GroupPtr Canvas::getOrCreateGroup(const std::string& name)
|
||||||
|
{
|
||||||
|
return _root_group->getOrCreateChild<Group>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
GroupPtr Canvas::getRootGroup()
|
||||||
|
{
|
||||||
|
return _root_group;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::enableRendering(bool force)
|
||||||
|
{
|
||||||
|
_visible = true;
|
||||||
|
if( force )
|
||||||
|
_render_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::update(double delta_time_sec)
|
||||||
|
{
|
||||||
|
if( (!_texture.serviceable() && _status != STATUS_DIRTY)
|
||||||
|
|| (_status & CREATE_FAILED) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( _status == STATUS_DIRTY )
|
||||||
|
{
|
||||||
|
_texture.setSize(_size_x, _size_y);
|
||||||
|
|
||||||
|
if( !_texture.serviceable() )
|
||||||
|
{
|
||||||
|
_texture.useImageCoords(true);
|
||||||
|
_texture.useStencil(true);
|
||||||
|
_texture.allocRT(/*_camera_callback*/);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Resizing causes a new texture to be created so we need to reapply all
|
||||||
|
// existing placements
|
||||||
|
reloadPlacements();
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Camera* camera = _texture.getCamera();
|
||||||
|
|
||||||
|
// TODO Allow custom render order? For now just keep in order with
|
||||||
|
// property tree.
|
||||||
|
camera->setRenderOrder(osg::Camera::PRE_RENDER, _node->getIndex());
|
||||||
|
|
||||||
|
osg::Vec4 clear_color(0.0f, 0.0f, 0.0f , 1.0f);
|
||||||
|
parseColor(_node->getStringValue("background"), clear_color);
|
||||||
|
camera->setClearColor(clear_color);
|
||||||
|
|
||||||
|
camera->addChild(_root_group->getMatrixTransform());
|
||||||
|
|
||||||
|
if( _texture.serviceable() )
|
||||||
|
{
|
||||||
|
setStatusFlags(STATUS_OK);
|
||||||
|
setStatusFlags(STATUS_DIRTY, false);
|
||||||
|
_render_dirty = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setStatusFlags(CREATE_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( _visible || _render_always )
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(CanvasWeakPtr canvas, _child_canvases)
|
||||||
|
{
|
||||||
|
// TODO should we check if the image the child canvas is displayed
|
||||||
|
// within is really visible?
|
||||||
|
if( !canvas.expired() )
|
||||||
|
canvas.lock()->_visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( _render_dirty )
|
||||||
|
{
|
||||||
|
// Also mark all canvases this canvas is displayed within as dirty
|
||||||
|
BOOST_FOREACH(CanvasWeakPtr canvas, _parent_canvases)
|
||||||
|
{
|
||||||
|
if( !canvas.expired() )
|
||||||
|
canvas.lock()->_render_dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_texture.setRender(_render_dirty);
|
||||||
|
|
||||||
|
_render_dirty = false;
|
||||||
|
_visible = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_texture.setRender(false);
|
||||||
|
|
||||||
|
_root_group->update(delta_time_sec);
|
||||||
|
|
||||||
|
if( _sampling_dirty )
|
||||||
|
{
|
||||||
|
_texture.setSampling(
|
||||||
|
_node->getBoolValue("mipmapping"),
|
||||||
|
_node->getIntValue("coverage-samples"),
|
||||||
|
_node->getIntValue("color-samples")
|
||||||
|
);
|
||||||
|
_sampling_dirty = false;
|
||||||
|
_render_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while( !_dirty_placements.empty() )
|
||||||
|
{
|
||||||
|
SGPropertyNode *node = _dirty_placements.back();
|
||||||
|
_dirty_placements.pop_back();
|
||||||
|
|
||||||
|
if( node->getIndex() >= static_cast<int>(_placements.size()) )
|
||||||
|
// New placement
|
||||||
|
_placements.resize(node->getIndex() + 1);
|
||||||
|
else
|
||||||
|
// Remove possibly existing placements
|
||||||
|
_placements[ node->getIndex() ].clear();
|
||||||
|
|
||||||
|
// Get new placements
|
||||||
|
PlacementFactoryMap::const_iterator placement_factory =
|
||||||
|
_placement_factories.find( node->getStringValue("type", "object") );
|
||||||
|
if( placement_factory != _placement_factories.end() )
|
||||||
|
{
|
||||||
|
Placements& placements = _placements[ node->getIndex() ] =
|
||||||
|
placement_factory->second
|
||||||
|
(
|
||||||
|
node,
|
||||||
|
boost::static_pointer_cast<Canvas>(_self.lock())
|
||||||
|
);
|
||||||
|
node->setStringValue
|
||||||
|
(
|
||||||
|
"status-msg",
|
||||||
|
placements.empty() ? "No match" : "Ok"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
node->setStringValue("status-msg", "Unknown placement type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool Canvas::addEventListener( const std::string& type,
|
||||||
|
const EventListener& cb )
|
||||||
|
{
|
||||||
|
if( !_root_group.get() )
|
||||||
|
throw std::runtime_error("Canvas::AddEventListener: no root group!");
|
||||||
|
|
||||||
|
return _root_group->addEventListener(type, cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setSizeX(int sx)
|
||||||
|
{
|
||||||
|
if( _size_x == sx )
|
||||||
|
return;
|
||||||
|
_size_x = sx;
|
||||||
|
setStatusFlags(STATUS_DIRTY);
|
||||||
|
|
||||||
|
if( _size_x <= 0 )
|
||||||
|
setStatusFlags(MISSING_SIZE_X);
|
||||||
|
else
|
||||||
|
setStatusFlags(MISSING_SIZE_X, false);
|
||||||
|
|
||||||
|
// reset flag to allow creation with new size
|
||||||
|
setStatusFlags(CREATE_FAILED, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setSizeY(int sy)
|
||||||
|
{
|
||||||
|
if( _size_y == sy )
|
||||||
|
return;
|
||||||
|
_size_y = sy;
|
||||||
|
setStatusFlags(STATUS_DIRTY);
|
||||||
|
|
||||||
|
if( _size_y <= 0 )
|
||||||
|
setStatusFlags(MISSING_SIZE_Y);
|
||||||
|
else
|
||||||
|
setStatusFlags(MISSING_SIZE_Y, false);
|
||||||
|
|
||||||
|
// reset flag to allow creation with new size
|
||||||
|
setStatusFlags(CREATE_FAILED, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
int Canvas::getSizeX() const
|
||||||
|
{
|
||||||
|
return _size_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
int Canvas::getSizeY() const
|
||||||
|
{
|
||||||
|
return _size_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setViewWidth(int w)
|
||||||
|
{
|
||||||
|
if( _view_width == w )
|
||||||
|
return;
|
||||||
|
_view_width = w;
|
||||||
|
|
||||||
|
_texture.setViewSize(_view_width, _view_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setViewHeight(int h)
|
||||||
|
{
|
||||||
|
if( _view_height == h )
|
||||||
|
return;
|
||||||
|
_view_height = h;
|
||||||
|
|
||||||
|
_texture.setViewSize(_view_width, _view_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
int Canvas::getViewWidth() const
|
||||||
|
{
|
||||||
|
return _texture.getViewSize().x();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
int Canvas::getViewHeight() const
|
||||||
|
{
|
||||||
|
return _texture.getViewSize().y();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
SGRect<int> Canvas::getViewport() const
|
||||||
|
{
|
||||||
|
return SGRect<int>(0, 0, getViewWidth(), getViewHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool Canvas::handleMouseEvent(const MouseEventPtr& event)
|
||||||
|
{
|
||||||
|
if( !_root_group.get() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
EventVisitor visitor( EventVisitor::TRAVERSE_DOWN,
|
||||||
|
event->getClientPos(),
|
||||||
|
event->getDelta(),
|
||||||
|
_root_group );
|
||||||
|
if( !_root_group->accept(visitor) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return _event_manager->handleEvent(event, visitor.getPropagationPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::childAdded( SGPropertyNode * parent,
|
||||||
|
SGPropertyNode * child )
|
||||||
|
{
|
||||||
|
if( parent != _node )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( child->getNameString() == "placement" )
|
||||||
|
_dirty_placements.push_back(child);
|
||||||
|
else if( _root_group.get() )
|
||||||
|
static_cast<Element*>(_root_group.get())->childAdded(parent, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::childRemoved( SGPropertyNode * parent,
|
||||||
|
SGPropertyNode * child )
|
||||||
|
{
|
||||||
|
_render_dirty = true;
|
||||||
|
|
||||||
|
if( parent != _node )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( child->getNameString() == "placement" )
|
||||||
|
_placements[ child->getIndex() ].clear();
|
||||||
|
else if( _root_group.get() )
|
||||||
|
static_cast<Element*>(_root_group.get())->childRemoved(parent, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::valueChanged(SGPropertyNode* node)
|
||||||
|
{
|
||||||
|
if( boost::starts_with(node->getNameString(), "status")
|
||||||
|
|| node->getParent()->getNameString() == "bounding-box" )
|
||||||
|
return;
|
||||||
|
_render_dirty = true;
|
||||||
|
|
||||||
|
bool handled = true;
|
||||||
|
if( node->getParent()->getParent() == _node
|
||||||
|
&& node->getParent()->getNameString() == "placement" )
|
||||||
|
{
|
||||||
|
size_t index = node->getIndex();
|
||||||
|
if( index < _placements.size() )
|
||||||
|
{
|
||||||
|
Placements& placements = _placements[index];
|
||||||
|
if( !placements.empty() )
|
||||||
|
{
|
||||||
|
bool placement_dirty = false;
|
||||||
|
BOOST_FOREACH(PlacementPtr& placement, placements)
|
||||||
|
{
|
||||||
|
// check if change can be directly handled by placement
|
||||||
|
if( placement->getProps() == node->getParent()
|
||||||
|
&& !placement->childChanged(node) )
|
||||||
|
placement_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !placement_dirty )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// prevent double updates...
|
||||||
|
for( size_t i = 0; i < _dirty_placements.size(); ++i )
|
||||||
|
{
|
||||||
|
if( node->getParent() == _dirty_placements[i] )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dirty_placements.push_back(node->getParent());
|
||||||
|
}
|
||||||
|
else if( node->getParent() == _node )
|
||||||
|
{
|
||||||
|
if( node->getNameString() == "background" )
|
||||||
|
{
|
||||||
|
osg::Vec4 color;
|
||||||
|
if( _texture.getCamera() && parseColor(node->getStringValue(), color) )
|
||||||
|
{
|
||||||
|
_texture.getCamera()->setClearColor(color);
|
||||||
|
_render_dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( node->getNameString() == "mipmapping"
|
||||||
|
|| node->getNameString() == "coverage-samples"
|
||||||
|
|| node->getNameString() == "color-samples" )
|
||||||
|
{
|
||||||
|
_sampling_dirty = true;
|
||||||
|
}
|
||||||
|
else if( node->getNameString() == "additive-blend" )
|
||||||
|
{
|
||||||
|
_texture.useAdditiveBlend( node->getBoolValue() );
|
||||||
|
}
|
||||||
|
else if( node->getNameString() == "render-always" )
|
||||||
|
{
|
||||||
|
_render_always = node->getBoolValue();
|
||||||
|
}
|
||||||
|
else if( node->getNameString() == "size" )
|
||||||
|
{
|
||||||
|
if( node->getIndex() == 0 )
|
||||||
|
setSizeX( node->getIntValue() );
|
||||||
|
else if( node->getIndex() == 1 )
|
||||||
|
setSizeY( node->getIntValue() );
|
||||||
|
}
|
||||||
|
else if( node->getNameString() == "view" )
|
||||||
|
{
|
||||||
|
if( node->getIndex() == 0 )
|
||||||
|
setViewWidth( node->getIntValue() );
|
||||||
|
else if( node->getIndex() == 1 )
|
||||||
|
setViewHeight( node->getIntValue() );
|
||||||
|
}
|
||||||
|
else if( node->getNameString() == "freeze" )
|
||||||
|
_texture.setRender( node->getBoolValue() );
|
||||||
|
else
|
||||||
|
handled = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
handled = false;
|
||||||
|
|
||||||
|
if( !handled && _root_group.get() )
|
||||||
|
_root_group->valueChanged(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
osg::Texture2D* Canvas::getTexture() const
|
||||||
|
{
|
||||||
|
return _texture.getTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Canvas::CullCallbackPtr Canvas::getCullCallback() const
|
||||||
|
{
|
||||||
|
return _cull_callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::reloadPlacements(const std::string& type)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < _placements.size(); ++i)
|
||||||
|
{
|
||||||
|
if( _placements[i].empty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SGPropertyNode* child = _placements[i].front()->getProps();
|
||||||
|
if( type.empty()
|
||||||
|
// reload if type matches or no type specified
|
||||||
|
|| child->getStringValue("type", type.c_str()) == type )
|
||||||
|
{
|
||||||
|
_dirty_placements.push_back(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::addPlacementFactory( const std::string& type,
|
||||||
|
PlacementFactory factory )
|
||||||
|
{
|
||||||
|
if( _placement_factories.find(type) != _placement_factories.end() )
|
||||||
|
SG_LOG
|
||||||
|
(
|
||||||
|
SG_GENERAL,
|
||||||
|
SG_WARN,
|
||||||
|
"Canvas::addPlacementFactory: replace existing factory '" << type << "'"
|
||||||
|
);
|
||||||
|
|
||||||
|
_placement_factories[type] = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::removePlacementFactory(const std::string& type)
|
||||||
|
{
|
||||||
|
PlacementFactoryMap::iterator it = _placement_factories.find(type);
|
||||||
|
if( it == _placement_factories.end() )
|
||||||
|
SG_LOG
|
||||||
|
(
|
||||||
|
SG_GENERAL,
|
||||||
|
SG_WARN,
|
||||||
|
"Canvas::removePlacementFactory: no such factory '" << type << "'"
|
||||||
|
);
|
||||||
|
else
|
||||||
|
_placement_factories.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setSystemAdapter(const SystemAdapterPtr& system_adapter)
|
||||||
|
{
|
||||||
|
_system_adapter = system_adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
SystemAdapterPtr Canvas::getSystemAdapter()
|
||||||
|
{
|
||||||
|
return _system_adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setSelf(const PropertyBasedElementPtr& self)
|
||||||
|
{
|
||||||
|
PropertyBasedElement::setSelf(self);
|
||||||
|
|
||||||
|
CanvasPtr canvas = boost::static_pointer_cast<Canvas>(self);
|
||||||
|
|
||||||
|
_root_group.reset( new Group(canvas, _node) );
|
||||||
|
_root_group->setSelf(_root_group);
|
||||||
|
|
||||||
|
// Remove automatically created property listener as we forward them on our
|
||||||
|
// own
|
||||||
|
_root_group->removeListener();
|
||||||
|
|
||||||
|
_cull_callback = new CullCallback(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Canvas::setStatusFlags(unsigned int flags, bool set)
|
||||||
|
{
|
||||||
|
if( set )
|
||||||
|
_status |= flags;
|
||||||
|
else
|
||||||
|
_status &= ~flags;
|
||||||
|
|
||||||
|
if( (_status & MISSING_SIZE_X) && (_status & MISSING_SIZE_Y) )
|
||||||
|
_status_msg = "Missing size";
|
||||||
|
else if( _status & MISSING_SIZE_X )
|
||||||
|
_status_msg = "Missing size-x";
|
||||||
|
else if( _status & MISSING_SIZE_Y )
|
||||||
|
_status_msg = "Missing size-y";
|
||||||
|
else if( _status & CREATE_FAILED )
|
||||||
|
_status_msg = "Creating render target failed";
|
||||||
|
else if( _status == STATUS_DIRTY )
|
||||||
|
_status_msg = "Creation pending...";
|
||||||
|
else
|
||||||
|
_status_msg = "Ok";
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Canvas::PlacementFactoryMap Canvas::_placement_factories;
|
||||||
|
SystemAdapterPtr Canvas::_system_adapter;
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
// The canvas for rendering with the 2d API
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#ifndef CANVAS_HXX_
|
||||||
|
#define CANVAS_HXX_
|
||||||
|
|
||||||
|
#include "canvas_fwd.hxx"
|
||||||
|
#include "ODGauge.hxx"
|
||||||
|
|
||||||
|
#include <simgear/canvas/elements/CanvasGroup.hxx>
|
||||||
|
#include <simgear/math/SGRect.hxx>
|
||||||
|
#include <simgear/props/PropertyBasedElement.hxx>
|
||||||
|
#include <simgear/props/propertyObject.hxx>
|
||||||
|
#include <osg/NodeCallback>
|
||||||
|
#include <osg/observer_ptr>
|
||||||
|
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
class CanvasMgr;
|
||||||
|
class MouseEvent;
|
||||||
|
|
||||||
|
class Canvas:
|
||||||
|
public PropertyBasedElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum StatusFlags
|
||||||
|
{
|
||||||
|
STATUS_OK,
|
||||||
|
STATUS_DIRTY = 1,
|
||||||
|
MISSING_SIZE_X = STATUS_DIRTY << 1,
|
||||||
|
MISSING_SIZE_Y = MISSING_SIZE_X << 1,
|
||||||
|
CREATE_FAILED = MISSING_SIZE_Y << 1
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This callback is installed on every placement of the canvas in the
|
||||||
|
* scene to only render the canvas if at least one placement is visible
|
||||||
|
*/
|
||||||
|
class CullCallback:
|
||||||
|
public osg::NodeCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CullCallback(const CanvasWeakPtr& canvas);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CanvasWeakPtr _canvas;
|
||||||
|
|
||||||
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
|
||||||
|
};
|
||||||
|
typedef osg::ref_ptr<CullCallback> CullCallbackPtr;
|
||||||
|
|
||||||
|
Canvas(SGPropertyNode* node);
|
||||||
|
virtual ~Canvas();
|
||||||
|
virtual void onDestroy();
|
||||||
|
|
||||||
|
void setCanvasMgr(CanvasMgr* canvas_mgr);
|
||||||
|
CanvasMgr* getCanvasMgr() const;
|
||||||
|
|
||||||
|
bool isInit() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a canvas which should be marked as dirty upon any change to this
|
||||||
|
* canvas.
|
||||||
|
*
|
||||||
|
* This mechanism is used to eg. redraw a canvas if it's displaying
|
||||||
|
* another canvas (recursive canvases)
|
||||||
|
*/
|
||||||
|
void addParentCanvas(const CanvasWeakPtr& canvas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a canvas which should be marked visible if this canvas is visible.
|
||||||
|
*/
|
||||||
|
void addChildCanvas(const CanvasWeakPtr& canvas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop notifying the given canvas upon changes
|
||||||
|
*/
|
||||||
|
void removeParentCanvas(const CanvasWeakPtr& canvas);
|
||||||
|
void removeChildCanvas(const CanvasWeakPtr& canvas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new group
|
||||||
|
*/
|
||||||
|
GroupPtr createGroup(const std::string& name = "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an existing group with the given name
|
||||||
|
*/
|
||||||
|
GroupPtr getGroup(const std::string& name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an existing group with the given name or otherwise create a new
|
||||||
|
* group
|
||||||
|
*/
|
||||||
|
GroupPtr getOrCreateGroup(const std::string& name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the root group of the canvas
|
||||||
|
*/
|
||||||
|
GroupPtr getRootGroup();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable rendering for the next frame
|
||||||
|
*
|
||||||
|
* @param force Force redraw even if nothing has changed (if dirty flag
|
||||||
|
* is not set)
|
||||||
|
*/
|
||||||
|
void enableRendering(bool force = false);
|
||||||
|
|
||||||
|
void update(double delta_time_sec);
|
||||||
|
|
||||||
|
bool addEventListener(const std::string& type, const EventListener& cb);
|
||||||
|
|
||||||
|
void setSizeX(int sx);
|
||||||
|
void setSizeY(int sy);
|
||||||
|
|
||||||
|
int getSizeX() const;
|
||||||
|
int getSizeY() const;
|
||||||
|
|
||||||
|
void setViewWidth(int w);
|
||||||
|
void setViewHeight(int h);
|
||||||
|
|
||||||
|
int getViewWidth() const;
|
||||||
|
int getViewHeight() const;
|
||||||
|
SGRect<int> getViewport() const;
|
||||||
|
|
||||||
|
bool handleMouseEvent(const MouseEventPtr& event);
|
||||||
|
|
||||||
|
virtual void childAdded( SGPropertyNode * parent,
|
||||||
|
SGPropertyNode * child );
|
||||||
|
virtual void childRemoved( SGPropertyNode * parent,
|
||||||
|
SGPropertyNode * child );
|
||||||
|
virtual void valueChanged (SGPropertyNode * node);
|
||||||
|
|
||||||
|
osg::Texture2D* getTexture() const;
|
||||||
|
|
||||||
|
CullCallbackPtr getCullCallback() const;
|
||||||
|
|
||||||
|
void reloadPlacements( const std::string& type = std::string() );
|
||||||
|
static void addPlacementFactory( const std::string& type,
|
||||||
|
PlacementFactory factory );
|
||||||
|
static void removePlacementFactory(const std::string& type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set global SystemAdapter for all Canvas/ODGauge instances.
|
||||||
|
*
|
||||||
|
* The SystemAdapter is responsible for application specific operations
|
||||||
|
* like loading images/fonts and adding/removing cameras to the scene
|
||||||
|
* graph.
|
||||||
|
*/
|
||||||
|
static void setSystemAdapter(const SystemAdapterPtr& system_adapter);
|
||||||
|
static SystemAdapterPtr getSystemAdapter();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
CanvasMgr *_canvas_mgr;
|
||||||
|
|
||||||
|
boost::scoped_ptr<EventManager> _event_manager;
|
||||||
|
|
||||||
|
int _size_x,
|
||||||
|
_size_y,
|
||||||
|
_view_width,
|
||||||
|
_view_height;
|
||||||
|
|
||||||
|
PropertyObject<int> _status;
|
||||||
|
PropertyObject<std::string> _status_msg;
|
||||||
|
|
||||||
|
bool _sampling_dirty,
|
||||||
|
_render_dirty,
|
||||||
|
_visible;
|
||||||
|
|
||||||
|
ODGauge _texture;
|
||||||
|
GroupPtr _root_group;
|
||||||
|
|
||||||
|
CullCallbackPtr _cull_callback;
|
||||||
|
bool _render_always; //<! Used to disable automatic lazy rendering (culling)
|
||||||
|
|
||||||
|
std::vector<SGPropertyNode*> _dirty_placements;
|
||||||
|
std::vector<Placements> _placements;
|
||||||
|
std::set<CanvasWeakPtr> _parent_canvases, //<! Canvases showing this canvas
|
||||||
|
_child_canvases; //<! Canvases displayed within
|
||||||
|
// this canvas
|
||||||
|
|
||||||
|
typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;
|
||||||
|
static PlacementFactoryMap _placement_factories;
|
||||||
|
|
||||||
|
virtual void setSelf(const PropertyBasedElementPtr& self);
|
||||||
|
void setStatusFlags(unsigned int flags, bool set = true);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static SystemAdapterPtr _system_adapter;
|
||||||
|
|
||||||
|
Canvas(const Canvas&); // = delete;
|
||||||
|
Canvas& operator=(const Canvas&); // = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
|
|
||||||
|
#endif /* CANVAS_HXX_ */
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
// Canvas Event for event model similar to DOM Level 3 Event Model
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#include "CanvasEvent.hxx"
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Event::Event():
|
||||||
|
type(UNKNOWN),
|
||||||
|
propagation_stopped(false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Event::~Event()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Event::Type Event::getType() const
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
std::string Event::getTypeString() const
|
||||||
|
{
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
# define ENUM_MAPPING(name, str) case name: return str;
|
||||||
|
# include "CanvasEventTypes.hxx"
|
||||||
|
# undef ENUM_MAPPING
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
ElementWeakPtr Event::getTarget() const
|
||||||
|
{
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
ElementWeakPtr Event::getCurrentTarget() const
|
||||||
|
{
|
||||||
|
return current_target;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
double Event::getTime() const
|
||||||
|
{
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void Event::stopPropagation()
|
||||||
|
{
|
||||||
|
propagation_stopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Event::Type Event::strToType(const std::string& str)
|
||||||
|
{
|
||||||
|
typedef std::map<std::string, Type> TypeMap;
|
||||||
|
static TypeMap type_map;
|
||||||
|
|
||||||
|
if( type_map.empty() )
|
||||||
|
{
|
||||||
|
# define ENUM_MAPPING(type, str) type_map[ str ] = type;
|
||||||
|
# include "CanvasEventTypes.hxx"
|
||||||
|
# undef ENUM_MAPPING
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeMap::const_iterator it = type_map.find(str);
|
||||||
|
if( it == type_map.end() )
|
||||||
|
return UNKNOWN;
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// Canvas Event for event model similar to DOM Level 3 Event Model
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#ifndef CANVAS_EVENT_HXX_
|
||||||
|
#define CANVAS_EVENT_HXX_
|
||||||
|
|
||||||
|
#include "canvas_fwd.hxx"
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
class Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
UNKNOWN,
|
||||||
|
# define ENUM_MAPPING(name, str) name,
|
||||||
|
# include "CanvasEventTypes.hxx"
|
||||||
|
# undef ENUM_MAPPING
|
||||||
|
USER_TYPE ///<! first unused id to be used for user defined types (not
|
||||||
|
/// implemented yet)
|
||||||
|
};
|
||||||
|
|
||||||
|
Type type;
|
||||||
|
ElementWeakPtr target,
|
||||||
|
current_target;
|
||||||
|
double time;
|
||||||
|
bool propagation_stopped;
|
||||||
|
|
||||||
|
Event();
|
||||||
|
|
||||||
|
// We need a vtable to allow nasal::Ghost to determine the dynamic type
|
||||||
|
// of the actual event instances.
|
||||||
|
virtual ~Event();
|
||||||
|
|
||||||
|
Type getType() const;
|
||||||
|
std::string getTypeString() const;
|
||||||
|
|
||||||
|
ElementWeakPtr getTarget() const;
|
||||||
|
ElementWeakPtr getCurrentTarget() const;
|
||||||
|
|
||||||
|
double getTime() const;
|
||||||
|
|
||||||
|
void stopPropagation();
|
||||||
|
|
||||||
|
static Type strToType(const std::string& str);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
|
|
||||||
|
#endif /* CANVAS_EVENT_HXX_ */
|
||||||
@@ -0,0 +1,348 @@
|
|||||||
|
// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#include "CanvasEventManager.hxx"
|
||||||
|
#include "MouseEvent.hxx"
|
||||||
|
#include <simgear/canvas/elements/CanvasElement.hxx>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
const unsigned int drag_threshold = 8;
|
||||||
|
const double multi_click_timeout = 0.4;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
EventManager::StampedPropagationPath::StampedPropagationPath():
|
||||||
|
time(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
EventManager::StampedPropagationPath::StampedPropagationPath(
|
||||||
|
const EventPropagationPath& path,
|
||||||
|
double time
|
||||||
|
):
|
||||||
|
path(path),
|
||||||
|
time(time)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void EventManager::StampedPropagationPath::clear()
|
||||||
|
{
|
||||||
|
path.clear();
|
||||||
|
time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool EventManager::StampedPropagationPath::valid() const
|
||||||
|
{
|
||||||
|
return !path.empty() && time > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
EventManager::EventManager():
|
||||||
|
_current_click_count(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool EventManager::handleEvent( const MouseEventPtr& event,
|
||||||
|
const EventPropagationPath& path )
|
||||||
|
{
|
||||||
|
bool handled = false;
|
||||||
|
switch( event->type )
|
||||||
|
{
|
||||||
|
case Event::MOUSE_DOWN:
|
||||||
|
_last_mouse_down = StampedPropagationPath(path, event->getTime());
|
||||||
|
break;
|
||||||
|
case Event::MOUSE_UP:
|
||||||
|
{
|
||||||
|
// If the mouse has moved while a button was down (aka. dragging) we
|
||||||
|
// need to notify the original element that the mouse has left it, and
|
||||||
|
// the new element that it has been entered
|
||||||
|
if( _last_mouse_down.path != path )
|
||||||
|
handled |= handleMove(event, path);
|
||||||
|
|
||||||
|
// normal mouseup
|
||||||
|
handled |= propagateEvent(event, path);
|
||||||
|
|
||||||
|
if( _last_mouse_down.path.empty() )
|
||||||
|
// Ignore mouse up without any previous mouse down
|
||||||
|
return handled;
|
||||||
|
|
||||||
|
// now handle click/dblclick
|
||||||
|
if( checkClickDistance(path, _last_mouse_down.path) )
|
||||||
|
handled |=
|
||||||
|
handleClick(event, getCommonAncestor(_last_mouse_down.path, path));
|
||||||
|
|
||||||
|
_last_mouse_down.clear();
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
case Event::DRAG:
|
||||||
|
if( !_last_mouse_down.valid() )
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return propagateEvent(event, _last_mouse_down.path);
|
||||||
|
case Event::MOUSE_MOVE:
|
||||||
|
handled |= handleMove(event, path);
|
||||||
|
break;
|
||||||
|
case Event::MOUSE_LEAVE:
|
||||||
|
// Mouse leaves window and therefore also current mouseover element
|
||||||
|
handleMove(event, EventPropagationPath());
|
||||||
|
|
||||||
|
// Event is only send if mouse is moved outside the window or dragging
|
||||||
|
// has ended somewhere outside the window. In both cases a mouse button
|
||||||
|
// has been released, so no more mouse down or click...
|
||||||
|
_last_mouse_down.clear();
|
||||||
|
_last_click.clear();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
case Event::WHEEL:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled | propagateEvent(event, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool EventManager::handleClick( const MouseEventPtr& event,
|
||||||
|
const EventPropagationPath& path )
|
||||||
|
{
|
||||||
|
MouseEventPtr click(new MouseEvent(*event));
|
||||||
|
click->type = Event::CLICK;
|
||||||
|
|
||||||
|
if( event->getTime() > _last_click.time + multi_click_timeout )
|
||||||
|
_current_click_count = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Maximum current click count is 3
|
||||||
|
_current_click_count = (_current_click_count % 3) + 1;
|
||||||
|
|
||||||
|
if( _current_click_count > 1 )
|
||||||
|
{
|
||||||
|
// Reset current click count if moved too far
|
||||||
|
if( !checkClickDistance(path, _last_click.path) )
|
||||||
|
_current_click_count = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
click->click_count = _current_click_count;
|
||||||
|
|
||||||
|
MouseEventPtr dbl_click;
|
||||||
|
if( _current_click_count == 2 )
|
||||||
|
{
|
||||||
|
dbl_click.reset(new MouseEvent(*click));
|
||||||
|
dbl_click->type = Event::DBL_CLICK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handled = propagateEvent(click, path);
|
||||||
|
|
||||||
|
if( dbl_click )
|
||||||
|
handled |= propagateEvent( dbl_click,
|
||||||
|
getCommonAncestor(_last_click.path, path) );
|
||||||
|
|
||||||
|
_last_click = StampedPropagationPath(path, event->getTime());
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool EventManager::handleMove( const MouseEventPtr& event,
|
||||||
|
const EventPropagationPath& path )
|
||||||
|
{
|
||||||
|
EventPropagationPath& last_path = _last_mouse_over.path;
|
||||||
|
if( last_path == path )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
|
// Leave old element
|
||||||
|
if( !last_path.empty() )
|
||||||
|
{
|
||||||
|
MouseEventPtr mouseout(new MouseEvent(*event));
|
||||||
|
mouseout->type = Event::MOUSE_OUT;
|
||||||
|
handled |= propagateEvent(mouseout, last_path);
|
||||||
|
|
||||||
|
// Send a mouseleave event to all ancestors of the currently left element
|
||||||
|
// which are not ancestor of the new element currently entered
|
||||||
|
EventPropagationPath path_leave = last_path;
|
||||||
|
for(size_t i = path_leave.size() - 1; i > 0; --i)
|
||||||
|
{
|
||||||
|
if( i < path.size() && path[i] == path_leave[i] )
|
||||||
|
break;
|
||||||
|
|
||||||
|
MouseEventPtr mouseleave(new MouseEvent(*event));
|
||||||
|
mouseleave->type = Event::MOUSE_LEAVE;
|
||||||
|
handled |= propagateEvent(mouseleave, path_leave);
|
||||||
|
|
||||||
|
path_leave.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enter new element
|
||||||
|
if( !path.empty() )
|
||||||
|
{
|
||||||
|
MouseEventPtr mouseover(new MouseEvent(*event));
|
||||||
|
mouseover->type = Event::MOUSE_OVER;
|
||||||
|
handled |= propagateEvent(mouseover, path);
|
||||||
|
|
||||||
|
// Send a mouseenter event to all ancestors of the currently entered
|
||||||
|
// element which are not ancestor of the old element currently being
|
||||||
|
// left
|
||||||
|
EventPropagationPath path_enter;
|
||||||
|
for(size_t i = 0; i < path.size(); ++i)
|
||||||
|
{
|
||||||
|
path_enter.push_back(path[i]);
|
||||||
|
|
||||||
|
if( i < last_path.size() && path[i] == last_path[i] )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
MouseEventPtr mouseenter(new MouseEvent(*event));
|
||||||
|
mouseenter->type = Event::MOUSE_ENTER;
|
||||||
|
handled |= propagateEvent(mouseenter, path_enter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_last_mouse_over.path = path;
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool EventManager::propagateEvent( const EventPtr& event,
|
||||||
|
const EventPropagationPath& path )
|
||||||
|
{
|
||||||
|
event->target = path.back().element;
|
||||||
|
MouseEventPtr mouse_event = boost::dynamic_pointer_cast<MouseEvent>(event);
|
||||||
|
|
||||||
|
// Event propagation similar to DOM Level 3 event flow:
|
||||||
|
// http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
|
||||||
|
|
||||||
|
// Capturing phase
|
||||||
|
// for( EventPropagationPath::const_iterator it = path.begin();
|
||||||
|
// it != path.end();
|
||||||
|
// ++it )
|
||||||
|
// {
|
||||||
|
// if( !it->element.expired() )
|
||||||
|
// std::cout << it->element.lock()->getProps()->getPath() << std::endl;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Check if event supports bubbling
|
||||||
|
const Event::Type types_no_bubbling[] = {
|
||||||
|
Event::MOUSE_ENTER,
|
||||||
|
Event::MOUSE_LEAVE,
|
||||||
|
};
|
||||||
|
const size_t num_types_no_bubbling = sizeof(types_no_bubbling)
|
||||||
|
/ sizeof(types_no_bubbling[0]);
|
||||||
|
bool do_bubble = true;
|
||||||
|
for( size_t i = 0; i < num_types_no_bubbling; ++i )
|
||||||
|
if( event->type == types_no_bubbling[i] )
|
||||||
|
{
|
||||||
|
do_bubble = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bubbling phase
|
||||||
|
for( EventPropagationPath::const_reverse_iterator
|
||||||
|
it = path.rbegin();
|
||||||
|
it != path.rend();
|
||||||
|
++it )
|
||||||
|
{
|
||||||
|
ElementPtr el = it->element.lock();
|
||||||
|
|
||||||
|
if( !el )
|
||||||
|
{
|
||||||
|
// Ignore element if it has been destroyed while traversing the event
|
||||||
|
// (eg. removed by another event handler)
|
||||||
|
if( do_bubble )
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO provide functions to convert delta to local coordinates on demand.
|
||||||
|
// Maybe also provide a clone method for events as local coordinates
|
||||||
|
// might differ between different elements receiving the same event.
|
||||||
|
if( mouse_event ) //&& event->type != Event::DRAG )
|
||||||
|
{
|
||||||
|
// TODO transform pos and delta for drag events. Maybe we should just
|
||||||
|
// store the global coordinates and convert to local coordinates
|
||||||
|
// on demand.
|
||||||
|
|
||||||
|
// Position and delta are specified in local coordinate system of
|
||||||
|
// current element
|
||||||
|
mouse_event->local_pos = it->local_pos;
|
||||||
|
//mouse_event->delta = it->local_delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
event->current_target = el;
|
||||||
|
el->handleEvent(event);
|
||||||
|
|
||||||
|
if( event->propagation_stopped || !do_bubble )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
EventManager::checkClickDistance( const EventPropagationPath& path1,
|
||||||
|
const EventPropagationPath& path2 ) const
|
||||||
|
{
|
||||||
|
osg::Vec2 delta = path1.front().local_pos - path2.front().local_pos;
|
||||||
|
return std::fabs(delta.x()) < drag_threshold
|
||||||
|
&& std::fabs(delta.y()) < drag_threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
EventPropagationPath
|
||||||
|
EventManager::getCommonAncestor( const EventPropagationPath& path1,
|
||||||
|
const EventPropagationPath& path2 ) const
|
||||||
|
{
|
||||||
|
if( path1.empty() || path2.empty() )
|
||||||
|
return EventPropagationPath();
|
||||||
|
|
||||||
|
if( path1.back().element.lock() == path2.back().element.lock() )
|
||||||
|
return path2;
|
||||||
|
|
||||||
|
EventPropagationPath path;
|
||||||
|
|
||||||
|
for( size_t i = 0; i < path1.size() && i < path2.size(); ++i )
|
||||||
|
{
|
||||||
|
if( path1[i].element.lock() != path2[i].element.lock() )
|
||||||
|
break;
|
||||||
|
|
||||||
|
path.push_back(path2[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#ifndef CANVAS_EVENT_MANAGER_HXX_
|
||||||
|
#define CANVAS_EVENT_MANAGER_HXX_
|
||||||
|
|
||||||
|
#include "canvas_fwd.hxx"
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
struct EventTarget
|
||||||
|
{
|
||||||
|
ElementWeakPtr element;
|
||||||
|
osg::Vec2f local_pos,
|
||||||
|
local_delta;
|
||||||
|
};
|
||||||
|
typedef std::deque<EventTarget> EventPropagationPath;
|
||||||
|
inline bool operator==(const EventTarget& t1, const EventTarget& t2)
|
||||||
|
{
|
||||||
|
return t1.element.lock() == t2.element.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
class EventManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EventManager();
|
||||||
|
|
||||||
|
bool handleEvent( const MouseEventPtr& event,
|
||||||
|
const EventPropagationPath& path );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
struct StampedPropagationPath
|
||||||
|
{
|
||||||
|
StampedPropagationPath();
|
||||||
|
StampedPropagationPath(const EventPropagationPath& path, double time);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
bool valid() const;
|
||||||
|
|
||||||
|
EventPropagationPath path;
|
||||||
|
double time;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO if we really need the paths modify to not copy around the paths
|
||||||
|
// that much.
|
||||||
|
StampedPropagationPath _last_mouse_down,
|
||||||
|
_last_click,
|
||||||
|
_last_mouse_over;
|
||||||
|
size_t _current_click_count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Propagate click event and handle multi-click (eg. create dblclick)
|
||||||
|
*/
|
||||||
|
bool handleClick( const MouseEventPtr& event,
|
||||||
|
const EventPropagationPath& path );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle mouseover/enter/out/leave
|
||||||
|
*/
|
||||||
|
bool handleMove( const MouseEventPtr& event,
|
||||||
|
const EventPropagationPath& path );
|
||||||
|
|
||||||
|
bool propagateEvent( const EventPtr& event,
|
||||||
|
const EventPropagationPath& path );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if two click events (either mousedown/up or two consecutive
|
||||||
|
* clicks) are inside a maximum distance to still create a click or
|
||||||
|
* dblclick event respectively.
|
||||||
|
*/
|
||||||
|
bool checkClickDistance( const EventPropagationPath& path1,
|
||||||
|
const EventPropagationPath& path2 ) const;
|
||||||
|
EventPropagationPath
|
||||||
|
getCommonAncestor( const EventPropagationPath& path1,
|
||||||
|
const EventPropagationPath& path2 ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
|
|
||||||
|
#endif /* CANVAS_EVENT_MANAGER_HXX_ */
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Mapping between canvas gui Event types and their names
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#ifndef ENUM_MAPPING
|
||||||
|
# error "Don't include this file directly!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ENUM_MAPPING(MOUSE_DOWN, "mousedown")
|
||||||
|
ENUM_MAPPING(MOUSE_UP, "mouseup")
|
||||||
|
ENUM_MAPPING(CLICK, "click")
|
||||||
|
ENUM_MAPPING(DBL_CLICK, "dblclick")
|
||||||
|
ENUM_MAPPING(DRAG, "drag")
|
||||||
|
ENUM_MAPPING(WHEEL, "wheel")
|
||||||
|
ENUM_MAPPING(MOUSE_MOVE, "mousemove")
|
||||||
|
ENUM_MAPPING(MOUSE_OVER, "mouseover")
|
||||||
|
ENUM_MAPPING(MOUSE_OUT, "mouseout")
|
||||||
|
ENUM_MAPPING(MOUSE_ENTER, "mouseenter")
|
||||||
|
ENUM_MAPPING(MOUSE_LEAVE, "mouseleave")
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
// Visitor for traversing a canvas element hierarchy similar to the traversal
|
||||||
|
// of the DOM Level 3 Event Model
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#include "CanvasEvent.hxx"
|
||||||
|
#include "CanvasEventVisitor.hxx"
|
||||||
|
#include <simgear/canvas/elements/CanvasElement.hxx>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
EventVisitor::EventVisitor( TraverseMode mode,
|
||||||
|
const osg::Vec2f& pos,
|
||||||
|
const osg::Vec2f& delta,
|
||||||
|
const ElementPtr& root ):
|
||||||
|
_traverse_mode( mode ),
|
||||||
|
_root(root)
|
||||||
|
{
|
||||||
|
if( mode == TRAVERSE_DOWN )
|
||||||
|
{
|
||||||
|
EventTarget target = {ElementWeakPtr(), pos, delta};
|
||||||
|
_target_path.push_back(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
EventVisitor::~EventVisitor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool EventVisitor::traverse(Element& el)
|
||||||
|
{
|
||||||
|
if( _traverse_mode == TRAVERSE_UP )
|
||||||
|
return el.ascend(*this);
|
||||||
|
else
|
||||||
|
return el.traverse(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool EventVisitor::apply(Element& el)
|
||||||
|
{
|
||||||
|
// We only need to check for hits while traversing down
|
||||||
|
if( _traverse_mode == TRAVERSE_DOWN )
|
||||||
|
{
|
||||||
|
// Transform event to local coordinates
|
||||||
|
const osg::Matrix& m = el.getMatrixTransform()->getInverseMatrix();
|
||||||
|
const osg::Vec2f& pos = _target_path.back().local_pos;
|
||||||
|
const osg::Vec2f local_pos
|
||||||
|
(
|
||||||
|
m(0, 0) * pos[0] + m(1, 0) * pos[1] + m(3, 0),
|
||||||
|
m(0, 1) * pos[0] + m(1, 1) * pos[1] + m(3, 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Don't check specified root element for collision, as its purpose is to
|
||||||
|
// catch all events which have no target. This allows for example calling
|
||||||
|
// event listeners attached to the canvas itself (its root group) even if
|
||||||
|
// no element has been hit.
|
||||||
|
if( _root.get() != &el && !el.hitBound(pos, local_pos) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const osg::Vec2f& delta = _target_path.back().local_delta;
|
||||||
|
const osg::Vec2f local_delta
|
||||||
|
(
|
||||||
|
m(0, 0) * delta[0] + m(1, 0) * delta[1],
|
||||||
|
m(0, 1) * delta[0] + m(1, 1) * delta[1]
|
||||||
|
);
|
||||||
|
|
||||||
|
EventTarget target = {el.getWeakPtr(), local_pos, local_delta};
|
||||||
|
_target_path.push_back(target);
|
||||||
|
|
||||||
|
if( el.traverse(*this) || &el == _root.get() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
_target_path.pop_back();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return el.ascend(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
const EventPropagationPath& EventVisitor::getPropagationPath() const
|
||||||
|
{
|
||||||
|
return _target_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
// Visitor for traversing a canvas element hierarchy similar to the traversal
|
||||||
|
// of the DOM Level 3 Event Model
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#ifndef CANVAS_EVENT_VISITOR_HXX_
|
||||||
|
#define CANVAS_EVENT_VISITOR_HXX_
|
||||||
|
|
||||||
|
#include "canvas_fwd.hxx"
|
||||||
|
#include "CanvasEventManager.hxx"
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
class EventVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum TraverseMode
|
||||||
|
{
|
||||||
|
TRAVERSE_UP,
|
||||||
|
TRAVERSE_DOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mode
|
||||||
|
* @param pos Mouse position
|
||||||
|
* @param delta Mouse movement since last mouse move event
|
||||||
|
* @param root Element to dispatch events to if no element is hit
|
||||||
|
*/
|
||||||
|
EventVisitor( TraverseMode mode,
|
||||||
|
const osg::Vec2f& pos,
|
||||||
|
const osg::Vec2f& delta,
|
||||||
|
const ElementPtr& root = ElementPtr() );
|
||||||
|
virtual ~EventVisitor();
|
||||||
|
virtual bool traverse(Element& el);
|
||||||
|
virtual bool apply(Element& el);
|
||||||
|
|
||||||
|
const EventPropagationPath& getPropagationPath() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
TraverseMode _traverse_mode;
|
||||||
|
EventPropagationPath _target_path;
|
||||||
|
ElementPtr _root;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CANVAS_EVENTVISITOR_HXX_ */
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// Canvas with 2D rendering API
|
||||||
|
//
|
||||||
|
// Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#include "CanvasMgr.hxx"
|
||||||
|
#include "Canvas.hxx"
|
||||||
|
#include "CanvasEventManager.hxx"
|
||||||
|
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
namespace canvas
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Canvas factory
|
||||||
|
*/
|
||||||
|
CanvasPtr canvasFactory(SGPropertyNode* node)
|
||||||
|
{
|
||||||
|
return CanvasPtr(new Canvas(node));
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
CanvasMgr::CanvasMgr(SGPropertyNode_ptr node):
|
||||||
|
PropertyBasedMgr(node, "texture", &canvasFactory)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
CanvasPtr CanvasMgr::createCanvas(const std::string& name)
|
||||||
|
{
|
||||||
|
return boost::static_pointer_cast<Canvas>( createElement(name) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
CanvasPtr CanvasMgr::getCanvas(size_t index) const
|
||||||
|
{
|
||||||
|
return boost::static_pointer_cast<Canvas>( getElement(index) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
CanvasPtr CanvasMgr::getCanvas(const std::string& name) const
|
||||||
|
{
|
||||||
|
return boost::static_pointer_cast<Canvas>( getElement(name) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void CanvasMgr::elementCreated(PropertyBasedElementPtr element)
|
||||||
|
{
|
||||||
|
CanvasPtr canvas = boost::static_pointer_cast<Canvas>(element);
|
||||||
|
canvas->setCanvasMgr(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace canvas
|
||||||
|
} // namespace simgear
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user