Compare commits
663 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d836d7187e | |||
| b0ecb5b62d | |||
| 09febce4ce | |||
| c5621ff44b | |||
| d58f3114cc | |||
| e1caaed3cf | |||
| 11959f5023 | |||
| 197e5f920d | |||
| e1300a9342 | |||
| 524d2572aa | |||
| 340bab73f5 | |||
| 8d1529cc48 | |||
| c501a73251 | |||
| 6b1c02526f | |||
| d8d7284c35 | |||
| a5a8b93a2e | |||
| a72fd0ebdd | |||
| d5bd1f5aea | |||
| 17c27d1176 | |||
| df698b9433 | |||
| 2ea59ac83a | |||
| 4264e5bee3 | |||
| 411bcc58c5 | |||
| f02cd717bc | |||
| 91f40ac779 | |||
| 04ffee8e82 | |||
| 54253ba8a3 | |||
| ddd533ee9c | |||
| 46133c76b2 | |||
| d4e9ace354 | |||
| 88dd914a31 | |||
| ca68d32a47 | |||
| 3c86dbe28c | |||
| 400bac868e | |||
| 7e765db562 | |||
| a993e179ab | |||
| 5253ff35f1 | |||
| cba0ec4de5 | |||
| ed0354dd06 | |||
| d255d6aeeb | |||
| 94abd0ee79 | |||
| 6a3cd9c0d7 | |||
| 81be16d058 | |||
| 3efdc963d8 | |||
| a4525bf88c | |||
| d7c7ff3dad | |||
| 987aec3fd6 | |||
| d5661c24bd | |||
| c3ee1111f9 | |||
| 9c1509b8c3 | |||
| 1020cdd7a6 | |||
| bff2f53996 | |||
| d5bf831f60 | |||
| 6c423be36f | |||
| 3c33e2c046 | |||
| 253ff41819 | |||
| 24d95b410d | |||
| db5aacf984 | |||
| 111a56dd8a | |||
| d1d0d61b4f | |||
| 640f279abe | |||
| 874191bd8d | |||
| 2066af9f28 | |||
| ef7b3c1715 | |||
| 6eb96851f9 | |||
| a42ef9de77 | |||
| fb23fe3084 | |||
| 57f0150a23 | |||
| 9b31a986b6 | |||
| 8fa46a1f9e | |||
| d805f5ceff | |||
| b4242e562d | |||
| 2effa810c1 | |||
| a78af6acc2 | |||
| fc084c84f4 | |||
| a846ab7443 | |||
| 9f53272d34 | |||
| aa53aac7be | |||
| db984fcad9 | |||
| 607713cdae | |||
| 7de0a61de3 | |||
| 1838460c38 | |||
| 3a4e00d0f5 | |||
| a9bd82150b | |||
| de5c3733d0 | |||
| 3ff662e710 | |||
| 669571799b | |||
| 81a98fc0d3 | |||
| f10157fb24 | |||
| 7d94508257 | |||
| 262a8607d0 | |||
| fd44a9552a | |||
| 8e2d6d8cb2 | |||
| 13b73cb51f | |||
| 5f730ba360 | |||
| 79dbbadf2d | |||
| cd150c265f | |||
| 7a50a91eab | |||
| b5561ee5d4 | |||
| 8dcda7fe35 | |||
| 9b679cc8dd | |||
| 674f8cc936 | |||
| 51a43ef45b | |||
| acc55d588a | |||
| d4990b30e9 | |||
| 920a8d34ea | |||
| c8dfcf4b39 | |||
| aa93632707 | |||
| cc55262cbc | |||
| f887b62a85 | |||
| 5b20781080 | |||
| 98a1efc123 | |||
| a628c1f5e4 | |||
| 6588e8fabf | |||
| 52d349538e | |||
| aad2b3a492 | |||
| 93180abf7b | |||
| e30c8d8949 | |||
| a90c5d71ad | |||
| 54f56813a5 | |||
| 8d29229c0f | |||
| dc498128be | |||
| 6d5b71b663 | |||
| 122fcbb40b | |||
| 4fc28bb65e | |||
| a7f92a3187 | |||
| dd16b68623 | |||
| df24d87245 | |||
| 6000e04c78 | |||
| 87181a8ecb | |||
| 7d0731754c | |||
| 962e63ab52 | |||
| 9f4b43f3f2 | |||
| ef722200c9 | |||
| 784f47fa86 | |||
| 90cdc28707 | |||
| 62844b321c | |||
| 8a6c7f5538 | |||
| 8c3eeb5201 | |||
| 5998fabadd | |||
| 97be02356f | |||
| e59867d479 | |||
| 8e1bcaed37 | |||
| f3c864c178 | |||
| 947923509e | |||
| 4e0f77c0f4 | |||
| 6f0505f19c | |||
| 98bf66cb25 | |||
| f9b641b24d | |||
| 3894314ab2 | |||
| edc9d38680 | |||
| ce5f72207e | |||
| ff8d009022 | |||
| 589c33ec05 | |||
| 28fe5b0df5 | |||
| 5a3dfe598f | |||
| d0c132ccd4 | |||
| 826541548c | |||
| e3adc76a72 | |||
| 2ae2d7ee1a | |||
| e28b50e8d6 | |||
| 9c78d86f58 | |||
| a6b23a751e | |||
| 34d5f1f9fe | |||
| 43ad15dc0e | |||
| d20147c79f | |||
| 7cc014cf9e | |||
| 9e735fc940 | |||
| 4fecf6c50d | |||
| c31c14e46b | |||
| 349dbb98a6 | |||
| f4fa5bb0fc | |||
| 4cdf75dc72 | |||
| 53eb39e033 | |||
| 57ae43890c | |||
| 1c59574cbf | |||
| 7ddef03aba | |||
| 4258738b89 | |||
| 594864e117 | |||
| a5698ce480 | |||
| 1a2c9011e6 | |||
| 600ac72a3d | |||
| 1118eed080 | |||
| e42c66bd0e | |||
| ff8fae377c | |||
| 6931252ed9 | |||
| ef8e549d86 | |||
| a5470029a8 | |||
| 13fb23d59d | |||
| a3197578d6 | |||
| ebc14b35f5 | |||
| b0235a2805 | |||
| d0069e0e1d | |||
| 878f136951 | |||
| bf364bf74c | |||
| 03c2850c59 | |||
| 4eddc7131d | |||
| 14be1935e8 | |||
| f08029354a | |||
| c18600b67f | |||
| 2acc0a6844 | |||
| 8ffba3a52f | |||
| 0fb2f35b10 | |||
| f8270b9cec | |||
| d3311ee231 | |||
| 21eb2c8dad | |||
| a11fd7a792 | |||
| a2ad9f8b10 | |||
| 9a0e2f3395 | |||
| cd9196ddb9 | |||
| c10fe673a2 | |||
| 105f8a1720 | |||
| 050f47daf1 | |||
| 683abd2029 | |||
| d08f937932 | |||
| 2f51742311 | |||
| b926d2f0bd | |||
| 89d1d36e79 | |||
| 999cd8cd11 | |||
| fd8b281731 | |||
| d8481b4528 | |||
| 6d93fa046c | |||
| c75672fd44 | |||
| 5484796745 | |||
| 4ed45e0515 | |||
| 9956c04526 | |||
| b74af71312 | |||
| 44640422f2 | |||
| be91f378ac | |||
| bdca18cc9f | |||
| 76cb15f545 | |||
| 4f9e754a51 | |||
| 955774a91a | |||
| e8a9485d5e | |||
| 0736c141b9 | |||
| 204549f55b | |||
| 82a5f307ed | |||
| 7a4650a1a9 | |||
| 518980d9ed | |||
| 5cc1e2e42d | |||
| c599385c8b | |||
| 1d37d3fdf7 | |||
| f3db64af05 | |||
| 3217372720 | |||
| 7a50654f3b | |||
| 9893921d76 | |||
| 5574f35473 | |||
| fd42e493c0 | |||
| 7843e6a709 | |||
| 4c129ec208 | |||
| 1bf44561da | |||
| ad612864ce | |||
| 1707436cad | |||
| b011d508f8 | |||
| f67a477f65 | |||
| 3573b97bfc | |||
| 37a42a3fb7 | |||
| 2d13ddc70c | |||
| 0be01f3c24 | |||
| eb492724c7 | |||
| 3b05d03220 | |||
| 4c04233a20 | |||
| 2b6d2fc117 | |||
| f64ef39687 | |||
| c1fb392333 | |||
| de60d5467c | |||
| c1274e24b0 | |||
| 7f593d3999 | |||
| 3a6a6097a7 | |||
| 69989e4e64 | |||
| 88999b34d3 | |||
| 582732918d | |||
| f1f69c607e | |||
| 8e82fee494 | |||
| a51475a094 | |||
| f25e2d48bd | |||
| 2bbff64a12 | |||
| 70b4503187 | |||
| 912bd4458f | |||
| d3f4494925 | |||
| 464467ae8b | |||
| 8e579ec8e0 | |||
| 4ef6cbf4fb | |||
| 68dfcddbe9 | |||
| 907761f14e | |||
| be7917c8d8 | |||
| 2e25f09ae4 | |||
| ea95d8604a | |||
| 35def3ab2e | |||
| 5527c12a8d | |||
| fb1cc72013 | |||
| 1f34883a27 | |||
| 724262651f | |||
| d7b2247878 | |||
| 372e7b6312 | |||
| 323a2d83fa | |||
| 03c3393616 | |||
| cbff011e3c | |||
| 2ba6fad633 | |||
| bc4878d71e | |||
| e991ae504b | |||
| c18181042f | |||
| 3de80d3b20 | |||
| 39dcd0a352 | |||
| 199e31ea3f | |||
| dce2247925 | |||
| 89e78c0276 | |||
| 9a57c11348 | |||
| 1dbe8b2a79 | |||
| 29fd0caf58 | |||
| d30701ed59 | |||
| e39550e77f | |||
| a21e7a5eee | |||
| 927b5ae707 | |||
| f59626004c | |||
| 2ece2719d0 | |||
| 78ee542d8d | |||
| cea9b38815 | |||
| cb8f6db68d | |||
| 85038c2b46 | |||
| 1e8055f504 | |||
| a7a5f20d1c | |||
| 0d744a4e74 | |||
| 216ec60dc1 | |||
| 3d9047bec4 | |||
| 08d65beb26 | |||
| 5cab66fb18 | |||
| 9466624f9d | |||
| 80b842a704 | |||
| d513a9fe5c | |||
| c98081cb04 | |||
| 17a1dc18be | |||
| b22ff229db | |||
| 23b03fd6ab | |||
| 97b273905a | |||
| e759c4d27a | |||
| 76685ae2d9 | |||
| 3fad3ceb35 | |||
| dede9e8549 | |||
| 97c018118d | |||
| 8b1ce36402 | |||
| 7931f315b1 | |||
| abb6404ab2 | |||
| c434542c65 | |||
| 42b7aa6450 | |||
| f2ce9cf857 | |||
| 56134d0202 | |||
| f33bbe2d5d | |||
| 59a478bdc5 | |||
| 141b332d4f | |||
| d4a312d6cb | |||
| 31d688b34c | |||
| fbef9ea600 | |||
| 0688491e1b | |||
| 434161687e | |||
| 4b3709b96b | |||
| 1fa993303d | |||
| 01897e7755 | |||
| 7040b2178d | |||
| edf23c4c18 | |||
| b0b9e66fad | |||
| 89488a43b9 | |||
| 798e13f70d | |||
| e758391a23 | |||
| 00d1e01e12 | |||
| 4f265a52a2 | |||
| 560717de76 | |||
| 0f40894317 | |||
| 3915e882a8 | |||
| c5caa23a63 | |||
| 36978d2ddc | |||
| 3f90c895b9 | |||
| 2ada171806 | |||
| 5dc683c968 | |||
| 7026cfe140 | |||
| b7cd1dd764 | |||
| 09bb8fc4f4 | |||
| 746ab49d36 | |||
| 1614dc975a | |||
| ba7598d90d | |||
| 92fc4872e8 | |||
| 30dbfc33a4 | |||
| b3de5aa08e | |||
| ba4773e448 | |||
| a713ee852c | |||
| a65accd412 | |||
| 1dc9583e06 | |||
| 3afe02ac1f | |||
| 57aa61f1ba | |||
| 121ea14fe4 | |||
| 9d457dc0ab | |||
| befd836ab4 | |||
| 044c301d64 | |||
| 94fd0df2e2 | |||
| e5087ca3db | |||
| 819a9da599 | |||
| fb02e55424 | |||
| 70e86434ef | |||
| c41b1e2f06 | |||
| 64641c28ef | |||
| 69e9f4ada2 | |||
| d28cf632e4 | |||
| b466bfa6c8 | |||
| 1c06f4cf06 | |||
| 25f40566ed | |||
| e8fa2cbc4d | |||
| 779c441e0a | |||
| e33031ee7d | |||
| ae63313b55 | |||
| ae50b8d839 | |||
| 10a27156c2 | |||
| 94057886a3 | |||
| 2d9bcb6e4f | |||
| 249bcd9e1a | |||
| b2679b7648 | |||
| 9995b8714b | |||
| 7b4dd2f7f5 | |||
| cc6b01cf88 | |||
| 3568ff72bf | |||
| e20614660b | |||
| c5a69f073c | |||
| 3025671b1a | |||
| 74da0043b4 | |||
| c0ddca12df | |||
| bf55e610b9 | |||
| 4e775a4090 | |||
| 9f7b31b5c5 | |||
| 279641df73 | |||
| 9e1fd16329 | |||
| d6ff5f0239 | |||
| 3f5d3fa0c6 | |||
| 51dc2b109e | |||
| 2358ff6f07 | |||
| 11788d2f39 | |||
| 541f7467c6 | |||
| 411c9707ee | |||
| ee0ba17c03 | |||
| 64bc850d8f | |||
| 154f64dae3 | |||
| 7fa758358f | |||
| f135881bd6 | |||
| 839301f81e | |||
| 04f4ca9772 | |||
| 525328fba1 | |||
| 471c125c1a | |||
| 8ef99137c6 | |||
| 404cad062a | |||
| d4be813f2e | |||
| ab3c0b2f03 | |||
| defcfc2962 | |||
| 267cfdf54b | |||
| a7b0231b3c | |||
| 7c19958840 | |||
| 34c3bb7d2c | |||
| b37545ee6c | |||
| c1e924c894 | |||
| 200e9e28ea | |||
| b95f958890 | |||
| fe9666bdaf | |||
| 948de5dc79 | |||
| 8800fd8250 | |||
| b1e5d8c915 | |||
| 02aec8b091 | |||
| 50517f6aa6 | |||
| a752473280 | |||
| 7e1972d483 | |||
| de48bf04bc | |||
| 228bf66cac | |||
| c986c1d26a | |||
| b0f7ea5b16 | |||
| 8b2e2ff1f8 | |||
| d00166223f | |||
| 4701b4bfc2 | |||
| e4c74c727f | |||
| f626ce29c4 | |||
| 768d8e5811 | |||
| 2ac3a4a103 | |||
| bb512f3fc0 | |||
| d6e7a89c97 | |||
| a5455da909 | |||
| 8dadc698cc | |||
| 2127712115 | |||
| d5b635027e | |||
| 9b2aeda51e | |||
| 5aba9b539f | |||
| b82020722b | |||
| b62a8fe65a | |||
| a5d85e3281 | |||
| e699bcf5a3 | |||
| 7ef5e079fd | |||
| 4076461347 | |||
| d610486c1e | |||
| 1891e2ad68 | |||
| f1e060902b | |||
| 7dbd920912 | |||
| 05ab9e3836 | |||
| a4e0f1f7aa | |||
| a8f27d13e6 | |||
| 05d425ea88 | |||
| 3cb12b5a60 | |||
| 8f1237e629 | |||
| 2c7f44f78d | |||
| a9447aa8c7 | |||
| 9b61b350fe | |||
| e3cf65fbdf | |||
| e51d43568e | |||
| 1bb6b7acdd | |||
| adc7a3ba4a | |||
| 94ec6cc362 | |||
| bbdb5eb6e3 | |||
| e487ca8bd8 | |||
| f5b0e20f78 | |||
| 6116eebbad | |||
| 8619705e44 | |||
| c216ed2d1f | |||
| e17dc25bba | |||
| d311915f9d | |||
| 3a95826b42 | |||
| dcc1009162 | |||
| d61e01ff4f | |||
| 51b9d8e7ad | |||
| 90eb5e9c31 | |||
| 17c34c88dc | |||
| ff6f658f9d | |||
| fb798a4150 | |||
| 4213bb3a62 | |||
| 8a34f91172 | |||
| 764ddd4773 | |||
| ea0dcc8ebd | |||
| 3f5db9f7f9 | |||
| a6a0bba1b7 | |||
| 5ec785e2f7 | |||
| f7d9f1f69d | |||
| 42efd2d005 | |||
| d32e13daee | |||
| e82c21e944 | |||
| 33f835a437 | |||
| 59d8110801 | |||
| d028b381fa | |||
| a1a3f810f0 | |||
| c96f0f2396 | |||
| 46c8985661 | |||
| c588639503 | |||
| b3c6f559b2 | |||
| 85544d109c | |||
| 4aba595b2b | |||
| b2241dca72 | |||
| 4ffe742b69 | |||
| 5979b8e385 | |||
| 955bd5a6d1 | |||
| 1eb8191519 | |||
| 396bda5611 | |||
| cb334be8c4 | |||
| 8845cc0556 | |||
| e34800ad49 | |||
| 5b574901b3 | |||
| 59b68154e1 | |||
| 5a501c8e48 | |||
| f927c15adf | |||
| d08157f7db | |||
| 8a9ac4f01f | |||
| 39df5f3b15 | |||
| 981bf328ae | |||
| 1f8e9727b0 | |||
| f604bcb557 | |||
| eccf9eb4a4 | |||
| 39403fa885 | |||
| 5e7cc30564 | |||
| f942b4c657 | |||
| f5aeb5b068 | |||
| 7f6cb9b07b | |||
| db3657d411 | |||
| 38e5da724d | |||
| 24a63eb304 | |||
| c1f5ae1c5a | |||
| 009211c740 | |||
| 1a208a1612 | |||
| b867e51c6c | |||
| 7693b93c50 | |||
| c3d7158669 | |||
| 9f5e50f25e | |||
| a091ab76d7 | |||
| d5eb242295 | |||
| b21e65fc5f | |||
| 1b07e81936 | |||
| 962b2d45ef | |||
| 7894b41277 | |||
| 51d0b8d2b5 | |||
| 7b992a1dc4 | |||
| 2f8615c6c4 | |||
| aee6d9d01c | |||
| fd4a0dbedf | |||
| 14381ac68a | |||
| c00a98fed4 | |||
| aab7581909 | |||
| 74dcc1b9d5 | |||
| 17241b3543 | |||
| a4a859f47b | |||
| b66ed8bc41 | |||
| 754feff5e7 | |||
| cd1b425a80 | |||
| 187947e8d8 | |||
| 6b38927123 | |||
| f46e4049b6 | |||
| 0ea8299fa7 | |||
| 5d793193e0 | |||
| 62337f75b8 | |||
| 4d4fdfff70 | |||
| b63d0a3138 | |||
| 7949c09183 | |||
| 3f535aca8c | |||
| 9f44809164 | |||
| f7ccb18af5 | |||
| cca9945867 | |||
| f23c6b0c2f | |||
| 6d22b8c6ed | |||
| 245ce7259c | |||
| f36cd60fdb | |||
| 8467e2d376 | |||
| 2529918d5f | |||
| e2711a6121 | |||
| 89d22e5f94 | |||
| f13fda9be5 | |||
| 49f6a63a06 | |||
| e078fea846 | |||
| 048c8b1670 | |||
| 3b5c38d861 | |||
| 90fb075e34 | |||
| 08c6d9ce96 | |||
| 76ccb8c31f | |||
| 3dfc502814 | |||
| df0f626283 | |||
| 1909ce9220 | |||
| 15bef82e1e | |||
| 60a45241e6 | |||
| d403e92315 | |||
| eed7ede376 | |||
| d20f49b58b | |||
| 37091df142 | |||
| 21081cf80f | |||
| c213b37e96 | |||
| d1ca84aa43 | |||
| 0f7fbc411a | |||
| f4b2b1b03f | |||
| 0ecc36c4a5 | |||
| a48eace90a | |||
| 7a2a51ad44 | |||
| f56fcb0a14 | |||
| 7816652078 | |||
| 20aacc7026 | |||
| 49938cfd09 | |||
| 53a4ed6b24 | |||
| 534000b49d | |||
| 7e2ccbf909 | |||
| b0b6968185 | |||
| 94963b5b3a | |||
| 77fa61e6fc | |||
| 94c450ad16 | |||
| a292bf7c83 | |||
| b24ee1c44f | |||
| 981b22ba49 | |||
| e1eedd3bba | |||
| b949fd4d43 |
@@ -1,57 +0,0 @@
|
||||
# minimum clang-format 10
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Allman
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 100
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 8
|
||||
ContinuationIndentWidth: 8
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ForEachMacros: [ BOOST_FOREACH ]
|
||||
IndentCaseLabels: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
Language: Cpp
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: Inner
|
||||
PointerAlignment: Left
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: Never
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: true
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: c++11
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
@@ -30,7 +30,3 @@ bitmaps_png/cpp_*/*.cpp generated
|
||||
# Lemon grammars
|
||||
common/libeval/grammar.c generated
|
||||
common/libeval/grammar.h generated
|
||||
|
||||
# Scripts
|
||||
*.sh text eol=lf
|
||||
*.bat text eol=crlf
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
custom: "https://donate.kicad.org"
|
||||
community_bridge: kicad
|
||||
community_bridge: kicad
|
||||
custom: "https://donate.cernandsocietyfoundation.cern/b/my-donation?cid=4&_cv=1"
|
||||
+5
-12
@@ -1,8 +1,8 @@
|
||||
.downloads-by-cmake
|
||||
.gdb_history
|
||||
boost_root
|
||||
/Build*
|
||||
/build*
|
||||
/Build
|
||||
/build
|
||||
/cmake-build-*
|
||||
common/fp_lib_table_keywords.cpp
|
||||
common/drc_rules_keywords.cpp
|
||||
@@ -17,6 +17,8 @@ include/fp_lib_table_lexer.h
|
||||
include/lib_table_lexer.h
|
||||
include/netlist_lexer.h
|
||||
include/page_layout_reader_lexer.h
|
||||
eeschema/cmp_library_lexer.h
|
||||
eeschema/cmp_library_keywords.*
|
||||
eeschema/dialogs/dialog_bom_cfg_keywords.cpp
|
||||
eeschema/dialogs/dialog_bom_cfg_lexer.h
|
||||
common/template_fieldnames_keywords.cpp
|
||||
@@ -25,11 +27,11 @@ eeschema/schematic_keywords.*
|
||||
pcbnew/pcb_plot_params_keywords.cpp
|
||||
pcbnew/pcb_plot_params_lexer.h
|
||||
Makefile
|
||||
CMakeUserPresets.json
|
||||
CMakeCache.txt
|
||||
.cache/
|
||||
auto_renamed_to_cpp
|
||||
Testing
|
||||
version.h
|
||||
config.h
|
||||
install_manifest.txt
|
||||
doxygen/out
|
||||
@@ -50,13 +52,11 @@ bitmaps_png/tmp
|
||||
common/pcb_keywords.cpp
|
||||
include/pcb_lexer.h
|
||||
fp-info-cache
|
||||
qa/tests/output/**
|
||||
|
||||
# demo project auxiliary files
|
||||
demos/**/*-bak
|
||||
demos/**/_autosave-*
|
||||
demos/**/fp-info-cache
|
||||
demos/**/~*.lck
|
||||
|
||||
# MacOS package info created by CMake
|
||||
bitmap2component/Info.plist
|
||||
@@ -102,9 +102,6 @@ __pycache__
|
||||
.editorconfig
|
||||
CMakeSettings.json
|
||||
.vscode/
|
||||
compile_commands.json
|
||||
/vcpkg_installed
|
||||
CMakePresets.json
|
||||
|
||||
# Sublime Text
|
||||
*.sublime-*
|
||||
@@ -113,10 +110,6 @@ CMakePresets.json
|
||||
.kdev4/
|
||||
*.kdev4
|
||||
|
||||
# Qt Creator
|
||||
CMakeLists.txt.user
|
||||
*.autosave
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
i18n_status.svg
|
||||
|
||||
+29
-6
@@ -3,21 +3,44 @@ stages:
|
||||
- test
|
||||
- report
|
||||
|
||||
variables:
|
||||
DEFAULT_FEDORA_IMAGE: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:40
|
||||
|
||||
default:
|
||||
image:
|
||||
name: $DEFAULT_FEDORA_IMAGE
|
||||
name: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:36
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Test the formatting in a merge request using clang-format
|
||||
##########################################################################
|
||||
# The variable CI_COMMIT_BEFORE_SHA is not available in normal merge requests
|
||||
# so we must build the commit hash ourselves, see:
|
||||
# https://gitlab.com/gitlab-org/gitlab/-/issues/12850
|
||||
test_formatting:
|
||||
stage: test
|
||||
needs: []
|
||||
only:
|
||||
- merge_requests
|
||||
allow_failure: true
|
||||
before_script:
|
||||
# We must manually add the KiCad remote to ensure it is named sensibly
|
||||
- git remote add product https://gitlab.com/kicad/code/kicad.git
|
||||
- git remote add source ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}.git
|
||||
- git fetch -n product
|
||||
- git fetch -n source
|
||||
# Get the SHAs of the commits
|
||||
- "TARGET_HEAD_SHA=$(git rev-parse product/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME})"
|
||||
- "SOURCE_HEAD_SHA=$(git rev-parse source/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME})"
|
||||
- "MERGE_BASE_SHA=$(git merge-base ${TARGET_HEAD_SHA} ${SOURCE_HEAD_SHA})"
|
||||
script:
|
||||
- echo "Testing formatting from commit ${MERGE_BASE_SHA}"
|
||||
- ./tools/check_coding.sh --diff --ci --commit ${MERGE_BASE_SHA}
|
||||
|
||||
|
||||
include:
|
||||
- local: '/.gitlab/templates.yml'
|
||||
- local: '/.gitlab/Fedora-Linux-CI.yml'
|
||||
- local: '/.gitlab/Ubuntu-20.04-CI.yml'
|
||||
- local: '/.gitlab/Windows-CI.yml'
|
||||
- local: '/.gitlab/macOS-CI.yml'
|
||||
- local: '/.gitlab/coverity.yml'
|
||||
- local: '/.gitlab/linux-metadata-validate.yml'
|
||||
- local: '/.gitlab/doxygen.yml'
|
||||
- local: '/.gitlab/mr_formatting.yml'
|
||||
|
||||
+14
-28
@@ -6,7 +6,7 @@
|
||||
# Don't tag until we have separate CI for MRs
|
||||
# tags:
|
||||
# - kicad-fedora
|
||||
image: $DEFAULT_FEDORA_IMAGE
|
||||
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
|
||||
extends: .only_code
|
||||
interruptible: false
|
||||
cache:
|
||||
@@ -25,10 +25,8 @@
|
||||
-G Ninja
|
||||
-DCMAKE_BUILD_TYPE=QABUILD
|
||||
-DKICAD_STDLIB_LIGHT_DEBUG=ON
|
||||
-DKICAD_SPICE=ON
|
||||
-DKICAD_BUILD_I18N=ON
|
||||
-DKICAD_TEST_XML_OUTPUT=ON
|
||||
-DKICAD_BUILD_PNS_DEBUG_TOOL=ON
|
||||
-DKICAD_USE_CMAKE_FINDPROTOBUF=ON
|
||||
../../
|
||||
- ninja 2>&1 | tee compilation_log.txt
|
||||
- cd ../../
|
||||
@@ -40,17 +38,10 @@
|
||||
when: always
|
||||
paths:
|
||||
- build/linux/3d-viewer/
|
||||
- build/linux/api/libkiapi.so*
|
||||
- build/linux/common/libkicommon.so*
|
||||
- build/linux/common/gal/libkigal.so*
|
||||
- build/linux/eeschema/_eeschema.kiface
|
||||
- build/linux/cvpcb/_cvpcb.kiface
|
||||
- build/linux/kicad/kicad-cli
|
||||
- build/linux/pcbnew/pcbnew.py
|
||||
- build/linux/pcbnew/_pcbnew.kiface
|
||||
- build/linux/pcbnew/_pcbnew.so
|
||||
- build/linux/qa/
|
||||
- build/linux/schemas/
|
||||
- build/linux/compilation_log.txt
|
||||
exclude:
|
||||
- build/linux/**/*.o
|
||||
@@ -61,18 +52,16 @@ fedora_build_linux_kicad:
|
||||
extends: .fedora_build_linux_base
|
||||
tags:
|
||||
- kicad-fedora
|
||||
only:
|
||||
only:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
fedora_build_linux_public:
|
||||
extends: .fedora_build_linux_base
|
||||
tags:
|
||||
- saas-linux-medium-amd64
|
||||
except:
|
||||
except:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
|
||||
|
||||
# Upload the compilation log in an easily downloadable form
|
||||
.fedora_report_build_warn:
|
||||
@@ -96,7 +85,7 @@ fedora_report_build_warn_kicad:
|
||||
needs:
|
||||
- job: fedora_build_linux_kicad
|
||||
artifacts: true
|
||||
only:
|
||||
only:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
@@ -105,10 +94,10 @@ fedora_report_build_warn_public:
|
||||
needs:
|
||||
- job: fedora_build_linux_public
|
||||
artifacts: true
|
||||
except:
|
||||
except:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
|
||||
|
||||
# Report on the metrics of the code
|
||||
.fedora_report_metrics:
|
||||
@@ -129,7 +118,7 @@ fedora_report_metrics_kicad:
|
||||
needs:
|
||||
- job: fedora_build_linux_kicad
|
||||
artifacts: true
|
||||
only:
|
||||
only:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
@@ -138,7 +127,7 @@ fedora_report_metrics_public:
|
||||
needs:
|
||||
- job: fedora_build_linux_public
|
||||
artifacts: true
|
||||
except:
|
||||
except:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
@@ -146,17 +135,14 @@ fedora_report_metrics_public:
|
||||
# Run the code unit tests.
|
||||
##########################################################################
|
||||
.fedora_qa:
|
||||
image: $DEFAULT_FEDORA_IMAGE
|
||||
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
|
||||
extends:
|
||||
- .unit_test
|
||||
- .only_code
|
||||
before_script:
|
||||
- if [ "$TEST" == "cli" ] || [ "$TEST" == "python" ]; then python3 -m pip install -r qa/tests/requirements.txt; fi
|
||||
- if [ "$TEST" == "cli" ]; then sudo dnf -y install gerbv; fi
|
||||
parallel:
|
||||
matrix:
|
||||
# The name of the test without the qa_ prefix
|
||||
- TEST: [python, cli, common, gerbview, pcbnew, pns_regressions, eeschema, kimath, sexpr, kicad2step, spice, api]
|
||||
- TEST: [python, common, gerbview, pcbnew, eeschema, kimath, sexpr, kicad2step]
|
||||
|
||||
fedora_qa_kicad:
|
||||
extends: .fedora_qa
|
||||
@@ -165,7 +151,7 @@ fedora_qa_kicad:
|
||||
needs:
|
||||
- job: fedora_build_linux_kicad
|
||||
artifacts: true
|
||||
only:
|
||||
only:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
@@ -174,6 +160,6 @@ fedora_qa_public:
|
||||
needs:
|
||||
- job: fedora_build_linux_public
|
||||
artifacts: true
|
||||
except:
|
||||
except:
|
||||
variables:
|
||||
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
-DKICAD_STDLIB_LIGHT_DEBUG=ON
|
||||
-DKICAD_SCRIPTING_WXPYTHON=ON
|
||||
-DKICAD_USE_OCC=ON
|
||||
-DKICAD_SPICE=ON
|
||||
-DKICAD_BUILD_I18N=ON
|
||||
-DKICAD_BUILD_PNS_DEBUG_TOOL=ON
|
||||
../../
|
||||
@@ -115,4 +116,4 @@
|
||||
parallel:
|
||||
matrix:
|
||||
# The name of the test without the qa_ prefix
|
||||
- TEST: [python, common, gerbview, pcbnew, eeschema, kimath, sexpr, kicad2step, spice]
|
||||
- TEST: [python, common, gerbview, pcbnew, eeschema, kimath, sexpr, kicad2step]
|
||||
|
||||
+11
-11
@@ -4,25 +4,25 @@
|
||||
win64_build:
|
||||
stage: build
|
||||
tags:
|
||||
- kicad-windows-ltsc2022
|
||||
- kicad-windows-1809
|
||||
extends: .only_code
|
||||
interruptible: false
|
||||
image: registry.gitlab.com/kicad/kicad-ci/windows-build-image/ltsc2022-msvc:latest
|
||||
image: registry.gitlab.com/kicad/kicad-ci/windows-build-image/win1809-msvc:latest
|
||||
variables:
|
||||
# Switch the compressor to fastzip and reduce the compression level
|
||||
FF_USE_FASTZIP: "true"
|
||||
CACHE_COMPRESSION_LEVEL: "fast"
|
||||
VCPKG_BINARY_SOURCES: 'nuget,kicad,readwrite'
|
||||
cache:
|
||||
key: win64-vcpkg-$CI_COMMIT_REF_SLUG
|
||||
key: win64-vcpkg-"$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- build\windows\vcpkg_installed
|
||||
- .vcpkgCache
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "schedule"
|
||||
when: never
|
||||
- if: $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
only:
|
||||
- branches@kicad/code/kicad
|
||||
- tags@kicad/code/kicad
|
||||
script:
|
||||
- C:\builder\build.ps1 -Env -Arch x64
|
||||
- $vcpkgCache=Join-Path -Path (Get-Location) -ChildPath ".vcpkgCache";$env:VCPKG_DEFAULT_BINARY_CACHE=$vcpkgCache;New-Item -ItemType Directory -Force -Path $vcpkgCache
|
||||
- nuget.exe sources add -Name kicad -Source "https://nuget.kicad.org:443/v3/index.json"
|
||||
- nuget.exe setapikey $env:KICAD_NUGET_KEY -Source "https://nuget.kicad.org:443/v3/index.json"
|
||||
- mkdir -p build/windows -Force
|
||||
- cd build/windows
|
||||
- cmake `
|
||||
@@ -31,9 +31,9 @@ win64_build:
|
||||
-DCMAKE_BUILD_TYPE=Debug `
|
||||
-DKICAD_SCRIPTING_WXPYTHON=OFF `
|
||||
-DKICAD_USE_OCC=ON `
|
||||
-DKICAD_SPICE=ON `
|
||||
-DKICAD_BUILD_PNS_DEBUG_TOOL=ON `
|
||||
-DKICAD_USE_3DCONNEXION=ON `
|
||||
-DVCPKG_BUILD_TYPE=debug `
|
||||
../../
|
||||
- cmake --build . 2>&1 | tee compilation_log.txt
|
||||
- cd ../../
|
||||
|
||||
+11
-17
@@ -22,16 +22,13 @@
|
||||
# These results will be saved for 1 day if the build fails.
|
||||
.coverity_submit: &coverity_submit |
|
||||
echo "Creating tar file of scan results"
|
||||
export COV_INT_FILENAME=cov-int-$(date +"%Y%m%d%H%M").tar.gz
|
||||
tar cfz $COV_INT_FILENAME cov-int
|
||||
tar cfz cov-int.tar.gz cov-int
|
||||
echo "Submitting scan results"
|
||||
s5cmd/s5cmd cp $COV_INT_FILENAME s3://$KICAD_CI_R2_BUCKET/coverity/
|
||||
export FILE_URL="$KICAD_CI_R2_PUBLIC_BASE/coverity/$COV_INT_FILENAME"
|
||||
export KICAD_VERSION=$(sed 's/[()]//g' kicad_build_version.txt)
|
||||
curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME \
|
||||
--form token=$COVERITY_SCAN_TOKEN \
|
||||
--form email=$GITLAB_USER_EMAIL \
|
||||
--form url="$FILE_URL" \
|
||||
--form file=@cov-int.tar.gz \
|
||||
--form version="$KICAD_VERSION" \
|
||||
--form description="$KICAD_VERSION / $CI_COMMIT_TITLE" 2>&1 \
|
||||
| tee curl-response.txt
|
||||
@@ -42,9 +39,12 @@ Coverity:
|
||||
tags:
|
||||
- coverity
|
||||
stage: build
|
||||
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:40
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_JOB_NAME == "coverity"
|
||||
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
|
||||
only:
|
||||
refs:
|
||||
- schedules
|
||||
variables:
|
||||
- $SCHEDULED_JOB_NAME == "coverity"
|
||||
cache:
|
||||
key: coverity
|
||||
paths:
|
||||
@@ -53,20 +53,14 @@ Coverity:
|
||||
- export COVERITY_SCAN_PROJECT_NAME="kicad"
|
||||
- test "$(git rev-parse --is-shallow-repository)" = "false" || (git fetch --unshallow)
|
||||
- git fetch origin
|
||||
- curl -LO https://github.com/peak/s5cmd/releases/download/v2.0.0/s5cmd_2.0.0_Linux-64bit.tar.gz
|
||||
- mkdir s5cmd
|
||||
- tar -xvf ./s5cmd_2.0.0_Linux-64bit.tar.gz -C s5cmd
|
||||
- export AWS_ACCESS_KEY_ID=$KICAD_CI_R2_KEY_ID
|
||||
- export AWS_SECRET_ACCESS_KEY=$KICAD_CI_R2_ACCESS_KEY
|
||||
- export S3_ENDPOINT_URL=$KICAD_CI_R2_ENDPOINT
|
||||
script:
|
||||
- *coverity_cache_prep
|
||||
- cmake
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
-DKICAD_STDLIB_LIGHT_DEBUG=ON
|
||||
-DKICAD_SCRIPTING_WXPYTHON=ON
|
||||
-DKICAD_USE_CMAKE_FINDPROTOBUF=ON
|
||||
- coverity/bin/cov-build --dir cov-int make -j10
|
||||
-DKICAD_SPICE=ON
|
||||
- coverity/bin/cov-build --dir cov-int make -j8
|
||||
- *coverity_submit
|
||||
artifacts:
|
||||
expire_in: 1 year
|
||||
|
||||
+6
-3
@@ -3,13 +3,16 @@ build_doxygen_docker:
|
||||
services:
|
||||
- docker:dind
|
||||
stage: build
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_JOB_NAME == "doxygen"
|
||||
tags:
|
||||
- gitlab-org-docker
|
||||
- docker
|
||||
before_script:
|
||||
- docker info
|
||||
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
|
||||
script:
|
||||
- docker build -t "${CI_REGISTRY_IMAGE}/doxygen:$CI_COMMIT_BRANCH" -f ./doxygen/doxygen.Dockerfile .
|
||||
- docker push "${CI_REGISTRY_IMAGE}/doxygen:$CI_COMMIT_BRANCH"
|
||||
only:
|
||||
refs:
|
||||
- schedules
|
||||
variables:
|
||||
- $SCHEDULED_JOB_NAME == "doxygen"
|
||||
|
||||
@@ -5,18 +5,24 @@ validate_linux_metadata:
|
||||
stage: test
|
||||
needs: []
|
||||
interruptible: false
|
||||
image: $DEFAULT_FEDORA_IMAGE
|
||||
# This is the only CI image with the utilities needed for this test
|
||||
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
|
||||
# Due to bug https://github.com/hughsie/appstream-glib/issues/381, this doesn't think our description tag
|
||||
# is localized even though it actually is.
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "schedule"
|
||||
when: never
|
||||
- if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- resources/linux/**/*
|
||||
- qa/resources/linux/**/*
|
||||
- translation/**/*
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
- branches
|
||||
- merge_requests
|
||||
- pushes
|
||||
changes:
|
||||
# Only run if the resources, its tests, or the translations are updated
|
||||
- resources/linux/**/*
|
||||
- qa/resources/linux/**/*
|
||||
- translation/**/*
|
||||
except:
|
||||
- schedules
|
||||
# Only build the metadata files in this CI job
|
||||
script:
|
||||
- mkdir -p build/linux
|
||||
@@ -25,6 +31,7 @@ validate_linux_metadata:
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
-DKICAD_STDLIB_LIGHT_DEBUG=ON
|
||||
-DKICAD_SCRIPTING_WXPYTHON=ON
|
||||
-DKICAD_SPICE=ON
|
||||
-DKICAD_BUILD_I18N=ON
|
||||
../../
|
||||
- make metadata
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
##########################################################################
|
||||
# Build KiCad on Windows and save the results
|
||||
##########################################################################
|
||||
macos_build:
|
||||
stage: build
|
||||
tags:
|
||||
- kicad-macos
|
||||
interruptible: false
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "schedule"
|
||||
when: never
|
||||
- if: $CI_PROJECT_ROOT_NAMESPACE == "kicad"
|
||||
script:
|
||||
- mkdir -p build/macos
|
||||
- cd build/macos
|
||||
- cmake
|
||||
-G Ninja
|
||||
-DCMAKE_TOOLCHAIN_FILE=/Users/$USER/kicad-mac-builder/toolchain/kicad-mac-builder.cmake
|
||||
../../
|
||||
- cmake --build . 2>&1 | tee compilation_log.txt
|
||||
- cd ../../
|
||||
artifacts:
|
||||
# Only save the artifacts that are needed for running the tests in the next stage
|
||||
# and the compilation log. The entire build directory is too large to save as an
|
||||
# artifact.
|
||||
expire_in: 2 hrs
|
||||
when: always
|
||||
paths:
|
||||
- build/macos/compilation_log.txt
|
||||
@@ -12,10 +12,8 @@ test_formatting:
|
||||
allow_failure: true
|
||||
before_script:
|
||||
# We must manually add the KiCad remote to ensure it is named sensibly
|
||||
- git remote add product https://gitlab.com/kicad/code/kicad.git ||
|
||||
git remote set-url product https://gitlab.com/kicad/code/kicad.git
|
||||
- git remote add source ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}.git ||
|
||||
git remote set-url source ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}.git
|
||||
- git remote add product https://gitlab.com/kicad/code/kicad.git
|
||||
- git remote add source ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL}.git
|
||||
- git fetch -n product
|
||||
- git fetch -n source
|
||||
# Get the SHAs of the commits
|
||||
|
||||
+10
-10
@@ -17,21 +17,21 @@
|
||||
.unit_test:
|
||||
stage: test
|
||||
when: on_success
|
||||
variables:
|
||||
BOOST_TEST_LOGGER: 'JUNIT,warning,test_results.${TEST}.xml:HRF,message'
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
# We define this using a before script because GitLab cannot merge variable
|
||||
# definitions across inheritance (so the variables block from this would disappear)
|
||||
before_script:
|
||||
- export BOOST_TEST_LOGGER='JUNIT,all,test_results.${TEST}.xml:HRF,warning'
|
||||
- export CTEST_OUTPUT_ON_FAILURE=1
|
||||
script:
|
||||
- cd build/linux/qa
|
||||
- ctest -R qa_${TEST}
|
||||
# GitLab supports displaying the results in the GUI through JUNIT artifacts
|
||||
# (https://docs.gitlab.com/ee/ci/junit_test_reports.html)
|
||||
# so we upload the JUNIT results.
|
||||
# so we upload the JUNIT results. Note that there is a bug with how paths
|
||||
# are processed in the junit report (https://gitlab.com/gitlab-org/gitlab/-/issues/23835)
|
||||
# so we can't use a glob and have to list out each hierarchy separately.
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- build/linux/qa/**/*.log
|
||||
- build/linux/qa/**/output/*
|
||||
- build/linux/qa/**/*.xml
|
||||
reports:
|
||||
junit:
|
||||
- build/linux/qa/**/*.xml
|
||||
- build/linux/qa/*/*.xml
|
||||
- build/linux/qa/*/*/*.xml
|
||||
|
||||
+173
-30
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2022 CERN
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -33,6 +33,14 @@
|
||||
#include <wx/log.h>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if BOOST_VERSION >= 106800
|
||||
#include <boost/uuid/detail/sha1.hpp>
|
||||
#else
|
||||
#include <boost/uuid/sha1.hpp>
|
||||
#endif
|
||||
|
||||
#include "3d_cache.h"
|
||||
#include "3d_info.h"
|
||||
#include "3d_plugin_manager.h"
|
||||
@@ -42,7 +50,6 @@
|
||||
#include <advanced_config.h>
|
||||
#include <common.h> // For ExpandEnvVarSubstitutions
|
||||
#include <filename_resolver.h>
|
||||
#include <mmh3_hash.h>
|
||||
#include <paths.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project.h>
|
||||
@@ -54,6 +61,19 @@
|
||||
#define MASK_3D_CACHE "3D_CACHE"
|
||||
|
||||
static std::mutex mutex3D_cache;
|
||||
static std::mutex mutex3D_cacheManager;
|
||||
|
||||
|
||||
static bool isSHA1Same( const unsigned char* shaA, const unsigned char* shaB ) noexcept
|
||||
{
|
||||
for( int i = 0; i < 20; ++i )
|
||||
{
|
||||
if( shaA[i] != shaB[i] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool checkTag( const char* aTag, void* aPluginMgrPtr )
|
||||
@@ -67,17 +87,51 @@ static bool checkTag( const char* aTag, void* aPluginMgrPtr )
|
||||
}
|
||||
|
||||
|
||||
static const wxString sha1ToWXString( const unsigned char* aSHA1Sum )
|
||||
{
|
||||
unsigned char uc;
|
||||
unsigned char tmp;
|
||||
char sha1[41];
|
||||
int j = 0;
|
||||
|
||||
for( int i = 0; i < 20; ++i )
|
||||
{
|
||||
uc = aSHA1Sum[i];
|
||||
tmp = uc / 16;
|
||||
|
||||
if( tmp > 9 )
|
||||
tmp += 87;
|
||||
else
|
||||
tmp += 48;
|
||||
|
||||
sha1[j++] = tmp;
|
||||
tmp = uc % 16;
|
||||
|
||||
if( tmp > 9 )
|
||||
tmp += 87;
|
||||
else
|
||||
tmp += 48;
|
||||
|
||||
sha1[j++] = tmp;
|
||||
}
|
||||
|
||||
sha1[j] = 0;
|
||||
|
||||
return wxString::FromUTF8Unchecked( sha1 );
|
||||
}
|
||||
|
||||
|
||||
class S3D_CACHE_ENTRY
|
||||
{
|
||||
public:
|
||||
S3D_CACHE_ENTRY();
|
||||
~S3D_CACHE_ENTRY();
|
||||
|
||||
void SetHash( const HASH_128& aHash );
|
||||
void SetSHA1( const unsigned char* aSHA1Sum );
|
||||
const wxString GetCacheBaseName();
|
||||
|
||||
wxDateTime modTime; // file modification time
|
||||
HASH_128 m_hash;
|
||||
unsigned char sha1sum[20];
|
||||
std::string pluginInfo; // PluginName:Version string
|
||||
SCENEGRAPH* sceneData;
|
||||
S3DMODEL* renderData;
|
||||
@@ -87,7 +141,7 @@ private:
|
||||
S3D_CACHE_ENTRY( const S3D_CACHE_ENTRY& source );
|
||||
S3D_CACHE_ENTRY& operator=( const S3D_CACHE_ENTRY& source );
|
||||
|
||||
wxString m_CacheBaseName; // base name of cache file
|
||||
wxString m_CacheBaseName; // base name of cache file (a SHA1 digest)
|
||||
};
|
||||
|
||||
|
||||
@@ -95,7 +149,7 @@ S3D_CACHE_ENTRY::S3D_CACHE_ENTRY()
|
||||
{
|
||||
sceneData = nullptr;
|
||||
renderData = nullptr;
|
||||
m_hash.Clear();
|
||||
memset( sha1sum, 0, 20 );
|
||||
}
|
||||
|
||||
|
||||
@@ -108,16 +162,24 @@ S3D_CACHE_ENTRY::~S3D_CACHE_ENTRY()
|
||||
}
|
||||
|
||||
|
||||
void S3D_CACHE_ENTRY::SetHash( const HASH_128& aHash )
|
||||
void S3D_CACHE_ENTRY::SetSHA1( const unsigned char* aSHA1Sum )
|
||||
{
|
||||
m_hash = aHash;
|
||||
if( nullptr == aSHA1Sum )
|
||||
{
|
||||
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [BUG] NULL passed for aSHA1Sum" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy( sha1sum, aSHA1Sum, 20 );
|
||||
}
|
||||
|
||||
|
||||
const wxString S3D_CACHE_ENTRY::GetCacheBaseName()
|
||||
{
|
||||
if( m_CacheBaseName.empty() )
|
||||
m_CacheBaseName = m_hash.ToString();
|
||||
m_CacheBaseName = sha1ToWXString( sha1sum );
|
||||
|
||||
return m_CacheBaseName;
|
||||
}
|
||||
@@ -141,12 +203,12 @@ S3D_CACHE::~S3D_CACHE()
|
||||
|
||||
|
||||
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePath,
|
||||
S3D_CACHE_ENTRY** aCachePtr, const EMBEDDED_FILES* aEmbeddedFiles )
|
||||
S3D_CACHE_ENTRY** aCachePtr )
|
||||
{
|
||||
if( aCachePtr )
|
||||
*aCachePtr = nullptr;
|
||||
|
||||
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile, aBasePath, aEmbeddedFiles );
|
||||
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile, aBasePath );
|
||||
|
||||
if( full3Dpath.empty() )
|
||||
{
|
||||
@@ -173,13 +235,13 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePa
|
||||
|
||||
if( fmdate != mi->second->modTime )
|
||||
{
|
||||
HASH_128 hashSum;
|
||||
getHash( full3Dpath, hashSum );
|
||||
unsigned char hashSum[20];
|
||||
getSHA1( full3Dpath, hashSum );
|
||||
mi->second->modTime = fmdate;
|
||||
|
||||
if( hashSum != mi->second->m_hash )
|
||||
if( !isSHA1Same( hashSum, mi->second->sha1sum ) )
|
||||
{
|
||||
mi->second->SetHash( hashSum );
|
||||
mi->second->SetSHA1( hashSum );
|
||||
reload = true;
|
||||
}
|
||||
}
|
||||
@@ -211,10 +273,9 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePa
|
||||
}
|
||||
|
||||
|
||||
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath,
|
||||
const EMBEDDED_FILES* aEmbeddedFiles )
|
||||
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath )
|
||||
{
|
||||
return load( aModelFile, aBasePath, nullptr, aEmbeddedFiles );
|
||||
return load( aModelFile, aBasePath );
|
||||
}
|
||||
|
||||
|
||||
@@ -223,13 +284,13 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
|
||||
if( aCachePtr )
|
||||
*aCachePtr = nullptr;
|
||||
|
||||
HASH_128 hashSum;
|
||||
unsigned char sha1sum[20];
|
||||
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
|
||||
m_CacheList.push_back( ep );
|
||||
wxFileName fname( aFileName );
|
||||
ep->modTime = fname.GetModificationTime();
|
||||
|
||||
if( !getHash( aFileName, hashSum ) || m_CacheDir.empty() )
|
||||
if( !getSHA1( aFileName, sha1sum ) || m_CacheDir.empty() )
|
||||
{
|
||||
// just in case we can't get a hash digest (for example, on access issues)
|
||||
// or we do not have a configured cache file directory, we create an
|
||||
@@ -267,7 +328,7 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
|
||||
if( aCachePtr )
|
||||
*aCachePtr = ep;
|
||||
|
||||
ep->SetHash( hashSum );
|
||||
ep->SetSHA1( sha1sum );
|
||||
|
||||
wxString bname = ep->GetCacheBaseName();
|
||||
wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
|
||||
@@ -285,7 +346,7 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
|
||||
}
|
||||
|
||||
|
||||
bool S3D_CACHE::getHash( const wxString& aFileName, HASH_128& aHash )
|
||||
bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum )
|
||||
{
|
||||
if( aFileName.empty() )
|
||||
{
|
||||
@@ -295,6 +356,14 @@ bool S3D_CACHE::getHash( const wxString& aFileName, HASH_128& aHash )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( nullptr == aSHA1Sum )
|
||||
{
|
||||
wxLogTrace( MASK_3D_CACHE, wxT( "%s\n * [BUG] NULL pointer passed for aMD5Sum" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
FILE* fp = _wfopen( aFileName.wc_str(), L"rb" );
|
||||
#else
|
||||
@@ -304,15 +373,31 @@ bool S3D_CACHE::getHash( const wxString& aFileName, HASH_128& aHash )
|
||||
if( nullptr == fp )
|
||||
return false;
|
||||
|
||||
MMH3_HASH dblock( 0xA1B2C3D4 );
|
||||
std::vector<char> block( 4096 );
|
||||
boost::uuids::detail::sha1 dblock;
|
||||
unsigned char block[4096];
|
||||
size_t bsize = 0;
|
||||
|
||||
while( ( bsize = fread( block.data(), 1, 4096, fp ) ) > 0 )
|
||||
dblock.add( block );
|
||||
while( ( bsize = fread( &block, 1, 4096, fp ) ) > 0 )
|
||||
dblock.process_bytes( block, bsize );
|
||||
|
||||
fclose( fp );
|
||||
aHash = dblock.digest();
|
||||
unsigned int digest[5];
|
||||
dblock.get_digest( digest );
|
||||
|
||||
// ensure MSB order
|
||||
for( int i = 0; i < 5; ++i )
|
||||
{
|
||||
int idx = i << 2;
|
||||
unsigned int tmp = digest[i];
|
||||
aSHA1Sum[idx+3] = tmp & 0xff;
|
||||
tmp >>= 8;
|
||||
aSHA1Sum[idx+2] = tmp & 0xff;
|
||||
tmp >>= 8;
|
||||
aSHA1Sum[idx+1] = tmp & 0xff;
|
||||
tmp >>= 8;
|
||||
aSHA1Sum[idx] = tmp & 0xff;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -547,11 +632,10 @@ void S3D_CACHE::ClosePlugins()
|
||||
}
|
||||
|
||||
|
||||
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName, const wxString& aBasePath,
|
||||
const EMBEDDED_FILES* aEmbeddedFiles )
|
||||
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName, const wxString& aBasePath )
|
||||
{
|
||||
S3D_CACHE_ENTRY* cp = nullptr;
|
||||
SCENEGRAPH* sp = load( aModelFileName, aBasePath, &cp, aEmbeddedFiles );
|
||||
SCENEGRAPH* sp = load( aModelFileName, aBasePath,&cp );
|
||||
|
||||
if( !sp )
|
||||
return nullptr;
|
||||
@@ -614,3 +698,62 @@ void S3D_CACHE::CleanCacheDir( int aNumDaysOld )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PROJECT::Cleanup3DCache()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( mutex3D_cacheManager );
|
||||
|
||||
// Get the existing cache from the project
|
||||
S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( GetElem( ELEM_3DCACHE ) );
|
||||
|
||||
if( cache )
|
||||
{
|
||||
// We'll delete ".3dc" cache files older than this many days
|
||||
int clearCacheInterval = 0;
|
||||
|
||||
if( Pgm().GetCommonSettings() )
|
||||
clearCacheInterval = Pgm().GetCommonSettings()->m_System.clear_3d_cache_interval;
|
||||
|
||||
// An interval of zero means the user doesn't want to ever clear the cache
|
||||
|
||||
if( clearCacheInterval > 0 )
|
||||
cache->CleanCacheDir( clearCacheInterval );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( mutex3D_cacheManager );
|
||||
|
||||
// Get the existing cache from the project
|
||||
S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( GetElem( ELEM_3DCACHE ) );
|
||||
|
||||
if( !cache )
|
||||
{
|
||||
// Create a cache if there is not one already
|
||||
cache = new S3D_CACHE();
|
||||
|
||||
wxFileName cfgpath;
|
||||
cfgpath.AssignDir( SETTINGS_MANAGER::GetUserSettingsPath() );
|
||||
cfgpath.AppendDir( wxT( "3d" ) );
|
||||
|
||||
cache->SetProgramBase( &Pgm() );
|
||||
cache->Set3DConfigDir( cfgpath.GetFullPath() );
|
||||
|
||||
SetElem( ELEM_3DCACHE, cache );
|
||||
aUpdateProjDir = true;
|
||||
}
|
||||
|
||||
if( aUpdateProjDir )
|
||||
cache->SetProject( this );
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
||||
FILENAME_RESOLVER* PROJECT::Get3DFilenameResolver()
|
||||
{
|
||||
return Get3DCacheManager()->GetResolver();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -32,14 +32,12 @@
|
||||
#include "3d_info.h"
|
||||
#include <core/typeinfo.h>
|
||||
#include "string_utils.h"
|
||||
#include <hash_128.h>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "plugins/3dapi/c3dmodel.h"
|
||||
#include <project.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
class EMBEDDED_FILES;
|
||||
class PGM_BASE;
|
||||
class S3D_CACHE_ENTRY;
|
||||
class SCENEGRAPH;
|
||||
@@ -57,13 +55,13 @@ public:
|
||||
S3D_CACHE();
|
||||
virtual ~S3D_CACHE();
|
||||
|
||||
PROJECT::ELEM ProjectElementType() noexcept override
|
||||
KICAD_T Type() noexcept override
|
||||
{
|
||||
return PROJECT::ELEM::S3DCACHE;
|
||||
return S3D_CACHE_T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the configuration directory to be used by the model manager for storing 3D
|
||||
* Sets the configuration directory to be used by the model manager for storing 3D
|
||||
* model manager configuration data and the model cache.
|
||||
*
|
||||
* The config directory may only be set once in the lifetime of the object.
|
||||
@@ -95,11 +93,9 @@ public:
|
||||
*
|
||||
* @param aModelFile is the partial or full path to the model to be loaded.
|
||||
* @param aBasePath is the path to search for any relative files
|
||||
* @param aEmbeddedFiles is a pointer to the embedded files list.
|
||||
* @return true if the model was successfully loaded, otherwise false.
|
||||
*/
|
||||
SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath,
|
||||
const EMBEDDED_FILES* aEmbeddedFiles );
|
||||
SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath );
|
||||
|
||||
FILENAME_RESOLVER* GetResolver() noexcept;
|
||||
|
||||
@@ -127,12 +123,9 @@ public:
|
||||
* structure for display by a renderer.
|
||||
*
|
||||
* @param aModelFileName is the full path to the model to be loaded.
|
||||
* @param aBasePath is the path to search for any relative files.
|
||||
* @param aEmbeddedFiles is a pointer to the embedded files list.
|
||||
* @return is a pointer to the render data or NULL if not available.
|
||||
*/
|
||||
S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath,
|
||||
const EMBEDDED_FILES* aEmbeddedFiles );
|
||||
S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath );
|
||||
|
||||
/**
|
||||
* Delete up old cache files in cache directory.
|
||||
@@ -160,10 +153,10 @@ private:
|
||||
* Calculate the SHA1 hash of the given file.
|
||||
*
|
||||
* @param aFileName file name (full path).
|
||||
* @param aHash a 128 bit hash to hold the hash.
|
||||
* @param aSHA1Sum a 20 byte character array to hold the SHA1 hash.
|
||||
* @return true on success, otherwise false.
|
||||
*/
|
||||
bool getHash( const wxString& aFileName, HASH_128& aHash );
|
||||
bool getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum );
|
||||
|
||||
// load scene data from a cache file
|
||||
bool loadCacheData( S3D_CACHE_ENTRY* aCacheItem );
|
||||
@@ -172,14 +165,12 @@ private:
|
||||
bool saveCacheData( S3D_CACHE_ENTRY* aCacheItem );
|
||||
|
||||
// the real load function (can supply a cache entry pointer to member functions)
|
||||
SCENEGRAPH* load( const wxString& aModelFile, const wxString& aBasePath,
|
||||
S3D_CACHE_ENTRY** aCachePtr = nullptr,
|
||||
const EMBEDDED_FILES* aEmbeddedFiles = nullptr );
|
||||
SCENEGRAPH* load( const wxString& aModelFile, const wxString& aBasePath, S3D_CACHE_ENTRY** aCachePtr = nullptr );
|
||||
|
||||
/// Cache entries.
|
||||
/// cache entries
|
||||
std::list< S3D_CACHE_ENTRY* > m_CacheList;
|
||||
|
||||
/// Mapping of file names to cache names and data.
|
||||
/// mapping of file names to cache names and data
|
||||
std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString > m_CacheMap;
|
||||
|
||||
FILENAME_RESOLVER* m_FNResolver;
|
||||
@@ -188,7 +179,7 @@ private:
|
||||
|
||||
PROJECT* m_project;
|
||||
wxString m_CacheDir;
|
||||
wxString m_ConfigDir; ///< base configuration path for 3D items.
|
||||
wxString m_ConfigDir; /// base configuration path for 3D items
|
||||
};
|
||||
|
||||
#endif // CACHE_3D_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2015 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -155,47 +155,13 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
|
||||
fn.AssignDir( PATHS::GetStockPlugins3DPath() );
|
||||
checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );
|
||||
#else
|
||||
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
|
||||
{
|
||||
// Exe will be at <build_dir>/pcbnew/pcbnew.app/Contents/MacOS/pcbnew for standalone
|
||||
// Plugin will be at <build_dir>/kicad/KiCad.app/Contents/PlugIns/3d
|
||||
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
|
||||
// Search path on OS X is
|
||||
// (1) Machine /Library/Application Support/kicad/PlugIns/3d
|
||||
checkPluginPath( PATHS::GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
|
||||
|
||||
if( fn.GetName() == wxT( "kicad" ) )
|
||||
{
|
||||
fn.AppendDir( wxT( ".." ) ); // Contents
|
||||
}
|
||||
else
|
||||
{
|
||||
fn.AppendDir( wxT( ".." ) ); // Contents
|
||||
fn.AppendDir( wxT( ".." ) ); // pcbnew.app
|
||||
fn.AppendDir( wxT( ".." ) ); // pcbnew
|
||||
fn.AppendDir( wxT( ".." ) ); // Build root
|
||||
fn.AppendDir( wxT( "kicad" ) );
|
||||
fn.AppendDir( wxT( "KiCad.app" ) );
|
||||
fn.AppendDir( wxT( "Contents" ) );
|
||||
}
|
||||
|
||||
fn.AppendDir( wxT( "PlugIns" ) );
|
||||
fn.AppendDir( wxT( "3d" ) );
|
||||
fn.MakeAbsolute();
|
||||
|
||||
std::string testpath = std::string( fn.GetPathWithSep().ToUTF8() );
|
||||
checkPluginPath( testpath, searchpaths );
|
||||
|
||||
// Also check when running KiCad manager from build dir
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search path on OS X is
|
||||
// (1) Machine /Library/Application Support/kicad/PlugIns/3d
|
||||
checkPluginPath( PATHS::GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
|
||||
|
||||
// (2) Bundle kicad.app/Contents/PlugIns/3d
|
||||
fn.AssignDir( PATHS::GetStockPlugins3DPath() );
|
||||
checkPluginPath( fn.GetPathWithSep(), searchpaths );
|
||||
}
|
||||
// (2) Bundle kicad.app/Contents/PlugIns/3d
|
||||
fn.AssignDir( PATHS::GetStockPlugins3DPath() );
|
||||
checkPluginPath( fn.GetPathWithSep(), searchpaths );
|
||||
#endif
|
||||
|
||||
std::list< wxString >::iterator sPL = searchpaths.begin();
|
||||
@@ -236,7 +202,7 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
|
||||
char const* cp = pp->GetFileFilter( i );
|
||||
|
||||
if( cp )
|
||||
addFilterString( cp );
|
||||
addFilterString( wxString::FromUTF8Unchecked( cp ) );
|
||||
}
|
||||
|
||||
addExtensionMap( pp );
|
||||
@@ -328,16 +294,6 @@ void S3D_PLUGIN_MANAGER::checkPluginName( const wxString& aPath,
|
||||
++bl;
|
||||
}
|
||||
|
||||
// prevent loading non-plugin dlls
|
||||
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
|
||||
{
|
||||
if( !path.GetName().StartsWith( "s3d_plugin" )
|
||||
&& !path.GetName().StartsWith( "libs3d_plugin" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aPluginList.push_back( wxpath );
|
||||
|
||||
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * [INFO] found 3D plugin '%s'\n" ), wxpath.GetData() );
|
||||
@@ -416,7 +372,7 @@ void S3D_PLUGIN_MANAGER::addExtensionMap( KICAD_PLUGIN_LDR_3D* aPlugin )
|
||||
wxString ws;
|
||||
|
||||
if( cp )
|
||||
ws = wxString( cp );
|
||||
ws = wxString::FromUTF8Unchecked( cp );
|
||||
|
||||
if( !ws.empty() )
|
||||
{
|
||||
@@ -444,8 +400,7 @@ SCENEGRAPH* S3D_PLUGIN_MANAGER::Load3DModel( const wxString& aFileName, std::str
|
||||
ext_to_find.MakeLower();
|
||||
#endif
|
||||
|
||||
// .gz files are compressed versions that may have additional information in the previous
|
||||
// extension.
|
||||
// .gz files are compressed versions that may have additional information in the previous extension
|
||||
if( ext_to_find == wxT( "gz" ) )
|
||||
{
|
||||
wxFileName second( raw.GetName() );
|
||||
@@ -519,7 +474,8 @@ bool S3D_PLUGIN_MANAGER::CheckTag( const char* aTag )
|
||||
ptag.clear();
|
||||
(*pS)->GetPluginInfo( ptag );
|
||||
|
||||
// if the plugin name matches then the version must also match
|
||||
// if the plugin name matches then the version
|
||||
// must also match
|
||||
if( !ptag.compare( 0, pname.size(), pname ) )
|
||||
{
|
||||
if( ptag.compare( tname ) )
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -91,7 +91,7 @@ endif()
|
||||
unset( S3DSG_VERSION_FILE CACHE )
|
||||
|
||||
# Define a flag to expose the appropriate EXPORT macro at build time
|
||||
target_compile_definitions( kicad_3dsg PRIVATE COMPILE_SGLIB )
|
||||
target_compile_definitions( kicad_3dsg PRIVATE -DCOMPILE_SGLIB )
|
||||
|
||||
target_link_libraries( kicad_3dsg ${wxWidgets_LIBRARIES} )
|
||||
|
||||
@@ -108,4 +108,4 @@ install( TARGETS
|
||||
if( KICAD_WIN32_INSTALL_PDBS )
|
||||
# Get the PDBs to copy over for MSVC
|
||||
install(FILES $<TARGET_PDB_FILE:kicad_3dsg> DESTINATION ${KICAD_BIN})
|
||||
endif()
|
||||
endif()
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -476,7 +476,7 @@ SGVECTOR S3D::CalcTriNorm( const SGPOINT& p1, const SGPOINT& p2, const SGPOINT&
|
||||
|
||||
// normal
|
||||
tri = glm::cross( pts[1] - pts[0], pts[2] - pts[0] );
|
||||
(void)glm::normalize( tri );
|
||||
glm::normalize( tri );
|
||||
|
||||
return SGVECTOR( tri.x, tri.y, tri.z );
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2023 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2023 CERN
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2022 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -23,7 +22,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <gal/3d/camera.h>
|
||||
#include "../3d_rendering/camera.h"
|
||||
#include "board_adapter.h"
|
||||
#include <board_design_settings.h>
|
||||
#include <board_stackup_manager/board_stackup.h>
|
||||
@@ -31,11 +30,9 @@
|
||||
#include <3d_rendering/raytracing/shapes2D/polygon_2d.h>
|
||||
#include <board.h>
|
||||
#include <dialogs/dialog_color_picker.h>
|
||||
#include <layer_range.h>
|
||||
#include <3d_math.h>
|
||||
#include "3d_fastmath.h"
|
||||
#include <geometry/geometry_utils.h>
|
||||
#include <lset.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <wx/log.h>
|
||||
@@ -52,7 +49,7 @@
|
||||
#define SOLDERPASTE_LAYER_THICKNESS pcbIUScale.mmToIU( 0.04 )
|
||||
|
||||
|
||||
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_SilkColors;
|
||||
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_SilkscreenColors;
|
||||
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_MaskColors;
|
||||
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_PasteColors;
|
||||
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_FinishColors;
|
||||
@@ -65,8 +62,6 @@ KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderMask;
|
||||
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderPaste;
|
||||
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSurfaceFinish;
|
||||
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBoardBody;
|
||||
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultComments;
|
||||
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultECOs;
|
||||
|
||||
// To be used in Raytracing render to create bevels on layer items
|
||||
float g_BevelThickness3DU = 0.0f;
|
||||
@@ -91,21 +86,24 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
|
||||
m_IsPreviewer( false ),
|
||||
m_board( nullptr ),
|
||||
m_3dModelManager( nullptr ),
|
||||
m_renderSettings( nullptr ),
|
||||
m_colors( nullptr ),
|
||||
m_layerZcoordTop(),
|
||||
m_layerZcoordBottom()
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
|
||||
|
||||
ReloadColorSettings();
|
||||
|
||||
m_boardPos = VECTOR2I();
|
||||
m_boardSize = VECTOR2I();
|
||||
m_boardCenter = SFVEC3F( 0.0f );
|
||||
|
||||
m_boardBoundingBox.Reset();
|
||||
|
||||
m_TH_IDs.Clear();
|
||||
m_TH_ODs.Clear();
|
||||
m_viaAnnuli.Clear();
|
||||
m_throughHoleIds.Clear();
|
||||
m_throughHoleOds.Clear();
|
||||
m_throughHoleAnnularRings.Clear();
|
||||
|
||||
m_copperLayersCount = 2;
|
||||
|
||||
@@ -132,36 +130,26 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
|
||||
m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
|
||||
m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
|
||||
m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
|
||||
m_UserDrawingsColor = SFVEC4F( 0.85, 0.85, 0.85, 1.0 );
|
||||
m_UserCommentsColor = SFVEC4F( 0.85, 0.85, 0.85, 1.0 );
|
||||
m_ECO1Color = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
|
||||
m_ECO2Color = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
|
||||
|
||||
m_platedPadsFront = nullptr;
|
||||
m_platedPadsBack = nullptr;
|
||||
m_offboardPadsFront = nullptr;
|
||||
m_offboardPadsBack = nullptr;
|
||||
|
||||
m_frontPlatedPadAndGraphicPolys = nullptr;
|
||||
m_backPlatedPadAndGraphicPolys = nullptr;
|
||||
m_frontPlatedCopperPolys = nullptr;
|
||||
m_backPlatedCopperPolys = nullptr;
|
||||
|
||||
ReloadColorSettings();
|
||||
m_frontPlatedPadPolys = nullptr;
|
||||
m_backPlatedPadPolys = nullptr;
|
||||
|
||||
if( !g_ColorsLoaded )
|
||||
{
|
||||
#define ADD_COLOR( list, r, g, b, a, name ) \
|
||||
list.emplace_back( r/255.0, g/255.0, b/255.0, a, name )
|
||||
|
||||
ADD_COLOR( g_SilkColors, 245, 245, 245, 1.0, NotSpecifiedPrm() ); // White
|
||||
ADD_COLOR( g_SilkColors, 20, 51, 36, 1.0, wxT( "Green" ) );
|
||||
ADD_COLOR( g_SilkColors, 181, 19, 21, 1.0, wxT( "Red" ) );
|
||||
ADD_COLOR( g_SilkColors, 2, 59, 162, 1.0, wxT( "Blue" ) );
|
||||
ADD_COLOR( g_SilkColors, 11, 11, 11, 1.0, wxT( "Black" ) );
|
||||
ADD_COLOR( g_SilkColors, 245, 245, 245, 1.0, wxT( "White" ) );
|
||||
ADD_COLOR( g_SilkColors, 32, 2, 53, 1.0, wxT( "Purple" ) );
|
||||
ADD_COLOR( g_SilkColors, 194, 195, 0, 1.0, wxT( "Yellow" ) );
|
||||
ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, NotSpecifiedPrm() ); // White
|
||||
ADD_COLOR( g_SilkscreenColors, 20, 51, 36, 1.0, wxT( "Green" ) );
|
||||
ADD_COLOR( g_SilkscreenColors, 181, 19, 21, 1.0, wxT( "Red" ) );
|
||||
ADD_COLOR( g_SilkscreenColors, 2, 59, 162, 1.0, wxT( "Blue" ) );
|
||||
ADD_COLOR( g_SilkscreenColors, 11, 11, 11, 1.0, wxT( "Black" ) );
|
||||
ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, wxT( "White" ) );
|
||||
ADD_COLOR( g_SilkscreenColors, 32, 2, 53, 1.0, wxT( "Purple" ) );
|
||||
ADD_COLOR( g_SilkscreenColors, 194, 195, 0, 1.0, wxT( "Yellow" ) );
|
||||
|
||||
ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, NotSpecifiedPrm() ); // Green
|
||||
ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, wxT( "Green" ) );
|
||||
@@ -208,9 +196,6 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
|
||||
g_DefaultSurfaceFinish = COLOR4D( 0.75, 0.61, 0.23, 1.0 );
|
||||
g_DefaultBoardBody = COLOR4D( 0.43, 0.45, 0.30, 0.90 );
|
||||
|
||||
g_DefaultComments = COLOR4D( 0.85, 0.85, 0.85, 1.0 );
|
||||
g_DefaultECOs = COLOR4D( 0.70, 0.10, 0.10, 1.0 );
|
||||
|
||||
g_ColorsLoaded = true;
|
||||
}
|
||||
#undef ADD_COLOR
|
||||
@@ -225,44 +210,62 @@ BOARD_ADAPTER::~BOARD_ADAPTER()
|
||||
|
||||
void BOARD_ADAPTER::ReloadColorSettings() noexcept
|
||||
{
|
||||
wxCHECK( PgmOrNull(), /* void */ );
|
||||
wxASSERT( PgmOrNull() );
|
||||
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
|
||||
|
||||
if( cfg )
|
||||
{
|
||||
m_colors = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
|
||||
GetBoardEditorCopperLayerColors( cfg );
|
||||
}
|
||||
PCBNEW_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
||||
m_colors = Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_ADAPTER::Is3dLayerEnabled( PCB_LAYER_ID aLayer,
|
||||
const std::bitset<LAYER_3D_END>& aVisibilityFlags ) const
|
||||
bool BOARD_ADAPTER::Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const
|
||||
{
|
||||
wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
|
||||
|
||||
if( m_board && !m_board->IsLayerEnabled( aLayer ) )
|
||||
return false;
|
||||
|
||||
// see if layer needs to be shown
|
||||
// check the flags
|
||||
switch( aLayer )
|
||||
{
|
||||
case B_Cu: return aVisibilityFlags.test( LAYER_3D_COPPER_BOTTOM );
|
||||
case F_Cu: return aVisibilityFlags.test( LAYER_3D_COPPER_TOP );
|
||||
case B_Adhes: return aVisibilityFlags.test( LAYER_3D_ADHESIVE );
|
||||
case F_Adhes: return aVisibilityFlags.test( LAYER_3D_ADHESIVE );
|
||||
case B_Paste: return aVisibilityFlags.test( LAYER_3D_SOLDERPASTE );
|
||||
case F_Paste: return aVisibilityFlags.test( LAYER_3D_SOLDERPASTE );
|
||||
case B_SilkS: return aVisibilityFlags.test( LAYER_3D_SILKSCREEN_BOTTOM );
|
||||
case F_SilkS: return aVisibilityFlags.test( LAYER_3D_SILKSCREEN_TOP );
|
||||
case B_Mask: return aVisibilityFlags.test( LAYER_3D_SOLDERMASK_BOTTOM );
|
||||
case F_Mask: return aVisibilityFlags.test( LAYER_3D_SOLDERMASK_TOP );
|
||||
case Dwgs_User: return aVisibilityFlags.test( LAYER_3D_USER_DRAWINGS );
|
||||
case Cmts_User: return aVisibilityFlags.test( LAYER_3D_USER_COMMENTS );
|
||||
case Eco1_User: return aVisibilityFlags.test( LAYER_3D_USER_ECO1 );
|
||||
case Eco2_User: return aVisibilityFlags.test( LAYER_3D_USER_ECO2 );
|
||||
default: return m_board && m_board->IsLayerVisible( aLayer );
|
||||
case B_Adhes:
|
||||
case F_Adhes:
|
||||
return m_Cfg->m_Render.show_adhesive;
|
||||
|
||||
case B_Paste:
|
||||
case F_Paste:
|
||||
return m_Cfg->m_Render.show_solderpaste;
|
||||
|
||||
case B_SilkS:
|
||||
case F_SilkS:
|
||||
return m_Cfg->m_Render.show_silkscreen;
|
||||
|
||||
case B_Mask:
|
||||
case F_Mask:
|
||||
return m_Cfg->m_Render.show_soldermask;
|
||||
|
||||
case Dwgs_User:
|
||||
case Cmts_User:
|
||||
return !m_Cfg->m_Render.realistic && m_Cfg->m_Render.show_comments;
|
||||
|
||||
case Eco1_User:
|
||||
case Eco2_User:
|
||||
return !m_Cfg->m_Render.realistic && m_Cfg->m_Render.show_eco;
|
||||
|
||||
case Edge_Cuts:
|
||||
return !m_Cfg->m_Render.realistic && !m_Cfg->m_Render.show_board_body;
|
||||
|
||||
case Margin:
|
||||
return !m_Cfg->m_Render.realistic;
|
||||
|
||||
case B_Cu:
|
||||
case F_Cu:
|
||||
return !m_board || m_board->IsLayerVisible( aLayer ) || m_Cfg->m_Render.realistic
|
||||
|| m_board->IsFootprintHolder();
|
||||
|
||||
default:
|
||||
// the layer is an internal copper layer, used the visibility
|
||||
return m_board && m_board->IsLayerVisible( aLayer );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,12 +281,6 @@ bool BOARD_ADAPTER::IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if( aFPAttributes & FP_DNP )
|
||||
{
|
||||
if( !m_Cfg->m_Render.show_footprints_dnp )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( aFPAttributes & FP_SMD )
|
||||
return m_Cfg->m_Render.show_footprints_insert;
|
||||
|
||||
@@ -339,7 +336,11 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
BOX2I bbbox;
|
||||
|
||||
if( m_board )
|
||||
bbbox = m_board->ComputeBoundingBox( !m_board->IsFootprintHolder() && haveOutline );
|
||||
{
|
||||
bbbox = m_board->ComputeBoundingBox( !m_board->IsFootprintHolder()
|
||||
&& m_Cfg->m_Render.realistic
|
||||
&& haveOutline );
|
||||
}
|
||||
|
||||
// Gives a non null size to avoid issues in zoom / scale calculations
|
||||
if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
|
||||
@@ -362,20 +363,13 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
// Calculate the conversion to apply to all positions.
|
||||
m_biuTo3Dunits = RANGE_SCALE_3D / std::max( m_boardSize.x, m_boardSize.y );
|
||||
|
||||
// Hack to keep "home" zoom from being too small.
|
||||
if( !m_board || !m_board->IsFootprintHolder() )
|
||||
m_biuTo3Dunits *= 1.6f;
|
||||
|
||||
ReloadColorSettings();
|
||||
|
||||
m_boardBodyThickness3DU = DEFAULT_BOARD_THICKNESS * m_biuTo3Dunits;
|
||||
m_frontCopperThickness3DU = DEFAULT_COPPER_THICKNESS * m_biuTo3Dunits;
|
||||
m_backCopperThickness3DU = DEFAULT_COPPER_THICKNESS * m_biuTo3Dunits;
|
||||
m_nonCopperLayerThickness3DU = DEFAULT_TECH_LAYER_THICKNESS * m_biuTo3Dunits;
|
||||
m_solderPasteLayerThickness3DU = SOLDERPASTE_LAYER_THICKNESS * m_biuTo3Dunits;
|
||||
|
||||
g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 )
|
||||
* m_biuTo3Dunits;
|
||||
g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 ) * m_biuTo3Dunits;
|
||||
|
||||
if( m_board )
|
||||
{
|
||||
@@ -395,19 +389,13 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
break;
|
||||
|
||||
case BS_ITEM_TYPE_COPPER:
|
||||
{
|
||||
// The copper thickness must be > 0 to avoid draw issues (divide by 0 for
|
||||
// instance). We use a minimal arbitrary value = 1 micrometer here:
|
||||
int copper_thickness = std::max( item->GetThickness(),
|
||||
pcbIUScale.mmToIU( 0.001 ) );
|
||||
|
||||
if( item->GetBrdLayerId() == F_Cu )
|
||||
m_frontCopperThickness3DU = copper_thickness * m_biuTo3Dunits;
|
||||
m_frontCopperThickness3DU = item->GetThickness() * m_biuTo3Dunits;
|
||||
else if( item->GetBrdLayerId() == B_Cu )
|
||||
m_backCopperThickness3DU = copper_thickness * m_biuTo3Dunits;
|
||||
m_backCopperThickness3DU = item->GetThickness() * m_biuTo3Dunits;
|
||||
else if( item->IsEnabled() )
|
||||
thickness += copper_thickness;
|
||||
}
|
||||
thickness += item->GetThickness();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -421,10 +409,8 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
|
||||
// Init Z position of each layer
|
||||
// calculate z position for each copper layer
|
||||
// Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer)
|
||||
// (layer id = B_Cu)
|
||||
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer)
|
||||
// (layer id = F_Cu)
|
||||
// Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
|
||||
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
|
||||
|
||||
// ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
|
||||
// | | Top = Bottom + m_copperThickness
|
||||
@@ -432,59 +418,42 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
// == == == == <- Bottom = -m_epoxyThickness / 2.0,
|
||||
// Top = Bottom - m_copperThickness
|
||||
|
||||
// Generate the Z position of copper layers
|
||||
// A copper layer Z position has 2 values: its top Z position and its bottom Z position
|
||||
for( auto layer_id : LAYER_RANGE( F_Cu, B_Cu, m_copperLayersCount ) )
|
||||
unsigned int layer;
|
||||
|
||||
for( layer = 0; layer < m_copperLayersCount; ++layer )
|
||||
{
|
||||
// This approximates internal layer positions (because we're treating all the dielectric
|
||||
// layers as having the same thickness). But we don't render them anyway so it doesn't
|
||||
// really matter.
|
||||
int layer_pos; // the position of the copper layer from board top to bottom
|
||||
m_layerZcoordBottom[layer] = m_boardBodyThickness3DU / 2.0f -
|
||||
(m_boardBodyThickness3DU * layer / (m_copperLayersCount - 1) );
|
||||
|
||||
switch( layer_id )
|
||||
{
|
||||
case F_Cu: layer_pos = 0; break;
|
||||
case B_Cu: layer_pos = m_copperLayersCount - 1; break;
|
||||
default: layer_pos = ( layer_id - B_Cu )/2; break;
|
||||
};
|
||||
|
||||
m_layerZcoordBottom[layer_id] = m_boardBodyThickness3DU / 2.0
|
||||
- ( m_boardBodyThickness3DU * layer_pos
|
||||
/ ( m_copperLayersCount - 1 ) );
|
||||
|
||||
if( layer_pos < (m_copperLayersCount / 2) )
|
||||
m_layerZcoordTop[layer_id] = m_layerZcoordBottom[layer_id] + m_frontCopperThickness3DU;
|
||||
if( layer < (m_copperLayersCount / 2) )
|
||||
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] + m_frontCopperThickness3DU;
|
||||
else
|
||||
m_layerZcoordTop[layer_id] = m_layerZcoordBottom[layer_id] - m_backCopperThickness3DU;
|
||||
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] - m_backCopperThickness3DU;
|
||||
}
|
||||
|
||||
#define layerThicknessMargin 1.1
|
||||
const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
|
||||
|
||||
// Fill remaining unused copper layers and back layer zpos with -m_boardBodyThickness / 2.0
|
||||
for( ; layer < MAX_CU_LAYERS; layer++ )
|
||||
{
|
||||
m_layerZcoordBottom[layer] = -( m_boardBodyThickness3DU / 2.0f );
|
||||
m_layerZcoordTop[layer] = -( m_boardBodyThickness3DU / 2.0f ) - m_backCopperThickness3DU;
|
||||
}
|
||||
|
||||
// This is the top of the copper layer thickness.
|
||||
const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
|
||||
const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
|
||||
|
||||
// Fill not copper layers zpos with a dummy position
|
||||
// (m_layerZcoordTop[B_Cu]with a small margin)
|
||||
// Some important layer position will be set later
|
||||
for( int layer_id = 0; layer_id < PCB_LAYER_ID_COUNT; layer_id++ )
|
||||
{
|
||||
if( IsCopperLayer( (PCB_LAYER_ID)layer_id ) )
|
||||
continue;
|
||||
|
||||
m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] = zpos_copperTop_back - 2.0f * zpos_offset;
|
||||
m_layerZcoordTop[(PCB_LAYER_ID) layer_id] =
|
||||
m_layerZcoordBottom[(PCB_LAYER_ID) layer_id] - m_backCopperThickness3DU;
|
||||
}
|
||||
|
||||
// calculate z position for each technical layer
|
||||
// calculate z position for each non copper layer
|
||||
// Solder mask and Solder paste have the same Z position
|
||||
for( PCB_LAYER_ID layer_id :
|
||||
{ B_Adhes, B_Mask, B_Paste, F_Adhes, F_Mask, F_Paste, B_SilkS, F_SilkS } )
|
||||
for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
|
||||
{
|
||||
float zposTop = 0.0;
|
||||
float zposBottom = 0.0;
|
||||
float zposTop;
|
||||
float zposBottom;
|
||||
|
||||
switch( layer_id )
|
||||
{
|
||||
@@ -528,11 +497,14 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
zposTop = zposBottom + m_nonCopperLayerThickness3DU;
|
||||
break;
|
||||
|
||||
// !TODO: review
|
||||
default:
|
||||
zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
|
||||
zposBottom = zposTop - m_nonCopperLayerThickness3DU;
|
||||
break;
|
||||
}
|
||||
|
||||
m_layerZcoordTop[layer_id] = zposTop;
|
||||
m_layerZcoordTop[layer_id] = zposTop;
|
||||
m_layerZcoordBottom[layer_id] = zposBottom;
|
||||
}
|
||||
|
||||
@@ -551,7 +523,7 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
|
||||
|
||||
#ifdef PRINT_STATISTICS_3D_VIEWER
|
||||
int64_t stats_startCreateBoardPolyTime = GetRunningMicroSecs();
|
||||
unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
|
||||
#endif
|
||||
|
||||
if( aStatusReporter )
|
||||
@@ -559,96 +531,25 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
||||
|
||||
createLayers( aStatusReporter );
|
||||
|
||||
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
auto to_SFVEC4F =
|
||||
[]( const COLOR4D& src )
|
||||
{
|
||||
return SFVEC4F( src.r, src.g, src.b, src.a );
|
||||
};
|
||||
|
||||
std::map<int, COLOR4D> colors = GetLayerColors();
|
||||
m_BgColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_TOP ) );
|
||||
m_BgColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ) );
|
||||
|
||||
m_BgColorTop = to_SFVEC4F( colors[ LAYER_3D_BACKGROUND_TOP ] );
|
||||
m_BgColorBot = to_SFVEC4F( colors[ LAYER_3D_BACKGROUND_BOTTOM ] );
|
||||
m_SolderPasteColor = to_SFVEC4F( colors[ LAYER_3D_SOLDERPASTE ] );
|
||||
m_SilkScreenColorBot = to_SFVEC4F( colors[ LAYER_3D_SILKSCREEN_BOTTOM ] );
|
||||
m_SilkScreenColorTop = to_SFVEC4F( colors[ LAYER_3D_SILKSCREEN_TOP ] );
|
||||
m_SolderMaskColorBot = to_SFVEC4F( colors[ LAYER_3D_SOLDERMASK_BOTTOM ] );
|
||||
m_SolderMaskColorTop = to_SFVEC4F( colors[ LAYER_3D_SOLDERMASK_TOP ] );
|
||||
m_CopperColor = to_SFVEC4F( colors[ LAYER_3D_COPPER_TOP ] );
|
||||
m_BoardBodyColor = to_SFVEC4F( colors[ LAYER_3D_BOARD ] );
|
||||
m_UserDrawingsColor = to_SFVEC4F( colors[ LAYER_3D_USER_DRAWINGS ] );
|
||||
m_UserCommentsColor = to_SFVEC4F( colors[ LAYER_3D_USER_COMMENTS ] );
|
||||
m_ECO1Color = to_SFVEC4F( colors[ LAYER_3D_USER_ECO1 ] );
|
||||
m_ECO2Color = to_SFVEC4F( colors[ LAYER_3D_USER_ECO2 ] );
|
||||
}
|
||||
m_SolderPasteColor = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERPASTE ) );
|
||||
|
||||
|
||||
std::map<int, COLOR4D> BOARD_ADAPTER::GetDefaultColors() const
|
||||
{
|
||||
std::map<int, COLOR4D> colors;
|
||||
|
||||
colors[ LAYER_3D_BACKGROUND_TOP ] = BOARD_ADAPTER::g_DefaultBackgroundTop;
|
||||
colors[ LAYER_3D_BACKGROUND_BOTTOM ] = BOARD_ADAPTER::g_DefaultBackgroundBot;
|
||||
colors[ LAYER_3D_BOARD ] = BOARD_ADAPTER::g_DefaultBoardBody;
|
||||
colors[ LAYER_3D_COPPER_TOP ] = BOARD_ADAPTER::g_DefaultSurfaceFinish;
|
||||
colors[ LAYER_3D_COPPER_BOTTOM ] = BOARD_ADAPTER::g_DefaultSurfaceFinish;
|
||||
colors[ LAYER_3D_SILKSCREEN_TOP ] = BOARD_ADAPTER::g_DefaultSilkscreen;
|
||||
colors[ LAYER_3D_SILKSCREEN_BOTTOM ] = BOARD_ADAPTER::g_DefaultSilkscreen;
|
||||
colors[ LAYER_3D_SOLDERMASK_TOP ] = BOARD_ADAPTER::g_DefaultSolderMask;
|
||||
colors[ LAYER_3D_SOLDERMASK_BOTTOM ] = BOARD_ADAPTER::g_DefaultSolderMask;
|
||||
colors[ LAYER_3D_SOLDERPASTE ] = BOARD_ADAPTER::g_DefaultSolderPaste;
|
||||
colors[ LAYER_3D_USER_DRAWINGS ] = BOARD_ADAPTER::g_DefaultComments;
|
||||
colors[ LAYER_3D_USER_COMMENTS ] = BOARD_ADAPTER::g_DefaultComments;
|
||||
colors[ LAYER_3D_USER_ECO1 ] = BOARD_ADAPTER::g_DefaultECOs;
|
||||
colors[ LAYER_3D_USER_ECO2 ] = BOARD_ADAPTER::g_DefaultECOs;
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::GetBoardEditorCopperLayerColors( PCBNEW_SETTINGS* aCfg )
|
||||
{
|
||||
m_BoardEditorColors.clear();
|
||||
|
||||
if( m_copperLayersCount <= 0 )
|
||||
return;
|
||||
|
||||
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings( aCfg->m_ColorTheme );
|
||||
|
||||
LSET copperLayers = LSET::AllCuMask();
|
||||
|
||||
for( auto layer : LAYER_RANGE( F_Cu, B_Cu, m_copperLayersCount ) )
|
||||
{
|
||||
m_BoardEditorColors[ layer ] = settings->GetColor( layer );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
|
||||
{
|
||||
std::map<int, COLOR4D> colors;
|
||||
|
||||
if( LAYER_PRESET_3D* preset = m_Cfg->FindPreset( m_Cfg->m_CurrentPreset ) )
|
||||
{
|
||||
colors = preset->colors;
|
||||
}
|
||||
else
|
||||
{
|
||||
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
for( const auto& [ layer, defaultColor /* unused */ ] : GetDefaultColors() )
|
||||
colors[ layer ] = settings->GetColor( layer );
|
||||
}
|
||||
|
||||
if( m_Cfg->m_UseStackupColors && m_board )
|
||||
if( m_board && colors->GetUseBoardStackupColors() )
|
||||
{
|
||||
const BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor();
|
||||
KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
|
||||
|
||||
// Can't do a const KIGFX::COLOR4D& return type here because there are temporary variables
|
||||
auto findColor =
|
||||
[]( const wxString& aColorName,
|
||||
const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D
|
||||
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
|
||||
{
|
||||
if( aColorName.StartsWith( wxT( "#" ) ) )
|
||||
{
|
||||
@@ -666,6 +567,13 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
|
||||
return KIGFX::COLOR4D();
|
||||
};
|
||||
|
||||
m_SilkScreenColorTop = to_SFVEC4F( g_DefaultSilkscreen );
|
||||
m_SilkScreenColorBot = to_SFVEC4F( g_DefaultSilkscreen );
|
||||
m_SolderMaskColorTop = to_SFVEC4F( g_DefaultSolderMask );
|
||||
m_SolderMaskColorBot = to_SFVEC4F( g_DefaultSolderMask );
|
||||
|
||||
KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
|
||||
|
||||
for( const BOARD_STACKUP_ITEM* stackupItem : stackup.GetList() )
|
||||
{
|
||||
wxString colorName = stackupItem->GetColor();
|
||||
@@ -674,17 +582,16 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
|
||||
{
|
||||
case BS_ITEM_TYPE_SILKSCREEN:
|
||||
if( stackupItem->GetBrdLayerId() == F_SilkS )
|
||||
colors[ LAYER_3D_SILKSCREEN_TOP ] = findColor( colorName, g_SilkColors );
|
||||
m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
|
||||
else
|
||||
colors[ LAYER_3D_SILKSCREEN_BOTTOM ] = findColor( colorName, g_SilkColors );
|
||||
|
||||
m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
|
||||
break;
|
||||
|
||||
case BS_ITEM_TYPE_SOLDERMASK:
|
||||
if( stackupItem->GetBrdLayerId() == F_Mask )
|
||||
colors[ LAYER_3D_SOLDERMASK_TOP ] = findColor( colorName, g_MaskColors );
|
||||
m_SolderMaskColorTop = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
|
||||
else
|
||||
colors[ LAYER_3D_SOLDERMASK_BOTTOM ] = findColor( colorName, g_MaskColors );
|
||||
m_SolderMaskColorBot = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
|
||||
|
||||
break;
|
||||
|
||||
@@ -707,227 +614,52 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
|
||||
}
|
||||
|
||||
if( bodyColor != COLOR4D( 0, 0, 0, 0 ) )
|
||||
colors[ LAYER_3D_BOARD ] = bodyColor;
|
||||
m_BoardBodyColor = to_SFVEC4F( bodyColor );
|
||||
else
|
||||
m_BoardBodyColor = to_SFVEC4F( g_DefaultBoardBody );
|
||||
|
||||
const wxString& finishName = stackup.m_FinishType;
|
||||
|
||||
if( finishName.EndsWith( wxT( "OSP" ) ) )
|
||||
{
|
||||
colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Copper" ), g_FinishColors );
|
||||
m_CopperColor = to_SFVEC4F( findColor( wxT( "Copper" ), g_FinishColors ) );
|
||||
}
|
||||
else if( finishName.EndsWith( wxT( "IG" ) )
|
||||
|| finishName.EndsWith( wxT( "gold" ) ) )
|
||||
{
|
||||
colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Gold" ), g_FinishColors );
|
||||
m_CopperColor = to_SFVEC4F( findColor( wxT( "Gold" ), g_FinishColors ) );
|
||||
}
|
||||
else if( finishName.StartsWith( wxT( "HAL" ) )
|
||||
|| finishName.StartsWith( wxT( "HASL" ) )
|
||||
|| finishName.EndsWith( wxT( "tin" ) )
|
||||
|| finishName.EndsWith( wxT( "nickel" ) ) )
|
||||
{
|
||||
colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Tin" ), g_FinishColors );
|
||||
m_CopperColor = to_SFVEC4F( findColor( wxT( "Tin" ), g_FinishColors ) );
|
||||
}
|
||||
else if( finishName.EndsWith( wxT( "silver" ) ) )
|
||||
{
|
||||
colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Silver" ), g_FinishColors );
|
||||
m_CopperColor = to_SFVEC4F( findColor( wxT( "Silver" ), g_FinishColors ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CopperColor = to_SFVEC4F( g_DefaultSurfaceFinish );
|
||||
}
|
||||
}
|
||||
|
||||
colors[ LAYER_3D_COPPER_BOTTOM ] = colors[ LAYER_3D_COPPER_TOP ];
|
||||
|
||||
for( const auto& [layer, val] : m_ColorOverrides )
|
||||
colors[layer] = val;
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::SetLayerColors( const std::map<int, COLOR4D>& aColors )
|
||||
{
|
||||
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
for( const auto& [ layer, color ] : aColors )
|
||||
settings->SetColor( layer, color );
|
||||
|
||||
Pgm().GetSettingsManager().SaveColorSettings( settings, "3d_viewer" );
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::SetVisibleLayers( const std::bitset<LAYER_3D_END>& aLayers )
|
||||
{
|
||||
m_Cfg->m_Render.show_board_body = aLayers.test( LAYER_3D_BOARD );
|
||||
m_Cfg->m_Render.show_copper_top = aLayers.test( LAYER_3D_COPPER_TOP );
|
||||
m_Cfg->m_Render.show_copper_bottom = aLayers.test( LAYER_3D_COPPER_BOTTOM );
|
||||
m_Cfg->m_Render.show_silkscreen_top = aLayers.test( LAYER_3D_SILKSCREEN_TOP );
|
||||
m_Cfg->m_Render.show_silkscreen_bottom = aLayers.test( LAYER_3D_SILKSCREEN_BOTTOM );
|
||||
m_Cfg->m_Render.show_soldermask_top = aLayers.test( LAYER_3D_SOLDERMASK_TOP );
|
||||
m_Cfg->m_Render.show_soldermask_bottom = aLayers.test( LAYER_3D_SOLDERMASK_BOTTOM );
|
||||
m_Cfg->m_Render.show_solderpaste = aLayers.test( LAYER_3D_SOLDERPASTE );
|
||||
m_Cfg->m_Render.show_adhesive = aLayers.test( LAYER_3D_ADHESIVE );
|
||||
m_Cfg->m_Render.show_comments = aLayers.test( LAYER_3D_USER_COMMENTS );
|
||||
m_Cfg->m_Render.show_drawings = aLayers.test( LAYER_3D_USER_DRAWINGS );
|
||||
m_Cfg->m_Render.show_eco1 = aLayers.test( LAYER_3D_USER_ECO1 );
|
||||
m_Cfg->m_Render.show_eco2 = aLayers.test( LAYER_3D_USER_ECO2 );
|
||||
|
||||
m_Cfg->m_Render.show_footprints_normal = aLayers.test( LAYER_3D_TH_MODELS );
|
||||
m_Cfg->m_Render.show_footprints_insert = aLayers.test( LAYER_3D_SMD_MODELS );
|
||||
m_Cfg->m_Render.show_footprints_virtual = aLayers.test( LAYER_3D_VIRTUAL_MODELS );
|
||||
m_Cfg->m_Render.show_footprints_not_in_posfile = aLayers.test( LAYER_3D_MODELS_NOT_IN_POS );
|
||||
m_Cfg->m_Render.show_footprints_dnp = aLayers.test( LAYER_3D_MODELS_MARKED_DNP );
|
||||
|
||||
m_Cfg->m_Render.show_fp_references = aLayers.test( LAYER_FP_REFERENCES );
|
||||
m_Cfg->m_Render.show_fp_values = aLayers.test( LAYER_FP_VALUES );
|
||||
m_Cfg->m_Render.show_fp_text = aLayers.test( LAYER_FP_TEXT );
|
||||
|
||||
m_Cfg->m_Render.show_model_bbox = aLayers.test( LAYER_3D_BOUNDING_BOXES );
|
||||
m_Cfg->m_Render.show_off_board_silk = aLayers.test( LAYER_3D_OFF_BOARD_SILK );
|
||||
m_Cfg->m_Render.show_axis = aLayers.test( LAYER_3D_AXES );
|
||||
}
|
||||
|
||||
|
||||
std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
|
||||
{
|
||||
std::bitset<LAYER_3D_END> ret;
|
||||
|
||||
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
|
||||
ret.set( LAYER_3D_COPPER_TOP, m_Cfg->m_Render.show_copper_top );
|
||||
ret.set( LAYER_3D_COPPER_BOTTOM, m_Cfg->m_Render.show_copper_bottom );
|
||||
ret.set( LAYER_3D_SILKSCREEN_TOP, m_Cfg->m_Render.show_silkscreen_top );
|
||||
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, m_Cfg->m_Render.show_silkscreen_bottom );
|
||||
ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
|
||||
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
|
||||
ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
|
||||
ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
|
||||
ret.set( LAYER_3D_USER_COMMENTS, m_Cfg->m_Render.show_comments );
|
||||
ret.set( LAYER_3D_USER_DRAWINGS, m_Cfg->m_Render.show_drawings );
|
||||
ret.set( LAYER_3D_USER_ECO1, m_Cfg->m_Render.show_eco1 );
|
||||
ret.set( LAYER_3D_USER_ECO2, m_Cfg->m_Render.show_eco2 );
|
||||
|
||||
ret.set( LAYER_FP_REFERENCES, m_Cfg->m_Render.show_fp_references );
|
||||
ret.set( LAYER_FP_VALUES, m_Cfg->m_Render.show_fp_values );
|
||||
ret.set( LAYER_FP_TEXT, m_Cfg->m_Render.show_fp_text );
|
||||
|
||||
ret.set( LAYER_3D_TH_MODELS, m_Cfg->m_Render.show_footprints_normal );
|
||||
ret.set( LAYER_3D_SMD_MODELS, m_Cfg->m_Render.show_footprints_insert );
|
||||
ret.set( LAYER_3D_VIRTUAL_MODELS, m_Cfg->m_Render.show_footprints_virtual );
|
||||
ret.set( LAYER_3D_MODELS_NOT_IN_POS, m_Cfg->m_Render.show_footprints_not_in_posfile );
|
||||
ret.set( LAYER_3D_MODELS_MARKED_DNP, m_Cfg->m_Render.show_footprints_dnp );
|
||||
|
||||
ret.set( LAYER_3D_BOUNDING_BOXES, m_Cfg->m_Render.show_model_bbox );
|
||||
ret.set( LAYER_3D_OFF_BOARD_SILK, m_Cfg->m_Render.show_off_board_silk );
|
||||
ret.set( LAYER_3D_AXES, m_Cfg->m_Render.show_axis );
|
||||
|
||||
if( m_Cfg->m_CurrentPreset == FOLLOW_PCB )
|
||||
{
|
||||
if( !m_board )
|
||||
return ret;
|
||||
|
||||
ret.set( LAYER_3D_BOARD, true );
|
||||
ret.set( LAYER_3D_COPPER_TOP, m_board->IsLayerVisible( F_Cu ) );
|
||||
ret.set( LAYER_3D_COPPER_BOTTOM, m_board->IsLayerVisible( B_Cu ) );
|
||||
ret.set( LAYER_3D_SILKSCREEN_TOP, m_board->IsLayerVisible( F_SilkS ) );
|
||||
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, m_board->IsLayerVisible( B_SilkS ) );
|
||||
ret.set( LAYER_3D_SOLDERMASK_TOP, m_board->IsLayerVisible( F_Mask ) );
|
||||
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_board->IsLayerVisible( B_Mask ) );
|
||||
ret.set( LAYER_3D_SOLDERPASTE, m_board->IsLayerVisible( F_Paste ) );
|
||||
ret.set( LAYER_3D_ADHESIVE, m_board->IsLayerVisible( F_Adhes ) );
|
||||
ret.set( LAYER_3D_USER_COMMENTS, m_board->IsLayerVisible( Cmts_User ) );
|
||||
ret.set( LAYER_3D_USER_DRAWINGS, m_board->IsLayerVisible( Dwgs_User ) );
|
||||
ret.set( LAYER_3D_USER_ECO1, m_board->IsLayerVisible( Eco1_User ) );
|
||||
ret.set( LAYER_3D_USER_ECO2, m_board->IsLayerVisible( Eco2_User ) );
|
||||
|
||||
for( GAL_LAYER_ID layer : { LAYER_FP_REFERENCES, LAYER_FP_VALUES, LAYER_FP_TEXT } )
|
||||
ret.set( layer, m_board->IsElementVisible( layer ) );
|
||||
}
|
||||
else if( m_Cfg->m_CurrentPreset == FOLLOW_PLOT_SETTINGS )
|
||||
{
|
||||
if( !m_board )
|
||||
return ret;
|
||||
|
||||
const PCB_PLOT_PARAMS& plotParams = m_board->GetPlotOptions();
|
||||
LSET layers = plotParams.GetLayerSelection() | plotParams.GetPlotOnAllLayersSelection();
|
||||
|
||||
ret.set( LAYER_3D_BOARD, true );
|
||||
ret.set( LAYER_3D_COPPER_TOP, layers.test( F_Cu ) );
|
||||
ret.set( LAYER_3D_COPPER_BOTTOM, layers.test( B_Cu ) );
|
||||
ret.set( LAYER_3D_SILKSCREEN_TOP, layers.test( F_SilkS ) );
|
||||
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, layers.test( B_SilkS ) );
|
||||
ret.set( LAYER_3D_SOLDERMASK_TOP, layers.test( F_Mask ) );
|
||||
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, layers.test( B_Mask ) );
|
||||
ret.set( LAYER_3D_SOLDERPASTE, layers.test( F_Paste ) );
|
||||
ret.set( LAYER_3D_ADHESIVE, layers.test( F_Adhes ) );
|
||||
ret.set( LAYER_3D_USER_COMMENTS, layers.test( Cmts_User ) );
|
||||
ret.set( LAYER_3D_USER_DRAWINGS, layers.test( Dwgs_User ) );
|
||||
ret.set( LAYER_3D_USER_ECO1, layers.test( Eco1_User ) );
|
||||
ret.set( LAYER_3D_USER_ECO2, layers.test( Eco2_User ) );
|
||||
|
||||
ret.set( LAYER_FP_REFERENCES, plotParams.GetPlotReference() );
|
||||
ret.set( LAYER_FP_VALUES, plotParams.GetPlotValue() );
|
||||
ret.set( LAYER_FP_TEXT, plotParams.GetPlotFPText() );
|
||||
}
|
||||
else if( LAYER_PRESET_3D* preset = m_Cfg->FindPreset( m_Cfg->m_CurrentPreset ) )
|
||||
{
|
||||
ret = preset->layers;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
|
||||
ret.set( LAYER_3D_COPPER_TOP, m_Cfg->m_Render.show_copper_top );
|
||||
ret.set( LAYER_3D_COPPER_BOTTOM, m_Cfg->m_Render.show_copper_bottom );
|
||||
ret.set( LAYER_3D_SILKSCREEN_TOP, m_Cfg->m_Render.show_silkscreen_top );
|
||||
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, m_Cfg->m_Render.show_silkscreen_bottom );
|
||||
ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
|
||||
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
|
||||
ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
|
||||
ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
|
||||
ret.set( LAYER_3D_USER_COMMENTS, m_Cfg->m_Render.show_comments );
|
||||
ret.set( LAYER_3D_USER_DRAWINGS, m_Cfg->m_Render.show_drawings );
|
||||
ret.set( LAYER_3D_USER_ECO1, m_Cfg->m_Render.show_eco1 );
|
||||
ret.set( LAYER_3D_USER_ECO2, m_Cfg->m_Render.show_eco2 );
|
||||
|
||||
ret.set( LAYER_FP_REFERENCES, m_Cfg->m_Render.show_fp_references );
|
||||
ret.set( LAYER_FP_VALUES, m_Cfg->m_Render.show_fp_values );
|
||||
ret.set( LAYER_FP_TEXT, m_Cfg->m_Render.show_fp_text );
|
||||
m_SilkScreenColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ) );
|
||||
m_SilkScreenColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ) );
|
||||
m_SolderMaskColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_BOTTOM ) );
|
||||
m_SolderMaskColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ) );
|
||||
m_CopperColor = to_SFVEC4F( colors->GetColor( LAYER_3D_COPPER ) );
|
||||
m_BoardBodyColor = to_SFVEC4F( colors->GetColor( LAYER_3D_BOARD ) );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetDefaultVisibleLayers() const
|
||||
{
|
||||
std::bitset<LAYER_3D_END> ret;
|
||||
|
||||
ret.set( LAYER_3D_BOARD, true );
|
||||
ret.set( LAYER_3D_COPPER_TOP, true );
|
||||
ret.set( LAYER_3D_COPPER_BOTTOM, true );
|
||||
ret.set( LAYER_3D_SILKSCREEN_TOP, true );
|
||||
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, true );
|
||||
ret.set( LAYER_3D_SOLDERMASK_TOP, true );
|
||||
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, true );
|
||||
ret.set( LAYER_3D_SOLDERPASTE, true );
|
||||
ret.set( LAYER_3D_ADHESIVE, true );
|
||||
ret.set( LAYER_3D_USER_COMMENTS, false );
|
||||
ret.set( LAYER_3D_USER_DRAWINGS, false );
|
||||
ret.set( LAYER_3D_USER_ECO1, false );
|
||||
ret.set( LAYER_3D_USER_ECO2, false );
|
||||
|
||||
ret.set( LAYER_FP_REFERENCES, true );
|
||||
ret.set( LAYER_FP_VALUES, true );
|
||||
ret.set( LAYER_FP_TEXT, true );
|
||||
|
||||
ret.set( LAYER_3D_TH_MODELS, true );
|
||||
ret.set( LAYER_3D_SMD_MODELS, true );
|
||||
ret.set( LAYER_3D_VIRTUAL_MODELS, true );
|
||||
ret.set( LAYER_3D_MODELS_NOT_IN_POS, false );
|
||||
ret.set( LAYER_3D_MODELS_MARKED_DNP, false );
|
||||
|
||||
ret.set( LAYER_3D_BOUNDING_BOXES, false );
|
||||
ret.set( LAYER_3D_OFF_BOARD_SILK, false );
|
||||
ret.set( LAYER_3D_AXES, true );
|
||||
|
||||
return ret;
|
||||
}
|
||||
extern bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
|
||||
int aErrorMax, int aChainingEpsilon,
|
||||
OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
|
||||
|
||||
|
||||
bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
|
||||
@@ -955,7 +687,9 @@ bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
|
||||
success = BuildFootprintPolygonOutlines( m_board, m_board_poly,
|
||||
m_board->GetDesignSettings().m_MaxError,
|
||||
chainingEpsilon );
|
||||
m_board_poly.Simplify();
|
||||
|
||||
// Make polygon strictly simple to avoid issues (especially in 3D viewer)
|
||||
m_board_poly.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
|
||||
if( !success && aErrorMsg )
|
||||
{
|
||||
@@ -965,7 +699,7 @@ bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
|
||||
}
|
||||
else
|
||||
{
|
||||
success = m_board->GetBoardPolygonOutlines( m_board_poly, nullptr, false, true );
|
||||
success = m_board->GetBoardPolygonOutlines( m_board_poly );
|
||||
|
||||
if( !success && aErrorMsg )
|
||||
*aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
|
||||
@@ -979,16 +713,18 @@ float BOARD_ADAPTER::GetFootprintZPos( bool aIsFlipped ) const
|
||||
{
|
||||
if( aIsFlipped )
|
||||
{
|
||||
if( auto it = m_layerZcoordBottom.find( B_Paste ); it != m_layerZcoordBottom.end() )
|
||||
return it->second;
|
||||
if( m_Cfg->m_Render.show_solderpaste )
|
||||
return m_layerZcoordBottom[B_SilkS];
|
||||
else
|
||||
return m_layerZcoordBottom[B_Paste];
|
||||
}
|
||||
else
|
||||
{
|
||||
if( auto it = m_layerZcoordTop.find( F_Paste ); it != m_layerZcoordTop.end() )
|
||||
return it->second;
|
||||
if( m_Cfg->m_Render.show_solderpaste )
|
||||
return m_layerZcoordTop[F_SilkS];
|
||||
else
|
||||
return m_layerZcoordTop[F_Paste];
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2023 CERN
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -31,8 +30,8 @@
|
||||
#include "../3d_rendering/raytracing/accelerators/container_2d.h"
|
||||
#include "../3d_rendering/raytracing/accelerators/container_3d.h"
|
||||
#include "../3d_rendering/raytracing/shapes3D/bbox_3d.h"
|
||||
#include <gal/3d/camera.h>
|
||||
#include <3d_enums.h>
|
||||
#include "../3d_rendering/camera.h"
|
||||
#include "../3d_enums.h"
|
||||
#include "../3d_cache/3d_cache.h"
|
||||
#include "../common_ogl/ogl_attr_list.h"
|
||||
#include "../3d_viewer/eda_3d_viewer_settings.h"
|
||||
@@ -42,8 +41,6 @@
|
||||
#include <pcb_track.h>
|
||||
#include <pcb_base_frame.h>
|
||||
#include <pcb_text.h>
|
||||
#include <pcb_textbox.h>
|
||||
#include <pcb_table.h>
|
||||
#include <pcb_shape.h>
|
||||
#include <pcb_dimension.h>
|
||||
#include <zone.h>
|
||||
@@ -52,7 +49,6 @@
|
||||
#include <dialogs/dialog_color_picker.h>
|
||||
|
||||
class COLOR_SETTINGS;
|
||||
class PCB_TEXTBOX;
|
||||
|
||||
/// A type that stores a container of 2d objects for each layer id
|
||||
typedef std::map<PCB_LAYER_ID, BVH_CONTAINER_2D*> MAP_CONTAINER_2D_BASE;
|
||||
@@ -89,8 +85,7 @@ public:
|
||||
*
|
||||
* @param aLayer layer ID to get status.
|
||||
*/
|
||||
bool Is3dLayerEnabled( PCB_LAYER_ID aLayer,
|
||||
const std::bitset<LAYER_3D_END>& aVisibilityFlags ) const;
|
||||
bool Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const;
|
||||
|
||||
/**
|
||||
* Test if footprint should be displayed in relation to attributes and the flags.
|
||||
@@ -107,23 +102,6 @@ public:
|
||||
|
||||
void ReloadColorSettings() noexcept;
|
||||
|
||||
/**
|
||||
* Build a color list which is used to store colors layers
|
||||
*/
|
||||
std::map<int, COLOR4D> GetLayerColors() const;
|
||||
|
||||
/**
|
||||
* Build the copper color list used by the board editor, and store it in m_BoardEditorColors
|
||||
*/
|
||||
void GetBoardEditorCopperLayerColors( PCBNEW_SETTINGS* aCfg );
|
||||
|
||||
std::map<int, COLOR4D> GetDefaultColors() const;
|
||||
void SetLayerColors( const std::map<int, COLOR4D>& aColors );
|
||||
|
||||
std::bitset<LAYER_3D_END> GetVisibleLayers() const;
|
||||
std::bitset<LAYER_3D_END> GetDefaultVisibleLayers() const;
|
||||
void SetVisibleLayers( const std::bitset<LAYER_3D_END>& aLayers );
|
||||
|
||||
/**
|
||||
* Function to be called by the render when it need to reload the settings for the board.
|
||||
*
|
||||
@@ -140,7 +118,7 @@ public:
|
||||
double BiuTo3dUnits() const noexcept { return m_biuTo3Dunits; }
|
||||
|
||||
/**
|
||||
* Get the board outline bounding box.
|
||||
* Get the board outling bounding box.
|
||||
*
|
||||
* @return the board bounding box in 3D units.
|
||||
*/
|
||||
@@ -236,12 +214,7 @@ public:
|
||||
*/
|
||||
float GetLayerTopZPos( PCB_LAYER_ID aLayerId ) const noexcept
|
||||
{
|
||||
auto it = m_layerZcoordTop.find( aLayerId );
|
||||
|
||||
if( it != m_layerZcoordTop.end() )
|
||||
return it->second;
|
||||
else
|
||||
return -( m_boardBodyThickness3DU / 2.0f );
|
||||
return m_layerZcoordTop[aLayerId];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,12 +225,7 @@ public:
|
||||
*/
|
||||
float GetLayerBottomZPos( PCB_LAYER_ID aLayerId ) const noexcept
|
||||
{
|
||||
auto it = m_layerZcoordBottom.find( aLayerId );
|
||||
|
||||
if( it != m_layerZcoordBottom.end() )
|
||||
return it->second;
|
||||
else
|
||||
return -( m_boardBodyThickness3DU / 2.0f ) - m_backCopperThickness3DU;
|
||||
return m_layerZcoordBottom[aLayerId];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,12 +236,10 @@ public:
|
||||
const MAP_CONTAINER_2D_BASE& GetLayerMap() const noexcept { return m_layerMap; }
|
||||
const BVH_CONTAINER_2D* GetPlatedPadsFront() const noexcept { return m_platedPadsFront; }
|
||||
const BVH_CONTAINER_2D* GetPlatedPadsBack() const noexcept { return m_platedPadsBack; }
|
||||
const BVH_CONTAINER_2D* GetOffboardPadsFront() const noexcept { return m_offboardPadsFront; }
|
||||
const BVH_CONTAINER_2D* GetOffboardPadsBack() const noexcept { return m_offboardPadsBack; }
|
||||
|
||||
const MAP_CONTAINER_2D_BASE& GetLayerHoleMap() const noexcept { return m_layerHoleMap; }
|
||||
const BVH_CONTAINER_2D& GetTH_IDs() const noexcept { return m_TH_IDs; }
|
||||
const BVH_CONTAINER_2D& GetTH_ODs() const noexcept { return m_TH_ODs; }
|
||||
const BVH_CONTAINER_2D& GetThroughHoleIds() const noexcept { return m_throughHoleIds; }
|
||||
const BVH_CONTAINER_2D& GetThroughHoleOds() const noexcept { return m_throughHoleOds; }
|
||||
|
||||
/**
|
||||
* Get through hole outside diameter 2D polygons.
|
||||
@@ -282,37 +248,37 @@ public:
|
||||
*
|
||||
* @return a container with through hold outside diameter 2D polygons.
|
||||
*/
|
||||
const SHAPE_POLY_SET& GetTH_ODPolys() const noexcept
|
||||
const SHAPE_POLY_SET& GetThroughHoleOdPolys() const noexcept
|
||||
{
|
||||
return m_TH_ODPolys;
|
||||
return m_throughHoleOdPolys;
|
||||
}
|
||||
|
||||
const BVH_CONTAINER_2D& GetViaAnnuli() const noexcept
|
||||
const BVH_CONTAINER_2D& GetThroughHoleAnnularRings() const noexcept
|
||||
{
|
||||
return m_viaAnnuli;
|
||||
return m_throughHoleAnnularRings;
|
||||
}
|
||||
|
||||
const SHAPE_POLY_SET& GetViaAnnuliPolys() const noexcept
|
||||
const SHAPE_POLY_SET& GetThroughHoleAnnularRingPolys() const noexcept
|
||||
{
|
||||
return m_viaAnnuliPolys;
|
||||
return m_throughHoleAnnularRingPolys;
|
||||
}
|
||||
|
||||
const SHAPE_POLY_SET& GetNPTH_ODPolys() const noexcept
|
||||
const SHAPE_POLY_SET& GetOuterNonPlatedThroughHolePoly() const noexcept
|
||||
{
|
||||
return m_NPTH_ODPolys;
|
||||
return m_nonPlatedThroughHoleOdPolys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a container with through hole via hole outside diameters.
|
||||
*/
|
||||
const BVH_CONTAINER_2D& GetViaTH_ODs() const noexcept
|
||||
const BVH_CONTAINER_2D& GetThroughHoleViaOds() const noexcept
|
||||
{
|
||||
return m_viaTH_ODs;
|
||||
return m_throughHoleViaOds;
|
||||
}
|
||||
|
||||
const SHAPE_POLY_SET& GetViaTH_ODPolys() const noexcept
|
||||
const SHAPE_POLY_SET& GetThroughHoleViaOdPolys() const noexcept
|
||||
{
|
||||
return m_viaTH_ODPolys;
|
||||
return m_throughHoleViaOdPolys;
|
||||
}
|
||||
|
||||
unsigned int GetViaCount() const noexcept { return m_viaCount; }
|
||||
@@ -352,16 +318,8 @@ public:
|
||||
*/
|
||||
const MAP_POLY& GetPolyMap() const noexcept { return m_layers_poly; }
|
||||
|
||||
const SHAPE_POLY_SET* GetFrontPlatedPadAndGraphicPolys()
|
||||
{
|
||||
return m_frontPlatedPadAndGraphicPolys;
|
||||
}
|
||||
|
||||
const SHAPE_POLY_SET* GetBackPlatedPadAndGraphicPolys()
|
||||
{
|
||||
return m_backPlatedPadAndGraphicPolys;
|
||||
}
|
||||
|
||||
const SHAPE_POLY_SET* GetFrontPlatedPadPolys() { return m_frontPlatedPadPolys; }
|
||||
const SHAPE_POLY_SET* GetBackPlatedPadPolys() { return m_backPlatedPadPolys; }
|
||||
const MAP_POLY& GetHoleIdPolysMap() const noexcept { return m_layerHoleIdPolys; }
|
||||
const MAP_POLY& GetHoleOdPolysMap() const noexcept { return m_layerHoleOdPolys; }
|
||||
|
||||
@@ -376,49 +334,45 @@ private:
|
||||
void destroyLayers();
|
||||
|
||||
// Helper functions to create the board
|
||||
void createTrackWithMargin( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayer, int aMargin = 0 );
|
||||
void createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer );
|
||||
|
||||
void createPadWithMargin( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayer, const VECTOR2I& aMargin ) const;
|
||||
|
||||
void createPadWithHole( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
|
||||
int aInflateValue );
|
||||
OBJECT_2D* createPadWithDrill( const PAD* aPad, int aInflateValue );
|
||||
|
||||
void addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayerId, bool aSkipPlatedPads, bool aSkipNonPlatedPads );
|
||||
|
||||
void addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayerId,
|
||||
const std::bitset<LAYER_3D_END>& aVisibilityFlags );
|
||||
PCB_LAYER_ID aLayerId );
|
||||
|
||||
void addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
|
||||
const BOARD_ITEM* aOwner );
|
||||
|
||||
void addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM* aOwner, PCB_LAYER_ID aLayer );
|
||||
const BOARD_ITEM* aOwner );
|
||||
|
||||
void addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D_BASE* aDstContainer,
|
||||
const BOARD_ITEM* aOwner );
|
||||
|
||||
void addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM* aOwner );
|
||||
|
||||
void addTable( const PCB_TABLE* aTable, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM* aOwner );
|
||||
|
||||
void addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayerId );
|
||||
|
||||
void createArcSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
||||
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount, int aWidth,
|
||||
CONTAINER_2D_BASE* aContainer, const BOARD_ITEM& aOwner );
|
||||
void transformArcToSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
||||
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount, int aWidth,
|
||||
CONTAINER_2D_BASE* aDstContainer, const BOARD_ITEM& aOwner );
|
||||
|
||||
void buildPadOutlineAsSegments( const PAD* aPad, PCB_LAYER_ID aLayer,
|
||||
CONTAINER_2D_BASE* aDstContainer, int aWidth );
|
||||
void buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer, int aWidth );
|
||||
|
||||
// Helper functions to create poly contours
|
||||
void buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aBuffer, int aWidth) const;
|
||||
|
||||
void transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
|
||||
SHAPE_POLY_SET& aBuffer ) const;
|
||||
|
||||
public:
|
||||
static CUSTOM_COLORS_LIST g_SilkColors;
|
||||
static CUSTOM_COLORS_LIST g_SilkscreenColors;
|
||||
static CUSTOM_COLORS_LIST g_MaskColors;
|
||||
static CUSTOM_COLORS_LIST g_PasteColors;
|
||||
static CUSTOM_COLORS_LIST g_FinishColors;
|
||||
@@ -431,85 +385,74 @@ public:
|
||||
static KIGFX::COLOR4D g_DefaultSolderPaste;
|
||||
static KIGFX::COLOR4D g_DefaultSurfaceFinish;
|
||||
static KIGFX::COLOR4D g_DefaultBoardBody;
|
||||
static KIGFX::COLOR4D g_DefaultComments;
|
||||
static KIGFX::COLOR4D g_DefaultECOs;
|
||||
|
||||
public:
|
||||
EDA_3D_VIEWER_SETTINGS* m_Cfg;
|
||||
|
||||
bool m_IsBoardView;
|
||||
bool m_MousewheelPanning;
|
||||
bool m_IsPreviewer; ///< true if we're in a 3D preview panel, false
|
||||
///< for the standard 3D viewer
|
||||
bool m_IsPreviewer; ///< true if the board adaptater is living in a 3D
|
||||
///< preview panel, false for the standard 3D viewer
|
||||
|
||||
SFVEC4F m_BgColorBot; ///< background bottom color
|
||||
SFVEC4F m_BgColorTop; ///< background top color
|
||||
SFVEC4F m_BoardBodyColor; ///< in realistic mode: FR4 board color
|
||||
SFVEC4F m_SolderMaskColorBot; ///< in realistic mode: solder mask color ( bot )
|
||||
SFVEC4F m_SolderMaskColorTop; ///< in realistic mode: solder mask color ( top )
|
||||
SFVEC4F m_SolderPasteColor; ///< in realistic mode: solder paste color
|
||||
SFVEC4F m_SilkScreenColorBot; ///< in realistic mode: SilkScreen color ( bot )
|
||||
SFVEC4F m_SilkScreenColorTop; ///< in realistic mode: SilkScreen color ( top )
|
||||
SFVEC4F m_CopperColor; ///< in realistic mode: copper color
|
||||
SFVEC4F m_UserDrawingsColor;
|
||||
SFVEC4F m_UserCommentsColor;
|
||||
SFVEC4F m_ECO1Color;
|
||||
SFVEC4F m_ECO2Color;
|
||||
|
||||
std::map<int, COLOR4D> m_ColorOverrides; ///< allows to override color scheme colors
|
||||
std::map<int, COLOR4D> m_BoardEditorColors; ///< list of colors used by the board editor
|
||||
SFVEC4F m_BgColorBot; ///< background bottom color
|
||||
SFVEC4F m_BgColorTop; ///< background top color
|
||||
SFVEC4F m_BoardBodyColor; ///< in realistic mode: FR4 board color
|
||||
SFVEC4F m_SolderMaskColorBot; ///< in realistic mode: solder mask color ( bot )
|
||||
SFVEC4F m_SolderMaskColorTop; ///< in realistic mode: solder mask color ( top )
|
||||
SFVEC4F m_SolderPasteColor; ///< in realistic mode: solder paste color
|
||||
SFVEC4F m_SilkScreenColorBot; ///< in realistic mode: SilkScreen color ( bot )
|
||||
SFVEC4F m_SilkScreenColorTop; ///< in realistic mode: SilkScreen color ( top )
|
||||
SFVEC4F m_CopperColor; ///< in realistic mode: copper color
|
||||
|
||||
private:
|
||||
BOARD* m_board;
|
||||
S3D_CACHE* m_3dModelManager;
|
||||
RENDER_SETTINGS* m_renderSettings;
|
||||
COLOR_SETTINGS* m_colors;
|
||||
|
||||
VECTOR2I m_boardPos; ///< Board center position in board internal units.
|
||||
VECTOR2I m_boardSize; ///< Board size in board internal units.
|
||||
SFVEC3F m_boardCenter; ///< 3D center position of the board in 3D units.
|
||||
BBOX_3D m_boardBoundingBox; ///< 3D bounding box of the board in 3D units.
|
||||
VECTOR2I m_boardPos; ///< Board center position in board internal units.
|
||||
VECTOR2I m_boardSize; ///< Board size in board internal units.
|
||||
SFVEC3F m_boardCenter; ///< 3D center position of the board in 3D units.
|
||||
BBOX_3D m_boardBoundingBox; ///< 3D bounding box of the board in 3D units.
|
||||
|
||||
MAP_POLY m_layers_poly; ///< Amalgamated polygon contours for various types
|
||||
///< of items
|
||||
MAP_POLY m_layers_poly; ///< Amalgamated polygon contours for various types of
|
||||
///< items
|
||||
|
||||
SHAPE_POLY_SET* m_frontPlatedPadAndGraphicPolys;
|
||||
SHAPE_POLY_SET* m_backPlatedPadAndGraphicPolys;
|
||||
SHAPE_POLY_SET* m_frontPlatedCopperPolys;
|
||||
SHAPE_POLY_SET* m_backPlatedCopperPolys;
|
||||
SHAPE_POLY_SET* m_frontPlatedPadPolys;
|
||||
SHAPE_POLY_SET* m_backPlatedPadPolys;
|
||||
|
||||
MAP_POLY m_layerHoleOdPolys; ///< Hole outer diameters (per layer)
|
||||
MAP_POLY m_layerHoleIdPolys; ///< Hole inner diameters (per layer)
|
||||
MAP_POLY m_layerHoleOdPolys; ///< Hole outer diameters (per layer)
|
||||
MAP_POLY m_layerHoleIdPolys; ///< Hole inner diameters (per layer)
|
||||
|
||||
SHAPE_POLY_SET m_NPTH_ODPolys; ///< NPTH outer diameters
|
||||
SHAPE_POLY_SET m_TH_ODPolys; ///< PTH outer diameters
|
||||
SHAPE_POLY_SET m_viaTH_ODPolys; ///< Via hole outer diameters
|
||||
SHAPE_POLY_SET m_viaAnnuliPolys; ///< Via annular ring outer diameters
|
||||
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys; ///< NPTH outer diameters
|
||||
SHAPE_POLY_SET m_throughHoleOdPolys; ///< PTH outer diameters
|
||||
SHAPE_POLY_SET m_throughHoleViaOdPolys; ///< Via hole outer diameters
|
||||
SHAPE_POLY_SET m_throughHoleAnnularRingPolys; ///< Via annular ring outer diameters
|
||||
|
||||
SHAPE_POLY_SET m_board_poly; ///< Board outline polygon.
|
||||
SHAPE_POLY_SET m_board_poly; ///< Board outline polygon.
|
||||
|
||||
MAP_CONTAINER_2D_BASE m_layerMap; ///< 2D elements for each layer.
|
||||
MAP_CONTAINER_2D_BASE m_layerHoleMap; ///< Holes for each layer.
|
||||
MAP_CONTAINER_2D_BASE m_layerMap; ///< 2D elements for each layer.
|
||||
MAP_CONTAINER_2D_BASE m_layerHoleMap; ///< Holes for each layer.
|
||||
|
||||
BVH_CONTAINER_2D* m_platedPadsFront;
|
||||
BVH_CONTAINER_2D* m_platedPadsBack;
|
||||
BVH_CONTAINER_2D* m_offboardPadsFront;
|
||||
BVH_CONTAINER_2D* m_offboardPadsBack;
|
||||
|
||||
BVH_CONTAINER_2D m_TH_ODs; ///< List of PTH outer diameters
|
||||
BVH_CONTAINER_2D m_TH_IDs; ///< List of PTH inner diameters
|
||||
BVH_CONTAINER_2D m_viaAnnuli; ///< List of via annular rings
|
||||
BVH_CONTAINER_2D m_viaTH_ODs; ///< List of via hole outer diameters
|
||||
BVH_CONTAINER_2D m_throughHoleOds; ///< List of PTH outer diameters
|
||||
BVH_CONTAINER_2D m_throughHoleIds; ///< List of PTH inner diameters
|
||||
BVH_CONTAINER_2D m_throughHoleAnnularRings; ///< List of via annular rings
|
||||
BVH_CONTAINER_2D m_throughHoleViaOds; ///< List of via hole outer diameters
|
||||
BVH_CONTAINER_2D m_throughHoleViaIds; ///< List of via hole inner diameters
|
||||
|
||||
unsigned int m_copperLayersCount;
|
||||
|
||||
double m_biuTo3Dunits; ///< Scale factor to convert board internal units
|
||||
///< to 3D units normalized between -1.0 and 1.0.
|
||||
double m_biuTo3Dunits; ///< Scale factor to convert board internal units to
|
||||
///< 3D units normalized between -1.0 and 1.0.
|
||||
|
||||
std::map<PCB_LAYER_ID, float> m_layerZcoordTop; ///< Top (End) Z position of each
|
||||
///< layer in 3D units.
|
||||
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordTop; ///< Top (End) Z position of each
|
||||
///< layer in 3D units.
|
||||
|
||||
std::map<PCB_LAYER_ID, float> m_layerZcoordBottom; ///< Bottom (Start) Z position of
|
||||
///< each layer in 3D units.
|
||||
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordBottom; ///< Bottom (Start) Z position of
|
||||
///< each layer in 3D units.
|
||||
|
||||
float m_frontCopperThickness3DU;
|
||||
float m_backCopperThickness3DU;
|
||||
@@ -534,4 +477,13 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class EDA_3D_BOARD_HOLDER
|
||||
{
|
||||
public:
|
||||
virtual BOARD_ADAPTER& GetAdapter() = 0;
|
||||
virtual CAMERA& GetCurrentCamera() = 0;
|
||||
|
||||
virtual ~EDA_3D_BOARD_HOLDER() {};
|
||||
};
|
||||
|
||||
#endif // BOARD_ADAPTER_H
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2023 CERN
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -24,25 +23,27 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file create_3Dgraphic_brd_items.cpp
|
||||
* @file create_graphic_brd_items.cpp
|
||||
* @brief This file implements the creation of 2D graphic primitives of pcb items:
|
||||
* pads, tracks, drawsegments, texts....
|
||||
* It is based on the function found in the files:
|
||||
* board_items_to_polygon_shape_transform.cpp
|
||||
*/
|
||||
|
||||
#include "../3d_rendering/raytracing/shapes2D/ring_2d.h"
|
||||
#include "../3d_rendering/raytracing/shapes2D/filled_circle_2d.h"
|
||||
#include "../3d_rendering/raytracing/shapes2D/round_segment_2d.h"
|
||||
#include "../3d_rendering/raytracing/shapes2D/triangle_2d.h"
|
||||
#include "fp_textbox.h"
|
||||
#include <board_adapter.h>
|
||||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include <pad.h>
|
||||
#include <pcb_text.h>
|
||||
#include <pcb_textbox.h>
|
||||
#include <pcb_table.h>
|
||||
#include <fp_shape.h>
|
||||
#include <board_design_settings.h>
|
||||
#include <pcb_painter.h> // for PCB_RENDER_SETTINGS
|
||||
#include <zone.h>
|
||||
#include <fp_text.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <trigo.h>
|
||||
#include <geometry/shape_segment.h>
|
||||
@@ -62,37 +63,6 @@
|
||||
#define TO_SFVEC2F( vec ) SFVEC2F( TO_3DU( vec.x ), TO_3DU( -vec.y ) )
|
||||
|
||||
|
||||
void addFILLED_CIRCLE_2D( CONTAINER_2D_BASE* aContainer, const SFVEC2F& aCenter, float aRadius,
|
||||
const BOARD_ITEM& aBoardItem )
|
||||
{
|
||||
if( aRadius > 0.0f )
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( aCenter, aRadius, aBoardItem ) );
|
||||
}
|
||||
|
||||
|
||||
void addRING_2D( CONTAINER_2D_BASE* aContainer, const SFVEC2F& aCenter, float aInnerRadius,
|
||||
float aOuterRadius, const BOARD_ITEM& aBoardItem )
|
||||
{
|
||||
if( aOuterRadius > aInnerRadius && aInnerRadius > 0.0f )
|
||||
aContainer->Add( new RING_2D( aCenter, aInnerRadius, aOuterRadius, aBoardItem ) );
|
||||
}
|
||||
|
||||
|
||||
void addROUND_SEGMENT_2D( CONTAINER_2D_BASE* aContainer, const SFVEC2F& aStart, const SFVEC2F& aEnd,
|
||||
float aWidth, const BOARD_ITEM& aBoardItem )
|
||||
{
|
||||
if( Is_segment_a_circle( aStart, aEnd ) )
|
||||
{
|
||||
// Cannot add segments that have the same start and end point
|
||||
addFILLED_CIRCLE_2D( aContainer, aStart, aWidth / 2, aBoardItem );
|
||||
return;
|
||||
}
|
||||
|
||||
if( aWidth > 0.0f )
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( aStart, aEnd, aWidth, aBoardItem ) );
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM* aOwner )
|
||||
{
|
||||
@@ -100,21 +70,37 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine
|
||||
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
||||
float penWidth_3DU = TO_3DU( aText->GetEffectiveTextPenWidth() );
|
||||
KIFONT::FONT* font = aText->GetFont();
|
||||
wxString shownText = aText->GetShownText( true );
|
||||
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( wxEmptyString, aText->IsBold(), aText->IsItalic() );
|
||||
|
||||
if( aOwner && aOwner->IsKnockout() )
|
||||
{
|
||||
SHAPE_POLY_SET finalPoly;
|
||||
const PCB_TEXT* pcbText = static_cast<const PCB_TEXT*>( aOwner );
|
||||
SHAPE_POLY_SET knockouts;
|
||||
|
||||
pcbText->TransformTextToPolySet( finalPoly, 0, m_board->GetDesignSettings().m_MaxError,
|
||||
ERROR_INSIDE );
|
||||
CALLBACK_GAL callback_gal( empty_opts,
|
||||
// Polygon callback
|
||||
[&]( const SHAPE_LINE_CHAIN& aPoly )
|
||||
{
|
||||
knockouts.AddOutline( aPoly );
|
||||
} );
|
||||
|
||||
attrs.m_StrokeWidth = aText->GetEffectiveTextPenWidth();
|
||||
attrs.m_Angle = aText->GetDrawRotation();
|
||||
|
||||
callback_gal.SetIsFill( font->IsOutline() );
|
||||
callback_gal.SetIsStroke( font->IsStroke() );
|
||||
callback_gal.SetLineWidth( attrs.m_StrokeWidth );
|
||||
font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs );
|
||||
|
||||
SHAPE_POLY_SET finalPoly;
|
||||
int margin = attrs.m_StrokeWidth * 1.5 +
|
||||
GetKnockoutTextMargin( attrs.m_Size, attrs.m_StrokeWidth );
|
||||
|
||||
aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
|
||||
finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
|
||||
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
// Do not call finalPoly.Fracture() here: ConvertPolygonToTriangles() call it
|
||||
// if needed, and Fracture() called twice can create bad results and is useless
|
||||
ConvertPolygonToTriangles( finalPoly, *aContainer, m_biuTo3Dunits, *aOwner );
|
||||
}
|
||||
else
|
||||
@@ -123,8 +109,24 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine
|
||||
// Stroke callback
|
||||
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
|
||||
{
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( aPt1 ), TO_SFVEC2F( aPt2 ),
|
||||
penWidth_3DU, *aOwner );
|
||||
const SFVEC2F pt1_3DU = TO_SFVEC2F( aPt1 );
|
||||
const SFVEC2F pt2_3DU = TO_SFVEC2F( aPt2 );
|
||||
|
||||
if( penWidth_3DU == 0.0 )
|
||||
{
|
||||
// Don't attempt to render degenerate shapes
|
||||
}
|
||||
else if( Is_segment_a_circle( pt1_3DU, pt2_3DU ) )
|
||||
{
|
||||
// Cannot add segments that have the same start and end point
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( pt1_3DU, penWidth_3DU / 2,
|
||||
*aOwner ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( pt1_3DU, pt2_3DU, penWidth_3DU,
|
||||
*aOwner ) );
|
||||
}
|
||||
},
|
||||
// Triangulation callback
|
||||
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
|
||||
@@ -135,15 +137,7 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine
|
||||
|
||||
attrs.m_Angle = aText->GetDrawRotation();
|
||||
|
||||
if( auto* cache = aText->GetRenderCache( font, shownText ) )
|
||||
{
|
||||
callback_gal.DrawGlyphs( *cache );
|
||||
}
|
||||
else
|
||||
{
|
||||
font->Draw( &callback_gal, shownText, aText->GetDrawPos(), attrs,
|
||||
aOwner->GetFontMetrics() );
|
||||
}
|
||||
font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,19 +157,18 @@ void BOARD_ADAPTER::addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D
|
||||
{
|
||||
const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
|
||||
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( seg.A ), TO_SFVEC2F( seg.B ),
|
||||
TO_3DU( linewidth ), *aOwner );
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( seg.A ), TO_SFVEC2F( seg.B ),
|
||||
TO_3DU( linewidth ), *aOwner ) );
|
||||
break;
|
||||
}
|
||||
|
||||
case SH_CIRCLE:
|
||||
{
|
||||
int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
|
||||
float innerR3DU = TO_3DU( radius ) - TO_3DU( aDimension->GetLineThickness() ) / 2.0f;
|
||||
float outerR3DU = TO_3DU( radius ) + TO_3DU( aDimension->GetLineThickness() ) / 2.0f;
|
||||
|
||||
addRING_2D( aContainer, TO_SFVEC2F( shape->Centre() ), innerR3DU, outerR3DU, *aOwner );
|
||||
int delta = aDimension->GetLineThickness() / 2;
|
||||
|
||||
aContainer->Add( new RING_2D( TO_SFVEC2F( shape->Centre() ), TO_3DU( radius - delta ),
|
||||
TO_3DU( radius + delta ), *aOwner ) );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -187,76 +180,48 @@ void BOARD_ADAPTER::addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D
|
||||
|
||||
|
||||
void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aContainer,
|
||||
PCB_LAYER_ID aLayerId,
|
||||
const std::bitset<LAYER_3D_END>& aVisibilityFlags )
|
||||
PCB_LAYER_ID aLayerId )
|
||||
{
|
||||
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
|
||||
|
||||
for( PCB_FIELD* field : aFootprint->GetFields() )
|
||||
{
|
||||
if( field->GetLayer() == aLayerId && field->IsVisible() )
|
||||
{
|
||||
if( !aVisibilityFlags.test( LAYER_FP_TEXT ) )
|
||||
continue;
|
||||
else if( field->IsReference() && !aVisibilityFlags.test( LAYER_FP_REFERENCES ) )
|
||||
continue;
|
||||
else if( field->IsValue() && !aVisibilityFlags.test( LAYER_FP_VALUES ) )
|
||||
continue;
|
||||
if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
|
||||
addText( &aFootprint->Reference(), aContainer, &aFootprint->Reference() );
|
||||
|
||||
addText( field, aContainer, field );
|
||||
}
|
||||
}
|
||||
if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
|
||||
addText( &aFootprint->Value(), aContainer, &aFootprint->Value() );
|
||||
|
||||
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_TEXT_T:
|
||||
case PCB_FP_TEXT_T:
|
||||
{
|
||||
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
|
||||
FP_TEXT* text = static_cast<FP_TEXT*>( item );
|
||||
|
||||
if( text->GetLayer() == aLayerId && text->IsVisible() )
|
||||
{
|
||||
if( !aVisibilityFlags.test( LAYER_FP_TEXT ) )
|
||||
continue;
|
||||
else if( text->GetText() == wxT( "${REFERENCE}" )
|
||||
&& !aVisibilityFlags.test( LAYER_FP_REFERENCES ) )
|
||||
continue;
|
||||
else if( text->GetText() == wxT( "${VALUE}" )
|
||||
&& !aVisibilityFlags.test( LAYER_FP_VALUES ) )
|
||||
continue;
|
||||
|
||||
addText( text, aContainer, text );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_FP_TEXTBOX_T:
|
||||
{
|
||||
FP_TEXTBOX* textbox = static_cast<FP_TEXTBOX*>( item );
|
||||
|
||||
if( textbox->GetLayer() == aLayerId )
|
||||
{
|
||||
addShape( textbox, aContainer, aFootprint );
|
||||
addText( textbox, aContainer, aFootprint );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_TEXTBOX_T:
|
||||
{
|
||||
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
|
||||
|
||||
if( textbox->GetLayer() == aLayerId )
|
||||
addShape( textbox, aContainer, aFootprint );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_TABLE_T:
|
||||
{
|
||||
PCB_TABLE* table = static_cast<PCB_TABLE*>( item );
|
||||
|
||||
if( table->GetLayer() == aLayerId )
|
||||
addTable( table, aContainer, aFootprint );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_DIM_ALIGNED_T:
|
||||
case PCB_DIM_CENTER_T:
|
||||
case PCB_DIM_ORTHOGONAL_T:
|
||||
case PCB_DIM_RADIAL_T:
|
||||
case PCB_DIM_LEADER_T:
|
||||
case PCB_FP_DIM_ALIGNED_T:
|
||||
case PCB_FP_DIM_CENTER_T:
|
||||
case PCB_FP_DIM_ORTHOGONAL_T:
|
||||
case PCB_FP_DIM_RADIAL_T:
|
||||
case PCB_FP_DIM_LEADER_T:
|
||||
{
|
||||
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
|
||||
|
||||
@@ -266,12 +231,12 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_SHAPE_T:
|
||||
case PCB_FP_SHAPE_T:
|
||||
{
|
||||
PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
|
||||
FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
|
||||
|
||||
if( shape->IsOnLayer( aLayerId ) )
|
||||
addShape( shape, aContainer, aFootprint, aLayerId );
|
||||
if( shape->GetLayer() == aLayerId )
|
||||
addShape( shape, aContainer, aFootprint );
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -283,9 +248,7 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::createTrackWithMargin( const PCB_TRACK* aTrack,
|
||||
CONTAINER_2D_BASE* aDstContainer, PCB_LAYER_ID aLayer,
|
||||
int aMargin )
|
||||
void BOARD_ADAPTER::createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer )
|
||||
{
|
||||
SFVEC2F start3DU = TO_SFVEC2F( aTrack->GetStart() );
|
||||
SFVEC2F end3DU = TO_SFVEC2F( aTrack->GetEnd() );
|
||||
@@ -294,10 +257,11 @@ void BOARD_ADAPTER::createTrackWithMargin( const PCB_TRACK* aTrack,
|
||||
{
|
||||
case PCB_VIA_T:
|
||||
{
|
||||
const PCB_VIA* via = static_cast<const PCB_VIA*>( aTrack );
|
||||
float width3DU = TO_3DU( via->GetWidth( aLayer ) + aMargin * 2 );
|
||||
const float radius3DU = TO_3DU( aTrack->GetWidth() / 2 );
|
||||
|
||||
if( radius3DU > 0.0 )
|
||||
aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius3DU, *aTrack ) );
|
||||
|
||||
addFILLED_CIRCLE_2D( aDstContainer, start3DU, width3DU / 2.0, *aTrack );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -305,23 +269,10 @@ void BOARD_ADAPTER::createTrackWithMargin( const PCB_TRACK* aTrack,
|
||||
{
|
||||
const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
|
||||
|
||||
if( arc->IsDegenerated() )
|
||||
{
|
||||
// Draw this very small arc like a track segment (a PCB_TRACE_T)
|
||||
PCB_TRACK track( arc->GetParent() );
|
||||
track.SetStart( arc->GetStart() );
|
||||
track.SetEnd( arc->GetEnd() );
|
||||
track.SetWidth( arc->GetWidth() );
|
||||
track.SetLayer( arc->GetLayer() );
|
||||
|
||||
createTrackWithMargin( &track, aDstContainer, aLayer, aMargin );
|
||||
return;
|
||||
}
|
||||
|
||||
VECTOR2I center( arc->GetCenter() );
|
||||
VECTOR2D center( arc->GetCenter() );
|
||||
EDA_ANGLE arc_angle = arc->GetAngle();
|
||||
double radius = arc->GetRadius();
|
||||
int arcsegcount = GetArcToSegmentCount( KiROUND( radius ), ARC_HIGH_DEF, arc_angle );
|
||||
int arcsegcount = GetArcToSegmentCount( radius, ARC_HIGH_DEF, arc_angle );
|
||||
int circlesegcount;
|
||||
|
||||
// Avoid arcs that cannot be drawn
|
||||
@@ -337,19 +288,32 @@ void BOARD_ADAPTER::createTrackWithMargin( const PCB_TRACK* aTrack,
|
||||
else
|
||||
{
|
||||
circlesegcount = KiROUND( arcsegcount * 360.0 / std::abs( arc_angle.AsDegrees() ) );
|
||||
circlesegcount = std::clamp( circlesegcount, 1, 128 );
|
||||
circlesegcount = std::max( 1, std::min( circlesegcount, 128 ) );
|
||||
}
|
||||
|
||||
createArcSegments( center, arc->GetStart(), arc_angle, circlesegcount,
|
||||
arc->GetWidth() + aMargin * 2,
|
||||
aDstContainer, *arc );
|
||||
transformArcToSegments( VECTOR2I( center.x, center.y ), arc->GetStart(), arc_angle,
|
||||
circlesegcount, arc->GetWidth(), aDstContainer, *arc );
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_TRACE_T: // Track is a usual straight segment
|
||||
{
|
||||
float width3DU = TO_3DU( aTrack->GetWidth() + aMargin * 2 );
|
||||
addROUND_SEGMENT_2D( aDstContainer, start3DU, end3DU, width3DU, *aTrack );
|
||||
if( aTrack->GetWidth() == 0 )
|
||||
{
|
||||
// Don't attempt to render degenerate shapes
|
||||
}
|
||||
else if( Is_segment_a_circle( start3DU, end3DU ) )
|
||||
{
|
||||
// Cannot add segments that have the same start and end point
|
||||
aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aTrack->GetWidth() / 2 ),
|
||||
*aTrack ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aTrack->GetWidth() ),
|
||||
*aTrack ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -374,32 +338,21 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
|
||||
// is only the size of the anchor), so for those we punt and just use aMargin.x.
|
||||
|
||||
if( ( clearance.x < 0 || clearance.x != clearance.y )
|
||||
&& aPad->GetShape( aLayer ) != PAD_SHAPE::CUSTOM )
|
||||
&& aPad->GetShape() != PAD_SHAPE::CUSTOM )
|
||||
{
|
||||
VECTOR2I dummySize = VECTOR2I( aPad->GetSize( aLayer ) ) + clearance + clearance;
|
||||
VECTOR2I dummySize = VECTOR2I( aPad->GetSize() ) + clearance + clearance;
|
||||
|
||||
if( dummySize.x <= 0 || dummySize.y <= 0 )
|
||||
return;
|
||||
|
||||
PAD dummy( *aPad );
|
||||
dummy.SetSize( aLayer, VECTOR2I( dummySize.x, dummySize.y ) );
|
||||
dummy.SetSize( wxSize( dummySize.x, dummySize.y ) );
|
||||
dummy.TransformShapeToPolygon( poly, aLayer, 0, maxError, ERROR_INSIDE );
|
||||
clearance = { 0, 0 };
|
||||
|
||||
// Remove group membership from dummy item before deleting
|
||||
dummy.SetParentGroup( nullptr );
|
||||
}
|
||||
else if( aPad->GetShape( aLayer ) == PAD_SHAPE::CUSTOM )
|
||||
{
|
||||
// A custom pad can have many complex subshape items. To avoid issues, use its
|
||||
// final polygon shape, not its basic shape set. One cannot apply the clearance
|
||||
// to each subshape: it does no work
|
||||
aPad->TransformShapeToPolygon( poly, aLayer, 0, maxError );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto padShapes =
|
||||
std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( aLayer ) );
|
||||
auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
|
||||
|
||||
for( const SHAPE* shape : padShapes->Shapes() )
|
||||
{
|
||||
@@ -409,11 +362,24 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
|
||||
{
|
||||
const SHAPE_SEGMENT* seg = static_cast<const SHAPE_SEGMENT*>( shape );
|
||||
|
||||
addROUND_SEGMENT_2D( aContainer,
|
||||
TO_SFVEC2F( seg->GetSeg().A ),
|
||||
TO_SFVEC2F( seg->GetSeg().B ),
|
||||
TO_3DU( seg->GetWidth() + clearance.x * 2 ),
|
||||
*aPad );
|
||||
const SFVEC2F a3DU = TO_SFVEC2F( seg->GetSeg().A );
|
||||
const SFVEC2F b3DU = TO_SFVEC2F( seg->GetSeg().B );
|
||||
const double width3DU = TO_3DU( seg->GetWidth() + clearance.x * 2 );
|
||||
|
||||
if( width3DU == 0.0 )
|
||||
{
|
||||
// Don't attempt to render degenerate shapes
|
||||
}
|
||||
else if( Is_segment_a_circle( a3DU, b3DU ) )
|
||||
{
|
||||
// Cannot add segments that have the same start and end point
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -421,10 +387,13 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
|
||||
{
|
||||
const SHAPE_CIRCLE* circle = static_cast<const SHAPE_CIRCLE*>( shape );
|
||||
|
||||
addFILLED_CIRCLE_2D( aContainer,
|
||||
TO_SFVEC2F( circle->GetCenter() ),
|
||||
TO_3DU( circle->GetRadius() + clearance.x ),
|
||||
*aPad );
|
||||
const double radius3DU = TO_3DU( circle->GetRadius() + clearance.x );
|
||||
const SFVEC2F center3DU = TO_SFVEC2F( circle->GetCenter() );
|
||||
|
||||
// Don't render zero radius circles
|
||||
if( radius3DU > 0.0 )
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( center3DU, radius3DU, *aPad ) );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -445,7 +414,7 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
|
||||
break;
|
||||
|
||||
case SH_POLY_SET:
|
||||
poly.Append( *static_cast<const SHAPE_POLY_SET*>( shape ) );
|
||||
poly = *(SHAPE_POLY_SET*) shape;
|
||||
break;
|
||||
|
||||
case SH_ARC:
|
||||
@@ -456,12 +425,23 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
|
||||
for( int i = 0; i < l.SegmentCount(); i++ )
|
||||
{
|
||||
SHAPE_SEGMENT seg( l.Segment( i ).A, l.Segment( i ).B, arc->GetWidth() );
|
||||
const SFVEC2F a3DU = TO_SFVEC2F( seg.GetSeg().A );
|
||||
const SFVEC2F b3DU = TO_SFVEC2F( seg.GetSeg().B );
|
||||
const double width3DU = TO_3DU( arc->GetWidth() + clearance.x * 2 );
|
||||
|
||||
addROUND_SEGMENT_2D( aContainer,
|
||||
TO_SFVEC2F( seg.GetSeg().A ),
|
||||
TO_SFVEC2F( seg.GetSeg().B ),
|
||||
TO_3DU( arc->GetWidth() + clearance.x * 2 ),
|
||||
*aPad );
|
||||
if( width3DU == 0.0 )
|
||||
{
|
||||
// Don't attempt to render degenerate shapes
|
||||
}
|
||||
else if( Is_segment_a_circle( a3DU, b3DU ) )
|
||||
{
|
||||
// Cannot add segments that have the same start and end point
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -477,7 +457,7 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
|
||||
if( !poly.IsEmpty() )
|
||||
{
|
||||
if( clearance.x )
|
||||
poly.Inflate( clearance.x, CORNER_STRATEGY::ROUND_ALL_CORNERS, maxError );
|
||||
poly.Inflate( clearance.x, 32 );
|
||||
|
||||
// Add the PAD polygon
|
||||
ConvertPolygonToTriangles( poly, *aContainer, m_biuTo3Dunits, *aPad );
|
||||
@@ -485,22 +465,29 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::createPadWithHole( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
|
||||
int aInflateValue )
|
||||
OBJECT_2D* BOARD_ADAPTER::createPadWithDrill( const PAD* aPad, int aInflateValue )
|
||||
{
|
||||
if( !aPad->HasHole() )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithHole - found an invalid pad" ) );
|
||||
return;
|
||||
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
|
||||
|
||||
addROUND_SEGMENT_2D( aDstContainer,
|
||||
TO_SFVEC2F( slot->GetSeg().A ),
|
||||
TO_SFVEC2F( slot->GetSeg().B ),
|
||||
TO_3DU( slot->GetWidth() + aInflateValue * 2 ),
|
||||
*aPad );
|
||||
if( slot->GetSeg().A == slot->GetSeg().B )
|
||||
{
|
||||
return new FILLED_CIRCLE_2D( TO_SFVEC2F( slot->GetSeg().A ),
|
||||
TO_3DU( slot->GetWidth() / 2 + aInflateValue ),
|
||||
*aPad );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ROUND_SEGMENT_2D( TO_SFVEC2F( slot->GetSeg().A ),
|
||||
TO_SFVEC2F( slot->GetSeg().B ),
|
||||
TO_3DU( slot->GetWidth() + aInflateValue * 2 ),
|
||||
*aPad );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -549,13 +536,13 @@ void BOARD_ADAPTER::addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aCo
|
||||
|
||||
case F_Mask:
|
||||
case B_Mask:
|
||||
margin.x += pad->GetSolderMaskExpansion( aLayerId );
|
||||
margin.y += pad->GetSolderMaskExpansion( aLayerId );
|
||||
margin.x += pad->GetSolderMaskExpansion();
|
||||
margin.y += pad->GetSolderMaskExpansion();
|
||||
break;
|
||||
|
||||
case F_Paste:
|
||||
case B_Paste:
|
||||
margin += pad->GetSolderPasteMargin( aLayerId );
|
||||
margin += pad->GetSolderPasteMargin();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -569,10 +556,10 @@ void BOARD_ADAPTER::addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aCo
|
||||
|
||||
// based on TransformArcToPolygon function from
|
||||
// common/convert_basic_shapes_to_polygon.cpp
|
||||
void BOARD_ADAPTER::createArcSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
||||
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount,
|
||||
int aWidth, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM& aOwner )
|
||||
void BOARD_ADAPTER::transformArcToSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
||||
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount,
|
||||
int aWidth, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM& aOwner )
|
||||
{
|
||||
// Don't attempt to render degenerate shapes
|
||||
if( aWidth == 0 )
|
||||
@@ -602,58 +589,70 @@ void BOARD_ADAPTER::createArcSegments( const VECTOR2I& aCentre, const VECTOR2I&
|
||||
curr_end = arc_start;
|
||||
RotatePoint( curr_end, aCentre, -ii );
|
||||
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( curr_start ), TO_SFVEC2F( curr_end ),
|
||||
TO_3DU( aWidth ), aOwner );
|
||||
const SFVEC2F start3DU = TO_SFVEC2F( curr_start );
|
||||
const SFVEC2F end3DU = TO_SFVEC2F( curr_end );
|
||||
|
||||
if( Is_segment_a_circle( start3DU, end3DU ) )
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
|
||||
else
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
|
||||
|
||||
curr_start = curr_end;
|
||||
}
|
||||
|
||||
if( curr_end != arc_end )
|
||||
{
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( curr_end ), TO_SFVEC2F( arc_end ),
|
||||
TO_3DU( aWidth ), aOwner );
|
||||
const SFVEC2F start3DU = TO_SFVEC2F( curr_end );
|
||||
const SFVEC2F end3DU = TO_SFVEC2F( arc_end );
|
||||
|
||||
if( Is_segment_a_circle( start3DU, end3DU ) )
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
|
||||
else
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM* aOwner, PCB_LAYER_ID aLayer )
|
||||
const BOARD_ITEM* aOwner )
|
||||
{
|
||||
// The full width of the lines to create
|
||||
int linewidth = aShape->GetWidth();
|
||||
int margin = 0;
|
||||
// The extra 1 protects the inner/outer radius values from degeneracy
|
||||
const int linewidth = aShape->GetWidth() + 1;
|
||||
PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
|
||||
|
||||
if( IsSolderMaskLayer( aLayer )
|
||||
&& aShape->HasSolderMask()
|
||||
&& IsExternalCopperLayer( aShape->GetLayer() ) )
|
||||
{
|
||||
margin = aShape->GetSolderMaskExpansion();
|
||||
linewidth += margin * 2;
|
||||
}
|
||||
|
||||
float linewidth3DU = TO_3DU( linewidth );
|
||||
|
||||
LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
|
||||
|
||||
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
||||
if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
|
||||
{
|
||||
switch( aShape->GetShape() )
|
||||
{
|
||||
case SHAPE_T::CIRCLE:
|
||||
{
|
||||
SFVEC2F center3DU = TO_SFVEC2F( aShape->GetCenter() );
|
||||
float innerR3DU = TO_3DU( aShape->GetRadius() ) - linewidth3DU / 2.0;
|
||||
float outerR3DU = TO_3DU( aShape->GetRadius() ) + linewidth3DU / 2.0;
|
||||
const SFVEC2F center3DU = TO_SFVEC2F( aShape->GetCenter() );
|
||||
float inner_radius3DU = TO_3DU( aShape->GetRadius() - linewidth / 2 );
|
||||
float outer_radius3DU = TO_3DU( aShape->GetRadius() + linewidth / 2 );
|
||||
|
||||
if( aShape->IsFilled() || innerR3DU <= 0.0 )
|
||||
addFILLED_CIRCLE_2D( aContainer, center3DU, outerR3DU, *aOwner );
|
||||
if( inner_radius3DU < 0 )
|
||||
inner_radius3DU = 0.0;
|
||||
|
||||
if( outer_radius3DU == 0.0 )
|
||||
{
|
||||
// Don't attempt to render degenerate shapes
|
||||
}
|
||||
else if( aShape->IsFilled() )
|
||||
{
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( center3DU, outer_radius3DU,
|
||||
*aOwner ) );
|
||||
}
|
||||
else
|
||||
addRING_2D( aContainer, center3DU, innerR3DU, outerR3DU, *aOwner );
|
||||
{
|
||||
aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU,
|
||||
*aOwner ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SHAPE_T::RECTANGLE:
|
||||
case SHAPE_T::RECT:
|
||||
if( aShape->IsFilled() )
|
||||
{
|
||||
SHAPE_POLY_SET polyList;
|
||||
@@ -661,13 +660,7 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
|
||||
aShape->TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
|
||||
ERROR_INSIDE );
|
||||
|
||||
polyList.Simplify();
|
||||
|
||||
if( margin != 0 )
|
||||
{
|
||||
polyList.Inflate( margin, CORNER_STRATEGY::ROUND_ALL_CORNERS,
|
||||
GetBoard()->GetDesignSettings().m_MaxError );
|
||||
}
|
||||
polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
|
||||
}
|
||||
@@ -675,14 +668,14 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
|
||||
{
|
||||
std::vector<VECTOR2I> pts = aShape->GetRectCorners();
|
||||
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( pts[0] ), TO_SFVEC2F( pts[1] ),
|
||||
linewidth3DU, *aOwner );
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( pts[1] ), TO_SFVEC2F( pts[2] ),
|
||||
linewidth3DU, *aOwner );
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( pts[2] ), TO_SFVEC2F( pts[3] ),
|
||||
linewidth3DU, *aOwner );
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( pts[3] ), TO_SFVEC2F( pts[0] ),
|
||||
linewidth3DU, *aOwner );
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[0] ), TO_SFVEC2F( pts[1] ),
|
||||
TO_3DU( linewidth ), *aOwner ) );
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[1] ), TO_SFVEC2F( pts[2] ),
|
||||
TO_3DU( linewidth ), *aOwner ) );
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[2] ), TO_SFVEC2F( pts[3] ),
|
||||
TO_3DU( linewidth ), *aOwner ) );
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[3] ), TO_SFVEC2F( pts[0] ),
|
||||
TO_3DU( linewidth ), *aOwner ) );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -690,15 +683,33 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
|
||||
{
|
||||
unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
|
||||
|
||||
createArcSegments( aShape->GetCenter(), aShape->GetStart(), aShape->GetArcAngle(),
|
||||
segCount, linewidth, aContainer, *aOwner );
|
||||
transformArcToSegments( aShape->GetCenter(), aShape->GetStart(), aShape->GetArcAngle(),
|
||||
segCount, linewidth, aContainer, *aOwner );
|
||||
break;
|
||||
}
|
||||
|
||||
case SHAPE_T::SEGMENT:
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( aShape->GetStart() ),
|
||||
TO_SFVEC2F( aShape->GetEnd() ), linewidth3DU, *aOwner );
|
||||
{
|
||||
const SFVEC2F start3DU = TO_SFVEC2F( aShape->GetStart() );
|
||||
const SFVEC2F end3DU = TO_SFVEC2F( aShape->GetEnd() );
|
||||
const double linewidth3DU = TO_3DU( linewidth );
|
||||
|
||||
if( linewidth3DU == 0.0 )
|
||||
{
|
||||
// Don't attempt to render degenerate shapes
|
||||
}
|
||||
else if( Is_segment_a_circle( start3DU, end3DU ) )
|
||||
{
|
||||
// Cannot add segments that have the same start and end point
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, linewidth3DU / 2, *aOwner ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth3DU, *aOwner ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SHAPE_T::BEZIER:
|
||||
case SHAPE_T::POLY:
|
||||
@@ -708,22 +719,9 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
|
||||
aShape->TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
|
||||
ERROR_INSIDE );
|
||||
|
||||
// Some polygons can be a bit complex (especially when coming from a
|
||||
// picture of a text converted to a polygon
|
||||
// So call Simplify before calling ConvertPolygonToTriangles, just in case.
|
||||
polyList.Simplify();
|
||||
|
||||
if( polyList.IsEmpty() ) // Just for caution
|
||||
break;
|
||||
|
||||
if( margin != 0 )
|
||||
{
|
||||
CORNER_STRATEGY cornerStr = margin >= 0 ? CORNER_STRATEGY::ROUND_ALL_CORNERS
|
||||
: CORNER_STRATEGY::ALLOW_ACUTE_CORNERS;
|
||||
|
||||
polyList.Inflate( margin, cornerStr, GetBoard()->GetDesignSettings().m_MaxError );
|
||||
}
|
||||
|
||||
ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
|
||||
break;
|
||||
}
|
||||
@@ -734,11 +732,12 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if( linewidth > 0 )
|
||||
{
|
||||
std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
|
||||
SFVEC2F a3DU;
|
||||
SFVEC2F b3DU;
|
||||
double width3DU = TO_3DU( linewidth );
|
||||
|
||||
const PCB_PLOT_PARAMS& plotParams = aShape->GetBoard()->GetPlotOptions();
|
||||
KIGFX::PCB_RENDER_SETTINGS renderSettings;
|
||||
@@ -748,11 +747,16 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
|
||||
|
||||
for( SHAPE* shape : shapes )
|
||||
{
|
||||
STROKE_PARAMS::Stroke( shape, lineStyle, aShape->GetWidth(), &renderSettings,
|
||||
STROKE_PARAMS::Stroke( shape, lineStyle, linewidth, &renderSettings,
|
||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||
{
|
||||
addROUND_SEGMENT_2D( aContainer, TO_SFVEC2F( a ), TO_SFVEC2F( b ),
|
||||
linewidth3DU, *aOwner );
|
||||
a3DU = TO_SFVEC2F( a );
|
||||
b3DU = TO_SFVEC2F( b );
|
||||
|
||||
if( Is_segment_a_circle( a3DU, b3DU ) )
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aOwner ) );
|
||||
else
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aOwner ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -762,79 +766,51 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM* aOwner )
|
||||
{
|
||||
addText( aTextBox, aContainer, aOwner );
|
||||
|
||||
if( !aTextBox->IsBorderEnabled() )
|
||||
return;
|
||||
|
||||
// We cannot use PCB_TEXTBOX::TransformShapeToPolygon because it convert the textbox
|
||||
// as filled polygon even if there's no background colour.
|
||||
// So for polygon, we use PCB_SHAPE::TransformShapeToPolygon
|
||||
|
||||
if( aTextBox->GetShape() == SHAPE_T::RECTANGLE )
|
||||
{
|
||||
addShape( static_cast<const PCB_SHAPE*>( aTextBox ), aContainer, aOwner, UNDEFINED_LAYER );
|
||||
}
|
||||
else
|
||||
{
|
||||
SHAPE_POLY_SET polyList;
|
||||
|
||||
aTextBox->PCB_SHAPE::TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
|
||||
ERROR_INSIDE );
|
||||
|
||||
ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::addTable( const PCB_TABLE* aTable, CONTAINER_2D_BASE* aContainer,
|
||||
const BOARD_ITEM* aOwner )
|
||||
{
|
||||
// JEY TODO: tables
|
||||
// add borders
|
||||
|
||||
for( PCB_TABLECELL* cell : aTable->GetCells() )
|
||||
addText( cell, aContainer, aOwner );
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* aContainer,
|
||||
PCB_LAYER_ID aLayerId )
|
||||
{
|
||||
// This convert the poly in outline and holes
|
||||
ConvertPolygonToTriangles( *aZone->GetFilledPolysList( aLayerId ), *aContainer, m_biuTo3Dunits,
|
||||
*aZone );
|
||||
ConvertPolygonToTriangles( *aZone->GetFilledPolysList( aLayerId ), *aContainer,
|
||||
m_biuTo3Dunits, *aZone );
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::buildPadOutlineAsSegments( const PAD* aPad, PCB_LAYER_ID aLayer,
|
||||
CONTAINER_2D_BASE* aContainer, int aWidth )
|
||||
void BOARD_ADAPTER::buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aContainer,
|
||||
int aWidth )
|
||||
{
|
||||
if( aPad->GetShape( aLayer ) == PAD_SHAPE::CIRCLE ) // Draw a ring
|
||||
if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
|
||||
{
|
||||
const SFVEC2F center3DU = TO_SFVEC2F( aPad->ShapePos( aLayer ) );
|
||||
const int radius = aPad->GetSize( aLayer ).x / 2;
|
||||
const float inner_radius3DU = TO_3DU( radius - aWidth / 2.0 );
|
||||
const float outer_radius3DU = TO_3DU( radius + aWidth / 2.0 );
|
||||
const SFVEC2F center3DU = TO_SFVEC2F( aPad->ShapePos() );
|
||||
const int radius = aPad->GetSize().x / 2;
|
||||
const float inner_radius3DU = TO_3DU( radius - aWidth / 2 );
|
||||
const float outer_radius3DU = TO_3DU( radius + aWidth / 2 );
|
||||
|
||||
addRING_2D( aContainer, center3DU, inner_radius3DU, outer_radius3DU, *aPad );
|
||||
aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU, *aPad ) );
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
// For other shapes, add outlines as thick segments in polygon buffer
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
|
||||
const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
|
||||
|
||||
for( int j = 0; j < path.PointCount(); j++ )
|
||||
{
|
||||
// For other shapes, add outlines as thick segments in polygon buffer
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon( aLayer,
|
||||
ERROR_INSIDE );
|
||||
const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
|
||||
SFVEC2F start3DU = TO_SFVEC2F( path.CPoint( j ) );
|
||||
SFVEC2F end3DU = TO_SFVEC2F( path.CPoint( j + 1 ) );
|
||||
|
||||
for( int j = 0; j < path.PointCount(); j++ )
|
||||
if( aWidth == 0 )
|
||||
{
|
||||
SFVEC2F start3DU = TO_SFVEC2F( path.CPoint( j ) );
|
||||
SFVEC2F end3DU = TO_SFVEC2F( path.CPoint( j + 1 ) );
|
||||
|
||||
addROUND_SEGMENT_2D( aContainer, start3DU, end3DU, TO_3DU( aWidth ), *aPad );
|
||||
// Don't attempt to render degenerate shapes
|
||||
}
|
||||
else if( Is_segment_a_circle( start3DU, end3DU ) )
|
||||
{
|
||||
// Cannot add segments that have the same start and end point
|
||||
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), *aPad ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), *aPad ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file create_layer_poly.cpp
|
||||
* @brief This file implements the creation of the pcb board items in the poly
|
||||
* contours format.
|
||||
*/
|
||||
|
||||
#include "board_adapter.h"
|
||||
#include <board_design_settings.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <fp_shape.h>
|
||||
#include <footprint.h>
|
||||
|
||||
|
||||
/*
|
||||
* This is used to draw pad outlines on silk layers.
|
||||
*/
|
||||
void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aBuffer,
|
||||
int aWidth ) const
|
||||
{
|
||||
int maxError = m_board->GetDesignSettings().m_MaxError;
|
||||
|
||||
if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
|
||||
{
|
||||
TransformRingToPolygon( aBuffer, aPad->ShapePos(), aPad->GetSize().x / 2, aWidth, maxError,
|
||||
ERROR_INSIDE );
|
||||
return;
|
||||
}
|
||||
|
||||
// For other shapes, add outlines as thick segments in polygon buffer
|
||||
const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
|
||||
const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
|
||||
|
||||
for( int ii = 0; ii < path.PointCount(); ++ii )
|
||||
{
|
||||
const VECTOR2I& a = path.CPoint( ii );
|
||||
const VECTOR2I& b = path.CPoint( ii + 1 );
|
||||
|
||||
TransformOvalToPolygon( aBuffer, a, b, aWidth, maxError, ERROR_INSIDE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BOARD_ADAPTER::transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
|
||||
SHAPE_POLY_SET& aBuffer ) const
|
||||
{
|
||||
int maxError = m_board->GetDesignSettings().m_MaxError;
|
||||
|
||||
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
|
||||
{
|
||||
if( item->Type() == PCB_FP_SHAPE_T )
|
||||
{
|
||||
FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
|
||||
|
||||
if( shape->GetLayer() == aLayer )
|
||||
shape->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
|
||||
}
|
||||
else if( BaseType( item->Type() ) == PCB_DIMENSION_T )
|
||||
{
|
||||
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
|
||||
|
||||
if( dimension->GetLayer() == aLayer )
|
||||
dimension->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -23,23 +23,23 @@
|
||||
*/
|
||||
|
||||
#include <gal/opengl/kiglew.h> // Must be included first
|
||||
#include <gal/opengl/gl_utils.h>
|
||||
#include <gl_utils.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include "../common_ogl/ogl_utils.h"
|
||||
#include "eda_3d_canvas.h"
|
||||
#include <eda_3d_viewer_frame.h>
|
||||
#include <3d_rendering/raytracing/render_3d_raytrace_gl.h>
|
||||
#include <3d_rendering/raytracing/render_3d_raytrace.h>
|
||||
#include <3d_rendering/opengl/render_3d_opengl.h>
|
||||
#include <3d_viewer_id.h>
|
||||
#include <advanced_config.h>
|
||||
#include <build_version.h>
|
||||
#include <board.h>
|
||||
#include <reporter.h>
|
||||
#include <gal/opengl/gl_context_mgr.h>
|
||||
#include <core/profile.h> // To use GetRunningMicroSecs or another profiling utility
|
||||
#include <gl_context_mgr.h>
|
||||
#include <profile.h> // To use GetRunningMicroSecs or another profiling utility
|
||||
#include <bitmaps.h>
|
||||
#include <macros.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
@@ -71,12 +71,10 @@ BEGIN_EVENT_TABLE( EDA_3D_CANVAS, HIDPI_GL_3D_CANVAS )
|
||||
EVT_MIDDLE_DOWN( EDA_3D_CANVAS::OnMiddleDown)
|
||||
EVT_MOUSEWHEEL( EDA_3D_CANVAS::OnMouseWheel )
|
||||
EVT_MOTION( EDA_3D_CANVAS::OnMouseMove )
|
||||
EVT_MAGNIFY( EDA_3D_CANVAS::OnMagnify )
|
||||
|
||||
// touch gesture events
|
||||
EVT_GESTURE_ZOOM( wxID_ANY, EDA_3D_CANVAS::OnZoomGesture )
|
||||
EVT_GESTURE_PAN( wxID_ANY, EDA_3D_CANVAS::OnPanGesture )
|
||||
EVT_GESTURE_ROTATE( wxID_ANY, EDA_3D_CANVAS::OnRotateGesture )
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
EVT_MAGNIFY( EDA_3D_CANVAS::OnMagnify )
|
||||
#endif
|
||||
|
||||
// other events
|
||||
EVT_ERASE_BACKGROUND( EDA_3D_CANVAS::OnEraseBackground )
|
||||
@@ -87,11 +85,10 @@ BEGIN_EVENT_TABLE( EDA_3D_CANVAS, HIDPI_GL_3D_CANVAS )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const wxGLAttributes& aGLAttribs,
|
||||
EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
|
||||
BOARD_ADAPTER& aBoardAdapter, CAMERA& aCamera,
|
||||
S3D_CACHE* a3DCachePointer ) :
|
||||
HIDPI_GL_3D_CANVAS( EDA_DRAW_PANEL_GAL::GetVcSettings(), aCamera, aParent, aGLAttribs,
|
||||
EDA_3D_CANVAS_ID, wxDefaultPosition,
|
||||
HIDPI_GL_3D_CANVAS( aCamera, aParent, wxID_ANY, aAttribList, wxDefaultPosition,
|
||||
wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ),
|
||||
m_eventDispatcher( nullptr ),
|
||||
m_parentStatusBar( nullptr ),
|
||||
@@ -125,7 +122,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const wxGLAttributes& aGLAttrib
|
||||
|
||||
m_is_currently_painting.clear();
|
||||
|
||||
m_3d_render_raytracing = new RENDER_3D_RAYTRACE_GL( this, m_boardAdapter, m_camera );
|
||||
m_3d_render_raytracing = new RENDER_3D_RAYTRACE( this, m_boardAdapter, m_camera );
|
||||
m_3d_render_opengl = new RENDER_3D_OPENGL( this, m_boardAdapter, m_camera );
|
||||
|
||||
wxASSERT( m_3d_render_raytracing != nullptr );
|
||||
@@ -149,12 +146,6 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const wxGLAttributes& aGLAttrib
|
||||
wxASSERT( a3DCachePointer != nullptr );
|
||||
m_boardAdapter.Set3dCacheManager( a3DCachePointer );
|
||||
|
||||
#if defined( __WXMSW__ )
|
||||
EnableTouchEvents( wxTOUCH_ZOOM_GESTURE | wxTOUCH_ROTATE_GESTURE | wxTOUCH_PAN_GESTURES );
|
||||
#elif defined( __WXGTK__ )
|
||||
EnableTouchEvents( wxTOUCH_ZOOM_GESTURE | wxTOUCH_ROTATE_GESTURE );
|
||||
#endif
|
||||
|
||||
const wxEventType events[] =
|
||||
{
|
||||
// Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
|
||||
@@ -165,7 +156,9 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const wxGLAttributes& aGLAttrib
|
||||
wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
|
||||
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
|
||||
wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, wxEVT_CHAR_HOOK,
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
wxEVT_MAGNIFY,
|
||||
#endif
|
||||
wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT
|
||||
};
|
||||
|
||||
@@ -189,8 +182,7 @@ void EDA_3D_CANVAS::releaseOpenGL()
|
||||
{
|
||||
if( m_glRC )
|
||||
{
|
||||
GL_CONTEXT_MANAGER* gl_mgr = Pgm().GetGLContextManager();
|
||||
gl_mgr->LockCtx( m_glRC, this );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
delete m_3d_render_raytracing;
|
||||
m_3d_render_raytracing = nullptr;
|
||||
@@ -201,8 +193,8 @@ void EDA_3D_CANVAS::releaseOpenGL()
|
||||
// This is just a copy of a pointer, can safely be set to NULL.
|
||||
m_3d_render = nullptr;
|
||||
|
||||
gl_mgr->UnlockCtx( m_glRC );
|
||||
gl_mgr->DestroyCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glRC );
|
||||
m_glRC = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -239,13 +231,10 @@ bool EDA_3D_CANVAS::initializeOpenGL()
|
||||
else
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::initializeOpenGL Using GLEW version %s" ),
|
||||
From_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
|
||||
FROM_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
|
||||
}
|
||||
|
||||
SetOpenGLInfo( (const char*) glGetString( GL_VENDOR ), (const char*) glGetString( GL_RENDERER ),
|
||||
(const char*) glGetString( GL_VERSION ) );
|
||||
|
||||
wxString version = From_UTF8( (char *) glGetString( GL_VERSION ) );
|
||||
wxString version = FROM_UTF8( (char *) glGetString( GL_VERSION ) );
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::%s OpenGL version string %s." ),
|
||||
__WXFUNCTION__, version );
|
||||
@@ -346,10 +335,6 @@ void EDA_3D_CANVAS::DisplayStatus()
|
||||
|
||||
msg.Printf( wxT( "dy %3.2f" ), m_camera.GetCameraPos().y );
|
||||
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::Y_POS ) );
|
||||
|
||||
msg.Printf( wxT( "zoom %3.2f" ), 1 / m_camera.GetZoom() );
|
||||
m_parentStatusBar->SetStatusText( msg,
|
||||
static_cast<int>( EDA_3D_VIEWER_STATUSBAR::ZOOM_LEVEL ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,14 +365,16 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
// therefore with invalid board.
|
||||
// This is dependent of the platform.
|
||||
// Especially on OSX, but also on Windows, it frequently happens
|
||||
if( !GetParent()->GetParent()->IsShownOnScreen() )
|
||||
if( !GetParent()->GetParent()->IsShown() )
|
||||
return; // The parent board editor frame is no more alive
|
||||
|
||||
wxString err_messages;
|
||||
INFOBAR_REPORTER warningReporter( m_parentInfoBar );
|
||||
STATUSBAR_REPORTER activityReporter( m_parentStatusBar, EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
|
||||
int64_t start_time = GetRunningMicroSecs();
|
||||
GL_CONTEXT_MANAGER* gl_mgr = Pgm().GetGLContextManager();
|
||||
wxString err_messages;
|
||||
|
||||
// !TODO: implement error reporter
|
||||
INFOBAR_REPORTER warningReporter( m_parentInfoBar );
|
||||
STATUSBAR_REPORTER activityReporter( m_parentStatusBar, EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
|
||||
|
||||
unsigned strtime = GetRunningMicroSecs();
|
||||
|
||||
// "Makes the OpenGL state that is represented by the OpenGL rendering
|
||||
// context context current, i.e. it will be used by all subsequent OpenGL calls.
|
||||
@@ -395,7 +382,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
|
||||
// Explicitly create a new rendering context instance for this canvas.
|
||||
if( m_glRC == nullptr )
|
||||
m_glRC = gl_mgr->CreateCtx( this );
|
||||
m_glRC = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
|
||||
|
||||
// CreateCtx could and does fail per sentry crash events, lets be graceful
|
||||
if( m_glRC == nullptr )
|
||||
@@ -406,7 +393,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
return;
|
||||
}
|
||||
|
||||
gl_mgr->LockCtx( m_glRC, this );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
// Set the OpenGL viewport according to the client size of this canvas.
|
||||
// This is done here rather than in a wxSizeEvent handler because our
|
||||
@@ -423,7 +410,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
{
|
||||
if( !initializeOpenGL() )
|
||||
{
|
||||
gl_mgr->UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
m_is_currently_painting.clear();
|
||||
|
||||
return;
|
||||
@@ -445,7 +432,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
|
||||
SwapBuffers();
|
||||
|
||||
gl_mgr->UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
m_is_currently_painting.clear();
|
||||
|
||||
return;
|
||||
@@ -479,8 +466,8 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
|
||||
if( m_camera_is_moving )
|
||||
{
|
||||
const int64_t curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
|
||||
curtime_delta_s = ( curtime_delta / 1e6 ) * m_camera_moving_speed;
|
||||
const unsigned curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
|
||||
curtime_delta_s = (curtime_delta / 1e6) * m_camera_moving_speed;
|
||||
m_camera.Interpolate( curtime_delta_s );
|
||||
|
||||
if( curtime_delta_s > 1.0f )
|
||||
@@ -533,7 +520,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
m_is_opengl_version_supported = false;
|
||||
m_opengl_supports_raytracing = false;
|
||||
m_is_opengl_initialized = false;
|
||||
gl_mgr->UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
m_is_currently_painting.clear();
|
||||
return;
|
||||
}
|
||||
@@ -545,9 +532,7 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
render_pivot( curtime_delta_s, scale );
|
||||
}
|
||||
|
||||
// This will only be enabled by the 3d mouse plugin, so we can leave
|
||||
// it as a simple if statement
|
||||
if( m_render3dmousePivot )
|
||||
if( m_render3dmousePivot && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
|
||||
{
|
||||
const float scale = glm::min( m_camera.GetZoom(), 1.0f );
|
||||
render3dmousePivot( scale );
|
||||
@@ -558,15 +543,18 @@ void EDA_3D_CANVAS::DoRePaint()
|
||||
// commands is displayed on the window."
|
||||
SwapBuffers();
|
||||
|
||||
gl_mgr->UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
|
||||
if( m_mouse_was_moved || m_camera_is_moving )
|
||||
if( !activityReporter.HasMessage() )
|
||||
{
|
||||
// Calculation time in milliseconds
|
||||
const double calculation_time = (double)( GetRunningMicroSecs() - start_time ) / 1e3;
|
||||
if( m_mouse_was_moved || m_camera_is_moving )
|
||||
{
|
||||
// Calculation time in milliseconds
|
||||
const double calculation_time = (double)( GetRunningMicroSecs() - strtime) / 1e3;
|
||||
|
||||
activityReporter.Report( wxString::Format( _( "Last render time %.0f ms" ),
|
||||
calculation_time ) );
|
||||
activityReporter.Report( wxString::Format( _( "Last render time %.0f ms" ),
|
||||
calculation_time ) );
|
||||
}
|
||||
}
|
||||
|
||||
// This will reset the flag of camera parameters changed
|
||||
@@ -626,6 +614,7 @@ void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event )
|
||||
}
|
||||
|
||||
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event )
|
||||
{
|
||||
SetFocus();
|
||||
@@ -643,82 +632,11 @@ void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event )
|
||||
DisplayStatus();
|
||||
Request_refresh();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::OnZoomGesture( wxZoomGestureEvent& aEvent )
|
||||
{
|
||||
SetFocus();
|
||||
|
||||
if( aEvent.IsGestureStart() )
|
||||
{
|
||||
m_gestureLastZoomFactor = 1.0;
|
||||
m_camera.SetCurMousePosition( aEvent.GetPosition() );
|
||||
}
|
||||
|
||||
if( m_camera_is_moving )
|
||||
return;
|
||||
|
||||
restart_editingTimeOut_Timer();
|
||||
|
||||
m_camera.Pan( aEvent.GetPosition() );
|
||||
m_camera.SetCurMousePosition( aEvent.GetPosition() );
|
||||
|
||||
m_camera.Zoom( aEvent.GetZoomFactor() / m_gestureLastZoomFactor );
|
||||
|
||||
m_gestureLastZoomFactor = aEvent.GetZoomFactor();
|
||||
|
||||
DisplayStatus();
|
||||
Request_refresh();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::OnPanGesture( wxPanGestureEvent& aEvent )
|
||||
{
|
||||
SetFocus();
|
||||
|
||||
if( aEvent.IsGestureStart() )
|
||||
m_camera.SetCurMousePosition( aEvent.GetPosition() );
|
||||
|
||||
if( m_camera_is_moving )
|
||||
return;
|
||||
|
||||
m_camera.Pan( aEvent.GetPosition() );
|
||||
m_camera.SetCurMousePosition( aEvent.GetPosition() );
|
||||
|
||||
DisplayStatus();
|
||||
Request_refresh();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::OnRotateGesture( wxRotateGestureEvent& aEvent )
|
||||
{
|
||||
SetFocus();
|
||||
|
||||
if( aEvent.IsGestureStart() )
|
||||
{
|
||||
m_gestureLastAngle = 0;
|
||||
m_camera.SetCurMousePosition( aEvent.GetPosition() );
|
||||
|
||||
// We don't want to process the first angle
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_camera_is_moving )
|
||||
return;
|
||||
|
||||
m_camera.RotateScreen( m_gestureLastAngle - aEvent.GetRotationAngle() );
|
||||
m_gestureLastAngle = aEvent.GetRotationAngle();
|
||||
|
||||
DisplayStatus();
|
||||
Request_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
|
||||
{
|
||||
if( m_3d_render && m_3d_render->IsReloadRequestPending() )
|
||||
return; // Prevents using invalid m_3d_render_raytracing data
|
||||
|
||||
if( m_camera_is_moving )
|
||||
return;
|
||||
|
||||
@@ -738,11 +656,13 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
|
||||
RAY mouseRay = getRayAtCurrentMousePosition();
|
||||
BOARD_ITEM* rollOverItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
|
||||
|
||||
auto printNetInfo = []( BOARD_CONNECTED_ITEM* aItem )
|
||||
{
|
||||
return wxString::Format( _( "Net %s\tNet class %s" ), aItem->GetNet()->GetNetname(),
|
||||
aItem->GetNet()->GetNetClass()->GetHumanReadableName() );
|
||||
};
|
||||
auto printNetInfo =
|
||||
[]( BOARD_CONNECTED_ITEM* aItem )
|
||||
{
|
||||
return wxString::Format( _( "Net %s\tNet class %s" ),
|
||||
aItem->GetNet()->GetNetname(),
|
||||
aItem->GetNet()->GetNetClass()->GetName() );
|
||||
};
|
||||
|
||||
if( rollOverItem )
|
||||
{
|
||||
@@ -833,11 +753,6 @@ void EDA_3D_CANVAS::OnLeftDown( wxMouseEvent& event )
|
||||
SetFocus();
|
||||
stop_editingTimeOut_Timer();
|
||||
|
||||
// Ensure m_camera.m_lastPosition (current mouse position) is up to date for
|
||||
// future drag events (can be not the case when left clicking after
|
||||
// opening a context menu)
|
||||
OnMouseMoveCamera( event );
|
||||
|
||||
if( !event.Dragging() && ( m_3d_render_raytracing != nullptr ) )
|
||||
{
|
||||
RAY mouseRay = getRayAtCurrentMousePosition();
|
||||
@@ -928,7 +843,7 @@ void EDA_3D_CANVAS::OnTimerTimeout_Redraw( wxTimerEvent& aEvent )
|
||||
|
||||
void EDA_3D_CANVAS::OnRefreshRequest( wxEvent& aEvent )
|
||||
{
|
||||
Refresh();
|
||||
DoRePaint();
|
||||
}
|
||||
|
||||
|
||||
@@ -1001,56 +916,68 @@ void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position()
|
||||
}
|
||||
|
||||
|
||||
bool EDA_3D_CANVAS::SetView3D( VIEW3D_TYPE aRequestedView )
|
||||
bool EDA_3D_CANVAS::SetView3D( int aKeycode )
|
||||
{
|
||||
if( m_camera_is_moving )
|
||||
return false;
|
||||
|
||||
const float delta_move = m_delta_move_step_factor * m_camera.GetZoom();
|
||||
const float arrow_moving_time_speed = 8.0f;
|
||||
bool handled = false;
|
||||
|
||||
switch( aRequestedView )
|
||||
switch( aKeycode )
|
||||
{
|
||||
case VIEW3D_TYPE::VIEW3D_PIVOT_CENTER:
|
||||
case WXK_SPACE:
|
||||
move_pivot_based_on_cur_mouse_position();
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_PAN_LEFT:
|
||||
case WXK_LEFT:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Pan_T1( SFVEC3F( -delta_move, 0.0f, 0.0f ) );
|
||||
request_start_moving_camera( arrow_moving_time_speed, false );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_PAN_RIGHT:
|
||||
case WXK_RIGHT:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Pan_T1( SFVEC3F( +delta_move, 0.0f, 0.0f ) );
|
||||
request_start_moving_camera( arrow_moving_time_speed, false );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_PAN_UP:
|
||||
case WXK_UP:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Pan_T1( SFVEC3F( 0.0f, +delta_move, 0.0f ) );
|
||||
request_start_moving_camera( arrow_moving_time_speed, false );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_PAN_DOWN:
|
||||
case WXK_DOWN:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Pan_T1( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
|
||||
request_start_moving_camera( arrow_moving_time_speed, false );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_FIT_SCREEN:
|
||||
case WXK_HOME:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Reset_T1();
|
||||
request_start_moving_camera( glm::min( glm::max( m_camera.GetZoom(), 1 / 1.26f ), 1.26f ) );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_ZOOM_IN:
|
||||
case WXK_END:
|
||||
break;
|
||||
|
||||
case WXK_TAB:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::EASING_IN_OUT );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.RotateZ_T1( glm::radians( 45.0f ) );
|
||||
request_start_moving_camera();
|
||||
handled = true;
|
||||
break;
|
||||
|
||||
case WXK_F1:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
|
||||
@@ -1059,7 +986,7 @@ bool EDA_3D_CANVAS::SetView3D( VIEW3D_TYPE aRequestedView )
|
||||
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_ZOOM_OUT:
|
||||
case WXK_F2:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
|
||||
@@ -1068,35 +995,93 @@ bool EDA_3D_CANVAS::SetView3D( VIEW3D_TYPE aRequestedView )
|
||||
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_RIGHT:
|
||||
case VIEW3D_TYPE::VIEW3D_LEFT:
|
||||
case VIEW3D_TYPE::VIEW3D_FRONT:
|
||||
case VIEW3D_TYPE::VIEW3D_BACK:
|
||||
case VIEW3D_TYPE::VIEW3D_FLIP:
|
||||
case ID_VIEW3D_RESET:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.ViewCommand_T1( aRequestedView );
|
||||
m_camera.Reset_T1();
|
||||
request_start_moving_camera( glm::min( glm::max( m_camera.GetZoom(), 0.5f ), 1.125f ) );
|
||||
return true;
|
||||
|
||||
case ID_VIEW3D_RIGHT:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Reset_T1();
|
||||
m_camera.RotateZ_T1( glm::radians( -90.0f ) );
|
||||
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
||||
request_start_moving_camera();
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_TOP:
|
||||
case VIEW3D_TYPE::VIEW3D_BOTTOM:
|
||||
case ID_VIEW3D_LEFT:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.ViewCommand_T1( aRequestedView );
|
||||
m_camera.Reset_T1();
|
||||
m_camera.RotateZ_T1( glm::radians( 90.0f ) );
|
||||
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
||||
request_start_moving_camera();
|
||||
return true;
|
||||
|
||||
case ID_VIEW3D_FRONT:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Reset_T1();
|
||||
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
||||
request_start_moving_camera();
|
||||
return true;
|
||||
|
||||
case ID_VIEW3D_BACK:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Reset_T1();
|
||||
m_camera.RotateX_T1( glm::radians( -90.0f ) );
|
||||
|
||||
// The rotation angle should be 180.
|
||||
// We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when
|
||||
// using 180 deg if the previous rotated position was already 180 deg
|
||||
m_camera.RotateZ_T1( glm::radians( 179.999f ) );
|
||||
request_start_moving_camera();
|
||||
return true;
|
||||
|
||||
case ID_VIEW3D_TOP:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Reset_T1();
|
||||
request_start_moving_camera( glm::min( glm::max( m_camera.GetZoom(), 0.5f ), 1.125f ) );
|
||||
return true;
|
||||
|
||||
case ID_VIEW3D_BOTTOM:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.Reset_T1();
|
||||
m_camera.RotateY_T1( glm::radians( 179.999f ) ); // Rotation = 180 - epsilon
|
||||
request_start_moving_camera( glm::min( glm::max( m_camera.GetZoom(), 0.5f ), 1.125f ) );
|
||||
return true;
|
||||
|
||||
case ID_VIEW3D_FLIP:
|
||||
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
|
||||
m_camera.SetT0_and_T1_current_T();
|
||||
m_camera.RotateY_T1( glm::radians( 179.999f ) );
|
||||
request_start_moving_camera();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
m_mouse_was_moved = true;
|
||||
|
||||
restart_editingTimeOut_Timer();
|
||||
|
||||
DisplayStatus();
|
||||
Request_refresh();
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::RenderEngineChanged()
|
||||
{
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" );
|
||||
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
||||
|
||||
switch( cfg->m_Render.engine )
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -38,12 +38,10 @@
|
||||
class WX_INFOBAR;
|
||||
class wxStatusBar;
|
||||
class BOARD;
|
||||
class RENDER_3D_RAYTRACE_GL;
|
||||
class RENDER_3D_RAYTRACE;
|
||||
class RENDER_3D_OPENGL;
|
||||
|
||||
|
||||
#define EDA_3D_CANVAS_ID wxID_HIGHEST + 1321
|
||||
|
||||
/**
|
||||
* Implement a canvas based on a wxGLCanvas
|
||||
*/
|
||||
@@ -54,12 +52,12 @@ public:
|
||||
* Create a new 3D Canvas with an attribute list.
|
||||
*
|
||||
* @param aParent the parent creator of this canvas.
|
||||
* @param aGLAttribs openGL attributes created by #OGL_ATT_LIST::GetAttributesList.
|
||||
* @param aAttribList a list of openGL options created by GetOpenGL_AttributesList.
|
||||
* @param aBoard The board.
|
||||
* @param aSettings the settings options to be used by this canvas.
|
||||
*/
|
||||
EDA_3D_CANVAS( wxWindow* aParent, const wxGLAttributes& aGLAttribs, BOARD_ADAPTER& aSettings,
|
||||
CAMERA& aCamera, S3D_CACHE* a3DCachePointer );
|
||||
EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
|
||||
BOARD_ADAPTER& aSettings, CAMERA& aCamera, S3D_CACHE* a3DCachePointer );
|
||||
|
||||
~EDA_3D_CANVAS();
|
||||
|
||||
@@ -99,7 +97,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current render ( a RENDER_3D_RAYTRACE_GL* or a RENDER_3D_OPENGL* render )
|
||||
* @return the current render ( a RENDER_3D_RAYTRACE* or a RENDER_3D_OPENGL* render )
|
||||
*/
|
||||
RENDER_3D_BASE* GetCurrentRender() const { return m_3d_render; }
|
||||
|
||||
@@ -109,19 +107,19 @@ public:
|
||||
void RenderRaytracingRequest();
|
||||
|
||||
/**
|
||||
* Request a screenshot and output it to the \a aDstImage.
|
||||
* Request a screenshot and output it to the \a aDstImage
|
||||
*
|
||||
* @param aDstImage - Screenshot destination image.
|
||||
* @param aDstImage - Screenshot destination image
|
||||
*/
|
||||
void GetScreenshot( wxImage& aDstImage );
|
||||
|
||||
/**
|
||||
* Select a specific 3D view or operation.
|
||||
* Helper function to call view commands.
|
||||
*
|
||||
* @param aRequestedView the view to move to.
|
||||
* @return true if the view request was handled, false if no command found for this view.
|
||||
* @param aKeycode ascii key commands.
|
||||
* @return true if the key code was handled, false if no command found for this code.
|
||||
*/
|
||||
bool SetView3D( VIEW3D_TYPE aRequestedView );
|
||||
bool SetView3D( int aKeycode );
|
||||
|
||||
/**
|
||||
* Enable or disable camera animation when switching to a pre-defined view.
|
||||
@@ -210,6 +208,12 @@ public:
|
||||
m_3dmousePivotPos = aPos;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Called by a wxPaintEvent event
|
||||
*/
|
||||
void OnPaint( wxPaintEvent& aEvent );
|
||||
|
||||
/**
|
||||
* The actual function to repaint the canvas.
|
||||
*
|
||||
@@ -218,32 +222,26 @@ public:
|
||||
*/
|
||||
void DoRePaint();
|
||||
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
|
||||
private:
|
||||
// The wxPaintEvent event. mainly calls DoRePaint()
|
||||
void OnPaint( wxPaintEvent& aEvent );
|
||||
|
||||
void OnEraseBackground( wxEraseEvent& event );
|
||||
|
||||
void OnRefreshRequest( wxEvent& aEvent );
|
||||
|
||||
void OnMouseWheel( wxMouseEvent& event );
|
||||
|
||||
void OnMagnify( wxMouseEvent& event );
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
void OnMagnify( wxMouseEvent& event );
|
||||
#endif
|
||||
|
||||
void OnMouseMove( wxMouseEvent& event );
|
||||
void OnLeftDown( wxMouseEvent& event );
|
||||
void OnLeftUp( wxMouseEvent& event );
|
||||
void OnMiddleUp( wxMouseEvent& event );
|
||||
void OnMiddleDown( wxMouseEvent& event );
|
||||
void OnTimerTimeout_Editing( wxTimerEvent& event );
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
void OnResize( wxSizeEvent& event );
|
||||
void OnTimerTimeout_Redraw( wxTimerEvent& event );
|
||||
|
||||
void OnZoomGesture( wxZoomGestureEvent& event );
|
||||
void OnPanGesture( wxPanGestureEvent& event );
|
||||
void OnRotateGesture( wxRotateGestureEvent& event );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
/**
|
||||
@@ -312,13 +310,13 @@ private:
|
||||
|
||||
bool m_render_pivot; // Render the pivot while camera moving
|
||||
float m_camera_moving_speed; // 1.0f will be 1:1
|
||||
int64_t m_strtime_camera_movement; // Ticktime of camera movement start
|
||||
unsigned m_strtime_camera_movement; // Ticktime of camera movement start
|
||||
bool m_animation_enabled; // Camera animation enabled
|
||||
int m_moving_speed_multiplier; // Camera animation speed multiplier option
|
||||
|
||||
BOARD_ADAPTER& m_boardAdapter; // Pre-computed 3D info and settings
|
||||
RENDER_3D_BASE* m_3d_render;
|
||||
RENDER_3D_RAYTRACE_GL* m_3d_render_raytracing;
|
||||
RENDER_3D_RAYTRACE* m_3d_render_raytracing;
|
||||
RENDER_3D_OPENGL* m_3d_render_opengl;
|
||||
|
||||
bool m_opengl_supports_raytracing;
|
||||
@@ -331,10 +329,6 @@ private:
|
||||
bool m_render3dmousePivot = false; // Render the 3dmouse pivot
|
||||
SFVEC3F m_3dmousePivotPos; // The position of the 3dmouse pivot
|
||||
|
||||
/// Used to track gesture events.
|
||||
double m_gestureLastZoomFactor = 1.0;
|
||||
double m_gestureLastAngle = 0.0;
|
||||
|
||||
/**
|
||||
* Trace mask used to enable or disable the trace output of this class.
|
||||
* The debug output can be turned on by setting the WXTRACE environment variable to
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -74,28 +74,4 @@ enum class MATERIAL_MODE
|
||||
CAD_MODE = 2 ///< Use a gray shading based on diffuse material
|
||||
};
|
||||
|
||||
enum class VIEW3D_TYPE
|
||||
{
|
||||
// Specific directions
|
||||
VIEW3D_TOP,
|
||||
VIEW3D_BOTTOM,
|
||||
VIEW3D_LEFT,
|
||||
VIEW3D_RIGHT,
|
||||
VIEW3D_FRONT,
|
||||
VIEW3D_BACK,
|
||||
VIEW3D_FLIP,
|
||||
|
||||
// Movement commands
|
||||
VIEW3D_PAN_UP,
|
||||
VIEW3D_PAN_DOWN,
|
||||
VIEW3D_PAN_LEFT,
|
||||
VIEW3D_PAN_RIGHT,
|
||||
VIEW3D_ZOOM_IN,
|
||||
VIEW3D_ZOOM_OUT,
|
||||
VIEW3D_PIVOT_CENTER,
|
||||
|
||||
// Specific levels
|
||||
VIEW3D_FIT_SCREEN
|
||||
};
|
||||
|
||||
#endif // _3D_ENUMS_H_
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -35,17 +35,15 @@
|
||||
#include "../3d_cache/3d_cache.h"
|
||||
#include <wx/dcclient.h>
|
||||
#include <base_units.h>
|
||||
#include <build_version.h>
|
||||
#include <gal/opengl/gl_context_mgr.h>
|
||||
#include <gl_context_mgr.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <pgm_base.h>
|
||||
#include <dpi_scaling_common.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <gal/dpi_scaling.h>
|
||||
#include <macros.h>
|
||||
|
||||
/**
|
||||
* Scale conversion from 3d model units to pcb units
|
||||
*/
|
||||
* Scale conversion from 3d model units to pcb units
|
||||
*/
|
||||
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
|
||||
|
||||
/**
|
||||
@@ -86,10 +84,9 @@ END_EVENT_TABLE()
|
||||
#define RANGE_SCALE_3D 8.0f
|
||||
|
||||
|
||||
EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const wxGLAttributes& aGLAttribs,
|
||||
EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList,
|
||||
S3D_CACHE* aCacheManager ) :
|
||||
HIDPI_GL_CANVAS( EDA_DRAW_PANEL_GAL::GetVcSettings(), aParent, aGLAttribs, wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize,
|
||||
wxFULL_REPAINT_ON_RESIZE ),
|
||||
m_trackBallCamera( RANGE_SCALE_3D * 4.0f ),
|
||||
m_cacheManager( aCacheManager )
|
||||
@@ -103,23 +100,27 @@ EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const wxGLAttribute
|
||||
m_BiuTo3dUnits = 1.0;
|
||||
|
||||
m_glRC = nullptr;
|
||||
|
||||
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
||||
|
||||
const DPI_SCALING dpi{ settings, this };
|
||||
SetScaleFactor( dpi.GetScaleFactor() );
|
||||
}
|
||||
|
||||
|
||||
EDA_3D_MODEL_VIEWER::~EDA_3D_MODEL_VIEWER()
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::~EDA_3D_MODEL_VIEWER" ) );
|
||||
GL_CONTEXT_MANAGER* gl_mgr = Pgm().GetGLContextManager();
|
||||
|
||||
if( m_glRC )
|
||||
{
|
||||
gl_mgr->LockCtx( m_glRC, this );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
delete m_ogl_3dmodel;
|
||||
m_ogl_3dmodel = nullptr;
|
||||
|
||||
gl_mgr->UnlockCtx( m_glRC );
|
||||
gl_mgr->DestroyCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glRC );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ void EDA_3D_MODEL_VIEWER::Set3DModel( const wxString& aModelPathName)
|
||||
|
||||
if( m_cacheManager )
|
||||
{
|
||||
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName, wxEmptyString, nullptr );
|
||||
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName, wxEmptyString );
|
||||
|
||||
if( model )
|
||||
Set3DModel( (const S3DMODEL &)*model );
|
||||
@@ -194,12 +195,9 @@ void EDA_3D_MODEL_VIEWER::ogl_initialize()
|
||||
else
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::ogl_initialize Using GLEW version %s" ),
|
||||
From_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
|
||||
FROM_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
|
||||
}
|
||||
|
||||
SetOpenGLInfo( (const char*) glGetString( GL_VENDOR ), (const char*) glGetString( GL_RENDERER ),
|
||||
(const char*) glGetString( GL_VERSION ) );
|
||||
|
||||
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
|
||||
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
|
||||
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
|
||||
@@ -257,7 +255,7 @@ void EDA_3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
|
||||
// context context current, i.e. it will be used by all subsequent OpenGL calls.
|
||||
// This function may only be called when the window is shown on screen"
|
||||
if( m_glRC == nullptr )
|
||||
m_glRC = Pgm().GetGLContextManager()->CreateCtx( this );
|
||||
m_glRC = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
|
||||
|
||||
// CreateCtx could and does fail per sentry crash events, lets be graceful
|
||||
if( m_glRC == nullptr )
|
||||
@@ -266,7 +264,7 @@ void EDA_3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
|
||||
return;
|
||||
}
|
||||
|
||||
Pgm().GetGLContextManager()->LockCtx( m_glRC, this );
|
||||
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
|
||||
|
||||
// Set the OpenGL viewport according to the client size of this canvas.
|
||||
// This is done here rather than in a wxSizeEvent handler because our
|
||||
@@ -302,7 +300,7 @@ void EDA_3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
|
||||
|
||||
// clear color and depth buffers
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
glClearDepth( 1.0f );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
@@ -384,7 +382,7 @@ void EDA_3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
|
||||
// commands is displayed on the window."
|
||||
SwapBuffers();
|
||||
|
||||
Pgm().GetGLContextManager()->UnlockCtx( m_glRC );
|
||||
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
|
||||
}
|
||||
|
||||
|
||||
@@ -402,16 +400,16 @@ void EDA_3D_MODEL_VIEWER::OnMouseWheel( wxMouseEvent& event )
|
||||
if( event.ShiftDown() )
|
||||
{
|
||||
//if( event.GetWheelRotation() < 0 )
|
||||
//SetView3D( VIEW_3D_TYPE::VIEW3D_PAN_UP ); // move up
|
||||
//SetView3D( WXK_UP ); // move up
|
||||
//else
|
||||
//SetView3D( VIEW_3D_TYPE::VIEW3D_PAN_DOWN ); // move down
|
||||
//SetView3D( WXK_DOWN ); // move down
|
||||
}
|
||||
else if( event.ControlDown() )
|
||||
{
|
||||
//if( event.GetWheelRotation() > 0 )
|
||||
//SetView3D( VIEW_3D_TYPE::VIEW3D_PAN_RIGHT ); // move right
|
||||
//SetView3D( WXK_RIGHT ); // move right
|
||||
//else
|
||||
//SetView3D( VIEW_3D_TYPE::VIEW3D_PAN_LEFT ); // move left
|
||||
//SetView3D( WXK_LEFT ); // move left
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file eda_3d_model_viewer.h
|
||||
* @file c3d_model_viewer.h
|
||||
* @brief Implements a model viewer canvas.
|
||||
*
|
||||
* The purpose of model viewer is to render 3d models that come in the original data from
|
||||
@@ -49,9 +49,9 @@ public:
|
||||
* Create a new 3D Canvas with a attribute list.
|
||||
*
|
||||
* @param aParent the parent creator of this canvas.
|
||||
* @param aGLAttribs openGL attributes created by #OGL_ATT_LIST::GetAttributesList.
|
||||
* @param aAttribList a list of openGL options created by #OGL_ATT_LIST::GetAttributesList.
|
||||
*/
|
||||
EDA_3D_MODEL_VIEWER( wxWindow* aParent, const wxGLAttributes& aGLAttribs,
|
||||
EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList = nullptr,
|
||||
S3D_CACHE* aCacheManager = nullptr );
|
||||
|
||||
~EDA_3D_MODEL_VIEWER();
|
||||
@@ -66,9 +66,7 @@ public:
|
||||
/**
|
||||
* Set this model to be displayed.
|
||||
*
|
||||
* N.B. This will not load a model from the internal cache. Only from on disk.
|
||||
*
|
||||
* @param aModelPathName 3D model path name. Must be a file on disk.
|
||||
* @param aModelPathName 3D model path name.
|
||||
*/
|
||||
void Set3DModel( const wxString& aModelPathName );
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
add_library(3d-viewer_navlib STATIC
|
||||
"nl_3d_viewer_plugin.cpp"
|
||||
"nl_3d_viewer_plugin_impl.cpp"
|
||||
"nl_footprint_properties_plugin.cpp"
|
||||
"nl_footprint_properties_plugin_impl.cpp"
|
||||
)
|
||||
|
||||
# 3d-viewer_navlib depends on make_lexer outputs in common
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -21,25 +21,23 @@
|
||||
#include "nl_3d_viewer_plugin.h"
|
||||
#include "nl_3d_viewer_plugin_impl.h"
|
||||
#include <advanced_config.h>
|
||||
#include <kiplatform/drivers.h>
|
||||
|
||||
|
||||
NL_3D_VIEWER_PLUGIN::NL_3D_VIEWER_PLUGIN( EDA_3D_CANVAS* aViewport )
|
||||
{
|
||||
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver
|
||||
&& KIPLATFORM::DRIVERS::Valid3DConnexionDriverVersion() )
|
||||
{
|
||||
m_impl = std::make_unique<NL_3D_VIEWER_PLUGIN_IMPL>( aViewport, "KiCAD 3D" );
|
||||
m_impl->Connect();
|
||||
}
|
||||
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
|
||||
m_impl = new NL_3D_VIEWER_PLUGIN_IMPL( aViewport );
|
||||
}
|
||||
|
||||
|
||||
NL_3D_VIEWER_PLUGIN::~NL_3D_VIEWER_PLUGIN() = default;
|
||||
NL_3D_VIEWER_PLUGIN::~NL_3D_VIEWER_PLUGIN()
|
||||
{
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
|
||||
void NL_3D_VIEWER_PLUGIN::SetFocus( bool focus )
|
||||
{
|
||||
if( m_impl )
|
||||
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
|
||||
m_impl->SetFocus( focus );
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -26,8 +26,6 @@
|
||||
#ifndef NL_3D_VIEWER_PLUGIN_H_
|
||||
#define NL_3D_VIEWER_PLUGIN_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
// Forward declarations.
|
||||
class EDA_3D_CANVAS;
|
||||
class NL_3D_VIEWER_PLUGIN_IMPL;
|
||||
@@ -56,7 +54,7 @@ public:
|
||||
void SetFocus( bool aFocus = true );
|
||||
|
||||
private:
|
||||
std::unique_ptr<NL_3D_VIEWER_PLUGIN_IMPL> m_impl;
|
||||
NL_3D_VIEWER_PLUGIN_IMPL* m_impl;
|
||||
};
|
||||
|
||||
#endif // NL_3D_VIEWER_PLUGIN_H_
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2024 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021 3Dconnexion
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -24,10 +24,9 @@
|
||||
#include <3d-viewer/3d_rendering/track_ball.h>
|
||||
#include <3d-viewer/3d_canvas/eda_3d_canvas.h>
|
||||
|
||||
// KiCad includes
|
||||
// KiCAD includes
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/tools_holder.h>
|
||||
|
||||
// stdlib
|
||||
#include <map>
|
||||
@@ -73,16 +72,17 @@ bool equals( glm::mat<L, C, T, Q> const& aFirst, glm::mat<L, C, T, Q> const& aSe
|
||||
}
|
||||
|
||||
|
||||
NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas,
|
||||
const std::string& aProfileHint ) :
|
||||
NAV_3D( false, false ),
|
||||
m_canvas( aCanvas ),
|
||||
m_capIsMoving( false ),
|
||||
m_newWidth( 0.0 )
|
||||
NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas ) :
|
||||
NAV_3D( false, false ), m_canvas( aCanvas ), m_capIsMoving( false )
|
||||
{
|
||||
m_camera = dynamic_cast<TRACK_BALL*>( m_canvas->GetCamera() );
|
||||
|
||||
PutProfileHint( aProfileHint );
|
||||
PutProfileHint( "KiCAD 3D" );
|
||||
|
||||
EnableNavigation( true );
|
||||
PutFrameTimingSource( TimingSource::SpaceMouse );
|
||||
|
||||
exportCommandsAndImages();
|
||||
}
|
||||
|
||||
|
||||
@@ -98,21 +98,18 @@ void NL_3D_VIEWER_PLUGIN_IMPL::SetFocus( bool aFocus )
|
||||
NAV_3D::Write( navlib::focus_k, aFocus );
|
||||
}
|
||||
|
||||
// temporary store for the categories
|
||||
typedef std::map<std::string, TDx::CCommandTreeNode*> CATEGORY_STORE;
|
||||
|
||||
EDA_3D_CANVAS* NL_3D_VIEWER_PLUGIN_IMPL::GetCanvas() const
|
||||
{
|
||||
return m_canvas;
|
||||
}
|
||||
|
||||
|
||||
void NL_3D_VIEWER_PLUGIN_IMPL::Connect()
|
||||
{
|
||||
EnableNavigation(true);
|
||||
PutFrameTimingSource(TimingSource::SpaceMouse);
|
||||
exportCommandsAndImages();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a category to the store.
|
||||
*
|
||||
* The function adds category paths of the format "A.B" where B is a sub-category of A.
|
||||
*
|
||||
* @param aCategoryPath is the std::string representation of the category.
|
||||
* @param aCategoryStore is the CATEGORY_STORE instance to add to.
|
||||
* @return a CATEGORY_STORE::iterator where the category was added.
|
||||
*/
|
||||
CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore )
|
||||
{
|
||||
using TDx::SpaceMouse::CCategory;
|
||||
@@ -176,7 +173,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
for( it = actions.begin(); it != actions.end(); ++it )
|
||||
{
|
||||
const TOOL_ACTION* action = *it;
|
||||
std::string label = action->GetMenuLabel().ToStdString();
|
||||
std::string label = action->GetLabel().ToStdString();
|
||||
|
||||
if( label.empty() )
|
||||
{
|
||||
@@ -185,7 +182,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
|
||||
std::string name = action->GetName();
|
||||
|
||||
// Do no export commands for the Pcbnew app.
|
||||
// Do no export commands for the pcbnew app.
|
||||
if( name.rfind( "pcbnew.", 0 ) == 0 )
|
||||
{
|
||||
continue;
|
||||
@@ -568,11 +565,10 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
|
||||
|
||||
// Only allow command execution if the window is enabled. i.e. there is not a modal dialog
|
||||
// currently active.
|
||||
TOOLS_HOLDER* tools_holder = nullptr;
|
||||
|
||||
if( parent->IsEnabled() && ( tools_holder = dynamic_cast<TOOLS_HOLDER*>( parent ) ) )
|
||||
if( parent->IsEnabled() )
|
||||
{
|
||||
TOOL_MANAGER* tool_manager = tools_holder->GetToolManager();
|
||||
TOOL_MANAGER* tool_manager = static_cast<PCB_BASE_FRAME*>( parent )->GetToolManager();
|
||||
|
||||
if( tool_manager == nullptr )
|
||||
{
|
||||
@@ -592,7 +588,7 @@ long NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
|
||||
|
||||
if( runAction )
|
||||
{
|
||||
tool_manager->RunAction( *context );
|
||||
tool_manager->RunAction( *context, true );
|
||||
m_canvas->Request_refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2024 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021 3Dconnexion
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -29,7 +29,7 @@
|
||||
// TDxWare SDK.
|
||||
#include <SpaceMouse/CNavigation3D.hpp>
|
||||
|
||||
// KiCad
|
||||
// KiCAD
|
||||
#include <include/plugins/3dapi/xv3d_types.h>
|
||||
|
||||
// wx
|
||||
@@ -42,20 +42,6 @@
|
||||
class EDA_3D_CANVAS;
|
||||
class TRACK_BALL;
|
||||
|
||||
// temporary store for the categories
|
||||
typedef std::map<std::string, TDx::CCommandTreeNode*> CATEGORY_STORE;
|
||||
|
||||
/**
|
||||
* Add a category to the store.
|
||||
*
|
||||
* The function adds category paths of the format "A.B" where B is a sub-category of A.
|
||||
*
|
||||
* @param aCategoryPath is the std::string representation of the category.
|
||||
* @param aCategoryStore is the CATEGORY_STORE instance to add to.
|
||||
* @return a CATEGORY_STORE::iterator where the category was added.
|
||||
*/
|
||||
CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore );
|
||||
|
||||
// Convenience typedef.
|
||||
typedef TDx::SpaceMouse::Navigation3D::CNavigation3D NAV_3D;
|
||||
|
||||
@@ -70,9 +56,8 @@ public:
|
||||
* Initializes a new instance of the NL_3DVIEWER_PLUGIN.
|
||||
*
|
||||
* @param aCanvas is the viewport to be navigated.
|
||||
* @param aProfileHint tells the 3DConnexion UI which profile to use.
|
||||
*/
|
||||
NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas, const std::string& aProfileHint );
|
||||
NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas );
|
||||
|
||||
virtual ~NL_3D_VIEWER_PLUGIN_IMPL();
|
||||
|
||||
@@ -84,21 +69,11 @@ public:
|
||||
*/
|
||||
void SetFocus( bool aFocus = true );
|
||||
|
||||
/**
|
||||
* Get the m_canvas pointer.
|
||||
*/
|
||||
EDA_3D_CANVAS* GetCanvas() const;
|
||||
|
||||
/**
|
||||
* Connect plugin implementation to the driver.
|
||||
*/
|
||||
void Connect();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Export the invocable actions and images to the 3Dconnexion UI.
|
||||
*/
|
||||
virtual void exportCommandsAndImages();
|
||||
void exportCommandsAndImages();
|
||||
|
||||
long GetCameraMatrix( navlib::matrix_t& aMatrix ) const override;
|
||||
long GetPointerPosition( navlib::point_t& aPosition ) const override;
|
||||
@@ -136,7 +111,6 @@ private:
|
||||
long GetCoordinateSystem( navlib::matrix_t& aMatrix ) const override;
|
||||
long GetIsViewRotatable( navlib::bool_t& isRotatable ) const override;
|
||||
|
||||
|
||||
private:
|
||||
EDA_3D_CANVAS* m_canvas;
|
||||
TRACK_BALL* m_camera;
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2024 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program 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
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "nl_footprint_properties_plugin.h"
|
||||
#include "nl_footprint_properties_plugin_impl.h"
|
||||
#include <advanced_config.h>
|
||||
#include <kiplatform/drivers.h>
|
||||
|
||||
|
||||
NL_FOOTPRINT_PROPERTIES_PLUGIN::NL_FOOTPRINT_PROPERTIES_PLUGIN( EDA_3D_CANVAS* aViewport )
|
||||
{
|
||||
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver
|
||||
&& KIPLATFORM::DRIVERS::Valid3DConnexionDriverVersion() )
|
||||
{
|
||||
m_impl = std::make_unique<NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL>( aViewport );
|
||||
m_impl->Connect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NL_FOOTPRINT_PROPERTIES_PLUGIN::~NL_FOOTPRINT_PROPERTIES_PLUGIN() = default;
|
||||
|
||||
|
||||
void NL_FOOTPRINT_PROPERTIES_PLUGIN::SetFocus( bool focus )
|
||||
{
|
||||
if( m_impl )
|
||||
m_impl->SetFocus( focus );
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2024 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program 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
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file nl_footprint_properties_plugin.h
|
||||
* @brief declaration of the nl_footprint_properties_plugin class
|
||||
*/
|
||||
|
||||
#ifndef NL_FOOTPRINT_PROPERTIES_PLUGIN_H_
|
||||
#define NL_FOOTPRINT_PROPERTIES_PLUGIN_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
// Forward declarations.
|
||||
class EDA_3D_CANVAS;
|
||||
class NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL;
|
||||
|
||||
/**
|
||||
* The class that implements the public interface to the SpaceMouse plug-in.
|
||||
*/
|
||||
class NL_FOOTPRINT_PROPERTIES_PLUGIN
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Initializes a new instance of the NL_FOOTPRINT_PROPERTIES_PLUGIN.
|
||||
*
|
||||
* @param aViewport is the viewport to be navigated.
|
||||
*/
|
||||
NL_FOOTPRINT_PROPERTIES_PLUGIN( EDA_3D_CANVAS* aViewport );
|
||||
|
||||
virtual ~NL_FOOTPRINT_PROPERTIES_PLUGIN();
|
||||
|
||||
/**
|
||||
* Set the connection to the 3Dconnexion driver to the focus state so that
|
||||
* 3DMouse data is routed here.
|
||||
*
|
||||
* @param aFocus is true to set the connection active.
|
||||
*/
|
||||
void SetFocus( bool aFocus = true );
|
||||
|
||||
private:
|
||||
std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL> m_impl;
|
||||
};
|
||||
|
||||
#endif // NL_FOOTPRINT_PROPERTIES_PLUGIN_H_
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2024 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program 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
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "nl_footprint_properties_plugin_impl.h"
|
||||
#include <3d-viewer/3d_canvas/eda_3d_canvas.h>
|
||||
|
||||
// KiCAD includes
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/tools_holder.h>
|
||||
|
||||
#include <wx/mstream.h>
|
||||
|
||||
#define BOUNDING_BOX_SCALE_FACTOR 1.3f
|
||||
|
||||
/**
|
||||
* Flag to enable the NL_FOOTPRINT_PROPERTIES_PLUGIN debug tracing.
|
||||
*
|
||||
* Use "KI_TRACE_NL_FOOTPRINT_PROPERTIES_PLUGIN" to enable.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
const wxChar* NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::m_logTrace =
|
||||
wxT( "KI_TRACE_NL_FOOTPRINT_PROPERTIES_PLUGIN" );
|
||||
|
||||
|
||||
NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL(EDA_3D_CANVAS* aCanvas) :
|
||||
NL_3D_VIEWER_PLUGIN_IMPL(aCanvas, "KiCAD Footprint Properties")
|
||||
{}
|
||||
|
||||
|
||||
long NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const
|
||||
{
|
||||
SFVEC3F min = NL_3D_VIEWER_PLUGIN_IMPL::GetCanvas()->GetBoardAdapter().GetBBox().Min();
|
||||
SFVEC3F max = NL_3D_VIEWER_PLUGIN_IMPL::GetCanvas()->GetBoardAdapter().GetBBox().Max();
|
||||
|
||||
SFVEC3F diff = ( BOUNDING_BOX_SCALE_FACTOR - 1.f ) / 2.f * ( max - min );
|
||||
|
||||
min -= diff;
|
||||
max += diff;
|
||||
|
||||
extents = { min.x, min.y, min.z, max.x, max.y, max.z };
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages()
|
||||
{
|
||||
std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList();
|
||||
|
||||
if( actions.size() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using TDx::SpaceMouse::CCommand;
|
||||
using TDx::SpaceMouse::CCommandSet;
|
||||
|
||||
// The root action set node
|
||||
CCommandSet commandSet( "EDA_3D_CANVAS", "3D Viewer" );
|
||||
|
||||
// Activate the command set
|
||||
NAV_3D::PutActiveCommands( commandSet.GetId() );
|
||||
|
||||
// temporary store for the categories
|
||||
CATEGORY_STORE categoryStore;
|
||||
|
||||
std::vector<TDx::CImage> vImages;
|
||||
|
||||
// add the action set to the category_store
|
||||
categoryStore.insert( categoryStore.end(), CATEGORY_STORE::value_type( ".", &commandSet ) );
|
||||
|
||||
std::list<TOOL_ACTION*>::const_iterator it;
|
||||
|
||||
for( it = actions.begin(); it != actions.end(); ++it )
|
||||
{
|
||||
const TOOL_ACTION* action = *it;
|
||||
std::string label = action->GetMenuLabel().ToStdString();
|
||||
|
||||
if( label.empty() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string name = action->GetName();
|
||||
|
||||
// Do no export commands for the pcbnew app.
|
||||
if( name.rfind( "pcbnew.", 0 ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Exclude commands which can't be used in the footprint properties.
|
||||
if( name.rfind( "3DViewer.Control.pivotCenter", 0 ) == 0
|
||||
|| name.rfind( "3DViewer.Control.material", 0 ) == 0
|
||||
|| name.rfind( "3DViewer.Control.attribute", 0 ) == 0
|
||||
|| name.rfind( "3DViewer.Control.show", 0 ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string strCategory = action->GetToolName();
|
||||
CATEGORY_STORE::iterator iter = categoryStore.find( strCategory );
|
||||
|
||||
if( iter == categoryStore.end() )
|
||||
{
|
||||
iter = add_category( std::move( strCategory ), categoryStore );
|
||||
}
|
||||
|
||||
std::string description = action->GetDescription().ToStdString();
|
||||
|
||||
// Arbitrary 8-bit data stream
|
||||
wxMemoryOutputStream imageStream;
|
||||
|
||||
if( action->GetIcon() != BITMAPS::INVALID_BITMAP )
|
||||
{
|
||||
wxImage image = KiBitmap( action->GetIcon() ).ConvertToImage();
|
||||
image.SaveFile( imageStream, wxBitmapType::wxBITMAP_TYPE_PNG );
|
||||
image.Destroy();
|
||||
|
||||
if( imageStream.GetSize() )
|
||||
{
|
||||
wxStreamBuffer* streamBuffer = imageStream.GetOutputStreamBuffer();
|
||||
TDx::CImage tdxImage = TDx::CImage::FromData( "", 0, name.c_str() );
|
||||
tdxImage.AssignImage( std::string( reinterpret_cast<const char*>(
|
||||
streamBuffer->GetBufferStart() ),
|
||||
streamBuffer->GetBufferSize() ),
|
||||
0 );
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "Adding image for : %s" ), name );
|
||||
vImages.push_back( std::move( tdxImage ) );
|
||||
}
|
||||
}
|
||||
|
||||
wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
|
||||
name, description, iter->first );
|
||||
|
||||
iter->second->push_back(
|
||||
CCommand( std::move( name ), std::move( label ), std::move( description ) ) );
|
||||
}
|
||||
|
||||
NAV_3D::AddCommandSet( commandSet );
|
||||
NAV_3D::AddImages( vImages );
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2024 3Dconnexion
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program 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
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file nl_footprint_properties_plugin_impl.h
|
||||
* @brief declaration of the nl_footprint_properties_plugin_impl class
|
||||
*/
|
||||
|
||||
#ifndef NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL_H_
|
||||
#define NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL_H_
|
||||
|
||||
#include "nl_3d_viewer_plugin_impl.h"
|
||||
// TDxWare SDK.
|
||||
#include <SpaceMouse/CNavigation3D.hpp>
|
||||
|
||||
/**
|
||||
* The class that adjusts NL_3D_VIEWER_PLUGIN_IMPL implementation for 3D Model preview in
|
||||
* footprint properties dialog.
|
||||
*/
|
||||
class NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL : public NL_3D_VIEWER_PLUGIN_IMPL
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Initialize a new instance of the NL_FOOTPRINT_PROPERTIES_PLUGIN.
|
||||
*
|
||||
* @param aCanvas is the viewport to be navigated.
|
||||
*/
|
||||
NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas );
|
||||
|
||||
private:
|
||||
/**
|
||||
* Get Footprint 3D Model extents.
|
||||
*
|
||||
* @param extents is the box around the 3D model.
|
||||
*/
|
||||
long GetModelExtents( navlib::box_t& extents ) const override;
|
||||
|
||||
/**
|
||||
* Export the invocable actions and images to the 3Dconnexion UI.
|
||||
*/
|
||||
void exportCommandsAndImages() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Trace mask used to enable or disable the trace output of this class.
|
||||
* The debug output can be turned on by setting the WXTRACE environment variable to
|
||||
* "KI_TRACE_NL_FOOTPRINT_PROPERTIES_PLUGIN". See the wxWidgets documentation on
|
||||
* wxLogTrace for more information.
|
||||
*/
|
||||
static const wxChar* m_logTrace;
|
||||
};
|
||||
#endif // NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL_H_
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -46,19 +46,6 @@ static void dbg_save_rgb_buffer( const wxString& aFileName, unsigned char *aRGBp
|
||||
}
|
||||
|
||||
|
||||
static void dbg_save_rgb_a_buffer( const wxString& aFileName, unsigned char* aRGBpixelBuffer,
|
||||
unsigned char* aAlphaBuffer, unsigned int aXSize,
|
||||
unsigned int aYSize )
|
||||
{
|
||||
wxImage image( aXSize, aYSize );
|
||||
image.SetData( aRGBpixelBuffer );
|
||||
image.SetAlpha( aAlphaBuffer );
|
||||
image = image.Mirror( false );
|
||||
image.SaveFile( aFileName + wxT( ".png" ), wxBITMAP_TYPE_PNG );
|
||||
image.Destroy();
|
||||
}
|
||||
|
||||
|
||||
void DBG_SaveBuffer( const wxString& aFileName, const unsigned char *aInBuffer,
|
||||
unsigned int aXSize, unsigned int aYSize )
|
||||
{
|
||||
@@ -123,31 +110,6 @@ void DBG_SaveBuffer( const wxString& aFileName, const SFVEC3F *aInBuffer,
|
||||
}
|
||||
|
||||
|
||||
void DBG_SaveBuffer( const wxString& aFileName, const SFVEC4F *aInBuffer,
|
||||
unsigned int aXSize, unsigned int aYSize )
|
||||
{
|
||||
const unsigned int wxh = aXSize * aYSize;
|
||||
|
||||
unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 4 );
|
||||
unsigned char *alphabuffer = (unsigned char*) malloc( wxh );
|
||||
|
||||
for( unsigned int i = 0; i < wxh; ++i )
|
||||
{
|
||||
const SFVEC4F &v = aInBuffer[i];
|
||||
const unsigned int ix3 = i * 3;
|
||||
|
||||
// Set RGB value with all same values intensities
|
||||
pixelbuffer[ix3 + 0] = (unsigned char) glm::min( (int) ( v.r * 255.0f ), 255 );
|
||||
pixelbuffer[ix3 + 1] = (unsigned char) glm::min( (int) ( v.g * 255.0f ), 255 );
|
||||
pixelbuffer[ix3 + 2] = (unsigned char) glm::min( (int) ( v.b * 255.0f ), 255 );
|
||||
|
||||
alphabuffer[i] = (unsigned char) glm::min( (int) ( v.a * 255.0f ), 255 );
|
||||
}
|
||||
|
||||
dbg_save_rgb_a_buffer( aFileName, pixelbuffer, alphabuffer, aXSize, aYSize );
|
||||
}
|
||||
|
||||
|
||||
void DBG_SaveNormalsBuffer( const wxString& aFileName, const SFVEC3F *aInNormalsBuffer,
|
||||
unsigned int aXSize, unsigned int aYSize )
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -42,9 +42,6 @@ void DBG_SaveBuffer( const wxString& aFileName, const float *aInBuffer,
|
||||
void DBG_SaveBuffer( const wxString& aFileName, const SFVEC3F *aInBuffer,
|
||||
unsigned int aXSize, unsigned int aYSize );
|
||||
|
||||
void DBG_SaveBuffer( const wxString& aFileName, const SFVEC4F *aInBuffer,
|
||||
unsigned int aXSize, unsigned int aYSize );
|
||||
|
||||
void DBG_SaveNormalsBuffer( const wxString& aFileName, const SFVEC3F *aInNormalsBuffer,
|
||||
unsigned int aXSize, unsigned int aYSize );
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -26,10 +26,9 @@
|
||||
* @file camera.cpp
|
||||
*/
|
||||
|
||||
#include <gal/3d/camera.h>
|
||||
#include "camera.h"
|
||||
#include <wx/log.h>
|
||||
#include <algorithm>
|
||||
#include <3d_enums.h>
|
||||
|
||||
// A helper function to normalize aAngle between -2PI and +2PI
|
||||
inline void normalise2PI( float& aAngle )
|
||||
@@ -51,22 +50,15 @@ const float CAMERA::DEFAULT_MIN_ZOOM = 0.020f;
|
||||
const float CAMERA::DEFAULT_MAX_ZOOM = 2.0f;
|
||||
|
||||
|
||||
CAMERA::CAMERA( float aInitialDistance ) :
|
||||
CAMERA( SFVEC3F( 0.0f, 0.0f, -aInitialDistance ), SFVEC3F( 0.0f ),
|
||||
PROJECTION_TYPE::PERSPECTIVE )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CAMERA::CAMERA( SFVEC3F aInitPos, SFVEC3F aLookat, PROJECTION_TYPE aProjectionType )
|
||||
CAMERA::CAMERA( float aInitialDistance )
|
||||
{
|
||||
wxLogTrace( m_logTrace, wxT( "CAMERA::CAMERA" ) );
|
||||
|
||||
m_camera_pos_init = aInitPos;
|
||||
m_board_lookat_pos_init = aLookat;
|
||||
m_windowSize = SFVEC2I( 0, 0 );
|
||||
m_projectionType = aProjectionType;
|
||||
m_interpolation_mode = CAMERA_INTERPOLATION::BEZIER;
|
||||
m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -aInitialDistance );
|
||||
m_board_lookat_pos_init = SFVEC3F( 0.0f );
|
||||
m_windowSize = SFVEC2I( 0, 0 );
|
||||
m_projectionType = PROJECTION_TYPE::PERSPECTIVE;
|
||||
m_interpolation_mode = CAMERA_INTERPOLATION::BEZIER;
|
||||
|
||||
m_minZoom = DEFAULT_MIN_ZOOM;
|
||||
m_maxZoom = DEFAULT_MAX_ZOOM;
|
||||
@@ -107,57 +99,6 @@ void CAMERA::Reset()
|
||||
}
|
||||
|
||||
|
||||
bool CAMERA::ViewCommand_T1( VIEW3D_TYPE aRequestedView )
|
||||
{
|
||||
switch( aRequestedView )
|
||||
{
|
||||
case VIEW3D_TYPE::VIEW3D_RIGHT:
|
||||
SetT0_and_T1_current_T();
|
||||
Reset_T1();
|
||||
RotateZ_T1( glm::radians( -90.0f ) );
|
||||
RotateX_T1( glm::radians( -90.0f ) );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_LEFT:
|
||||
Reset_T1();
|
||||
RotateZ_T1( glm::radians( 90.0f ) );
|
||||
RotateX_T1( glm::radians( -90.0f ) );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_FRONT:
|
||||
Reset_T1();
|
||||
RotateX_T1( glm::radians( -90.0f ) );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_BACK:
|
||||
Reset_T1();
|
||||
RotateX_T1( glm::radians( -90.0f ) );
|
||||
|
||||
// The rotation angle should be 180.
|
||||
// We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when
|
||||
// using 180 deg if the previous rotated position was already 180 deg
|
||||
RotateZ_T1( glm::radians( 179.999f ) );
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_TOP:
|
||||
Reset_T1();
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_BOTTOM:
|
||||
Reset_T1();
|
||||
RotateY_T1( glm::radians( 179.999f ) ); // Rotation = 180 - epsilon
|
||||
return true;
|
||||
|
||||
case VIEW3D_TYPE::VIEW3D_FLIP:
|
||||
RotateY_T1( glm::radians( 179.999f ) );
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CAMERA::Reset_T1()
|
||||
{
|
||||
m_camera_pos_t1 = m_camera_pos_init;
|
||||
@@ -287,8 +228,7 @@ void CAMERA::rebuildProjection()
|
||||
|
||||
case PROJECTION_TYPE::ORTHO:
|
||||
|
||||
// Keep the viewed plane at (m_camera_pos_init * m_zoom) the same dimensions in both
|
||||
// projections.
|
||||
// Keep the viewed plane at (m_camera_pos_init * m_zoom) the same dimensions in both projections.
|
||||
m_frustum.angle = 45.0f;
|
||||
m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
|
||||
|
||||
@@ -648,14 +588,6 @@ bool CAMERA::Zoom_T1( float aFactor )
|
||||
}
|
||||
|
||||
|
||||
void CAMERA::RotateScreen( float aAngleInRadians )
|
||||
{
|
||||
glm::mat4 matrix = GetRotationMatrix();
|
||||
SetRotationMatrix( glm::rotate( matrix, aAngleInRadians, GetDir() ) );
|
||||
updateRotationMatrix();
|
||||
}
|
||||
|
||||
|
||||
void CAMERA::RotateX( float aAngleInRadians )
|
||||
{
|
||||
m_rotate_aux.x += aAngleInRadians;
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -30,11 +30,9 @@
|
||||
#ifndef CAMERA_H
|
||||
#define CAMERA_H
|
||||
|
||||
#include <gal/gal.h>
|
||||
#include <plugins/3dapi/xv3d_types.h>
|
||||
#include "../3d_rendering/raytracing/ray.h"
|
||||
#include <wx/gdicmn.h> // for wxSize
|
||||
#include <vector>
|
||||
#include <3d_enums.h>
|
||||
|
||||
enum class PROJECTION_TYPE
|
||||
{
|
||||
@@ -60,29 +58,6 @@ struct CAMERA_FRUSTUM
|
||||
SFVEC3F fbr; ///< Far Bottom Right
|
||||
float nearD, farD, ratio, angle, tang;
|
||||
float nw, nh, fw, fh;
|
||||
|
||||
CAMERA_FRUSTUM() :
|
||||
nc( { 0.0, 0.0, 0.0 } ),
|
||||
fc( { 0.0, 0.0, 0.0 } ),
|
||||
ntl( { 0.0, 0.0, 0.0 } ),
|
||||
ntr( { 0.0, 0.0, 0.0 } ),
|
||||
nbl( { 0.0, 0.0, 0.0 } ),
|
||||
nbr( { 0.0, 0.0, 0.0 } ),
|
||||
ftl( { 0.0, 0.0, 0.0 } ),
|
||||
ftr( { 0.0, 0.0, 0.0 } ),
|
||||
fbl( { 0.0, 0.0, 0.0 } ),
|
||||
fbr( { 0.0, 0.0, 0.0 } ),
|
||||
nearD( 0.0 ),
|
||||
farD( 0.0 ),
|
||||
ratio( 1.0 ),
|
||||
angle( 0.0 ),
|
||||
tang( 0.0 ),
|
||||
nw( 0.0 ),
|
||||
nh( 0.0 ),
|
||||
fw( 0.0 ),
|
||||
fh( 0.0 )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -99,7 +74,7 @@ enum class CAMERA_INTERPOLATION
|
||||
*
|
||||
* It must be derived by other classes to implement a real camera object.
|
||||
*/
|
||||
class GAL_API CAMERA
|
||||
class CAMERA
|
||||
{
|
||||
public:
|
||||
static const float DEFAULT_MIN_ZOOM;
|
||||
@@ -111,7 +86,6 @@ public:
|
||||
* @param aInitialDistance Initial Z-distance to the board
|
||||
*/
|
||||
explicit CAMERA( float aInitialDistance );
|
||||
explicit CAMERA( SFVEC3F aInitPos, SFVEC3F aLookat, PROJECTION_TYPE aProjectionType );
|
||||
|
||||
virtual ~CAMERA()
|
||||
{
|
||||
@@ -234,13 +208,6 @@ public:
|
||||
zoomChanged();
|
||||
}
|
||||
|
||||
bool ViewCommand_T1( VIEW3D_TYPE aRequestedView );
|
||||
|
||||
/**
|
||||
* Rotates the camera in screen plane.
|
||||
*/
|
||||
void RotateScreen( float aAngleInRadians );
|
||||
|
||||
void RotateX( float aAngleInRadians );
|
||||
void RotateY( float aAngleInRadians );
|
||||
void RotateZ( float aAngleInRadians );
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file color_rgb.cpp
|
||||
*/
|
||||
|
||||
|
||||
#include "color_rgb.h"
|
||||
|
||||
|
||||
COLOR_RGB::COLOR_RGB( const SFVEC3F& aColor )
|
||||
{
|
||||
r = (unsigned int) glm::clamp( (int) ( aColor.r * 255 ), 0, 255 );
|
||||
g = (unsigned int) glm::clamp( (int) ( aColor.g * 255 ), 0, 255 );
|
||||
b = (unsigned int) glm::clamp( (int) ( aColor.b * 255 ), 0, 255 );
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2 )
|
||||
{
|
||||
const unsigned int r = aC1.r + aC2.r;
|
||||
const unsigned int g = aC1.g + aC2.g;
|
||||
const unsigned int b = aC1.b + aC2.b;
|
||||
|
||||
return COLOR_RGB( ( r >> 1 ), ( g >> 1 ), ( b >> 1 ) );
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3 )
|
||||
{
|
||||
const unsigned int r = aC1.r + aC2.r + aC3.r;
|
||||
const unsigned int g = aC1.g + aC2.g + aC3.g;
|
||||
const unsigned int b = aC1.b + aC2.b + aC3.b;
|
||||
|
||||
return COLOR_RGB( ( r / 3 ), ( g / 3 ), ( b / 3 ) );
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3,
|
||||
const COLOR_RGB& aC4 )
|
||||
{
|
||||
const unsigned int r = aC1.r + aC2.r + aC3.r + aC4.r;
|
||||
const unsigned int g = aC1.g + aC2.g + aC3.g + aC4.g;
|
||||
const unsigned int b = aC1.b + aC2.b + aC3.b + aC4.b;
|
||||
|
||||
return COLOR_RGB( ( r >> 2 ), ( g >> 2 ), ( b >> 2 ) );
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file color_rgb.h
|
||||
*/
|
||||
|
||||
#ifndef COLOR_RGB_H
|
||||
#define COLOR_RGB_H
|
||||
|
||||
#include <plugins/3dapi/xv3d_types.h>
|
||||
|
||||
union COLOR_RGB
|
||||
{
|
||||
unsigned char c[3];
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
};
|
||||
|
||||
COLOR_RGB( const SFVEC3F& aColor );
|
||||
COLOR_RGB() { r = 0; g = 0; b = 0; }
|
||||
COLOR_RGB( unsigned char aR, unsigned char aG, unsigned char aB )
|
||||
{
|
||||
r = aR;
|
||||
g = aG;
|
||||
b = aB;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2 );
|
||||
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3 );
|
||||
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3,
|
||||
const COLOR_RGB& aC4 );
|
||||
|
||||
#endif // COLOR_RGB_H
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file color_rgba.cpp
|
||||
*/
|
||||
|
||||
|
||||
#include "color_rgba.h"
|
||||
|
||||
|
||||
COLOR_RGBA::COLOR_RGBA( const SFVEC3F& aColor )
|
||||
{
|
||||
r = (unsigned int) glm::clamp( (int) ( aColor.r * 255 ), 0, 255 );
|
||||
g = (unsigned int) glm::clamp( (int) ( aColor.g * 255 ), 0, 255 );
|
||||
b = (unsigned int) glm::clamp( (int) ( aColor.b * 255 ), 0, 255 );
|
||||
a = 255;
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGBA::COLOR_RGBA( const SFVEC4F& aColor )
|
||||
{
|
||||
r = (unsigned int) glm::clamp( (int) ( aColor.r * 255 ), 0, 255 );
|
||||
g = (unsigned int) glm::clamp( (int) ( aColor.g * 255 ), 0, 255 );
|
||||
b = (unsigned int) glm::clamp( (int) ( aColor.b * 255 ), 0, 255 );
|
||||
a = (unsigned int) glm::clamp( (int) ( aColor.a * 255 ), 0, 255 );
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGBA::operator SFVEC4F() const
|
||||
{
|
||||
return SFVEC4F( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGBA BlendColor( const COLOR_RGBA& aC1, const COLOR_RGBA& aC2 )
|
||||
{
|
||||
const unsigned int r = aC1.r + aC2.r;
|
||||
const unsigned int g = aC1.g + aC2.g;
|
||||
const unsigned int b = aC1.b + aC2.b;
|
||||
const unsigned int a = aC1.a + aC2.a;
|
||||
|
||||
return COLOR_RGBA( ( r >> 1 ), ( g >> 1 ), ( b >> 1 ), ( a >> 1 ) );
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGBA BlendColor( const COLOR_RGBA& aC1, const COLOR_RGBA& aC2, const COLOR_RGBA& aC3 )
|
||||
{
|
||||
const unsigned int r = aC1.r + aC2.r + aC3.r;
|
||||
const unsigned int g = aC1.g + aC2.g + aC3.g;
|
||||
const unsigned int b = aC1.b + aC2.b + aC3.b;
|
||||
const unsigned int a = aC1.a + aC2.a + aC3.a;
|
||||
|
||||
return COLOR_RGBA( ( r / 3 ), ( g / 3 ), ( b / 3 ), ( a / 3 ) );
|
||||
}
|
||||
|
||||
|
||||
COLOR_RGBA BlendColor( const COLOR_RGBA& aC1, const COLOR_RGBA& aC2, const COLOR_RGBA& aC3,
|
||||
const COLOR_RGBA& aC4 )
|
||||
{
|
||||
const unsigned int r = aC1.r + aC2.r + aC3.r + aC4.r;
|
||||
const unsigned int g = aC1.g + aC2.g + aC3.g + aC4.g;
|
||||
const unsigned int b = aC1.b + aC2.b + aC3.b + aC4.b;
|
||||
const unsigned int a = aC1.a + aC2.a + aC3.a + aC4.a;
|
||||
|
||||
return COLOR_RGBA( ( r >> 2 ), ( g >> 2 ), ( b >> 2 ), ( a >> 2 ) );
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file color_rgba.h
|
||||
*/
|
||||
|
||||
#ifndef COLOR_RGBA_H
|
||||
#define COLOR_RGBA_H
|
||||
|
||||
#include <plugins/3dapi/xv3d_types.h>
|
||||
|
||||
union COLOR_RGBA
|
||||
{
|
||||
unsigned char c[4];
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
unsigned char a;
|
||||
};
|
||||
|
||||
COLOR_RGBA( const SFVEC3F& aColor );
|
||||
COLOR_RGBA( const SFVEC4F& aColor );
|
||||
COLOR_RGBA() { r = 0; g = 0; b = 0; a = 0; }
|
||||
COLOR_RGBA( unsigned char aR, unsigned char aG, unsigned char aB )
|
||||
{
|
||||
r = aR;
|
||||
g = aG;
|
||||
b = aB;
|
||||
}
|
||||
|
||||
COLOR_RGBA( unsigned char aR, unsigned char aG, unsigned char aB, unsigned char aA )
|
||||
{
|
||||
r = aR;
|
||||
g = aG;
|
||||
b = aB;
|
||||
a = aA;
|
||||
}
|
||||
|
||||
operator SFVEC4F() const;
|
||||
};
|
||||
|
||||
|
||||
COLOR_RGBA BlendColor( const COLOR_RGBA& aC1, const COLOR_RGBA& aC2 );
|
||||
COLOR_RGBA BlendColor( const COLOR_RGBA& aC1, const COLOR_RGBA& aC2, const COLOR_RGBA& aC3 );
|
||||
COLOR_RGBA BlendColor( const COLOR_RGBA& aC1, const COLOR_RGBA& aC2, const COLOR_RGBA& aC3,
|
||||
const COLOR_RGBA& aC4 );
|
||||
|
||||
#endif // COLOR_RGBA_H
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2020 Oleg Endo <olegendo@gcc.gnu.org>
|
||||
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -24,7 +24,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 3d_model.cpp
|
||||
* @file c_ogl_3dmodel.cpp
|
||||
* @brief
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
@@ -98,8 +99,8 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
|
||||
|
||||
/**
|
||||
* WARNING: Horrible hack here!
|
||||
* Somehow, buffer values are being shared between Pcbnew and the 3d viewer, which then frees
|
||||
* the buffer, resulting in errors in Pcbnew. To resolve this temporarily, we generate
|
||||
* Somehow, buffer values are being shared between pcbnew and the 3d viewer, which then frees
|
||||
* the buffer, resulting in errors in pcbnew. To resolve this temporarily, we generate
|
||||
* extra buffers in 3dviewer and use the higher numbers. These are freed on close.
|
||||
* todo: Correctly separate the OpenGL contexts to prevent overlapping buffer vals
|
||||
*/
|
||||
@@ -332,8 +333,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
|
||||
|
||||
// temporary index buffer which will contain either GLushort or GLuint
|
||||
// type indices. allocate with a bit of meadow at the end.
|
||||
auto tmp_idx =
|
||||
std::make_unique<GLuint[]>( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) );
|
||||
auto tmp_idx = std::make_unique<GLuint[]>( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) );
|
||||
|
||||
unsigned int prev_vtx_count = 0;
|
||||
unsigned int idx_offset = 0;
|
||||
@@ -448,7 +448,7 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
|
||||
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const float*)¶m.x );
|
||||
|
||||
std::vector<const MODEL_3D::MATERIAL *> materialsToRender;
|
||||
|
||||
|
||||
materialsToRender.reserve( m_materials.size() );
|
||||
|
||||
if( aModelWorldMatrix && aCameraWorldPos )
|
||||
@@ -483,21 +483,23 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
|
||||
|
||||
// Sort from back to front
|
||||
std::sort( materialsSorted.begin(), materialsSorted.end(),
|
||||
[&]( std::pair<const MODEL_3D::MATERIAL*, float>& a,
|
||||
std::pair<const MODEL_3D::MATERIAL*, float>& b )
|
||||
{
|
||||
bool aInsideB = a.first->m_bbox.Inside( b.first->m_bbox );
|
||||
bool bInsideA = b.first->m_bbox.Inside( a.first->m_bbox );
|
||||
|
||||
[&]( std::pair<const MODEL_3D::MATERIAL*, float>& a,
|
||||
std::pair<const MODEL_3D::MATERIAL*, float>& b ) {
|
||||
// If A is inside B, then A is rendered first
|
||||
if( aInsideB != bInsideA )
|
||||
return bInsideA;
|
||||
if( b.first->m_bbox.Inside( a.first->m_bbox ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( a.first->m_bbox.Inside( b.first->m_bbox ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if( a.second != b.second )
|
||||
return a.second > b.second;
|
||||
|
||||
return a.first > b.first; // compare pointers as a last resort
|
||||
} );
|
||||
return a.second > b.second;
|
||||
} );
|
||||
|
||||
for( const std::pair<const MODEL_3D::MATERIAL*, float>& mat : materialsSorted )
|
||||
{
|
||||
@@ -508,9 +510,9 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
|
||||
{
|
||||
for( const MODEL_3D::MATERIAL& mat : m_materials )
|
||||
{
|
||||
// There is at least one default material created in case a mesh has no declared
|
||||
// materials. Most meshes have a material, so usually the first material will have
|
||||
// nothing to render and is skip. See S3D::GetModel for more details.
|
||||
// There is at least one default material created in case a mesh has no declared materials.
|
||||
// Most meshes have a material, so usually the first material will have nothing to render and is skip.
|
||||
// See S3D::GetModel for more details.
|
||||
if( mat.m_render_idx_count == 0 )
|
||||
{
|
||||
continue;
|
||||
@@ -522,10 +524,10 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
materialsToRender.push_back( &mat );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( const MODEL_3D::MATERIAL* mat : materialsToRender )
|
||||
{
|
||||
@@ -536,8 +538,7 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
|
||||
break;
|
||||
|
||||
case MATERIAL_MODE::DIFFUSE_ONLY:
|
||||
OglSetDiffuseMaterial( mat->m_Diffuse, aOpacity, aUseSelectedMaterial,
|
||||
aSelectionColor );
|
||||
OglSetDiffuseMaterial( mat->m_Diffuse, aOpacity, aUseSelectedMaterial, aSelectionColor );
|
||||
break;
|
||||
|
||||
case MATERIAL_MODE::CAD_MODE:
|
||||
@@ -605,7 +606,7 @@ void MODEL_3D::DrawBboxes() const
|
||||
: sizeof( GLuint );
|
||||
|
||||
glDrawElements( GL_LINES, bbox_idx_count * m_meshes_bbox.size(), m_bbox_index_buffer_type,
|
||||
reinterpret_cast<const void*>(
|
||||
reinterpret_cast<const void*>(
|
||||
static_cast<uintptr_t>( bbox_idx_count * idx_size ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2020 Oleg Endo <olegendo@gcc.gnu.org>
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <plugins/3dapi/c3dmodel.h>
|
||||
#include "../../common_ogl/openGL_includes.h"
|
||||
#include "../raytracing/shapes3D/bbox_3d.h"
|
||||
#include <3d_enums.h>
|
||||
#include "../../3d_enums.h"
|
||||
|
||||
#include <wx/chartype.h>
|
||||
|
||||
@@ -146,8 +146,7 @@ private:
|
||||
unsigned int m_render_idx_buffer_offset = 0;
|
||||
unsigned int m_render_idx_count = 0;
|
||||
|
||||
BBOX_3D m_bbox; ///< bounding box for this material group, used for transparent
|
||||
///< material ordering.
|
||||
BBOX_3D m_bbox; ///< bounding box for this material group, used for transparent material ordering
|
||||
|
||||
MATERIAL( const SMATERIAL& aOther ) : SMATERIAL( aOther ) { }
|
||||
bool IsTransparent() const { return m_Transparency > FLT_EPSILON; }
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 2023 CERN
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -24,25 +23,24 @@
|
||||
*/
|
||||
|
||||
#include "render_3d_opengl.h"
|
||||
#include "opengl_utils.h"
|
||||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include "../../3d_math.h"
|
||||
#include "convert_basic_shapes_to_polygon.h"
|
||||
#include <lset.h>
|
||||
#include <trigo.h>
|
||||
#include <project.h>
|
||||
#include <core/profile.h> // To use GetRunningMicroSecs or another profiling utility
|
||||
#include <profile.h> // To use GetRunningMicroSecs or another profiling utility
|
||||
#include <fp_lib_table.h>
|
||||
#include <eda_3d_canvas.h>
|
||||
#include <eda_3d_viewer_frame.h>
|
||||
#include <project_pcb.h>
|
||||
|
||||
|
||||
void RENDER_3D_OPENGL::addObjectTriangles( const FILLED_CIRCLE_2D* aCircle,
|
||||
void RENDER_3D_OPENGL::addObjectTriangles( const FILLED_CIRCLE_2D* aFilledCircle,
|
||||
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop,
|
||||
float aZbot )
|
||||
{
|
||||
const SFVEC2F& center = aCircle->GetCenter();
|
||||
const float radius = aCircle->GetRadius() * 2.0f; // Double because the render triangle
|
||||
const SFVEC2F& center = aFilledCircle->GetCenter();
|
||||
const float radius = aFilledCircle->GetRadius() * 2.0f; // Double because the render triangle
|
||||
|
||||
// This is a small adjustment to the circle texture
|
||||
const float texture_factor = ( 8.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
|
||||
@@ -304,7 +302,7 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateHoles( const LIST_OBJECT2D& aListH
|
||||
|
||||
OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D* aContainer,
|
||||
const SHAPE_POLY_SET* aPolyList,
|
||||
PCB_LAYER_ID aLayer,
|
||||
PCB_LAYER_ID aLayerId,
|
||||
const BVH_CONTAINER_2D* aThroughHoles )
|
||||
{
|
||||
if( aContainer == nullptr )
|
||||
@@ -318,7 +316,7 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D*
|
||||
float layer_z_bot = 0.0f;
|
||||
float layer_z_top = 0.0f;
|
||||
|
||||
getLayerZPos( aLayer, layer_z_top, layer_z_bot );
|
||||
getLayerZPos( aLayerId, layer_z_top, layer_z_bot );
|
||||
|
||||
// Calculate an estimation for the nr of triangles based on the nr of objects
|
||||
unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
|
||||
@@ -377,12 +375,12 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D*
|
||||
}
|
||||
|
||||
|
||||
OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateEmptyLayerList( PCB_LAYER_ID aLayer )
|
||||
OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateEmptyLayerList( PCB_LAYER_ID aLayerId )
|
||||
{
|
||||
float layer_z_bot = 0.0f;
|
||||
float layer_z_top = 0.0f;
|
||||
|
||||
getLayerZPos( aLayer, layer_z_top, layer_z_bot );
|
||||
getLayerZPos( aLayerId, layer_z_top, layer_z_bot );
|
||||
|
||||
TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( 1 );
|
||||
|
||||
@@ -455,7 +453,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
|
||||
|
||||
OBJECT_2D_STATS::Instance().ResetStats();
|
||||
|
||||
int64_t stats_startReloadTime = GetRunningMicroSecs();
|
||||
unsigned stats_startReloadTime = GetRunningMicroSecs();
|
||||
|
||||
m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
|
||||
|
||||
@@ -466,22 +464,28 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
|
||||
aStatusReporter->Report( _( "Load OpenGL: board" ) );
|
||||
|
||||
// Create Board
|
||||
m_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetTH_IDs() );
|
||||
m_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetThroughHoleIds() );
|
||||
|
||||
m_antiBoardPolys.RemoveAllContours();
|
||||
m_antiBoardPolys.NewOutline();
|
||||
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Outline( 0 ).SetClosed( true );
|
||||
if( m_boardAdapter.m_Cfg->m_Render.realistic )
|
||||
{
|
||||
m_antiBoardPolys.RemoveAllContours();
|
||||
m_antiBoardPolys.NewOutline();
|
||||
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
|
||||
m_antiBoardPolys.Outline( 0 ).SetClosed( true );
|
||||
|
||||
m_antiBoardPolys.BooleanSubtract( m_boardAdapter.GetBoardPoly() );
|
||||
m_antiBoard = createBoard( m_antiBoardPolys );
|
||||
m_antiBoardPolys.BooleanSubtract( m_boardAdapter.GetBoardPoly(),
|
||||
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
m_antiBoard = createBoard( m_antiBoardPolys );
|
||||
}
|
||||
|
||||
SHAPE_POLY_SET board_poly_with_holes = m_boardAdapter.GetBoardPoly().CloneDropTriangulation();
|
||||
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
|
||||
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
|
||||
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
m_boardWithHoles = createBoard( board_poly_with_holes );
|
||||
|
||||
@@ -492,21 +496,28 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
|
||||
if( aStatusReporter )
|
||||
aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
|
||||
|
||||
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetTH_ODPolys().CloneDropTriangulation();
|
||||
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetThroughHoleOdPolys().CloneDropTriangulation();
|
||||
|
||||
outerPolyTHT.BooleanIntersection( m_boardAdapter.GetBoardPoly() );
|
||||
|
||||
m_outerThroughHoles = generateHoles( m_boardAdapter.GetTH_ODs().GetList(), outerPolyTHT,
|
||||
1.0f, 0.0f, false, &m_boardAdapter.GetTH_IDs() );
|
||||
|
||||
m_outerViaThroughHoles = generateHoles( m_boardAdapter.GetViaTH_ODs().GetList(),
|
||||
m_boardAdapter.GetViaTH_ODPolys(), 1.0f, 0.0f, false );
|
||||
|
||||
if( m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annuli )
|
||||
if( m_boardAdapter.m_Cfg->m_Render.realistic )
|
||||
{
|
||||
m_outerThroughHoleRings = generateHoles( m_boardAdapter.GetViaAnnuli().GetList(),
|
||||
m_boardAdapter.GetViaAnnuliPolys(),
|
||||
1.0f, 0.0f, false );
|
||||
outerPolyTHT.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
||||
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
}
|
||||
|
||||
m_outerThroughHoles = generateHoles( m_boardAdapter.GetThroughHoleOds().GetList(),
|
||||
outerPolyTHT, 1.0f, 0.0f, false,
|
||||
&m_boardAdapter.GetThroughHoleIds() );
|
||||
|
||||
m_outerViaThroughHoles = generateHoles(
|
||||
m_boardAdapter.GetThroughHoleViaOds().GetList(),
|
||||
m_boardAdapter.GetThroughHoleViaOdPolys(), 1.0f, 0.0f, false );
|
||||
|
||||
if( m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annulus &&
|
||||
m_boardAdapter.m_Cfg->m_Render.realistic )
|
||||
{
|
||||
m_outerThroughHoleRings = generateHoles(
|
||||
m_boardAdapter.GetThroughHoleAnnularRings().GetList(),
|
||||
m_boardAdapter.GetThroughHoleAnnularRingPolys(), 1.0f, 0.0f, false );
|
||||
}
|
||||
|
||||
const MAP_POLY& innerMapHoles = m_boardAdapter.GetHoleIdPolysMap();
|
||||
@@ -521,20 +532,28 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
|
||||
float layer_z_bot = 0.0f;
|
||||
float layer_z_top = 0.0f;
|
||||
|
||||
for( const auto& [ layer, poly ] : outerMapHoles )
|
||||
for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : outerMapHoles )
|
||||
{
|
||||
getLayerZPos( layer, layer_z_top, layer_z_bot );
|
||||
const PCB_LAYER_ID layer_id = ii.first;
|
||||
const SHAPE_POLY_SET* poly = ii.second;
|
||||
const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
|
||||
|
||||
m_outerLayerHoles[layer] = generateHoles( map_holes.at( layer )->GetList(), *poly,
|
||||
layer_z_top, layer_z_bot, false );
|
||||
getLayerZPos( layer_id, layer_z_top, layer_z_bot );
|
||||
|
||||
m_outerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
|
||||
layer_z_top, layer_z_bot, false );
|
||||
}
|
||||
|
||||
for( const auto& [ layer, poly ] : innerMapHoles )
|
||||
for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : innerMapHoles )
|
||||
{
|
||||
getLayerZPos( layer, layer_z_top, layer_z_bot );
|
||||
const PCB_LAYER_ID layer_id = ii.first;
|
||||
const SHAPE_POLY_SET* poly = ii.second;
|
||||
const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
|
||||
|
||||
m_innerLayerHoles[layer] = generateHoles( map_holes.at( layer )->GetList(), *poly,
|
||||
layer_z_top, layer_z_bot, false );
|
||||
getLayerZPos( layer_id, layer_z_top, layer_z_bot );
|
||||
|
||||
m_innerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
|
||||
layer_z_top, layer_z_bot, false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,96 +564,107 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
|
||||
if( aStatusReporter )
|
||||
aStatusReporter->Report( _( "Load OpenGL: layers" ) );
|
||||
|
||||
std::bitset<LAYER_3D_END> visibilityFlags = m_boardAdapter.GetVisibleLayers();
|
||||
const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
|
||||
wxString msg;
|
||||
const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
|
||||
|
||||
for( const auto& [ layer, container2d ] : m_boardAdapter.GetLayerMap() )
|
||||
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& ii : m_boardAdapter.GetLayerMap() )
|
||||
{
|
||||
if( !m_boardAdapter.Is3dLayerEnabled( layer, visibilityFlags ) )
|
||||
const PCB_LAYER_ID layer_id = ii.first;
|
||||
|
||||
if( !m_boardAdapter.Is3dLayerEnabled( layer_id ) )
|
||||
continue;
|
||||
|
||||
if( aStatusReporter )
|
||||
{
|
||||
msg = m_boardAdapter.GetBoard()->GetLayerName( layer );
|
||||
aStatusReporter->Report( wxString::Format( _( "Load OpenGL layer %s" ), msg ) );
|
||||
aStatusReporter->Report( wxString::Format( _( "Load OpenGL layer %d" ),
|
||||
(int) layer_id ) );
|
||||
}
|
||||
|
||||
const BVH_CONTAINER_2D* container2d = ii.second;
|
||||
|
||||
SHAPE_POLY_SET polyListSubtracted;
|
||||
SHAPE_POLY_SET* polyList = nullptr;
|
||||
|
||||
// Load the vertical (Z axis) component of shapes
|
||||
|
||||
if( m_boardAdapter.m_Cfg->m_Render.opengl_copper_thickness )
|
||||
if( map_poly.find( layer_id ) != map_poly.end() )
|
||||
{
|
||||
if( map_poly.find( layer ) != map_poly.end() )
|
||||
polyListSubtracted = *map_poly.at( layer_id );;
|
||||
|
||||
if( m_boardAdapter.m_Cfg->m_Render.realistic )
|
||||
{
|
||||
polyListSubtracted = *map_poly.at( layer );
|
||||
polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
if( LSET::PhysicalLayersMask().test( layer ) )
|
||||
if( layer_id != B_Mask && layer_id != F_Mask )
|
||||
{
|
||||
polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly() );
|
||||
}
|
||||
|
||||
if( layer != B_Mask && layer != F_Mask )
|
||||
{
|
||||
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
|
||||
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
|
||||
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
}
|
||||
|
||||
if( m_boardAdapter.m_Cfg->m_Render.subtract_mask_from_silk )
|
||||
{
|
||||
if( layer == B_SilkS && map_poly.find( B_Mask ) != map_poly.end() )
|
||||
if( layer_id == B_SilkS && map_poly.find( B_Mask ) != map_poly.end() )
|
||||
{
|
||||
polyListSubtracted.BooleanSubtract( *map_poly.at( B_Mask ) );
|
||||
polyListSubtracted.BooleanSubtract( *map_poly.at( B_Mask ),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
}
|
||||
else if( layer == F_SilkS && map_poly.find( F_Mask ) != map_poly.end() )
|
||||
else if( layer_id == F_SilkS && map_poly.find( F_Mask ) != map_poly.end() )
|
||||
{
|
||||
polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ) );
|
||||
polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
}
|
||||
}
|
||||
|
||||
polyList = &polyListSubtracted;
|
||||
}
|
||||
|
||||
polyList = &polyListSubtracted;
|
||||
}
|
||||
|
||||
OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, polyList, layer,
|
||||
&m_boardAdapter.GetTH_IDs() );
|
||||
OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, polyList, layer_id,
|
||||
&m_boardAdapter.GetThroughHoleIds() );
|
||||
|
||||
if( oglList != nullptr )
|
||||
m_layers[layer] = oglList;
|
||||
m_layers[layer_id] = oglList;
|
||||
|
||||
}
|
||||
|
||||
if( m_boardAdapter.m_Cfg->m_Render.DifferentiatePlatedCopper() )
|
||||
if( m_boardAdapter.m_Cfg->m_Render.renderPlatedPadsAsPlated
|
||||
&& m_boardAdapter.m_Cfg->m_Render.realistic )
|
||||
{
|
||||
const SHAPE_POLY_SET* frontPlatedPadAndGraphicPolys =
|
||||
m_boardAdapter.GetFrontPlatedPadAndGraphicPolys();
|
||||
const SHAPE_POLY_SET* backPlatedPadAndGraphicPolys =
|
||||
m_boardAdapter.GetBackPlatedPadAndGraphicPolys();
|
||||
const SHAPE_POLY_SET* frontPlatedPadPolys = m_boardAdapter.GetFrontPlatedPadPolys();
|
||||
const SHAPE_POLY_SET* backPlatedPadPolys = m_boardAdapter.GetBackPlatedPadPolys();
|
||||
|
||||
if( frontPlatedPadAndGraphicPolys )
|
||||
if( frontPlatedPadPolys )
|
||||
{
|
||||
SHAPE_POLY_SET poly = frontPlatedPadAndGraphicPolys->CloneDropTriangulation();
|
||||
poly.BooleanIntersection( m_boardAdapter.GetBoardPoly() );
|
||||
poly.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
|
||||
poly.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
|
||||
SHAPE_POLY_SET polySubtracted = frontPlatedPadPolys->CloneDropTriangulation();
|
||||
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
polySubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(), &poly,
|
||||
F_Cu );
|
||||
m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(),
|
||||
&polySubtracted, F_Cu );
|
||||
|
||||
// An entry for F_Cu must exist in m_layers or we'll never look at m_platedPadsFront
|
||||
if( m_layers.count( F_Cu ) == 0 )
|
||||
m_layers[F_Cu] = generateEmptyLayerList( F_Cu );
|
||||
}
|
||||
|
||||
if( backPlatedPadAndGraphicPolys )
|
||||
if( backPlatedPadPolys )
|
||||
{
|
||||
SHAPE_POLY_SET poly = backPlatedPadAndGraphicPolys->CloneDropTriangulation();
|
||||
poly.BooleanIntersection( m_boardAdapter.GetBoardPoly() );
|
||||
poly.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
|
||||
poly.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
|
||||
SHAPE_POLY_SET polySubtracted = backPlatedPadPolys->CloneDropTriangulation();
|
||||
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
polySubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
m_platedPadsBack = generateLayerList( m_boardAdapter.GetPlatedPadsBack(), &poly, B_Cu );
|
||||
m_platedPadsBack = generateLayerList( m_boardAdapter.GetPlatedPadsBack(),
|
||||
&polySubtracted, B_Cu );
|
||||
|
||||
// An entry for B_Cu must exist in m_layers or we'll never look at m_platedPadsBack
|
||||
if( m_layers.count( B_Cu ) == 0 )
|
||||
@@ -642,15 +672,6 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
|
||||
}
|
||||
}
|
||||
|
||||
if( m_boardAdapter.m_Cfg->m_Render.show_off_board_silk )
|
||||
{
|
||||
if( const BVH_CONTAINER_2D* padsFront = m_boardAdapter.GetOffboardPadsFront() )
|
||||
m_offboardPadsFront = generateLayerList( padsFront, nullptr, F_Cu );
|
||||
|
||||
if( const BVH_CONTAINER_2D* padsBack = m_boardAdapter.GetOffboardPadsBack() )
|
||||
m_offboardPadsBack = generateLayerList( padsBack, nullptr, B_Cu );
|
||||
}
|
||||
|
||||
// Load 3D models
|
||||
if( aStatusReporter )
|
||||
aStatusReporter->Report( _( "Loading 3D models..." ) );
|
||||
@@ -754,9 +775,6 @@ void RENDER_3D_OPENGL::generateViasAndPads()
|
||||
{
|
||||
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
||||
|
||||
if( via->GetViaType() == VIATYPE::THROUGH )
|
||||
continue; // handle with pad holes so castellation is taken into account
|
||||
|
||||
const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits();
|
||||
const int nrSegments = m_boardAdapter.GetCircleSegmentCount( via->GetDrillValue() );
|
||||
const float hole_inner_radius = holediameter / 2.0f;
|
||||
@@ -786,33 +804,14 @@ void RENDER_3D_OPENGL::generateViasAndPads()
|
||||
}
|
||||
|
||||
|
||||
if( m_boardAdapter.GetHoleCount() > 0 || m_boardAdapter.GetViaCount() > 0 )
|
||||
if( m_boardAdapter.GetHoleCount() > 0 )
|
||||
{
|
||||
SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes
|
||||
SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes
|
||||
SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
|
||||
SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
|
||||
|
||||
tht_outer_holes_poly.RemoveAllContours();
|
||||
tht_inner_holes_poly.RemoveAllContours();
|
||||
|
||||
// Insert through-via holes (vertical cylinders)
|
||||
for( const PCB_TRACK* track : m_boardAdapter.GetBoard()->Tracks() )
|
||||
{
|
||||
if( track->Type() == PCB_VIA_T )
|
||||
{
|
||||
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
||||
|
||||
if( via->GetViaType() == VIATYPE::THROUGH )
|
||||
{
|
||||
TransformCircleToPolygon( tht_outer_holes_poly, via->GetPosition(),
|
||||
via->GetDrill() / 2 + platingThickness,
|
||||
ARC_HIGH_DEF, ERROR_INSIDE );
|
||||
|
||||
TransformCircleToPolygon( tht_inner_holes_poly, via->GetPosition(),
|
||||
via->GetDrill() / 2, ARC_HIGH_DEF, ERROR_INSIDE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert pads holes (vertical cylinders)
|
||||
for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
|
||||
{
|
||||
@@ -835,9 +834,10 @@ void RENDER_3D_OPENGL::generateViasAndPads()
|
||||
}
|
||||
|
||||
// Subtract the holes
|
||||
tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly );
|
||||
tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
tht_outer_holes_poly.BooleanSubtract( m_antiBoardPolys );
|
||||
if( m_boardAdapter.m_Cfg->m_Render.realistic )
|
||||
tht_outer_holes_poly.BooleanSubtract( m_antiBoardPolys, SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
CONTAINER_2D holesContainer;
|
||||
|
||||
@@ -894,16 +894,16 @@ void RENDER_3D_OPENGL::Load3dModelsIfNeeded()
|
||||
if( m_3dModelMap.size() > 0 )
|
||||
return;
|
||||
|
||||
if( wxFrame* frame = dynamic_cast<wxFrame*>( m_canvas->GetParent() ) )
|
||||
wxFrame* frame = dynamic_cast<EDA_3D_VIEWER_FRAME*>( m_canvas->GetParent() );
|
||||
|
||||
if( frame )
|
||||
{
|
||||
STATUSBAR_REPORTER activityReporter( frame->GetStatusBar(),
|
||||
(int) EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
|
||||
load3dModels( &activityReporter );
|
||||
}
|
||||
else
|
||||
{
|
||||
load3dModels( nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -912,10 +912,6 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
|
||||
if( !m_boardAdapter.GetBoard() )
|
||||
return;
|
||||
|
||||
// Building the 3D models late crashes on recent versions of macOS
|
||||
// Unclear the exact mechanism, but as a workaround, just build them
|
||||
// all the time. See https://gitlab.com/kicad/code/kicad/-/issues/17198
|
||||
#ifndef __WXMAC__
|
||||
if( !m_boardAdapter.m_IsPreviewer
|
||||
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_normal
|
||||
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_insert
|
||||
@@ -923,7 +919,6 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Go for all footprints
|
||||
for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
|
||||
@@ -937,8 +932,8 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
|
||||
{
|
||||
// FindRow() can throw an exception
|
||||
const FP_LIB_TABLE_ROW* fpRow =
|
||||
PROJECT_PCB::PcbFootprintLibs( m_boardAdapter.GetBoard()->GetProject() )
|
||||
->FindRow( libraryName, false );
|
||||
m_boardAdapter.GetBoard()->GetProject()->PcbFootprintLibs()->FindRow(
|
||||
libraryName, false );
|
||||
|
||||
if( fpRow )
|
||||
footprintBasePath = fpRow->GetFullURI( true );
|
||||
@@ -968,9 +963,7 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
|
||||
{
|
||||
// It is not present, try get it from cache
|
||||
const S3DMODEL* modelPtr =
|
||||
m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename,
|
||||
footprintBasePath,
|
||||
footprint );
|
||||
m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename, footprintBasePath );
|
||||
|
||||
// only add it if the return is not NULL
|
||||
if( modelPtr )
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -129,7 +129,7 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >&
|
||||
{
|
||||
if( aContournPoints.size() >= 4 )
|
||||
{
|
||||
// Calculate normals of each segment of the contour
|
||||
// Calculate normals of each segment of the contourn
|
||||
std::vector< SFVEC2F > contournNormals;
|
||||
|
||||
contournNormals.clear();
|
||||
@@ -245,7 +245,7 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlin
|
||||
}
|
||||
}
|
||||
|
||||
// Add first position of the list to close the path.
|
||||
// Add first position fo the list to close the path
|
||||
if( lastV != contournPoints[0] )
|
||||
contournPoints.push_back( contournPoints[0] );
|
||||
|
||||
@@ -471,11 +471,38 @@ void OPENGL_RENDER_LIST::DrawAll( bool aDrawMiddle ) const
|
||||
}
|
||||
|
||||
|
||||
void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
|
||||
const OPENGL_RENDER_LIST* aSubtractList,
|
||||
const OPENGL_RENDER_LIST* bSubtractList,
|
||||
const OPENGL_RENDER_LIST* cSubtractList,
|
||||
const OPENGL_RENDER_LIST* dSubtractList ) const
|
||||
void OPENGL_RENDER_LIST::DrawAllCameraCulled( float zCameraPos, bool aDrawMiddle ) const
|
||||
{
|
||||
zCameraPos = m_haveTransformation
|
||||
? ( ( zCameraPos - m_zPositionTransformation ) / m_zScaleTransformation )
|
||||
: zCameraPos;
|
||||
|
||||
if( aDrawMiddle )
|
||||
DrawMiddle();
|
||||
|
||||
if( zCameraPos > m_zTop )
|
||||
{
|
||||
DrawTop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( zCameraPos < m_zBot )
|
||||
{
|
||||
DrawBot();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If camera is in the middle dont draw it.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OPENGL_RENDER_LIST::DrawAllCameraCulledSubtractLayer( bool aDrawMiddle,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractA,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractB,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractC,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractD ) const
|
||||
{
|
||||
glClearStencil( 0x00 );
|
||||
glClear( GL_STENCIL_BUFFER_BIT );
|
||||
@@ -490,20 +517,20 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
|
||||
glStencilFunc( GL_ALWAYS, 1, 0 );
|
||||
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
|
||||
|
||||
if( aSubtractList )
|
||||
aSubtractList->DrawBot();
|
||||
if( aLayerToSubtractA )
|
||||
aLayerToSubtractA->DrawBot();
|
||||
|
||||
if( bSubtractList )
|
||||
bSubtractList->DrawBot();
|
||||
if( aLayerToSubtractB )
|
||||
aLayerToSubtractB->DrawBot();
|
||||
|
||||
if( cSubtractList )
|
||||
cSubtractList->DrawBot();
|
||||
if( aLayerToSubtractC )
|
||||
aLayerToSubtractC->DrawBot();
|
||||
|
||||
if( dSubtractList )
|
||||
dSubtractList->DrawBot();
|
||||
if( aLayerToSubtractD )
|
||||
aLayerToSubtractD->DrawBot();
|
||||
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glDepthMask( GL_TRUE );
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
||||
glStencilFunc( GL_EQUAL, 0, 1 );
|
||||
@@ -517,20 +544,20 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
|
||||
glStencilFunc( GL_ALWAYS, 2, 0 );
|
||||
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
|
||||
|
||||
if( aSubtractList )
|
||||
aSubtractList->DrawTop();
|
||||
if( aLayerToSubtractA )
|
||||
aLayerToSubtractA->DrawTop();
|
||||
|
||||
if( bSubtractList )
|
||||
bSubtractList->DrawTop();
|
||||
if( aLayerToSubtractB )
|
||||
aLayerToSubtractB->DrawTop();
|
||||
|
||||
if( cSubtractList )
|
||||
cSubtractList->DrawTop();
|
||||
if( aLayerToSubtractC )
|
||||
aLayerToSubtractC->DrawTop();
|
||||
|
||||
if( dSubtractList )
|
||||
dSubtractList->DrawTop();
|
||||
if( aLayerToSubtractD )
|
||||
aLayerToSubtractD->DrawTop();
|
||||
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glDepthMask( GL_TRUE );
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
|
||||
glStencilFunc( GL_NOTEQUAL, 2, 0x03 );
|
||||
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
|
||||
@@ -548,8 +575,8 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
|
||||
|
||||
if( aDrawMiddle )
|
||||
{
|
||||
if( aSubtractList )
|
||||
aSubtractList->DrawMiddle();
|
||||
if( aLayerToSubtractA )
|
||||
aLayerToSubtractA->DrawMiddle();
|
||||
}
|
||||
|
||||
glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
|
||||
@@ -561,7 +588,7 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
|
||||
|
||||
void OPENGL_RENDER_LIST::ApplyScalePosition( float aZposition, float aZscale )
|
||||
{
|
||||
wxCHECK2( aZscale > FLT_EPSILON, aZscale = FLT_EPSILON + 1 );
|
||||
wxASSERT( aZscale > FLT_EPSILON );
|
||||
|
||||
m_zPositionTransformation = aZposition;
|
||||
m_zScaleTransformation = aZscale;
|
||||
@@ -569,12 +596,6 @@ void OPENGL_RENDER_LIST::ApplyScalePosition( float aZposition, float aZscale )
|
||||
}
|
||||
|
||||
|
||||
void OPENGL_RENDER_LIST::ApplyScalePosition( OPENGL_RENDER_LIST* aOtherList )
|
||||
{
|
||||
ApplyScalePosition( aOtherList->GetZBot(), aOtherList->GetZTop() - aOtherList->GetZBot() );
|
||||
}
|
||||
|
||||
|
||||
void OPENGL_RENDER_LIST::SetItIsTransparent( bool aSetTransparent )
|
||||
{
|
||||
m_draw_it_transparent = aSetTransparent;
|
||||
@@ -584,11 +605,11 @@ void OPENGL_RENDER_LIST::SetItIsTransparent( bool aSetTransparent )
|
||||
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
|
||||
const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp, GLuint aTextureId ) const
|
||||
{
|
||||
wxCHECK( aTriangleContainer != nullptr, 0 );
|
||||
wxASSERT( aTriangleContainer != nullptr );
|
||||
|
||||
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
|
||||
|
||||
// Top and Bot don't have normals array stored in container
|
||||
// Top and Bot dont have normals array stored in container
|
||||
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
|
||||
|
||||
if( ( aTriangleContainer->GetVertexSize() > 0 )
|
||||
@@ -651,11 +672,11 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
|
||||
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
|
||||
bool aIsNormalUp ) const
|
||||
{
|
||||
wxCHECK( aTriangleContainer != nullptr, 0 );
|
||||
wxASSERT( aTriangleContainer != nullptr );
|
||||
|
||||
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
|
||||
|
||||
// Top and Bot dint have normals array stored in container
|
||||
// Top and Bot dont have normals array stored in container
|
||||
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
|
||||
|
||||
if( ( aTriangleContainer->GetVertexSize() > 0 )
|
||||
@@ -695,7 +716,7 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* a
|
||||
GLuint OPENGL_RENDER_LIST::generate_middle_triangles(
|
||||
const TRIANGLE_LIST* aTriangleContainer ) const
|
||||
{
|
||||
wxCHECK( aTriangleContainer != nullptr, 0 );
|
||||
wxASSERT( aTriangleContainer != nullptr );
|
||||
|
||||
// We expect that it is a multiple of 3 vertex
|
||||
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
|
||||
@@ -767,5 +788,3 @@ void OPENGL_RENDER_LIST::beginTransformation() const
|
||||
glScalef( 1.0f, 1.0f, m_zScaleTransformation );
|
||||
}
|
||||
}
|
||||
|
||||
// LocalWords: EDA Luzeiro txt MERCHANTABILITY wxASSERT normals fo
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -194,14 +194,15 @@ public:
|
||||
*
|
||||
* @param zCameraPos is the camera z axis position.
|
||||
*/
|
||||
void DrawCulled( bool aDrawMiddle,
|
||||
const OPENGL_RENDER_LIST* aSubtractList = nullptr,
|
||||
const OPENGL_RENDER_LIST* bSubtractList = nullptr,
|
||||
const OPENGL_RENDER_LIST* cSubtractList = nullptr,
|
||||
const OPENGL_RENDER_LIST* dSubtractList = nullptr ) const;
|
||||
void DrawAllCameraCulled( float zCameraPos, bool aDrawMiddle = true ) const;
|
||||
|
||||
void DrawAllCameraCulledSubtractLayer( bool aDrawMiddle,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractA = nullptr,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractB = nullptr,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractC = nullptr,
|
||||
const OPENGL_RENDER_LIST* aLayerToSubtractD = nullptr ) const;
|
||||
|
||||
void ApplyScalePosition( float aZposition, float aZscale );
|
||||
void ApplyScalePosition( OPENGL_RENDER_LIST* aOtherList );
|
||||
|
||||
void ClearScalePosition() { m_haveTransformation = false; }
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <trigo.h>
|
||||
#include <wx/debug.h> // For the wxASSERT
|
||||
|
||||
#define RADPERDEG 0.0174533f
|
||||
#define RADPERDEG 0.0174533
|
||||
|
||||
void DrawRoundArrow( SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize )
|
||||
{
|
||||
@@ -155,7 +155,7 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
|
||||
{
|
||||
SFVEC2D corner = SFVEC2D( 0.0, radius );
|
||||
RotatePoint( &corner.x, &corner.y, ii );
|
||||
glVertex3f( static_cast<GLfloat>( corner.x ), static_cast<GLfloat>( corner.y ), 0.0 );
|
||||
glVertex3f( corner.x, corner.y, 0.0 );
|
||||
}
|
||||
|
||||
glVertex3d( 0.0, -radius, 0.0 );
|
||||
@@ -171,7 +171,7 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
|
||||
SFVEC2D corner = SFVEC2D( 0.0, radius );
|
||||
|
||||
RotatePoint( &corner.x, &corner.y, ii );
|
||||
glVertex3f( static_cast<GLfloat>( corner.x ), static_cast<GLfloat>( corner.y ), 1.0 );
|
||||
glVertex3f( corner.x, corner.y, 1.0 );
|
||||
}
|
||||
|
||||
glVertex3f( 0.0, radius, 1.0 );
|
||||
@@ -185,10 +185,9 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
|
||||
SFVEC2D corner = SFVEC2D( 0.0, radius );
|
||||
|
||||
RotatePoint( &corner.x, &corner.y, ii );
|
||||
glNormal3f( static_cast<GLfloat>( corner.x * 2.0f ),
|
||||
static_cast<GLfloat>( corner.y * 2.0f ), 0.0f );
|
||||
glVertex3f( static_cast<GLfloat>( corner.x ), static_cast<GLfloat>( corner.y ), 1.0f );
|
||||
glVertex3f( static_cast<GLfloat>( corner.x ), static_cast<GLfloat>( corner.y ), 0.0f );
|
||||
glNormal3f( corner.x * 2.0f, corner.y * 2.0f, 0.0f );
|
||||
glVertex3f( corner.x, corner.y, 1.0 );
|
||||
glVertex3f( corner.x, corner.y, 0.0 );
|
||||
}
|
||||
|
||||
glNormal3f( 0.0, 1.0f, 0.0f );
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -73,15 +73,16 @@ public:
|
||||
|
||||
private:
|
||||
OPENGL_RENDER_LIST* generateHoles( const LIST_OBJECT2D& aListHolesObject2d,
|
||||
const SHAPE_POLY_SET& aPoly, float aZtop, float aZbot,
|
||||
bool aInvertFaces,
|
||||
const SHAPE_POLY_SET& aPoly, float aZtop,
|
||||
float aZbot, bool aInvertFaces,
|
||||
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
|
||||
|
||||
OPENGL_RENDER_LIST* generateLayerList( const BVH_CONTAINER_2D* aContainer,
|
||||
const SHAPE_POLY_SET* aPolyList, PCB_LAYER_ID aLayer,
|
||||
const SHAPE_POLY_SET* aPolyList,
|
||||
PCB_LAYER_ID aLayerId,
|
||||
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
|
||||
|
||||
OPENGL_RENDER_LIST* generateEmptyLayerList( PCB_LAYER_ID aLayer );
|
||||
OPENGL_RENDER_LIST* generateEmptyLayerList( PCB_LAYER_ID aLayerId );
|
||||
|
||||
void addTopAndBottomTriangles( TRIANGLE_DISPLAY_LIST* aDst, const SFVEC2F& v0,
|
||||
const SFVEC2F& v1, const SFVEC2F& v2, float top, float bot );
|
||||
@@ -92,17 +93,17 @@ private:
|
||||
void addObjectTriangles( const POLYGON_4PT_2D* aPoly, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
||||
float aZtop, float aZbot );
|
||||
|
||||
void addObjectTriangles( const FILLED_CIRCLE_2D* aCircle, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
||||
float aZtop, float aZbot );
|
||||
void addObjectTriangles( const FILLED_CIRCLE_2D* aFilledCircle,
|
||||
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
|
||||
|
||||
void addObjectTriangles( const TRIANGLE_2D* aTri, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
||||
float aZtop, float aZbot );
|
||||
|
||||
void addObjectTriangles( const ROUND_SEGMENT_2D* aSeg, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
||||
float aZtop, float aZbot );
|
||||
void addObjectTriangles( const ROUND_SEGMENT_2D* aSeg,
|
||||
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
|
||||
|
||||
void renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPos, bool aShowThickness,
|
||||
bool aSkipRenderHoles );
|
||||
void renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPosition,
|
||||
bool aDrawMiddleSegments, bool aSkipRenderHoles );
|
||||
|
||||
void renderBoardBody( bool aSkipRenderHoles );
|
||||
|
||||
@@ -153,12 +154,15 @@ private:
|
||||
void renderOpaqueModels( const glm::mat4 &aCameraViewMatrix );
|
||||
void renderTransparentModels( const glm::mat4 &aCameraViewMatrix );
|
||||
|
||||
void renderModel( const glm::mat4 &aCameraViewMatrix, const MODELTORENDER &aModelToRender,
|
||||
const SFVEC3F &aSelColor, const SFVEC3F *aCameraWorldPos );
|
||||
void renderModel( const glm::mat4 &aCameraViewMatrix,
|
||||
const MODELTORENDER &aModelToRender,
|
||||
const SFVEC3F &aSelColor,
|
||||
const SFVEC3F *aCameraWorldPos );
|
||||
|
||||
|
||||
void get3dModelsSelected( std::list<MODELTORENDER> &aDstRenderList, bool aGetTop, bool aGetBot,
|
||||
bool aRenderTransparentOnly, bool aRenderSelectedOnly );
|
||||
void get3dModelsSelected( std::list<MODELTORENDER> &aDstRenderList,
|
||||
bool aGetTop, bool aGetBot, bool aRenderTransparentOnly,
|
||||
bool aRenderSelectedOnly );
|
||||
|
||||
void get3dModelsFromFootprint( std::list<MODELTORENDER> &aDstRenderList,
|
||||
const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
|
||||
@@ -185,6 +189,7 @@ private:
|
||||
void unsetDepthOffset();
|
||||
|
||||
void setLayerMaterial( PCB_LAYER_ID aLayerID );
|
||||
SFVEC4F getLayerColor( PCB_LAYER_ID aLayerID );
|
||||
|
||||
bool initializeOpenGL();
|
||||
OPENGL_RENDER_LIST* createBoard( const SHAPE_POLY_SET& aBoardPoly,
|
||||
@@ -208,13 +213,9 @@ private:
|
||||
SMATERIAL m_GrayMaterial;
|
||||
} m_materials;
|
||||
|
||||
EDA_3D_CANVAS* m_canvas;
|
||||
|
||||
MAP_OGL_DISP_LISTS m_layers;
|
||||
OPENGL_RENDER_LIST* m_platedPadsFront;
|
||||
OPENGL_RENDER_LIST* m_platedPadsBack;
|
||||
OPENGL_RENDER_LIST* m_offboardPadsFront;
|
||||
OPENGL_RENDER_LIST* m_offboardPadsBack;
|
||||
MAP_OGL_DISP_LISTS m_outerLayerHoles;
|
||||
MAP_OGL_DISP_LISTS m_innerLayerHoles;
|
||||
OPENGL_RENDER_LIST* m_board;
|
||||
@@ -234,8 +235,8 @@ private:
|
||||
OPENGL_RENDER_LIST* m_padHoles;
|
||||
|
||||
// Caches
|
||||
std::map<wxString, MODEL_3D*> m_3dModelMap;
|
||||
std::map<std::vector<float>, glm::mat4> m_3dModelMatrixMap;
|
||||
std::map< wxString, MODEL_3D* > m_3dModelMap;
|
||||
std::map< std::vector<float>, glm::mat4 > m_3dModelMatrixMap;
|
||||
|
||||
BOARD_ITEM* m_currentRollOverItem;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -63,7 +63,7 @@ void POST_SHADER::UpdateSize( unsigned int xSize, unsigned int ySize )
|
||||
const unsigned int n_elements = xSize * ySize;
|
||||
|
||||
m_normals = new SFVEC3F[n_elements];
|
||||
m_color = new SFVEC4F[n_elements];
|
||||
m_color = new SFVEC3F[n_elements];
|
||||
m_depth = new float[n_elements];
|
||||
m_wc_hitposition = new SFVEC3F[n_elements];
|
||||
m_shadow_att_factor = new float[n_elements];
|
||||
@@ -77,7 +77,7 @@ void POST_SHADER::UpdateSize( const SFVEC2UI& aSize )
|
||||
|
||||
|
||||
void POST_SHADER::SetPixelData( unsigned int x, unsigned int y, const SFVEC3F& aNormal,
|
||||
const SFVEC4F& aColor, const SFVEC3F& aHitPosition,
|
||||
const SFVEC3F& aColor, const SFVEC3F& aHitPosition,
|
||||
float aDepth, float aShadowAttFactor )
|
||||
{
|
||||
wxASSERT( x < m_size.x );
|
||||
@@ -125,7 +125,7 @@ const SFVEC3F& POST_SHADER::GetNormalAt( const SFVEC2F& aPos ) const
|
||||
}
|
||||
|
||||
|
||||
const SFVEC4F& POST_SHADER::GetColorAt( const SFVEC2F& aPos ) const
|
||||
const SFVEC3F& POST_SHADER::GetColorAt( const SFVEC2F& aPos ) const
|
||||
{
|
||||
return m_color[GetIndex( aPos )];
|
||||
}
|
||||
@@ -149,13 +149,13 @@ const SFVEC3F& POST_SHADER::GetNormalAt( const SFVEC2I& aPos ) const
|
||||
}
|
||||
|
||||
|
||||
const SFVEC4F& POST_SHADER::GetColorAt( const SFVEC2I& aPos ) const
|
||||
const SFVEC3F& POST_SHADER::GetColorAt( const SFVEC2I& aPos ) const
|
||||
{
|
||||
return m_color[GetIndex( aPos )];
|
||||
}
|
||||
|
||||
|
||||
const SFVEC4F& POST_SHADER::GetColorAtNotProtected( const SFVEC2I& aPos ) const
|
||||
const SFVEC3F& POST_SHADER::GetColorAtNotProtected( const SFVEC2I& aPos ) const
|
||||
{
|
||||
return m_color[ aPos.x + m_size.x * aPos.y ];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef POST_SHADER_H
|
||||
#define POST_SHADER_H
|
||||
|
||||
#include <gal/3d/camera.h>
|
||||
#include "camera.h"
|
||||
|
||||
class POST_SHADER
|
||||
{
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
* @param aShadeColor The result of the shader.
|
||||
* @return the result of the shade process
|
||||
*/
|
||||
virtual SFVEC4F ApplyShadeColor( const SFVEC2I& aShaderPos, const SFVEC4F& aInputColor,
|
||||
virtual SFVEC3F ApplyShadeColor( const SFVEC2I& aShaderPos, const SFVEC3F& aInputColor,
|
||||
const SFVEC3F& aShadeColor ) const = 0;
|
||||
|
||||
void UpdateSize( const SFVEC2UI& aSize );
|
||||
@@ -56,10 +56,10 @@ public:
|
||||
void InitFrame() { m_tmin = FLT_MAX; m_tmax = 0.0f; }
|
||||
|
||||
void SetPixelData( unsigned int x, unsigned int y, const SFVEC3F& aNormal,
|
||||
const SFVEC4F& aColor, const SFVEC3F& aHitPosition,
|
||||
const SFVEC3F& aColor, const SFVEC3F& aHitPosition,
|
||||
float aDepth, float aShadowAttFactor );
|
||||
|
||||
const SFVEC4F& GetColorAtNotProtected( const SFVEC2I& aPos ) const;
|
||||
const SFVEC3F& GetColorAtNotProtected( const SFVEC2I& aPos ) const;
|
||||
|
||||
void DebugBuffersOutputAsImages() const;
|
||||
|
||||
@@ -88,12 +88,12 @@ public:
|
||||
|
||||
protected:
|
||||
const SFVEC3F& GetNormalAt( const SFVEC2F& aPos ) const;
|
||||
const SFVEC4F& GetColorAt( const SFVEC2F& aPos ) const;
|
||||
const SFVEC3F& GetColorAt( const SFVEC2F& aPos ) const;
|
||||
const SFVEC3F& GetPositionAt( const SFVEC2F& aPos ) const;
|
||||
float GetDepthAt( const SFVEC2F& aPos ) const;
|
||||
|
||||
const SFVEC3F& GetNormalAt( const SFVEC2I& aPos ) const;
|
||||
const SFVEC4F& GetColorAt( const SFVEC2I& aPos ) const;
|
||||
const SFVEC3F& GetColorAt( const SFVEC2I& aPos ) const;
|
||||
const SFVEC3F& GetPositionAt( const SFVEC2I& aPos ) const;
|
||||
const float& GetShadowFactorAt( const SFVEC2I& aPos ) const;
|
||||
|
||||
@@ -109,7 +109,7 @@ protected:
|
||||
|
||||
SFVEC2UI m_size;
|
||||
SFVEC3F* m_normals;
|
||||
SFVEC4F* m_color;
|
||||
SFVEC3F* m_color;
|
||||
SFVEC3F* m_wc_hitposition;
|
||||
float* m_depth;
|
||||
float* m_shadow_att_factor;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -187,21 +187,21 @@ SFVEC3F POST_SHADER_SSAO::Shade( const SFVEC2I& aShaderPos ) const
|
||||
ao += aoFF( aShaderPos, ddiff8, n, shadowAt8, shadowAt0, -npw, ph );
|
||||
|
||||
gi += giFF( aShaderPos, ddiff , n, shadowAt1, npw, nph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( npw, nph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( npw, nph ) ) );
|
||||
gi += giFF( aShaderPos, ddiff2, n, shadowAt2, npw, -nph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( npw,-nph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( npw,-nph ) ) );
|
||||
gi += giFF( aShaderPos, ddiff3, n, shadowAt3, -npw, nph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( -npw, nph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( -npw, nph ) ) );
|
||||
gi += giFF( aShaderPos, ddiff4, n, shadowAt4, -npw, -nph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( -npw,-nph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( -npw,-nph ) ) );
|
||||
gi += giFF( aShaderPos, ddiff5, n, shadowAt5 , pw, nph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( pw, nph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( pw, nph ) ) );
|
||||
gi += giFF( aShaderPos, ddiff6, n, shadowAt6, pw,-nph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( pw,-nph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( pw,-nph ) ) );
|
||||
gi += giFF( aShaderPos, ddiff7, n, shadowAt7, npw, ph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( npw, ph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( npw, ph ) ) );
|
||||
gi += giFF( aShaderPos, ddiff8, n, shadowAt8, -npw, ph) *
|
||||
giColorCurveShade( GetColorAt( aShaderPos + SFVEC2I( -npw, ph ) ) );
|
||||
giColorCurve( GetColorAt( aShaderPos + SFVEC2I( -npw, ph ) ) );
|
||||
}
|
||||
|
||||
// If it received direct light, it shouldn't consider much AO
|
||||
@@ -227,20 +227,18 @@ SFVEC3F POST_SHADER_SSAO::Shade( const SFVEC2I& aShaderPos ) const
|
||||
}
|
||||
|
||||
|
||||
SFVEC4F POST_SHADER_SSAO::ApplyShadeColor( const SFVEC2I& aShaderPos, const SFVEC4F& aInputColor,
|
||||
SFVEC3F POST_SHADER_SSAO::ApplyShadeColor( const SFVEC2I& aShaderPos, const SFVEC3F& aInputColor,
|
||||
const SFVEC3F& aShadeColor ) const
|
||||
{
|
||||
SFVEC4F outColor;
|
||||
SFVEC3F inColor( aInputColor );
|
||||
SFVEC3F outColor;
|
||||
|
||||
const SFVEC3F subtracted = inColor - aShadeColor;
|
||||
const SFVEC3F mixed = glm::mix( inColor, inColor * 0.50f - aShadeColor * 0.05f,
|
||||
const SFVEC3F subtracted = aInputColor - aShadeColor;
|
||||
const SFVEC3F mixed = glm::mix( aInputColor, aInputColor * 0.50f - aShadeColor * 0.05f,
|
||||
glm::min( aShadeColor, 1.0f ) );
|
||||
|
||||
outColor.r = ( aShadeColor.r < 0.0f ) ? subtracted.r : mixed.r;
|
||||
outColor.g = ( aShadeColor.g < 0.0f ) ? subtracted.g : mixed.g;
|
||||
outColor.b = ( aShadeColor.b < 0.0f ) ? subtracted.b : mixed.b;
|
||||
outColor.a = std::max( aInputColor.a, ( aShadeColor.r + aShadeColor.g + aShadeColor.b ) / 3 );
|
||||
|
||||
return outColor;
|
||||
}
|
||||
@@ -258,18 +256,6 @@ SFVEC3F POST_SHADER_SSAO::giColorCurve( const SFVEC3F& aColor ) const
|
||||
}
|
||||
|
||||
|
||||
SFVEC4F POST_SHADER_SSAO::giColorCurve( const SFVEC4F& aColor ) const
|
||||
{
|
||||
return SFVEC4F( giColorCurve( SFVEC3F( aColor ) ), aColor.a );
|
||||
}
|
||||
|
||||
|
||||
SFVEC3F POST_SHADER_SSAO::giColorCurveShade( const SFVEC4F& aColor ) const
|
||||
{
|
||||
return giColorCurve( SFVEC3F( aColor ) );
|
||||
}
|
||||
|
||||
|
||||
SFVEC3F POST_SHADER_SSAO::Blur( const SFVEC2I& aShaderPos ) const
|
||||
{
|
||||
const float dCenter = GetDepthAt( aShaderPos );
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user