Compare commits

..

551 Commits

Author SHA1 Message Date
Wayne Stambaugh 2c061ed67a Tag release version 6.0.4. 2022-03-17 19:33:28 -04:00
Seth Hillbrand 9bfbe3acd8 Revert "Special-case synthetic click after tool selection."
This reverts commit dd55ffb75c.
2022-03-17 16:21:39 -07:00
Seth Hillbrand 40bdd26e39 Revert "Make sure LIB_ID escape context allows for formatting constructs."
This reverts commit 02252be29d.
2022-03-17 16:21:38 -07:00
Seth Hillbrand b0f8055377 Revert "Pull some fixes back from master."
This reverts commit 5c63df28e4.
2022-03-17 16:21:37 -07:00
Seth Hillbrand 33f4fc9873 Revert "Improved performance for Cleanup Tracks & Vias."
This reverts commit 14378812be.
2022-03-17 16:21:34 -07:00
Jeff Young c90842dd08 Update value & footprint from clipboard whether keeping annotation or not.
Fixes https://gitlab.com/kicad/code/kicad/issues/11116

(cherry picked from commit 400cff994d)
2022-03-17 22:34:52 +00:00
Jeff Young 310b4cdf75 Re-entrancy blocker for line/wire/bus tool.
Also clear infobar messages after a cancelInteractive.

Fixes https://gitlab.com/kicad/code/kicad/issues/11155

(cherry picked from commit 05bca282f7)
2022-03-17 22:34:52 +00:00
Seth Hillbrand 2208e0db16 Avoid marking symbols that will not be processed
We want to shorting the processing time by marking symbols that have
already been processed.  But we must avoid marking symbols that will not
be processed due to their other flags

Fixes https://gitlab.com/kicad/code/kicad/issues/11164
2022-03-17 10:10:21 -07:00
jean-pierre charras cf4c403094 Gerber plotter: fix incorrect handling of arcs in polygons.
From master branch.
Fixes #11156
https://gitlab.com/kicad/code/kicad/issues/11156
2022-03-17 13:06:37 +01:00
Jeff Young dd55ffb75c Special-case synthetic click after tool selection.
Fixes https://gitlab.com/kicad/code/kicad/issues/11057

(cherry picked from commit 1f745b000d)
2022-03-16 17:11:07 +00:00
Jeff Young d34faf30cc Save pointer to markers provider.
Fixes https://gitlab.com/kicad/code/kicad/issues/11136

(cherry picked from commit a81c8d4922)
2022-03-16 16:23:10 +00:00
Jeff Young 3720a52ecb Bubble ESC up from the 3D preview.
Fixes https://gitlab.com/kicad/code/kicad/issues/9984

(cherry picked from commit 32fdab8902)
2022-03-16 16:21:24 +00:00
Jeff Young 47de9f8f04 Fix typo which leads to catastrophic performance on boards with tons of zones.
(cherry picked from commit 392a3ec131)
2022-03-16 15:16:11 +00:00
Jeff Young 14378812be Improved performance for Cleanup Tracks & Vias. 2022-03-16 15:15:20 +00:00
Jeff Young 0070a4686e Cherry-pick the short-arc-is-really-a-segment fix from master.
Fixes https://gitlab.com/kicad/code/kicad/issues/11119
2022-03-16 15:15:15 +00:00
Jeff Young 5c63df28e4 Pull some fixes back from master.
Mostly wxT(), but also some performance, and some for better response
to Cancel button.
2022-03-16 15:15:09 +00:00
Jeff Young e5ea37507c Exclude hidden text from selection in FP Editor.
Fixes https://gitlab.com/kicad/code/kicad/issues/11111

(cherry picked from commit 06c1bccccd)
2022-03-16 15:15:01 +00:00
Jeff Young 53bd87d792 Performance fixes for the board from hell....
(cherry picked from commit e4b56ab7f1)
2022-03-16 15:14:51 +00:00
Jeff Young 02252be29d Make sure LIB_ID escape context allows for formatting constructs.
Also make sure that value field is updated from name changes when the
symbol is a power symbol (even if it's from the schematic instead of
the library).

Fixes https://gitlab.com/kicad/code/kicad/issues/11093

(cherry picked from commit a9eb7a0e28)
2022-03-16 15:14:29 +00:00
Wayne Stambaugh 9e9598af5f Begin version 6.0.4 development. 2022-03-15 20:14:40 -04:00
Wayne Stambaugh 9dc35b575c Tag release version 6.0.3. 2022-03-15 20:06:04 -04:00
Wayne Stambaugh 3cd24f656b Correct sheet schematic import from different project warning file name. 2022-03-15 18:21:47 -04:00
Marco Ciampa 73eac90922 Updated Italian translation 2022-03-15 20:36:19 +01:00
Marco Ciampa 70e5c9f7c6 Updated Italian translation 2022-03-15 20:21:04 +01:00
Marco Ciampa d820a7fe42 Updated Italian translation 2022-03-15 19:12:11 +01:00
Jeff Young b9d7a0565f Hand cherry-pick fixes from master.
https://gitlab.com/kicad/code/kicad/-/commit/0a8718cd1d62a40ea9094b773fb6caf56a695a05
https://gitlab.com/kicad/code/kicad/-/commit/7fb4a2c0a53089439ef3c31800bc310bc7c8a6ba
2022-03-15 13:19:12 +00:00
jean-pierre charras ad2486b09f Fix a incorrect filename in a copy command (MSW specific).
Also fix a regression and respect the KICAD_BUILD_QA_TESTS build option.
2022-03-14 21:14:04 -04:00
Marek Roszko 4742043a7e Extend manifest product version to include minor 2022-03-14 20:34:23 -04:00
Marek Roszko 9e56c7e5c9 Stuff a resource manifest into the kipython kiface 2022-03-14 20:32:29 -04:00
Marek Roszko 674fbfa889 Switch the kiface extension on windows to native dll
Fixes issue where Windows really wants to see the DLL extension to load the resource metadata
2022-03-14 20:23:37 -04:00
Seth Hillbrand ae1cc29dc6 Revert "Move connected_items from hash table to tree"
This reverts commit 187aa1c171.
2022-03-14 17:22:44 -07:00
jean-pierre charras f1c772ba55 Try to blindly fix a QA test issue. 2022-03-14 20:39:34 +01:00
jean-pierre charras 6f6505f6a1 Fix crash in SCH_LABEL_BASE::IsType() when the item is not living in a schematic.
It happens for instance when copying the item from the clipboard.
From master branch.
Fixes #11128
2022-03-14 09:36:10 +01:00
Marek Roszko af4a4cbc08 Don't use wxScreenDC as this returns "a" screen but not "the" screen
Windows supports per-monitor and per-app DPI. wxScreenDC is unable to resolve the actual DPI setting since it has no window context.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10681


(cherry picked from commit 605dd8a580)
2022-03-14 03:32:04 +00:00
Marek Roszko 40462012ee Don't pre-scale the line width
Fixes https://gitlab.com/kicad/code/kicad/-/issues/11122


(cherry picked from commit d74a0cdaa3)
2022-03-14 03:09:23 +00:00
jean-pierre charras 70514be11f Fix CMakeLists.txt syntax error and msys2 compatibility. 2022-03-13 12:50:26 +01:00
Marek Roszko 7558dad915 Don't use the ANSI version of SetDllDirectory 2022-03-12 21:45:14 -05:00
Marek Roszko 5e9b982ddf Plant the ability to verify code signing signatures when trying to load kifaces
Off by default and intended for use in released builds only
2022-03-12 21:44:36 -05:00
Marek Roszko 17539a564e Two very minor win32 calls to lock down dll/exe search paths from cwd 2022-03-12 15:47:48 -05:00
Marek Roszko 43aa0bfdc3 Tweak the "pyd" extension if for windows to be completely inclusive 2022-03-12 15:47:48 -05:00
Marco Ciampa 7ab4bf3823 Small fix in Italian translation 2022-03-12 17:47:54 +01:00
Marek Roszko ae01dc8ef1 Set SetErrorMode on Debug build
(cherry picked from commit d3ca857af7)
2022-03-12 01:57:45 +00:00
Seth Hillbrand 187aa1c171 Move connected_items from hash table to tree
This gains about 10% speed in heavily connected sheets

Fixes https://gitlab.com/kicad/code/kicad/issues/10974
2022-03-11 16:19:03 -08:00
Seth Hillbrand 17b1b68ac7 Break up buildConnectionGraph for debugging
Needed to find bottlenecks in fns, so break out individual sections of
the massive function for easier understanding.

buildItemSubgraphs (one section of the previous function) would build
millions of connections that were never used as stacked pins created X!
connections.  Also tested using sets instead of lists and keeping unique
lists to avoid flagging but none of these were as performant as using
flags to remember which items had already been processed.

Fixes https://gitlab.com/kicad/code/kicad/issues/10974
2022-03-11 16:18:56 -08:00
Wayne Stambaugh 35f15f016d Improve shared schematic file churn heuristics.
The previous solution cleared all of the fields and force the unit setting
to unit one which would have less than desirable effects when reusing a
schematic in another project.  This solution forces all of the instance
settings to the first sheet instance of the current project to prevent file
change churn when changing shared sheets in the current project.

This will not prevent shared schematic file changes when the first sheet
instance data differs between projects.

(cherry picked from commit dd1dbb81f6)
2022-03-11 14:34:30 -05:00
Wayne Stambaugh 70277e5514 Reduce shared schematic file change churn.
(cherry picked from commit bf5d585e24)
2022-03-11 14:34:04 -05:00
Marek Roszko 2874688281 Set some error flags for win32
(cherry picked from commit afaff022d7)
2022-03-11 01:17:50 +00:00
Seth Hillbrand 826096790d Cleanup a few more raw strings
(cherry picked from commit 455e330f3b)
2022-03-10 11:23:19 -08:00
Seth Hillbrand a2e66f6667 Don't write bytecode on MacOS
MacOS packages are signed and checked on each run.  Since Python lives
inside the package, adding byte code will break the package signature

(cherry picked from commit 5881471a52)
2022-03-10 11:23:19 -08:00
Jeff Young c241032a3b Redraw pads when mask or paste layer is visible after board setup.
Fixes https://gitlab.com/kicad/code/kicad/issues/11079
2022-03-10 17:54:38 +00:00
Seth Hillbrand 9ca35cbcee Rework of a24cdcb3f0
Inflate with linked holes needs to account for fractured polygons,
otherwise inflating with positive value will create rounded divots where
overlapping fracture lines meet and inflating with negative value will
create spaces between fracture lines.

Calling Simplify before Inflate takes an inordinate amount of time as
the Clipper healing routine is rather slow.  Our own Unfracture is meant
to heal the results of our Fracture routine and works much more quickly.
After healing, we still call the Simplify routine
2022-03-10 09:14:13 -08:00
Jon Evans 9c386026a8 Use actual project path when saving project
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10540
2022-03-10 09:08:20 -05:00
Marek Roszko 012a9bb7cb Don't forget to cache bust oce
(cherry picked from commit 25507ad6cf)
2022-03-10 02:39:42 +00:00
Marek Roszko 563aa3ed74 Avoid loading duplicate shapes due to hierarchy structure
Fix https://gitlab.com/kicad/code/kicad/-/issues/9416
Fix https://gitlab.com/kicad/code/kicad/-/issues/6107


(cherry picked from commit 2de4906d65)
2022-03-10 02:39:35 +00:00
Seth Hillbrand e8ef863861 Remove double-call of settings from Netlister
Double-calls are no longer needed when using settings.  They can
interfere depending on how the system executes the commands.

Removing keeps the last used plugin as the default, rather than the last
selected

Fixes https://gitlab.com/kicad/code/kicad/issues/11094
2022-03-09 17:12:18 -08:00
Seth Hillbrand a24cdcb3f0 Always return simplified polygons
Clipper can handle complex input polygons but we will sometimes struggle
dealing with outputs from the inflate routine that have degenerate or
overlapping points.  Calling Simplify after the inflate keeps our
polygons easier to handle

Fixes https://gitlab.com/kicad/code/kicad/issues/11036
2022-03-09 16:19:15 -08:00
Seth Hillbrand 5314ba6440 Avoid implementation dependent on events
Adding a page in the ctor can generate events that change the default
page.  Instead, we set the default after all pages have been added,
avoiding the reset

Fixes https://gitlab.com/kicad/code/kicad/issues/10910
2022-03-09 15:41:38 -08:00
Marek Roszko c465a6ebc7 Add some more reserves for string funcs
(cherry picked from commit 2df80c6473)
2022-03-09 16:45:28 +00:00
Marek Roszko 4e5038eb3e Try and reduce memory allocs when (un)escaping strings
(cherry picked from commit ca5049b6bc)
2022-03-09 16:45:02 +00:00
Jeff Young 2372359aaa Don't kill entire OpenGL cache on undo.
The comment regarding bitmaps was true for one more month in 2018, but
hasn't been true for the last 3 years, and clearing the cache is a huge
performance hit.

(cherry picked from commit d58427a519)
2022-03-09 15:06:40 +00:00
Jeff Young 5e0251c2ba Natural sorting for nets.
Fixes https://gitlab.com/kicad/code/kicad/issues/10534

(cherry picked from commit 96f9ea286e)
2022-03-09 14:37:46 +00:00
Jeff Young fd5eeceb4f Reentrancy block for symbol editor symbol properties dialog.
Fixes https://gitlab.com/kicad/code/kicad/issues/11060

(cherry picked from commit d3716b9956)
2022-03-09 14:35:47 +00:00
Seth Hillbrand da480aba47 Fix one more test case for arc approx 2022-03-08 12:36:08 -08:00
Seth Hillbrand 63f4f42e6a Fix testcases for arc rounding 2022-03-08 11:36:35 -08:00
Seth Hillbrand 8d246dbee0 We're not c++20 yet
Remove designated initializers
2022-03-08 11:08:41 -08:00
Seth Hillbrand 79517e44ce Fix QA for arc/arc collisions
We no longer need the arbitary offset when we are calculating collisions
based on values that are not nm off from a "round" value.

(cherry picked from commit 2200c1319d)
2022-03-08 10:37:04 -08:00
Seth Hillbrand a940607524 Adds uncertainty propagation to center point calc
Since we use center points to move back and forth for angle and
adjustments, we want to ensure that our center point is stable.

Rounding using integers introduces a 0.5 int uncertainty in each
measurement.  These are combined together multiple times to calculate
the center point, which combines the uncertainty.  Propagating the
uncertainty to the final calculation allows us to assign a range of true
values and pick the value that is most likely the correct value.

Fixes https://gitlab.com/kicad/code/kicad/issues/10739

(cherry picked from commit ed7222b1e7)
2022-03-08 10:34:41 -08:00
Seth Hillbrand 0cf1a67e29 Cache read arc data for stability
Arcs can be altered by the process of changing from on-disk
representation to in-memory representation.  Saving back to disk without
modifying the arc should not modify the calculated values.

This stores a copy of the on-disk representation that is only used to
save back to disk in the event that the arc is not modified during
editing.

Fixes https://gitlab.com/kicad/code/kicad/issues/10442

(cherry picked from commit cd7141fd10)
2022-03-08 10:33:49 -08:00
Seth Hillbrand f4cdb97141 Normalize IsInsideCourtyard
(cherry picked from commit c18d9b9baf)
2022-03-08 10:07:59 -08:00
Seth Hillbrand 0cfa88ca9a Move temp save files to temporary directory
Avoid excess writes to the project directory to dodge issues with remote
file systems not fully writing data.

wxRename works across disk boundaries (in theory) and falls back to
wxCopy/wxRemove when it fails

Fixes https://gitlab.com/kicad/code/kicad/issues/10747
2022-03-08 10:05:04 -08:00
Mike Williams 2535237c31 Schematic: breaking wire needs different drag parameters
Our heuristics for determining when to append to the undo aren't
sufficient for the two segments of a broken wire. One is new and the
other is changed, but the drag should be appended to the current undo.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10865
2022-03-08 18:00:46 +00:00
Marco Ciampa 4c86a5ce64 Updated Italian translation 2022-03-08 16:04:39 +01:00
jean-pierre charras c75c7d084a plot_board_layers.cpp: Add missing layers (USer_x) in list
Fixes #11072
https://gitlab.com/kicad/code/kicad/issues/11072
2022-03-08 14:44:53 +01:00
jean-pierre charras dd154c155f pcbnew: Fix Bezier "Add Primitive" in Pad Creation Dialog (From master branch) 2022-03-08 14:44:05 +01:00
Seth Hillbrand 0838543745 Fix cherry-pick error 2022-03-07 19:53:01 -08:00
Seth Hillbrand bd1f01f7ee Update Translations 2022-03-07 16:52:14 -08:00
Henrik Kauhanen 8ab1d91f3c Translated using Weblate (Swedish)
Currently translated at 99.5% (7178 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-03-08 01:49:49 +01:00
Konstantin Baranovskiy 35a7490342 Translated using Weblate (Russian)
Currently translated at 100.0% (7210 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ru/
2022-03-08 01:49:49 +01:00
Henrik Kauhanen d0314aab88 Translated using Weblate (Finnish)
Currently translated at 87.3% (6296 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/fi/
2022-03-08 01:49:49 +01:00
Ulices 812aba6065 Translated using Weblate (Spanish (Mexico))
Currently translated at 100.0% (7210 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/es_MX/
2022-03-08 01:49:49 +01:00
Mark Hämmerling 6abcfeeb0f Translated using Weblate (German)
Currently translated at 100.0% (7210 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-03-08 01:49:49 +01:00
Radek K 703b18519f Translated using Weblate (Czech)
Currently translated at 91.4% (6594 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-03-08 01:49:48 +01:00
Arnau Llovet Vidal 1199af0d52 Translated using Weblate (Catalan)
Currently translated at 65.2% (4706 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-03-08 01:49:48 +01:00
taotieren 2f1ebebba3 Translated using Weblate (Chinese (Traditional))
Currently translated at 99.5% (7179 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hant/
2022-03-08 01:49:48 +01:00
taotieren 19f4852280 Translated using Weblate (Chinese (Simplified))
Currently translated at 99.9% (7209 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-03-08 01:49:48 +01:00
Tian Yunhao 0be07689a7 Translated using Weblate (Chinese (Simplified))
Currently translated at 99.9% (7209 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-03-08 01:49:48 +01:00
lê văn lập f227ccfd5d Translated using Weblate (Vietnamese)
Currently translated at 18.2% (1315 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/vi/
2022-03-08 01:49:48 +01:00
ZbeeGin fd9804a3dc Translated using Weblate (Polish)
Currently translated at 100.0% (7210 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pl/
2022-03-08 01:49:48 +01:00
김랑기 502f2dab11 Translated using Weblate (Korean)
Currently translated at 100.0% (7210 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ko/
2022-03-08 01:49:48 +01:00
Mark Hämmerling 8e46ae5ce8 Translated using Weblate (German)
Currently translated at 100.0% (7210 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-03-08 01:49:48 +01:00
Jan Straka 8a863cdf54 Translated using Weblate (Czech)
Currently translated at 91.4% (6590 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-03-08 01:49:48 +01:00
Arnau Llovet Vidal 493e733f0c Translated using Weblate (Catalan)
Currently translated at 64.9% (4685 of 7210 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-03-08 01:49:48 +01:00
Seth Hillbrand 38ac1b2f2d Fix the order of evaluation in the arc printing
MapAngles will adjust by small amounts the angles t1 and t2.  This
adjustment will determine the CW/CCW drawing.  Therefore, the MapAngles
needs to be called explicitly before the Normalize180() call.
Left-to-Right evaluation is not a given for MSVC

Fixes https://gitlab.com/kicad/code/kicad/issues/11050

(cherry picked from commit c9fb95b888)
2022-03-07 16:48:09 -08:00
Jon Evans 1394509734 Settings: allow multiple project access from Python standalone
We can't handle this in the UI, but we can externally, so allow
it for Python scripting and eventually we'll use this in the UI
also...

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10540
2022-03-05 12:50:45 -05:00
Jeff Young 1ffe0da204 Improvements for pads/vias in zones which knockout other zones.
1) Drop tiny islands which might cause connection problems.
2) Cleanup some dead code in filler
3) Don't estabilish a connection to an island that is fully covered
by whatever its connecting to.

Fixes https://gitlab.com/kicad/code/kicad/issues/11036
2022-03-05 15:40:30 +00:00
Jeff Young 46d423a164 Must clear arcs before calling Clipper. 2022-03-05 15:40:30 +00:00
Seth Hillbrand 7aebc4b11f Change connectivity item group from set to vector
Reserve space for new items to speed construction of connectivity graph

Fixes https://gitlab.com/kicad/code/kicad/issues/10974
2022-03-05 13:14:52 +00:00
Seth Hillbrand c1dcfdffb1 Remove unneeded condition to rotate
The condition that the board must have elements on it before allowing
the rotate command is invalid as we allow rotating new elements before
placement

Fixes https://gitlab.com/kicad/code/kicad/issues/10581
2022-03-03 15:44:50 -08:00
Jeff Young 191558e2d7 Reimplementation of 513486b0ec.
(For https://gitlab.com/kicad/code/kicad/-/issues/11020.)
2022-03-03 23:29:22 +00:00
Jeff Young 912c2eac09 Make LIB_ITEM::COMPARE_FLAGS really a flags field, and add ERC.
Before they were 1/2 treated as flags and 1/2 treated as a mode enum.

The ERC flag relaxes constraints on data that is settable in the
schematic editor.

Fixes https://gitlab.com/kicad/code/kicad/issues/11018

(cherry picked from commit 76535d8572)
2022-03-03 23:29:22 +00:00
Seth Hillbrand 802d20c409 Duplicate from selected or current
When double-clicking to open a symbol, it is no longer selected in the
tree.  We need to use the `GetTargetLibId()` to pick the correct symbol
(first selected, then current) when using the duplicate command

Fixes https://gitlab.com/kicad/code/kicad/issues/11034
2022-03-03 15:20:30 -08:00
Seth Hillbrand 8f75841c85 Check for additional connections between tracks
Prevents removal when a track is connected not just to other tracks but
also other connected items

Fixes https://gitlab.com/kicad/code/kicad/issues/10916

(cherry picked from commit 9d927f3135)
2022-03-03 13:08:37 -08:00
jean-pierre charras c3f8d8b5a1 FP_TEXT::ViewGetLOD() fix incorrect test (LAYER_MOD_VALUES color has no matter)
Fixes #11026
https://gitlab.com/kicad/code/kicad/issues/11026
Fixes #11028
2022-03-03 11:59:03 +01:00
Seth Hillbrand 79b6991d7b Fix broken unit select context menu
The fix for https://gitlab.com/kicad/code/kicad/issues/10529 kicked the
subsequent IDs for unit selection off the maximum ID value for popup
menus.  This increases the maximum popup number (integers are free)
2022-03-02 16:32:04 -08:00
Seth Hillbrand 17dc324e85 Explicitly give unit values
Removes the ability to hide symbol units in file formats.  This was
mostly the case for a while but there remained corner cases where we
left a default/hidden option

Fixes https://gitlab.com/kicad/code/kicad/issues/10888

(cherry picked from commit 8c36ba3653)
2022-03-02 16:04:03 -08:00
Seth Hillbrand 23479821e3 Fix issue with 9396735733
Need to select unconditionally target layer if not on copper
2022-03-02 10:46:59 -08:00
Seth Hillbrand 9396735733 Select the copper layer before processing
If we are converting to tracks, the copper layer needs to be selected
before any other elements are processed, otherwise, we end up with the
default undefined layer

Fixes https://gitlab.com/kicad/code/kicad/issues/11025
2022-03-02 10:17:16 -08:00
Seth Hillbrand 901c330478 Update end item before moving on track/via change
The move even dereferences m_enditem for logging and perhaps other
actions.  We need to ensure that the end item has not been invalidated
before taking this action

Fixes https://gitlab.com/kicad/code/kicad/issues/10732
2022-03-02 09:21:52 -08:00
Jeff Young 354c320329 Make sure Cleanup handles shapes other than segments.
Fixes https://gitlab.com/kicad/code/kicad/issues/10955
2022-03-02 15:26:02 +00:00
Jeff Young 0ea559e3b8 Reconcile two different printing bug fixes.
https://gitlab.com/kicad/code/kicad/-/commit/a9f092b3706d65ddcf1ecfb34ef1559877524862
https://gitlab.com/kicad/code/kicad/-/commit/6f5cb1f97d95ad893744cdcb47115ca0fb1db438

Fixes https://gitlab.com/kicad/code/kicad/issues/11004

(cherry picked from commit c4143b0ff6)
2022-03-02 12:07:43 +00:00
Jeff Young 6fd898d1b3 Be more careful about non-visible elements in fields autoplacer.
Fixes https://gitlab.com/kicad/code/kicad/issues/10774

(cherry picked from commit f241617478)
2022-03-02 12:07:43 +00:00
Jeff Young d20c2fe5c5 High-contrast mode: don't render vias that don't cross high-contrast layer.
Fixes https://gitlab.com/kicad/code/kicad/issues/8740

(cherry picked from commit bbfbfc2cd2)
2022-03-02 12:07:43 +00:00
Jeff Young 3585c184cc Pull bug fixes back from master.
Fixes https://gitlab.com/kicad/code/kicad/issues/11007
2022-03-02 12:07:43 +00:00
Seth Hillbrand 429544c188 Handle locally-coded file names for sheets
Windows can accidentally create forward slash-coded files.  This simply
converts them to the proper unix-coded value when set

Fixes https://gitlab.com/kicad/code/kicad/issues/10964
2022-03-01 17:21:16 -08:00
Seth Hillbrand 8385ce3021 Ensure fields are properly ordered
When reading sheet fields, we need to maintain a consistent order for
the mandatory fields as they are dereferenced by place.  We force this
during the `SetFields()` call.
2022-03-01 17:08:54 -08:00
Seth Hillbrand 0b98acfe12 Freeze TEDIT in place
Avoids updating the TEDIT field, preventing merge conflicts and unneeded
VCS cruft
2022-03-01 15:53:07 -08:00
Seth Hillbrand acb5ce7108 Resolve text when requested
Getting resolved text for a symbol should always happen, even if we have
unresolved data in the instances

Fixes https://gitlab.com/kicad/code/kicad/issues/11003
2022-03-01 15:10:41 -08:00
Seth Hillbrand 63b06af6b1 Avoid resolving text vars without screen
We need to keep the screen blank while initially loading a sheet before
the hierarchy is developed.  Avoid resolving text variables during this
process

Fixes https://gitlab.com/kicad/code/kicad/issues/11000
2022-02-28 12:27:38 -08:00
jean-pierre charras e5a85b107f Gerber plotter: fix broken plot of SHAPE_LINE_CHAIN with arcs.
Also simplify SHAPE_T::POLY plot.
From Master branch.
2022-02-28 18:26:26 +01:00
jean-pierre charras e2982a0e47 svg importer: fix a crash when importing some files with no graphic item 2022-02-28 18:26:24 +01:00
Jeff Young 5396bb970f Don't rename archives when doing a project save-as.
Fixes https://gitlab.com/kicad/code/kicad/issues/10184
2022-02-27 20:15:27 +00:00
Jeff Young d4937f1b3e Don't allow break commands (or labelling cmds) on multiple wire selections.
Fixes https://gitlab.com/kicad/code/kicad/issues/10934
2022-02-27 20:14:56 +00:00
Jeff Young 1c6f3f8f0d Drop a knee between tracks to a single item when dragging.
This prevents the disambiguation menu from coming up when we don't
really care which element we start the drag on.

Fixes https://gitlab.com/kicad/code/kicad/issues/10745

(cherry picked from commit ae85f57577)
2022-02-27 18:20:25 +00:00
Jeff Young 6341548939 Infobar warning if symbol loading was cancelled.
Also makes sure the progress dialog is closed when we're done reading
symbols (it used to stay up for much of the symbol editor initialization).

Also makes sure that any cancel in the preLoad step is honoured in the
sync step.  (The preload is done because it is multi-threaded and therefore
faster than the single-threaded sync.)

Also makes sure that individual threads pay attention to the cancellation,
not just the GUI thread.

Fixes https://gitlab.com/kicad/code/kicad/issues/8372

(cherry picked from commit 1f16092e29)
2022-02-27 18:20:25 +00:00
jean-pierre charras a91dd68444 FP editor: fix crash when trying to export a footprint to the board editor.
From Master branch.
2022-02-27 08:41:36 +01:00
Jeff Young a8175f49a6 Repair tab order in Footprint Properties dialog.
Fixes https://gitlab.com/kicad/code/kicad/issues/10978

(cherry picked from commit 2c6a2c3479)
2022-02-26 17:42:02 +00:00
jean-pierre charras 05110b7bdc DIALOG_BOARD_STATISTICS: Reset the drill count list before recalculations.
Fixes #10984
https://gitlab.com/kicad/code/kicad/issues/10984
2022-02-26 17:11:45 +01:00
jean-pierre charras aadcc43dbb APPEARANCE_CONTROLS: fix missing update when toggling a layer view.
Fixes #10977
https://gitlab.com/kicad/code/kicad/issues/10977
2022-02-26 10:40:47 +01:00
Seth Hillbrand ff6f398607 Handle list double-click without shortcuts
The LIST_DCLICK event can be fired by spacebar or enter in GTK.  This
conflicts with using the spacebar to reset local coordinates.  Instead,
we capture the double-click event manually to add the footprint to the
board

Fixes https://gitlab.com/kicad/code/kicad/issues/5714

Fixes https://gitlab.com/kicad/code/kicad/issues/10633
2022-02-25 16:53:03 -08:00
Seth Hillbrand a30ad0b54a Honor modifier keys in diambiguation
Needs to be reset for the new action before selecting elements at a
point.

Fixes https://gitlab.com/kicad/code/kicad/issues/9712
2022-02-25 16:15:56 -08:00
Steffen Mauch ab835937a7 Fixing Eagle refs that do not work with KiCad
KiCad has stricter requirements for what consititutes an annotated
symbol.  This checks for and corrects annotations that begin with '#',
do not begin with a non-numeric character or do not end with a number

(cherry picked from commit 78620347c8)

Fixes https://gitlab.com/kicad/code/kicad/issues/10760
2022-02-25 15:45:30 -08:00
Jeff Young b17eb3a584 Connectivity rebuild must be done after commit push.
Fixes https://gitlab.com/kicad/code/kicad/issues/10608
2022-02-25 23:15:44 +00:00
Jeff Young 9c2bc98fd3 On-the-fly translations for Grid and Zoom menus.
Fixes https://gitlab.com/kicad/code/kicad/issues/10961

(cherry picked from commit 107067ad05)
2022-02-25 22:02:51 +00:00
Jeff Young 96bd27ef0f Initial focus for Get and Place Footprint.
Fixes https://gitlab.com/kicad/code/kicad/issues/10230

(cherry picked from commit 714c65275c)
2022-02-25 22:02:43 +00:00
Seth Hillbrand 23351b2046 Add MRU to image placement tools
(cherry picked from commit faa3829ad4)
2022-02-25 13:21:25 -08:00
Seth Hillbrand 69bd4218f7 Update Translations 2022-02-25 11:59:49 -08:00
Benedikt Freisen f27f001fcb Translated using Weblate (German)
Currently translated at 100.0% (7211 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-25 20:58:02 +01:00
Axel Henriksson be772ecd18 Translated using Weblate (Swedish)
Currently translated at 99.5% (7175 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-25 20:58:01 +01:00
Henrik Kauhanen 48ba236851 Translated using Weblate (Swedish)
Currently translated at 99.5% (7175 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-25 20:58:01 +01:00
Arnau Llovet Vidal 5120566c77 Translated using Weblate (Catalan)
Currently translated at 64.8% (4678 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-25 20:58:01 +01:00
Jakub Janek 7789857e30 Translated using Weblate (Slovak)
Currently translated at 75.3% (5430 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sk/
2022-02-25 20:58:01 +01:00
ZbeeGin 89d85800ab Translated using Weblate (Polish)
Currently translated at 100.0% (7211 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pl/
2022-02-25 20:58:01 +01:00
Jan Straka 43dcf09747 Translated using Weblate (Czech)
Currently translated at 91.0% (6567 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-02-25 20:58:01 +01:00
Eric a372594dea Translated using Weblate (Chinese (Simplified))
Currently translated at 99.9% (7210 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-25 20:58:01 +01:00
Henrik Kauhanen 414e6dc43e Translated using Weblate (Swedish)
Currently translated at 99.0% (7145 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-25 20:58:01 +01:00
Wellington Terumi Uemura f34d146c38 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (7211 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pt_BR/
2022-02-25 20:58:01 +01:00
Mark Hämmerling d9f5d1d865 Translated using Weblate (German)
Currently translated at 100.0% (7211 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-25 20:58:01 +01:00
Arnau Llovet Vidal b15d6bd10a Translated using Weblate (Catalan)
Currently translated at 61.3% (4421 of 7211 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-25 20:58:01 +01:00
Seth Hillbrand 54f621c570 Use board polygon instead of bbox for size
Board BBox uses the visible size of the board, which includes edge cut
thickness.  This is not appropriate for the Board characteristics.
Using the outline polygon gives accurate results and falls back to a
bounding box in the case where the outline is invalid

Fixes https://gitlab.com/kicad/code/kicad/issues/10972
2022-02-25 11:13:01 -08:00
Seth Hillbrand d29d981784 Avoid overflow in textbox
Count() returns unsigned values.  Since, we subtract 1 from this value,
if the count is 0, we will underflow the unsigned value, creating an
extremely large value that we multiply by the interline spacing.
2022-02-25 11:11:29 -08:00
jean-pierre charras 3801a8adc0 Eeschema: ensure ERC exclusions list is up to date before saving it in *.kicad_pro
Fixes #10339
From master branch
2022-02-25 18:26:48 +01:00
Mike Williams 7d4cb91f39 Schematic: disallow center rotation, allow both endpoint rotations
Center rotation will often misalign lines to the grid, which is bad
until fix off grid items on the schematic.

We can rotate a connection end into a new connection or to become
collinear with an existing line, so we need to check for this at the end
of rotation.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10565
2022-02-25 16:27:55 +00:00
jean-pierre charras 0f497d1b7a Fix incorrect conversion from lines to rect in fp editor.
Fixes #10965
https://gitlab.com/kicad/code/kicad/issues/10965
2022-02-25 13:50:57 +01:00
Jeff Young 5f1976f341 fixup! Better DRC checking when placing vias. 2022-02-25 10:40:05 +00:00
Jeff Young 6036331b25 Debounce layer visibility buttons and fix issues with FP Editor.
(cherry picked from commit cb16ad7557)
2022-02-25 10:40:05 +00:00
Jeff Young 5129143bcb Layer visibilities aren't stored in project for footprint editor.
Fixes https://gitlab.com/kicad/code/kicad/issues/10953

(cherry picked from commit 5c54f40eae)
2022-02-25 10:40:05 +00:00
Jeff Young d7d31e4b76 Implement multi-layer stitching via logic.
(cherry picked from commit d65f9ad2d8)
2022-02-25 10:40:05 +00:00
Jeff Young b00f855c26 Better DRC checking when placing vias.
(cherry picked from commit 369f53bb19)
2022-02-25 10:40:05 +00:00
Jeff Young 4b0177c8fe Handle hidden layers in FP Editor.
Fixes https://gitlab.com/kicad/code/kicad/issues/10946

(cherry picked from commit 08df5c0b01)
2022-02-25 10:40:05 +00:00
Jeff Young b11ec85706 Copy Pad_Master when copying BOARD_DESIGN_SETTINGS.
Fixes https://gitlab.com/kicad/code/kicad/issues/10932

(cherry picked from commit d2069e1548)
2022-02-25 10:40:05 +00:00
Seth Hillbrand de48f41184 Fix wxT commit
Fixes https://gitlab.com/kicad/code/kicad/issues/10967
2022-02-24 17:00:10 -08:00
Greg Davill 55bdef9bd2 action_plugin: Remove duplicated entry in UndoList
(cherry picked from commit 429c311ec3)
2022-02-24 14:46:13 -08:00
Jeff Young 5cc2bef954 Formatting. 2022-02-22 13:48:20 +00:00
aris-kimi 8ce9f08268 Update year
Fixes https://gitlab.com/kicad/code/kicad/issues/10842
2022-02-21 22:21:31 +00:00
Jeff Young 6ccaf5e27d Flip all layers of a zone.
Fixes https://gitlab.com/kicad/code/kicad/issues/10621
2022-02-21 22:02:19 +00:00
Jeff Young a24912d01d A bit of safety. 2022-02-21 22:02:19 +00:00
Marek Roszko 8ad0f24031 Simplify locale data path setting... 2022-02-21 13:13:37 -05:00
Jeff Young 2498655cc5 Respect ERROR_OUTSIDE when inflating polygons.
Fixes https://gitlab.com/kicad/code/kicad/issues/10896

(cherry picked from commit e6c617b74d)
2022-02-21 17:32:25 +00:00
Marek Roszko b2ac4b2c65 Simplify KICAD6_TEMPLATE_DIR default
The search_stack method is bugland

Fix https://gitlab.com/kicad/code/kicad/-/issues/10119


(cherry picked from commit ad251b7b8c)
2022-02-21 17:23:07 +00:00
Mike Williams 899c2d9080 Schematic: handle switching h/v mode better while drawing lines
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10859
(cherry picked from commit e35c3f2b99)
2022-02-21 12:06:12 -05:00
Jeff Young b4ac59d9d3 Don't crash on highight net during drag.
Fixes https://gitlab.com/kicad/code/kicad/issues/10866
2022-02-21 12:25:55 +00:00
Jeff Young a5305aa235 A more discerning un-flashed-connectivity test.
(cherry picked from commit aa2c8e9b0c)
2022-02-21 11:20:48 +00:00
Tomasz Wlostowski 680163f8a8 Cherry-pick commits from Master and about SVG import:
*Fixes in the SVG import polygon postprocessing:
- don't drop subsequent polys when a non-filled primitive is imported 'in between'
- fix missing holes (also related to the interleaving of stroke and filled shapes, depending on the software that wrote the SVG file)

*GRAPHICS_IMPORTER_BUFFER: forgot to store the indices of the paths belonging to a compound shape

*pcbnew: GRAPHICS_IMPORTER can now recognize multi-path shapes (and postprocess polygons with holes into Kicad-compatible fractured polysets)

*SHAPE_POLY_SET: polysets can now be built from a bunch of arbitraily ordered oriented outlines.
Used by the SVG hole support

*SVG_IMPORT_PLUGIN: enable postprocessing of polygons with degeneracy and holes

*pcbnew: SVG importer support for even-odd fill rule
2022-02-21 10:50:05 +01:00
Marek Roszko 0fdd1df208 Update Copyright on win32 manifests
(cherry picked from commit 46d719ed42)
2022-02-21 03:22:16 +00:00
Marek Roszko 9367b7f309 Fix double parsing solids from step models resulting in triangle z-fighting
Fix https://gitlab.com/kicad/code/kicad/-/issues/9416
Fix https://gitlab.com/kicad/code/kicad/-/issues/9835
Fix https://gitlab.com/kicad/code/kicad/-/issues/10554


(cherry picked from commit b438810b6b)
2022-02-20 23:52:29 +00:00
Jeff Young f8d15a641a Use only a physical connection to determine flashing of pads.
Checking for proper nets just confuses things when the nets are set
wrongly for some reason.  This way we generate clearer DRC errors.

Fixes https://gitlab.com/kicad/code/kicad/issues/10645
2022-02-20 20:52:39 +00:00
Jeff Young d56e488f2d Remove unnecessary validations.
Not sure if this will fix the bug or not as I can't reproduce it, but
I'd say odds are pretty good.

Fixes https://gitlab.com/kicad/code/kicad/issues/10467
2022-02-20 20:52:39 +00:00
Jeff Young cf9fafaba5 EEschema features need to process ~ for empty string; not EDA_TEXT.
Fixes https://gitlab.com/kicad/code/kicad/issues/10918
2022-02-20 20:52:39 +00:00
jean-pierre charras d5ca09dffc Optimize DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS: a time consuming call (OnModify())
was made for each item change.
It is now made only once.
Fixes #10905
https://gitlab.com/kicad/code/kicad/issues/10905
2022-02-20 20:12:36 +01:00
Jeff Young b24f51908b Fix nullptr error (no router tool in footprint editor).
(cherry picked from commit df3291c59d)
2022-02-20 16:57:54 +00:00
Jeff Young 15fd0aa989 Disable grid when ctrl/cmd key is down.
Fixes https://gitlab.com/kicad/code/kicad/issues/9995
2022-02-20 16:10:53 +00:00
Jeff Young 246b6fcdd6 Use router to update message panel when routing.
Fixes https://gitlab.com/kicad/code/kicad/issues/10068
2022-02-20 13:54:01 +00:00
Jeff Young 2b7c79541b While flags are in prefs, actual clearance values are in board setup.
Fixes https://gitlab.com/kicad/code/kicad/issues/10852

(cherry picked from commit 7ddd3137a3)
2022-02-20 01:03:08 +00:00
Jeff Young 7f40cac4b0 Fix collapsing name column in Net Inspector.
(cherry picked from commit 4966e2ebc2)
2022-02-20 01:03:08 +00:00
Jeff Young 7978c8c291 Allow Rule Areas on all physical layers.
Required to do things like modify silk_clearance rules.

(cherry picked from commit 8f670552a6)
2022-02-20 01:03:08 +00:00
Jeff Young fc6ec23ac1 On-the-fly language updating for appearance panel & selection filter.
Fixes https://gitlab.com/kicad/code/kicad/issues/10040

(cherry picked from commit 6ce63d66e8)
2022-02-20 01:03:08 +00:00
Jeff Young 02ec87b036 Cancel or commit pad edit mode when switching footprints.
Fixes https://gitlab.com/kicad/code/kicad/issues/10209

(cherry picked from commit 85805b95ba)
2022-02-20 01:03:08 +00:00
Jeff Young da82ba00e4 Resolve text variables before attempting to open datasheet.
(cherry picked from commit 510dc28a5c)
2022-02-20 01:03:08 +00:00
Jeff Young b041a77cfa Don't paste into hidden columns.
Fixes https://gitlab.com/kicad/code/kicad/issues/10168

(cherry picked from commit c27ec5cae1)
2022-02-20 01:03:08 +00:00
Jeff Young 9fcd4113b0 Fix crash bug when adding rows to pin table and then pasting to unit.
(cherry picked from commit 8a22dab83d)
2022-02-20 01:03:08 +00:00
Jeff Young 762258203c Add zone margin when subtracting other graphics and zones.
It was already added for pads and tracks, but not the other objects.

Fixes https://gitlab.com/kicad/code/kicad/issues/10896

(cherry picked from commit 81bed9ab96)
2022-02-20 01:03:08 +00:00
Seth Hillbrand 75a4036e45 Trim wires based on how many pins they intersect
If a wire intersects more than 2 pins from the same symbol, we don't
trim connections.  If the wire intersects exactly two pins from a single
symbol, we remove the wire between the pins.

We avoided doing this before because we didn't have a good metric for
trimming vs. not.  But the per-symbol calculation feels like the least
surprising option.

Fixes https://gitlab.com/kicad/code/kicad/issues/10909

Fixes https://gitlab.com/kicad/code/kicad/issues/1857
2022-02-19 16:54:19 -08:00
Seth Hillbrand f0d7a09af9 Remove broken call to normalize outlines
We should never be editing the user's outlines for them.  This creates
broken zones that are hard to repair.  In this case, there was also a
secondary zone with no outline that would crash the system

Fixes https://gitlab.com/kicad/code/kicad/issues/10904
2022-02-18 09:30:26 -08:00
jean-pierre charras 7be3a6b3c5 pcbnew: fix incorrect calculation of the board thickness from board stackup.
dielectric sub layers were not taken in account.
Fixes #10899
https://gitlab.com/kicad/code/kicad/issues/10899
2022-02-18 18:10:49 +01:00
jean-pierre charras 08bc14ccf2 Gerbview: fix missing handling of ID_GRID_SETTINGS event.
Fixes #10885
https://gitlab.com/kicad/code/kicad/issues/10885
2022-02-18 12:30:44 +01:00
Marco Ciampa 5781cb0ce5 Updated Italian translation 2022-02-18 12:05:13 +01:00
Seth Hillbrand ed2148d634 Prevent merging tracks across pads
When merging co-linear tracks, we should maintain the existing break if
it exists on pads, vias and other connection points

(cherry picked from commit 3a29d94c0a)
2022-02-17 19:44:33 -08:00
Seth Hillbrand 8e9d44942f Maintain connectivity while cleaning tracks/vias
When merging segments that loop back on each other, we need to merge
them in such a way to to keep the resulting endpoints connected to the
original adjoining endpoints

Fixes https://gitlab.com/kicad/code/kicad/issues/10780
2022-02-17 15:24:23 -08:00
qu1ck 8b1f1c0296 Fix double loading plugins and sys.path entires multiplying
(cherry picked from commit b53b68c686)
2022-02-17 10:59:52 -08:00
Tomasz Wlostowski 4eb9440a42 router: include arc approximation tollerance in arc hull clearance calculation
fixes: https://gitlab.com/kicad/code/kicad/-/issues/10470
(cherry picked from commit ce28525172)
2022-02-17 09:22:19 -08:00
jean-pierre charras 7cf7270738 GERBER_JOBFILE_WRITER: allows all *_User layers to be listed in *gbrjob file. 2022-02-17 15:35:49 +01:00
Jeff Young 9c48707c88 For Coverity. 2022-02-17 14:30:47 +00:00
Jeff Young ff21a16f7d Formatting. 2022-02-17 14:30:47 +00:00
Jeff Young 3b072ca8b4 Sync all fields between units when symbol is edited.
Fixes https://gitlab.com/kicad/code/kicad/issues/10610

(cherry picked from commit d60ed70d54)
2022-02-17 14:30:47 +00:00
Jeff Young e56355fc17 Update alt pin assignments in other units.
Fixes https://gitlab.com/kicad/code/kicad/issues/10849

(cherry picked from commit e499793147)
2022-02-17 14:30:47 +00:00
Jeff Young cfae33e7a8 Fix Mac button-text grid control spacing.
(cherry picked from commit 9fb3032c77)
2022-02-17 14:30:47 +00:00
Wayne Stambaugh c6c4f9ae4b Eeschema: fix broken symbol library rescue.
Apparently at some point during V5 development, symbol cache library names
were saved by replacing the LIB_ID separator character ':' with '_'.  This
caused the cache look up to fail there by skipping the symbol rescue which
could result in broken schematics.

I have no idea where this happened during V5 development.  The video demo
in the HEAD of the 5.1 branch shows the issue.  All of the other demo cache
libraries are correct.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10488
2022-02-17 09:09:19 -05:00
Mikolaj Wielgus 46f7223dd9 Fix sizing of the two last columns in drill statistics table 2022-02-17 14:16:31 +01:00
Mikolaj Wielgus 75bba51b0b Fix board statistics drill grid column sizing
And remove the horizontal scrollbar.
2022-02-17 14:16:31 +01:00
jean-pierre charras 34ed850a23 GERBER_JOBFILE_WRITER: fix missing handling of User_1 to User_9 user layers.
Fixes #10878
https://gitlab.com/kicad/code/kicad/issues/10878
2022-02-17 11:48:40 +01:00
Seth Hillbrand 266ee381d5 Update Translations 2022-02-16 17:23:19 -08:00
Henrik Kauhanen 15a44d75fb Translated using Weblate (Swedish)
Currently translated at 99.0% (7145 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-17 02:22:39 +01:00
Mustafa Selçuk ÇAVDAR f93304b144 Translated using Weblate (Turkish)
Currently translated at 43.3% (3126 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-02-17 02:22:39 +01:00
Henrik Kauhanen 5fe583e195 Translated using Weblate (Swedish)
Currently translated at 99.0% (7145 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-17 02:22:39 +01:00
Mark Hämmerling 9153fcd04a Translated using Weblate (German)
Currently translated at 99.9% (7209 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-17 02:22:39 +01:00
Henrik Kauhanen 0f5219ad92 Translated using Weblate (Swedish)
Currently translated at 99.0% (7145 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-17 02:22:39 +01:00
Eric 5b90195dfa Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7212 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-17 02:22:38 +01:00
Henrik Kauhanen 28c6ac53b7 Translated using Weblate (Swedish)
Currently translated at 99.0% (7145 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-17 02:22:38 +01:00
Wellington Terumi Uemura 79e8c8df67 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (7212 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pt_BR/
2022-02-17 02:22:38 +01:00
Tokita, Hiroshi f02722b7a7 Translated using Weblate (Japanese)
Currently translated at 99.8% (7200 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ja/
2022-02-17 02:22:38 +01:00
Henrik Kauhanen 34e116c18b Translated using Weblate (Finnish)
Currently translated at 87.3% (6298 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/fi/
2022-02-17 02:22:38 +01:00
Ulices 1a5e00254d Translated using Weblate (Spanish (Mexico))
Currently translated at 99.5% (7182 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/es_MX/
2022-02-17 02:22:38 +01:00
Henrik Kauhanen f36a0eeb95 Translated using Weblate (German)
Currently translated at 99.8% (7202 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-17 02:22:38 +01:00
Mark Hämmerling f8b3f5b02f Translated using Weblate (German)
Currently translated at 99.8% (7202 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-17 02:22:38 +01:00
Jan Straka dca9df1908 Translated using Weblate (Czech)
Currently translated at 90.6% (6536 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-02-17 02:22:38 +01:00
Arnau Llovet Vidal f2e1b8cc7a Translated using Weblate (Catalan)
Currently translated at 61.1% (4410 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-17 02:22:38 +01:00
ZbeeGin 9c4eab9677 Translated using Weblate (Polish)
Currently translated at 99.9% (7209 of 7212 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pl/
2022-02-17 02:22:38 +01:00
Seth Hillbrand 470d7d228d Fix wxT overzealous replacements
A couple of regex mistakes slipped through and need to be reverted here
2022-02-16 17:21:49 -08:00
Jeff Young 71eefc8322 Don't force user to be overly pedantic when writing diffpair rules.
(cherry picked from commit fe7e72538e)
2022-02-15 20:57:45 +00:00
jean-pierre charras ef96ee4a99 French translation update. 2022-02-15 10:20:56 +01:00
jean-pierre charras 35968dfe18 DIALOG_PLOT: use a short living quasimodal dialog instead of a long living window.
In this case, a quasimodal dialog is the right way.
From master branch, commit 43f5a7c74
2022-02-15 09:24:16 +01:00
Seth Hillbrand b3965c014c Update Translations 2022-02-14 09:20:24 -08:00
Eric c3cc615f37 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-14 18:19:04 +01:00
Mustafa Selçuk ÇAVDAR bc232a7b6b Translated using Weblate (Turkish)
Currently translated at 43.1% (3099 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-02-14 18:19:04 +01:00
Henrik Kauhanen 880098d659 Translated using Weblate (Swedish)
Currently translated at 99.5% (7153 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-14 18:19:04 +01:00
Krzysztof Kawa 1640c27cd2 Translated using Weblate (Polish)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pl/
2022-02-14 18:19:04 +01:00
ZbeeGin 96fc0feb4d Translated using Weblate (Polish)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pl/
2022-02-14 18:19:04 +01:00
김랑기 fdae390c52 Translated using Weblate (Korean)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ko/
2022-02-14 18:19:04 +01:00
Henrik Kauhanen 2cb5643556 Translated using Weblate (Finnish)
Currently translated at 87.8% (6313 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/fi/
2022-02-14 18:19:04 +01:00
Ulices d689d1a866 Translated using Weblate (Spanish (Mexico))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/es_MX/
2022-02-14 18:19:04 +01:00
Jan Straka 76c690c819 Translated using Weblate (Czech)
Currently translated at 90.5% (6509 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-02-14 18:19:04 +01:00
Arnau Llovet Vidal 3c601180c2 Translated using Weblate (Catalan)
Currently translated at 61.0% (4390 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-14 18:19:03 +01:00
Mark Hämmerling 3c83040c4b Translated using Weblate (German)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-14 18:19:03 +01:00
Seth Hillbrand 6147e997ff Format string for translation 2022-02-14 09:17:53 -08:00
Seth Hillbrand e88bef0023 Fix PCM strings 2022-02-14 09:17:53 -08:00
jean-pierre charras 54a3ca06c0 Pcbnew, DIALOG_GRAPHIC_ITEM_PROPERTIES: fix incorrect test for arcs.
It was due to mixing decidegrees and degrees, and seen for 180 deg arcs
Fixes #10841
https://gitlab.com/kicad/code/kicad/issues/10841
2022-02-14 09:46:57 +01:00
jean-pierre charras 0cb82a0985 Import netlist: fix issues: do not read netlist before it is selected.
Now the netlist must be explicitly selected and read instead of beeing
read during dialog creation.
It also avoid a useless netlist read when closing the dialog or trying
to change the netlist filename.

From master branch
2022-02-14 08:37:53 +01:00
Roberto Fernandez Bautista b7f8f95725 Don't lock OpenGL context twice
Use GAL_DRAWING_CONTEXT as this unlocks the context in its destructor,
so that when an exception is thrown inside the `try` block, it should
automatically unlock before we switch backend.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10840

(cherry picked from commit 1b6fe615e5)
2022-02-13 21:10:48 +00:00
Graham Keeth 30276fb5f7 update custom rule syntax help to make diff pair rule examples clearer
(cherry picked from commit 4442f76add)
2022-02-13 20:15:47 +00:00
Jeff Young f37531ed39 Fix repaints getting done after the wrong dialog.
(cherry picked from commit b7c9a1ad55)
2022-02-13 18:37:44 +00:00
Jeff Young fd4ac7c5df Error messages for zone merging.
Also fixes a bug where zones meeting at a point would get merged
resulting in a self-intersecting zone.

Also fixes a bug where undo would not be handled correctly when zones
could not be merged.

Fixes https://gitlab.com/kicad/code/kicad/issues/10466

(cherry picked from commit d5a2059c21)
2022-02-13 18:30:32 +00:00
Jeff Young b8b9f646c6 Show pin dangling symbols in Symbol Editor.
Even though we don't have connections they're a still a good visual
indication of which end of the pin is which.

Fixes https://gitlab.com/kicad/code/kicad/issues/10742

(cherry picked from commit aedfe08bad)
2022-02-13 18:29:12 +00:00
Jeff Young f561f85ebb Move CN_VISITOR from HitTest() to Collide().
The former isn't sufficiently aware of layer differences (such as for
pads with some layers unflashed).

(cherry picked from commit 6e063247e5)
2022-02-13 18:22:18 +00:00
Jeff Young 7cba8e847d Don't use bounding box cache during insideArea.
For starters we can't rely on it having been updated, but we also
cache the entire result so there's no huge cost-savings anyway.

Fixes https://gitlab.com/kicad/code/kicad/issues/10821

(cherry picked from commit 8dcc933fc3)
2022-02-13 18:20:31 +00:00
Jeff Young f8ac6df0cd Implement undo for Eeschema find/replace.
Fixes https://gitlab.com/kicad/code/kicad/issues/10824

(cherry picked from commit 33e57930bc)
2022-02-13 18:19:59 +00:00
Mark Roszko 310e339c39 Remove jenkins badge 2022-02-12 14:23:43 +00:00
jean-pierre charras 6b6d97e726 Gerbview: fix a long standing issue: negative objects are now correctly printed. 2022-02-12 11:57:14 +01:00
木 王 7c910c2d0b fix-npth 2022-02-12 11:56:46 +01:00
Seth Hillbrand 1b8f25235c There is one source of truth in AC
Don't store default values in two separate places.  Passes the existing
by value as the default.

Issue identified by @axemagn

Fixes https://gitlab.com/kicad/code/kicad/issues/10221

(cherry picked from commit 3b87ab630e)
2022-02-11 13:24:31 -08:00
Wayne Stambaugh f7133168c1 Begin version 6.0.3 development. 2022-02-10 19:34:34 -05:00
Wayne Stambaugh 702e8b8915 Tag release version 6.0.2. 2022-02-10 19:29:07 -05:00
Marco Ciampa 9226144312 Typo fixed in Italian translation 2022-02-10 21:57:07 +01:00
Seth Hillbrand d937abb5b8 Fix float scaling to use single fn
Function `scaletoIU` was updated in a8c275ae5d but this missed other
conversion points that re-implemented the same routine.  This unifies
the scaling for both ReadIJCoord and ReadXYCoord to use the same routine
as calls from am_primitive

Fixes https://gitlab.com/kicad/code/kicad/issues/10800
2022-02-10 12:36:10 -08:00
Seth Hillbrand bfd5afd6c8 Fix broken wide string for Mac 2022-02-10 09:48:27 -08:00
jean-pierre charras ab878cc257 gerbview: fix incorrect render of regions defined by a 360 deg arcd (a circle)
these regions were missing.
2022-02-10 09:52:14 +01:00
Seth Hillbrand a8c275ae5d Fix relative return with nullptr condition
Previous fix for CVE munged return conditions for gerber files in some
cases.  This restores the proper order where a nullptr will return 0,0
in the relative case and the current coordinate in others

Also fixes incorrect scale factor for inches/mils conversion to mm
2022-02-09 13:09:19 -08:00
Seth Hillbrand d75329b6f1 Quote BOM executable for spaces 2022-02-09 10:53:09 -08:00
Seth Hillbrand 861589d837 Use wxEmptyString instead of wxT( "" )
Also fixes places where ternaries did autopromotion instead of returning
an empty wxString
2022-02-09 10:33:52 -08:00
Wayne Stambaugh 54f91a0221 Wide characterize libs and bitmap2component source. 2022-02-09 09:01:53 -05:00
Jeff Young 8e1e8e1492 More wxT-ification. 2022-02-09 11:14:38 +00:00
Seth Hillbrand 20ef0e54fe Widen text in pcb_calculator 2022-02-08 17:08:22 -08:00
Seth Hillbrand aa126a12f2 Widen QA strings 2022-02-08 16:22:30 -08:00
Seth Hillbrand eecb54bff2 Widen strings in cvpcb 2022-02-08 16:03:23 -08:00
Seth Hillbrand b554c4cb66 Fix a couple of PCM formatting issues
- Include files using global includes
- Use standard file format extensions
2022-02-08 15:52:51 -08:00
Seth Hillbrand b447d55900 Update kicad manager strings to wide 2022-02-08 15:52:24 -08:00
Seth Hillbrand a444addd89 Default eeschema strings to wide
Prevents stack bug on MacOS
2022-02-08 15:14:54 -08:00
Jeff Young 209d593ca0 wxT-ify utils. 2022-02-08 22:24:29 +00:00
Henrik Kauhanen 4fbb957fa3 Translated using Weblate (Swedish)
Currently translated at 99.4% (7144 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-08 02:49:15 +01:00
Henrik Kauhanen 8100a8940f Translated using Weblate (Finnish)
Currently translated at 87.8% (6315 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/fi/
2022-02-08 02:49:15 +01:00
Mustafa Selçuk ÇAVDAR 485e4ddf05 Translated using Weblate (Turkish)
Currently translated at 43.0% (3095 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-02-08 02:49:15 +01:00
Henrik Kauhanen 4ab750e926 Translated using Weblate (Swedish)
Currently translated at 99.4% (7147 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-08 02:49:15 +01:00
Henrik Kauhanen a10d9628c9 Translated using Weblate (Finnish)
Currently translated at 87.8% (6311 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/fi/
2022-02-08 02:49:15 +01:00
Arnau Llovet Vidal 5b175d6d53 Translated using Weblate (Catalan)
Currently translated at 58.4% (4202 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-08 02:49:15 +01:00
Axel Henriksson 10217f5507 Translated using Weblate (Swedish)
Currently translated at 99.4% (7147 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-08 02:49:15 +01:00
Henrik Kauhanen f185511698 Translated using Weblate (Swedish)
Currently translated at 99.4% (7147 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-08 02:49:15 +01:00
Axel Henriksson db972a708a Translated using Weblate (Swedish)
Currently translated at 99.4% (7145 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-08 02:49:15 +01:00
Petri Niemelä efaabfa852 Translated using Weblate (Finnish)
Currently translated at 87.7% (6303 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/fi/
2022-02-08 02:49:15 +01:00
Mark Hämmerling 932cb82c82 Translated using Weblate (German)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-08 02:49:15 +01:00
Arnau Llovet Vidal f0d52ff2de Translated using Weblate (Catalan)
Currently translated at 56.9% (4092 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-08 02:49:14 +01:00
Henrik Kauhanen fc737ffffd Translated using Weblate (Swedish)
Currently translated at 99.4% (7145 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-08 02:49:14 +01:00
Marco Ciampa 4df36a3438 Updated Italian translation 2022-02-07 11:27:56 +01:00
Marek Roszko e72bd34383 Fix color4d distance return type
(cherry picked from commit 1f8d101b1d)
2022-02-07 02:11:55 +00:00
Seth Hillbrand 8fc831cbc2 Validate arc output when editing
Handles checking output of the arc to ensure we don't end up generating
an invalid arc.  Also keeps the limit of the arc angle to be (360,360)
excluding 0.

Fixes https://gitlab.com/kicad/code/kicad/issues/10070
2022-02-06 17:18:04 -08:00
Marek Roszko aa5b6c70a7 Ensure we close the occt document at the end of loading
(cherry picked from commit d211ef1ea3)
2022-02-06 16:18:31 +00:00
Jon Evans 7d5c1d7b5c Disable Ubuntu CI for now
Build box is going down for a time

(cherry picked from commit 41b6c9bf8f)
2022-02-06 09:13:35 -05:00
Mark Roszko f5a56c1ebc Use unique_ptr to avoid memory leak in 3d model cache loading
PVS V773
2022-02-05 20:20:45 +00:00
Jeff Young 3af606a020 Wide string decls for gerbview. 2022-02-05 19:59:29 +00:00
Marek Roszko 132358211e Fix a set of odd null on new checks PVS V668
(cherry picked from commit 1c77eb14d7)
2022-02-05 19:43:21 +00:00
Roberto Fernandez Bautista f412d8d461 CADSTAR: Fix potential nullptr dereferencing bug
Don't assume the footprint will have the pad index that the file references.
2022-02-05 19:22:05 +00:00
Marek Roszko 71bcc9883a Fix typoed test condition for TH no hole pads PVS V501
(cherry picked from commit b9f1aaf029)
2022-02-05 18:32:08 +00:00
Marek Roszko be958e3fdb Avoid potential divide by zero in footprint spreading PVS V609
(cherry picked from commit 8588bea4b2)
2022-02-05 18:31:00 +00:00
Marek Roszko b2c99dd953 Fix some leaking objects identified by PVS Studio V773
(cherry picked from commit a7ebfc31f9)
2022-02-05 18:30:24 +00:00
Wayne Stambaugh c875af48e7 Don't create new project on save as when project file already exists.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10625
2022-02-05 11:30:21 -05:00
Jeff Young 471c0c4c1d More wide-string declarations. 2022-02-05 13:29:00 +00:00
Jeff Young 9e5e46514d More wide-string declarations. 2022-02-05 13:29:00 +00:00
jean-pierre charras ba70f202ce Fix a compil issue. 2022-02-05 11:16:56 +01:00
Seth Hillbrand e18fc36646 wxT rework for common directory 2022-02-04 16:24:50 -08:00
Jeff Young 4657614e4f More wxString wide literals. 2022-02-04 23:12:09 +00:00
Jeff Young d295025964 Be explicit about literal wide-strings. 2022-02-04 20:21:07 +00:00
Jeff Young 2365c1e96f Add duplicated items to parent group.
Fixes https://gitlab.com/kicad/code/kicad/issues/10155

(cherry picked from commit 42917874dd)
2022-02-04 18:14:25 +00:00
Jeff Young 430c4862b6 Log an undo item when filling zones.
If we wanted to put it into the parent's undo item, then the *parent*
would need to not start a new undo record.  Not starting one in the
zone filler tries to add it to the *previous* change, not to the parent
change.

Fixes https://gitlab.com/kicad/code/kicad/issues/10091

(cherry picked from commit 4cc1ced2f3)
2022-02-04 18:14:25 +00:00
Seth Hillbrand 4c81307391 Allow dialogs to force evaluation of UNIT_BINDER
When setting previous values, we don't get the "OnFocus" event, so the
evaluation would not get triggered by simply repeating (using the
keyboard)

Fixes https://gitlab.com/kicad/code/kicad/issues/10752
2022-02-04 10:03:23 -08:00
jean-pierre charras 57cbe261f2 WX_GRID: highlight the selected cell after selection by tab or arrow keys.
Fixes #9290
https://gitlab.com/kicad/code/kicad/issues/9290
2022-02-04 13:55:00 +01:00
Marek Roszko 50d3a507d0 Mark some limits as constexpr
gcc doesn't need it and computes during compile regardless, but experimenting in godbolt, both clang and MSVC actually do need it or else it's partially computed at runtime


(cherry picked from commit ca7840334c)
2022-02-04 12:50:54 +00:00
Seth Hillbrand 7642a9db79 Setup selection when repeating
We need the item to be currently selected when repeating the last symbol
insert.  This ensures we have a valid selection before starting the move
tool and possibly getting odd system behavior from mouse positions

Fixes https://gitlab.com/kicad/code/kicad/issues/10619
2022-02-03 17:09:31 -08:00
Jeff Young 527e06d989 Fix some overly-large text spacing.
While overly-large bounding boxes mostly don't matter, they make us
knock out holes in zones that are too large.
2022-02-04 00:34:20 +00:00
Jeff Young 69b69aa431 Update text variables when they change.
Fixes https://gitlab.com/kicad/code/kicad/issues/10734
2022-02-04 00:34:20 +00:00
Jeff Young d6a86fa9e0 Don't double-count the text thickness in its polygon shape.
The stroke font already takes the thickness into account in
ComputeStringBoundaryLimits() (which is called by GetTextBox()).
2022-02-04 00:34:20 +00:00
Seth Hillbrand 0a13f15a9d Ensure we can version scripting properly
Adds Version() and FullVersion() calls to support reporting version to
scripts and scripting window

Fixes https://gitlab.com/kicad/code/kicad/issues/10079
2022-02-03 15:54:07 -08:00
Seth Hillbrand ef94f31204 Update error message to match new arc dialog
We now provide arc end points and interior angle, so we cannot check for
null radius in the same fashion.  Instead, the starpoint==endpoint
indicates a zero radius

Fixes https://gitlab.com/kicad/code/kicad/issues/10714
2022-02-03 14:31:58 -08:00
Seth Hillbrand 7601a3385f Convert strings to wide when using wxString routines
WxString does not allocate space for wide strings needed during
conversion unless the string is explicitly wide.  This can cause buffer
over/underflow

Fixes https://gitlab.com/kicad/code/kicad/issues/10605
2022-02-03 13:08:07 -08:00
Seth Hillbrand ccf2a63f45 When undoing creation of the sheet, get out first
We can't stay in a sheet that is deleted by the action of undo.  Checks
the current sheet and, if we are currently using it, ensures that the
following action is to leave the current sheet

Fixes https://gitlab.com/kicad/code/kicad/issues/10733
2022-02-03 11:19:33 -08:00
Seth Hillbrand 901685f01b Don't convert KIID on the fly
Converting to string on save prevent unneeded ops
2022-02-03 10:34:14 -08:00
Seth Hillbrand bdf235c25f Restore missing bitmaps 2022-02-03 09:23:27 -08:00
jean-pierre charras 0ffa266315 DIALOG_SPICE_MODEL: fix a cosmetic issue (no room for the help text)
Fixes #10170
https://gitlab.com/kicad/code/kicad/issues/10170

(cherry picked from commit 7c3f0612f1)
2022-02-03 15:01:04 +00:00
Jeff Young 5c94d59e75 Use natural order sorting for FP libraries.
Fixes https://gitlab.com/kicad/code/kicad/issues/10349

(cherry picked from commit a187076438)
2022-02-03 15:01:04 +00:00
Scott Candey 02f93805d0 Common: Corrects Mac OS text navigation shortcuts in Scintilla
Ctrl-A moves cursor to beginning of current line in text box.
Ctrl-E moves cursor to the end of the line.
This change makes navigation in Scintilla text boxes consistent
with other text boxes in KiCad.

Fixes https://gitlab.com/kicad/code/kicad/issues/9996

(cherry picked from commit 23fdbe4b21)
2022-02-03 15:01:04 +00:00
Jeff Young 2e324aa845 Promote to cell selection for spreadsheet-style paste.
Fixes https://gitlab.com/kicad/code/kicad/issues/9211

(cherry picked from commit 9de62d1dd4)
2022-02-03 15:01:04 +00:00
Jeff Young fecb625459 Resolve text variables in eeschema before passing to pcbnew.
Fixes https://gitlab.com/kicad/code/kicad/issues/10429

(cherry picked from commit 2b14b60c32)
2022-02-03 15:00:39 +00:00
Jeff Young b883eee911 Use superclass's copy c'tor from within subclass copy c'tor.
Fixes https://gitlab.com/kicad/code/kicad/issues/10481

(cherry picked from commit 8c758aeeb5)
2022-02-03 15:00:39 +00:00
Jeff Young 01f3a14dc3 Allow more (lots more) unfold from bus menu entries.
Fixes https://gitlab.com/kicad/code/kicad/issues/10529

(cherry picked from commit 4665cdcdc5)
2022-02-03 15:00:39 +00:00
Jeff Young 2425444947 Map zone layers before checking their visibility.
Fixes https://gitlab.com/kicad/code/kicad/issues/10509

(cherry picked from commit 09d0f6e17c)
2022-02-03 15:00:39 +00:00
Jeff Young 66e12af548 Expand text vars in titleblock before exporting.
Fixes https://gitlab.com/kicad/code/kicad/issues/10197

(cherry picked from commit 407660201e)
2022-02-03 15:00:39 +00:00
Jeff Young ea38056e33 Resolve textvars in plot directory.
Fixes https://gitlab.com/kicad/code/kicad/issues/10405

(cherry picked from commit e5d5ee07f0)
2022-02-03 15:00:39 +00:00
Jeff Young c805144c08 Support (and save/recall) zoom in/out in Custom Rules editor.
Fixes https://gitlab.com/kicad/code/kicad/issues/5796

(cherry picked from commit 0036f44e37)
2022-02-03 15:00:39 +00:00
Seth Hillbrand 927afe313d Review ReadXY/ReadIJ to avoid static char arrays
Tighten up the code a bit, removing extra calls and loops.  Removes
unchecked use of stack char array

Fixes https://gitlab.com/kicad/code/kicad/issues/10719
2022-02-02 17:16:30 -08:00
Henrik Kauhanen 03f643ca42 Translated using Weblate (Swedish)
Currently translated at 98.4% (7072 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-02 22:43:15 +01:00
Axel Henriksson 945b841e1b Translated using Weblate (Swedish)
Currently translated at 98.4% (7072 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-02 22:43:15 +01:00
Arnau Llovet Vidal 6771ceb050 Translated using Weblate (Catalan)
Currently translated at 53.5% (3850 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-02 22:43:15 +01:00
Ian McInerney 61853a2d7c Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:15 +01:00
taotieren 92773335f7 Translated using Weblate (Chinese (Traditional))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hant/
2022-02-02 22:43:15 +01:00
CloverGit ef58267013 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:15 +01:00
Mustafa Selçuk ÇAVDAR 35e9c57555 Translated using Weblate (Turkish)
Currently translated at 43.0% (3093 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-02-02 22:43:15 +01:00
Axel Henriksson 1e3b3df808 Translated using Weblate (Swedish)
Currently translated at 98.3% (7066 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-02-02 22:43:15 +01:00
Dejan Smole c062ba3044 Translated using Weblate (Slovenian)
Currently translated at 77.2% (5553 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sl/
2022-02-02 22:43:15 +01:00
Jakub Janek 44b4e6753c Translated using Weblate (Slovak)
Currently translated at 75.5% (5430 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sk/
2022-02-02 22:43:15 +01:00
dsa-t 9c22a8000e Translated using Weblate (Russian)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ru/
2022-02-02 22:43:15 +01:00
ZbeeGin 83729adca4 Translated using Weblate (Polish)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pl/
2022-02-02 22:43:14 +01:00
김랑기 2585f7e7a4 Translated using Weblate (Korean)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ko/
2022-02-02 22:43:14 +01:00
Tokita, Hiroshi a7d586818c Translated using Weblate (Japanese)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ja/
2022-02-02 22:43:14 +01:00
Mark Hämmerling 0030ddee26 Translated using Weblate (German)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-02-02 22:43:14 +01:00
Arnau Llovet Vidal 1853900389 Translated using Weblate (Catalan)
Currently translated at 53.4% (3842 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-02 22:43:14 +01:00
Eric f1a04828f7 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:14 +01:00
Rigo Ligo c8b0a3697f Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:14 +01:00
Tian Yunhao e8774181f8 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:14 +01:00
taotieren b253d9085d Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:14 +01:00
taotieren 6d1351fa98 Translated using Weblate (Chinese (Traditional))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hant/
2022-02-02 22:43:14 +01:00
taotieren d7eef72c29 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:14 +01:00
Eric 84bae1f3df Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:14 +01:00
Mustafa Selçuk ÇAVDAR b5bc942758 Translated using Weblate (Turkish)
Currently translated at 23.9% (1718 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-02-02 22:43:14 +01:00
Wellington Terumi Uemura 86f485619a Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pt_BR/
2022-02-02 22:43:14 +01:00
Tokita, Hiroshi a9f832556c Translated using Weblate (Japanese)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ja/
2022-02-02 22:43:13 +01:00
Arnau Llovet Vidal 01aff3bf80 Translated using Weblate (Catalan)
Currently translated at 47.1% (3386 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-02 22:43:13 +01:00
Mustafa Selçuk ÇAVDAR 5ba8dcdcf1 Translated using Weblate (Turkish)
Currently translated at 12.7% (914 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-02-02 22:43:13 +01:00
Mustafa Selçuk ÇAVDAR c2edf23118 Translated using Weblate (Turkish)
Currently translated at 10.3% (742 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-02-02 22:43:13 +01:00
Rigo Ligo 00dd29ae8b Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-02-02 22:43:13 +01:00
Wellington Terumi Uemura 5c4389a3c4 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pt_BR/
2022-02-02 22:43:13 +01:00
Arnau Llovet Vidal c81a71627f Translated using Weblate (Catalan)
Currently translated at 46.9% (3377 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-02-02 22:43:13 +01:00
Seth Hillbrand 6d84acfacd Handle invalid pads more gracefully
Pads generated outside of KiCad may have self-intersecting polygons that
simplify to multiple sets.  We handle this by adding multiple primitives
for such polygons and limiting our fracture calls to only polygons that
have holes

Fixes https://gitlab.com/kicad/code/kicad/issues/10712
2022-02-02 13:36:24 -08:00
jean-pierre charras 788c607d47 EDA_SHAPE::MakeEffectiveShapes(): protect against empty polygons.
Fixes #10713
https://gitlab.com/kicad/code/kicad/issues/10713
2022-02-02 20:48:42 +01:00
Steffen Mauch 169881dcf1 EAGLE plugin: use specified RATIO value for text size calculation
(cherry picked from commit 61b2b0ff0c)
2022-02-02 08:48:25 -08:00
Seth Hillbrand a7fbdfe918 Fix overflow vulnerability in Gerbview
Corrects an unguarded read that could lead to arbitrary code execution
in specifically crafted gerber files.

Fixes https://gitlab.com/kicad/code/kicad/issues/10700

(cherry picked from commit 54b20cb049)
2022-02-02 08:31:15 -08:00
jean-pierre charras 3d11ce5139 export D356 netlist: fix incorrect id for pads type connectors.
these pads are similar to SMD pads and should have the same id.
Fixes #10694
https://gitlab.com/kicad/code/kicad/issues/10694
2022-02-01 08:45:02 +01:00
Seth Hillbrand 833ce19221 Be more diligent in preventing drag line errors
They can happen even when there are no collisions, so we need to reset
the 'ok' flag before using the line again.

Fixes https://gitlab.com/kicad/code/kicad/issues/9555
2022-01-31 16:09:14 -08:00
Alex 73d0d7796c Allow overlay scrolling on GTK, except for GAL canvases.
This prevents glitches when both scrollbars
are visible and scrolling to the end.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10559

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9988

(cherry picked from commit 4c4089e836)
2022-01-31 15:43:31 -05:00
jean-pierre charras 42dfdf8c38 PCB_CONTROL::unfilledZoneCheck(): skip rule areas: they are not filled by definition.
Fixes #10691
https://gitlab.com/kicad/code/kicad/issues/10691
2022-01-31 17:04:05 +01:00
Seth Hillbrand 70d00689ca Fully select a line for transformation
When not trying to select points, we need to ensure that the full
line is selected for transformation

Fixes https://gitlab.com/kicad/code/kicad/issues/10566
2022-01-29 17:36:54 -08:00
jean-pierre charras 26dfc4477f PCB_TARGET: add missing TransformShapeWithClearanceToPolygon() method.
From Master branch.
2022-01-29 20:07:14 +01:00
Seth Hillbrand 38a4894d92 Prevent multiple single-point line solutions
Suggested by @rivimey, we test the case where both lines return singular
point lines and prevent them leaking into our drag solution

Fixes https://gitlab.com/kicad/code/kicad/issues/9555
2022-01-29 07:07:03 -08:00
Seth Hillbrand c2707f3cc0 Fix large memory leak in DRC
All elements get effective shapes, many of which get triangulated.  This
memory needs to be freed when destroying the tree
2022-01-28 17:07:11 -08:00
Seth Hillbrand 8753051db6 Don't count zero-length as duplicate
We were checking for duplicate tracks by looking to see if the two
tracks had two shared points.  A null track always matched this case,
which removed the valid track.  We solve this by avoiding null tracks in
the duplicate checker.  They are removed separately in the null track
stage.

This also fixes a GTK-specific tree issue where we require the
BeforeReset()/AfterReset() calls instead of Cleared() to prevent GTK
from dereferencing a parent after freeing

Fixes https://gitlab.com/kicad/code/kicad/issues/10624
2022-01-28 16:34:00 -08:00
Seth Hillbrand 8ae304dcca Don't allow degenerate lines in dragger
If walkaround returns an invalid line, don't consider it for a track

Fixes https://gitlab.com/kicad/code/kicad/issues/9555
2022-01-28 15:18:42 -08:00
Seth Hillbrand 796893de56 Fix negative arc angles in PCAD import 2022-01-28 10:18:17 -08:00
alexfanqi ea52101c1b Add riscv64 support for libcontext
modified to match function arguments different from upstream

Author: Andreas Schwab
(cherry picked from commit 01f0aad7c0)
2022-01-27 08:56:46 -05:00
Wayne Stambaugh ca27b38182 Fix broken environment variable substitution on Windows.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10303

(cherry picked from commit 9af365b5b3)
2022-01-27 08:56:46 -05:00
jean-pierre charras 3f6a4296d9 Pcbnew, export svg: Fix incorrect saving of layer set.
From Master branch
2022-01-27 13:07:40 +01:00
jean-pierre charras 2a27899b9b French translation update.
Fixes #10588
https://gitlab.com/kicad/code/kicad/issues/10588
2022-01-25 09:38:39 +01:00
Marek Roszko 1a534ade89 Remove UpdateUI from preferences pdf viewer option
Partial fix for https://gitlab.com/kicad/code/kicad/-/issues/10590
2022-01-24 20:36:21 -05:00
Seth Hillbrand fddfce4fb1 Force a size event to avoid multiple yields
When the grid editor is shown, we also want to ensure that the grid gets
resized to account for the new editor.  Queuing the event will ensure
that happens after the editor is emplaced in the grid

Fixes https://gitlab.com/kicad/code/kicad/issues/5690
2022-01-24 15:31:45 -08:00
Wayne Stambaugh ab184ba9f3 Fix wxWidgets invalid string specifier assertion. 2022-01-24 15:44:42 -05:00
Seth Hillbrand a1615cce7e Enforce strictly weak ordering in sheets
This ensures that irreflexivity is given in sort ordering.  This may
have been triggering issues in MacOS when adding sheets

Fixes https://gitlab.com/kicad/code/kicad/issues/10557
2022-01-24 10:41:02 -08:00
Seth Hillbrand 871556ebda Allow time to update editor
On GTK, the full editor needs to be shown and, for some systems, the
editor will not show correctly.  By yielding we should allow the time to
recalculate sizes for the editor in the grid

Fixes https://gitlab.com/kicad/code/kicad/issues/5690
2022-01-24 09:55:46 -08:00
Marek Roszko 7152c4ebb8 Add extraction of patch version to feed to resource defines 2022-01-23 14:47:54 -05:00
Mark Roszko 34dafdd2c1 Try and silence the ci failure on windows 2022-01-23 19:23:43 +00:00
Seth Hillbrand f12d0cb0e2 Get all eeschema layers properly ordered
Layers not in the given order are drawn behind everyone else.  Missing
the text prevents global labels from showing properly in GAL order

Fixes https://gitlab.com/kicad/code/kicad/issues/10546
2022-01-23 10:03:03 -08:00
jean-pierre charras 029e42f8d1 DIALOG_SIM_SETTINGS: fix incorrect validation of DC souces in DC Transfer panel
From Master branch
Fixes #10568
https://gitlab.com/kicad/code/kicad/issues/10568
2022-01-23 17:01:55 +01:00
jean-pierre charras 60ae18893e PCB_POINT_EDITOR: fix missing init of PAD pos0 after changing
(From Master branch)
2022-01-22 10:43:23 +01:00
Marek Roszko e0b835fe20 Set curl to use the Windows cert store
(cherry picked from commit 3ede5f42be)
2022-01-22 03:10:11 +00:00
Steffen Mauch d6c4215a1f pcbnew: EAGLE importer does map value to wrong layer if nothing is defined in original EAGLE footprint
Fixes https://gitlab.com/kicad/code/kicad/issues/10311

(cherry picked from commit 55b782d66e)
2022-01-21 13:16:41 -08:00
Steven A. Falco 8b6a166698 Missing include file
(cherry picked from commit 042f584859)
2022-01-21 09:01:33 -08:00
jean-pierre charras e9a5e5466c SYMBOL_VIEWER_FRAME: fix refresh of the canvas after selecting a new symbol.
From Master branch
2022-01-21 17:34:51 +01:00
Jeff Young 0317185860 Don't update units for UNSCALED, PERCENT or DEGREES.
Fixes https://gitlab.com/kicad/code/kicad/issues/10020

(cherry picked from commit 27d8df1122)
2022-01-21 15:42:48 +00:00
Jeff Young c02cadec2a Exclude rules which match no enabled layers.
Fixes https://gitlab.com/kicad/code/kicad/issues/10227

(cherry picked from commit 0967cc82e2)
2022-01-21 15:06:18 +00:00
Jeff Young b608ebd058 Don't findnext on an empty string; show the dialog.
Fixes https://gitlab.com/kicad/code/kicad/issues/10313

(cherry picked from commit 60fc75e239)
2022-01-21 15:05:27 +00:00
Jeff Young 6d7659fb20 Flip arc endpoints when mirroring in FPEditor.
Fixes https://gitlab.com/kicad/code/kicad/issues/10550

(cherry picked from commit 7f6bc28f87)
2022-01-21 15:02:15 +00:00
Seth Hillbrand dd7029ea07 Always use the project directory for default save
Fixes https://gitlab.com/kicad/code/kicad/issues/10478
2022-01-20 11:51:16 -08:00
Seth Hillbrand 323a069738 Clear Undo list when renaming
Our undo/redo list is tied to the screen that gets cleared when we
reload the file after renaming.  We need to clear the Undo list at this
point to prevent possible crashes when moving too far back in the stack

Fixes https://gitlab.com/kicad/code/kicad/issues/10504
2022-01-20 11:28:41 -08:00
Seth Hillbrand 615eda816e Don't close filled polylines when printing
Eeschema/libedit support open, filled polylines.  When printing, this
should be drawn as a fill, followed by the polyline to avoid assumptions
about closed polygons in the graphic code

Fixes https://gitlab.com/kicad/code/kicad/issues/10537
2022-01-20 10:53:57 -08:00
Seth Hillbrand 6810479a19 Prevent UI updates from changing zoom selection
The zoom selection should only change when requested by the user, not in
response to UI updates.  This can cause unexpected zoom shifts when the
calculated zoom is within a range of one of the presets.  It also adds
unneeded calls during the UI update cycle

Fixes https://gitlab.com/kicad/code/kicad/issues/10498
2022-01-20 10:09:25 -08:00
jean-pierre charras d9c6765be7 ITMAP_BASE::DrawBitmap(): fix position of the clipping area when using matrix transform.
Fixes #10525
https://gitlab.com/kicad/code/kicad/issues/10525
From Master branch
2022-01-20 16:27:18 +01:00
Seth Hillbrand 857683d372 Remove unneeded distance calc 2022-01-18 15:58:20 -08:00
jean-pierre charras 24865971af DRAWING_SHEET_PARSER: fix missing parse of "T_comment" case for DS_DATA_ITEM_BITMAP.
Fixes #10477
https://gitlab.com/kicad/code/kicad/issues/10477
From Master.
2022-01-17 18:04:26 +01:00
jean-pierre charras 10ce515aca LSET::SeqStackupBottom2Top(): add missing user layers to list of layers
These missing layers were not exported in export SVG.
From master branch
2022-01-17 11:01:11 +01:00
Wayne Stambaugh da28ade004 Footprint editor: use most recently used path on footprint import.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10418

(cherry picked from commit c154e85ebd)
2022-01-16 09:48:21 -05:00
Marek Roszko f97a0fb3e9 Add a way to add a "revision" for use in windows manifests
(cherry picked from commit d4ee74a832)
2022-01-15 20:20:53 +00:00
Seth Hillbrand cccdac136f Fix transparent circle printing
DrawEllipse seems to work fine using transparent bg for all DCs except
printing (which is the only one we use now)  Use two arcs to draw a
transparent fill for the circle instead as a workaround until we
implement Cairo printing

Fixes https://gitlab.com/kicad/code/kicad/issues/10431
2022-01-14 16:13:05 -08:00
Jon Evans 2306d00c89 Do not check key states for non-key events in TryBefore
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10127
2022-01-13 22:28:45 -05:00
Jon Evans 20bbf9b179 PNS: Do not clear layer pairs when importing new sizes
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10225
2022-01-13 20:37:37 -05:00
Jon Evans cf4d46b24d PNS: Do not allow smart pads when in 90-degree mode
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10386
2022-01-13 20:21:19 -05:00
qu1ck 739c14eaa2 FOOTPRINT::GetProperty() swig extension
(cherry picked from commit 33a4c9b08e)
2022-01-13 13:10:44 -08:00
Wayne Stambaugh adfbfc27af Footprint editor: fix Eagle plugin footprint library layer mapping bug.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10354

(cherry picked from commit a77b5649cc)
2022-01-12 20:52:55 -05:00
Wayne Stambaugh 26047615bd Fix X3D model parser.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10385

(cherry picked from commit 44e4abde0e)
2022-01-12 19:00:27 -05:00
Seth Hillbrand dcb8f29317 Handle rotated symbol rectangles in Eagle import
Fixes https://gitlab.com/kicad/code/kicad/issues/10360
2022-01-12 15:10:42 -08:00
dana 57d58fe335 Handle Unicode clipboard data in pcbnew and symbol editor
Fixes #10323

(cherry picked from commit 8373180cbb)
2022-01-12 09:23:24 -08:00
Seth Hillbrand 56d87a8613 Catch default autowire case
Since we are dereferencing the optional, we need to ensure it exists in
all cases

Fixes https://gitlab.com/kicad/code/kicad/issues/10394
2022-01-12 09:02:39 -08:00
Wayne Stambaugh 9a0323fe17 Begin version 6.0.2 development. 2022-01-11 21:22:36 -05:00
Wayne Stambaugh 0a9271f98e Tag release version 6.0.2. 2022-01-11 21:18:26 -05:00
prometheus 3c91b0c693 Translated using Weblate (Turkish)
Currently translated at 10.2% (737 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-01-12 01:42:50 +01:00
Arnau Llovet Vidal 562bd7d564 Translated using Weblate (Catalan)
Currently translated at 46.6% (3353 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ca/
2022-01-12 01:42:49 +01:00
Seth Hillbrand ad726dc6e4 Rework cd8d6ba0 for 6.0.1
Addresses https://gitlab.com/kicad/code/kicad/-/issues/10357 as well as
a few additional rounding points in 3d viewer based on master commit
2022-01-11 13:49:57 -08:00
Roberto Fernandez Bautista b2ecf097ed Include Footprints within Groups when re annotating duplicates
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10329

(cherry picked from commit de7158b80e)
2022-01-11 20:52:01 +00:00
Seth Hillbrand 8dca61ce9c Fix copy-paste error 2022-01-11 06:08:15 -08:00
Steven A. Falco e8e25fd732 Launchers must specify WM_CLASS
On some Linux desktops, we get extra icons in the application dock.
This happens because the dock doesn't know the "class" of the
application.  We need to add StartupWMClass=xxx lines, where xxx is
the name associated with the application.

This patch addresses the following issue:

https://gitlab.com/kicad/packaging/kicad-ubuntu-builder/kicad-daily-package/-/issues/30

While it was written against Ubuntu, it also affects Fedora, and
probably other Linux systems too.
2022-01-11 01:25:16 +00:00
Seth Hillbrand bd7841bf96 Handle arcs in global track width changes
Also add defensive code against invalid indices

Fixes https://gitlab.com/kicad/code/kicad/issues/10325
2022-01-10 17:19:49 -08:00
Seth Hillbrand 55020c2b89 Better fix for missing end segment
Rather than skipping our endEdit() call in libedit, we need to
parameterize whether we want the shape open/closed.  Closed will remove
the last segment if it lands on the first point.  We don't want that
but we do want to remove the last point if it duplicates the second to
last (in the case of double-clicking)

Fixes https://gitlab.com/kicad/code/kicad/issues/10334
2022-01-10 13:37:47 -08:00
Seth Hillbrand a74d1d9962 Keep ratsnest setting when pasting
Paste items should copy the global ratsnest visibility setting

Fixes https://gitlab.com/kicad/code/kicad/issues/10346
2022-01-10 12:48:03 -08:00
Seth Hillbrand 4d899d7820 Remove default hotkey for toggle zone display
It is too easy to accidentally hide your zones and the 'A' hotkey is
intuitively mapped to Add Footprint, to match Add Symbol in eeschema.

This won't change current hotkey customizations but will help prevent
future user error.  Users can still map the action to a hotkey if the
new toggle is useful to their workflow
2022-01-10 11:48:26 -08:00
Seth Hillbrand 4907b90215 Fix FP circle validity check
Radius is encoded by m_endX

Fixes https://gitlab.com/kicad/code/kicad/issues/10337
2022-01-10 10:54:23 -08:00
Jan Straka a399f799ad Translated using Weblate (Czech)
Currently translated at 90.5% (6507 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-01-10 18:58:11 +01:00
Jan Straka 55cd2da432 Translated using Weblate (Czech)
Currently translated at 89.5% (6432 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-01-10 18:58:11 +01:00
obit 096600ffc4 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-01-10 18:58:11 +01:00
Axel Henriksson b4bae29c02 Translated using Weblate (Swedish)
Currently translated at 98.3% (7066 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/sv/
2022-01-10 18:58:11 +01:00
Mark Hämmerling e4a5ce78aa Translated using Weblate (German)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-01-10 18:58:11 +01:00
Mark Hämmerling 522738284d Translated using Weblate (German)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/de/
2022-01-10 18:58:11 +01:00
pondahai cc0d5ec46a Translated using Weblate (Chinese (Traditional))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hant/
2022-01-10 18:58:11 +01:00
Tian Yunhao f2018a09d8 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-01-10 18:58:11 +01:00
김랑기 54952ca97e Translated using Weblate (Korean)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ko/
2022-01-10 18:58:10 +01:00
Tokita, Hiroshi a8543b1122 Translated using Weblate (Japanese)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/ja/
2022-01-10 18:58:10 +01:00
Tian Yunhao 790ca19445 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-01-10 18:58:10 +01:00
Wellington Terumi Uemura f56b3bdd07 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pt_BR/
2022-01-10 18:58:10 +01:00
Rafael Silva 7d635d3d43 Translated using Weblate (Portuguese)
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/pt/
2022-01-10 18:58:10 +01:00
Jose Perez 37f62e539b Translated using Weblate (Spanish)
Currently translated at 99.9% (7185 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/es/
2022-01-10 18:58:10 +01:00
Jan Straka 3196f4adb6 Translated using Weblate (Czech)
Currently translated at 88.9% (6395 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/cs/
2022-01-10 18:58:10 +01:00
Gökhan Koçmarlı b4d67b6b29 Translated using Weblate (Turkish)
Currently translated at 9.9% (712 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/tr/
2022-01-10 18:58:10 +01:00
Eric f7d790598b Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (7186 of 7186 strings)

Translation: KiCad EDA/v6
Translate-URL: https://hosted.weblate.org/projects/kicad/v6/zh_Hans/
2022-01-10 18:58:10 +01:00
Wayne Stambaugh bbf00e0461 Pcbnew: honor footprint exclude from BOM setting.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10297

(cherry picked from commit f379c49084)
2022-01-09 11:30:06 -05:00
Mikolaj Wielgus a91f807e13 Update contributor name 2022-01-09 09:29:54 +01:00
Seth Hillbrand 100cf757fe Force Mesa to use its own call
Mesa does not support adaptive swapping but will sometimes report that
it does.  This prevents Mesa drivers from testing (and segfaulting) the
limits of their call

Fixes https://gitlab.com/kicad/code/kicad/issues/10069
2022-01-08 17:13:25 -08:00
Jon Evans 76f21d950d Ensure LIB_TREE cleans up while frame still exists
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10266
2022-01-08 17:32:17 -05:00
Seth Hillbrand 69469b254a Printing multiple bitmaps
A long-standing issue with multiple workarounds
(https://gitlab.com/kicad/code/kicad/-/issues/1877) prevented eeschema
printouts with multiple images or images in both the worksheet and the
schematic.

We worked around this by ordering the bitmap printing to be the first
step in the printing process.  This partially worked but didn't get
everything correct.  The primary difficulty in debugging this was that
the wxPrintPreview that we generate looked correct.  Only the actual
printout was incorrect.

The fix is to explicitly clip bitmap drawing to the bitmap area,
regardless of how large the bitmap is.
2022-01-07 17:15:59 -08:00
Seth Hillbrand bfca928900 Plot pads in layer color
v6 pads are not allowed to be a different color from the rest of the
copper layer, so don't query the GAL layer for a color

Fixes https://gitlab.com/kicad/code/kicad/issues/10293
2022-01-07 08:55:59 -08:00
Seth Hillbrand 62f8603353 Don't deduplicate symbol polygons
SHAPE_LINE_CHAIN will, by default, remove duplicate points when
appending.  We don't want to do this when constructing our polygons in
symbol editor, so we need to explicitly call the routine without
deduplication

Fixes https://gitlab.com/kicad/code/kicad/issues/10289
2022-01-07 08:25:09 -08:00
Seth Hillbrand 9a2332dfcf Clear edited point when exiting tool
When leaving the main point editor loop, we need to ensure that the edit
point is cleared as well.  This is usually cleared by a ClearEvent call
but in case this is missed, we need to ensure that other tools are not
caught out

Fixes https://gitlab.com/kicad/code/kicad/issues/10288
2022-01-07 08:23:31 -08:00
qu1ck 4bcfa8df1f Template for vector<VECTOR2I> in swig 2022-01-06 23:48:52 -05:00
Seth Hillbrand a0e424c2ac Forgot to build ninja files 2022-01-06 20:09:44 -08:00
Seth Hillbrand f4b9a92b94 Swap make for ninja in Fedora CI
Take advantage of extra cores on hetzner machine
2022-01-06 20:09:44 -08:00
Seth Hillbrand 184a592f82 Use KiCad builders for Fedora 2022-01-06 20:09:44 -08:00
Seth Hillbrand 3e6bf7814b Safely sort view layers
Changing view order of only some layers can cause overwriting of the
original layer if not pre-staged

Fixes https://gitlab.com/kicad/code/kicad/issues/10283
2022-01-06 14:41:10 -08:00
Seth Hillbrand 9864337914 Do not call SafeYield on close
wxSafeYield() is not "safe".  Pending actions may include deletion of
the currently active class.  This will cause crashes when exiting.  If
needed for specific behaviors, we should use wxSafeYieldFor( flag ) with
the appropriate events specified rather than a general yield which can
cause more problems
2022-01-06 12:31:59 -08:00
Seth Hillbrand 78e737b9d8 DRC scripting: load project from board if possible
s_SettingsManager is not always initialized when the WriteDRCReport is
run.  We should first attempt to extract the project from the actual
board being checked.  Failing that, we fall back to the static settings manager and then exit if we don't have a project associated.

Fixes https://gitlab.com/kicad/code/kicad/issues/10221
2022-01-06 11:50:21 -08:00
Brian Mayton d014f0307b Add ORANGE to DXF output
Matches the schematic color options to DXF layers

Fixes https://gitlab.com/kicad/code/kicad/issues/10281

Signed-off-by: Seth Hillbrand <seth@kipro-pcb.com>
2022-01-06 11:02:57 -08:00
Seth Hillbrand 7c9340f855 Fix swap interval checking
Checking for the existence of the call only validated that our header
defined the value, not that the video card/driver supported the call.
We query the extensions string directly to check for support.  This
should fix both the X11 and virtualization issues (potentially other
crashes with older video cards as well)

Fixes https://gitlab.com/kicad/code/kicad/issues/8944
2022-01-06 10:53:13 -08:00
jean-pierre charras 3069b198b1 PANEL_TEMPLATE_FIELDNAMES: fix incorrect management of boolean options
(it was impossible to disable them)
From Master branch.
Fixes https://gitlab.com/kicad/code/kicad/issues/10280
2022-01-06 19:44:23 +01:00
Seth Hillbrand 05d3dc533b Prevent cvpcb from losing text focus on filter
Refresh event changes focus (on GTK).  We fix this by storing the
existing insertion point in the text box, refocusing and restoring the
text position

Fixes https://gitlab.com/kicad/code/kicad/issues/10029
2022-01-06 09:16:34 -08:00
Marek Roszko 1e05732f55 Add std::hash specialization for VECTOR2I
(cherry picked from commit 589a03afcd)

Fixes https://gitlab.com/kicad/code/kicad/issues/10275
2022-01-05 20:32:46 -08:00
Seth Hillbrand 71e7b4b77b Use 'special' escaping for certain fields
Most fields are escaped using the `\` notation.  But the VALUE field and
the symbol name need to be escaped using braces notation.

Fixes https://gitlab.com/kicad/code/kicad/issues/10097
2022-01-05 17:18:39 -08:00
Seth Hillbrand b8a7a66a0a Keep symbol synced with edit tool
Undo/Redo can change the symbol referenced by the symbol drawing tool.
This updates the current symbol before important steps to keep the
system synced

Fixes https://gitlab.com/kicad/code/kicad/issues/10125
2022-01-05 16:51:41 -08:00
Seth Hillbrand 55087a9e82 Don't remove last point in libedit
SHAPE_LINE_CHAIN in libedit doesn't make a polygon, so we always need
the last point and it shouldn't be closed

Fixes https://gitlab.com/kicad/code/kicad/issues/9934
2022-01-05 16:02:50 -08:00
Seth Hillbrand 444801ada6 Prevent unneeded fallback
Starting in be8327bd54, we assume that all
exceptions in DoRePaint() are caused by OpenGL.  But many calls in
UpdateItems() will throw if there are internal errors such as
std::out_of_range.  Here, we catch those errors and simply skip ahead
rather than falling back to Cairo
2022-01-05 13:46:15 -08:00
Steffen Mauch 7afe188a29 eeschema: automatic generated symbol library from EAGLE plugin does not include footprint reference
Fixes https://gitlab.com/kicad/code/kicad/issues/10262

(cherry picked from commit 3ced3afa68)
2022-01-05 15:28:05 -05:00
Ian McInerney 1ad1cf8374 Fix compile error with UTF8 unicode wxWidgets build
Fixes https://gitlab.com/kicad/code/kicad/issues/10210

(Cherry-picked from bd828f598c)
2022-01-05 19:45:27 +00:00
Ian McInerney abaee94109 Revert caf406943e and don't install the kicad2step lib
This fixes https://gitlab.com/kicad/code/kicad/-/issues/9944 and reverts
caf406943e. The original fix caused issues
with some CMake versions because it tried to give library dependencies
to an object library, which can't have any library dependencies.
Instead, we need it as a static library, and since there is no need to
actually have it as an end-user library, it shouldn't be in the install
command.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9944

(Cherry-picked from commit fb36e1b582)
2022-01-05 19:45:27 +00:00
Steffen Mauch d60e77176f eeschema: EAGLE plugin does not reference footprint with library suffix
Fixes https://gitlab.com/kicad/code/kicad/issues/10261

(cherry picked from commit 502e34349e)
2022-01-05 14:39:43 -05:00
Seth Hillbrand 7f1648934f Update pin cache when undoing
The pin cache is invalidated by swap, so we need to ensure that it is
reset when we undo a change to the pins in schematic editor

Fixes https://gitlab.com/kicad/code/kicad/issues/10272
2022-01-05 11:33:03 -08:00
Seth Hillbrand bef762e652 Don't strip extensions twice in BOM export
Exporting the Bill of Materials uses the netlist exporter.  Both of
these routines were stripping the extension, leading to projects like
"test.project.kicad_pro" having the project name stripped.  We separate
the BOM netlist export from generic plugin netlist export to allow the
correct behavior when exporting netlists and generating BOMs

Fixes https://gitlab.com/kicad/code/kicad/issues/10270
2022-01-05 11:07:23 -08:00
Seth Hillbrand a05ec04ee8 Set readable flags correctly on open
Missing files may be thrown during open.  These should have existence
and readable flags set correctly
2022-01-05 09:54:10 -08:00
Steffen Mauch 362eedc510 pcbnew: EAGLE plugin is case sensitive to >VALUE / >NAME
Fixes https://gitlab.com/kicad/code/kicad/issues/10253

(cherry picked from commit 82f147ecef)
2022-01-05 08:07:41 -05:00
Steffen Mauch 11402e2db1 pcbnew: fixing eagle_plugin with empty class names
Fixes #10229
https://gitlab.com/kicad/code/kicad/issues/10229

(cherry picked from commit a5307c6f59)
2022-01-05 07:22:01 -05:00
Seth Hillbrand b1658fdf9a Don't rename existing schematic file
We should never leave a situation where the schematic file may no longer
exist (if the first rename succeeds and the second fails).  So, make a
backup copy of the original schematic file and then attempt to rename
the autosave over the first file.  In this case, if either attempt
fails, we do not lose the original file

Fixes https://gitlab.com/kicad/code/kicad/issues/10074

Fixes https://gitlab.com/kicad/code/kicad/issues/10256

Fixes https://gitlab.com/kicad/code/kicad/issues/10219
2022-01-04 20:27:43 -08:00
Jon Evans f9d8ec6137 Handle footprint shapes in polygon creation
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10259
2022-01-04 21:31:22 -05:00
Jon Evans e9b91b6fab Fix creating polygons from footprint rule areas
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10257
2022-01-04 21:28:04 -05:00
Seth Hillbrand 873353d8d7 Prevent clipping by default
The text bbox inflation from fb4343bc clips dimensions by default.  This
restores the default size to not clip the dimension line.  It is still a
bit larger than I'd like it to be but is usable

Fixes https://gitlab.com/kicad/code/kicad/issues/10033
2022-01-04 12:11:23 -08:00
Seth Hillbrand a326d777f0 Don't split legacy paths
The '.' is a valid character in the legacy preferences, not a separator.
Also adds fail-safe catch for JSON throws

Fixes https://gitlab.com/kicad/code/kicad/issues/10211
2022-01-04 19:08:12 +00:00
Thomas Pointhuber dec310f7f8 altium: Fix board outline import with arcs using SHAPE_LINE_CHAIN instead of a hack 2022-01-04 19:57:26 +01:00
Seth Hillbrand ca8cf14dff Fix missing FOOTPRINT cast in swig
Fixes https://gitlab.com/kicad/code/kicad/issues/10236
2022-01-04 10:49:29 -08:00
Seth Hillbrand ed9a3deb57 Fix pad snapping in renumber pads
Snap shouldn't be looking for other items in this routine or using the
grid

Fixes https://gitlab.com/kicad/code/kicad/issues/10238
2022-01-03 17:18:03 -08:00
Wayne Stambaugh 58b07efd99 Make footprint and symbol editors use MRU path for new libraries.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10216

(cherry picked from commit ff38853886)
2022-01-03 18:36:46 -05:00
Seth Hillbrand 1874ad2f7e Catch errors from load()
Loading footprints may throw in some cases.  We need to catch these
nicely without breaking out of the full loading process

Fixes https://gitlab.com/kicad/code/kicad/issues/10213
2022-01-03 15:30:20 -08:00
Marco Ciampa b115aec42b Updated Italian translation 2022-01-03 12:02:20 +01:00
Roberto Fernandez Bautista 5e884d14c7 Rename ComparePageNumAndName -> ComparePageNum 2022-01-02 23:27:15 +00:00
Mike Williams e36381bdd2 Gerbview: Fix diff mode issues with OpenGL transparency
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10121
(cherry picked from commit 404659d275)
2022-01-02 18:18:00 -05:00
Jon Evans 45182febaf Exit router and invoke edit tool when attempting to drag an arc track
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10208
2022-01-02 16:10:26 -05:00
Jon Evans ea99c42df6 Move duplicate field handling into field parser
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10130
2022-01-02 13:19:31 -05:00
Jon Evans 0065036899 Load local settings even when not setting project active
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10179
2022-01-02 12:40:25 -05:00
Jon Evans bb388d47fc Fix undo/redo sample action plugin for latest API
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10212
2022-01-02 12:26:27 -05:00
Jon Evans 134b09004b Fix highlighting color logic when net colors are active
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10157
2022-01-02 12:11:24 -05:00
Jon Evans c52421869a Fix saving of existing appearance presets
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10166
2022-01-02 11:59:19 -05:00
Seth Hillbrand addc5574b4 Ensure merged line gets selected if either parent is
We were only checking for the selection of a single line that gets
merged.  This prevents the merged line from being highlighted but not
selected after merging

Fixes https://gitlab.com/kicad/code/kicad/issues/10202
2022-01-01 16:53:31 -08:00
Seth Hillbrand bd75cffff3 Prevent ops on empty selection
Fixes https://gitlab.com/kicad/code/kicad/issues/10164
2022-01-01 15:28:47 -08:00
Marco Ciampa 3453bf3f88 Updated Italian translation 2022-01-01 22:06:16 +01:00
Marek Roszko f139cc2d9f Add kicad_3dsg copy for qa_pcbnew to run out of build dir
Mirror of the pcbnew step for the same reason


(cherry picked from commit b85fb9137f)
2022-01-01 19:54:30 +00:00
Marek Roszko 6fd93eaa1e Silence MSVC warnings about type mismatch and unused var
(cherry picked from commit 34e90e5045)
2022-01-01 19:50:11 +00:00
Roberto Fernandez Bautista cf8c614a02 Use virtual page number when real page numbers are blank
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10158

(cherry picked from commit a0d708e04d)
2022-01-01 18:39:49 +00:00
Marco Ciampa 9fd1ad9b7b Updated Italian translation 2022-01-01 17:10:10 +01:00
jean-pierre charras d45472adcd French translation update 2021-12-31 13:23:17 +01:00
jean-pierre charras f67c0ea8c7 fix missing line breaks and non printable html char on Windows 2021-12-31 13:21:43 +01:00
jean-pierre charras 3c2bb97eae PANEL_PREVIEW_3D_MODEL: fix incorrect values of offset for unit inch and mil.
From master commit 49cb9586
2021-12-31 10:05:56 +01:00
Marek Roszko cbdfb5d396 Remove the unused updateui in the selection filter base
(cherry picked from commit e75d283007)
2021-12-30 17:18:38 +00:00
Roberto Fernandez Bautista e19acb4632 Correctly handle excluding an ERC marker in eeschema when right clicking
In addition, hide the option to exclude a marker if the selected marker
is already excluded.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10173

(cherry picked from commit 701e256b3f)
2021-12-30 17:16:04 +00:00
Erwan Rouault 11c967b259 pcbnew: Add via height support in drc length
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10135
2021-12-30 14:34:44 +00:00
Jon Evans 517e44e917 3D viewer: Disable copper thickness in OpenGL mode
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10153
2021-12-30 09:20:09 -05:00
Jon Evans 0ec440805d Tune connectivity progress reporter
We don't need quite as many updates, this helps speed a little

See https://gitlab.com/kicad/code/kicad/-/issues/10154
2021-12-30 09:16:19 -05:00
Marek Roszko 67fe8904c0 Add win32 VERSION_INFO resource blocks for the DLLs
(cherry picked from commit 3f711b8958)
2021-12-29 04:56:26 +00:00
Marek Roszko da850036e3 Append product version to task manager titlebar (effectively)
(cherry picked from commit 426f6dd485)
2021-12-29 01:27:40 +00:00
Mike Williams b80595903c Eeschema: draw dangling end shadows
(cherry picked from commit bf2c4c1584)
2021-12-28 16:10:40 -08:00
Steven A. Falco c83880428c Add python 3.11 support
(Cherry-picked from commit 40589d2c33)
2021-12-28 14:53:31 +00:00
Jacob Mealey cc84344499 fix in pcbnew/python/swig/units.i ... added error handling
Added error handling in unit conversions for the pcbnew python bindings.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10081
2021-12-28 07:21:35 +00:00
Marek Roszko 32be48222a Fix parent of schematic setup parent nodes
(cherry picked from commit 705aa64c24)
2021-12-28 01:16:18 +00:00
Marek Roszko b7ec594c0a Use the correct parent for the root node placeholders of board setup
(cherry picked from commit 38842647b8)
2021-12-28 01:16:05 +00:00
Wayne Stambaugh 2481b21d80 Don't treat project Save As path as a path and file name.
The single string ctor of wxFileName treats the string as a path and file
name.  If there is a dot in the last path name, it assumes that the last
path is actually a file name and extension.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10116

(cherry picked from commit fcc497509a)
2021-12-26 17:04:45 -05:00
Marek Roszko ceb4d08ce9 Fix race condition with ShowEventCounters on Windows
(cherry picked from commit 3dd8c57bdd)
2021-12-26 13:33:18 +00:00
Steven A. Falco 6edc605cab Several scripting options are no longer valid
Remove invalid scripting options from the yml file.
2021-12-25 11:14:26 -05:00
Mikolaj Wielgus d913e6a8f7 Restore Translators-Other section in credits 2021-12-24 20:36:10 +01:00
jean-pierre charras bde0c3e879 DIALOG_TEMPLATE_SELECTOR: Force display refresh after selecting a path
For some reason the panel showing the templates did not show the new selection
Fixes #10106
From Master branch
2021-12-24 11:51:26 +01:00
jean-pierre charras b95032901e pcbnew print: minor fix: option edge.cut on all layers not stored. Fixes #10046 https://gitlab.com/kicad/code/kicad/issues/10046 2021-12-23 18:36:42 +01:00
jean-pierre charras 753e08a944 Use ChangeValue() instead of SetValue() in some wxTextCtrl (It avoids generating unused events) 2021-12-23 18:36:42 +01:00
jean-pierre charras ee1b327162 3D viewer: fix a minor cosmetic issue. Fixes #10002 https://gitlab.com/kicad/code/kicad/issues/10002 2021-12-23 18:36:24 +01:00
jean-pierre charras da5f2366f9 PANEL_SETUP_BOARD_STACKUP: fix a typo that prevent displaying a color swatch. Fixes #10027 https://gitlab.com/kicad/code/kicad/issues/10027 2021-12-23 18:36:24 +01:00
Jeff Young e7cc177d94 Allow a 0 pin-symbol-size.
This is particularly important when reading legacy projects as 0 is
what signals the painter to use the old algorithm (1/2 pin name/number
size).

Fixes https://gitlab.com/kicad/code/kicad/issues/10100

(cherry picked from commit f089cf44a7)
2021-12-23 17:01:48 +00:00
Jeff Young 93c48b9d46 Hot-update units in track editing dialogs.
Fixes https://gitlab.com/kicad/code/kicad/issues/10099

(cherry picked from commit 4e8a7fc911)
2021-12-23 17:01:44 +00:00
Jeff Young 1b033d56a7 Improve clean up tracks & vias algorithm for neck-downs.
Fixes https://gitlab.com/kicad/code/kicad/issues/10098

(cherry picked from commit d5a5928e5a)
2021-12-23 17:01:39 +00:00
Jeff Young ad583eab13 Add hot-updating of units in common wxGrids.
Fixes https://gitlab.com/kicad/code/kicad/issues/10020

(cherry picked from commit 6e2460ad37)
2021-12-23 17:01:34 +00:00
Jeff Young 0d3246e3ab Don't commit zone refill if there were no changes.
Fixes https://gitlab.com/kicad/code/kicad/issues/10085

(cherry picked from commit 77239591c0)
2021-12-23 17:01:31 +00:00
Jeff Young 76fd029cd6 Don't leave stranded symbols/footprints in editors when doc closes.
Fixes https://gitlab.com/kicad/code/kicad/issues/10026

(cherry picked from commit 9af33cdfe8)
2021-12-23 17:01:25 +00:00
Jeff Young 2efa878287 Use a bigger hammer to update adjacent segments.
Fixes https://gitlab.com/kicad/code/kicad/issues/9927

(cherry picked from commit ee5db73113)
2021-12-23 17:01:22 +00:00
Jeff Young 1dc78c4adc Tidy up pad & parent footprint selection corner cases.
Fixes https://gitlab.com/kicad/code/kicad/issues/9923

(cherry picked from commit d9dba2edb2)
2021-12-23 17:01:19 +00:00
Jeff Young 34d855cd53 Make sure undo/redo of pagesetup is done to correct sheet.
Fixes https://gitlab.com/kicad/code/kicad/issues/9999

(cherry picked from commit aa4dcb2bf1)
2021-12-23 17:01:15 +00:00
Jeff Young 9cb36e5bc5 Restore units to a bunch of wxGrids.
Fixes https://gitlab.com/kicad/code/kicad/issues/10063

(cherry picked from commit 8b52e969d6)
2021-12-23 17:01:10 +00:00
Jeff Young b6ff44cccf Fix failure to remove hover selection after rotate operation.
Fixes https://gitlab.com/kicad/code/kicad/issues/10058

(cherry picked from commit f696c4ddfc)
2021-12-23 17:01:06 +00:00
Jeff Young e9e742816d Scale markers somewhat proportionally to zoom.
Fixes https://gitlab.com/kicad/code/kicad/issues/10048

(cherry picked from commit a1c8e36c99)
2021-12-23 17:01:01 +00:00
Wayne Stambaugh b403930601 Begin version 6.0.1 development. 2021-12-22 08:44:30 -05:00
9000 changed files with 1089515 additions and 2664762 deletions
+9 -12
View File
@@ -1,9 +1,8 @@
.downloads-by-cmake
.gdb_history
boost_root
/Build
/build
/cmake-build-*
Build*
build*
common/fp_lib_table_keywords.cpp
common/drc_rules_keywords.cpp
common/drc_rules_lexer.h
@@ -24,17 +23,19 @@ eeschema/dialogs/dialog_bom_cfg_lexer.h
common/template_fieldnames_keywords.cpp
common/template_fieldnames_lexer.h
eeschema/schematic_keywords.*
eeschema/sch_text_help_md.h
pcbnew/pcb_plot_params_keywords.cpp
pcbnew/pcb_plot_params_lexer.h
pcbnew/dialogs/panel_setup_rules_help_md.h
Makefile
CMakeCache.txt
.cache/
auto_renamed_to_cpp
Testing
version.h
config.h
install_manifest.txt
doxygen/out
Documentation/doxygen
Documentation/development/doxygen
*.bak
*.pyc
common/pcb_plot_params_keywords.cpp
@@ -79,6 +80,7 @@ pcbnew/Info.plist
*.o.*
*.a
*.a.*
*.cmake
*.orig
*.rej
*.so
@@ -88,7 +90,7 @@ pcbnew/Info.plist
*.patch
# These CMake files are wanted
!cmake/**/*.cmake
!CMakeModules/*.cmake
# Eclipse IDE
.settings/
@@ -101,7 +103,6 @@ __pycache__
.vs/
.editorconfig
CMakeSettings.json
.vscode/
# Sublime Text
*.sublime-*
@@ -119,14 +120,10 @@ i18n_status.csv
*.kicad_prl
*-backups
# QA dataoutput
qa/data/**/*.csv
# Don't actually ignore any of these files, since we need them in the tree
!resources/linux/icons/hicolor/**/**/*
!resources/linux/icons-nightly/hicolor/**/**/*
!CMakeModules/**/*
!resources/bitmaps_png/png/**/*
!bitmaps_png/png/**/*
# Junk temp files generated by MSVC for resource files
/resources/msw/RC*
+4 -7
View File
@@ -5,7 +5,7 @@ stages:
default:
image:
name: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:36
name: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:34
entrypoint: ["/bin/sh", "-c"]
@@ -14,7 +14,7 @@ default:
##########################################################################
# 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
# https://gitlab.com/gitlab-org/gitlab/issues/12850
test_formatting:
stage: test
needs: []
@@ -23,10 +23,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
@@ -45,4 +43,3 @@ include:
- local: '/.gitlab/Windows-CI.yml'
- local: '/.gitlab/coverity.yml'
- local: '/.gitlab/linux-metadata-validate.yml'
- local: '/.gitlab/doxygen.yml'
+16 -88
View File
@@ -1,12 +1,11 @@
##########################################################################
# Build KiCad on Fedora and save the results
##########################################################################
.fedora_build_linux_base:
fedora_build_linux:
stage: build
# Don't tag until we have separate CI for MRs
# tags:
# - kicad-fedora
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
tags:
- kicad-fedora
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:34
extends: .only_code
interruptible: false
cache:
@@ -23,8 +22,9 @@
- cd build/linux
- cmake
-G Ninja
-DCMAKE_BUILD_TYPE=QABUILD
-DCMAKE_BUILD_TYPE=Debug
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_USE_OCC=ON
-DKICAD_SPICE=ON
-DKICAD_BUILD_I18N=ON
../../
@@ -39,35 +39,18 @@
paths:
- build/linux/3d-viewer/
- build/linux/pcbnew/pcbnew.py
- build/linux/pcbnew/_pcbnew.kiface
- build/linux/pcbnew/_pcbnew.so
- build/linux/qa/
- build/linux/compilation_log.txt
exclude:
- build/linux/**/*.o
- build/linux/**/*.a
# This split is to ensure we can always use our runner for our jobs
fedora_build_linux_kicad:
extends: .fedora_build_linux_base
tags:
- kicad-fedora
only:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
fedora_build_linux_public:
extends: .fedora_build_linux_base
except:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
# Upload the compilation log in an easily downloadable form
.fedora_report_build_warn:
fedora_report_build_warn:
stage: report
extends: .only_code
when: always
needs:
- job: fedora_build_linux
artifacts: true
script:
- echo "Uploading compilation log"
- cp build/linux/compilation_log.txt compilation_log.txt
@@ -78,32 +61,14 @@ fedora_build_linux_public:
paths:
- compilation_log.txt
fedora_report_build_warn_kicad:
extends: .fedora_report_build_warn
tags:
- kicad-fedora
needs:
- job: fedora_build_linux_kicad
artifacts: true
only:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
fedora_report_build_warn_public:
extends: .fedora_report_build_warn
needs:
- job: fedora_build_linux_public
artifacts: true
except:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
# Report on the metrics of the code
.fedora_report_metrics:
fedora_report_metrics:
stage: report
extends: .only_code
when: always
needs:
- job: fedora_build_linux
artifacts: true
script:
- cat build/linux/compilation_log.txt | { grep "warning:" || test $? = 1; } | awk 'END{print "number_of_fedora_warnings "NR}' > metrics.txt
- cat metrics.txt
@@ -111,31 +76,11 @@ fedora_report_build_warn_public:
reports:
metrics: metrics.txt
fedora_report_metrics_kicad:
extends: .fedora_report_metrics
tags:
- kicad-fedora
needs:
- job: fedora_build_linux_kicad
artifacts: true
only:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
fedora_report_metrics_public:
extends: .fedora_report_metrics
needs:
- job: fedora_build_linux_public
artifacts: true
except:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
##########################################################################
# Run the code unit tests.
##########################################################################
.fedora_qa:
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
fedora_qa:
extends:
- .unit_test
- .only_code
@@ -143,23 +88,6 @@ fedora_report_metrics_public:
matrix:
# The name of the test without the qa_ prefix
- TEST: [python, common, gerbview, pcbnew, eeschema, kimath, sexpr, kicad2step]
fedora_qa_kicad:
extends: .fedora_qa
tags:
- kicad-fedora
needs:
- job: fedora_build_linux_kicad
- job: fedora_build_linux
artifacts: true
only:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
fedora_qa_public:
extends: .fedora_qa
needs:
- job: fedora_build_linux_public
artifacts: true
except:
variables:
- $CI_PROJECT_ROOT_NAMESPACE == "kicad"
+1 -5
View File
@@ -28,7 +28,7 @@
-G Ninja
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=Debug
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SCRIPTING_WXPYTHON=ON
-DKICAD_USE_OCC=ON
@@ -47,13 +47,9 @@
paths:
- build/linux/3d-viewer/
- build/linux/pcbnew/pcbnew.py
- build/linux/pcbnew/_pcbnew.kiface
- build/linux/pcbnew/_pcbnew.so
- build/linux/qa/
- build/linux/compilation_log.txt
exclude:
- build/linux/**/*.o
- build/linux/**/*.a
# Upload the compilation log in an easily downloadable form
.ubuntu20.04_report_build_warn:
+2 -14
View File
@@ -7,33 +7,21 @@ win64_build:
- kicad-windows-1809
extends: .only_code
interruptible: false
image: registry.gitlab.com/kicad/kicad-ci/windows-build-image/win1809-msvc:latest
variables:
VCPKG_BINARY_SOURCES: 'nuget,kicad,readwrite'
cache:
key: win64-vcpkg-"$CI_COMMIT_REF_SLUG"
paths:
- build\windows\vcpkg_installed
- .vcpkgCache
image: registry.gitlab.com/kicad/kicad-ci/source_containers/win64:msvc1809
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 `
-G "Ninja" `
-DCMAKE_TOOLCHAIN_FILE=C:\builder\vcpkg\scripts\buildsystems\vcpkg.cmake `
-DCMAKE_TOOLCHAIN_FILE=C:\build\vcpkg\scripts\buildsystems\vcpkg.cmake `
-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 `
../../
- cmake --build . 2>&1 | tee compilation_log.txt
- cd ../../
+4 -2
View File
@@ -25,7 +25,7 @@
tar cfz cov-int.tar.gz cov-int
echo "Submitting scan results"
export KICAD_VERSION=$(sed 's/[()]//g' kicad_build_version.txt)
curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME \
curl -v https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME \
--form token=$COVERITY_SCAN_TOKEN \
--form email=$GITLAB_USER_EMAIL \
--form file=@cov-int.tar.gz \
@@ -39,7 +39,8 @@ Coverity:
tags:
- coverity
stage: build
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
# Use Fedora 33 because Coverity needs GCC 10 still (as of 06/16/2021)
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:33
only:
refs:
- schedules
@@ -59,6 +60,7 @@ Coverity:
-DCMAKE_BUILD_TYPE=Debug
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SCRIPTING_WXPYTHON=ON
-DKICAD_USE_OCC=ON
-DKICAD_SPICE=ON
- coverity/bin/cov-build --dir cov-int make -j8
- *coverity_submit
-18
View File
@@ -1,18 +0,0 @@
build_doxygen_docker:
image: docker:stable
services:
- docker:dind
stage: build
tags:
- 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"
-20
View File
@@ -1,20 +0,0 @@
<!-- --------Before Creating a New Issue-----------
* Limit report to a single issue.
* Search the issue tracker to verify the issue has not already been reported.
* Complete all instructions between `template comment markers <>.
* Keep report contents limited to the necessary information required to fix the issue.
* When creating an issue against the stable version of KiCad, make sure the latest available stable version is installed as issues may have already been resolved in later stable versions. -->
# Description
<!-- What is the current behavior and what is the expected behavior? -->
<!-- If the issue is visual/graphical, please attach screenshots of the problem. -->
<!-- Add the issue details below this line and before the "Steps to reproduce" heading. -->
# Steps to reproduce
<!-- If there are multiple steps to reproduce it or it is a visual issue, then providing a screen recording as an attachment to this report is recommended. -->
<!-- If this issue is specific to a project, please attach the necessary files to this issue. -->
<!-- Add the steps to reproduce using the numbers below -->
<!-- Add new step numbers before the "KiCad Version" heading. -->
1.
# KiCad Version
+2 -1
View File
@@ -6,7 +6,7 @@ validate_linux_metadata:
needs: []
interruptible: false
# 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
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:34
# 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
@@ -31,6 +31,7 @@ validate_linux_metadata:
-DCMAKE_BUILD_TYPE=Debug
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SCRIPTING_WXPYTHON=ON
-DKICAD_USE_OCC=ON
-DKICAD_SPICE=ON
-DKICAD_BUILD_I18N=ON
../../
-25
View File
@@ -1,25 +0,0 @@
##########################################################################
# 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: []
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
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}
+2 -2
View File
@@ -11,7 +11,7 @@
- schedules
##########################################################################
# Define a template for all the unit tests, since each one is run in a separate
# Define a template for all the unit tests, since each one is run in a separate
# job to make the display nicer.
##########################################################################
.unit_test:
@@ -28,7 +28,7 @@
# 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. Note that there is a bug with how paths
# are processed in the junit report (https://gitlab.com/gitlab-org/gitlab/-/issues/23835)
# 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:
reports:
+23 -36
View File
@@ -2,8 +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 (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2022 CERN
* Copyright (C) 2018-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,6 +29,7 @@
#include <wx/datetime.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/stdpaths.h>
@@ -55,7 +55,6 @@
#include <project.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <wx_filename.h>
#define MASK_3D_CACHE "3D_CACHE"
@@ -195,20 +194,29 @@ S3D_CACHE::S3D_CACHE()
S3D_CACHE::~S3D_CACHE()
{
COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
FlushCache();
// We'll delete ".3dc" cache files older than this many days
int clearCacheInterval = commonSettings->m_System.clear_3d_cache_interval;
// An interval of zero means the user doesn't want to ever clear the cache
if( clearCacheInterval > 0 )
CleanCacheDir( clearCacheInterval );
delete m_FNResolver;
delete m_Plugins;
}
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePath,
S3D_CACHE_ENTRY** aCachePtr )
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCachePtr )
{
if( aCachePtr )
*aCachePtr = nullptr;
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile, aBasePath );
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile );
if( full3Dpath.empty() )
{
@@ -273,9 +281,9 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePa
}
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath )
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile )
{
return load( aModelFile, aBasePath );
return load( aModelFile );
}
@@ -296,7 +304,8 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
// or we do not have a configured cache file directory, we create an
// entry to prevent further attempts at loading the file
if( m_CacheMap.emplace( aFileName, ep ).second == false )
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
( aFileName, ep ) ).second == false )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
@@ -314,7 +323,8 @@ SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY**
return nullptr;
}
if( m_CacheMap.emplace( aFileName, ep ).second == false )
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
( aFileName, ep ) ).second == false )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
@@ -503,7 +513,7 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
wxFileName cfgdir( ExpandEnvVarSubstitutions( aConfigDir, m_project ), wxEmptyString );
cfgdir.Normalize( FN_NORMALIZE_FLAGS );
cfgdir.Normalize();
if( !cfgdir.DirExists() )
{
@@ -632,10 +642,10 @@ void S3D_CACHE::ClosePlugins()
}
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName, const wxString& aBasePath )
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName )
{
S3D_CACHE_ENTRY* cp = nullptr;
SCENEGRAPH* sp = load( aModelFileName, aBasePath,&cp );
SCENEGRAPH* sp = load( aModelFileName, &cp );
if( !sp )
return nullptr;
@@ -700,29 +710,6 @@ 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 );
+3 -4
View File
@@ -92,10 +92,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
* @return true if the model was successfully loaded, otherwise false.
*/
SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath );
SCENEGRAPH* Load( const wxString& aModelFile );
FILENAME_RESOLVER* GetResolver() noexcept;
@@ -125,7 +124,7 @@ public:
* @param aModelFileName is the full path to the model to be loaded.
* @return is a pointer to the render data or NULL if not available.
*/
S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath );
S3DMODEL* GetModel( const wxString& aModelFileName );
/**
* Delete up old cache files in cache directory.
@@ -165,7 +164,7 @@ 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 );
SCENEGRAPH* load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCachePtr = nullptr );
/// cache entries
std::list< S3D_CACHE_ENTRY* > m_CacheList;
+51 -46
View File
@@ -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 (C) 2020-2023 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
@@ -29,13 +29,13 @@
#include <wx/dir.h>
#include <wx/dynlib.h>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/stdpaths.h>
#include <wx/string.h>
#include <common.h>
#include <paths.h>
#include <wx_filename.h>
#include "3d_plugin_manager.h"
#include "plugins/3d/3d_plugin.h"
#include "3d_cache/sg/scenegraph.h"
@@ -55,7 +55,7 @@
S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER()
{
// create the initial file filter list entry
m_FileFilters.emplace_back( _( "All Files" ) + wxT( " (*.*)|*.*" ) );
m_FileFilters.push_back( _( "All Files" ) + wxT( " (*.*)|*.*" ) );
// discover and load plugins
loadPlugins();
@@ -120,48 +120,57 @@ S3D_PLUGIN_MANAGER::~S3D_PLUGIN_MANAGER()
void S3D_PLUGIN_MANAGER::loadPlugins( void )
{
std::list<wxString> searchpaths;
std::list<wxString> pluginlist;
wxFileName fn;
std::list< wxString > searchpaths;
std::list< wxString > pluginlist;
wxFileName fn;
#ifndef __WXMAC__
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
#ifdef DEBUG
// set up to work from the build directory
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
fn.AppendDir( wxT( ".." ) );
fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) );
std::string testpath = std::string( fn.GetPathWithSep().ToUTF8() );
checkPluginPath( testpath, searchpaths );
// add subdirectories too
wxDir debugPluginDir;
wxString subdir;
debugPluginDir.Open( testpath );
if( debugPluginDir.IsOpened() && debugPluginDir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS ) )
{
// set up to work from the build directory
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
fn.AppendDir( wxT( ".." ) );
fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) );
checkPluginPath( testpath + subdir, searchpaths );
std::string testpath = std::string( fn.GetPathWithSep().ToUTF8() );
checkPluginPath( testpath, searchpaths );
// add subdirectories too
wxDir debugPluginDir;
wxString subdir;
debugPluginDir.Open( testpath );
if( debugPluginDir.IsOpened()
&& debugPluginDir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS ) )
{
while( debugPluginDir.GetNext( &subdir ) )
checkPluginPath( testpath + subdir, searchpaths );
while( debugPluginDir.GetNext( &subdir ) )
checkPluginPath( testpath + subdir, searchpaths );
}
}
#endif
fn.AssignDir( PATHS::GetStockPlugins3DPath() );
checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );
// check for per-user third party plugins
// note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name;
fn.AssignDir( PATHS::GetUserPlugins3DPath() );
checkPluginPath( fn.GetPathWithSep(), searchpaths );
#else
// Search path on OS X is
// (1) Machine /Library/Application Support/kicad/PlugIns/3d
// (1) User ~/Library/Application Support/kicad/PlugIns/3d
checkPluginPath( PATHS::GetOSXKicadUserDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
// (2) Machine /Library/Application Support/kicad/PlugIns/3d
checkPluginPath( PATHS::GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
// (2) Bundle kicad.app/Contents/PlugIns/3d
// (3) Bundle kicad.app/Contents/PlugIns/3d
fn.AssignDir( PATHS::GetStockPlugins3DPath() );
checkPluginPath( fn.GetPathWithSep(), searchpaths );
#endif
std::list< wxString >::iterator sPL = searchpaths.begin();
@@ -248,7 +257,7 @@ void S3D_PLUGIN_MANAGER::listPlugins( const wxString& aPath, std::list< wxString
// Per definition a loadable "xxx.bundle" is similar to an "xxx.app" app
// bundle being a folder with some special content in it. We obviously don't
// want to have that here for our loadable module, so just use ".so".
nameFilter.Append( wxS( ".so" ) );
nameFilter.Append( ".so" );
#endif
wxString lp = wd.GetNameWithSep();
@@ -279,7 +288,7 @@ void S3D_PLUGIN_MANAGER::checkPluginName( const wxString& aPath,
wxFileName path( ExpandEnvVarSubstitutions( aPath, nullptr ) );
path.Normalize( FN_NORMALIZE_FLAGS );
path.Normalize();
// determine if the path is already in the list
wxString wxpath = path.GetFullPath();
@@ -294,16 +303,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() );
@@ -313,15 +312,21 @@ void S3D_PLUGIN_MANAGER::checkPluginName( const wxString& aPath,
void S3D_PLUGIN_MANAGER::checkPluginPath( const wxString& aPath,
std::list< wxString >& aSearchList )
{
// check the existence of a path and add it to the path search list
if( aPath.empty() )
return;
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * [INFO] checking if valid plugin directory '%s'\n" ),
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * [INFO] checking for 3D plugins in '%s'\n" ),
aPath.GetData() );
wxFileName path;
path.AssignDir( aPath );
path.Normalize( FN_NORMALIZE_FLAGS );
if( aPath.StartsWith( wxT( "${" ) ) || aPath.StartsWith( wxT( "$(" ) ) )
path.Assign( ExpandEnvVarSubstitutions( aPath, nullptr ), wxEmptyString );
else
path.Assign( aPath, wxEmptyString );
path.Normalize();
if( !wxFileName::DirExists( path.GetFullPath() ) )
return;
@@ -386,7 +391,7 @@ void S3D_PLUGIN_MANAGER::addExtensionMap( KICAD_PLUGIN_LDR_3D* aPlugin )
if( !ws.empty() )
{
m_ExtMap.emplace( ws, aPlugin );
m_ExtMap.insert( std::pair< const wxString, KICAD_PLUGIN_LDR_3D* >( ws, aPlugin ) );
}
}
+1 -1
View File
@@ -359,7 +359,7 @@ S3DMODEL* S3D::GetModel( SCENEGRAPH* aNode )
app.transparency = 0.0f;
materials.matorder.push_back( &app );
materials.matmap.emplace( &app, 0 );
materials.matmap.insert( std::pair< SGAPPEARANCE const*, int >( &app, 0 ) );
if( aNode->Prepare( nullptr, materials, meshes ) )
{
+6 -3
View File
@@ -420,7 +420,8 @@ bool S3D::CalcTriangleNormals( std::vector< SGPOINT > coords, std::vector< int >
}
else
{
vmap.emplace( p1, std::list < glm::dvec3 >( 1, tri ) );
vmap.insert( std::pair < int, std::list < glm::dvec3 > >
( p1, std::list < glm::dvec3 >( 1, tri ) ) );
}
ip = vmap.find( p2 );
@@ -431,7 +432,8 @@ bool S3D::CalcTriangleNormals( std::vector< SGPOINT > coords, std::vector< int >
}
else
{
vmap.emplace( p2, std::list < glm::dvec3 >( 1, tri ) );
vmap.insert( std::pair < int, std::list < glm::dvec3 > >
( p2, std::list < glm::dvec3 >( 1, tri ) ) );
}
ip = vmap.find( p3 );
@@ -442,7 +444,8 @@ bool S3D::CalcTriangleNormals( std::vector< SGPOINT > coords, std::vector< int >
}
else
{
vmap.emplace( p3, std::list < glm::dvec3 >( 1, tri ) );
vmap.insert( std::pair < int, std::list < glm::dvec3 > >
( p3, std::list < glm::dvec3 >( 1, tri ) ) );
}
}
+1 -1
View File
@@ -260,7 +260,7 @@ bool S3D::GetMatIndex( MATLIST& aList, SGNODE* aNode, int& aIndex )
int idx = (int)aList.matorder.size();
aList.matorder.push_back( node );
aList.matmap.emplace( node, idx );
aList.matmap.insert( std::pair< SGAPPEARANCE const*, int >( node, idx ) );
aIndex = idx;
return true;
+1 -1
View File
@@ -699,7 +699,7 @@ bool SGSHAPE::Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
if( mit == indexmap.end() )
{
indexmap.emplace( lv[i], vertices.size() );
indexmap.insert( std::pair< int, unsigned int >( lv[i], vertices.size() ) );
vertices.push_back( lv[i] );
}
}
+172 -148
View File
@@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2022 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* 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
@@ -33,20 +33,10 @@
#include <3d_math.h>
#include "3d_fastmath.h"
#include <geometry/geometry_utils.h>
#include <convert_to_biu.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <wx/log.h>
#include <pcbnew_settings.h>
#include <advanced_config.h>
#define DEFAULT_BOARD_THICKNESS pcbIUScale.mmToIU( 1.6 )
#define DEFAULT_COPPER_THICKNESS pcbIUScale.mmToIU( 0.035 ) // for 35 um
// The solder mask layer (and silkscreen) thickness
#define DEFAULT_TECH_LAYER_THICKNESS pcbIUScale.mmToIU( 0.025 )
// The solder paste thickness is chosen bigger than the solder mask layer
// to be sure is covers the mask when overlapping.
#define SOLDERPASTE_LAYER_THICKNESS pcbIUScale.mmToIU( 0.04 )
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_SilkscreenColors;
@@ -63,9 +53,6 @@ KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderPaste;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSurfaceFinish;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBoardBody;
// To be used in Raytracing render to create bevels on layer items
float g_BevelThickness3DU = 0.0f;
static bool g_ColorsLoaded = false;
/**
@@ -80,23 +67,26 @@ const wxChar *BOARD_ADAPTER::m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" );
BOARD_ADAPTER::BOARD_ADAPTER() :
m_Cfg( nullptr ),
m_IsBoardView( true ),
m_MousewheelPanning( true ),
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_gridType = GRID3D_TYPE::NONE;
m_antiAliasingMode = ANTIALIASING_MODE::AA_8X;
m_drawFlags.resize( FL_LAST, false );
m_boardPos = VECTOR2I();
m_boardSize = VECTOR2I();
if( PgmOrNull() )
m_colors = Pgm().GetSettingsManager().GetColorSettings();
m_renderEngine = RENDER_ENGINE::OPENGL;
m_materialMode = MATERIAL_MODE::NORMAL;
m_boardPos = wxPoint();
m_boardSize = wxSize();
m_boardCenter = SFVEC3F( 0.0f );
m_boardBoundingBox.Reset();
@@ -105,14 +95,12 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_throughHoleOds.Clear();
m_throughHoleAnnularRings.Clear();
m_copperLayersCount = 2;
m_copperLayersCount = -1;
m_epoxyThickness3DU = 0.0f;
m_copperThickness3DU = 0.0f;
m_nonCopperLayerThickness3DU = 0.0f;
m_solderPasteLayerThickness3DU = 0.0f;
m_biuTo3Dunits = 1.0;
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;
m_trackCount = 0;
m_viaCount = 0;
@@ -121,6 +109,27 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_averageHoleDiameter = 0.0f;
m_averageTrackWidth = 0.0f;
SetFlag( FL_USE_REALISTIC_MODE, true );
SetFlag( FL_FP_ATTRIBUTES_NORMAL, true );
SetFlag( FL_SHOW_BOARD_BODY, true );
SetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS, false );
SetFlag( FL_FP_ATTRIBUTES_NORMAL, true );
SetFlag( FL_FP_ATTRIBUTES_NORMAL_INSERT, true );
SetFlag( FL_FP_ATTRIBUTES_VIRTUAL, true );
SetFlag( FL_ZONE, true );
SetFlag( FL_SILKSCREEN, true );
SetFlag( FL_SOLDERMASK, true );
SetFlag( FL_SUBTRACT_MASK_FROM_SILK, false );
SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, true );
SetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, false );
SetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE, false );
SetFlag( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, false );
SetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, false );
SetFlag( FL_USE_SELECTION, true );
SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, true );
m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
@@ -137,10 +146,22 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_frontPlatedPadPolys = nullptr;
m_backPlatedPadPolys = nullptr;
// Avoid raytracing options not initialized:
m_RtShadowSampleCount = 0;
m_RtReflectionSampleCount = 0;
m_RtRefractionSampleCount = 0;
m_RtSpreadShadows = 0.0;
m_RtSpreadReflections = 0.0;
m_RtSpreadRefractions = 0.0;
m_RtRecursiveReflectionCount = 0;
m_RtRecursiveRefractionCount = 0;
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 )
list.push_back( CUSTOM_COLOR_ITEM( r/255.0, g/255.0, b/255.0, a, name ) )
ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, NotSpecifiedPrm() ); // White
ADD_COLOR( g_SilkscreenColors, 20, 51, 36, 1.0, wxT( "Green" ) );
@@ -208,15 +229,6 @@ BOARD_ADAPTER::~BOARD_ADAPTER()
}
void BOARD_ADAPTER::ReloadColorSettings() noexcept
{
wxASSERT( PgmOrNull() );
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
{
wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
@@ -230,38 +242,50 @@ bool BOARD_ADAPTER::Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const
{
case B_Adhes:
case F_Adhes:
return m_Cfg->m_Render.show_adhesive;
return GetFlag( FL_ADHESIVE );
case B_Paste:
case F_Paste:
return m_Cfg->m_Render.show_solderpaste;
return GetFlag( FL_SOLDERPASTE );
case B_SilkS:
case F_SilkS:
return m_Cfg->m_Render.show_silkscreen;
return GetFlag( FL_SILKSCREEN );
case B_Mask:
case F_Mask:
return m_Cfg->m_Render.show_soldermask;
return GetFlag( FL_SOLDERMASK );
case Dwgs_User:
case Cmts_User:
return !m_Cfg->m_Render.realistic && m_Cfg->m_Render.show_comments;
if( GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
return GetFlag( FL_COMMENTS );
case Eco1_User:
case Eco2_User:
return !m_Cfg->m_Render.realistic && m_Cfg->m_Render.show_eco;
if( GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
return GetFlag( FL_ECO );
case Edge_Cuts:
return !m_Cfg->m_Render.realistic && !m_Cfg->m_Render.show_board_body;
if( GetFlag( FL_SHOW_BOARD_BODY ) || GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
return true;
case Margin:
return !m_Cfg->m_Render.realistic;
if( GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
return true;
case B_Cu:
case F_Cu:
return !m_board || m_board->IsLayerVisible( aLayer ) || m_Cfg->m_Render.realistic
|| m_board->IsFootprintHolder();
return m_board ? m_board->IsLayerVisible( aLayer ) || GetFlag( FL_USE_REALISTIC_MODE )
: true;
default:
// the layer is an internal copper layer, used the visibility
@@ -270,31 +294,45 @@ bool BOARD_ADAPTER::Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const
}
bool BOARD_ADAPTER::IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const
bool BOARD_ADAPTER::GetFlag( DISPLAY3D_FLG aFlag ) const
{
if( m_IsPreviewer ) // In panel Preview, footprints are always shown, of course
return true;
wxASSERT( aFlag < FL_LAST );
if( aFPAttributes & FP_EXCLUDE_FROM_POS_FILES )
{
if( !m_Cfg->m_Render.show_footprints_not_in_posfile )
return false;
}
if( aFPAttributes & FP_SMD )
return m_Cfg->m_Render.show_footprints_insert;
if( aFPAttributes & FP_THROUGH_HOLE )
return m_Cfg->m_Render.show_footprints_normal;
return m_Cfg->m_Render.show_footprints_virtual;
return m_drawFlags[aFlag];
}
void BOARD_ADAPTER::SetFlag( DISPLAY3D_FLG aFlag, bool aState )
{
wxASSERT( aFlag < FL_LAST );
m_drawFlags[aFlag] = aState;
}
bool BOARD_ADAPTER::IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const
{
if( aFPAttributes & FP_SMD )
return GetFlag( FL_FP_ATTRIBUTES_NORMAL_INSERT );
else if( aFPAttributes & FP_THROUGH_HOLE )
return GetFlag( FL_FP_ATTRIBUTES_NORMAL );
else
return GetFlag( FL_FP_ATTRIBUTES_VIRTUAL );
}
// !TODO: define the actual copper thickness by user from board stackup
#define COPPER_THICKNESS Millimeter2iu( 0.035 ) // for 35 um
// The solder mask layer (and silkscreen) thickness
#define TECH_LAYER_THICKNESS Millimeter2iu( 0.025 )
// The solder paste thickness is chosen bigger than the solder mask layer
// to be sure is covers the mask when overlapping.
#define SOLDERPASTE_LAYER_THICKNESS Millimeter2iu( 0.04 )
int BOARD_ADAPTER::GetHolePlatingThickness() const noexcept
{
return m_board ? m_board->GetDesignSettings().GetHolePlatingThickness()
: DEFAULT_COPPER_THICKNESS;
: 0.035 * PCB_IU_PER_MM;
}
@@ -310,7 +348,7 @@ unsigned int BOARD_ADAPTER::GetCircleSegmentCount( int aDiameterBIU ) const
{
wxASSERT( aDiameterBIU > 0 );
return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, FULL_CIRCLE );
return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, 360.0 );
}
@@ -323,28 +361,34 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
wxString msg;
const bool haveOutline = createBoardPolygon( &msg );
const bool succeedToGetBoardPolygon = createBoardPolygon( &msg );
if( aWarningReporter )
{
if( !haveOutline )
if( !succeedToGetBoardPolygon )
aWarningReporter->Report( msg, RPT_SEVERITY_WARNING );
else
aWarningReporter->Report( wxEmptyString );
}
BOX2I bbbox;
// Calculates the board bounding box (board outlines + items)
// to ensure any item, even outside the board outlines can be seen
bool boardEdgesOnly = true;
if( ( m_board && m_board->IsFootprintHolder() ) || !GetFlag( FL_USE_REALISTIC_MODE )
|| !succeedToGetBoardPolygon )
{
boardEdgesOnly = false;
}
EDA_RECT bbbox;
if( m_board )
{
bbbox = m_board->ComputeBoundingBox( !m_board->IsFootprintHolder()
&& m_Cfg->m_Render.realistic
&& haveOutline );
}
bbbox = m_board->ComputeBoundingBox( boardEdgesOnly );
// Gives a non null size to avoid issues in zoom / scale calculations
if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
bbbox.Inflate( pcbIUScale.mmToIU( 10 ) );
bbbox.Inflate( Millimeter2iu( 10 ) );
m_boardSize = bbbox.GetSize();
m_boardPos = bbbox.Centre();
@@ -363,54 +407,20 @@ 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 );
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;
m_epoxyThickness3DU = m_board
? m_board->GetDesignSettings().GetBoardThickness() * m_biuTo3Dunits
: 1.6 * PCB_IU_PER_MM * m_biuTo3Dunits;
g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 ) * m_biuTo3Dunits;
if( m_board )
{
const BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
if( bds.GetStackupDescriptor().GetCount() )
{
int thickness = 0;
for( BOARD_STACKUP_ITEM* item : bds.GetStackupDescriptor().GetList() )
{
switch( item->GetType() )
{
case BS_ITEM_TYPE_DIELECTRIC:
for( int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
thickness += item->GetThickness( sublayer );
break;
case BS_ITEM_TYPE_COPPER:
if( item->GetBrdLayerId() == F_Cu )
m_frontCopperThickness3DU = item->GetThickness() * m_biuTo3Dunits;
else if( item->GetBrdLayerId() == B_Cu )
m_backCopperThickness3DU = item->GetThickness() * m_biuTo3Dunits;
else if( item->IsEnabled() )
thickness += item->GetThickness();
break;
default:
break;
}
}
m_boardBodyThickness3DU = thickness * m_biuTo3Dunits;
}
}
// !TODO: use value defined by user (currently use default values by ctor
m_copperThickness3DU = COPPER_THICKNESS * m_biuTo3Dunits;
m_nonCopperLayerThickness3DU = TECH_LAYER_THICKNESS * m_biuTo3Dunits;
m_solderPasteLayerThickness3DU = SOLDERPASTE_LAYER_THICKNESS * m_biuTo3Dunits;
// 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 = 31)
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
// all unused copper layer z position are set to 0
// ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
// | | Top = Bottom + m_copperThickness
@@ -422,26 +432,24 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
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.
m_layerZcoordBottom[layer] = m_boardBodyThickness3DU / 2.0f -
(m_boardBodyThickness3DU * layer / (m_copperLayersCount - 1) );
m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
(m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
if( layer < (m_copperLayersCount / 2) )
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] + m_frontCopperThickness3DU;
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] + m_copperThickness3DU;
else
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] - m_backCopperThickness3DU;
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] - m_copperThickness3DU;
}
#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
// Fill remaining unused copper layers and back layer zpos
// with -m_epoxyThickness / 2.0
for( ; layer < MAX_CU_LAYERS; layer++ )
{
m_layerZcoordBottom[layer] = -( m_boardBodyThickness3DU / 2.0f );
m_layerZcoordTop[layer] = -( m_boardBodyThickness3DU / 2.0f ) - m_backCopperThickness3DU;
m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
m_layerZcoordTop[layer] = -(m_epoxyThickness3DU / 2.0f) - m_copperThickness3DU;
}
// This is the top of the copper layer thickness.
@@ -597,7 +605,32 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
case BS_ITEM_TYPE_DIELECTRIC:
{
KIGFX::COLOR4D layerColor = findColor( colorName, g_BoardColors );
KIGFX::COLOR4D layerColor = COLOR4D::UNSPECIFIED;
const wxString& materialName = stackupItem->GetMaterial();
if( materialName.StartsWith( wxT( "FR4" ) ) )
{
layerColor = findColor( wxT( "FR4 natural" ), g_BoardColors );
}
else if( materialName.IsSameAs( wxT( "PTFE" ) )
|| materialName.IsSameAs( wxT( "Teflon" ) ) )
{
layerColor = findColor( wxT( "PTFE natural" ), g_BoardColors );
}
else if( materialName.IsSameAs( wxT( "Polyimide" ) )
|| materialName.IsSameAs( wxT( "Kapton" ) ) )
{
layerColor = findColor( wxT( "Polyimide" ), g_BoardColors );
}
else if( materialName.IsSameAs( wxT( "Al" ) ) )
{
layerColor = findColor( wxT( "Aluminum" ), g_BoardColors );
}
else // A default color value for unknown dielectric material
// (i.e. an exotic name entered by hand)
{
layerColor = findColor( wxT( "FR4 natural" ), g_BoardColors );
}
if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
bodyColor = layerColor;
@@ -657,6 +690,11 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
}
extern bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
int aErrorMax, int aChainingEpsilon,
OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
{
m_board_poly.RemoveAllContours();
@@ -676,8 +714,7 @@ bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
return false;
}
// max dist from one endPt to next startPt
int chainingEpsilon = m_board->GetOutlinesChainingEpsilon();
int chainingEpsilon = Millimeter2iu( 0.02 ); // max dist from one endPt to next startPt
success = BuildFootprintPolygonOutlines( m_board, m_board_poly,
m_board->GetDesignSettings().m_MaxError,
@@ -708,14 +745,14 @@ float BOARD_ADAPTER::GetFootprintZPos( bool aIsFlipped ) const
{
if( aIsFlipped )
{
if( m_Cfg->m_Render.show_solderpaste )
if( GetFlag( FL_SOLDERPASTE ) )
return m_layerZcoordBottom[B_SilkS];
else
return m_layerZcoordBottom[B_Paste];
}
else
{
if( m_Cfg->m_Render.show_solderpaste )
if( GetFlag( FL_SOLDERPASTE ) )
return m_layerZcoordTop[F_SilkS];
else
return m_layerZcoordTop[F_Paste];
@@ -743,16 +780,3 @@ SFVEC4F BOARD_ADAPTER::GetColor( const COLOR4D& aColor ) const
{
return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
}
SFVEC2F BOARD_ADAPTER::GetSphericalCoord( int i ) const
{
SFVEC2F sphericalCoord =
SFVEC2F( ( m_Cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
m_Cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
return sphericalCoord;
}
+424 -125
View File
@@ -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 (C) 1992-2022 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
@@ -34,11 +34,11 @@
#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"
#include <layer_ids.h>
#include <pad.h>
#include <pcb_track.h>
#include <wx/gdicmn.h>
#include <pcb_base_frame.h>
#include <pcb_text.h>
#include <pcb_shape.h>
@@ -51,10 +51,10 @@
class COLOR_SETTINGS;
/// 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;
typedef std::map< PCB_LAYER_ID, BVH_CONTAINER_2D *> MAP_CONTAINER_2D_BASE;
/// A type that stores polysets for each layer id
typedef std::map<PCB_LAYER_ID, SHAPE_POLY_SET*> MAP_POLY;
typedef std::map< PCB_LAYER_ID, SHAPE_POLY_SET *> MAP_POLY;
/// This defines the range that all coord will have to be rendered.
/// It will use this value to convert to a normalized value between
@@ -77,8 +77,34 @@ public:
*
* @param aCachePointer: the pointer to the 3D cache manager.
*/
void Set3dCacheManager( S3D_CACHE* aCacheMgr ) noexcept { m_3dModelManager = aCacheMgr; }
S3D_CACHE* Get3dCacheManager() const noexcept { return m_3dModelManager; }
void Set3dCacheManager( S3D_CACHE* aCachePointer ) noexcept
{
m_3dModelManager = aCachePointer;
}
/**
* Return the 3D cache manager pointer.
*/
S3D_CACHE* Get3dCacheManager() const noexcept
{
return m_3dModelManager;
}
/**
* Get a configuration status of a flag.
*
* @param aFlag the flag to get the status.
* @return true if flag is set, false if not.
*/
bool GetFlag( DISPLAY3D_FLG aFlag ) const ;
/**
* Set the status of a flag.
*
* @param aFlag the flag to set the status
* @param aState status to set.
*/
void SetFlag( DISPLAY3D_FLG aFlag, bool aState );
/**
* Check if a layer is enabled.
@@ -97,10 +123,25 @@ public:
*
* @param aBoard board to process.
*/
void SetBoard( BOARD* aBoard ) noexcept { m_board = aBoard; }
const BOARD* GetBoard() const noexcept { return m_board; }
void SetBoard( BOARD* aBoard ) noexcept
{
m_board = aBoard;
}
void ReloadColorSettings() noexcept;
/**
* Get current board to be rendered.
*
* @return BOARD pointer
*/
const BOARD* GetBoard() const noexcept
{
return m_board;
}
void SetColorSettings( COLOR_SETTINGS* aSettings ) noexcept
{
m_colors = aSettings;
}
/**
* Function to be called by the render when it need to reload the settings for the board.
@@ -115,33 +156,55 @@ public:
*
* @return the conversion factor to transform a position from the board to 3D units.
*/
double BiuTo3dUnits() const noexcept { return m_biuTo3Dunits; }
double BiuTo3dUnits() const noexcept
{
return m_biuTo3Dunits;
}
/**
* Get the board outling bounding box.
*
* @return the board bounding box in 3D units.
*/
const BBOX_3D& GetBBox() const noexcept { return m_boardBoundingBox; }
const BBOX_3D& GetBBox() const noexcept
{
return m_boardBoundingBox;
}
/**
* Get the board body thickness, including internal copper layers (in 3D units).
* Get the current epoxy thickness.
*
* @return epoxy thickness in 3D units.
*/
float GetBoardBodyThickness() const noexcept { return m_boardBodyThickness3DU; }
float GetEpoxyThickness() const noexcept
{
return m_epoxyThickness3DU;
}
/**
* Get the non copper layers thickness (in 3D units).
* Get the current non copper layers thickness.
*
* @return thickness in 3D units of non copper layers.
*/
float GetNonCopperLayerThickness() const noexcept { return m_nonCopperLayerThickness3DU; }
float GetNonCopperLayerThickness() const noexcept
{
return m_nonCopperLayerThickness3DU;
}
/**
* Get the copper layer thicknesses (in 3D units).
* Get the current copper layer thickness.
*
* @return thickness in 3D units of copper layers.
*/
float GetFrontCopperThickness() const noexcept { return m_frontCopperThickness3DU; }
float GetBackCopperThickness() const noexcept { return m_backCopperThickness3DU; }
float GetCopperThickness() const noexcept
{
return m_copperThickness3DU;
}
/**
* Get the hole plating thickness (NB: in BOARD UNITS!).
* Get the current copper layer thickness.
*
* @return thickness in board units.
*/
int GetHolePlatingThickness() const noexcept;
@@ -150,21 +213,30 @@ public:
*
* @return size in BIU units.
*/
VECTOR2I GetBoardSize() const noexcept { return m_boardSize; }
wxSize GetBoardSize() const noexcept
{
return m_boardSize;
}
/**
* Get the board center.
*
* @return position in BIU units.
*/
VECTOR2I GetBoardPos() const noexcept { return m_boardPos; }
wxPoint GetBoardPos() const noexcept
{
return m_boardPos;
}
/**
* The board center position in 3D units.
*
* @return board center vector position in 3D units.
*/
const SFVEC3F& GetBoardCenter() const noexcept { return m_boardCenter; }
const SFVEC3F& GetBoardCenter() const noexcept
{
return m_boardCenter;
}
/**
* Get the position of the footprint in 3d integer units considering if it is flipped or not.
@@ -175,12 +247,81 @@ public:
*/
float GetFootprintZPos( bool aIsFlipped ) const ;
/**
* Get the current grid.
*
* @return space type of the grid.
*/
GRID3D_TYPE GetGridType() const noexcept
{
return m_gridType;
}
/**
* Set the current grid.
*
* @param aGridType the type space of the grid.
*/
void SetGridType( GRID3D_TYPE aGridType ) noexcept
{
m_gridType = aGridType;
}
/**
* Get the current antialiasing mode value.
*
* @return antialiasing mode value
*/
ANTIALIASING_MODE GetAntiAliasingMode() const { return m_antiAliasingMode; }
/**
* Set the current antialiasing mode value.
*
* @param aAAmode antialiasing mode value.
*/
void SetAntiAliasingMode( ANTIALIASING_MODE aAAmode ) { m_antiAliasingMode = aAAmode; }
/**
* @param aRenderEngine the render engine mode selected.
*/
void SetRenderEngine( RENDER_ENGINE aRenderEngine ) noexcept
{
m_renderEngine = aRenderEngine;
}
/**
* @return render engine on use.
*/
RENDER_ENGINE GetRenderEngine() const noexcept
{
return m_renderEngine;
}
/**
* @param aMaterialMode the render material mode.
*/
void SetMaterialMode( MATERIAL_MODE aMaterialMode ) noexcept
{
m_materialMode = aMaterialMode;
}
/**
* @return material rendering mode.
*/
MATERIAL_MODE GetMaterialMode() const noexcept
{
return m_materialMode;
}
/**
* Get the current polygon of the epoxy board.
*
* @return the shape polygon
*/
const SHAPE_POLY_SET& GetBoardPoly() const noexcept { return m_board_poly; }
const SHAPE_POLY_SET& GetBoardPoly() const noexcept
{
return m_board_poly;
}
/**
* Get the technical color of a layer.
@@ -204,8 +345,6 @@ public:
*/
SFVEC4F GetColor( const COLOR4D& aColor ) const;
SFVEC2F GetSphericalCoord( int i ) const;
/**
* Get the top z position.
*
@@ -233,13 +372,50 @@ public:
*
* @return the map containers of this board.
*/
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 MAP_CONTAINER_2D_BASE& GetLayerMap() const noexcept
{
return m_layerMap;
}
const MAP_CONTAINER_2D_BASE& GetLayerHoleMap() const noexcept { return m_layerHoleMap; }
const BVH_CONTAINER_2D& GetThroughHoleIds() const noexcept { return m_throughHoleIds; }
const BVH_CONTAINER_2D& GetThroughHoleOds() const noexcept { return m_throughHoleOds; }
const BVH_CONTAINER_2D* GetPlatedPadsFront() const noexcept
{
return m_platedPadsFront;
}
const BVH_CONTAINER_2D* GetPlatedPadsBack() const noexcept
{
return m_platedPadsBack;
}
/**
* Get the map of container that have the holes per layer.
*
* @return the map containers of holes from this board.
*/
const MAP_CONTAINER_2D_BASE& GetLayerHoleMap() const noexcept
{
return m_layerHoleMap;
}
/**
* Get the inflated through hole outside diameters container.
*
* @return a container with holes.
*/
const BVH_CONTAINER_2D& GetThroughHoleOds() const noexcept
{
return m_throughHoleOds;
}
/**
* Get the through hole annular rings container.
*
* @return a container with through hole annular rings.
*/
const BVH_CONTAINER_2D& GetThroughHoleAnnularRings() const noexcept
{
return m_throughHoleAnnularRings;
}
/**
* Get through hole outside diameter 2D polygons.
@@ -253,11 +429,6 @@ public:
return m_throughHoleOdPolys;
}
const BVH_CONTAINER_2D& GetThroughHoleAnnularRings() const noexcept
{
return m_throughHoleAnnularRings;
}
const SHAPE_POLY_SET& GetThroughHoleAnnularRingPolys() const noexcept
{
return m_throughHoleAnnularRingPolys;
@@ -281,23 +452,65 @@ public:
return m_throughHoleViaOdPolys;
}
unsigned int GetViaCount() const noexcept { return m_viaCount; }
unsigned int GetHoleCount() const noexcept { return m_holeCount; }
/**
* Get the through hole inner diameter container.
*
* @return a container with holes inner diameters.
*/
const BVH_CONTAINER_2D& GetThroughHoleIds() const noexcept
{
return m_throughHoleIds;
}
/**
* Get number of vias in this board.
*
* @return number of vias.
*/
unsigned int GetViaCount() const noexcept
{
return m_viaCount;
}
/**
* Get number of holes in this board.
*
* @return number of holes.
*/
unsigned int GetHoleCount() const noexcept
{
return m_holeCount;
}
/**
* Thee average diameter of the via holes.
*
* @return via hole average diameter dimension in 3D units.
*/
float GetAverageViaHoleDiameter() const noexcept { return m_averageViaHoleDiameter; }
float GetAverageViaHoleDiameter() const noexcept
{
return m_averageViaHoleDiameter;
}
/**
* Average diameter of through holes.
*
* @return the average diameter of through holes in 3D units.
*/
float GetAverageHoleDiameter() const noexcept { return m_averageHoleDiameter; }
float GetAverageHoleDiameter() const noexcept
{
return m_averageHoleDiameter;
}
/**
* Average width of the tracks.
*
* @return average track width in 3D units.
*/
float GetAverageTrackWidth() const noexcept { return m_averageTrackWidth; }
float GetAverageTrackWidth() const noexcept
{
return m_averageTrackWidth;
}
/**
* @param aDiameter3DU diameter in 3DU.
@@ -316,12 +529,30 @@ public:
*
* @return the map with polygon's layers.
*/
const MAP_POLY& GetPolyMap() const noexcept { return m_layers_poly; }
const MAP_POLY& GetPolyMap() const noexcept
{
return m_layers_poly;
}
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; }
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;
}
private:
/**
@@ -334,42 +565,48 @@ private:
void destroyLayers();
// Helper functions to create the board
void createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer );
void createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer,
int aClearanceValue );
void createPadWithMargin( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayer, const VECTOR2I& aMargin ) const;
void createPadWithClearance( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayer, const wxSize& aClearanceValue ) const;
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 addPadsWithClearance( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue,
bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads,
bool aSkipNonPlatedPads );
void addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId );
void addFootprintShapesWithClearance( const FOOTPRINT* aFootprint,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue );
void addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
const BOARD_ITEM* aItem );
void addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner );
void addShapeWithClearance( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D_BASE* aDstContainer,
const BOARD_ITEM* aOwner );
void addShapeWithClearance( const PCB_DIMENSION_BASE* aDimension,
CONTAINER_2D_BASE* aDstContainer, PCB_LAYER_ID aLayerId,
int aClearanceValue );
void addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* aDstContainer,
void addSolidAreasShapes( const ZONE* aZoneContainer, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId );
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 transformArcToSegments( const wxPoint& aCentre, const wxPoint& aStart, double aArcAngle,
int aCircleToSegmentsCount, int aWidth,
CONTAINER_2D_BASE* aDstContainer, const BOARD_ITEM& aBoardItem );
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 buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aCornerBuffer,
int aWidth) const;
void transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aBuffer ) const;
void transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) const;
public:
static CUSTOM_COLORS_LIST g_SilkscreenColors;
@@ -387,90 +624,152 @@ public:
static KIGFX::COLOR4D g_DefaultBoardBody;
public:
EDA_3D_VIEWER_SETTINGS* m_Cfg;
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
bool m_IsBoardView;
bool m_MousewheelPanning;
bool m_IsPreviewer; ///< true if the board adaptater is living in a 3D
///< preview panel, false for the standard 3D viewer
SFVEC3F m_OpenGlSelectionColor;
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
// Raytracing light colors
SFVEC3F m_RtCameraLightColor;
SFVEC3F m_RtLightColorTop;
SFVEC3F m_RtLightColorBottom;
std::vector<SFVEC3F> m_RtLightColor;
std::vector<SFVEC2F> m_RtLightSphericalCoords;
// Raytracing options
int m_RtShadowSampleCount;
int m_RtReflectionSampleCount;
int m_RtRefractionSampleCount;
int m_RtRecursiveReflectionCount;
int m_RtRecursiveRefractionCount;
float m_RtSpreadShadows;
float m_RtSpreadReflections;
float m_RtSpreadRefractions;
private:
BOARD* m_board;
S3D_CACHE* m_3dModelManager;
RENDER_SETTINGS* m_renderSettings;
COLOR_SETTINGS* m_colors;
BOARD* m_board;
S3D_CACHE* m_3dModelManager;
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.
std::vector< bool > m_drawFlags;
GRID3D_TYPE m_gridType;
RENDER_ENGINE m_renderEngine;
MATERIAL_MODE m_materialMode;
ANTIALIASING_MODE m_antiAliasingMode;
MAP_POLY m_layers_poly; ///< Amalgamated polygon contours for various types of
///< items
wxPoint m_boardPos; ///< Board center position in board internal units.
wxSize 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.
///< Polygon contours for each layer.
MAP_POLY m_layers_poly;
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)
///< Polygon contours for hole outer diameters for each layer.
MAP_POLY m_layerHoleOdPolys;
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
///< Polygon contours for hole inner diameters for each layer.
MAP_POLY m_layerHoleIdPolys;
SHAPE_POLY_SET m_board_poly; ///< Board outline polygon.
///< Polygon contours for non plated through hole outer diameters.
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys;
///< Polygon contours for through hole outer diameters.
SHAPE_POLY_SET m_throughHoleOdPolys;
///< Polygon contours for through holes via outer diameters.
SHAPE_POLY_SET m_throughHoleViaOdPolys;
///< Polygon contours for through hole via annular rings.
SHAPE_POLY_SET m_throughHoleAnnularRingPolys;
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_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_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
///< The holes per each layer.
MAP_CONTAINER_2D_BASE m_layerHoleMap;
unsigned int m_copperLayersCount;
///< List of through holes with the radius of the hole inflated with the copper thickness.
BVH_CONTAINER_2D m_throughHoleOds;
double m_biuTo3Dunits; ///< Scale factor to convert board internal units to
///< 3D units normalized between -1.0 and 1.0.
///< List of plated through hole annular rings.
BVH_CONTAINER_2D m_throughHoleAnnularRings;
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordTop; ///< Top (End) Z position of each
///< layer in 3D units.
///< List of through hole inner diameters.
BVH_CONTAINER_2D m_throughHoleIds;
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordBottom; ///< Bottom (Start) Z position of
///< each layer in 3D units.
///< List of through hole vias with the radius of the hole inflated with the copper thickness.
BVH_CONTAINER_2D m_throughHoleViaOds;
float m_frontCopperThickness3DU;
float m_backCopperThickness3DU;
float m_boardBodyThickness3DU;
float m_nonCopperLayerThickness3DU;
float m_solderPasteLayerThickness3DU;
///< List of through hole via inner diameters.
BVH_CONTAINER_2D m_throughHoleViaIds;
unsigned int m_trackCount;
float m_averageTrackWidth;
unsigned int m_viaCount;
float m_averageViaHoleDiameter;
unsigned int m_holeCount;
float m_averageHoleDiameter;
///< Number of copper layers actually used by the board.
unsigned int m_copperLayersCount;
///< Scale factor to convert board internal units to 3D units normalized between -1.0 and 1.0.
double m_biuTo3Dunits;
///< Top (End) Z position of each layer in 3D units.
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordTop;
///< Bottom (Start) Z position of each layer in 3D units.
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordBottom;
///< Copper thickness in 3D units.
float m_copperThickness3DU;
///< Epoxy thickness in 3D units.
float m_epoxyThickness3DU;
///< Non copper layers thickness in 3D units.
float m_nonCopperLayerThickness3DU;
///< solder paste layers thickness in 3D units.
float m_solderPasteLayerThickness3DU;
///< Number of tracks in the board.
unsigned int m_trackCount;
///< Track average width.
float m_averageTrackWidth;
///< Number of through hole vias in the board.
unsigned int m_viaCount;
///< Computed average diameter of the via holes in 3D units.
float m_averageViaHoleDiameter;
///< Number of holes in the board.
unsigned int m_holeCount;
///< Computed average diameter of the holes in 3D units.
float m_averageHoleDiameter;
/**
* Trace mask used to enable or disable debug output for this class. Output can be turned
* on by setting the WXTRACE environment variable to "KI_TRACE_EDA_CINFO3D_VISU". See the
* wxWidgets documentation on wxLogTrace for more information.
* 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_EDA_CINFO3D_VISU". See the wxWidgets documentation on wxLogTrace for
* more information.
*/
static const wxChar* m_logTrace;
File diff suppressed because it is too large Load Diff
+231 -243
View File
@@ -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 (C) 1992-2022 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
@@ -32,12 +32,15 @@
*/
#include "board_adapter.h"
#include "../3d_rendering/raytracing/shapes2D/ring_2d.h"
#include "../3d_rendering/raytracing/shapes2D/filled_circle_2d.h"
#include "../3d_rendering/raytracing/shapes3D/cylinder_3d.h"
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_text.h>
#include <pcb_textbox.h>
#include <fp_shape.h>
#include <zone.h>
#include <convert_basic_shapes_to_polygon.h>
@@ -58,7 +61,7 @@ void BOARD_ADAPTER::destroyLayers()
{
if( !m_layers_poly.empty() )
{
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layers_poly )
for( auto& poly : m_layers_poly )
delete poly.second;
m_layers_poly.clear();
@@ -72,7 +75,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerHoleIdPolys.empty() )
{
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layerHoleIdPolys )
for( auto& poly : m_layerHoleIdPolys )
delete poly.second;
m_layerHoleIdPolys.clear();
@@ -80,7 +83,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerHoleOdPolys.empty() )
{
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layerHoleOdPolys )
for( auto& poly : m_layerHoleOdPolys )
delete poly.second;
m_layerHoleOdPolys.clear();
@@ -88,7 +91,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerMap.empty() )
{
for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& poly : m_layerMap )
for( auto& poly : m_layerMap )
delete poly.second;
m_layerMap.clear();
@@ -102,7 +105,7 @@ void BOARD_ADAPTER::destroyLayers()
if( !m_layerHoleMap.empty() )
{
for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& poly : m_layerHoleMap )
for( auto& poly : m_layerHoleMap )
delete poly.second;
m_layerHoleMap.clear();
@@ -153,8 +156,6 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
trackList.clear();
trackList.reserve( m_board->Tracks().size() );
int maxError = m_board->GetDesignSettings().m_MaxError;
for( PCB_TRACK* track : m_board->Tracks() )
{
if( !Is3dLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
@@ -185,34 +186,33 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
m_averageViaHoleDiameter /= (float)m_viaCount;
// Prepare copper layers index and containers
std::vector<PCB_LAYER_ID> layer_ids;
layer_ids.clear();
layer_ids.reserve( m_copperLayersCount );
std::vector< PCB_LAYER_ID > layer_id;
layer_id.clear();
layer_id.reserve( m_copperLayersCount );
for( unsigned i = 0; i < arrayDim( cu_seq ); ++i )
cu_seq[i] = ToLAYER_ID( B_Cu - i );
for( LSEQ cu = cu_set.Seq( cu_seq, arrayDim( cu_seq ) ); cu; ++cu )
{
const PCB_LAYER_ID layer = *cu;
const PCB_LAYER_ID curr_layer_id = *cu;
if( !Is3dLayerEnabled( layer ) ) // Skip non enabled layers
if( !Is3dLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
continue;
layer_ids.push_back( layer );
layer_id.push_back( curr_layer_id );
BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
m_layerMap[layer] = layerContainer;
m_layerMap[curr_layer_id] = layerContainer;
if( m_Cfg->m_Render.opengl_copper_thickness
&& m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && m_renderEngine == RENDER_ENGINE::OPENGL )
{
SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
m_layers_poly[layer] = layerPoly;
m_layers_poly[curr_layer_id] = layerPoly;
}
}
if( m_Cfg->m_Render.renderPlatedPadsAsPlated && m_Cfg->m_Render.realistic )
if( GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_frontPlatedPadPolys = new SHAPE_POLY_SET;
m_backPlatedPadPolys = new SHAPE_POLY_SET;
@@ -226,31 +226,36 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
aStatusReporter->Report( _( "Create tracks and vias" ) );
// Create tracks as objects and add it to container
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
for( const PCB_TRACK* track : trackList )
// Add track segments shapes and via annulus shapes
unsigned int nTracks = trackList.size();
for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
{
const PCB_TRACK *track = trackList[trackIdx];
// NOTE: Vias can be on multiple layers
if( !track->IsOnLayer( layer ) )
if( !track->IsOnLayer( curr_layer_id ) )
continue;
// Skip vias annulus when not connected on this layer (if removing is enabled)
const PCB_VIA *via = dyn_cast< const PCB_VIA*>( track );
if( via && IsCopperLayer( layer ) && !via->FlashLayer( layer ) )
if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
continue;
// Add object item to layer container
createTrack( track, layerContainer );
createTrack( track, layerContainer, 0.0f );
}
}
// Create VIAS and THTs objects and add it to holes containers
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
// ADD TRACKS
unsigned int nTracks = trackList.size();
@@ -259,7 +264,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_TRACK *track = trackList[trackIdx];
if( !track->IsOnLayer( layer ) )
if( !track->IsOnLayer( curr_layer_id ) )
continue;
// ADD VIAS and THT
@@ -279,20 +284,21 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( viatype != VIATYPE::THROUGH )
{
// Add hole objects
BVH_CONTAINER_2D *layerHoleContainer = nullptr;
// Check if the layer is already created
if( m_layerHoleMap.find( layer ) == m_layerHoleMap.end() )
if( m_layerHoleMap.find( curr_layer_id ) == m_layerHoleMap.end() )
{
// not found, create a new container
layerHoleContainer = new BVH_CONTAINER_2D;
m_layerHoleMap[layer] = layerHoleContainer;
m_layerHoleMap[curr_layer_id] = layerHoleContainer;
}
else
{
// found
layerHoleContainer = m_layerHoleMap[layer];
layerHoleContainer = m_layerHoleMap[curr_layer_id];
}
// Add a hole for this layer
@@ -300,38 +306,33 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
hole_inner_radius + thickness,
*track ) );
}
else if( layer == layer_ids[0] ) // it only adds once the THT holes
else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
{
// Add through hole object
m_throughHoleOds.Add( new FILLED_CIRCLE_2D( via_center,
hole_inner_radius + thickness,
*track ) );
hole_inner_radius + thickness,
*track ) );
m_throughHoleViaOds.Add( new FILLED_CIRCLE_2D( via_center,
hole_inner_radius + thickness,
*track ) );
if( m_Cfg->m_Render.clip_silk_on_via_annulus
&& m_Cfg->m_Render.realistic
&& ring_radius > 0.0 )
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) &&
GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_throughHoleAnnularRings.Add( new FILLED_CIRCLE_2D( via_center,
ring_radius,
*track ) );
ring_radius,
*track ) );
}
if( hole_inner_radius > 0.0 )
{
m_throughHoleIds.Add( new FILLED_CIRCLE_2D( via_center,
hole_inner_radius,
*track ) );
}
m_throughHoleIds.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius,
*track ) );
}
}
}
}
// Create VIAS and THTs objects and add it to holes containers
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
// ADD TRACKS
const unsigned int nTracks = trackList.size();
@@ -340,7 +341,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_TRACK *track = trackList[trackIdx];
if( !track->IsOnLayer( layer ) )
if( !track->IsOnLayer( curr_layer_id ) )
continue;
// ADD VIAS and THT
@@ -358,37 +359,40 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
SHAPE_POLY_SET *layerInnerHolesPoly = nullptr;
// Check if the layer is already created
if( m_layerHoleOdPolys.find( layer ) == m_layerHoleOdPolys.end() )
if( m_layerHoleOdPolys.find( curr_layer_id ) ==
m_layerHoleOdPolys.end() )
{
// not found, create a new container
layerOuterHolesPoly = new SHAPE_POLY_SET;
m_layerHoleOdPolys[layer] = layerOuterHolesPoly;
m_layerHoleOdPolys[curr_layer_id] = layerOuterHolesPoly;
wxASSERT( m_layerHoleIdPolys.find( layer ) == m_layerHoleIdPolys.end() );
wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) ==
m_layerHoleIdPolys.end() );
layerInnerHolesPoly = new SHAPE_POLY_SET;
m_layerHoleIdPolys[layer] = layerInnerHolesPoly;
m_layerHoleIdPolys[curr_layer_id] = layerInnerHolesPoly;
}
else
{
// found
layerOuterHolesPoly = m_layerHoleOdPolys[layer];
layerOuterHolesPoly = m_layerHoleOdPolys[curr_layer_id];
wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) !=
m_layerHoleIdPolys.end() );
layerInnerHolesPoly = m_layerHoleIdPolys[layer];
layerInnerHolesPoly = m_layerHoleIdPolys[curr_layer_id];
}
const int holediameter = via->GetDrillValue();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
hole_outer_radius, maxError, ERROR_INSIDE );
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
holediameter / 2, maxError, ERROR_INSIDE );
holediameter / 2, ARC_HIGH_DEF, ERROR_INSIDE );
}
else if( layer == layer_ids[0] ) // it only adds once the THT holes
else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
{
const int holediameter = via->GetDrillValue();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
@@ -396,16 +400,17 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add through hole contours
TransformCircleToPolygon( m_throughHoleOdPolys, via->GetStart(),
hole_outer_radius, maxError, ERROR_INSIDE );
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
// Add same thing for vias only
TransformCircleToPolygon( m_throughHoleViaOdPolys, via->GetStart(),
hole_outer_radius, maxError, ERROR_INSIDE );
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
if( m_Cfg->m_Render.clip_silk_on_via_annulus && m_Cfg->m_Render.realistic )
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
TransformCircleToPolygon( m_throughHoleAnnularRingPolys, via->GetStart(),
hole_outer_ring_radius, maxError, ERROR_INSIDE );
TransformCircleToPolygon( m_throughHoleAnnularRingPolys,
via->GetStart(), hole_outer_ring_radius,
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
}
@@ -413,13 +418,13 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
// Creates vertical outline contours of the tracks and add it to the poly of the layer
if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && m_renderEngine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
// ADD TRACKS
unsigned int nTracks = trackList.size();
@@ -428,17 +433,18 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_TRACK *track = trackList[trackIdx];
if( !track->IsOnLayer( layer ) )
if( !track->IsOnLayer( curr_layer_id ) )
continue;
// Skip vias annulus when not connected on this layer (if removing is enabled)
const PCB_VIA *via = dyn_cast<const PCB_VIA*>( track );
if( via && !via->FlashLayer( layer ) && IsCopperLayer( layer ) )
if( via && !via->FlashLayer( curr_layer_id ) && IsCopperLayer( curr_layer_id ) )
continue;
// Add the track/via contour
track->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
track->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
}
@@ -448,7 +454,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
for( PAD* pad : footprint->Pads() )
{
const VECTOR2I padHole = pad->GetDrillSize();
const wxSize padHole = pad->GetDrillSize();
if( !padHole.x ) // Not drilled pad like SMD pad
continue;
@@ -463,8 +469,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
m_throughHoleOds.Add( createPadWithDrill( pad, inflate ) );
if( m_Cfg->m_Render.clip_silk_on_via_annulus && m_Cfg->m_Render.realistic )
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_throughHoleAnnularRings.Add( createPadWithDrill( pad, inflate ) );
}
m_throughHoleIds.Add( createPadWithDrill( pad, 0 ) );
}
@@ -478,7 +486,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
for( PAD* pad : footprint->Pads() )
{
const VECTOR2I padHole = pad->GetDrillSize();
const wxSize padHole = pad->GetDrillSize();
if( !padHole.x ) // Not drilled pad like SMD pad
continue;
@@ -488,47 +496,50 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( pad->GetAttribute () != PAD_ATTRIB::NPTH )
{
if( m_Cfg->m_Render.clip_silk_on_via_annulus && m_Cfg->m_Render.realistic )
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, inflate, maxError,
ERROR_INSIDE );
pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys,
inflate, ARC_HIGH_DEF, ERROR_INSIDE );
}
pad->TransformHoleToPolygon( m_throughHoleOdPolys, inflate, maxError,
ERROR_INSIDE );
pad->TransformHoleWithClearanceToPolygon( m_throughHoleOdPolys, inflate,
ARC_HIGH_DEF, ERROR_INSIDE );
}
else
{
// If not plated, no copper.
if( m_Cfg->m_Render.clip_silk_on_via_annulus && m_Cfg->m_Render.realistic )
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, 0, maxError,
ERROR_INSIDE );
pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
pad->TransformHoleToPolygon( m_nonPlatedThroughHoleOdPolys, 0, maxError,
ERROR_INSIDE );
pad->TransformHoleWithClearanceToPolygon( m_nonPlatedThroughHoleOdPolys, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
}
const bool renderPlatedPadsAsPlated = m_Cfg->m_Render.renderPlatedPadsAsPlated
&& m_Cfg->m_Render.realistic;
const bool renderPlatedPadsAsPlated = GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
GetFlag( FL_USE_REALISTIC_MODE );
// Add footprints PADs objects to containers
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
// ADD PADS
for( FOOTPRINT* footprint : m_board->Footprints() )
{
addPads( footprint, layerContainer, layer, renderPlatedPadsAsPlated, false );
// Note: NPTH pads are not drawn on copper layers when the pad
// has same shape as its hole
addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
true, renderPlatedPadsAsPlated, false );
// Micro-wave footprints may have items on copper layers
addFootprintShapes( footprint, layerContainer, layer );
addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
}
}
@@ -537,8 +548,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// ADD PLATED PADS
for( FOOTPRINT* footprint : m_board->Footprints() )
{
addPads( footprint, m_platedPadsFront, F_Cu, false, true );
addPads( footprint, m_platedPadsBack, B_Cu, false, true );
addPadsWithClearance( footprint, m_platedPadsFront, F_Cu, 0, true, false, true );
addPadsWithClearance( footprint, m_platedPadsBack, B_Cu, 0, true, false, true );
}
m_platedPadsFront->BuildBVH();
@@ -546,23 +558,25 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
// Add footprints PADs poly contours (vertical outlines)
if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && m_renderEngine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
// Add pads to polygon list
for( FOOTPRINT* footprint : m_board->Footprints() )
{
// Note: NPTH pads are not drawn on copper layers when the pad has same shape as
// its hole
footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE,
true, renderPlatedPadsAsPlated, false );
// Note: NPTH pads are not drawn on copper layers when the pad
// has same shape as its hole
footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, renderPlatedPadsAsPlated,
false );
transformFPShapesToPolySet( footprint, layer, *layerPoly );
transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
}
}
@@ -571,95 +585,88 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// ADD PLATED PADS contours
for( FOOTPRINT* footprint : m_board->Footprints() )
{
footprint->TransformPadsToPolySet( *m_frontPlatedPadPolys, F_Cu, 0, maxError,
ERROR_INSIDE, true, false, true );
footprint->TransformPadsWithClearanceToPolygon( *m_frontPlatedPadPolys, F_Cu,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, false, true );
footprint->TransformPadsToPolySet( *m_backPlatedPadPolys, B_Cu, 0, maxError,
ERROR_INSIDE, true, false, true );
footprint->TransformPadsWithClearanceToPolygon( *m_backPlatedPadPolys, B_Cu,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, false, true );
}
}
}
// Add graphic item on copper layers to object containers
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
// Add graphic items on copper layers (texts and other graphics)
for( BOARD_ITEM* item : m_board->Drawings() )
{
if( !item->IsOnLayer( layer ) )
if( !item->IsOnLayer( curr_layer_id ) )
continue;
switch( item->Type() )
{
case PCB_SHAPE_T:
addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
break;
addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_TEXT_T:
addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
break;
case PCB_TEXTBOX_T:
addText( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
break;
addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_DIM_ALIGNED_T:
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
addShape( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer, item );
break;
addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ),
layerContainer, curr_layer_id, 0 );
break;
default:
wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
item->Type() );
break;
break;
}
}
}
// Add graphic item on copper layers to poly contours (vertical outlines)
if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && m_renderEngine == RENDER_ENGINE::OPENGL )
{
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID cur_layer_id : layer_id )
{
wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
wxASSERT( m_layers_poly.find( cur_layer_id ) != m_layers_poly.end() );
SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
SHAPE_POLY_SET *layerPoly = m_layers_poly[cur_layer_id];
// Add graphic items on copper layers (texts and other )
for( BOARD_ITEM* item : m_board->Drawings() )
{
if( !item->IsOnLayer( layer ) )
if( !item->IsOnLayer( cur_layer_id ) )
continue;
switch( item->Type() )
{
case PCB_SHAPE_T:
item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
item->TransformShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
break;
case PCB_TEXT_T:
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
text->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
break;
text->TransformTextShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
case PCB_TEXTBOX_T:
{
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
textbox->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
break;
}
default:
wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
@@ -670,7 +677,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
}
if( m_Cfg->m_Render.show_zones )
if( GetFlag( FL_ZONE ) )
{
if( aStatusReporter )
aStatusReporter->Report( _( "Create zones" ) );
@@ -713,11 +720,13 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
auto layerPolyContainer = m_layers_poly.find( layer );
if( layerContainer != m_layerMap.end() )
{
addSolidAreasShapes( zone, layerContainer->second, layer );
}
if( m_Cfg->m_Render.opengl_copper_thickness
&& m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL
&& layerPolyContainer != m_layers_poly.end() )
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
&& m_renderEngine == RENDER_ENGINE::OPENGL
&& layerPolyContainer != m_layers_poly.end() )
{
auto mut_it = layer_lock.find( layer );
@@ -742,9 +751,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( aStatusReporter )
aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && m_renderEngine == RENDER_ENGINE::OPENGL )
{
if( renderPlatedPadsAsPlated )
if( GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
if( m_frontPlatedPadPolys && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
{
@@ -769,18 +778,18 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
}
std::vector<PCB_LAYER_ID> &selected_layer_id = layer_ids;
std::vector<PCB_LAYER_ID> layer_id_without_F_and_B;
std::vector< PCB_LAYER_ID > &selected_layer_id = layer_id;
std::vector< PCB_LAYER_ID > layer_id_without_F_and_B;
if( renderPlatedPadsAsPlated )
if( GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
layer_id_without_F_and_B.clear();
layer_id_without_F_and_B.reserve( layer_ids.size() );
layer_id_without_F_and_B.reserve( layer_id.size() );
for( PCB_LAYER_ID layer: layer_ids )
for( size_t i = 0; i < layer_id.size(); ++i )
{
if( layer != F_Cu && layer != B_Cu )
layer_id_without_F_and_B.push_back( layer );
if( ( layer_id[i] != F_Cu ) && ( layer_id[i] != B_Cu ) )
layer_id_without_F_and_B.push_back( layer_id[i] );
}
selected_layer_id = layer_id_without_F_and_B;
@@ -789,10 +798,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( selected_layer_id.size() > 0 )
{
if( aStatusReporter )
{
aStatusReporter->Report( wxString::Format( _( "Simplifying %d copper layers" ),
(int) selected_layer_id.size() ) );
}
aStatusReporter->Report( wxString::Format(
_( "Simplifying %d copper layers" ),
(int)selected_layer_id.size() ) );
std::atomic<size_t> nextItem( 0 );
std::atomic<size_t> threadsFinished( 0 );
@@ -832,7 +840,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( aStatusReporter )
aStatusReporter->Report( _( "Simplify holes contours" ) );
for( PCB_LAYER_ID layer : layer_ids )
for( PCB_LAYER_ID layer : layer_id )
{
if( m_layerHoleOdPolys.find( layer ) != m_layerHoleOdPolys.end() )
{
@@ -862,13 +870,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
aStatusReporter->Report( _( "Build Tech layers" ) );
// draw graphic items, on technical layers
// Vertical walls (layer thickness) around shapes is really time consumming
// They are built on request
bool buildVerticalWallsForTechLayers = m_Cfg->m_Render.opengl_copper_thickness
&& m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL;
static const PCB_LAYER_ID techLayerList[] = {
static const PCB_LAYER_ID teckLayerList[] = {
B_Adhes,
F_Adhes,
B_Paste,
@@ -888,51 +890,49 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
};
// User layers are not drawn here, only technical layers
for( LSEQ seq = LSET::AllNonCuMask().Seq( techLayerList, arrayDim( techLayerList ) );
for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, arrayDim( teckLayerList ) );
seq;
++seq )
{
const PCB_LAYER_ID layer = *seq;
const PCB_LAYER_ID curr_layer_id = *seq;
if( !Is3dLayerEnabled( layer ) )
if( !Is3dLayerEnabled( curr_layer_id ) )
continue;
if( aStatusReporter )
aStatusReporter->Report( wxString::Format( _( "Build Tech layer %d" ), (int) layer ) );
aStatusReporter->Report( wxString::Format(
_( "Build Tech layer %d" ), (int)curr_layer_id ) );
BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
m_layerMap[layer] = layerContainer;
m_layerMap[curr_layer_id] = layerContainer;
SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
m_layers_poly[layer] = layerPoly;
m_layers_poly[curr_layer_id] = layerPoly;
// Add drawing objects
for( BOARD_ITEM* item : m_board->Drawings() )
{
if( !item->IsOnLayer( layer ) )
if( !item->IsOnLayer( curr_layer_id ) )
continue;
switch( item->Type() )
{
case PCB_SHAPE_T:
addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_TEXT_T:
addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
break;
case PCB_TEXTBOX_T:
addText( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_DIM_ALIGNED_T:
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
addShape( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer, item );
addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer,
curr_layer_id, 0 );
break;
default:
@@ -940,52 +940,43 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
}
// Add drawing contours (vertical walls)
if( buildVerticalWallsForTechLayers )
// Add drawing contours
for( BOARD_ITEM* item : m_board->Drawings() )
{
for( BOARD_ITEM* item : m_board->Drawings() )
if( !item->IsOnLayer( curr_layer_id ) )
continue;
switch( item->Type() )
{
if( !item->IsOnLayer( layer ) )
continue;
case PCB_SHAPE_T:
item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
break;
switch( item->Type() )
{
case PCB_SHAPE_T:
item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break;
case PCB_TEXT_T:
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
case PCB_TEXT_T:
{
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
text->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
break;
text->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
break;
}
case PCB_TEXTBOX_T:
{
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
textbox->TransformTextToPolySet( *layerPoly, 0, maxError, ERROR_INSIDE );
break;
}
default:
break;
}
default:
break;
}
}
// Add footprints tech layers - objects
for( FOOTPRINT* footprint : m_board->Footprints() )
{
if( layer == F_SilkS || layer == B_SilkS )
if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
{
int linewidth = m_board->GetDesignSettings().m_LineThickness[ LAYER_CLASS_SILK ];
for( PAD* pad : footprint->Pads() )
{
if( !pad->IsOnLayer( layer ) )
if( !pad->IsOnLayer( curr_layer_id ) )
continue;
buildPadOutlineAsSegments( pad, layerContainer, linewidth );
@@ -993,60 +984,57 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
else
{
addPads( footprint, layerContainer, layer, false, false );
addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
false, false, false );
}
addFootprintShapes( footprint, layerContainer, layer );
addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
}
// Add footprints tech layers - contours (vertical walls)
if( buildVerticalWallsForTechLayers )
// Add footprints tech layers - contours
for( FOOTPRINT* footprint : m_board->Footprints() )
{
for( FOOTPRINT* footprint : m_board->Footprints() )
if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) )
{
if( layer == F_SilkS || layer == B_SilkS )
int linewidth = m_board->GetDesignSettings().m_LineThickness[ LAYER_CLASS_SILK ];
for( PAD* pad : footprint->Pads() )
{
int linewidth = m_board->GetDesignSettings().m_LineThickness[ LAYER_CLASS_SILK ];
if( !pad->IsOnLayer( curr_layer_id ) )
continue;
for( PAD* pad : footprint->Pads() )
{
if( !pad->IsOnLayer( layer ) )
continue;
buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
}
buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
}
else
{
footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
}
// On tech layers, use a poor circle approximation, only for texts (stroke font)
footprint->TransformFPTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
// Add the remaining things with dynamic seg count for circles
transformFPShapesToPolySet( footprint, layer, *layerPoly );
}
else
{
footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
// On tech layers, use a poor circle approximation, only for texts (stroke font)
footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
// Add the remaining things with dynamic seg count for circles
transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly );
}
// Draw non copper zones
if( m_Cfg->m_Render.show_zones )
if( GetFlag( FL_ZONE ) )
{
for( ZONE* zone : m_board->Zones() )
{
if( zone->IsOnLayer( layer ) )
addSolidAreasShapes( zone, layerContainer, layer );
if( zone->IsOnLayer( curr_layer_id ) )
addSolidAreasShapes( zone, layerContainer, curr_layer_id );
}
if( buildVerticalWallsForTechLayers )
for( ZONE* zone : m_board->Zones() )
{
for( ZONE* zone : m_board->Zones() )
{
if( zone->IsOnLayer( layer ) )
zone->TransformSolidAreasShapesToPolygon( layer, *layerPoly );
}
if( zone->IsOnLayer( curr_layer_id ) )
zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly );
}
}
@@ -1066,7 +1054,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( !m_layerHoleMap.empty() )
{
for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& hole : m_layerHoleMap )
for( auto& hole : m_layerHoleMap )
hole.second->BuildBVH();
}
+14 -25
View File
@@ -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 (C) 1992-2022 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
@@ -29,24 +29,18 @@
*/
#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,
void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aCornerBuffer,
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 );
TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(), aPad->GetSize().x / 2,
aWidth, ARC_HIGH_DEF, ERROR_INSIDE );
return;
}
@@ -59,31 +53,26 @@ void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& a
const VECTOR2I& a = path.CPoint( ii );
const VECTOR2I& b = path.CPoint( ii + 1 );
TransformOvalToPolygon( aBuffer, a, b, aWidth, maxError, ERROR_INSIDE );
TransformOvalToPolygon( aCornerBuffer, (wxPoint) a, (wxPoint) b, aWidth, ARC_HIGH_DEF,
ERROR_INSIDE );
}
}
void BOARD_ADAPTER::transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aBuffer ) const
void BOARD_ADAPTER::transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) 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 );
FP_SHAPE* outline = (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 );
if( outline->GetLayer() == aLayer )
{
outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
}
}
+157 -128
View File
@@ -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 (C) 1992-2023 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
@@ -32,7 +32,6 @@
#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 <board.h>
#include <reporter.h>
#include <gl_context_mgr.h>
@@ -56,12 +55,14 @@
*/
const wxChar* EDA_3D_CANVAS::m_logTrace = wxT( "KI_TRACE_EDA_3D_CANVAS" );
const float EDA_3D_CANVAS::m_delta_move_step_factor = 0.7f;
// A custom event, used to call DoRePaint during an idle time
wxDEFINE_EVENT( wxEVT_REFRESH_CUSTOM_COMMAND, wxEvent );
wxDEFINE_EVENT( wxEVT_REFRESH_CUSTOM_COMMAND, wxEvent);
BEGIN_EVENT_TABLE( EDA_3D_CANVAS, HIDPI_GL_3D_CANVAS )
BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas )
EVT_PAINT( EDA_3D_CANVAS::OnPaint )
// mouse events
@@ -78,6 +79,7 @@ BEGIN_EVENT_TABLE( EDA_3D_CANVAS, HIDPI_GL_3D_CANVAS )
// other events
EVT_ERASE_BACKGROUND( EDA_3D_CANVAS::OnEraseBackground )
//EVT_REFRESH_CUSTOM_COMMAND( ID_CUSTOM_EVENT_1, EDA_3D_CANVAS::OnRefreshRequest )
EVT_CUSTOM(wxEVT_REFRESH_CUSTOM_COMMAND, ID_CUSTOM_EVENT_1, EDA_3D_CANVAS::OnRefreshRequest )
EVT_CLOSE( EDA_3D_CANVAS::OnCloseWindow )
@@ -87,28 +89,30 @@ END_EVENT_TABLE()
EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
BOARD_ADAPTER& aBoardAdapter, CAMERA& aCamera,
S3D_CACHE* a3DCachePointer ) :
HIDPI_GL_3D_CANVAS( aCamera, aParent, wxID_ANY, aAttribList, wxDefaultPosition,
wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ),
m_eventDispatcher( nullptr ),
m_parentStatusBar( nullptr ),
m_parentInfoBar( nullptr ),
m_glRC( nullptr ),
m_is_opengl_initialized( false ),
m_is_opengl_version_supported( true ),
m_editing_timeout_timer( this, wxID_HIGHEST + 1 ),
m_redraw_trigger_timer( this, wxID_HIGHEST + 2 ),
m_render_pivot( false ),
m_camera_moving_speed( 1.0f ),
m_strtime_camera_movement( 0 ),
m_animation_enabled( true ),
m_moving_speed_multiplier( 3 ),
m_boardAdapter( aBoardAdapter ),
m_3d_render( nullptr ),
m_opengl_supports_raytracing( true ),
m_render_raytracing_was_requested( false ),
m_accelerator3DShapes( nullptr ),
m_currentRollOverItem( nullptr )
S3D_CACHE* a3DCachePointer )
: HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE ),
m_eventDispatcher( nullptr ),
m_parentStatusBar( nullptr ),
m_parentInfoBar( nullptr ),
m_glRC( nullptr ),
m_is_opengl_initialized( false ),
m_is_opengl_version_supported( true ),
m_mouse_is_moving( false ),
m_mouse_was_moved( false ),
m_camera_is_moving( false ),
m_render_pivot( false ),
m_camera_moving_speed( 1.0f ),
m_strtime_camera_movement( 0 ),
m_animation_enabled( true ),
m_moving_speed_multiplier( 3 ),
m_boardAdapter( aBoardAdapter ),
m_camera( aCamera ),
m_3d_render( nullptr ),
m_opengl_supports_raytracing( true ),
m_render_raytracing_was_requested( false ),
m_accelerator3DShapes( nullptr ),
m_currentRollOverItem( nullptr )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::EDA_3D_CANVAS" ) );
@@ -128,20 +132,14 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
wxASSERT( m_3d_render_raytracing != nullptr );
wxASSERT( m_3d_render_opengl != nullptr );
auto busy_indicator_factory =
[]()
{
return std::make_unique<WX_BUSY_INDICATOR>();
};
auto busy_indicator_factory = []() { return std::make_unique<WX_BUSY_INDICATOR>(); };
m_3d_render_raytracing->SetBusyIndicatorFactory( busy_indicator_factory );
m_3d_render_opengl->SetBusyIndicatorFactory( busy_indicator_factory );
// We always start with the opengl engine (raytracing is avoided due to very
// long calculation time)
m_3d_render = m_3d_render_opengl;
RenderEngineChanged();
m_boardAdapter.ReloadColorSettings();
m_boardAdapter.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
wxASSERT( a3DCachePointer != nullptr );
m_boardAdapter.Set3dCacheManager( a3DCachePointer );
@@ -210,7 +208,7 @@ void EDA_3D_CANVAS::OnCloseWindow( wxCloseEvent& event )
void EDA_3D_CANVAS::OnResize( wxSizeEvent& event )
{
Request_refresh();
this->Request_refresh();
}
@@ -304,7 +302,7 @@ void EDA_3D_CANVAS::ReloadRequest( BOARD* aBoard , S3D_CACHE* aCachePointer )
if( aBoard != nullptr )
m_boardAdapter.SetBoard( aBoard );
m_boardAdapter.ReloadColorSettings();
m_boardAdapter.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
if( m_3d_render )
m_3d_render->ReloadRequest();
@@ -372,7 +370,8 @@ void EDA_3D_CANVAS::DoRePaint()
// !TODO: implement error reporter
INFOBAR_REPORTER warningReporter( m_parentInfoBar );
STATUSBAR_REPORTER activityReporter( m_parentStatusBar, EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
STATUSBAR_REPORTER activityReporter( m_parentStatusBar,
(int) EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
unsigned strtime = GetRunningMicroSecs();
@@ -384,15 +383,6 @@ void EDA_3D_CANVAS::DoRePaint()
if( m_glRC == nullptr )
m_glRC = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
// CreateCtx could and does fail per sentry crash events, lets be graceful
if( m_glRC == nullptr )
{
warningReporter.Report( _( "OpenGL context creation error" ), RPT_SEVERITY_ERROR );
warningReporter.Finalize();
m_is_currently_painting.clear();
return;
}
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
// Set the OpenGL viewport according to the client size of this canvas.
@@ -443,11 +433,11 @@ void EDA_3D_CANVAS::DoRePaint()
{
m_3d_render = m_3d_render_opengl;
m_render_raytracing_was_requested = false;
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::OPENGL;
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL );
}
// Check if a raytacing was requested and need to switch to raytracing mode
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL )
{
const bool was_camera_changed = m_camera.ParametersChanged();
@@ -496,7 +486,7 @@ void EDA_3D_CANVAS::DoRePaint()
bool reloadRaytracingForCalculations = false;
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL
&& m_3d_render_opengl->IsReloadRequestPending() )
{
reloadRaytracingForCalculations = true;
@@ -532,12 +522,6 @@ void EDA_3D_CANVAS::DoRePaint()
render_pivot( curtime_delta_s, scale );
}
if( m_render3dmousePivot && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
{
const float scale = glm::min( m_camera.GetZoom(), 1.0f );
render3dmousePivot( scale );
}
// "Swaps the double-buffer of this window, making the back-buffer the
// front-buffer and vice versa, so that the output of the previous OpenGL
// commands is displayed on the window."
@@ -601,16 +585,68 @@ void EDA_3D_CANVAS::OnEraseBackground( wxEraseEvent& event )
void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event )
{
bool mouseActivity = false;
wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnMouseWheel" ) );
OnMouseWheelCamera( event, m_boardAdapter.m_MousewheelPanning );
if( m_camera_is_moving )
return;
if( m_mouse_was_moved )
float delta_move = m_delta_move_step_factor * m_camera.GetZoom();
if( m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) )
delta_move *= 0.01f * event.GetWheelRotation();
else
if( event.GetWheelRotation() < 0 )
delta_move = -delta_move;
// mousewheel_panning enabled:
// wheel -> pan;
// wheel + shift -> horizontal scrolling;
// wheel + ctrl -> zooming;
// mousewheel_panning disabled:
// wheel + shift -> vertical scrolling;
// wheel + ctrl -> horizontal scrolling;
// wheel -> zooming.
if( m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) && !event.ControlDown() )
{
if( event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() )
m_camera.Pan( SFVEC3F( -delta_move, 0.0f, 0.0f ) );
else
m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
mouseActivity = true;
}
else if( event.ShiftDown() && !m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) )
{
m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
mouseActivity = true;
}
else if( event.ControlDown() && !m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) )
{
m_camera.Pan( SFVEC3F( delta_move, 0.0f, 0.0f ) );
mouseActivity = true;
}
else
{
mouseActivity = m_camera.Zoom( event.GetWheelRotation() > 0 ? 1.1f : 1/1.1f );
}
// If it results on a camera movement
if( mouseActivity )
{
DisplayStatus();
Request_refresh();
m_mouse_is_moving = true;
m_mouse_was_moved = true;
restart_editingTimeOut_Timer();
}
// Update the cursor current mouse position on the camera
m_camera.SetCurMousePosition( GetNativePosition( event.GetPosition() ) );
}
@@ -637,37 +673,44 @@ void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event )
void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
{
//wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnMouseMove" ) );
if( m_camera_is_moving )
return;
OnMouseMoveCamera( event );
const wxSize& nativeWinSize = GetNativePixelSize();
const wxPoint& nativePosition = GetNativePosition( event.GetPosition() );
if( m_mouse_was_moved )
m_camera.SetCurWindowSize( nativeWinSize );
if( event.Dragging() )
{
if( event.LeftIsDown() ) // Drag
m_camera.Drag( nativePosition );
else if( event.MiddleIsDown() ) // Pan
m_camera.Pan( nativePosition );
m_mouse_is_moving = true;
m_mouse_was_moved = true;
// orientation has changed, redraw mesh
DisplayStatus();
Request_refresh();
// *Do not* reactivate the timer here during the mouse move command:
// OnMiddleUp() will do it at the end of mouse drag/move command
}
if( !event.Dragging() && m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
{
STATUSBAR_REPORTER reporter( m_parentStatusBar, EDA_3D_VIEWER_STATUSBAR::HOVERED_ITEM );
RAY mouseRay = getRayAtCurrentMousePosition();
BOARD_ITEM* rollOverItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
m_camera.SetCurMousePosition( nativePosition );
auto printNetInfo =
[]( BOARD_CONNECTED_ITEM* aItem )
{
return wxString::Format( _( "Net %s\tNet class %s" ),
aItem->GetNet()->GetNetname(),
aItem->GetNet()->GetNetClass()->GetName() );
};
if( !event.Dragging() && m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL )
{
STATUSBAR_REPORTER reporter( m_parentStatusBar,
static_cast<int>( EDA_3D_VIEWER_STATUSBAR::HOVERED_ITEM ) );
RAY mouseRay = getRayAtCurrrentMousePosition();
BOARD_ITEM *rollOverItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
if( rollOverItem )
{
wxString msg;
if( rollOverItem != m_currentRollOverItem )
{
m_3d_render_opengl->SetCurrentRollOverItem( rollOverItem );
@@ -680,61 +723,62 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
{
case PCB_PAD_T:
{
PAD* pad = static_cast<PAD*>( rollOverItem );
PAD* pad = dynamic_cast<PAD*>( rollOverItem );
if( !pad->GetNumber().IsEmpty() )
msg += wxString::Format( _( "Pad %s\t" ), pad->GetNumber() );
if( pad->IsOnCopperLayer() )
msg += printNetInfo( pad );
break;
if( pad && pad->IsOnCopperLayer() )
{
reporter.Report( wxString::Format( _( "Net %s\tNetClass %s\tPadName %s" ),
pad->GetNet()->GetNetname(),
pad->GetNet()->GetNetClassName(),
pad->GetNumber() ) );
}
}
break;
case PCB_FOOTPRINT_T:
{
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( rollOverItem );
msg += footprint->GetReference();
break;
FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( rollOverItem );
if( footprint )
reporter.Report( footprint->GetReference() );
}
break;
case PCB_TRACE_T:
case PCB_VIA_T:
case PCB_ARC_T:
{
PCB_TRACK* track = static_cast<PCB_TRACK*>( rollOverItem );
msg += printNetInfo( track );
break;
PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( rollOverItem );
if( track )
{
reporter.Report( wxString::Format( _( "Net %s\tNetClass %s" ),
track->GetNet()->GetNetname(),
track->GetNet()->GetNetClassName() ) );
}
}
break;
case PCB_ZONE_T:
{
ZONE* zone = static_cast<ZONE*>( rollOverItem );
ZONE* zone = dynamic_cast<ZONE*>( rollOverItem );
if( !zone->GetZoneName().IsEmpty() )
if( zone && zone->IsOnCopperLayer() )
{
if( zone->GetIsRuleArea() )
msg += wxString::Format( _( "Rule area %s\t" ), zone->GetZoneName() );
else
msg += wxString::Format( _( "Zone %s\t" ), zone->GetZoneName() );
reporter.Report( wxString::Format( _( "Net %s\tNetClass %s" ),
zone->GetNet()->GetNetname(),
zone->GetNet()->GetNetClassName() ) );
}
if( zone->IsOnCopperLayer() )
msg += printNetInfo( zone );
break;
}
break;
default:
break;
}
reporter.Report( msg );
}
else
{
if( m_currentRollOverItem
&& m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( m_currentRollOverItem && m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL )
{
m_3d_render_opengl->SetCurrentRollOverItem( nullptr );
Request_refresh();
@@ -755,7 +799,7 @@ void EDA_3D_CANVAS::OnLeftDown( wxMouseEvent& event )
if( !event.Dragging() && ( m_3d_render_raytracing != nullptr ) )
{
RAY mouseRay = getRayAtCurrentMousePosition();
RAY mouseRay = getRayAtCurrrentMousePosition();
BOARD_ITEM *intersectedBoardItem = m_3d_render_raytracing->IntersectBoardItem( mouseRay );
@@ -801,14 +845,8 @@ void EDA_3D_CANVAS::OnMiddleUp( wxMouseEvent& event )
}
void EDA_3D_CANVAS::OnTimerTimeout_Editing( wxTimerEvent& aEvent )
void EDA_3D_CANVAS::OnTimerTimeout_Editing( wxTimerEvent& /* event */ )
{
if( aEvent.GetId() != m_editing_timeout_timer.GetId() )
{
aEvent.Skip();
return;
}
m_mouse_is_moving = false;
m_mouse_was_moved = false;
@@ -829,14 +867,8 @@ void EDA_3D_CANVAS::restart_editingTimeOut_Timer()
}
void EDA_3D_CANVAS::OnTimerTimeout_Redraw( wxTimerEvent& aEvent )
void EDA_3D_CANVAS::OnTimerTimeout_Redraw( wxTimerEvent& event )
{
if( aEvent.GetId() != m_redraw_trigger_timer.GetId() )
{
aEvent.Skip();
return;
}
Request_refresh( true );
}
@@ -899,7 +931,7 @@ void EDA_3D_CANVAS::request_start_moving_camera( float aMovingSpeed, bool aRende
void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position()
{
RAY mouseRay = getRayAtCurrentMousePosition();
RAY mouseRay = getRayAtCurrrentMousePosition();
float hit_t;
@@ -923,7 +955,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode )
const float delta_move = m_delta_move_step_factor * m_camera.GetZoom();
const float arrow_moving_time_speed = 8.0f;
bool handled = false;
bool handled = false;
switch( aKeycode )
{
@@ -1080,10 +1112,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode )
void EDA_3D_CANVAS::RenderEngineChanged()
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
switch( cfg->m_Render.engine )
switch( m_boardAdapter.GetRenderEngine() )
{
case RENDER_ENGINE::OPENGL: m_3d_render = m_3d_render_opengl; break;
case RENDER_ENGINE::RAYTRACING: m_3d_render = m_3d_render_raytracing; break;
@@ -1099,13 +1128,13 @@ void EDA_3D_CANVAS::RenderEngineChanged()
}
RAY EDA_3D_CANVAS::getRayAtCurrentMousePosition()
RAY EDA_3D_CANVAS::getRayAtCurrrentMousePosition()
{
SFVEC3F rayOrigin;
SFVEC3F rayDir;
// Generate a ray origin and direction based on current mouser position and camera
m_camera.MakeRayAtCurrentMousePosition( rayOrigin, rayDir );
m_camera.MakeRayAtCurrrentMousePosition( rayOrigin, rayDir );
RAY mouseRay;
mouseRay.Init( rayOrigin, rayDir );
+10 -60
View File
@@ -30,7 +30,7 @@
#include "3d_rendering/raytracing/accelerators/accelerator_3d.h"
#include "3d_rendering/render_3d_base.h"
#include "3d_cache/3d_cache.h"
#include <gal/hidpi_gl_3D_canvas.h>
#include <gal/hidpi_gl_canvas.h>
#include <wx/image.h>
#include <wx/timer.h>
@@ -45,7 +45,7 @@ class RENDER_3D_OPENGL;
/**
* Implement a canvas based on a wxGLCanvas
*/
class EDA_3D_CANVAS : public HIDPI_GL_3D_CANVAS
class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
{
public:
/**
@@ -161,53 +161,6 @@ public:
*/
void OnEvent( wxEvent& aEvent );
/**
* Get information used to display 3D board.
*/
const BOARD_ADAPTER& GetBoardAdapter() const { return m_boardAdapter; }
/**
* Get a value indicating whether to render the pivot.
*/
bool GetRenderPivot() { return m_render_pivot; }
/**
* Set aValue indicating whether to render the pivot.
*
* @param aValue true will cause the pivot to be rendered on the next redraw.
*/
void SetRenderPivot( bool aValue ) { m_render_pivot = aValue; }
/**
* Get a value indicating whether to render the 3dmouse pivot.
*/
bool GetRender3dmousePivot()
{
return m_render3dmousePivot;
}
/**
* Set aValue indicating whether to render the 3dmouse pivot.
*
* @param aValue true will cause the pivot to be rendered on the next redraw.
*/
void SetRender3dmousePivot( bool aValue )
{
m_render3dmousePivot = aValue;
}
/**
* Set the position of the the 3dmouse pivot.
*
* @param aPos is the position of the 3dmouse rotation pivot
*/
void Set3dmousePivotPos( const SFVEC3F& aPos )
{
m_3dmousePivotPos = aPos;
}
private:
/**
* Called by a wxPaintEvent event
@@ -275,13 +228,6 @@ private:
*/
void render_pivot( float t, float aScale );
/**
* Render the 3dmouse pivot cursor.
*
* @param aScale scale to apply on the cursor.
*/
void render3dmousePivot( float aScale );
/**
* @return true if OpenGL initialization succeeded.
*/
@@ -292,7 +238,7 @@ private:
*/
void releaseOpenGL();
RAY getRayAtCurrentMousePosition();
RAY getRayAtCurrrentMousePosition();
private:
TOOL_DISPATCHER* m_eventDispatcher;
@@ -308,6 +254,9 @@ private:
wxTimer m_redraw_trigger_timer; // Used to schedule a redraw event
std::atomic_flag m_is_currently_painting; // Avoid drawing twice at the same time
bool m_mouse_is_moving; // Mouse activity is in progress
bool m_mouse_was_moved;
bool m_camera_is_moving; // Camera animation is ongoing
bool m_render_pivot; // Render the pivot while camera moving
float m_camera_moving_speed; // 1.0f will be 1:1
unsigned m_strtime_camera_movement; // Ticktime of camera movement start
@@ -315,10 +264,14 @@ private:
int m_moving_speed_multiplier; // Camera animation speed multiplier option
BOARD_ADAPTER& m_boardAdapter; // Pre-computed 3D info and settings
CAMERA& m_camera;
RENDER_3D_BASE* m_3d_render;
RENDER_3D_RAYTRACE* m_3d_render_raytracing;
RENDER_3D_OPENGL* m_3d_render_opengl;
static const float m_delta_move_step_factor; // Step factor to used with cursor on
// relation to the current zoom
bool m_opengl_supports_raytracing;
bool m_render_raytracing_was_requested;
@@ -326,9 +279,6 @@ private:
BOARD_ITEM* m_currentRollOverItem;
bool m_render3dmousePivot = false; // Render the 3dmouse pivot
SFVEC3F m_3dmousePivotPos; // The position of the 3dmouse pivot
/**
* 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
+1 -42
View File
@@ -73,7 +73,7 @@ static void pivot_render_triangles( float t )
}
void EDA_3D_CANVAS::render_pivot( float t, float aScale )
void EDA_3D_CANVAS::render_pivot( float t , float aScale )
{
wxASSERT( aScale >= 0.0f );
wxASSERT( t >= 0.0f );
@@ -118,44 +118,3 @@ void EDA_3D_CANVAS::render_pivot( float t, float aScale )
pivot_render_triangles( t * 0.5f );
glPopMatrix();
}
void EDA_3D_CANVAS::render3dmousePivot( float aScale )
{
wxASSERT( aScale >= 0.0f );
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
glDisable( GL_CULL_FACE );
// Set projection and modelview matrixes
glMatrixMode( GL_PROJECTION );
glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) );
glEnable( GL_COLOR_MATERIAL );
glColor4f( 0.0f, 0.667f, 0.902f, 0.75f );
// Translate to the look at position
glTranslatef( m_3dmousePivotPos.x, m_3dmousePivotPos.y, m_3dmousePivotPos.z );
glPointSize( 16.0f );
glEnable( GL_POINT_SMOOTH );
glHint( GL_POINT_SMOOTH_HINT, GL_NICEST );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glScalef( aScale, aScale, aScale );
// Draw a point at the look at position.
glBegin( GL_POINTS );
glVertex3f( 0, 0, 0 );
glEnd();
glDisable( GL_BLEND );
glDisable( GL_POINT_SMOOTH );
}
+59 -11
View File
@@ -30,6 +30,52 @@
#ifndef _3D_ENUMS_H_
#define _3D_ENUMS_H_
/// Flags used in rendering options
enum DISPLAY3D_FLG
{
FL_AXIS = 0,
FL_ZONE,
FL_ADHESIVE,
FL_SILKSCREEN,
FL_SOLDERMASK,
FL_SOLDERPASTE,
FL_COMMENTS,
FL_ECO,
FL_FP_ATTRIBUTES_NORMAL,
FL_FP_ATTRIBUTES_NORMAL_INSERT,
FL_FP_ATTRIBUTES_VIRTUAL,
FL_USE_SELECTION,
FL_HIGHLIGHT_ROLLOVER_ITEM,
FL_SHOW_BOARD_BODY,
FL_MOUSEWHEEL_PANNING,
FL_USE_REALISTIC_MODE,
FL_SUBTRACT_MASK_FROM_SILK,
FL_CLIP_SILK_ON_VIA_ANNULUS,
FL_RENDER_PLATED_PADS_AS_PLATED,
// OpenGL options
FL_RENDER_OPENGL_SHOW_MODEL_BBOX,
FL_RENDER_OPENGL_COPPER_THICKNESS,
FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE,
FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE,
FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE,
FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE,
// Raytracing options
FL_RENDER_RAYTRACING_SHADOWS,
FL_RENDER_RAYTRACING_BACKFLOOR,
FL_RENDER_RAYTRACING_REFRACTIONS,
FL_RENDER_RAYTRACING_REFLECTIONS,
FL_RENDER_RAYTRACING_POST_PROCESSING,
FL_RENDER_RAYTRACING_ANTI_ALIASING,
FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES,
FL_LAST
};
/// Rotation direction for the 3d canvas
enum class ROTATION_DIR
{
@@ -41,37 +87,39 @@ enum class ROTATION_DIR
Z_CCW
};
/// Camera types
enum class CAMERA_TYPE
{
TRACKBALL
};
// Do not modify the following enum numbers, they are saved in the config file and used in the UI
/// Grid types
enum class GRID3D_TYPE
{
NONE = 0,
GRID_1MM = 1,
GRID_2P5MM = 2,
GRID_5MM = 3,
GRID_10MM = 4
NONE,
GRID_1MM,
GRID_2P5MM,
GRID_5MM,
GRID_10MM
};
/// Render engine mode
enum class RENDER_ENGINE
{
OPENGL = 0,
RAYTRACING = 1,
OPENGL,
RAYTRACING,
};
/// Render 3d model shape materials mode
enum class MATERIAL_MODE
{
NORMAL = 0, ///< Use all material properties from model file
DIFFUSE_ONLY = 1, ///< Use only diffuse material properties
CAD_MODE = 2 ///< Use a gray shading based on diffuse material
NORMAL, ///< Use all material properties from model file
DIFFUSE_ONLY, ///< Use only diffuse material properties
CAD_MODE ///< Use a gray shading based on diffuse material
};
#endif // _3D_ENUMS_H_
@@ -27,7 +27,6 @@
* 3d models that come in the original data from the files without any transformations.
*/
#include <gal/opengl/kiglew.h> // Must be included first
#include <iostream>
#include "3d_rendering/opengl/3d_model.h"
#include "eda_3d_model_viewer.h"
@@ -39,12 +38,11 @@
#include <settings/common_settings.h>
#include <pgm_base.h>
#include <gal/dpi_scaling.h>
#include <macros.h>
/**
* Scale conversion from 3d model units to pcb units
*/
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
#define UNITS3D_TO_UNITSPCB (IU_PER_MM)
/**
* Trace mask used to enable or disable the trace output of this class.
@@ -158,7 +156,7 @@ void EDA_3D_MODEL_VIEWER::Set3DModel( const wxString& aModelPathName)
if( m_cacheManager )
{
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName, wxEmptyString );
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName );
if( model )
Set3DModel( (const S3DMODEL &)*model );
@@ -184,20 +182,6 @@ void EDA_3D_MODEL_VIEWER::Clear3DModel()
void EDA_3D_MODEL_VIEWER::ogl_initialize()
{
const GLenum err = glewInit();
if( GLEW_OK != err )
{
const wxString msgError = (const char*) glewGetErrorString( err );
wxLogMessage( msgError );
}
else
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::ogl_initialize Using GLEW version %s" ),
FROM_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
}
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
@@ -257,13 +241,6 @@ void EDA_3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
if( m_glRC == nullptr )
m_glRC = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
// CreateCtx could and does fail per sentry crash events, lets be graceful
if( m_glRC == nullptr )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::OnPaint creating gl context failed" ) );
return;
}
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
// Set the OpenGL viewport according to the client size of this canvas.
@@ -330,16 +307,8 @@ void EDA_3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
m_ogl_3dmodel->BeginDrawMulti( true );
m_ogl_3dmodel->DrawOpaque( false );
glDepthMask( GL_FALSE );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
m_ogl_3dmodel->DrawTransparent( 1.0f, false );
glDisable( GL_BLEND );
glDepthMask( GL_TRUE );
m_ogl_3dmodel->EndDrawMulti();
glPopMatrix();
-25
View File
@@ -1,25 +0,0 @@
add_library(3d-viewer_navlib STATIC
"nl_3d_viewer_plugin.cpp"
"nl_3d_viewer_plugin_impl.cpp"
)
# 3d-viewer_navlib depends on make_lexer outputs in common
add_dependencies( 3d-viewer_navlib pcbcommon )
# Find the 3DxWare SDK component 3DxWare::NlClient
# find_package(TDxWare_SDK 4.0 REQUIRED COMPONENTS 3DxWare::Navlib)
target_compile_definitions(3d-viewer_navlib PRIVATE
$<TARGET_PROPERTY:3DxWare::Navlib,INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(3d-viewer_navlib PRIVATE
$<TARGET_PROPERTY:3DxWare::Navlib,INTERFACE_COMPILE_OPTIONS>
)
target_include_directories(3d-viewer_navlib PRIVATE
$<TARGET_PROPERTY:3DxWare::Navlib,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:pcbnew_kiface_objects,INCLUDE_DIRECTORIES>
)
target_link_libraries(3d-viewer_navlib
$<TARGET_PROPERTY:3DxWare::Navlib,INTERFACE_LINK_LIBRARIES>
3DxWare::Navlib
)
@@ -1,43 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
* 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_3d_viewer_plugin.h"
#include "nl_3d_viewer_plugin_impl.h"
#include <advanced_config.h>
NL_3D_VIEWER_PLUGIN::NL_3D_VIEWER_PLUGIN( EDA_3D_CANVAS* aViewport )
{
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
m_impl = new NL_3D_VIEWER_PLUGIN_IMPL( aViewport );
}
NL_3D_VIEWER_PLUGIN::~NL_3D_VIEWER_PLUGIN()
{
delete m_impl;
}
void NL_3D_VIEWER_PLUGIN::SetFocus( bool focus )
{
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
m_impl->SetFocus( focus );
}
-60
View File
@@ -1,60 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
* 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_3d_viewer_plugin.h
* @brief Declaration of the NL_3D_VIEWER_PLUGIN class
*/
#ifndef NL_3D_VIEWER_PLUGIN_H_
#define NL_3D_VIEWER_PLUGIN_H_
// Forward declarations.
class EDA_3D_CANVAS;
class NL_3D_VIEWER_PLUGIN_IMPL;
/**
* The class that implements the public interface to the SpaceMouse plug-in.
*/
class NL_3D_VIEWER_PLUGIN
{
public:
/**
* Initializes a new instance of the NL_3D_VIEWER_PLUGIN.
*
* @param aViewport is the viewport to be navigated.
*/
NL_3D_VIEWER_PLUGIN( EDA_3D_CANVAS* aViewport );
virtual ~NL_3D_VIEWER_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:
NL_3D_VIEWER_PLUGIN_IMPL* m_impl;
};
#endif // NL_3D_VIEWER_PLUGIN_H_
@@ -1,659 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
* 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_3d_viewer_plugin_impl.h"
// 3d-viewer
#include <3d-viewer/3d_rendering/track_ball.h>
#include <3d-viewer/3d_canvas/eda_3d_canvas.h>
// KiCAD includes
#include <tool/action_manager.h>
#include <tool/tool_manager.h>
// stdlib
#include <map>
#include <string>
#include <vector>
#include <wx/mstream.h>
/**
* Flag to enable the NL_3D_VIEWER_PLUGIN debug tracing.
*
* Use "KI_TRACE_NL_3D_VIEWER_PLUGIN" to enable.
*
* @ingroup trace_env_vars
*/
const wxChar* NL_3D_VIEWER_PLUGIN_IMPL::m_logTrace = wxT( "KI_TRACE_NL_3D_VIEWER_PLUGIN" );
/**
* Template to compare two glm::mat<T> values for equality within a required epsilon.
*
* @param aFirst value to compare.
* @param aSecond value to compare.
* @param aEpsilon allowed error.
* @return true if the values considered equal within the specified epsilon, otherwise false.
*/
template <glm::length_t L, glm::length_t C, class T, glm::qualifier Q>
bool equals( glm::mat<L, C, T, Q> const& aFirst, glm::mat<L, C, T, Q> const& aSecond,
T aEpsilon = static_cast<T>( FLT_EPSILON * 10 ) )
{
T const* first = glm::value_ptr( aFirst );
T const* second = glm::value_ptr( aSecond );
for( glm::length_t j = 0; j < L * C; ++j )
{
if( !equals( first[j], second[j], aEpsilon ) )
{
return false;
}
}
return true;
}
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( "KiCAD 3D" );
EnableNavigation( true );
PutFrameTimingSource( TimingSource::SpaceMouse );
exportCommandsAndImages();
}
NL_3D_VIEWER_PLUGIN_IMPL::~NL_3D_VIEWER_PLUGIN_IMPL()
{
EnableNavigation( false );
}
void NL_3D_VIEWER_PLUGIN_IMPL::SetFocus( bool aFocus )
{
wxLogTrace( m_logTrace, wxT( "NL_3D_VIEWER_PLUGIN_IMPL::SetFocus %d" ), aFocus );
NAV_3D::Write( navlib::focus_k, aFocus );
}
// 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 )
{
using TDx::SpaceMouse::CCategory;
CATEGORY_STORE::iterator parent_iter = aCategoryStore.begin();
std::string::size_type pos = aCategoryPath.find_last_of( '.' );
if( pos != std::string::npos )
{
std::string parentPath = aCategoryPath.substr( 0, pos );
parent_iter = aCategoryStore.find( parentPath );
if( parent_iter == aCategoryStore.end() )
{
parent_iter = add_category( parentPath, aCategoryStore );
}
}
std::string name = aCategoryPath.substr( pos + 1 );
std::unique_ptr<CCategory> categoryNode =
std::make_unique<CCategory>( aCategoryPath.c_str(), name.c_str() );
CATEGORY_STORE::iterator iter = aCategoryStore.insert(
aCategoryStore.end(), CATEGORY_STORE::value_type( aCategoryPath, categoryNode.get() ) );
parent_iter->second->push_back( std::move( categoryNode ) );
return iter;
}
void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages()
{
wxLogTrace( m_logTrace, wxT( "NL_3D_VIEWER_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->GetLabel().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;
}
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 );
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetCameraMatrix( navlib::matrix_t& matrix ) const
{
// cache the camera matrix so that we can tell if the view has been moved and
// calculate a delta transform if required.
m_cameraMatrix = m_camera->GetViewMatrix();
std::copy_n( glm::value_ptr( glm::inverse( m_cameraMatrix ) ), 16, matrix.m );
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetPointerPosition( navlib::point_t& position ) const
{
SFVEC3F origin, direction;
m_camera->MakeRayAtCurrentMousePosition( origin, direction );
position = { origin.x, origin.y, origin.z };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetViewExtents( navlib::box_t& extents ) const
{
if( m_camera->GetProjection() == PROJECTION_TYPE::PERSPECTIVE )
{
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
}
const CAMERA_FRUSTUM& f = m_camera->GetFrustum();
double half_width = f.fw / 2.;
double half_height = f.fh / 2.;
extents = { -half_width, -half_height, f.nearD, half_width, half_height, f.farD };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetViewFOV( double& aFov ) const
{
const CAMERA_FRUSTUM& f = m_camera->GetFrustum();
aFov = glm::radians( f.angle );
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetViewFrustum( navlib::frustum_t& aFrustum ) const
{
if( m_camera->GetProjection() != PROJECTION_TYPE::PERSPECTIVE )
{
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
}
const CAMERA_FRUSTUM& f = m_camera->GetFrustum();
double half_width = f.nw / 2.;
double half_height = f.nh / 2.;
aFrustum = { -half_width, half_width, -half_height, half_height, f.nearD, f.farD };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetIsViewPerspective( navlib::bool_t& perspective ) const
{
perspective = m_camera->GetProjection() == PROJECTION_TYPE::PERSPECTIVE ? 1 : 0;
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetCameraMatrix( const navlib::matrix_t& aCameraMatrix )
{
long result = 0;
glm::mat4 cam, viewMatrix;
std::copy_n( aCameraMatrix.m, 16, glm::value_ptr( cam ) );
viewMatrix = glm::inverse( cam );
glm::mat4 camera = m_camera->GetViewMatrix();
// The navlib does not move the camera in its z-axis in an orthographic projection
// as this does not change the viewed object size. However ...
if( m_camera->GetProjection() == PROJECTION_TYPE::ORTHO )
{
// ... the CAMERA class couples zoom and distance to the object: we need to
// ensure that The CAMERA's z position relative to the lookat_pos is not changed
// in an orthographic projection.
glm::vec4 lookat( m_camera->GetLookAtPos(), 1.0f );
glm::vec4 lookat_new = viewMatrix * lookat;
glm::vec4 lookat_old = camera * lookat;
viewMatrix[3].z += lookat_old.z - lookat_new.z;
}
if( !equals( camera, m_cameraMatrix ) )
{
// Some other input device has moved the camera. Apply only the intended delta
// transform ...
m_camera->SetViewMatrix( viewMatrix * glm::inverse( m_cameraMatrix ) * camera );
m_camera->Update();
// .., cache the intended camera matrix so that we can calculate the delta
// transform when needed ...
m_cameraMatrix = viewMatrix;
// ... and let the 3DMouse controller know, that something is amiss.
return navlib::make_result_code( navlib::navlib_errc::error );
}
m_camera->SetViewMatrix( viewMatrix );
m_camera->Update();
// cache the view matrix so that we know when it has changed.
m_cameraMatrix = m_camera->GetViewMatrix();
// The camera has a constraint on the z position so we need to check that ...
if( !equals( m_cameraMatrix[3].z, viewMatrix[3].z ) )
{
// ... and let the 3DMouse controller know, when something is amiss.
return navlib::make_result_code( navlib::navlib_errc::error );
}
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetViewExtents( const navlib::box_t& extents )
{
const CAMERA_FRUSTUM& f = m_camera->GetFrustum();
float factor = f.nw / ( extents.max_x - extents.min_x );
float zoom = m_camera->GetZoom() / factor;
m_camera->Zoom( factor );
// The camera auto positions the camera to match the zoom values. We need to
// update our cached camera matrix to match the new z value
m_cameraMatrix[3].z = m_camera->GetViewMatrix()[3].z;
// The camera has a constraint on the zoom factor so we need to check that ...
if( zoom != m_camera->GetZoom() )
{
// ... and let the 3DMouse controller know, when something is amiss.
return navlib::make_result_code( navlib::navlib_errc::error );
}
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetViewFOV( double fov )
{
return navlib::make_result_code( navlib::navlib_errc::function_not_supported );
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetViewFrustum( const navlib::frustum_t& frustum )
{
return navlib::make_result_code( navlib::navlib_errc::permission_denied );
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetModelExtents( navlib::box_t& extents ) const
{
SFVEC3F min = m_canvas->GetBoardAdapter().GetBBox().Min();
SFVEC3F max = m_canvas->GetBoardAdapter().GetBBox().Max();
extents = { min.x, min.y, min.z, max.x, max.y, max.z };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetSelectionExtents( navlib::box_t& extents ) const
{
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetSelectionTransform( navlib::matrix_t& transform ) const
{
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetIsSelectionEmpty( navlib::bool_t& empty ) const
{
empty = true;
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetSelectionTransform( const navlib::matrix_t& matrix )
{
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotPosition( navlib::point_t& position ) const
{
SFVEC3F lap = m_camera->GetLookAtPos();
position = { lap.x, lap.y, lap.z };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::IsUserPivot( navlib::bool_t& userPivot ) const
{
userPivot = false;
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotPosition( const navlib::point_t& position )
{
SFVEC3F pivotPos = SFVEC3F( position.x, position.y, position.z );
// Set the 3dmouse pivot position.
m_canvas->Set3dmousePivotPos( pivotPos );
// Set the camera lookat pos.
m_camera->SetLookAtPos_T1( pivotPos );
m_canvas->Request_refresh();
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetPivotVisible( navlib::bool_t& visible ) const
{
visible = m_canvas->GetRender3dmousePivot();
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetPivotVisible( bool visible )
{
m_canvas->SetRender3dmousePivot( visible );
m_canvas->Request_refresh();
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetHitLookAt( navlib::point_t& position ) const
{
RAY mouseRay;
mouseRay.Init( m_rayOrigin, m_rayDirection );
float hit;
glm::vec3 vec;
// Test it with the board bounding box
if( m_canvas->GetBoardAdapter().GetBBox().Intersect( mouseRay, &hit ) )
{
vec = mouseRay.at( hit );
position = { vec.x, vec.y, vec.z };
return 0;
}
return navlib::make_result_code( navlib::navlib_errc::no_data_available );
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetHitAperture( double aperture )
{
return navlib::make_result_code( navlib::navlib_errc::function_not_supported );
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetHitDirection( const navlib::vector_t& direction )
{
m_rayDirection = { direction.x, direction.y, direction.z };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetHitLookFrom( const navlib::point_t& eye )
{
m_rayOrigin = { eye.x, eye.y, eye.z };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetHitSelectionOnly( bool onlySelection )
{
return navlib::make_result_code( navlib::navlib_errc::function_not_supported );
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetActiveCommand( std::string commandId )
{
if( commandId.empty() )
{
return 0;
}
std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList();
TOOL_ACTION* context = nullptr;
for( std::list<TOOL_ACTION*>::const_iterator it = actions.begin(); it != actions.end(); it++ )
{
TOOL_ACTION* action = *it;
std::string nm = action->GetName();
if( commandId == nm )
{
context = action;
}
}
if( context != nullptr )
{
wxWindow* parent = m_canvas->GetParent();
// Only allow command execution if the window is enabled. i.e. there is not a modal dialog
// currently active.
if( parent->IsEnabled() )
{
TOOL_MANAGER* tool_manager = static_cast<PCB_BASE_FRAME*>( parent )->GetToolManager();
if( tool_manager == nullptr )
{
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
}
// Get the selection to use to test if the action is enabled
SELECTION& sel = tool_manager->GetToolHolder()->GetCurrentSelection();
bool runAction = true;
if( const ACTION_CONDITIONS* aCond =
tool_manager->GetActionManager()->GetCondition( *context ) )
{
runAction = aCond->enableCondition( sel );
}
if( runAction )
{
tool_manager->RunAction( *context, true );
m_canvas->Request_refresh();
}
}
else
{
return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
}
}
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetSettingsChanged( long change )
{
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetMotionFlag( bool value )
{
m_capIsMoving = value;
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetTransaction( long value )
{
if( value != 0L )
{
}
else
{
m_canvas->Request_refresh( true );
wxLogTrace( m_logTrace, wxT( "End of transaction" ) );
}
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::SetCameraTarget( const navlib::point_t& position )
{
return navlib::make_result_code( navlib::navlib_errc::function_not_supported );
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetFrontView( navlib::matrix_t& matrix ) const
{
matrix = { 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1 };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetCoordinateSystem( navlib::matrix_t& matrix ) const
{
// Use the right-handed coordinate system X-right, Z-up, Y-in (row vectors)
matrix = { 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1 };
return 0;
}
long NL_3D_VIEWER_PLUGIN_IMPL::GetIsViewRotatable( navlib::bool_t& isRotatable ) const
{
isRotatable = true;
return 0;
}
@@ -1,136 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
* 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_3d_viewer_plugin_impl.h
* @brief Declaration of the NL_3D_VIEWER_PLUGIN_IMPL class
*/
#ifndef NL_3D_VIEWER_PLUGIN_IMPL_H_
#define NL_3D_VIEWER_PLUGIN_IMPL_H_
// TDxWare SDK.
#include <SpaceMouse/CNavigation3D.hpp>
// KiCAD
#include <include/plugins/3dapi/xv3d_types.h>
// wx
#include <wx/chartype.h>
// glm
#include <glm/glm.hpp>
// Forward declarations.
class EDA_3D_CANVAS;
class TRACK_BALL;
// Convenience typedef.
typedef TDx::SpaceMouse::Navigation3D::CNavigation3D NAV_3D;
/**
* The class that implements the accessors and mutators required for
* 3D navigation in an EDA_3D_CANVAS using a SpaceMouse.
*/
class NL_3D_VIEWER_PLUGIN_IMPL : public NAV_3D
{
public:
/**
* Initializes a new instance of the NL_3DVIEWER_PLUGIN.
*
* @param aCanvas is the viewport to be navigated.
*/
NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas );
virtual ~NL_3D_VIEWER_PLUGIN_IMPL();
/**
* 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:
/**
* Export the invocable actions and images to the 3Dconnexion UI.
*/
void exportCommandsAndImages();
long GetCameraMatrix( navlib::matrix_t& aMatrix ) const override;
long GetPointerPosition( navlib::point_t& aPosition ) const override;
long GetViewExtents( navlib::box_t& aExtents ) const override;
long GetViewFOV( double& aFov ) const override;
long GetViewFrustum( navlib::frustum_t& aFrustum ) const override;
long GetIsViewPerspective( navlib::bool_t& aPerspective ) const override;
long SetCameraMatrix( const navlib::matrix_t& aMatrix ) override;
long SetViewExtents( const navlib::box_t& aExtents ) override;
long SetViewFOV( double aFov ) override;
long SetViewFrustum( const navlib::frustum_t& aFrustum ) override;
long GetModelExtents( navlib::box_t& aExtents ) const override;
long GetSelectionExtents( navlib::box_t& aExtents ) const override;
long GetSelectionTransform( navlib::matrix_t& aTransform ) const override;
long GetIsSelectionEmpty( navlib::bool_t& aEmpty ) const override;
long SetSelectionTransform( const navlib::matrix_t& aMatrix ) override;
long GetPivotPosition( navlib::point_t& aPosition ) const override;
long IsUserPivot( navlib::bool_t& aUserPivot ) const override;
long SetPivotPosition( const navlib::point_t& aPosition ) override;
long GetPivotVisible( navlib::bool_t& aVisible ) const override;
long SetPivotVisible( bool aVisible ) override;
long GetHitLookAt( navlib::point_t& aPosition ) const override;
long SetHitAperture( double aAperture ) override;
long SetHitDirection( const navlib::vector_t& aDirection ) override;
long SetHitLookFrom( const navlib::point_t& aPosition ) override;
long SetHitSelectionOnly( bool aSelectionOnly ) override;
long SetActiveCommand( std::string aCommandId ) override;
long SetSettingsChanged( long aChangeNumber ) override;
long SetMotionFlag( bool aValue ) override;
long SetTransaction( long aValue ) override;
long SetCameraTarget( const navlib::point_t& aPosition ) override;
long GetFrontView( navlib::matrix_t& aMatrix ) const override;
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;
bool m_capIsMoving;
double m_newWidth;
SFVEC3F m_rayOrigin;
SFVEC3F m_rayDirection;
// The cached CAMERA affine matrix. This is used to determine if the camera has been
// moved. The camera matrix is the world to camera affine.
mutable glm::mat4 m_cameraMatrix;
/**
* 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_3DVIEWER_PLUGIN". See the wxWidgets documentation on wxLogTrace for
* more information.
*/
static const wxChar* m_logTrace;
};
#endif // NL_3D_VIEWER_PLUGIN_IMPL_H_
+34 -106
View File
@@ -28,7 +28,7 @@
#include "camera.h"
#include <wx/log.h>
#include <algorithm>
// A helper function to normalize aAngle between -2PI and +2PI
inline void normalise2PI( float& aAngle )
@@ -46,8 +46,9 @@ inline void normalise2PI( float& aAngle )
*/
const wxChar *CAMERA::m_logTrace = wxT( "KI_TRACE_CAMERA" );
const float CAMERA::DEFAULT_MIN_ZOOM = 0.020f;
const float CAMERA::DEFAULT_MAX_ZOOM = 2.0f;
#define DEFAULT_MIN_ZOOM 0.10f
#define DEFAULT_MAX_ZOOM 1.20f
CAMERA::CAMERA( float aInitialDistance )
@@ -120,21 +121,6 @@ void CAMERA::Reset_T1()
}
void CAMERA::SetBoardLookAtPos( const SFVEC3F& aBoardPos )
{
if( m_board_lookat_pos_init != aBoardPos )
{
m_board_lookat_pos_init = aBoardPos;
m_lookat_pos = aBoardPos;
m_parametersChanged = true;
updateViewMatrix();
updateFrustum();
}
}
void CAMERA::zoomChanged()
{
if( m_zoom < m_minZoom )
@@ -179,20 +165,12 @@ void CAMERA::updateRotationMatrix()
}
glm::mat4 CAMERA::GetRotationMatrix() const
const glm::mat4 CAMERA::GetRotationMatrix() const
{
return m_rotationMatrix * m_rotationMatrixAux;
}
void CAMERA::SetRotationMatrix( const glm::mat4& aRotation )
{
m_parametersChanged = true;
std::copy_n( glm::value_ptr( aRotation * glm::inverse( m_rotationMatrixAux ) ), 12,
glm::value_ptr( m_rotationMatrix ) );
}
void CAMERA::rebuildProjection()
{
if( ( m_windowSize.x == 0 ) || ( m_windowSize.y == 0 ) )
@@ -208,6 +186,7 @@ void CAMERA::rebuildProjection()
m_frustum.nearD = 0.10f;
// Ratio width / height of the window display
m_frustum.angle = 45.0f;
m_projectionMatrix = glm::perspective( glm::radians( m_frustum.angle ), m_frustum.ratio,
@@ -220,22 +199,19 @@ void CAMERA::rebuildProjection()
m_focalLen.x = ( (float)m_windowSize.y / (float)m_windowSize.x ) / m_frustum.tang;
m_focalLen.y = 1.0f / m_frustum.tang;
m_frustum.nh = 2.0f * m_frustum.nearD * m_frustum.tang;
m_frustum.nh = m_frustum.nearD * m_frustum.tang;
m_frustum.nw = m_frustum.nh * m_frustum.ratio;
m_frustum.fh = 2.0f * m_frustum.farD * m_frustum.tang;
m_frustum.fh = m_frustum.farD * m_frustum.tang;
m_frustum.fw = m_frustum.fh * m_frustum.ratio;
break;
case PROJECTION_TYPE::ORTHO:
// 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 );
m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
const float orthoReductionFactor =
glm::length( m_camera_pos_init ) * m_zoom * m_frustum.tang;
// This formula was found by trial and error
const float orthoReductionFactor = glm::length( m_camera_pos_init ) *
m_zoom * m_zoom * 0.5f;
// Initialize Projection Matrix for Orthographic View
m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
@@ -307,26 +283,21 @@ void CAMERA::updateFrustum()
* http://www.lighthouse3d.com/tutorials/view-frustum-culling/
*/
const SFVEC3F half_right_nw = m_right * m_frustum.nw * 0.5f;
const SFVEC3F half_right_fw = m_right * m_frustum.fw * 0.5f;
const SFVEC3F half_up_nh = m_up * m_frustum.nh * 0.5f;
const SFVEC3F half_up_fh = m_up * m_frustum.fh * 0.5f;
// compute the centers of the near and far planes
m_frustum.nc = m_pos - m_dir * m_frustum.nearD;
m_frustum.fc = m_pos - m_dir * m_frustum.farD;
// compute the 4 corners of the frustum on the near plane
m_frustum.ntl = m_frustum.nc + half_up_nh - half_right_nw;
m_frustum.ntr = m_frustum.nc + half_up_nh + half_right_nw;
m_frustum.nbl = m_frustum.nc - half_up_nh - half_right_nw;
m_frustum.nbr = m_frustum.nc - half_up_nh + half_right_nw;
m_frustum.ntl = m_frustum.nc + m_up * m_frustum.nh - m_right * m_frustum.nw;
m_frustum.ntr = m_frustum.nc + m_up * m_frustum.nh + m_right * m_frustum.nw;
m_frustum.nbl = m_frustum.nc - m_up * m_frustum.nh - m_right * m_frustum.nw;
m_frustum.nbr = m_frustum.nc - m_up * m_frustum.nh + m_right * m_frustum.nw;
// compute the 4 corners of the frustum on the far plane
m_frustum.ftl = m_frustum.fc + half_up_fh - half_right_fw;
m_frustum.ftr = m_frustum.fc + half_up_fh + half_right_fw;
m_frustum.fbl = m_frustum.fc - half_up_fh - half_right_fw;
m_frustum.fbr = m_frustum.fc - half_up_fh + half_right_fw;
m_frustum.ftl = m_frustum.fc + m_up * m_frustum.fh - m_right * m_frustum.fw;
m_frustum.ftr = m_frustum.fc + m_up * m_frustum.fh + m_right * m_frustum.fw;
m_frustum.fbl = m_frustum.fc - m_up * m_frustum.fh - m_right * m_frustum.fw;
m_frustum.fbr = m_frustum.fc - m_up * m_frustum.fh + m_right * m_frustum.fw;
if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
{
@@ -335,12 +306,16 @@ void CAMERA::updateFrustum()
m_up_nY.resize( m_windowSize.y + 1 );
// Precalc X values for camera -> ray generation
const SFVEC3F right_nw = m_right * m_frustum.nw;
for( unsigned int x = 0; x < ( (unsigned int) m_windowSize.x + 1 ); ++x )
m_right_nX[x] = half_right_nw * m_scr_nX[x];
m_right_nX[x] = right_nw * m_scr_nX[x];
// Precalc Y values for camera -> ray generation
const SFVEC3F up_nh = m_up * m_frustum.nh;
for( unsigned int y = 0; y < ( (unsigned int) m_windowSize.y + 1 ); ++y )
m_up_nY[y] = half_up_nh * m_scr_nY[y];
m_up_nY[y] = up_nh * m_scr_nY[y];
}
}
@@ -351,16 +326,18 @@ void CAMERA::MakeRay( const SFVEC2I& aWindowPos, SFVEC3F& aOutOrigin,
wxASSERT( aWindowPos.x < m_windowSize.x );
wxASSERT( aWindowPos.y < m_windowSize.y );
aOutOrigin = m_frustum.nc + m_up_nY[aWindowPos.y] + m_right_nX[aWindowPos.x];
const SFVEC3F up_plus_right = m_up_nY[aWindowPos.y] + m_right_nX[aWindowPos.x];
switch( m_projectionType )
{
default:
case PROJECTION_TYPE::PERSPECTIVE:
aOutOrigin = up_plus_right + m_frustum.nc;
aOutDirection = glm::normalize( aOutOrigin - m_pos );
break;
case PROJECTION_TYPE::ORTHO:
aOutOrigin = up_plus_right * 0.5f + m_frustum.nc;
aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
break;
}
@@ -383,23 +360,23 @@ void CAMERA::MakeRay( const SFVEC2F& aWindowPos, SFVEC3F& aOutOrigin,
m_right_nX[floorWinPos_i.x] * (1.0f - relativeWinPos.x) +
m_right_nX[floorWinPos_i.x + 1] * relativeWinPos.x;
aOutOrigin = up_plus_right + m_frustum.nc;
switch( m_projectionType )
{
default:
case PROJECTION_TYPE::PERSPECTIVE:
aOutOrigin = up_plus_right + m_frustum.nc;
aOutDirection = glm::normalize( aOutOrigin - m_pos );
break;
case PROJECTION_TYPE::ORTHO:
aOutOrigin = up_plus_right * 0.5f + m_frustum.nc;
aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
break;
}
}
void CAMERA::MakeRayAtCurrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const
void CAMERA::MakeRayAtCurrrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const
{
const SFVEC2I windowPos = SFVEC2I( m_lastPosition.x, m_windowSize.y - m_lastPosition.y );
@@ -453,38 +430,6 @@ const glm::mat4& CAMERA::GetViewMatrix() const
}
void CAMERA::SetViewMatrix( glm::mat4 aViewMatrix )
{
SetRotationMatrix( aViewMatrix );
// The look at position in the view frame.
glm::vec4 lookat = aViewMatrix * glm::vec4( m_lookat_pos, 1.0f );
wxLogTrace( m_logTrace,
wxT( "CAMERA::SetViewMatrix aViewMatrix[3].z =%f, old_zoom=%f, new_zoom=%f, "
"m[3].z=%f" ),
aViewMatrix[3].z, m_zoom, lookat.z / m_camera_pos_init.z, lookat.z );
m_zoom = lookat.z / m_camera_pos_init.z;
if( m_zoom > m_maxZoom )
{
m_zoom = m_maxZoom;
aViewMatrix[3].z += -lookat.z + m_maxZoom * m_camera_pos_init.z;
}
else if( m_zoom < m_minZoom )
{
m_zoom = m_minZoom;
aViewMatrix[3].z += -lookat.z + m_minZoom * m_camera_pos_init.z;
}
m_viewMatrix = std::move( aViewMatrix );
m_camera_pos = m_viewMatrix
* glm::inverse( m_rotationMatrix * m_rotationMatrixAux
* glm::translate( glm::mat4( 1.0f ), -m_lookat_pos ) )[3];
}
const glm::mat4& CAMERA::GetViewMatrix_Inv() const
{
return m_viewMatrixInverse;
@@ -534,41 +479,24 @@ void CAMERA::ZoomReset()
rebuildProjection();
}
bool CAMERA::Zoom( float aFactor )
{
if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
if( ( m_zoom == m_minZoom && aFactor > 1 ) || ( m_zoom == m_maxZoom && aFactor < 1 )
|| aFactor == 1 )
{
return false;
}
float zoom = m_zoom;
m_zoom /= aFactor;
if( m_zoom <= m_minZoom && aFactor > 1 )
{
aFactor = zoom / m_minZoom;
m_zoom = m_minZoom;
}
else if( m_zoom >= m_maxZoom && aFactor < 1 )
{
aFactor = zoom / m_maxZoom;
m_zoom = m_maxZoom;
}
m_camera_pos.z /= aFactor;
updateViewMatrix();
rebuildProjection();
zoomChanged();
return true;
}
bool CAMERA::Zoom_T1( float aFactor )
{
if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
if( ( m_zoom == m_minZoom && aFactor > 1 ) || ( m_zoom == m_maxZoom && aFactor < 1 )
|| aFactor == 1 )
{
return false;
+11 -34
View File
@@ -77,9 +77,6 @@ enum class CAMERA_INTERPOLATION
class CAMERA
{
public:
static const float DEFAULT_MIN_ZOOM;
static const float DEFAULT_MAX_ZOOM;
/**
* Initialize a camera.
*
@@ -96,7 +93,7 @@ public:
*
* @return the rotation matrix of the camera
*/
glm::mat4 GetRotationMatrix() const;
const glm::mat4 GetRotationMatrix() const;
const glm::mat4& GetViewMatrix() const;
const glm::mat4& GetViewMatrix_Inv() const;
@@ -111,27 +108,17 @@ public:
const SFVEC2F& GetFocalLen() const { return m_focalLen; }
float GetNear() const { return m_frustum.nearD; }
float GetFar() const { return m_frustum.farD; }
const CAMERA_FRUSTUM& GetFrustum() const { return m_frustum; }
const SFVEC3F& GetLookAtPos() const { return m_lookat_pos; }
/**
* Set the rotation matrix to be applied in a transformation camera, without
* making any new calculations on camera.
*
* @param aRotation is the total rotation matrix of the camera.
*/
void SetRotationMatrix( const glm::mat4& aRotation );
void SetBoardLookAtPos( const SFVEC3F& aBoardPos )
{
if( m_board_lookat_pos_init != aBoardPos )
{
m_board_lookat_pos_init = aBoardPos;
SetLookAtPos( aBoardPos );
}
}
/**
* Set the affine matrix to be applied to a transformation camera.
*
* @param aViewMatrix is the affine matrix of the camera. The affine matrix
* maps coordinates in the world frame to those in the
* camera frame.
*/
void SetViewMatrix( glm::mat4 aViewMatrix );
void SetBoardLookAtPos( const SFVEC3F& aBoardPos );
virtual void SetLookAtPos( const SFVEC3F& aLookAtPos ) = 0;
void SetLookAtPos_T1( const SFVEC3F& aLookAtPos )
{
@@ -165,11 +152,6 @@ public:
void ResetXYpos();
void ResetXYpos_T1();
/**
* Get the current mouse position.
*/
const wxPoint& GetCurMousePosition() { return m_lastPosition; }
/**
* Update the current mouse position without make any new calculations on camera.
*/
@@ -268,12 +250,7 @@ public:
* @param aOutOrigin out origin position of the ray.
* @param aOutDirection out direction.
*/
void MakeRayAtCurrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const;
/**
* Update the camera.
*/
void Update() { updateFrustum(); }
void MakeRayAtCurrrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const;
protected:
void zoomChanged();
+42 -122
View File
@@ -27,14 +27,13 @@
* @file c_ogl_3dmodel.cpp
* @brief
*/
#include <algorithm>
#include <stdexcept>
#include <gal/opengl/kiglew.h> // Must be included first
#include "3d_model.h"
#include "opengl_utils.h"
#include "../common_ogl/ogl_utils.h"
#include "../3d_math.h"
#include <utility>
#include <wx/debug.h>
#include <wx/log.h>
#include <chrono>
@@ -150,25 +149,24 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
for( unsigned int mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i )
{
const SMESH& mesh = a3DModel.m_Meshes[mesh_i];
const auto& mesh = a3DModel.m_Meshes[mesh_i];
// silently ignore meshes that have invalid material references or invalid geometry.
if( mesh.m_MaterialIdx >= m_materials.size()
|| mesh.m_Positions == nullptr
|| mesh.m_FaceIdx == nullptr
|| mesh.m_Normals == nullptr
|| mesh.m_FaceIdxSize == 0
|| mesh.m_VertexSize == 0 )
{
continue;
}
|| mesh.m_Positions == nullptr
|| mesh.m_FaceIdx == nullptr
|| mesh.m_Normals == nullptr
|| mesh.m_FaceIdxSize == 0
|| mesh.m_VertexSize == 0 )
continue;
MESH_GROUP& mesh_group = mesh_groups[mesh.m_MaterialIdx];
MATERIAL& material = m_materials[mesh.m_MaterialIdx];
auto& mesh_group = mesh_groups[mesh.m_MaterialIdx];
auto& material = m_materials[mesh.m_MaterialIdx];
if( material.IsTransparent() && m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY )
if( material.IsTransparent()
&& m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY )
m_have_transparent_meshes = true;
else
else
m_have_opaque_meshes = true;
const unsigned int vtx_offset = mesh_group.m_vertices.size();
@@ -178,20 +176,19 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
// use material color for mesh bounding box or some sort of average vertex color.
glm::vec3 avg_color = material.m_Diffuse;
BBOX_3D &mesh_bbox = m_meshes_bbox[mesh_i];
for( unsigned int vtx_i = 0; vtx_i < mesh.m_VertexSize; ++vtx_i )
{
mesh_bbox.Union( mesh.m_Positions[vtx_i] );
m_meshes_bbox[mesh_i].Union( mesh.m_Positions[vtx_i] );
VERTEX& vtx_out = mesh_group.m_vertices[vtx_offset + vtx_i];
auto& vtx_out = mesh_group.m_vertices[vtx_offset + vtx_i];
vtx_out.m_pos = mesh.m_Positions[vtx_i];
vtx_out.m_nrm = glm::clamp( glm::vec4( mesh.m_Normals[vtx_i], 1.0f ) * 127.0f,
-127.0f, 127.0f );
vtx_out.m_tex_uv = mesh.m_Texcoords != nullptr ? mesh.m_Texcoords[vtx_i]
: glm::vec2 (0);
vtx_out.m_tex_uv = mesh.m_Texcoords != nullptr
? mesh.m_Texcoords[vtx_i]
: glm::vec2 (0);
if( mesh.m_Color != nullptr )
{
@@ -225,19 +222,16 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
}
}
if( mesh_bbox.IsInitialized() )
if( m_meshes_bbox[mesh_i].IsInitialized() )
{
// generate geometry for the bounding box
MakeBbox( mesh_bbox, ( mesh_i + 1 ) * bbox_vtx_count,
MakeBbox( m_meshes_bbox[mesh_i], ( mesh_i + 1 ) * bbox_vtx_count,
&bbox_tmp_vertices[( mesh_i + 1 ) * bbox_vtx_count],
&bbox_tmp_indices[( mesh_i + 1 ) * bbox_idx_count],
{ avg_color, 1.0f } );
// bump the outer bounding box
m_model_bbox.Union( mesh_bbox );
// add to the material group
material.m_bbox.Union( mesh_bbox );
m_model_bbox.Union( m_meshes_bbox[mesh_i] );
}
@@ -305,7 +299,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
unsigned int total_vertex_count = 0;
unsigned int total_index_count = 0;
for( const MESH_GROUP& mg : mesh_groups )
for( auto& mg : mesh_groups )
{
total_vertex_count += mg.m_vertices.size();
total_index_count += mg.m_indices.size();
@@ -333,7 +327,8 @@ 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;
@@ -341,22 +336,23 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
for( unsigned int mg_i = 0; mg_i < mesh_groups.size (); ++mg_i )
{
MESH_GROUP& mg = mesh_groups[mg_i];
MATERIAL& mat = m_materials[mg_i];
uintptr_t tmp_idx_ptr = reinterpret_cast<uintptr_t>( tmp_idx.get() );
auto& mg = mesh_groups[mg_i];
auto& mat = m_materials[mg_i];
if( m_index_buffer_type == GL_UNSIGNED_SHORT )
{
GLushort* idx_out = reinterpret_cast<GLushort*>( tmp_idx_ptr + idx_offset );
auto idx_out = reinterpret_cast<GLushort*>(
reinterpret_cast<uintptr_t>( tmp_idx.get() ) + idx_offset );
for( GLuint idx : mg.m_indices )
for( auto idx : mg.m_indices )
*idx_out++ = static_cast<GLushort>( idx + prev_vtx_count );
}
else if( m_index_buffer_type == GL_UNSIGNED_INT )
{
GLuint* idx_out = reinterpret_cast<GLuint*>( tmp_idx_ptr + idx_offset );
auto idx_out = reinterpret_cast<GLuint*>(
reinterpret_cast<uintptr_t>( tmp_idx.get() ) + idx_offset );
for( GLuint idx : mg.m_indices )
for( auto idx : mg.m_indices )
*idx_out++ = static_cast<GLuint>( idx + prev_vtx_count );
}
@@ -416,9 +412,7 @@ void MODEL_3D::EndDrawMulti()
void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMaterial,
const SFVEC3F& aSelectionColor,
const glm::mat4 *aModelWorldMatrix,
const SFVEC3F *aCameraWorldPos ) const
SFVEC3F& aSelectionColor ) const
{
if( aOpacity <= FLT_EPSILON )
return;
@@ -447,102 +441,28 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const float*)&param.x );
std::vector<const MODEL_3D::MATERIAL *> materialsToRender;
materialsToRender.reserve( m_materials.size() );
if( aModelWorldMatrix && aCameraWorldPos )
// BeginDrawMulti();
for( const MODEL_3D::MATERIAL& mat : m_materials )
{
// Sort Material groups
std::vector<std::pair<const MODEL_3D::MATERIAL*, float>> materialsSorted;
// Calculate the distance to the camera for each material group
for( const MODEL_3D::MATERIAL& mat : m_materials )
{
if( mat.m_render_idx_count == 0 )
{
continue;
}
if( ( mat.IsTransparent() != aTransparent )
if( ( mat.IsTransparent() != aTransparent )
&& ( aOpacity >= 1.0f )
&& m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY )
{
continue;
}
const BBOX_3D& bBox = mat.m_bbox;
const SFVEC3F& bBoxCenter = bBox.GetCenter();
const SFVEC3F bBoxWorld = *aModelWorldMatrix * glm::vec4( bBoxCenter, 1.0f );
const float distanceToCamera = glm::length( *aCameraWorldPos - bBoxWorld );
materialsSorted.emplace_back( &mat, distanceToCamera );
}
// 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 ) {
// If A is inside B, then A is rendered first
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;
}
}
return a.second > b.second;
} );
for( const std::pair<const MODEL_3D::MATERIAL*, float>& mat : materialsSorted )
{
materialsToRender.push_back( mat.first );
continue;
}
}
else
{
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.
if( mat.m_render_idx_count == 0 )
{
continue;
}
if( ( mat.IsTransparent() != aTransparent )
&& ( aOpacity >= 1.0f )
&& m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY )
{
continue;
}
materialsToRender.push_back( &mat );
}
}
for( const MODEL_3D::MATERIAL* mat : materialsToRender )
{
switch( m_materialMode )
{
case MATERIAL_MODE::NORMAL:
OglSetMaterial( *mat, aOpacity, aUseSelectedMaterial, aSelectionColor );
OglSetMaterial( mat, aOpacity, aUseSelectedMaterial, aSelectionColor );
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:
OglSetDiffuseMaterial( MaterialDiffuseToColorCAD( mat->m_Diffuse ), aOpacity,
OglSetDiffuseMaterial( MaterialDiffuseToColorCAD( mat.m_Diffuse ), aOpacity,
aUseSelectedMaterial, aSelectionColor );
break;
@@ -550,9 +470,9 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
break;
}
glDrawElements( GL_TRIANGLES, mat->m_render_idx_count, m_index_buffer_type,
glDrawElements( GL_TRIANGLES, mat.m_render_idx_count, m_index_buffer_type,
reinterpret_cast<const void*>(
static_cast<uintptr_t>( mat->m_render_idx_buffer_offset ) ) );
static_cast<uintptr_t>( mat.m_render_idx_buffer_offset ) ) );
}
}
+5 -14
View File
@@ -54,7 +54,7 @@ public:
*/
void DrawOpaque( bool aUseSelectedMaterial, SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
{
Draw( false, 1.0f, aUseSelectedMaterial, aSelectionColor, nullptr, nullptr );
Draw( false, 1.0f, aUseSelectedMaterial, aSelectionColor );
}
/**
@@ -63,19 +63,9 @@ public:
void DrawTransparent( float aOpacity, bool aUseSelectedMaterial,
SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
{
Draw( true, aOpacity, aUseSelectedMaterial, aSelectionColor, nullptr, nullptr );
Draw( true, aOpacity, aUseSelectedMaterial, aSelectionColor );
}
/**
* Render the model into the current context.
* if aModelWorldMatrix and aCameraWorldPos is provided,
* it renders the material groups sorted.
*/
void Draw( bool aTransparent, float aOpacity, bool aUseSelectedMaterial,
const SFVEC3F& aSelectionColor,
const glm::mat4 *aModelWorldMatrix,
const SFVEC3F *aCameraWorldPos ) const;
/**
* Return true if have opaque meshes to render.
*/
@@ -146,8 +136,6 @@ 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
MATERIAL( const SMATERIAL& aOther ) : SMATERIAL( aOther ) { }
bool IsTransparent() const { return m_Transparency > FLT_EPSILON; }
};
@@ -171,6 +159,9 @@ private:
static void MakeBbox( const BBOX_3D& aBox, unsigned int aIdxOffset, VERTEX* aVtxOut,
GLuint* aIdxOut, const glm::vec4& aColor );
void Draw( bool aTransparent, float aOpacity, bool aUseSelectedMaterial,
SFVEC3F& aSelectionColor ) const;
};
#endif // _MODEL_3D_H_
+75 -144
View File
@@ -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 (C) 2015-2022 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
@@ -27,11 +27,9 @@
#include <board.h>
#include <footprint.h>
#include "../../3d_math.h"
#include "convert_basic_shapes_to_polygon.h"
#include <trigo.h>
#include <project.h>
#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>
@@ -376,37 +374,23 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D*
}
OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateEmptyLayerList( PCB_LAYER_ID aLayerId )
{
float layer_z_bot = 0.0f;
float layer_z_top = 0.0f;
getLayerZPos( aLayerId, layer_z_top, layer_z_bot );
TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( 1 );
// store in a list so it will be latter deleted
m_triangles.push_back( layerTriangles );
return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top );
}
OPENGL_RENDER_LIST* RENDER_3D_OPENGL::createBoard( const SHAPE_POLY_SET& aBoardPoly,
const BVH_CONTAINER_2D* aThroughHoles )
{
OPENGL_RENDER_LIST* dispLists = nullptr;
CONTAINER_2D boardContainer;
SHAPE_POLY_SET brd_outlines = aBoardPoly;
ConvertPolygonToTriangles( aBoardPoly, boardContainer, m_boardAdapter.BiuTo3dUnits(),
ConvertPolygonToTriangles( brd_outlines, boardContainer, m_boardAdapter.BiuTo3dUnits(),
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
const LIST_OBJECT2D& listBoardObject2d = boardContainer.GetList();
if( listBoardObject2d.size() > 0 )
{
// We will set a unitary Z so it will in future used with transformations since the
// board poly will be used not only to draw itself but also the solder mask layers.
// We will set a unitary Z so it will in future used with transformations
// since the board poly will be used not only to draw itself but also the
// solder mask layers.
const float layer_z_top = 1.0f;
const float layer_z_bot = 0.0f;
@@ -467,7 +451,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
// Create Board
m_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetThroughHoleIds() );
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_antiBoardPolys.RemoveAllContours();
m_antiBoardPolys.NewOutline();
@@ -482,7 +466,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
m_antiBoard = createBoard( m_antiBoardPolys );
}
SHAPE_POLY_SET board_poly_with_holes = m_boardAdapter.GetBoardPoly().CloneDropTriangulation();
SHAPE_POLY_SET board_poly_with_holes = m_boardAdapter.GetBoardPoly();
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
SHAPE_POLY_SET::PM_FAST );
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
@@ -497,13 +481,11 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( aStatusReporter )
aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetThroughHoleOdPolys().CloneDropTriangulation();
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetThroughHoleOdPolys();
if( m_boardAdapter.m_Cfg->m_Render.realistic )
{
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
outerPolyTHT.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
}
m_outerThroughHoles = generateHoles( m_boardAdapter.GetThroughHoleOds().GetList(),
outerPolyTHT, 1.0f, 0.0f, false,
@@ -513,8 +495,8 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
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 )
if( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) &&
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_outerThroughHoleRings = generateHoles(
m_boardAdapter.GetThroughHoleAnnularRings().GetList(),
@@ -533,7 +515,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
float layer_z_bot = 0.0f;
float layer_z_top = 0.0f;
for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : outerMapHoles )
for( const auto ii : outerMapHoles )
{
const PCB_LAYER_ID layer_id = ii.first;
const SHAPE_POLY_SET* poly = ii.second;
@@ -545,7 +527,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
layer_z_top, layer_z_bot, false );
}
for( const std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& ii : innerMapHoles )
for( const auto ii : innerMapHoles )
{
const PCB_LAYER_ID layer_id = ii.first;
const SHAPE_POLY_SET* poly = ii.second;
@@ -567,7 +549,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& ii : m_boardAdapter.GetLayerMap() )
for( const auto ii : m_boardAdapter.GetLayerMap() )
{
const PCB_LAYER_ID layer_id = ii.first;
@@ -575,15 +557,13 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
continue;
if( aStatusReporter )
{
aStatusReporter->Report( wxString::Format( _( "Load OpenGL layer %d" ),
(int) layer_id ) );
}
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;
SHAPE_POLY_SET* aPolyList = nullptr;
// Load the vertical (Z axis) component of shapes
@@ -591,20 +571,21 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
{
polyListSubtracted = *map_poly.at( layer_id );;
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_FAST );
if( layer_id != B_Mask && layer_id != F_Mask )
if( ( layer_id != B_Mask ) && ( layer_id != F_Mask ) )
{
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
SHAPE_POLY_SET::PM_FAST );
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
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( m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) )
{
if( layer_id == B_SilkS && map_poly.find( B_Mask ) != map_poly.end() )
{
@@ -619,10 +600,10 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
}
}
polyList = &polyListSubtracted;
aPolyList = &polyListSubtracted;
}
OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, polyList, layer_id,
OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, aPolyList, layer_id,
&m_boardAdapter.GetThroughHoleIds() );
if( oglList != nullptr )
@@ -630,15 +611,12 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
}
if( m_boardAdapter.m_Cfg->m_Render.renderPlatedPadsAsPlated
&& m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
const SHAPE_POLY_SET* frontPlatedPadPolys = m_boardAdapter.GetFrontPlatedPadPolys();
const SHAPE_POLY_SET* backPlatedPadPolys = m_boardAdapter.GetBackPlatedPadPolys();
if( frontPlatedPadPolys )
if( m_boardAdapter.GetFrontPlatedPadPolys() )
{
SHAPE_POLY_SET polySubtracted = frontPlatedPadPolys->CloneDropTriangulation();
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetFrontPlatedPadPolys();
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_FAST );
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
@@ -648,15 +626,11 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
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( backPlatedPadPolys )
if( m_boardAdapter.GetBackPlatedPadPolys() )
{
SHAPE_POLY_SET polySubtracted = backPlatedPadPolys->CloneDropTriangulation();
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetBackPlatedPadPolys();
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_FAST );
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
@@ -666,10 +640,6 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
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 )
m_layers[B_Cu] = generateEmptyLayerList( B_Cu );
}
}
@@ -682,7 +652,8 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( aStatusReporter )
{
// Calculation time in seconds
double calculation_time = (double)( GetRunningMicroSecs() - stats_startReloadTime) / 1e6;
const double calculation_time = (double)( GetRunningMicroSecs() -
stats_startReloadTime) / 1e6;
aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
}
@@ -703,10 +674,10 @@ void RENDER_3D_OPENGL::addTopAndBottomTriangles( TRIANGLE_DISPLAY_LIST* aDst, co
}
void RENDER_3D_OPENGL::getLayerZPos( PCB_LAYER_ID aLayer, float& aOutZtop, float& aOutZbot ) const
void RENDER_3D_OPENGL::getLayerZPos( PCB_LAYER_ID aLayerID, float& aOutZtop, float& aOutZbot ) const
{
aOutZbot = m_boardAdapter.GetLayerBottomZPos( aLayer );
aOutZtop = m_boardAdapter.GetLayerTopZPos( aLayer );
aOutZbot = m_boardAdapter.GetLayerBottomZPos( aLayerID );
aOutZtop = m_boardAdapter.GetLayerTopZPos( aLayerID );
if( aOutZtop < aOutZbot )
{
@@ -761,11 +732,13 @@ void RENDER_3D_OPENGL::generateViasAndPads()
if( m_boardAdapter.GetViaCount() > 0 )
{
float averageDiameter = m_boardAdapter.GetAverageViaHoleDiameter();
unsigned int averageSegCount = m_boardAdapter.GetCircleSegmentCount( averageDiameter );
unsigned int trianglesEstimate = averageSegCount * 8 * m_boardAdapter.GetViaCount();
const unsigned int reserve_nr_triangles_estimation =
m_boardAdapter.GetCircleSegmentCount(
m_boardAdapter.GetAverageViaHoleDiameter() ) * 8 *
m_boardAdapter.GetViaCount();
TRIANGLE_DISPLAY_LIST* layerTriangleVIA = new TRIANGLE_DISPLAY_LIST( trianglesEstimate );
TRIANGLE_DISPLAY_LIST* layerTriangleVIA =
new TRIANGLE_DISPLAY_LIST( reserve_nr_triangles_estimation );
// Insert plated vertical holes inside the board
@@ -776,9 +749,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;
@@ -808,33 +778,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() )
{
@@ -842,16 +793,17 @@ void RENDER_3D_OPENGL::generateViasAndPads()
{
if( pad->GetAttribute() != PAD_ATTRIB::NPTH )
{
const VECTOR2I drillsize = pad->GetDrillSize();
const bool hasHole = drillsize.x && drillsize.y;
const wxSize drillsize = pad->GetDrillSize();
const bool hasHole = drillsize.x && drillsize.y;
if( !hasHole )
continue;
pad->TransformHoleToPolygon( tht_outer_holes_poly, platingThickness,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleToPolygon( tht_inner_holes_poly, 0, ARC_HIGH_DEF,
ERROR_INSIDE );
pad->TransformHoleWithClearanceToPolygon( tht_outer_holes_poly,
platingThickness,
ARC_HIGH_DEF, ERROR_INSIDE );
pad->TransformHoleWithClearanceToPolygon( tht_inner_holes_poly, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
}
@@ -859,27 +811,29 @@ void RENDER_3D_OPENGL::generateViasAndPads()
// Subtract the holes
tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
tht_outer_holes_poly.BooleanSubtract( m_antiBoardPolys, SHAPE_POLY_SET::PM_FAST );
CONTAINER_2D holesContainer;
ConvertPolygonToTriangles( tht_outer_holes_poly, holesContainer,
m_boardAdapter.BiuTo3dUnits(), *m_boardAdapter.GetBoard() );
m_boardAdapter.BiuTo3dUnits(),
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
const LIST_OBJECT2D& holes2D = holesContainer.GetList();
const LIST_OBJECT2D& listHolesObject2d = holesContainer.GetList();
if( holes2D.size() > 0 )
if( listHolesObject2d.size() > 0 )
{
float layer_z_top, layer_z_bot, dummy;
getLayerZPos( F_Cu, layer_z_top, dummy );
getLayerZPos( B_Cu, dummy, layer_z_bot );
TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( holes2D.size() );
TRIANGLE_DISPLAY_LIST* layerTriangles =
new TRIANGLE_DISPLAY_LIST( listHolesObject2d.size() );
// Convert the list of objects(triangles) to triangle layer structure
for( const OBJECT_2D* itemOnLayer : holes2D )
for( const OBJECT_2D* itemOnLayer : listHolesObject2d )
{
const OBJECT_2D* object2d_A = itemOnLayer;
@@ -926,9 +880,7 @@ void RENDER_3D_OPENGL::Load3dModelsIfNeeded()
load3dModels( &activityReporter );
}
else
{
load3dModels( nullptr );
}
}
@@ -937,10 +889,9 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
if( !m_boardAdapter.GetBoard() )
return;
if( !m_boardAdapter.m_IsPreviewer
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_normal
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_insert
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_virtual )
if( !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL )
&& !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL_INSERT )
&& !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_VIRTUAL ) )
{
return;
}
@@ -948,55 +899,35 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
// Go for all footprints
for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
{
wxString libraryName = footprint->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString;
if( m_boardAdapter.GetBoard()->GetProject() )
for( const FP_3DMODEL& model : footprint->Models() )
{
try
{
// FindRow() can throw an exception
const FP_LIB_TABLE_ROW* fpRow =
m_boardAdapter.GetBoard()->GetProject()->PcbFootprintLibs()->FindRow(
libraryName, false );
if( fpRow )
footprintBasePath = fpRow->GetFullURI( true );
}
catch( ... )
{
// Do nothing if the libraryName is not found in lib table
}
}
for( const FP_3DMODEL& fp_model : footprint->Models() )
{
if( fp_model.m_Show && !fp_model.m_Filename.empty() )
if( model.m_Show && !model.m_Filename.empty() )
{
if( aStatusReporter )
{
// Display the short filename of the 3D fp_model loaded:
// Display the short filename of the 3D model loaded:
// (the full name is usually too long to be displayed)
wxFileName fn( fp_model.m_Filename );
wxFileName fn( model.m_Filename );
aStatusReporter->Report( wxString::Format( _( "Loading %s..." ),
fn.GetFullName() ) );
}
// Check if the fp_model is not present in our cache map
// Check if the model is not present in our cache map
// (Not already loaded in memory)
if( m_3dModelMap.find( fp_model.m_Filename ) == m_3dModelMap.end() )
if( m_3dModelMap.find( model.m_Filename ) == m_3dModelMap.end() )
{
// It is not present, try get it from cache
const S3DMODEL* modelPtr =
m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename, footprintBasePath );
m_boardAdapter.Get3dCacheManager()->GetModel( model.m_Filename );
// only add it if the return is not NULL
if( modelPtr )
{
MATERIAL_MODE materialMode = m_boardAdapter.m_Cfg->m_Render.material_mode;
MODEL_3D* model = new MODEL_3D( *modelPtr, materialMode );
MATERIAL_MODE materialMode = m_boardAdapter.GetMaterialMode();
MODEL_3D* ogl_model = new MODEL_3D( *modelPtr, materialMode );
m_3dModelMap[ fp_model.m_Filename ] = model;
if( ogl_model )
m_3dModelMap[ model.m_Filename ] = ogl_model;
}
}
}
@@ -650,7 +650,6 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
glDrawArrays( GL_TRIANGLES, 0, aTriangleContainer->GetVertexSize() );
glBindTexture( GL_TEXTURE_2D, 0 );
glDisable( GL_TEXTURE_2D );
glDisable( GL_ALPHA_TEST );
glDisable( GL_BLEND );
@@ -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 (C) 1992-2022 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
@@ -144,14 +144,14 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
if( aNrSidesPerCircle > 1 )
{
const float radius = 0.5f;
const EDA_ANGLE delta = ANGLE_360 / aNrSidesPerCircle;
const int delta = 3600 / aNrSidesPerCircle;
// Generate bottom
glNormal3f( 0.0f, 0.0f,-1.0f );
glBegin( GL_TRIANGLE_FAN );
glVertex3f( 0.0, 0.0, 0.0 ); // This is the V0 of the FAN
for( EDA_ANGLE ii = ANGLE_0; ii < ANGLE_180; ii += delta )
for( int ii = 0; ii < 1800; ii += delta )
{
SFVEC2D corner = SFVEC2D( 0.0, radius );
RotatePoint( &corner.x, &corner.y, ii );
@@ -166,7 +166,7 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
glBegin( GL_TRIANGLE_FAN );
glVertex3f( 0.0, 0.0, 1.0 ); // This is the V0 of the FAN
for( EDA_ANGLE ii = ANGLE_180; ii > ANGLE_0; ii -= delta )
for( int ii = 1800; ii > 0; ii -= delta )
{
SFVEC2D corner = SFVEC2D( 0.0, radius );
@@ -180,7 +180,7 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
// Generate contours
glBegin( GL_QUAD_STRIP );
for( EDA_ANGLE ii = ANGLE_180; ii > ANGLE_0; ii -= delta )
for( int ii = 1800; ii > 0; ii -= delta )
{
SFVEC2D corner = SFVEC2D( 0.0, radius );
+189 -349
View File
@@ -22,19 +22,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cstdint>
#include <gal/opengl/kiglew.h> // Must be included first
#include "plugins/3dapi/xv3d_types.h"
#include "render_3d_opengl.h"
#include "opengl_utils.h"
#include "common_ogl/ogl_utils.h"
#include <footprint.h>
#include <3d_math.h>
#include <glm/geometric.hpp>
#include <math/util.h> // for KiROUND
#include <utility>
#include <vector>
#include <wx/log.h>
#include <base_units.h>
@@ -42,7 +37,7 @@
/**
* Scale conversion from 3d model units to pcb units
*/
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
#define UNITS3D_TO_UNITSPCB (IU_PER_MM)
RENDER_3D_OPENGL::RENDER_3D_OPENGL( EDA_3D_CANVAS* aCanvas, BOARD_ADAPTER& aAdapter,
CAMERA& aCamera ) :
@@ -174,7 +169,7 @@ void RENDER_3D_OPENGL::setupMaterials()
{
m_materials = {};
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
// http://devernay.free.fr/cours/opengl/materials.html
@@ -333,7 +328,7 @@ void RENDER_3D_OPENGL::setLayerMaterial( PCB_LAYER_ID aLayerID )
// Convert Opacity to Transparency
m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a;
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_materials.m_SolderMask.m_Ambient = m_materials.m_SolderMask.m_Diffuse * 0.3f;
@@ -400,7 +395,7 @@ SFVEC4F RENDER_3D_OPENGL::getLayerColor( PCB_LAYER_ID aLayerID )
{
SFVEC4F layerColor = m_boardAdapter.GetLayerColor( aLayerID );
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
switch( aLayerID )
{
@@ -509,7 +504,7 @@ void RENDER_3D_OPENGL::setCopperMaterial()
void RENDER_3D_OPENGL::setPlatedCopperAndDepthOffset( PCB_LAYER_ID aLayer_id )
{
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( -0.1f, -2.0f );
glPolygonOffset(-0.1f, -2.0f );
setLayerMaterial( aLayer_id );
}
@@ -538,8 +533,8 @@ void RENDER_3D_OPENGL::renderBoardBody( bool aSkipRenderHoles )
if( ogl_disp_list )
{
ogl_disp_list->ApplyScalePosition( -m_boardAdapter.GetBoardBodyThickness() / 2.0f,
m_boardAdapter.GetBoardBodyThickness() );
ogl_disp_list->ApplyScalePosition( -m_boardAdapter.GetEpoxyThickness() / 2.0f,
m_boardAdapter.GetEpoxyThickness() );
ogl_disp_list->SetItIsTransparent( true );
@@ -568,16 +563,16 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
reload( aStatusReporter, aWarningReporter );
// generate a new 3D grid as the size of the board may had changed
m_lastGridType = static_cast<GRID3D_TYPE>( m_boardAdapter.m_Cfg->m_Render.grid_type );
m_lastGridType = m_boardAdapter.GetGridType();
generate3dGrid( m_lastGridType );
}
else
{
// Check if grid was changed
if( m_boardAdapter.m_Cfg->m_Render.grid_type != m_lastGridType )
if( m_boardAdapter.GetGridType() != m_lastGridType )
{
// and generate a new one
m_lastGridType = static_cast<GRID3D_TYPE>( m_boardAdapter.m_Cfg->m_Render.grid_type );
m_lastGridType = m_boardAdapter.GetGridType();
generate3dGrid( m_lastGridType );
}
}
@@ -591,7 +586,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glEnable( GL_NORMALIZE ); // This allow OpenGL to normalize the normals after transformations
glViewport( 0, 0, m_windowSize.x, m_windowSize.y );
if( aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_AA_disableOnMove )
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE ) && aIsMoving )
glDisable( GL_MULTISAMPLE );
else
glEnable( GL_MULTISAMPLE );
@@ -632,9 +627,13 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
float zpos;
if( cameraPos.z > 0.0f )
{
zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
}
else
{
zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
}
// This is a point light.
const GLfloat headlight_pos[] = { cameraPos.x, cameraPos.y, zpos, 1.0f };
@@ -642,13 +641,16 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
}
bool skipThickness = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_thickness_disableOnMove;
bool skipRenderHoles = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_holes_disableOnMove;
bool skipRenderVias = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_vias_disableOnMove;
const bool drawMiddleSegments = !( aIsMoving &&
m_boardAdapter.GetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE ) );
bool drawMiddleSegments = !skipThickness;
const bool skipRenderHoles = aIsMoving &&
m_boardAdapter.GetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE );
if( m_boardAdapter.m_Cfg->m_Render.realistic )
const bool skipRenderVias = aIsMoving &&
m_boardAdapter.GetFlag( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE );
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
// Draw vias and pad holes with copper material
setLayerMaterial( B_Cu );
@@ -678,8 +680,8 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// So avoid creating them is they are not very visible
const double opacity_min = 0.8;
if( m_boardAdapter.m_Cfg->m_Render.show_board_body
&& m_boardAdapter.m_BoardBodyColor.a > opacity_min )
if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) &&
( m_boardAdapter.m_BoardBodyColor.a > opacity_min ) )
{
if( ( layer_id > F_Cu ) && ( layer_id < B_Cu ) )
continue;
@@ -691,30 +693,29 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( ( layer_id >= F_Cu ) && ( layer_id <= B_Cu ) )
{
if( m_boardAdapter.m_Cfg->m_Render.renderPlatedPadsAsPlated
&& m_boardAdapter.m_Cfg->m_Render.realistic )
{
setCopperMaterial();
}
else
{
if( !m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ||
!( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) )
setLayerMaterial( layer_id );
}
else
setCopperMaterial();
if( skipRenderHoles )
{
pLayerDispList->DrawAllCameraCulled( m_camera.GetPos().z, drawMiddleSegments );
// Draw plated pads
// Draw copper plated pads
if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
( m_platedPadsFront || m_platedPadsBack ) )
setPlatedCopperAndDepthOffset( layer_id );
if( layer_id == F_Cu && m_platedPadsFront )
{
setPlatedCopperAndDepthOffset( layer_id );
m_platedPadsFront->DrawAllCameraCulled( m_camera.GetPos().z,
drawMiddleSegments );
}
else if( layer_id == B_Cu && m_platedPadsBack )
{
setPlatedCopperAndDepthOffset( layer_id );
m_platedPadsBack->DrawAllCameraCulled( m_camera.GetPos().z,
drawMiddleSegments );
}
@@ -750,10 +751,16 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
viasHolesLayer,
m_antiBoard );
// Draw plated pads
if( layer_id == F_Cu && m_platedPadsFront )
// Draw copper plated pads
if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
( m_platedPadsFront || m_platedPadsBack ) )
{
setPlatedCopperAndDepthOffset( layer_id );
}
if( layer_id == F_Cu && m_platedPadsFront )
{
m_platedPadsFront->DrawAllCameraCulledSubtractLayer(
drawMiddleSegments,
m_outerThroughHoles,
@@ -762,7 +769,6 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
}
else if( layer_id == B_Cu && m_platedPadsBack )
{
setPlatedCopperAndDepthOffset( layer_id );
m_platedPadsBack->DrawAllCameraCulledSubtractLayer(
drawMiddleSegments,
m_outerThroughHoles,
@@ -779,16 +785,21 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
m_outerThroughHoles,
m_antiBoard );
if( layer_id == F_Cu && m_platedPadsFront )
// Draw copper plated pads
if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
( m_platedPadsFront || m_platedPadsBack ) )
{
setPlatedCopperAndDepthOffset( layer_id );
}
if( layer_id == F_Cu && m_platedPadsFront )
{
m_platedPadsFront->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_outerThroughHoles,
m_antiBoard );
}
else if( layer_id == B_Cu && m_platedPadsBack )
{
setPlatedCopperAndDepthOffset( layer_id );
m_platedPadsBack->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_outerThroughHoles,
m_antiBoard );
@@ -802,45 +813,34 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
{
setLayerMaterial( layer_id );
OPENGL_RENDER_LIST* throughHolesOuter = m_outerThroughHoles;
if( m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annulus
&& m_boardAdapter.m_Cfg->m_Render.realistic
&& ( layer_id == B_SilkS || layer_id == F_SilkS ) )
{
throughHolesOuter = m_outerThroughHoleRings;
}
OPENGL_RENDER_LIST* throughHolesOuter =
m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE )
&& ( layer_id == B_SilkS || layer_id == F_SilkS )
? m_outerThroughHoleRings
: m_outerThroughHoles;
if( throughHolesOuter )
{
throughHolesOuter->ApplyScalePosition( pLayerDispList->GetZBot(),
pLayerDispList->GetZTop()
- pLayerDispList->GetZBot() );
throughHolesOuter->ApplyScalePosition(
pLayerDispList->GetZBot(),
pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
}
OPENGL_RENDER_LIST* anti_board = m_antiBoard;
if( anti_board )
{
anti_board->ApplyScalePosition( pLayerDispList->GetZBot(),
pLayerDispList->GetZTop()
- pLayerDispList->GetZBot() );
anti_board->ApplyScalePosition(
pLayerDispList->GetZBot(),
pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
}
if( skipRenderHoles )
{
// Do not render Paste layers when skipRenderHoles is enabled
// otherwise it will cause z-fight issues
if( layer_id != B_Paste && layer_id != F_Paste )
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
anti_board );
}
}
else if( m_boardAdapter.m_Cfg->m_Render.subtract_mask_from_silk
&& m_boardAdapter.m_Cfg->m_Render.realistic
&& ( ( layer_id == B_SilkS && m_layers.find( B_Mask ) != m_layers.end() )
|| ( layer_id == F_SilkS && m_layers.find( F_Mask ) != m_layers.end() ) ) )
if( !skipRenderHoles
&& m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE )
&& ( ( layer_id == B_SilkS && m_layers.find( B_Mask ) != m_layers.end() )
|| ( layer_id == F_SilkS && m_layers.find( F_Mask ) != m_layers.end() ) ) )
{
const PCB_LAYER_ID layerMask_id = (layer_id == B_SilkS) ? B_Mask : F_Mask;
@@ -850,35 +850,43 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
pLayerDispListMask,
throughHolesOuter, anti_board );
}
else if( throughHolesOuter )
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, nullptr,
throughHolesOuter,
anti_board );
}
else
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
anti_board );
if( !skipRenderHoles && throughHolesOuter
&& ( layer_id == B_SilkS || layer_id == F_SilkS ) )
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, nullptr,
throughHolesOuter,
anti_board );
}
else
{
// Do not render Paste layers when skipRenderHoles is enabled
// otherwise it will cause z-fight issues
if( !( skipRenderHoles && ( layer_id == B_Paste || layer_id == F_Paste ) ) )
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
anti_board );
}
}
}
}
glPopMatrix();
}
glm::mat4 cameraViewMatrix;
glGetFloatv( GL_MODELVIEW_MATRIX, glm::value_ptr( cameraViewMatrix ) );
// Render 3D Models (Non-transparent)
renderOpaqueModels( cameraViewMatrix );
render3dModels( false, false );
render3dModels( true, false );
// Display board body
if( m_boardAdapter.m_Cfg->m_Render.show_board_body )
if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) )
{
renderBoardBody( skipRenderHoles );
}
// Display transparent mask layers
if( m_boardAdapter.m_Cfg->m_Render.show_soldermask )
if( m_boardAdapter.GetFlag( FL_SOLDERMASK ) )
{
// add a depth buffer offset, it will help to hide some artifacts
// on silkscreen where the SolderMask is removed
@@ -916,7 +924,6 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// Enables Texture Env so it can combine model transparency with each footprint opacity
glEnable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, m_circleTexture ); // Uses an existent texture so the glTexEnv operations will work
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
@@ -931,9 +938,10 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_CONSTANT );
renderTransparentModels( cameraViewMatrix );
render3dModels( false, true );
render3dModels( true, true );
glDisable( GL_BLEND );
OglResetTextureState();
@@ -941,7 +949,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glDepthMask( GL_TRUE );
// Render Grid
if( m_boardAdapter.m_Cfg->m_Render.grid_type != GRID3D_TYPE::NONE )
if( m_boardAdapter.GetGridType() != GRID3D_TYPE::NONE )
{
glDisable( GL_LIGHTING );
@@ -952,7 +960,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
}
// Render 3D arrows
if( m_boardAdapter.m_Cfg->m_Render.show_axis )
if( m_boardAdapter.GetFlag( FL_AXIS ) )
render3dArrows();
// Return back to the original viewport (this is important if we want
@@ -1046,29 +1054,41 @@ void RENDER_3D_OPENGL::freeAllLists()
delete m_platedPadsBack;
m_platedPadsBack = nullptr;
for( const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry : m_outerLayerHoles )
delete entry.second;
for( MAP_OGL_DISP_LISTS::const_iterator ii = m_outerLayerHoles.begin();
ii != m_outerLayerHoles.end();
++ii )
{
OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
delete pLayerDispList;
}
m_outerLayerHoles.clear();
for( const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry : m_innerLayerHoles )
delete entry.second;
for( MAP_OGL_DISP_LISTS::const_iterator ii = m_innerLayerHoles.begin();
ii != m_innerLayerHoles.end();
++ii )
{
OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
delete pLayerDispList;
}
m_innerLayerHoles.clear();
for( LIST_TRIANGLES::const_iterator ii = m_triangles.begin(); ii != m_triangles.end(); ++ii )
{
delete *ii;
}
m_triangles.clear();
for( const std::pair<const wxString, MODEL_3D*>& entry : m_3dModelMap )
delete entry.second;
for( MAP_3DMODEL::const_iterator ii = m_3dModelMap.begin(); ii != m_3dModelMap.end(); ++ii )
{
MODEL_3D* pointer = static_cast<MODEL_3D*>(ii->second);
delete pointer;
}
m_3dModelMap.clear();
m_3dModelMatrixMap.clear();
delete m_board;
m_board = nullptr;
@@ -1153,30 +1173,26 @@ void RENDER_3D_OPENGL::renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPos
}
void RENDER_3D_OPENGL::get3dModelsSelected( std::list<MODELTORENDER> &aDstRenderList,
bool aGetTop, bool aGetBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly )
void RENDER_3D_OPENGL::render3dModelsSelected( bool aRenderTopOrBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly )
{
wxASSERT( ( aGetTop == true ) || ( aGetBot == true ) );
if( !m_boardAdapter.GetBoard() )
return;
MODEL_3D::BeginDrawMulti( !aRenderSelectedOnly );
// Go for all footprints
for( FOOTPRINT* fp : m_boardAdapter.GetBoard()->Footprints() )
{
bool highlight = false;
if( m_boardAdapter.m_IsBoardView )
if( m_boardAdapter.GetFlag( FL_USE_SELECTION ) )
{
if( fp->IsSelected() )
highlight = true;
if( m_boardAdapter.m_Cfg->m_Render.opengl_highlight_on_rollover
&& fp == m_currentRollOverItem )
{
if( m_boardAdapter.GetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM ) && fp == m_currentRollOverItem )
highlight = true;
}
if( aRenderSelectedOnly != highlight )
continue;
@@ -1186,52 +1202,52 @@ void RENDER_3D_OPENGL::get3dModelsSelected( std::list<MODELTORENDER> &aDstRender
{
if( m_boardAdapter.IsFootprintShown( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
{
const bool isFlipped = fp->IsFlipped();
if( ( aGetTop == !isFlipped ) ||
( aGetBot == isFlipped ) )
get3dModelsFromFootprint( aDstRenderList, fp, aRenderTransparentOnly, highlight );
if( aRenderTopOrBot == !fp->IsFlipped() )
renderFootprint( fp, aRenderTransparentOnly, highlight );
}
}
}
MODEL_3D::EndDrawMulti();
}
void RENDER_3D_OPENGL::get3dModelsFromFootprint( std::list<MODELTORENDER> &aDstRenderList,
const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
bool aIsSelected )
void RENDER_3D_OPENGL::render3dModels( bool aRenderTopOrBot, bool aRenderTransparentOnly )
{
if( m_boardAdapter.GetFlag( FL_USE_SELECTION ) )
render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, true );
render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, false );
}
void RENDER_3D_OPENGL::renderFootprint( const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
bool aIsSelected )
{
if( !aFootprint->Models().empty() )
{
const double zpos = m_boardAdapter.GetFootprintZPos( aFootprint->IsFlipped() );
VECTOR2I pos = aFootprint->GetPosition();
glPushMatrix();
glm::mat4 fpMatrix( 1.0f );
wxPoint pos = aFootprint->GetPosition();
fpMatrix = glm::translate( fpMatrix,
SFVEC3F( pos.x * m_boardAdapter.BiuTo3dUnits(),
-pos.y * m_boardAdapter.BiuTo3dUnits(),
zpos ) );
glTranslatef( pos.x * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(),
zpos );
if( !aFootprint->GetOrientation().IsZero() )
{
fpMatrix = glm::rotate( fpMatrix,
(float) aFootprint->GetOrientation().AsRadians(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
}
if( aFootprint->GetOrientation() )
glRotated( (double) aFootprint->GetOrientation() / 10.0, 0.0, 0.0, 1.0 );
if( aFootprint->IsFlipped() )
{
fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(), SFVEC3F( 0.0f, 1.0f, 0.0f ) );
fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(), SFVEC3F( 0.0f, 0.0f, 1.0f ) );
glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
}
const double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3dUnits() *
UNITS3D_TO_UNITSPCB;
double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3dUnits() * UNITS3D_TO_UNITSPCB;
fpMatrix = glm::scale( fpMatrix,
SFVEC3F( modelunit_to_3d_units_factor ) );
glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor,
modelunit_to_3d_units_factor );
// Get the list of model files for this model
for( const FP_3DMODEL& sM : aFootprint->Models() )
@@ -1252,232 +1268,56 @@ void RENDER_3D_OPENGL::get3dModelsFromFootprint( std::list<MODELTORENDER> &aDstR
if( ( !aRenderTransparentOnly && modelPtr->HasOpaqueMeshes() && opaque ) ||
( aRenderTransparentOnly && ( modelPtr->HasTransparentMeshes() || !opaque ) ) )
{
glm::mat4 modelworldMatrix = fpMatrix;
glPushMatrix();
const SFVEC3F offset = SFVEC3F( sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z );
const SFVEC3F rotation = SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y, sM.m_Rotation.z );
const SFVEC3F scale = SFVEC3F( sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z );
std::vector<float> key = { offset.x, offset.y, offset.z,
rotation.x, rotation.y, rotation.z,
scale.x, scale.y, scale.z };
auto it = m_3dModelMatrixMap.find( key );
if( it != m_3dModelMatrixMap.end() )
{
modelworldMatrix *= it->second;
}
else
{
glm::mat4 mtx( 1.0f );
mtx = glm::translate( mtx, offset );
mtx = glm::rotate( mtx, glm::radians( -rotation.z ), { 0.0f, 0.0f, 1.0f } );
mtx = glm::rotate( mtx, glm::radians( -rotation.y ), { 0.0f, 1.0f, 0.0f } );
mtx = glm::rotate( mtx, glm::radians( -rotation.x ), { 1.0f, 0.0f, 0.0f } );
mtx = glm::scale( mtx, scale );
m_3dModelMatrixMap[ key ] = mtx;
modelworldMatrix *= mtx;
}
// FIXME: don't do this over and over again unless the
// values have changed. cache the matrix somewhere.
glm::mat4 mtx( 1 );
mtx = glm::translate( mtx, { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z } );
mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.z ),
{ 0.0f, 0.0f, 1.0f } );
mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.y ),
{ 0.0f, 1.0f, 0.0f } );
mtx = glm::rotate( mtx, glm::radians( (float) -sM.m_Rotation.x ),
{ 1.0f, 0.0f, 0.0f } );
mtx = glm::scale( mtx, { sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z } );
glMultMatrixf( glm::value_ptr( mtx ) );
if( aRenderTransparentOnly )
{
aDstRenderList.emplace_back( modelworldMatrix,
modelPtr,
sM.m_Opacity,
true,
aFootprint->IsSelected() || aIsSelected );
modelPtr->DrawTransparent( sM.m_Opacity,
aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_OpenGlSelectionColor );
}
else
{
aDstRenderList.emplace_back( modelworldMatrix,
modelPtr,
1.0f,
false,
aFootprint->IsSelected() || aIsSelected );
modelPtr->DrawOpaque( aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_OpenGlSelectionColor );
}
}
}
}
}
}
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) )
{
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
void RENDER_3D_OPENGL::renderOpaqueModels( const glm::mat4 &aCameraViewMatrix )
{
const SFVEC3F selColor = m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.opengl_selection_color );
glDisable( GL_LIGHTING );
glPushMatrix();
glLineWidth( 1 );
modelPtr->DrawBboxes();
std::list<MODELTORENDER> renderList;
glLineWidth( 4 );
modelPtr->DrawBbox();
if( m_boardAdapter.m_IsBoardView )
{
renderList.clear();
glEnable( GL_LIGHTING );
glDisable( GL_BLEND );
}
get3dModelsSelected( renderList, true, true, false, true );
if( !renderList.empty() )
{
MODEL_3D::BeginDrawMulti( false );
for( const MODELTORENDER& mtr : renderList )
{
renderModel( aCameraViewMatrix, mtr, selColor, nullptr );
}
MODEL_3D::EndDrawMulti();
}
}
renderList.clear();
get3dModelsSelected( renderList, true, true, false, false );
if( !renderList.empty() )
{
MODEL_3D::BeginDrawMulti( true );
for( const MODELTORENDER& mtr : renderList )
{
renderModel( aCameraViewMatrix, mtr, selColor, nullptr );
}
MODEL_3D::EndDrawMulti();
}
glPopMatrix();
}
void RENDER_3D_OPENGL::renderTransparentModels( const glm::mat4 &aCameraViewMatrix )
{
const SFVEC3F selColor = m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.opengl_selection_color );
std::list<MODELTORENDER> renderListModels; // do not clear it until this function returns
if( m_boardAdapter.m_IsBoardView )
{
// Get Transparent Selected
get3dModelsSelected( renderListModels, true, true, true, true );
}
// Get Transparent Not Selected
get3dModelsSelected( renderListModels, true, true, true, false );
if( renderListModels.empty() )
return;
std::vector<std::pair<const MODELTORENDER *, float>> transparentModelList;
transparentModelList.reserve( renderListModels.size() );
// Calculate the distance to the camera for each model
const SFVEC3F &cameraPos = m_camera.GetPos();
for( const MODELTORENDER& mtr : renderListModels )
{
const BBOX_3D& bBox = mtr.m_model->GetBBox();
const SFVEC3F& bBoxCenter = bBox.GetCenter();
const SFVEC3F bBoxWorld = mtr.m_modelWorldMat * glm::vec4( bBoxCenter, 1.0f );
const float distanceToCamera = glm::length( cameraPos - bBoxWorld );
transparentModelList.emplace_back( &mtr, distanceToCamera );
}
// Sort from back to front
std::sort( transparentModelList.begin(), transparentModelList.end(),
[&]( std::pair<const MODELTORENDER *, float>& a,
std::pair<const MODELTORENDER *, float>& b ) {
return a.second > b.second;
} );
// Start rendering calls
glPushMatrix();
bool isUsingColorInformation = !( transparentModelList.begin()->first->m_isSelected &&
m_boardAdapter.m_IsBoardView );
MODEL_3D::BeginDrawMulti( isUsingColorInformation );
for( const std::pair<const MODELTORENDER *, float>& mtr : transparentModelList )
{
if( m_boardAdapter.m_IsBoardView )
{
// Toggle between using model color or the select color
if( !isUsingColorInformation && !mtr.first->m_isSelected )
{
isUsingColorInformation = true;
glEnableClientState( GL_COLOR_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnable( GL_COLOR_MATERIAL );
}
else
{
if( isUsingColorInformation && mtr.first->m_isSelected )
{
isUsingColorInformation = false;
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisable( GL_COLOR_MATERIAL );
glPopMatrix();
}
}
}
// Render model, sort each individuall material group
// by passing cameraPos
renderModel( aCameraViewMatrix, *mtr.first, selColor, &cameraPos );
}
MODEL_3D::EndDrawMulti();
glPopMatrix();
}
void RENDER_3D_OPENGL::renderModel( const glm::mat4 &aCameraViewMatrix,
const MODELTORENDER &aModelToRender,
const SFVEC3F &aSelColor,
const SFVEC3F *aCameraWorldPos )
{
const glm::mat4 modelviewMatrix = aCameraViewMatrix * aModelToRender.m_modelWorldMat;
glLoadMatrixf( glm::value_ptr( modelviewMatrix ) );
aModelToRender.m_model->Draw( aModelToRender.m_isTransparent,
aModelToRender.m_opacity,
aModelToRender.m_isSelected,
aSelColor,
&aModelToRender.m_modelWorldMat,
aCameraWorldPos );
if( m_boardAdapter.m_Cfg->m_Render.opengl_show_model_bbox )
{
const bool wasBlendEnabled = glIsEnabled( GL_BLEND );
if( !wasBlendEnabled )
{
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
glDisable( GL_LIGHTING );
glLineWidth( 1 );
aModelToRender.m_model->DrawBboxes();
glLineWidth( 4 );
aModelToRender.m_model->DrawBbox();
glEnable( GL_LIGHTING );
if( !wasBlendEnabled )
{
glDisable( GL_BLEND );
}
glPopMatrix();
}
}
@@ -1535,21 +1375,21 @@ void RENDER_3D_OPENGL::generate3dGrid( GRID3D_TYPE aGridType )
glNormal3f( 0.0, 0.0, 1.0 );
const VECTOR2I brd_size = m_boardAdapter.GetBoardSize();
VECTOR2I brd_center_pos = m_boardAdapter.GetBoardPos();
const wxSize brd_size = m_boardAdapter.GetBoardSize();
wxPoint brd_center_pos = m_boardAdapter.GetBoardPos();
brd_center_pos.y = -brd_center_pos.y;
const int xsize = std::max( brd_size.x, pcbIUScale.mmToIU( 100 ) ) * 1.2;
const int ysize = std::max( brd_size.y, pcbIUScale.mmToIU( 100 ) ) * 1.2;
const int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
const int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
// Grid limits, in 3D units
double xmin = ( brd_center_pos.x - xsize / 2 ) * scale;
double xmax = ( brd_center_pos.x + xsize / 2 ) * scale;
double ymin = ( brd_center_pos.y - ysize / 2 ) * scale;
double ymax = ( brd_center_pos.y + ysize / 2 ) * scale;
double zmin = pcbIUScale.mmToIU( -50 ) * scale;
double zmax = pcbIUScale.mmToIU( 100 ) * scale;
double zmin = Millimeter2iu( -50 ) * scale;
double zmax = Millimeter2iu( 100 ) * scale;
// Set rasterised line width (min value = 1)
glLineWidth( 1 );
@@ -1563,7 +1403,7 @@ void RENDER_3D_OPENGL::generate3dGrid( GRID3D_TYPE aGridType )
glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
transparency );
const int delta = KiROUND( ii * griSizeMM * pcbIUScale.IU_PER_MM );
const int delta = KiROUND( ii * griSizeMM * IU_PER_MM );
if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
{
@@ -1615,7 +1455,7 @@ void RENDER_3D_OPENGL::generate3dGrid( GRID3D_TYPE aGridType )
glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
transparency );
const double delta = ii * griSizeMM * pcbIUScale.IU_PER_MM;
const double delta = ii * griSizeMM * IU_PER_MM;
glBegin( GL_LINES );
xmax = ( brd_center_pos.x + delta ) * scale;
@@ -1645,7 +1485,7 @@ void RENDER_3D_OPENGL::generate3dGrid( GRID3D_TYPE aGridType )
else
glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
const double delta = ii * griSizeMM * pcbIUScale.IU_PER_MM * scale;
const double delta = ii * griSizeMM * IU_PER_MM * scale;
if( delta <= zmax )
{
@@ -41,8 +41,10 @@
#include <map>
typedef std::map< PCB_LAYER_ID, OPENGL_RENDER_LIST* > MAP_OGL_DISP_LISTS;
typedef std::list<TRIANGLE_DISPLAY_LIST* > LIST_TRIANGLES;
typedef std::map< wxString, MODEL_3D* > MAP_3DMODEL;
#define SIZE_OF_CIRCLE_TEXTURE 1024
@@ -82,8 +84,6 @@ private:
PCB_LAYER_ID aLayerId,
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
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 );
@@ -129,44 +129,18 @@ private:
*/
void load3dModels( REPORTER* aStatusReporter );
struct MODELTORENDER
{
glm::mat4 m_modelWorldMat;
const MODEL_3D* m_model;
float m_opacity;
bool m_isTransparent;
bool m_isSelected;
/**
* @param aRenderTopOrBot true will render Top, false will render bottom
* @param aRenderTransparentOnly true will render only the transparent objects, false will
* render opaque
*/
void render3dModels( bool aRenderTopOrBot, bool aRenderTransparentOnly );
MODELTORENDER( glm::mat4 aModelWorldMat,
const MODEL_3D* aNodel,
float aOpacity,
bool aIsTransparent,
bool aIsSelected ) :
m_modelWorldMat( std::move( aModelWorldMat ) ),
m_model( aNodel ),
m_opacity( aOpacity ),
m_isTransparent( aIsTransparent ),
m_isSelected( aIsSelected )
{
}
};
void render3dModelsSelected( bool aRenderTopOrBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly );
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 get3dModelsSelected( std::list<MODELTORENDER> &aDstRenderList,
bool aGetTop, bool aGetBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly );
void get3dModelsFromFootprint( std::list<MODELTORENDER> &aDstRenderList,
const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
bool aIsSelected );
void renderFootprint( const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
bool aIsSelected );
void setLightFront( bool enabled );
void setLightTop( bool enabled );
@@ -234,9 +208,7 @@ private:
OPENGL_RENDER_LIST* m_vias;
OPENGL_RENDER_LIST* m_padHoles;
// Caches
std::map< wxString, MODEL_3D* > m_3dModelMap;
std::map< std::vector<float>, glm::mat4 > m_3dModelMatrixMap;
MAP_3DMODEL m_3dModelMap;
BOARD_ITEM* m_currentRollOverItem;
@@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2022 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* 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
@@ -39,8 +39,6 @@
#include <board.h>
#include <footprint.h>
#include <fp_lib_table.h>
#include <eda_3d_viewer_frame.h>
#include <base_units.h>
#include <profile.h> // To use GetRunningMicroSecs or another profiling utility
@@ -67,28 +65,35 @@ static float TransparencyControl( float aGrayColorValue, float aTransparency )
/**
* Scale conversion from 3d model units to pcb units
*/
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
#define UNITS3D_TO_UNITSPCB ( IU_PER_MM )
void RENDER_3D_RAYTRACE::setupMaterials()
{
MATERIAL::SetDefaultRefractionRayCount( m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_refractions );
MATERIAL::SetDefaultReflectionRayCount( m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_reflections );
MATERIAL::SetDefaultRefractionRayCount( m_boardAdapter.m_RtRefractionSampleCount );
MATERIAL::SetDefaultReflectionRayCount( m_boardAdapter.m_RtReflectionSampleCount );
MATERIAL::SetDefaultRefractionRecursionCount( m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_refractions );
MATERIAL::SetDefaultReflectionRecursionCount( m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_reflections );
MATERIAL::SetDefaultRefractionRecursionCount( m_boardAdapter.m_RtRecursiveRefractionCount );
MATERIAL::SetDefaultReflectionRecursionCount( m_boardAdapter.m_RtRecursiveReflectionCount );
double mmTo3Dunits = pcbIUScale.IU_PER_MM * m_boardAdapter.BiuTo3dUnits();
double mmTo3Dunits = IU_PER_MM * m_boardAdapter.BiuTo3dUnits();
if( m_boardAdapter.m_Cfg->m_Render.raytrace_procedural_textures )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
{
m_boardMaterial = BOARD_NORMAL( 0.40f * mmTo3Dunits );
m_copperMaterial = COPPER_NORMAL( 4.0f * mmTo3Dunits, &m_boardMaterial );
m_platedCopperMaterial = PLATED_COPPER_NORMAL( 0.5f * mmTo3Dunits );
m_solderMaskMaterial = SOLDER_MASK_NORMAL( &m_boardMaterial );
m_plasticMaterial = PLASTIC_NORMAL( 0.05f * mmTo3Dunits );
m_shinyPlasticMaterial = PLASTIC_SHINE_NORMAL( 0.1f * mmTo3Dunits );
m_brushedMetalMaterial = BRUSHED_METAL_NORMAL( 0.05f * mmTo3Dunits );
m_silkScreenMaterial = SILK_SCREEN_NORMAL( 0.25f * mmTo3Dunits );
}
@@ -102,14 +107,14 @@ void RENDER_3D_RAYTRACE::setupMaterials()
ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_CopperColor * 0.3f ),
SFVEC3F( 0.0f ), copperSpecularLinear, 0.4f * 128.0f, 0.0f, 0.0f );
if( m_boardAdapter.m_Cfg->m_Render.raytrace_procedural_textures )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_Copper.SetGenerator( &m_platedCopperMaterial );
m_materials.m_NonPlatedCopper = BLINN_PHONG_MATERIAL(
ConvertSRGBToLinear( SFVEC3F( 0.191f, 0.073f, 0.022f ) ), SFVEC3F( 0.0f, 0.0f, 0.0f ),
SFVEC3F( 0.256f, 0.137f, 0.086f ), 0.15f * 128.0f, 0.0f, 0.0f );
if( m_boardAdapter.m_Cfg->m_Render.raytrace_procedural_textures )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_NonPlatedCopper.SetGenerator( &m_copperMaterial );
m_materials.m_Paste = BLINN_PHONG_MATERIAL(
@@ -127,7 +132,7 @@ void RENDER_3D_RAYTRACE::setupMaterials()
(SFVEC3F) m_boardAdapter.m_SilkScreenColorTop ) ),
SFVEC3F( 0.0f ), SFVEC3F( 0.10f ) ), 0.078125f * 128.0f, 0.0f, 0.0f );
if( m_boardAdapter.m_Cfg->m_Render.raytrace_procedural_textures )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_SilkS.SetGenerator( &m_silkScreenMaterial );
// Assume that SolderMaskTop == SolderMaskBot
@@ -148,7 +153,7 @@ void RENDER_3D_RAYTRACE::setupMaterials()
m_materials.m_SolderMask.SetCastShadows( true );
m_materials.m_SolderMask.SetRefractionRayCount( 1 );
if( m_boardAdapter.m_Cfg->m_Render.raytrace_procedural_textures )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_SolderMask.SetGenerator( &m_solderMaskMaterial );
m_materials.m_EpoxyBoard =
@@ -161,7 +166,7 @@ void RENDER_3D_RAYTRACE::setupMaterials()
m_materials.m_EpoxyBoard.SetAbsorvance( 10.0f );
if( m_boardAdapter.m_Cfg->m_Render.raytrace_procedural_textures )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_EpoxyBoard.SetGenerator( &m_boardMaterial );
SFVEC3F bgTop = ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_BgColorTop );
@@ -273,11 +278,11 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
// layer and the flag is set, then clip the silk at the outer edge of the annular ring,
// rather than the at the outer edge of the copper plating.
const BVH_CONTAINER_2D& throughHoleOuter =
m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annulus
&& m_boardAdapter.m_Cfg->m_Render.realistic
&& ( aLayer_id == B_SilkS || aLayer_id == F_SilkS ) ?
m_boardAdapter.GetThroughHoleAnnularRings() :
m_boardAdapter.GetThroughHoleOds();
( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE )
&& ( ( aLayer_id == B_SilkS ) || ( aLayer_id == F_SilkS ) ) ) ?
m_boardAdapter.GetThroughHoleAnnularRings() :
m_boardAdapter.GetThroughHoleOds();
if( !throughHoleOuter.GetList().empty() )
{
@@ -303,8 +308,8 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
const MAP_CONTAINER_2D_BASE& mapLayers = m_boardAdapter.GetLayerMap();
if( m_boardAdapter.m_Cfg->m_Render.subtract_mask_from_silk
&& m_boardAdapter.m_Cfg->m_Render.realistic
if( m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE )
&& ( ( aLayer_id == B_SilkS && mapLayers.find( B_Mask ) != mapLayers.end() )
|| ( aLayer_id == F_SilkS && mapLayers.find( F_Mask ) != mapLayers.end() ) ) )
{
@@ -434,7 +439,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
*m_boardAdapter.GetBoard(), ii );
}
if( m_boardAdapter.m_Cfg->m_Render.show_board_body )
if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) )
{
const LIST_OBJECT2D& listObjects = m_outlineBoard2dObjects->GetList();
@@ -558,9 +563,9 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
aStatusReporter->Report( _( "Load Raytracing: layers" ) );
// Add layers maps (except B_Mask and F_Mask)
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() )
for( auto entry : m_boardAdapter.GetLayerMap() )
{
const PCB_LAYER_ID layer_id = entry.first;
PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second;
// Only process layers that exist
@@ -587,7 +592,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
case F_Paste:
materialLayer = &m_materials.m_Paste;
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
layerColor = m_boardAdapter.m_SolderPasteColor;
else
layerColor = m_boardAdapter.GetLayerColor( layer_id );
@@ -597,7 +602,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
case B_SilkS:
materialLayer = &m_materials.m_SilkS;
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
layerColor = m_boardAdapter.m_SilkScreenColorBot;
else
layerColor = m_boardAdapter.GetLayerColor( layer_id );
@@ -607,7 +612,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
case F_SilkS:
materialLayer = &m_materials.m_SilkS;
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
layerColor = m_boardAdapter.m_SilkScreenColorTop;
else
layerColor = m_boardAdapter.GetLayerColor( layer_id );
@@ -631,24 +636,19 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
break;
default:
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
if( m_boardAdapter.m_Cfg->m_Render.renderPlatedPadsAsPlated )
{
if( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) )
layerColor = SFVEC3F( 184.0f / 255.0f, 115.0f / 255.0f, 50.0f / 255.0f );
materialLayer = &m_materials.m_NonPlatedCopper;
}
else
{
layerColor = m_boardAdapter.m_CopperColor;
materialLayer = &m_materials.m_Copper;
}
}
else
{
layerColor = m_boardAdapter.GetLayerColor( layer_id );
}
materialLayer = &m_materials.m_NonPlatedCopper;
break;
}
@@ -656,16 +656,16 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
} // for each layer on map
// Create plated copper
if( m_boardAdapter.m_Cfg->m_Render.renderPlatedPadsAsPlated
&& m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
createItemsFromContainer( m_boardAdapter.GetPlatedPadsFront(), F_Cu, &m_materials.m_Copper,
m_boardAdapter.m_CopperColor,
m_boardAdapter.GetFrontCopperThickness() * 0.1f );
m_boardAdapter.GetCopperThickness() * 0.1f );
createItemsFromContainer( m_boardAdapter.GetPlatedPadsBack(), B_Cu, &m_materials.m_Copper,
m_boardAdapter.m_CopperColor,
-m_boardAdapter.GetBackCopperThickness() * 0.1f );
-m_boardAdapter.GetCopperThickness() * 0.1f );
}
if( !aOnlyLoadCopperAndShapes )
@@ -674,14 +674,13 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
// Solder mask layers are "negative" layers so the elements that we have in the container
// should remove the board outline. We will check for all objects in the outline if it
// intersects any object in the layer container and also any hole.
if( m_boardAdapter.m_Cfg->m_Render.show_soldermask
&& !m_outlineBoard2dObjects->GetList().empty() )
if( m_boardAdapter.GetFlag( FL_SOLDERMASK ) && !m_outlineBoard2dObjects->GetList().empty() )
{
const MATERIAL* materialLayer = &m_materials.m_SolderMask;
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() )
for( auto entry : m_boardAdapter.GetLayerMap() )
{
const PCB_LAYER_ID layer_id = entry.first;
PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second;
// Only process layers that exist
@@ -694,7 +693,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
SFVEC3F layerColor;
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
if( layer_id == B_Mask )
layerColor = m_boardAdapter.m_SolderMaskColorBot;
@@ -799,7 +798,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
if( !aOnlyLoadCopperAndShapes )
{
// Add floor
if( m_boardAdapter.m_Cfg->m_Render.raytrace_backfloor )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) )
{
BBOX_3D boardBBox = m_boardAdapter.GetBBox();
@@ -879,47 +878,41 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
&& ( aSource.b < ( 1.0f / 255.0f ) ) );
};
SFVEC3F cameraLightColor =
m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.raytrace_lightColorCamera );
SFVEC3F topLightColor =
m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.raytrace_lightColorTop );
SFVEC3F bottomLightColor =
m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.raytrace_lightColorBottom );
m_cameraLight = new DIRECTIONAL_LIGHT( SFVEC3F( 0.0f, 0.0f, 0.0f ), cameraLightColor );
m_cameraLight = new DIRECTIONAL_LIGHT( SFVEC3F( 0.0f, 0.0f, 0.0f ),
m_boardAdapter.m_RtCameraLightColor );
m_cameraLight->SetCastShadows( false );
if( !IsColorZero( cameraLightColor ) )
if( !IsColorZero( m_boardAdapter.m_RtCameraLightColor ) )
m_lights.push_back( m_cameraLight );
const SFVEC3F& boardCenter = m_boardAdapter.GetBBox().GetCenter();
if( !IsColorZero( topLightColor ) )
if( !IsColorZero( m_boardAdapter.m_RtLightColorTop ) )
{
m_lights.push_back( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
+RANGE_SCALE_3D * 2.0f ),
topLightColor ) );
m_boardAdapter.m_RtLightColorTop ) );
}
if( !IsColorZero( bottomLightColor ) )
if( !IsColorZero( m_boardAdapter.m_RtLightColorBottom ) )
{
m_lights.push_back( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
-RANGE_SCALE_3D * 2.0f ),
bottomLightColor ) );
m_boardAdapter.m_RtLightColorBottom ) );
}
for( size_t i = 0; i < m_boardAdapter.m_Cfg->m_Render.raytrace_lightColor.size(); ++i )
{
SFVEC3F lightColor =
m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.raytrace_lightColor[i] );
wxASSERT( m_boardAdapter.m_RtLightColor.size()
== m_boardAdapter.m_RtLightSphericalCoords.size() );
if( !IsColorZero( lightColor ) )
for( size_t i = 0; i < m_boardAdapter.m_RtLightColor.size(); ++i )
{
if( !IsColorZero( m_boardAdapter.m_RtLightColor[i] ) )
{
const SFVEC2F sc = m_boardAdapter.GetSphericalCoord( i );
const SFVEC2F sc = m_boardAdapter.m_RtLightSphericalCoords[i];
m_lights.push_back( new DIRECTIONAL_LIGHT(
SphericalToCartesian( glm::pi<float>() * sc.x, glm::pi<float>() * sc.y ),
lightColor ) );
m_boardAdapter.m_RtLightColor[i] ) );
}
}
}
@@ -931,33 +924,10 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
{
float ratio =
std::max( 1.0f, m_objectContainer.GetBBox().GetMaxDimension() / RANGE_SCALE_3D );
m_camera.SetMaxZoom( m_camera.GetMaxZoom() * ratio );
float max_zoom = CAMERA::DEFAULT_MAX_ZOOM * ratio;
float min_zoom = static_cast<float>( MIN_DISTANCE_IU * m_boardAdapter.BiuTo3dUnits()
/ -m_camera.GetCameraInitPos().z );
if( min_zoom > max_zoom )
std::swap( min_zoom, max_zoom );
float zoom_ratio = max_zoom / min_zoom;
// Set the minimum number of zoom 'steps' between max and min.
int steps = 3 * 3;
steps -= static_cast<int>( ceil( log( zoom_ratio ) / log( 1.26f ) ) );
steps = std::max( steps, 0 );
// Resize max and min zoom to accomplish the number of steps.
float increased_zoom = pow( 1.26f, steps / 2 );
max_zoom *= increased_zoom;
min_zoom /= increased_zoom;
if( steps & 1 )
min_zoom /= 1.26f;
min_zoom = std::min( min_zoom, 1.0f );
m_camera.SetMaxZoom( max_zoom );
m_camera.SetMinZoom( min_zoom );
m_camera.SetMinZoom( static_cast<float>( MIN_DISTANCE_IU * m_boardAdapter.BiuTo3dUnits()
/ -m_camera.GetCameraInitPos().z ) );
}
// Create an accelerator
@@ -982,10 +952,10 @@ void RENDER_3D_RAYTRACE::insertHole( const PCB_VIA* aVia )
aVia->LayerPair( &top_layer, &bottom_layer );
float topZ = m_boardAdapter.GetLayerBottomZPos( top_layer )
+ m_boardAdapter.GetFrontCopperThickness();
+ m_boardAdapter.GetCopperThickness();
float botZ = m_boardAdapter.GetLayerBottomZPos( bottom_layer )
- m_boardAdapter.GetBackCopperThickness();
- m_boardAdapter.GetCopperThickness();
const SFVEC2F center = SFVEC2F( aVia->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
-aVia->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
@@ -1000,7 +970,7 @@ void RENDER_3D_RAYTRACE::insertHole( const PCB_VIA* aVia )
objPtr->SetMaterial( &m_materials.m_Copper );
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.m_CopperColor ) );
else if( aVia->GetViaType() == VIATYPE::MICROVIA )
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.GetItemColor( LAYER_VIA_MICROVIA ) ) );
@@ -1019,13 +989,13 @@ void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
SFVEC3F objColor;
if( m_boardAdapter.m_Cfg->m_Render.realistic )
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
objColor = m_boardAdapter.m_CopperColor;
else
objColor = m_boardAdapter.GetItemColor( LAYER_PADS_TH );
const VECTOR2I drillsize = aPad->GetDrillSize();
const bool hasHole = drillsize.x && drillsize.y;
const wxSize drillsize = aPad->GetDrillSize();
const bool hasHole = drillsize.x && drillsize.y;
if( !hasHole )
return;
@@ -1033,10 +1003,10 @@ void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
CONST_LIST_OBJECT2D antiOutlineIntersectionList;
const float topZ = m_boardAdapter.GetLayerBottomZPos( F_Cu )
+ m_boardAdapter.GetFrontCopperThickness() * 0.99f;
+ m_boardAdapter.GetCopperThickness() * 0.99f;
const float botZ = m_boardAdapter.GetLayerBottomZPos( B_Cu )
- m_boardAdapter.GetBackCopperThickness() * 0.99f;
- m_boardAdapter.GetCopperThickness() * 0.99f;
if( drillsize.x == drillsize.y ) // usual round hole
{
@@ -1083,7 +1053,7 @@ void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
}
else // Oblong hole
{
VECTOR2I ends_offset;
wxPoint ends_offset;
int width;
if( drillsize.x > drillsize.y ) // Horizontal oval
@@ -1097,10 +1067,10 @@ void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
width = drillsize.x;
}
RotatePoint( ends_offset, aPad->GetOrientation() );
RotatePoint( &ends_offset, aPad->GetOrientation() );
VECTOR2I start = VECTOR2I( aPad->GetPosition() ) + ends_offset;
VECTOR2I end = VECTOR2I( aPad->GetPosition() ) - ends_offset;
wxPoint start = aPad->GetPosition() + ends_offset;
wxPoint end = aPad->GetPosition() - ends_offset;
ROUND_SEGMENT_2D* innerSeg =
new ROUND_SEGMENT_2D( SFVEC2F( start.x * m_boardAdapter.BiuTo3dUnits(),
@@ -1225,10 +1195,9 @@ void RENDER_3D_RAYTRACE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMa
if( !m_boardAdapter.GetBoard() )
return;
if( !m_boardAdapter.m_IsPreviewer
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_normal
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_insert
&& !m_boardAdapter.m_Cfg->m_Render.show_footprints_virtual )
if( !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL )
&& !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL_INSERT )
&& !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_VIRTUAL ) )
{
return;
}
@@ -1241,7 +1210,7 @@ void RENDER_3D_RAYTRACE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMa
{
double zpos = m_boardAdapter.GetFootprintZPos( fp->IsFlipped() );
VECTOR2I pos = fp->GetPosition();
wxPoint pos = fp->GetPosition();
glm::mat4 fpMatrix = glm::mat4( 1.0f );
@@ -1250,10 +1219,11 @@ void RENDER_3D_RAYTRACE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMa
-pos.y * m_boardAdapter.BiuTo3dUnits(),
zpos ) );
if( !fp->GetOrientation().IsZero() )
if( fp->GetOrientation() )
{
fpMatrix = glm::rotate( fpMatrix, (float) fp->GetOrientation().AsRadians(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
fpMatrix = glm::rotate( fpMatrix,
( (float) ( fp->GetOrientation() / 10.0f ) / 180.0f ) * glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
}
if( fp->IsFlipped() )
@@ -1277,35 +1247,13 @@ void RENDER_3D_RAYTRACE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMa
auto sM = fp->Models().begin();
auto eM = fp->Models().end();
wxString libraryName = fp->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString;
if( m_boardAdapter.GetBoard()->GetProject() )
{
try
{
// FindRow() can throw an exception
const FP_LIB_TABLE_ROW* fpRow =
m_boardAdapter.GetBoard()->GetProject()->PcbFootprintLibs()->FindRow(
libraryName, false );
if( fpRow )
footprintBasePath = fpRow->GetFullURI( true );
}
catch( ... )
{
// Do nothing if the libraryName is not found in lib table
}
}
while( sM != eM )
{
if( ( static_cast<float>( sM->m_Opacity ) > FLT_EPSILON )
&& ( sM->m_Show && !sM->m_Filename.empty() ) )
{
// get it from cache
const S3DMODEL* modelPtr =
cacheMgr->GetModel( sM->m_Filename, footprintBasePath );
const S3DMODEL* modelPtr = cacheMgr->GetModel( sM->m_Filename );
// only add it if the return is not NULL.
if( modelPtr )
@@ -1364,7 +1312,7 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE::getModelMaterial( const S3DMODEL* a3DModel
for( unsigned int imat = 0; imat < a3DModel->m_MaterialsSize; ++imat )
{
if( m_boardAdapter.m_Cfg->m_Render.material_mode == MATERIAL_MODE::NORMAL )
if( m_boardAdapter.GetMaterialMode() == MATERIAL_MODE::NORMAL )
{
const SMATERIAL& material = a3DModel->m_Materials[imat];
@@ -1386,7 +1334,7 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE::getModelMaterial( const S3DMODEL* a3DModel
ConvertSRGBToLinear( material.m_Specular ), material.m_Shininess * 180.0f,
material.m_Transparency, reflectionFactor );
if( m_boardAdapter.m_Cfg->m_Render.raytrace_procedural_textures )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
{
// Guess material type and apply a normal perturbator
if( ( RGBtoGray( material.m_Diffuse ) < 0.3f )
@@ -1554,7 +1502,7 @@ void RENDER_3D_RAYTRACE::addModels( CONTAINER_3D& aDstContainer, const S3DMODEL*
const SFVEC3F diffuseColor =
a3DModel->m_Materials[mesh.m_MaterialIdx].m_Diffuse;
if( m_boardAdapter.m_Cfg->m_Render.material_mode == MATERIAL_MODE::CAD_MODE )
if( m_boardAdapter.GetMaterialMode() == MATERIAL_MODE::CAD_MODE )
newTriangle->SetColor( ConvertSRGBToLinear(
MaterialDiffuseToColorCAD( diffuseColor ) ) );
else
@@ -1562,8 +1510,7 @@ void RENDER_3D_RAYTRACE::addModels( CONTAINER_3D& aDstContainer, const S3DMODEL*
}
else
{
if( m_boardAdapter.m_Cfg->m_Render.material_mode == MATERIAL_MODE::CAD_MODE )
{
if( m_boardAdapter.GetMaterialMode() == MATERIAL_MODE::CAD_MODE )
newTriangle->SetColor(
ConvertSRGBToLinear( MaterialDiffuseToColorCAD(
mesh.m_Color[idx0] ) ),
@@ -1571,14 +1518,11 @@ void RENDER_3D_RAYTRACE::addModels( CONTAINER_3D& aDstContainer, const S3DMODEL*
mesh.m_Color[idx1] ) ),
ConvertSRGBToLinear( MaterialDiffuseToColorCAD(
mesh.m_Color[idx2] ) ) );
}
else
{
newTriangle->SetColor(
ConvertSRGBToLinear( mesh.m_Color[idx0] ),
ConvertSRGBToLinear( mesh.m_Color[idx1] ),
ConvertSRGBToLinear( mesh.m_Color[idx2] ) );
}
}
}
}
@@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2022 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
* 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
@@ -223,7 +223,7 @@ SFVEC3F PLATED_COPPER_NORMAL::Generate( const RAY& aRay, const HITINFO& aHitInfo
const float noise1 = ( s_perlinNoise.noise( hitPos.x, hitPos.y ) - 0.5f );
const float noise2 = ( s_perlinNoise.noise( hitPos.y, hitPos.x ) - 0.5f );
return SFVEC3F( noise1, noise2, 0.0f ) * 0.1f;
return SFVEC3F( noise1, noise2, -( noise1 + noise2 ) ) * 0.02f;
}
@@ -293,7 +293,7 @@ void RENDER_3D_RAYTRACE::render( GLubyte* ptrPBO, REPORTER* aStatusReporter )
if( m_cameraLight )
m_cameraLight->SetDirection( -m_camera.GetDir() );
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL )
{
// Set all pixels of PBO transparent (Alpha to 0)
// This way it will draw the full buffer but only shows the updated (
@@ -399,7 +399,7 @@ void RENDER_3D_RAYTRACE::renderTracing( GLubyte* ptrPBO, REPORTER* aStatusReport
// or mark it as finished
if( m_blockRenderProgressCount >= m_blockPositions.size() )
{
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
m_renderState = RT_RENDER_STATE_POST_PROCESS_SHADE;
else
m_renderState = RT_RENDER_STATE_FINISH;
@@ -504,7 +504,7 @@ void RENDER_3D_RAYTRACE::renderAntiAliasPackets( const SFVEC3F* aBgColorY,
const HITINFO_PACKET* aHitPck_AA_X1Y1,
const RAY* aRayPck, SFVEC3F* aOutHitColor )
{
const bool is_testShadow = m_boardAdapter.m_Cfg->m_Render.raytrace_shadows;
const bool is_testShadow = m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS );
for( unsigned int y = 0, i = 0; y < RAYPACKET_DIM; ++y )
{
@@ -652,7 +652,7 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
if( !m_accelerator->Intersect( blockPacket, hitPacket_X0Y0 ) )
{
// If block is empty then set shades and continue
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{
for( unsigned int y = 0; y < RAYPACKET_DIM; ++y )
{
@@ -670,9 +670,10 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
}
// This will set the output color to be displayed
// If post processing is enabled, it will not reflect the final result (as the final
// color will be computed on post processing) but it is used for report progress
const bool isFinalColor = !m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing;
// If post processing is enabled, it will not reflect the final result
// (as the final color will be computed on post processing)
// but it is used for report progress
const bool isFinalColor = !m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING );
for( unsigned int y = 0; y < RAYPACKET_DIM; ++y )
{
@@ -697,9 +698,9 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
// Shade original (0, 0) hits ("paint" the intersected objects)
renderRayPackets( bgColor, blockPacket.m_ray, hitPacket_X0Y0,
m_boardAdapter.m_Cfg->m_Render.raytrace_shadows, hitColor_X0Y0 );
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ), hitColor_X0Y0 );
if( m_boardAdapter.m_Cfg->m_Render.raytrace_anti_aliasing )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) )
{
SFVEC3F hitColor_AA_X1Y1[RAYPACKET_RAYS_PER_PACKET];
@@ -718,13 +719,16 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
const SFVEC3F& outColor = bgColor[y];
for( unsigned int x = 0; x < RAYPACKET_DIM; ++x, ++i )
{
hitColor_AA_X1Y1[i] = outColor;
}
}
}
else
{
renderRayPackets( bgColor, blockPacket_AA_X1Y1.m_ray, hitPacket_AA_X1Y1,
m_boardAdapter.m_Cfg->m_Render.raytrace_shadows, hitColor_AA_X1Y1 );
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ),
hitColor_AA_X1Y1 );
}
SFVEC3F hitColor_AA_X1Y0[RAYPACKET_RAYS_PER_PACKET];
@@ -733,7 +737,8 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
for( unsigned int i = 0; i < RAYPACKET_RAYS_PER_PACKET; ++i )
{
SFVEC3F color_average = ( hitColor_X0Y0[i] + hitColor_AA_X1Y1[i] ) * SFVEC3F( 0.5f );
const SFVEC3F color_average = ( hitColor_X0Y0[i] +
hitColor_AA_X1Y1[i] ) * SFVEC3F( 0.5f );
hitColor_AA_X1Y0[i] = color_average;
hitColor_AA_X0Y1[i] = color_average;
@@ -779,7 +784,7 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
const uint32_t ptrInc = ( m_realBufferSize.x - RAYPACKET_DIM ) * 4;
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{
SFVEC2I bPos;
bPos.y = blockPos.y;
@@ -793,7 +798,6 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
const SFVEC3F& hColor = hitColor_X0Y0[i];
if( hitPacket_X0Y0[i].m_hitresult == true )
{
m_postShaderSsao.SetPixelData( bPos.x, bPos.y,
hitPacket_X0Y0[i].m_HitInfo.m_HitNormal,
hColor,
@@ -801,12 +805,9 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
hitPacket_X0Y0[i].m_HitInfo.m_tHit ),
hitPacket_X0Y0[i].m_HitInfo.m_tHit,
hitPacket_X0Y0[i].m_HitInfo.m_ShadowFactor );
}
else
{
m_postShaderSsao.SetPixelData( bPos.x, bPos.y, SFVEC3F( 0.0f ), hColor,
SFVEC3F( 0.0f ), 0, 1.0f );
}
renderFinalColor( ptr, hColor, false );
@@ -836,12 +837,13 @@ void RENDER_3D_RAYTRACE::renderBlockTracing( GLubyte* ptrPBO, signed int iBlock
void RENDER_3D_RAYTRACE::postProcessShading( GLubyte* /* ptrPBO */, REPORTER* aStatusReporter )
{
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{
if( aStatusReporter )
aStatusReporter->Report( _( "Rendering: Post processing shader" ) );
m_postShaderSsao.SetShadowsEnabled( m_boardAdapter.m_Cfg->m_Render.raytrace_shadows );
m_postShaderSsao.SetShadowsEnabled(
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
std::atomic<size_t> nextBlock( 0 );
std::atomic<size_t> threadsFinished( 0 );
@@ -888,7 +890,7 @@ void RENDER_3D_RAYTRACE::postProcessShading( GLubyte* /* ptrPBO */, REPORTER* aS
void RENDER_3D_RAYTRACE::postProcessBlurFinish( GLubyte* ptrPBO, REPORTER* /* aStatusReporter */ )
{
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{
// Now blurs the shader result and compute the final color
std::atomic<size_t> nextBlock( 0 );
@@ -1558,7 +1560,8 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F diffuseColorObj = aHitInfo.pHitObject->GetDiffuseColor( aHitInfo );
#if USE_EXPERIMENTAL_SOFT_SHADOWS
bool is_aa_enabled = m_boardAdapter.m_Cfg->m_Render.raytrace_anti_aliasing && !m_isPreview;
const bool is_aa_enabled = m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) &&
(!m_isPreview);
#endif
float shadow_att_factor_sum = 0.0f;
@@ -1604,8 +1607,9 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
}
else // Experimental softshadow calculation
{
const unsigned int shadow_number_of_samples =
m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_shadows;
m_boardAdapter.m_RtShadowSampleCount;
const float shadow_inc_factor = 1.0f / (float) ( shadow_number_of_samples );
for( unsigned int i = 0; i < shadow_number_of_samples; ++i )
@@ -1621,7 +1625,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F unifVector = UniformRandomHemisphereDirection();
const SFVEC3F disturbed_vector_to_light =
glm::normalize( vectorToLight + unifVector *
m_boardAdapter.m_Cfg->m_Render.raytrace_spread_shadows );
m_boardAdapter.m_RtSpreadShadows );
rayToLight.Init( hitPoint, disturbed_vector_to_light );
}
@@ -1666,7 +1670,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
{
// Reflections
if( ( objMaterial->GetReflection() > 0.0f )
&& m_boardAdapter.m_Cfg->m_Render.raytrace_reflections
&& m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS )
&& ( aRecursiveLevel < objMaterial->GetReflectionRecursionCount() ) )
{
const unsigned int reflection_number_of_samples =
@@ -1691,7 +1695,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F random_reflectVector =
glm::normalize( reflectVector +
UniformRandomHemisphereDirection() *
m_boardAdapter.m_Cfg->m_Render.raytrace_spread_reflections );
m_boardAdapter.m_RtSpreadReflections );
reflectedRay.Init( hitPoint, random_reflectVector );
}
@@ -1717,7 +1721,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
// Refraction
const float objTransparency = aHitInfo.pHitObject->GetModelTransparency();
if( ( objTransparency > 0.0f ) && m_boardAdapter.m_Cfg->m_Render.raytrace_refractions
if( ( objTransparency > 0.0f ) && m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS )
&& ( aRecursiveLevel < objMaterial->GetRefractionRecursionCount() ) )
{
const float airIndex = 1.000293f;
@@ -1756,7 +1760,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
const SFVEC3F randomizeRefractedVector =
glm::normalize( refractedVector +
UniformRandomHemisphereDirection() *
m_boardAdapter.m_Cfg->m_Render.raytrace_spread_refractions );
m_boardAdapter.m_RtSpreadRefractions );
refractedRay.Init( startPoint, randomizeRefractedVector );
}
@@ -229,16 +229,6 @@ bool BBOX_2D::Inside( const SFVEC2F& aPoint ) const
}
bool BBOX_2D::Inside( const BBOX_2D& aBBox ) const
{
wxASSERT( IsInitialized() );
wxASSERT( aBBox.IsInitialized() );
return Inside( aBBox.Min() ) &&
Inside( aBBox.Max() );
}
float BBOX_2D::Area() const
{
SFVEC2F extent = GetExtent();
@@ -132,14 +132,6 @@ public:
*/
bool Inside( const SFVEC2F& aPoint ) const;
/**
* Check if a bounding box is inside this bounding box.
*
* @param aBBox the bounding box to test if it is inside
* @return true if aBBox is smaller and all points are inside
*/
bool Inside( const BBOX_2D& aBBox ) const;
/**
* Calculate the area of a bounding box.
*
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2022 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
@@ -22,14 +22,19 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file object_2d.cpp
*/
#include "object_2d.h"
#include <wx/log.h>
#include <map>
OBJECT_2D_STATS *OBJECT_2D_STATS::s_instance = nullptr;
OBJECT_2D::OBJECT_2D( OBJECT_2D_TYPE aObjType, const BOARD_ITEM& aBoardItem ) :
m_boardItem( aBoardItem )
OBJECT_2D::OBJECT_2D( OBJECT_2D_TYPE aObjType, const BOARD_ITEM& aBoardItem )
: m_boardItem(aBoardItem)
{
m_obj_type = aObjType;
OBJECT_2D_STATS::Instance().AddOne( aObjType );
@@ -118,19 +118,19 @@ bool TRIANGLE_2D::IsPointInside( const SFVEC2F& aPoint ) const
}
void ConvertPolygonToTriangles( const SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BASE& aDstContainer,
void ConvertPolygonToTriangles( SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3dUnitsScale, const BOARD_ITEM& aBoardItem )
{
VECTOR2I a;
VECTOR2I b;
VECTOR2I c;
const_cast<SHAPE_POLY_SET&>( aPolyList ).CacheTriangulation( false );
aPolyList.CacheTriangulation( false );
const double conver_d = (double)aBiuTo3dUnitsScale;
for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ )
{
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* triPoly = aPolyList.TriangulatedPolygon( j );
auto triPoly = aPolyList.TriangulatedPolygon( j );
for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
{
@@ -64,6 +64,6 @@ private:
};
void ConvertPolygonToTriangles( const SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BASE& aDstContainer,
void ConvertPolygonToTriangles( SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3dUnitsScale, const BOARD_ITEM& aBoardItem );
#endif // _TRIANGLE_2D_H_
@@ -238,16 +238,6 @@ bool BBOX_3D::Inside( const SFVEC3F& aPoint ) const
}
bool BBOX_3D::Inside( const BBOX_3D& aBBox ) const
{
wxASSERT( IsInitialized() );
wxASSERT( aBBox.IsInitialized() );
return Inside( aBBox.Min() ) &&
Inside( aBBox.Max() );
}
float BBOX_3D::Volume() const
{
wxASSERT( IsInitialized() );
@@ -264,6 +254,47 @@ SFVEC3F BBOX_3D::Offset( const SFVEC3F& p ) const
}
/// @todo Why are we keeping both implementations of Intersect()?
// Intersection code based on the book:
// "Physical Based Ray Tracing" (by Matt Pharr and Greg Humphrey)
// https://github.com/mmp/pbrt-v2/blob/master/src/core/geometry.cpp#L68
#if 0
bool BBOX_3D::Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) const
{
float t0 = 0.0f;
float t1 = FLT_MAX;
for( unsigned int i = 0; i < 3; ++i )
{
// Update interval for _i_th bounding box slab
float tNear = ( m_min[i] - aRay.m_Origin[i] ) * aRay.m_InvDir[i];
float tFar = ( m_max[i] - aRay.m_Origin[i] ) * aRay.m_InvDir[i];
// Update parametric interval from slab intersection
if( tNear > tFar )
{
// Swap
float ftemp = tNear;
tNear = tFar;
tFar = ftemp;
}
t0 = tNear > t0 ? tNear : t0;
t1 = tFar < t1 ? tFar : t1;
if( t0 > t1 )
return false;
}
if( aOutHitt0 )
*aOutHitt0 = t0;
if( aOutHitt1 )
*aOutHitt1 = t1;
return true;
}
#else
// https://github.com/mmp/pbrt-v2/blob/master/src/accelerators/bvh.cpp#L126
bool BBOX_3D::Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) const
{
@@ -301,6 +332,7 @@ bool BBOX_3D::Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) c
return true;
}
#endif
void BBOX_3D::ApplyTransformation( glm::mat4 aTransformMatrix )
@@ -317,3 +349,22 @@ void BBOX_3D::ApplyTransformation( glm::mat4 aTransformMatrix )
}
void BBOX_3D::ApplyTransformationAA( glm::mat4 aTransformMatrix )
{
wxASSERT( IsInitialized() );
// apply the transformation matrix for each of vertices of the bounding box
// and make a union with all vertices
BBOX_3D tmpBBox = BBOX_3D(
SFVEC3F( aTransformMatrix * glm::vec4( m_min.x, m_min.y, m_min.z, 1.0f ) ) );
tmpBBox.Union( SFVEC3F( aTransformMatrix * glm::vec4( m_max.x, m_min.y, m_min.z, 1.0f ) ) );
tmpBBox.Union( SFVEC3F( aTransformMatrix * glm::vec4( m_min.x, m_max.y, m_min.z, 1.0f ) ) );
tmpBBox.Union( SFVEC3F( aTransformMatrix * glm::vec4( m_min.x, m_min.y, m_max.z, 1.0f ) ) );
tmpBBox.Union( SFVEC3F( aTransformMatrix * glm::vec4( m_min.x, m_max.y, m_max.z, 1.0f ) ) );
tmpBBox.Union( SFVEC3F( aTransformMatrix * glm::vec4( m_max.x, m_max.y, m_min.z, 1.0f ) ) );
tmpBBox.Union( SFVEC3F( aTransformMatrix * glm::vec4( m_max.x, m_min.y, m_max.z, 1.0f ) ) );
tmpBBox.Union( SFVEC3F( aTransformMatrix * glm::vec4( m_max.x, m_max.y, m_max.z, 1.0f ) ) );
m_min = tmpBBox.m_min;
m_max = tmpBBox.m_max;
}
@@ -125,14 +125,6 @@ public:
*/
bool Inside( const SFVEC3F& aPoint ) const;
/**
* Check if a bounding box is inside this bounding box.
*
* @param aBBox the bounding box to test if it is inside
* @return true if aBBox is smaller and all points are inside
*/
bool Inside( const BBOX_3D& aBBox ) const;
/**
* Apply a transformation matrix to the box points.
*
@@ -140,6 +132,14 @@ public:
*/
void ApplyTransformation( glm::mat4 aTransformMatrix );
/**
* Apply a transformation matrix to the box points and recalculate it
* to fit an axis aligned bounding box.
*
* @param aTransformMatrix matrix to apply to the points of the bounding box.
*/
void ApplyTransformationAA( glm::mat4 aTransformMatrix );
/**
* Calculate the volume of a bounding box.
*
@@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2022 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* 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
@@ -25,10 +25,6 @@
#include "layer_item_3d.h"
#include "3d_fastmath.h"
#include <wx/debug.h>
#include <advanced_config.h>
extern float g_BevelThickness3DU;
LAYER_ITEM::LAYER_ITEM( const OBJECT_2D* aObject2D, float aZMin, float aZMax ) :
@@ -227,53 +223,18 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
{
aHitInfo.m_tHit = t;
aHitInfo.m_HitPoint = hitPoint;
aHitInfo.pHitObject = this;
const float zNormalDir = hit_top?1.0f:hit_bot?-1.0f:0.0f;
if( ( outNormal.x == 0.0f ) && ( outNormal.y == 0.0f ) )
{
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, zNormalDir );
aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
}
else
{
// Calculate smooth bevel normal
float zBend = 0.0f;
if( hit_top || hit_bot )
{
float zDistanceToTopOrBot;
// Calculate the distance from hitpoint z to the Max/Min z of the layer
if( hit_top )
{
zDistanceToTopOrBot = ( m_bbox.Max().z - hitPoint.z );
}
else
{
zDistanceToTopOrBot = ( hitPoint.z - m_bbox.Min().z );
}
// For items that are > than g_BevelThickness3DU
// (eg on board vias / plated holeS) use a factor based on m_bbox.GetExtent().z
const float bevelThickness = glm::max( g_BevelThickness3DU,
m_bbox.GetExtent().z *
(float)ADVANCED_CFG::GetCfg().m_3DRT_BevelExtentFactor );
if( ( zDistanceToTopOrBot > 0.0f ) && ( zDistanceToTopOrBot < bevelThickness ) )
{
// Invert and Normalize the distance 0..1
zBend = ( bevelThickness - zDistanceToTopOrBot ) / bevelThickness;
}
}
const SFVEC3F normalLateral = SFVEC3F( outNormal.x, outNormal.y, 0.0f );
const SFVEC3F normalTopBot = SFVEC3F( 0.0f, 0.0f, zNormalDir );
// Interpolate between the regular lateral normal and the top/bot normal
aHitInfo.m_HitNormal = glm::mix( normalLateral, normalTopBot, zBend );
aHitInfo.m_HitNormal = SFVEC3F( outNormal.x, outNormal.y, 0.0f );
}
aHitInfo.pHitObject = this;
m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
return true;
+1 -1
View File
@@ -98,7 +98,7 @@ protected:
*/
std::unique_ptr<BUSY_INDICATOR> CreateBusyIndicator() const;
///< the canvas to display the scene
///< the canvas to disply the scene
EDA_3D_CANVAS* m_canvas;
///< Settings reference in use for this render.
+48 -22
View File
@@ -33,23 +33,22 @@
#include "../3d_math.h"
#include <wx/log.h>
#include <glm/gtc/quaternion.hpp>
// stdlib
#include <algorithm>
TRACK_BALL::TRACK_BALL( float aInitialDistance ) :
CAMERA( aInitialDistance )
{
wxLogTrace( m_logTrace, wxT( "TRACK_BALL::TRACK_BALL" ) );
memset( m_quat, 0, sizeof( m_quat ) );
memset( m_quat_t0, 0, sizeof( m_quat_t0 ) );
memset( m_quat_t1, 0, sizeof( m_quat_t1 ) );
trackball( m_quat, 0.0, 0.0, 0.0, 0.0 );
trackball( m_quat_t0, 0.0, 0.0, 0.0, 0.0 );
trackball( m_quat_t1, 0.0, 0.0, 0.0, 0.0 );
}
void TRACK_BALL::Drag( const wxPoint& aNewMousePosition )
{
m_parametersChanged = true;
@@ -65,15 +64,34 @@ void TRACK_BALL::Drag( const wxPoint& aNewMousePosition )
zoom * ( 2.0 * aNewMousePosition.x - m_windowSize.x ) / m_windowSize.x,
zoom * ( m_windowSize.y - 2.0 * aNewMousePosition.y ) / m_windowSize.y );
float spin_matrix[4][4];
build_rotmatrix( spin_matrix, spin_quat );
m_rotationMatrix = glm::make_mat4( &spin_matrix[0][0] ) * m_rotationMatrix;
add_quats( spin_quat, m_quat, m_quat );
float rotationMatrix[4][4];
build_rotmatrix( rotationMatrix, m_quat );
m_rotationMatrix = glm::make_mat4( &rotationMatrix[0][0] );
updateViewMatrix();
updateFrustum();
}
void TRACK_BALL::SetLookAtPos( const SFVEC3F& aLookAtPos )
{
if( m_lookat_pos != aLookAtPos )
{
m_lookat_pos = aLookAtPos;
updateViewMatrix();
updateFrustum();
m_parametersChanged = true;
}
}
void TRACK_BALL::Pan( const wxPoint& aNewMousePosition )
{
m_parametersChanged = true;
@@ -88,7 +106,7 @@ void TRACK_BALL::Pan( const wxPoint& aNewMousePosition )
else // PROJECTION_TYPE::PERSPECTIVE
{
// Unproject the coordinates using the precomputed frustum tangent (zoom level dependent)
const float panFactor = -m_camera_pos.z * m_frustum.tang * 2;
const float panFactor = -m_camera_pos.z * m_frustum.tang * 2;
m_camera_pos.x -= panFactor * m_frustum.ratio *
( m_lastPosition.x - aNewMousePosition.x ) / m_windowSize.x;
m_camera_pos.y -= panFactor * ( aNewMousePosition.y - m_lastPosition.y ) / m_windowSize.y;
@@ -98,6 +116,7 @@ void TRACK_BALL::Pan( const wxPoint& aNewMousePosition )
updateFrustum();
}
void TRACK_BALL::Pan( const SFVEC3F& aDeltaOffsetInc )
{
m_parametersChanged = true;
@@ -108,11 +127,22 @@ void TRACK_BALL::Pan( const SFVEC3F& aDeltaOffsetInc )
updateFrustum();
}
void TRACK_BALL::Pan_T1( const SFVEC3F& aDeltaOffsetInc )
{
m_camera_pos_t1 = m_camera_pos + aDeltaOffsetInc;
}
void TRACK_BALL::Reset()
{
CAMERA::Reset();
memset( m_quat, 0, sizeof( m_quat ) );
trackball( m_quat, 0.0, 0.0, 0.0, 0.0 );
}
void TRACK_BALL::Reset_T1()
{
CAMERA::Reset_T1();
@@ -121,20 +151,16 @@ void TRACK_BALL::Reset_T1()
trackball( m_quat_t1, 0.0, 0.0, 0.0, 0.0 );
}
void TRACK_BALL::SetT0_and_T1_current_T()
{
CAMERA::SetT0_and_T1_current_T();
double quat[4];
// Charge the quaternions with the current rotation matrix to allow dual input.
std::copy_n( glm::value_ptr( glm::conjugate( glm::quat_cast( m_rotationMatrix ) ) ),
sizeof( quat ) / sizeof( quat[0] ), quat );
memcpy( m_quat_t0, quat, sizeof( quat ) );
memcpy( m_quat_t1, quat, sizeof( quat ) );
memcpy( m_quat_t0, m_quat, sizeof( m_quat ) );
memcpy( m_quat_t1, m_quat, sizeof( m_quat ) );
}
void TRACK_BALL::Interpolate( float t )
{
wxASSERT( t >= 0.0f );
@@ -158,15 +184,15 @@ void TRACK_BALL::Interpolate( float t )
}
const float t0 = 1.0f - t;
double quat[4];
quat[0] = m_quat_t0[0] * t0 + m_quat_t1[0] * t;
quat[1] = m_quat_t0[1] * t0 + m_quat_t1[1] * t;
quat[2] = m_quat_t0[2] * t0 + m_quat_t1[2] * t;
quat[3] = m_quat_t0[3] * t0 + m_quat_t1[3] * t;
m_quat[0] = m_quat_t0[0] * t0 + m_quat_t1[0] * t;
m_quat[1] = m_quat_t0[1] * t0 + m_quat_t1[1] * t;
m_quat[2] = m_quat_t0[2] * t0 + m_quat_t1[2] * t;
m_quat[3] = m_quat_t0[3] * t0 + m_quat_t1[3] * t;
float rotationMatrix[4][4];
build_rotmatrix( rotationMatrix, quat );
build_rotmatrix( rotationMatrix, m_quat );
m_rotationMatrix = glm::make_mat4( &rotationMatrix[0][0] );
+6 -1
View File
@@ -50,6 +50,10 @@ public:
void Pan_T1( const SFVEC3F& aDeltaOffsetInc ) override;
void SetLookAtPos( const SFVEC3F& aLookAtPos ) override;
void Reset() override;
void Reset_T1() override;
void SetT0_and_T1_current_T() override;
@@ -58,8 +62,9 @@ public:
private:
/**
* interpolate quaternions of the trackball
* quarternion of the trackball
*/
double m_quat[4];
double m_quat_t0[4];
double m_quat_t1[4];
};
+3 -4
View File
@@ -118,10 +118,9 @@ void EDA_3D_VIEWER_FRAME::CreateMenuBar()
prefsMenu->AppendSeparator();
prefsMenu->Add( EDA_3D_ACTIONS::showTHT, ACTION_MENU::CHECK );
prefsMenu->Add( EDA_3D_ACTIONS::showSMD, ACTION_MENU::CHECK );
prefsMenu->Add( EDA_3D_ACTIONS::showVirtual, ACTION_MENU::CHECK );
prefsMenu->Add( EDA_3D_ACTIONS::showNotInPosFile, ACTION_MENU::CHECK );
prefsMenu->Add( EDA_3D_ACTIONS::showTHT, ACTION_MENU::CHECK );
prefsMenu->Add( EDA_3D_ACTIONS::showSMD, ACTION_MENU::CHECK );
prefsMenu->Add( EDA_3D_ACTIONS::showVirtual, ACTION_MENU::CHECK );
prefsMenu->AppendSeparator();
+1 -36
View File
@@ -4,7 +4,7 @@
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2022 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
@@ -25,10 +25,8 @@
*/
#include <wx/wupdlock.h>
#include <wx/choice.h>
#include <bitmaps.h>
#include <dialogs/eda_view_switcher.h>
#include <eda_3d_viewer_frame.h>
#include <menus_helpers.h>
#include <tool/action_toolbar.h>
@@ -52,32 +50,6 @@ void EDA_3D_VIEWER_FRAME::ReCreateMainToolbar()
m_mainToolBar->SetAuiManager( &m_auimgr );
}
// Show the hotkey to open the windows list selector:
wxString keyName = KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY );
m_viewportsLabel = new wxStaticText( m_mainToolBar, wxID_ANY,
wxString::Format( _( "Viewports (%s+Tab):" ), keyName ) );
m_viewportsLabel->Wrap( -1 );
m_cbViewports = new wxChoice( m_mainToolBar, wxID_ANY );
for( std::pair<const wxString, VIEWPORT3D>& pair : m_viewports )
m_cbViewports->Append( pair.first, static_cast<void*>( &pair.second ) );
m_cbViewports->Append( wxT( "---" ) );
m_cbViewports->Append( _( "Save viewport..." ) );
m_cbViewports->Append( _( "Delete viewport..." ) );
m_cbViewports->SetToolTip( wxString::Format( _( "Save and restore view orientation and zoom.\n"
"Use %s+Tab to activate selector.\n"
"Successive Tabs while holding %s down will "
"cycle through viewports in the popup." ),
keyName, keyName ) );
m_cbViewports->SetSelection( m_cbViewports->GetCount() - 3 );
m_lastSelectedViewport = nullptr;
// Set up toolbar
m_mainToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
KiScaledBitmap( BITMAPS::import3d, this ), _( "Reload board" ) );
@@ -126,13 +98,6 @@ void EDA_3D_VIEWER_FRAME::ReCreateMainToolbar()
m_mainToolBar->Add( EDA_3D_ACTIONS::showTHT, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->Add( EDA_3D_ACTIONS::showSMD, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->Add( EDA_3D_ACTIONS::showVirtual, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->Add( EDA_3D_ACTIONS::showNotInPosFile, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->AddControl( m_viewportsLabel );
m_mainToolBar->AddControl( m_cbViewports );
m_mainToolBar->KiRealize();
}
+259 -361
View File
@@ -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 (C) 1992-2023 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
@@ -28,25 +28,19 @@
#include <wx/wupdlock.h>
#include <wx/clipbrd.h>
#include <wx/filedlg.h>
#include <wx/choice.h>
#include <wx/dialog.h>
#include <wx/treebook.h>
#include "eda_3d_viewer_frame.h"
#include "eda_list_dialog.h"
#include "wx/generic/textdlgg.h"
#include <dialogs/eda_view_switcher.h>
#include <eda_3d_viewer_settings.h>
#include <3d_viewer_id.h>
#include <3d_viewer/tools/eda_3d_actions.h>
#include <3d_viewer/tools/eda_3d_controller.h>
#include <3d_viewer/tools/eda_3d_conditions.h>
#include <advanced_config.h>
#include <bitmaps.h>
#include <board_design_settings.h>
#include <core/arraydim.h>
#include <gal/dpi_scaling.h>
#include <pgm_base.h>
#include <project.h>
#include <project/project_file.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <tool/action_manager.h>
@@ -54,11 +48,15 @@
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <widgets/wx_infobar.h>
#include <widgets/infobar.h>
#include <widgets/paged_dialog.h>
#include <dialogs/panel_3D_display_options.h>
#include <dialogs/panel_3D_opengl_options.h>
#include <dialogs/panel_3D_raytracing_options.h>
#include <dialogs/panel_3D_colors.h>
#include <panel_hotkeys_editor.h>
#include <wildcards_and_files_ext.h>
#include <3d_navlib/nl_3d_viewer_plugin.h>
/**
* Flag to enable 3D viewer main frame window debug tracing.
*
@@ -69,7 +67,7 @@
const wxChar* EDA_3D_VIEWER_FRAME::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
BEGIN_EVENT_TABLE( EDA_3D_VIEWER_FRAME, KIWAY_PLAYER )
BEGIN_EVENT_TABLE( EDA_3D_VIEWER_FRAME, EDA_BASE_FRAME )
EVT_ACTIVATE( EDA_3D_VIEWER_FRAME::OnActivate )
EVT_SET_FOCUS( EDA_3D_VIEWER_FRAME::OnSetFocus )
@@ -78,26 +76,26 @@ BEGIN_EVENT_TABLE( EDA_3D_VIEWER_FRAME, KIWAY_PLAYER )
EDA_3D_VIEWER_FRAME::Process_Special_Functions )
EVT_MENU( wxID_CLOSE, EDA_3D_VIEWER_FRAME::Exit3DFrame )
EVT_MENU( ID_RENDER_CURRENT_VIEW, EDA_3D_VIEWER_FRAME::onRenderEngineSelection )
EVT_MENU( ID_DISABLE_RAY_TRACING, EDA_3D_VIEWER_FRAME::onDisableRayTracing )
EVT_MENU( ID_RENDER_CURRENT_VIEW, EDA_3D_VIEWER_FRAME::OnRenderEngineSelection )
EVT_MENU( ID_DISABLE_RAY_TRACING, EDA_3D_VIEWER_FRAME::OnDisableRayTracing )
EVT_CLOSE( EDA_3D_VIEWER_FRAME::OnCloseWindow )
END_EVENT_TABLE()
EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent,
const wxString& aTitle, long style ) :
EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
const wxString &aTitle, long style ) :
KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition,
wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ), unityScale ),
m_mainToolBar( nullptr ), m_canvas( nullptr ), m_currentCamera( m_trackBallCamera ),
m_viewportsLabel( nullptr ),
m_cbViewports( nullptr ),
m_trackBallCamera( 2 * RANGE_SCALE_3D ), m_spaceMouse( nullptr )
wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) ),
m_mainToolBar( nullptr ),
m_canvas( nullptr ),
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( 2 * RANGE_SCALE_3D )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME %s" ), aTitle );
m_disable_ray_tracing = false;
m_aboutTitle = _HKI( "KiCad 3D Viewer" );
m_aboutTitle = _( "KiCad 3D Viewer" );
// Give it an icon
wxIcon icon;
@@ -110,21 +108,20 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent
wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
SetStatusWidths( arrayDim( status_dims ), status_dims );
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
ANTIALIASING_MODE aaMode = static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode );
m_canvas = new EDA_3D_CANVAS( this,
OGL_ATT_LIST::GetAttributesList( m_boardAdapter.GetAntiAliasingMode() ),
m_boardAdapter, m_currentCamera,
Prj().Get3DCacheManager() );
m_canvas = new EDA_3D_CANVAS( this, OGL_ATT_LIST::GetAttributesList( aaMode ),
m_boardAdapter, m_currentCamera, Prj().Get3DCacheManager() );
auto config = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
LoadSettings( config );
LoadSettings( cfg );
// Some settings need the canvas
loadCommonSettings();
SetUserViewports( Prj().GetProjectFile().m_Viewports3D );
// Create the manager
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, cfg, this );
m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this );
m_actions = new EDA_3D_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
@@ -138,7 +135,7 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent
setupUIConditions();
if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
ctrlTool->SetRotationIncrement( cfg->m_Camera.rotation_increment );
ctrlTool->SetRotationIncrement( config->m_Camera.rotation_increment );
// Run the viewer control tool, it is supposed to be always active
m_toolManager->InvokeTool( "3DViewer.Control" );
@@ -150,64 +147,37 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent
m_auimgr.SetManagedWindow( this );
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) ).Top().Layer( 6 ) );
m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( wxS( "InfoBar" ) ).Top().Layer( 1 ) );
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) ).Center() );
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
// hiding it.
m_auimgr.Update();
// We don't want the infobar displayed right away
m_auimgr.GetPane( wxS( "InfoBar" ) ).Hide();
m_auimgr.GetPane( "InfoBar" ).Hide();
m_auimgr.Update();
m_canvas->SetInfoBar( m_infoBar );
m_canvas->SetStatusBar( status_bar );
if( ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
{
try
{
m_spaceMouse = new NL_3D_VIEWER_PLUGIN( m_canvas );
}
catch( const std::system_error& e )
{
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
}
}
// Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
// in order to receive mouse events. Otherwise, the user has to click somewhere on
// the canvas before it will respond to mouse wheel events.
m_canvas->SetFocus();
m_cbViewports->Connect( wxEVT_COMMAND_CHOICE_SELECTED,
wxCommandEventHandler( EDA_3D_VIEWER_FRAME::onViewportChanged ),
nullptr, this );
m_cbViewports->Connect( wxEVT_UPDATE_UI,
wxUpdateUIEventHandler( EDA_3D_VIEWER_FRAME::onUpdateViewportsCb ),
nullptr, this );
}
EDA_3D_VIEWER_FRAME::~EDA_3D_VIEWER_FRAME()
{
delete m_spaceMouse;
Prj().GetProjectFile().m_Viewports3D = GetUserViewports();
m_cbViewports->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED,
wxCommandEventHandler( EDA_3D_VIEWER_FRAME::onViewportChanged ),
nullptr, this );
m_cbViewports->Disconnect( wxEVT_UPDATE_UI,
wxUpdateUIEventHandler( EDA_3D_VIEWER_FRAME::onUpdateViewportsCb ),
nullptr, this );
m_canvas->SetEventDispatcher( nullptr );
m_auimgr.UnInit();
// m_canvas delete will be called by wxWidget manager
//delete m_canvas;
//m_canvas = nullptr;
}
@@ -219,122 +189,57 @@ void EDA_3D_VIEWER_FRAME::setupUIConditions()
EDA_3D_CONDITIONS cond( &m_boardAdapter );
// Helper to define check conditions
#define FlagCheck( x ) ACTION_CONDITIONS().Check( cond.Flag( x ) )
#define GridSizeCheck( x ) ACTION_CONDITIONS().Check( cond.GridSize( x ) )
auto raytracing =
auto raytracingCondition =
[this]( const SELECTION& aSel )
{
return m_boardAdapter.m_Cfg->m_Render.engine != RENDER_ENGINE::OPENGL;
};
auto showTH =
[this]( const SELECTION& aSel )
{
return m_boardAdapter.m_Cfg->m_Render.show_footprints_normal;
};
auto showSMD =
[this]( const SELECTION& aSel )
{
return m_boardAdapter.m_Cfg->m_Render.show_footprints_insert;
};
auto showVirtual =
[this]( const SELECTION& aSel )
{
return m_boardAdapter.m_Cfg->m_Render.show_footprints_virtual;
};
auto show_NotInPosfile =
[this]( const SELECTION& aSel )
{
return m_boardAdapter.m_Cfg->m_Render.show_footprints_not_in_posfile;
};
auto showBBoxes =
[this]( const SELECTION& aSel )
{
return m_boardAdapter.m_Cfg->m_Render.opengl_show_model_bbox;
};
auto showAxes =
[this]( const SELECTION& aSel )
{
return m_boardAdapter.m_Cfg->m_Render.show_axis;
};
auto ortho =
[this]( const SELECTION& )
{
return m_currentCamera.GetProjection() == PROJECTION_TYPE::ORTHO;
return m_boardAdapter.GetRenderEngine() != RENDER_ENGINE::OPENGL;
};
RegisterUIUpdateHandler( ID_RENDER_CURRENT_VIEW, ACTION_CONDITIONS().Check( raytracing ) );
RegisterUIUpdateHandler( ID_RENDER_CURRENT_VIEW,
ACTION_CONDITIONS().Check( raytracingCondition ) );
mgr->SetConditions( EDA_3D_ACTIONS::showTHT, ACTION_CONDITIONS().Check( showTH ) );
mgr->SetConditions( EDA_3D_ACTIONS::showSMD, ACTION_CONDITIONS().Check( showSMD ) );
mgr->SetConditions( EDA_3D_ACTIONS::showVirtual, ACTION_CONDITIONS().Check( showVirtual ) );
mgr->SetConditions( EDA_3D_ACTIONS::showNotInPosFile, ACTION_CONDITIONS().Check( show_NotInPosfile ) );
mgr->SetConditions( EDA_3D_ACTIONS::showTHT, FlagCheck( FL_FP_ATTRIBUTES_NORMAL ) );
mgr->SetConditions( EDA_3D_ACTIONS::showSMD, FlagCheck( FL_FP_ATTRIBUTES_NORMAL_INSERT ) );
mgr->SetConditions( EDA_3D_ACTIONS::showVirtual, FlagCheck( FL_FP_ATTRIBUTES_VIRTUAL ) );
mgr->SetConditions( EDA_3D_ACTIONS::showBBoxes, ACTION_CONDITIONS().Check( showBBoxes ) );
mgr->SetConditions( EDA_3D_ACTIONS::showAxis, ACTION_CONDITIONS().Check( showAxes ) );
mgr->SetConditions( EDA_3D_ACTIONS::showBBoxes, FlagCheck( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) );
mgr->SetConditions( EDA_3D_ACTIONS::showAxis, FlagCheck( FL_AXIS ) );
mgr->SetConditions( EDA_3D_ACTIONS::noGrid, GridSizeCheck( GRID3D_TYPE::NONE ) );
mgr->SetConditions( EDA_3D_ACTIONS::show10mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_10MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::show5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_5MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::show2_5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_2P5MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::show1mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_1MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( ortho ) );
auto orthoCondition =
[this]( const SELECTION& )
{
return m_currentCamera.GetProjection() == PROJECTION_TYPE::ORTHO;
};
mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( orthoCondition ) );
#undef FlagCheck
#undef GridSizeCheck
}
bool EDA_3D_VIEWER_FRAME::TryBefore( wxEvent& aEvent )
void EDA_3D_VIEWER_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
{
static bool s_viewportSwitcherShown = false;
wxTreebook* book = aParent->GetTreebook();
// wxWidgets generates no key events for the tab key when the ctrl key is held down. One
// way around this is to look at all events and inspect the keyboard state of the tab key.
// However, this runs into issues on some linux VMs where querying the keyboard state is
// very slow. Fortunately we only use ctrl-tab on Mac, so we implement this lovely hack:
#ifdef __WXMAC__
if( wxGetKeyState( WXK_TAB ) )
#else
if( ( aEvent.GetEventType() == wxEVT_CHAR || aEvent.GetEventType() == wxEVT_CHAR_HOOK )
&& static_cast<wxKeyEvent&>( aEvent ).GetKeyCode() == WXK_TAB )
#endif
{
if( !s_viewportSwitcherShown && wxGetKeyState( VIEWPORT_SWITCH_KEY ) )
{
if( this->IsActive() )
{
if( m_viewportMRU.size() > 0 )
{
EDA_VIEW_SWITCHER switcher( this, m_viewportMRU, VIEWPORT_SWITCH_KEY );
book->AddPage( new wxPanel( book ), _( "3D Viewer" ) );
book->AddSubPage( new PANEL_3D_DISPLAY_OPTIONS( this, book ), _( "General" ) );
book->AddSubPage( new PANEL_3D_OPENGL_OPTIONS( this, book ), _( "Realtime Renderer" ) );
book->AddSubPage( new PANEL_3D_RAYTRACING_OPTIONS( this, book ), _( "Raytracing Renderer" ) );
book->AddSubPage( new PANEL_3D_COLORS( this, book ), _( "Colors" ) );
s_viewportSwitcherShown = true;
switcher.ShowModal();
s_viewportSwitcherShown = false;
int idx = switcher.GetSelection();
if( idx >= 0 && idx < (int) m_viewportMRU.size() )
applyViewport( m_viewportMRU[idx] );
return true;
}
}
}
}
return wxFrame::TryBefore( aEvent );
}
void EDA_3D_VIEWER_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
{
KIWAY_PLAYER::handleIconizeEvent( aEvent );
if( m_spaceMouse != nullptr && aEvent.IsIconized()
&& ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
{
m_spaceMouse->SetFocus( false );
}
aHotkeysPanel->AddHotKeys( GetToolManager() );
}
@@ -360,14 +265,14 @@ void EDA_3D_VIEWER_FRAME::NewDisplay( bool aForceImmediateRedraw )
void EDA_3D_VIEWER_FRAME::Redraw()
{
// Only update in OpenGL for an interactive interaction
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL )
m_canvas->Request_refresh( true );
}
void EDA_3D_VIEWER_FRAME::refreshRender()
{
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL )
m_canvas->Request_refresh();
else
NewDisplay( true );
@@ -389,6 +294,10 @@ void EDA_3D_VIEWER_FRAME::OnCloseWindow( wxCloseEvent &event )
if( m_canvas )
m_canvas->Close();
// m_canvas delete will be called by wxWidget manager
//delete m_canvas;
//m_canvas = nullptr;
Destroy();
event.Skip( true );
}
@@ -439,199 +348,31 @@ void EDA_3D_VIEWER_FRAME::Process_Special_Functions( wxCommandEvent &event )
}
std::vector<VIEWPORT3D> EDA_3D_VIEWER_FRAME::GetUserViewports() const
void EDA_3D_VIEWER_FRAME::OnRenderEngineSelection( wxCommandEvent &event )
{
std::vector<VIEWPORT3D> ret;
for( const std::pair<const wxString, VIEWPORT3D>& pair : m_viewports )
ret.emplace_back( pair.second );
return ret;
}
void EDA_3D_VIEWER_FRAME::SetUserViewports( std::vector<VIEWPORT3D>& aViewportList )
{
m_viewports.clear();
for( const VIEWPORT3D& viewport : aViewportList )
{
if( m_viewports.count( viewport.name ) )
continue;
m_viewports[viewport.name] = viewport;
m_viewportMRU.Add( viewport.name );
}
}
void EDA_3D_VIEWER_FRAME::applyViewport( const wxString& aViewportName )
{
int idx = m_cbViewports->FindString( aViewportName );
if( idx >= 0 && idx < m_cbViewports->GetCount() - 3 /* separator */ )
{
m_cbViewports->SetSelection( idx );
m_lastSelectedViewport = static_cast<VIEWPORT3D*>( m_cbViewports->GetClientData( idx ) );
m_currentCamera.SetViewMatrix( m_lastSelectedViewport->matrix );
if( m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
m_canvas->Request_refresh();
else
m_canvas->RenderRaytracingRequest();
if( !m_lastSelectedViewport->name.IsEmpty() )
{
m_viewportMRU.Remove( m_lastSelectedViewport->name );
m_viewportMRU.Insert( m_lastSelectedViewport->name, 0 );
}
}
else
{
m_cbViewports->SetSelection( -1 ); // separator
m_lastSelectedViewport = nullptr;
}
}
void EDA_3D_VIEWER_FRAME::onViewportChanged( wxCommandEvent& aEvent )
{
int count = m_cbViewports->GetCount();
int index = m_cbViewports->GetSelection();
if( index >= 0 && index < count - 3 /* separator */ )
{
VIEWPORT3D* viewport = static_cast<VIEWPORT3D*>( m_cbViewports->GetClientData( index ) );
wxCHECK( viewport, /* void */ );
applyViewport( viewport->name );
}
else if( index == count - 2 )
{
// Save current state to new preset
wxString name;
wxTextEntryDialog dlg( this, _( "Viewport name:" ), _( "Save Viewport" ), name );
if( dlg.ShowModal() != wxID_OK )
{
if( m_lastSelectedViewport )
m_cbViewports->SetStringSelection( m_lastSelectedViewport->name );
else
m_cbViewports->SetSelection( -1 );
return;
}
name = dlg.GetValue();
bool exists = m_viewports.count( name );
if( !exists )
{
m_viewports[name] = VIEWPORT3D( name, m_currentCamera.GetViewMatrix() );
index = m_cbViewports->Insert( name, index-1, static_cast<void*>( &m_viewports[name] ) );
}
else
{
index = m_cbViewports->FindString( name );
m_viewports[name].matrix = m_currentCamera.GetViewMatrix();
m_viewportMRU.Remove( name );
}
m_cbViewports->SetSelection( index );
m_viewportMRU.Insert( name, 0 );
return;
}
else if( index == count - 1 )
{
// Delete an existing viewport
wxArrayString headers;
std::vector<wxArrayString> items;
headers.Add( _( "Viewports" ) );
for( std::pair<const wxString, VIEWPORT3D>& pair : m_viewports )
{
wxArrayString item;
item.Add( pair.first );
items.emplace_back( item );
}
EDA_LIST_DIALOG dlg( this, _( "Delete Viewport" ), headers, items );
dlg.SetListLabel( _( "Select viewport:" ) );
if( dlg.ShowModal() == wxID_OK )
{
wxString viewportName = dlg.GetTextSelection();
int idx = m_cbViewports->FindString( viewportName );
if( idx != wxNOT_FOUND )
{
m_viewports.erase( viewportName );
m_cbViewports->Delete( idx );
m_viewportMRU.Remove( viewportName );
}
}
if( m_lastSelectedViewport )
m_cbViewports->SetStringSelection( m_lastSelectedViewport->name );
else
m_cbViewports->SetSelection( -1 );
return;
}
passOnFocus();
}
void EDA_3D_VIEWER_FRAME::onUpdateViewportsCb( wxUpdateUIEvent& aEvent )
{
int count = m_cbViewports->GetCount();
int index = m_cbViewports->GetSelection();
if( index >= 0 && index < count - 3 )
{
VIEWPORT3D* viewport = static_cast<VIEWPORT3D*>( m_cbViewports->GetClientData( index ) );
wxCHECK( viewport, /* void */ );
if( m_currentCamera.GetViewMatrix() != viewport->matrix )
m_cbViewports->SetSelection( -1 );
}
}
void EDA_3D_VIEWER_FRAME::onRenderEngineSelection( wxCommandEvent &event )
{
RENDER_ENGINE& engine = m_boardAdapter.m_Cfg->m_Render.engine;
RENDER_ENGINE old_engine = engine;
const RENDER_ENGINE old_engine = m_boardAdapter.GetRenderEngine();
if( old_engine == RENDER_ENGINE::OPENGL )
engine = RENDER_ENGINE::RAYTRACING;
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::RAYTRACING );
else
engine = RENDER_ENGINE::OPENGL;
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL );
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::OnRenderEngineSelection type %s " ),
engine == RENDER_ENGINE::RAYTRACING ? wxT( "raytracing" ) : wxT( "realtime" ) );
m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::RAYTRACING ? wxT( "raytracing" )
: wxT( "realtime" ) );
if( old_engine != engine )
if( old_engine != m_boardAdapter.GetRenderEngine() )
RenderEngineChanged();
}
void EDA_3D_VIEWER_FRAME::onDisableRayTracing( wxCommandEvent& aEvent )
void EDA_3D_VIEWER_FRAME::OnDisableRayTracing( wxCommandEvent& aEvent )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::%s disabling ray tracing." ),
__WXFUNCTION__ );
m_disable_ray_tracing = true;
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::OPENGL;
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL );
}
@@ -650,9 +391,6 @@ void EDA_3D_VIEWER_FRAME::OnActivate( wxActivateEvent &aEvent )
m_canvas->SetFocus();
}
if( m_spaceMouse != nullptr && ADVANCED_CFG::GetCfg().m_Use3DConnexionDriver )
m_spaceMouse->SetFocus( aEvent.GetActive() );
aEvent.Skip(); // required under wxMAC
}
@@ -667,13 +405,6 @@ void EDA_3D_VIEWER_FRAME::OnSetFocus( wxFocusEvent& aEvent )
}
void EDA_3D_VIEWER_FRAME::passOnFocus()
{
if( m_canvas )
m_canvas->SetFocus();
}
void EDA_3D_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE *aCfg )
{
EDA_BASE_FRAME::LoadSettings( aCfg );
@@ -685,16 +416,109 @@ void EDA_3D_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE *aCfg )
if( cfg )
{
m_boardAdapter.m_Cfg = cfg;
m_boardAdapter.m_RtCameraLightColor =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorCamera );
m_boardAdapter.m_RtLightColorTop =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorTop );
m_boardAdapter.m_RtLightColorBottom =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColorBottom );
// When opening the 3D viewer, we use the OpenGL mode, never the ray tracing engine
// because the ray tracing is very time consuming, and can be seen as not working
m_boardAdapter.m_RtLightColor.resize( cfg->m_Render.raytrace_lightColor.size() );
m_boardAdapter.m_RtLightSphericalCoords.resize( cfg->m_Render.raytrace_lightColor.size() );
for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
{
m_boardAdapter.m_RtLightColor[i] =
m_boardAdapter.GetColor( cfg->m_Render.raytrace_lightColor[i] );
SFVEC2F sphericalCoord =
SFVEC2F( ( cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
m_boardAdapter.m_RtLightSphericalCoords[i] = sphericalCoord;
}
#define TRANSFER_SETTING( flag, field ) m_boardAdapter.SetFlag( flag, cfg->m_Render.field )
TRANSFER_SETTING( FL_USE_REALISTIC_MODE, realistic );
TRANSFER_SETTING( FL_SUBTRACT_MASK_FROM_SILK, subtract_mask_from_silk );
// OpenGL options
TRANSFER_SETTING( FL_RENDER_OPENGL_COPPER_THICKNESS, opengl_copper_thickness );
TRANSFER_SETTING( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, opengl_show_model_bbox );
TRANSFER_SETTING( FL_HIGHLIGHT_ROLLOVER_ITEM, opengl_highlight_on_rollover );
TRANSFER_SETTING( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, opengl_AA_disableOnMove );
TRANSFER_SETTING( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE, opengl_thickness_disableOnMove );
TRANSFER_SETTING( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, opengl_vias_disableOnMove );
TRANSFER_SETTING( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, opengl_holes_disableOnMove );
// Raytracing options
TRANSFER_SETTING( FL_RENDER_RAYTRACING_SHADOWS, raytrace_shadows );
TRANSFER_SETTING( FL_RENDER_RAYTRACING_BACKFLOOR, raytrace_backfloor );
TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFRACTIONS, raytrace_refractions );
TRANSFER_SETTING( FL_RENDER_RAYTRACING_REFLECTIONS, raytrace_reflections );
TRANSFER_SETTING( FL_RENDER_RAYTRACING_POST_PROCESSING, raytrace_post_processing );
TRANSFER_SETTING( FL_RENDER_RAYTRACING_ANTI_ALIASING, raytrace_anti_aliasing );
TRANSFER_SETTING( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, raytrace_procedural_textures );
TRANSFER_SETTING( FL_AXIS, show_axis );
TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL, show_footprints_normal );
TRANSFER_SETTING( FL_FP_ATTRIBUTES_NORMAL_INSERT, show_footprints_insert );
TRANSFER_SETTING( FL_FP_ATTRIBUTES_VIRTUAL, show_footprints_virtual );
TRANSFER_SETTING( FL_ZONE, show_zones );
TRANSFER_SETTING( FL_ADHESIVE, show_adhesive );
TRANSFER_SETTING( FL_SILKSCREEN, show_silkscreen );
TRANSFER_SETTING( FL_SOLDERMASK, show_soldermask );
TRANSFER_SETTING( FL_SOLDERPASTE, show_solderpaste );
TRANSFER_SETTING( FL_COMMENTS, show_comments );
TRANSFER_SETTING( FL_ECO, show_eco );
TRANSFER_SETTING( FL_SHOW_BOARD_BODY, show_board_body );
TRANSFER_SETTING( FL_CLIP_SILK_ON_VIA_ANNULUS, clip_silk_on_via_annulus );
TRANSFER_SETTING( FL_RENDER_PLATED_PADS_AS_PLATED, renderPlatedPadsAsPlated );
m_boardAdapter.SetGridType( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
m_boardAdapter.SetAntiAliasingMode(
static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
m_boardAdapter.m_OpenGlSelectionColor =
m_boardAdapter.GetColor( cfg->m_Render.opengl_selection_color );
m_boardAdapter.m_RtShadowSampleCount = cfg->m_Render.raytrace_nrsamples_shadows;
m_boardAdapter.m_RtReflectionSampleCount = cfg->m_Render.raytrace_nrsamples_reflections;
m_boardAdapter.m_RtRefractionSampleCount = cfg->m_Render.raytrace_nrsamples_refractions;
m_boardAdapter.m_RtSpreadShadows = cfg->m_Render.raytrace_spread_shadows;
m_boardAdapter.m_RtSpreadReflections = cfg->m_Render.raytrace_spread_reflections;
m_boardAdapter.m_RtSpreadRefractions = cfg->m_Render.raytrace_spread_refractions;
m_boardAdapter.m_RtRecursiveRefractionCount =
cfg->m_Render.raytrace_recursivelevel_refractions;
m_boardAdapter.m_RtRecursiveReflectionCount =
cfg->m_Render.raytrace_recursivelevel_reflections;
// When opening the 3D viewer, we use the opengl mode, not the ray tracing engine
// because the ray tracing is very time consumming, and can be seen as not working
// (freeze window) with large boards.
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::OPENGL;
#if 0
RENDER_ENGINE engine = static_cast<RENDER_ENGINE>( cfg->m_Render.engine );
wxLogTrace( m_logTrace, engine == RENDER_ENGINE::RAYTRACING ?
wxT( "EDA_3D_VIEWER_FRAME::LoadSettings render setting Ray Trace" )
:
wxT( "EDA_3D_VIEWER_FRAME::LoadSettings render setting OpenGL" ) );
#else
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL );
#endif
m_boardAdapter.SetMaterialMode( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
m_canvas->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
m_canvas->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
m_canvas->SetProjectionMode( cfg->m_Camera.projection_mode );
#undef TRANSFER_SETTING
}
}
@@ -707,19 +531,95 @@ void EDA_3D_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE *aCfg )
wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::SaveSettings" ) );
wxLogTrace( m_logTrace, m_boardAdapter.m_Cfg->m_Render.engine == RENDER_ENGINE::RAYTRACING ?
wxT( "EDA_3D_VIEWER_FRAME::SaveSettings render setting Ray Trace" )
:
wxT( "EDA_3D_VIEWER_FRAME::SaveSettings render setting OpenGL" ) );
wxLogTrace( m_logTrace, m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::RAYTRACING ?
wxT( "EDA_3D_VIEWER_FRAME::SaveSettings render setting Ray Trace" ) :
wxT( "EDA_3D_VIEWER_FRAME::SaveSettings render setting OpenGL" ) );
if( cfg )
{
auto save_color =
[] ( const SFVEC3F& aSource, COLOR4D& aTarget )
{
aTarget = COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 );
};
save_color( m_boardAdapter.m_RtCameraLightColor, cfg->m_Render.raytrace_lightColorCamera );
save_color( m_boardAdapter.m_RtLightColorTop, cfg->m_Render.raytrace_lightColorTop );
save_color( m_boardAdapter.m_RtLightColorBottom, cfg->m_Render.raytrace_lightColorBottom );
for( size_t i = 0; i < cfg->m_Render.raytrace_lightColor.size(); ++i )
{
save_color( m_boardAdapter.m_RtLightColor[i], cfg->m_Render.raytrace_lightColor[i] );
cfg->m_Render.raytrace_lightElevation[i] =
(int)( m_boardAdapter.m_RtLightSphericalCoords[i].x * 180.0f - 90.0f );
cfg->m_Render.raytrace_lightAzimuth[i] =
(int)( m_boardAdapter.m_RtLightSphericalCoords[i].y * 180.0f );
}
cfg->m_Render.raytrace_nrsamples_shadows = m_boardAdapter.m_RtShadowSampleCount;
cfg->m_Render.raytrace_nrsamples_reflections = m_boardAdapter.m_RtReflectionSampleCount;
cfg->m_Render.raytrace_nrsamples_refractions = m_boardAdapter.m_RtRefractionSampleCount;
cfg->m_Render.raytrace_spread_shadows = m_boardAdapter.m_RtSpreadShadows;
cfg->m_Render.raytrace_spread_reflections = m_boardAdapter.m_RtSpreadReflections;
cfg->m_Render.raytrace_spread_refractions = m_boardAdapter.m_RtSpreadRefractions;
cfg->m_Render.raytrace_recursivelevel_refractions =
m_boardAdapter.m_RtRecursiveRefractionCount;
cfg->m_Render.raytrace_recursivelevel_reflections =
m_boardAdapter.m_RtRecursiveReflectionCount;
#define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
cfg->m_Render.engine = static_cast<int>( m_boardAdapter.GetRenderEngine() );
cfg->m_Render.grid_type = static_cast<int>( m_boardAdapter.GetGridType() );
cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.GetMaterialMode() );
cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.GetAntiAliasingMode() );
save_color( m_boardAdapter.m_OpenGlSelectionColor, cfg->m_Render.opengl_selection_color );
cfg->m_Camera.animation_enabled = m_canvas->GetAnimationEnabled();
cfg->m_Camera.moving_speed_multiplier = m_canvas->GetMovingSpeedMultiplier();
cfg->m_Camera.projection_mode = m_canvas->GetProjectionMode();
if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
cfg->m_Camera.rotation_increment = ctrlTool->GetRotationIncrement();
TRANSFER_SETTING( opengl_AA_disableOnMove, FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE );
TRANSFER_SETTING( opengl_copper_thickness, FL_RENDER_OPENGL_COPPER_THICKNESS );
TRANSFER_SETTING( opengl_show_model_bbox, FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
TRANSFER_SETTING( opengl_highlight_on_rollover, FL_HIGHLIGHT_ROLLOVER_ITEM );
TRANSFER_SETTING( opengl_thickness_disableOnMove, FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE );
TRANSFER_SETTING( opengl_vias_disableOnMove, FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE );
TRANSFER_SETTING( opengl_holes_disableOnMove, FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE );
TRANSFER_SETTING( raytrace_anti_aliasing, FL_RENDER_RAYTRACING_ANTI_ALIASING );
TRANSFER_SETTING( raytrace_backfloor, FL_RENDER_RAYTRACING_BACKFLOOR );
TRANSFER_SETTING( raytrace_post_processing, FL_RENDER_RAYTRACING_POST_PROCESSING );
TRANSFER_SETTING( raytrace_procedural_textures, FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES );
TRANSFER_SETTING( raytrace_reflections, FL_RENDER_RAYTRACING_REFLECTIONS );
TRANSFER_SETTING( raytrace_refractions, FL_RENDER_RAYTRACING_REFRACTIONS );
TRANSFER_SETTING( raytrace_shadows, FL_RENDER_RAYTRACING_SHADOWS );
TRANSFER_SETTING( realistic, FL_USE_REALISTIC_MODE );
TRANSFER_SETTING( show_adhesive, FL_ADHESIVE );
TRANSFER_SETTING( show_axis, FL_AXIS );
TRANSFER_SETTING( show_board_body, FL_SHOW_BOARD_BODY );
TRANSFER_SETTING( clip_silk_on_via_annulus, FL_CLIP_SILK_ON_VIA_ANNULUS );
TRANSFER_SETTING( renderPlatedPadsAsPlated, FL_RENDER_PLATED_PADS_AS_PLATED );
TRANSFER_SETTING( show_comments, FL_COMMENTS );
TRANSFER_SETTING( show_eco, FL_ECO );
TRANSFER_SETTING( show_footprints_insert, FL_FP_ATTRIBUTES_NORMAL_INSERT );
TRANSFER_SETTING( show_footprints_normal, FL_FP_ATTRIBUTES_NORMAL );
TRANSFER_SETTING( show_footprints_virtual, FL_FP_ATTRIBUTES_VIRTUAL );
TRANSFER_SETTING( show_silkscreen, FL_SILKSCREEN );
TRANSFER_SETTING( show_soldermask, FL_SOLDERMASK );
TRANSFER_SETTING( show_solderpaste, FL_SOLDERPASTE );
TRANSFER_SETTING( show_zones, FL_ZONE );
TRANSFER_SETTING( subtract_mask_from_silk, FL_SUBTRACT_MASK_FROM_SILK );
#undef TRANSFER_SETTING
}
}
@@ -735,7 +635,6 @@ void EDA_3D_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTex
ReCreateMainToolbar();
loadCommonSettings();
LoadSettings( Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>() );
NewDisplay( true );
}
@@ -851,7 +750,6 @@ void EDA_3D_VIEWER_FRAME::loadCommonSettings()
const DPI_SCALING dpi{ settings, this };
m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
// TODO(JE) use all control options
m_boardAdapter.m_MousewheelPanning = settings->m_Input.scroll_modifier_zoom != 0;
m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.scroll_modifier_zoom != 0 );
}
+16 -38
View File
@@ -4,7 +4,7 @@
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2022 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
@@ -42,13 +42,11 @@
/// A variable name whose value holds the path of 3D shape files.
/// Currently an environment variable, eventually a project variable.
#define KICAD7_3DMODEL_DIR wxT( "KICAD7_3DMODEL_DIR" )
#define KICAD6_3DMODEL_DIR wxT( "KICAD6_3DMODEL_DIR" )
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
// Forward declarations
class NL_3D_VIEWER_PLUGIN;
enum EDA_3D_VIEWER_STATUSBAR
{
@@ -75,6 +73,8 @@ public:
wxWindow* GetToolCanvas() const override { return m_canvas; }
void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
/**
* Request reloading the 3D view.
*
@@ -106,9 +106,6 @@ public:
EDA_3D_CANVAS* GetCanvas() { return m_canvas; }
std::vector<VIEWPORT3D> GetUserViewports() const;
void SetUserViewports( std::vector<VIEWPORT3D>& aViewportList );
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
@@ -123,32 +120,22 @@ public:
protected:
void setupUIConditions() override;
void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
/**
* switch to a given predefined 3D viewport
* @param aViewportName is the name of the viewport to switch on
*/
void applyViewport( const wxString& aViewportName );
private:
/// Called when user press the File->Exit
void Exit3DFrame( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& event );
bool TryBefore( wxEvent& aEvent ) override;
void Process_Special_Functions( wxCommandEvent& event );
void onRenderEngineSelection( wxCommandEvent& event );
void onDisableRayTracing( wxCommandEvent& aEvent );
void onViewportChanged( wxCommandEvent& aEvent );
void onUpdateViewportsCb( wxUpdateUIEvent& aEvent );
void OnRenderEngineSelection( wxCommandEvent& event );
void OnDisableRayTracing( wxCommandEvent& aEvent );
void OnActivate( wxActivateEvent& event );
void OnSetFocus( wxFocusEvent& event );
void passOnFocus();
void Install3DViewOptionDialog( wxCommandEvent& event );
void CreateMenuBar();
void ReCreateMainToolbar();
@@ -173,24 +160,15 @@ private:
*/
void loadCommonSettings();
private:
wxFileName m_defaultSaveScreenshotFileName;
wxFileName m_defaultSaveScreenshotFileName;
ACTION_TOOLBAR* m_mainToolBar;
wxStaticText* m_viewportsLabel;
wxChoice* m_cbViewports;
EDA_3D_CANVAS* m_canvas;
BOARD_ADAPTER m_boardAdapter;
CAMERA& m_currentCamera;
TRACK_BALL m_trackBallCamera;
ACTION_TOOLBAR* m_mainToolBar;
EDA_3D_CANVAS* m_canvas;
BOARD_ADAPTER m_boardAdapter;
CAMERA& m_currentCamera;
TRACK_BALL m_trackBallCamera;
bool m_disable_ray_tracing;
NL_3D_VIEWER_PLUGIN* m_spaceMouse;
std::map<wxString, VIEWPORT3D> m_viewports;
VIEWPORT3D* m_lastSelectedViewport;
wxArrayString m_viewportMRU;
bool m_disable_ray_tracing;
/**
* Trace mask used to enable or disable the trace output of this class.
+23 -28
View File
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020-2022 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 as published by the
@@ -37,27 +37,25 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
m_Render(),
m_Camera()
{
m_params.emplace_back( new PARAM_ENUM<RENDER_ENGINE>( "render.engine", &m_Render.engine,
RENDER_ENGINE::OPENGL,
RENDER_ENGINE::OPENGL,
RENDER_ENGINE::RAYTRACING ) );
m_params.emplace_back( new PARAM<int>( "render.engine", &m_Render.engine,
static_cast<int>( RENDER_ENGINE::OPENGL ),
static_cast<int>( RENDER_ENGINE::OPENGL ),
static_cast<int>( RENDER_ENGINE::RAYTRACING ) ) );
m_params.emplace_back( new PARAM_ENUM<GRID3D_TYPE>( "render.grid_type", &m_Render.grid_type,
GRID3D_TYPE::NONE,
GRID3D_TYPE::NONE,
GRID3D_TYPE::GRID_10MM ) );
m_params.emplace_back( new PARAM<int>( "render.grid_type", &m_Render.grid_type,
static_cast<int>( GRID3D_TYPE::NONE ),
static_cast<int>( GRID3D_TYPE::NONE ),
static_cast<int>( GRID3D_TYPE::GRID_10MM ) ) );
m_params.emplace_back( new PARAM_ENUM<MATERIAL_MODE>( "render.material_mode",
&m_Render.material_mode,
MATERIAL_MODE::NORMAL,
MATERIAL_MODE::NORMAL,
MATERIAL_MODE::CAD_MODE ) );
m_params.emplace_back( new PARAM<int>( "render.material_mode", &m_Render.material_mode,
static_cast<int>( MATERIAL_MODE::NORMAL ),
static_cast<int>( MATERIAL_MODE::NORMAL ),
static_cast<int>( MATERIAL_MODE::CAD_MODE ) ) );
m_params.emplace_back( new PARAM_ENUM<ANTIALIASING_MODE>( "render.opengl_AA_mode",
&m_Render.opengl_AA_mode,
ANTIALIASING_MODE::AA_8X,
ANTIALIASING_MODE::AA_NONE,
ANTIALIASING_MODE::AA_8X ) );
m_params.emplace_back( new PARAM<int>( "render.opengl_AA_mode", &m_Render.opengl_AA_mode,
static_cast<int>( ANTIALIASING_MODE::AA_8X ),
static_cast<int>( ANTIALIASING_MODE::AA_NONE ),
static_cast<int>( ANTIALIASING_MODE::AA_8X ) ) );
m_params.emplace_back( new PARAM<COLOR4D>( "render.opengl_selection_color",
&m_Render.opengl_selection_color,
@@ -88,7 +86,7 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
&m_Render.raytrace_backfloor, false ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_post_processing",
&m_Render.raytrace_post_processing, true ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_procedural_textures",
m_params.emplace_back( new PARAM<bool>( "render.raytrace_procedural_textures",
&m_Render.raytrace_procedural_textures, true ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_reflections",
&m_Render.raytrace_reflections, true ) );
@@ -180,8 +178,6 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
&m_Render.show_footprints_normal, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_virtual",
&m_Render.show_footprints_virtual, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_not_in_posfile",
&m_Render.show_footprints_not_in_posfile, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_silkscreen",
&m_Render.show_silkscreen, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_soldermask",
@@ -207,12 +203,11 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
registerMigration( 0, 1, std::bind( &EDA_3D_VIEWER_SETTINGS::migrateSchema0to1, this ) );
registerMigration( 1, 2,
[&]() -> bool
{
Set( "render.opengl_copper_thickness", false );
return true;
} );
registerMigration( 1, 2, [&]() -> bool
{
Set( "render.opengl_copper_thickness", false );
return true;
} );
}
+6 -11
View File
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020-2022 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 as published by the
@@ -21,23 +21,19 @@
#ifndef EDA_3D_VIEWER_SETTINGS_H_
#define EDA_3D_VIEWER_SETTINGS_H_
#include <3d_enums.h>
#include <common_ogl/ogl_attr_list.h>
#include <plugins/3dapi/xv3d_types.h>
#include <settings/app_settings.h>
#include <settings/parameters.h>
#include "render_settings.h"
#include <plugins/3dapi/xv3d_types.h>
class EDA_3D_VIEWER_SETTINGS : public APP_SETTINGS_BASE
{
public:
struct RENDER_SETTINGS
{
RENDER_ENGINE engine;
GRID3D_TYPE grid_type;
ANTIALIASING_MODE opengl_AA_mode;
MATERIAL_MODE material_mode;
int engine;
int grid_type;
int opengl_AA_mode;
int material_mode;
bool opengl_AA_disableOnMove;
bool opengl_thickness_disableOnMove;
bool opengl_vias_disableOnMove;
@@ -83,7 +79,6 @@ public:
bool show_footprints_insert;
bool show_footprints_normal;
bool show_footprints_virtual;
bool show_footprints_not_in_posfile;
bool show_silkscreen;
bool show_soldermask;
bool show_solderpaste;
+25 -22
View File
@@ -111,7 +111,7 @@ TOOL_ACTION EDA_3D_ACTIONS::resetView( "3DViewer.Control.resetView",
TOOL_ACTION EDA_3D_ACTIONS::flipView( "3DViewer.Control.flipView",
AS_ACTIVE,
'F', "",
0, "",
_( "Flip Board" ), _( "Flip the board view" ),
BITMAPS::flip_board, AF_NONE, (void*) ID_VIEW3D_FLIP );
@@ -207,70 +207,73 @@ TOOL_ACTION EDA_3D_ACTIONS::showTHT( "3DViewer.Control.attributesTHT",
'T', "",
_( "Toggle Through Hole 3D models" ),
_( "Toggle 3D models for 'Through hole' type components" ),
BITMAPS::show_tht, AF_NONE );
BITMAPS::show_tht, AF_NONE, (void*) FL_FP_ATTRIBUTES_NORMAL );
TOOL_ACTION EDA_3D_ACTIONS::showSMD( "3DViewer.Control.attributesSMD",
AS_ACTIVE,
'S', "",
_( "Toggle SMD 3D models" ),
_( "Toggle 3D models for 'Surface mount' type components" ),
BITMAPS::show_smt, AF_NONE );
BITMAPS::show_smt, AF_NONE, (void*) FL_FP_ATTRIBUTES_NORMAL_INSERT );
TOOL_ACTION EDA_3D_ACTIONS::showVirtual( "3DViewer.Control.attributesOther",
AS_ACTIVE,
'V', "",
_( "Toggle unspecified 3D models" ), _( "Toggle 3D models for 'unspecified' type components" ),
BITMAPS::show_other, AF_NONE );
TOOL_ACTION EDA_3D_ACTIONS::showNotInPosFile( "3DViewer.Control.attribute_not_in_posfile",
AS_ACTIVE,
'P', "",
_( "Toggle 3D models not in pos file" ), _( "Toggle 3D models not in pos file" ),
BITMAPS::show_not_in_posfile, AF_NONE );
_( "Toggle Other 3D models" ), _( "Toggle 3D models for 'Other' type components" ),
BITMAPS::show_other, AF_NONE, (void*) FL_FP_ATTRIBUTES_VIRTUAL );
TOOL_ACTION EDA_3D_ACTIONS::showBBoxes( "3DViewer.Control.showBoundingBoxes",
AS_GLOBAL, 0, "",
_( "Show Model Bounding Boxes" ), _( "Show Model Bounding Boxes" ),
BITMAPS::ortho, AF_NONE );
BITMAPS::ortho, AF_NONE, (void*) FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
TOOL_ACTION EDA_3D_ACTIONS::toggleRealisticMode( "3DViewer.Control.toggleRealisticMode",
AS_GLOBAL, 0, "",
_( "Toggle realistic mode" ), _( "Toggle realistic mode" ) );
_( "Toggle realistic mode" ), _( "Toggle realistic mode" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_USE_REALISTIC_MODE );
TOOL_ACTION EDA_3D_ACTIONS::toggleBoardBody( "3DViewer.Control.toggleBoardBody",
AS_GLOBAL, 0, "",
_( "Toggle board body display" ), _( "Toggle board body display" ) );
_( "Toggle board body display" ), _( "Toggle board body display" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_SHOW_BOARD_BODY );
TOOL_ACTION EDA_3D_ACTIONS::showAxis( "3DViewer.Control.showAxis",
AS_GLOBAL, 0, "",
_( "Show 3D Axis" ), _( "Show 3D Axis" ),
BITMAPS::axis3d_front, AF_NONE );
BITMAPS::axis3d_front, AF_NONE, (void*) FL_AXIS );
TOOL_ACTION EDA_3D_ACTIONS::toggleZones( "3DViewer.Control.toggleZones",
AS_GLOBAL, 0, "",
_( "Toggle zone display" ), _( "Toggle zone display" ) );
_( "Toggle zone display" ), _( "Toggle zone display" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_ZONE );
TOOL_ACTION EDA_3D_ACTIONS::toggleAdhesive( "3DViewer.Control.toggleAdhesive",
AS_GLOBAL, 0, "",
_( "Toggle adhesive display" ), _( "Toggle display of adhesive layers" ) );
_( "Toggle adhesive display" ), _( "Toggle display of adhesive layers" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_ADHESIVE );
TOOL_ACTION EDA_3D_ACTIONS::toggleSilk( "3DViewer.Control.toggleSilk",
AS_GLOBAL, 0, "",
_( "Toggle silkscreen display" ), _( "Toggle display of silkscreen layers" ) );
_( "Toggle silkscreen display" ), _( "Toggle display of silkscreen layers" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_SILKSCREEN );
TOOL_ACTION EDA_3D_ACTIONS::toggleSolderMask( "3DViewer.Control.toggleSolderMask",
AS_GLOBAL, 0, "",
_( "Toggle solder mask display" ), _( "Toggle display of solder mask layers" ) );
_( "Toggle solder mask display" ), _( "Toggle display of solder mask layers" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_SOLDERMASK );
TOOL_ACTION EDA_3D_ACTIONS::toggleSolderPaste( "3DViewer.Control.toggleSolderPaste",
AS_GLOBAL, 0, "",
_( "Toggle solder paste display" ), _( "Toggle display of solder paste layers" ) );
_( "Toggle solder paste display" ), _( "Toggle display of solder paste layers" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_SOLDERPASTE );
TOOL_ACTION EDA_3D_ACTIONS::toggleComments( "3DViewer.Control.toggleComments",
AS_GLOBAL, 0, "",
_( "Toggle comments display" ), _( "Toggle display of comments and drawings layers" ) );
_( "Toggle comments display" ), _( "Toggle display of comments and drawings layers" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_COMMENTS );
TOOL_ACTION EDA_3D_ACTIONS::toggleECO( "3DViewer.Control.toggleECO",
AS_GLOBAL, 0, "",
_( "Toggle ECO display" ), _( "Toggle display of ECO layers" ) );
_( "Toggle ECO display" ), _( "Toggle display of ECO layers" ),
BITMAPS::INVALID_BITMAP, AF_NONE, (void*) FL_ECO );
@@ -78,7 +78,6 @@ public:
static TOOL_ACTION showTHT;
static TOOL_ACTION showSMD;
static TOOL_ACTION showVirtual;
static TOOL_ACTION showNotInPosFile;
static TOOL_ACTION showBBoxes;
static TOOL_ACTION toggleRealisticMode;
static TOOL_ACTION toggleBoardBody;
@@ -30,15 +30,43 @@
using namespace std::placeholders;
SELECTION_CONDITION EDA_3D_CONDITIONS::MaterialMode( MATERIAL_MODE aMaterial )
{
return std::bind( &EDA_3D_CONDITIONS::materialModeFunction, _1, m_adapter, aMaterial );
}
SELECTION_CONDITION EDA_3D_CONDITIONS::Flag( DISPLAY3D_FLG aFlag )
{
return std::bind( &EDA_3D_CONDITIONS::flagFunction, _1, m_adapter, aFlag );
}
SELECTION_CONDITION EDA_3D_CONDITIONS::GridSize( GRID3D_TYPE aGridSize )
{
return std::bind( &EDA_3D_CONDITIONS::gridSizeFunction, _1, m_adapter, aGridSize );
}
bool EDA_3D_CONDITIONS::materialModeFunction( const SELECTION& aSelection,
BOARD_ADAPTER* aAdapter,
MATERIAL_MODE aMaterial )
{
return aAdapter->GetMaterialMode() == aMaterial;
}
bool EDA_3D_CONDITIONS::flagFunction( const SELECTION& aSelection,
BOARD_ADAPTER* aAdapter,
DISPLAY3D_FLG aFlag )
{
return aAdapter->GetFlag( aFlag );
}
bool EDA_3D_CONDITIONS::gridSizeFunction( const SELECTION& aSelection,
BOARD_ADAPTER* aAdapter,
GRID3D_TYPE aGridSize )
{
return aAdapter->m_Cfg->m_Render.grid_type == aGridSize;
return aAdapter->GetGridType() == aGridSize;
}
@@ -44,6 +44,24 @@ public:
m_adapter( aAdapter )
{}
/**
* Creates a functor that tests if a specific material mode is active.
*
* @param aAdapter is the board adapter the setting is in
* @param aMaterial is the material mode to test for.
* @return Functor testing if a material mode is active.
*/
SELECTION_CONDITION MaterialMode( MATERIAL_MODE aMaterial );
/**
* Creates a functor that tests if the board adapter has a flag set currently.
*
* @param aAdapter is the board adapter the setting is in
* @param aFlag is the flag to test for.
* @return Functor testing if the flag is set.
*/
SELECTION_CONDITION Flag( DISPLAY3D_FLG aFlag );
/**
* Creates a functor that tests the current grid size.
*
@@ -54,6 +72,14 @@ public:
SELECTION_CONDITION GridSize( GRID3D_TYPE aGridSize );
private:
///< Helper function used by MaterialMode()
static bool materialModeFunction( const SELECTION& aSelection, BOARD_ADAPTER* aAdapter,
MATERIAL_MODE aMaterial );
///< Helper function used by Flag()
static bool flagFunction( const SELECTION& aSelection, BOARD_ADAPTER* aAdapter,
DISPLAY3D_FLG aFlag );
///< Helper function used by GridDize()
static bool gridSizeFunction( const SELECTION& aSelection, BOARD_ADAPTER* aAdapter,
GRID3D_TYPE aGridSize );
+47 -86
View File
@@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2021 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
@@ -179,17 +179,17 @@ int EDA_3D_CONTROLLER::RotateView( const TOOL_EVENT& aEvent )
switch( aEvent.Parameter<ROTATION_DIR>() )
{
case ROTATION_DIR::X_CW: m_camera->RotateX( -rotIncrement ); break;
case ROTATION_DIR::X_CW: m_camera->RotateX( -rotIncrement ); break;
case ROTATION_DIR::X_CCW: m_camera->RotateX( rotIncrement ); break;
/// Y rotations are backward b/c the RHR has Y pointing into the screen
case ROTATION_DIR::Y_CW: m_camera->RotateY( rotIncrement ); break;
case ROTATION_DIR::Y_CCW: m_camera->RotateY( -rotIncrement ); break;
case ROTATION_DIR::Z_CW: m_camera->RotateZ( -rotIncrement ); break;
case ROTATION_DIR::Y_CW: m_camera->RotateY( rotIncrement ); break;
case ROTATION_DIR::Y_CCW: m_camera->RotateY( -rotIncrement ); break;
case ROTATION_DIR::Z_CW: m_camera->RotateZ( -rotIncrement ); break;
case ROTATION_DIR::Z_CCW: m_camera->RotateZ( rotIncrement ); break;
default: wxFAIL; break;
default: wxFAIL; break;
}
if( m_boardAdapter->m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( m_boardAdapter->GetRenderEngine() == RENDER_ENGINE::OPENGL )
m_canvas->Request_refresh();
else
m_canvas->RenderRaytracingRequest();
@@ -200,7 +200,9 @@ int EDA_3D_CONTROLLER::RotateView( const TOOL_EVENT& aEvent )
int EDA_3D_CONTROLLER::SetMaterial( const TOOL_EVENT& aEvent )
{
m_boardAdapter->m_Cfg->m_Render.material_mode = aEvent.Parameter<MATERIAL_MODE>();
MATERIAL_MODE mode = aEvent.Parameter<MATERIAL_MODE>();
m_boardAdapter->SetMaterialMode( mode );
if( auto* viewer = dynamic_cast<EDA_3D_VIEWER_FRAME*>( m_toolMgr->GetToolHolder() ) )
viewer->NewDisplay( true );
@@ -215,7 +217,7 @@ int EDA_3D_CONTROLLER::ToggleOrtho( const TOOL_EVENT& aEvent )
{
m_camera->ToggleProjection();
if( m_boardAdapter->m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
if( m_boardAdapter->GetRenderEngine() == RENDER_ENGINE::OPENGL )
m_canvas->Request_refresh();
else
m_canvas->RenderRaytracingRequest();
@@ -223,96 +225,56 @@ int EDA_3D_CONTROLLER::ToggleOrtho( const TOOL_EVENT& aEvent )
return 0;
}
int EDA_3D_CONTROLLER::ToggleVisibility( const TOOL_EVENT& aEvent )
{
bool reload = false;
DISPLAY3D_FLG flag = aEvent.Parameter<DISPLAY3D_FLG>();
#define FLIP( x ) x = !x
m_boardAdapter->SetFlag( flag, !m_boardAdapter->GetFlag( flag ) );
if( aEvent.IsAction( &EDA_3D_ACTIONS::showTHT ) )
switch( flag )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_footprints_normal );
reload = true;
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::showSMD ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_footprints_insert );
reload = true;
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::showVirtual ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_footprints_virtual );
reload = true;
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::showNotInPosFile ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_footprints_not_in_posfile );
reload = true;
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::showBBoxes ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.opengl_show_model_bbox );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleRealisticMode ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.realistic );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleBoardBody ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_board_body );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::showAxis ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_axis );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleZones ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_zones );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleAdhesive ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_adhesive );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleSilk ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_silkscreen );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleSolderMask ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_soldermask );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleSolderPaste ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_solderpaste );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleComments ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_comments );
}
else if( aEvent.IsAction( &EDA_3D_ACTIONS::toggleECO ) )
{
FLIP( m_boardAdapter->m_Cfg->m_Render.show_eco );
}
// These commands do not request a 3D scene rebuild (and do not exist in raytracing):
case FL_RENDER_OPENGL_SHOW_MODEL_BBOX:
case FL_AXIS:
m_canvas->Request_refresh();
break;
if( reload )
{
if( m_boardAdapter->m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL )
// These commands do not request a 3D scene rebuild and exist in raytracing:
case FL_RENDER_RAYTRACING_SHADOWS:
case FL_RENDER_RAYTRACING_REFRACTIONS:
case FL_RENDER_RAYTRACING_REFLECTIONS:
case FL_RENDER_RAYTRACING_ANTI_ALIASING:
if( m_boardAdapter->GetRenderEngine() == RENDER_ENGINE::OPENGL )
m_canvas->Request_refresh();
else
m_canvas->RenderRaytracingRequest();
break;
case FL_FP_ATTRIBUTES_NORMAL:
case FL_FP_ATTRIBUTES_NORMAL_INSERT:
case FL_FP_ATTRIBUTES_VIRTUAL:
// Loading 3D shapes can be needed if not yet loaded
if( m_boardAdapter->GetRenderEngine() == RENDER_ENGINE::OPENGL )
{
auto* renderer = static_cast<RENDER_3D_OPENGL*>( m_canvas->GetCurrentRender() );
renderer->Load3dModelsIfNeeded();
RENDER_3D_OPENGL* render = static_cast<RENDER_3D_OPENGL*>( m_canvas->GetCurrentRender() );
render->Load3dModelsIfNeeded();
m_canvas->Request_refresh();
}
else
{
m_canvas->RenderRaytracingRequest();
}
}
else
break;
default:
{
if( auto viewer = dynamic_cast<EDA_3D_VIEWER_FRAME*>( m_toolMgr->GetToolHolder() ) )
viewer->NewDisplay( true );
else
m_canvas->Request_refresh();
break;
}
}
return 0;
@@ -321,7 +283,8 @@ int EDA_3D_CONTROLLER::ToggleVisibility( const TOOL_EVENT& aEvent )
int EDA_3D_CONTROLLER::On3DGridSelection( const TOOL_EVENT& aEvent )
{
m_boardAdapter->m_Cfg->m_Render.grid_type = aEvent.Parameter<GRID3D_TYPE>();
GRID3D_TYPE grid = aEvent.Parameter<GRID3D_TYPE>();
m_boardAdapter->SetGridType( grid );
if( m_canvas )
m_canvas->Request_refresh();
@@ -436,8 +399,6 @@ void EDA_3D_CONTROLLER::setTransitions()
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::showTHT.MakeEvent() );
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::showSMD.MakeEvent() );
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::showVirtual.MakeEvent() );
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::showNotInPosFile.MakeEvent() );
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::showVirtual.MakeEvent() );
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::showBBoxes.MakeEvent() );
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::toggleRealisticMode.MakeEvent() );
Go( &EDA_3D_CONTROLLER::ToggleVisibility, EDA_3D_ACTIONS::toggleBoardBody.MakeEvent() );
+10 -13
View File
@@ -11,7 +11,6 @@ include_directories(
3d_viewer
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/include/gal/opengl
${CMAKE_SOURCE_DIR}/common/dialogs
${INC_AFTER}
)
@@ -111,17 +110,15 @@ add_library(3d-viewer STATIC ${3D-VIEWER_SRCS})
add_dependencies( 3d-viewer pcbcommon )
target_link_libraries( 3d-viewer
PRIVATE
gal
kimath
nlohmann_json
${Boost_LIBRARIES}
${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES}
kicad_3dsg )
gal
kimath
${Boost_LIBRARIES}
${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES}
kicad_3dsg )
target_include_directories( 3d-viewer PRIVATE
$<TARGET_PROPERTY:nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>
)
add_subdirectory( 3d_cache )
message( STATUS "Including 3Dconnexion SpaceMouse navigation support in 3d-viewer" )
add_subdirectory( 3d_navlib )
target_link_libraries( 3d-viewer PRIVATE 3d-viewer_navlib)
+4 -5
View File
@@ -33,11 +33,10 @@
/// Anti-aliasing options
enum class ANTIALIASING_MODE
{
// Do not change these numbers, they are stored in the config file
AA_NONE = 0,
AA_2X = 1,
AA_4X = 2,
AA_8X = 3
AA_NONE,
AA_2X,
AA_4X,
AA_8X
};
/**
+1 -2
View File
@@ -1,8 +1,7 @@
Credits
=======
The 3D-viewer contains parts, source code or adaptations or implementations that should give the following
aknowledgments:
The 3D-viewer contains parts, source code or adaptations or implementations that should give the following aknowledge:
cbvh_packet_traversal.cpp
+1 -1
View File
@@ -45,7 +45,7 @@ bool S3D::Select3DModel( wxWindow* aParent, S3D_CACHE* aCache, wxString& prevMod
bool S3D::Configure3DPaths( wxWindow* aParent, FILENAME_RESOLVER* aResolver )
{
DIALOG_CONFIGURE_PATHS dlg( aParent );
DIALOG_CONFIGURE_PATHS dlg( aParent, aResolver );
// Use QuasiModal so that HTML help window will work
return( dlg.ShowQuasiModal() == wxID_OK );
+2 -3
View File
@@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-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
@@ -34,7 +34,6 @@
#include <common_ogl/ogl_attr_list.h>
#include <filename_resolver.h>
#include <pcbnew/footprint.h>
#include <wx_filename.h>
#include <wx/filedlg.h>
@@ -165,7 +164,7 @@ bool DIALOG_SELECT_3DMODEL::TransferDataFromWindow()
// file selection mode: retrieve the filename and specify a
// path relative to one of the config paths
wxFileName fname = m_FileTree->GetFilePath();
fname.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
fname.Normalize();
m_model->m_Filename = m_resolver->ShortenPath( fname.GetFullPath() );
return true;
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -57,7 +57,7 @@ DIALOG_SELECT_3D_MODEL_BASE::DIALOG_SELECT_3D_MODEL_BASE( wxWindow* parent, wxWi
m_stDirChoice = new wxStaticText( this, wxID_ANY, _("Available paths:"), wxDefaultPosition, wxDefaultSize, 0 );
m_stDirChoice->Wrap( -1 );
bSizerLower->Add( m_stDirChoice, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxTOP, 5 );
bSizerLower->Add( m_stDirChoice, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxArrayString m_dirChoicesChoices;
m_dirChoices = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dirChoicesChoices, 0 );
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="16" />
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration">; </property>
<property name="code_generation">C++</property>
@@ -14,7 +14,6 @@
<property name="file">dialog_select_3d_model_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_select_3d_model_base</property>
@@ -26,7 +25,6 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@@ -52,7 +50,6 @@
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
<property name="title">Select 3D Model</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
@@ -330,7 +327,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxTOP</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@@ -467,7 +464,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -22,10 +22,10 @@
#include <wx/splitter.h>
#include <wx/stattext.h>
#include <wx/choice.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@@ -51,7 +51,7 @@ class DIALOG_SELECT_3D_MODEL_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, override them in your derived class
// Virtual event handlers, overide them in your derived class
virtual void OnFileActivated( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSelectionChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void SetRootDir( wxCommandEvent& event ) { event.Skip(); }
@@ -61,7 +61,6 @@ class DIALOG_SELECT_3D_MODEL_BASE : public DIALOG_SHIM
public:
DIALOG_SELECT_3D_MODEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select 3D Model"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_SELECT_3D_MODEL_BASE();
void m_splitterWinOnIdle( wxIdleEvent& )
+19 -36
View File
@@ -27,30 +27,31 @@
#include <pgm_base.h>
PANEL_3D_COLORS::PANEL_3D_COLORS( wxWindow* aParent ) :
PANEL_3D_COLORS_BASE( aParent )
PANEL_3D_COLORS::PANEL_3D_COLORS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) :
PANEL_3D_COLORS_BASE( aParent ),
m_boardAdapter( aFrame->GetAdapter() )
{
m_backgroundTop->SetDefaultColor( BOARD_ADAPTER::g_DefaultBackgroundTop );
m_backgroundBottom->SetDefaultColor( BOARD_ADAPTER::g_DefaultBackgroundBot );
m_backgroundTop->SetDefaultColor( m_boardAdapter.g_DefaultBackgroundTop );
m_backgroundBottom->SetDefaultColor( m_boardAdapter.g_DefaultBackgroundBot );
m_silkscreenTop->SetUserColors( &BOARD_ADAPTER::g_SilkscreenColors );
m_silkscreenTop->SetDefaultColor( BOARD_ADAPTER::g_DefaultSilkscreen );
m_silkscreenBottom->SetUserColors( &BOARD_ADAPTER::g_SilkscreenColors );
m_silkscreenBottom->SetDefaultColor( BOARD_ADAPTER::g_DefaultSilkscreen );
m_silkscreenTop->SetUserColors( &m_boardAdapter.g_SilkscreenColors );
m_silkscreenTop->SetDefaultColor( m_boardAdapter.g_DefaultSilkscreen );
m_silkscreenBottom->SetUserColors( &m_boardAdapter.g_SilkscreenColors );
m_silkscreenBottom->SetDefaultColor( m_boardAdapter.g_DefaultSilkscreen );
m_solderMaskTop->SetUserColors( &BOARD_ADAPTER::g_MaskColors );
m_solderMaskTop->SetDefaultColor( BOARD_ADAPTER::g_DefaultSolderMask );
m_solderMaskBottom->SetUserColors( &BOARD_ADAPTER::g_MaskColors );
m_solderMaskBottom->SetDefaultColor( BOARD_ADAPTER::g_DefaultSolderMask );
m_solderMaskTop->SetUserColors( &m_boardAdapter.g_MaskColors );
m_solderMaskTop->SetDefaultColor( m_boardAdapter.g_DefaultSolderMask );
m_solderMaskBottom->SetUserColors( &m_boardAdapter.g_MaskColors );
m_solderMaskBottom->SetDefaultColor( m_boardAdapter.g_DefaultSolderMask );
m_solderPaste->SetUserColors( &BOARD_ADAPTER::g_PasteColors );
m_solderPaste->SetDefaultColor( BOARD_ADAPTER::g_DefaultSolderPaste );
m_solderPaste->SetUserColors( &m_boardAdapter.g_PasteColors );
m_solderPaste->SetDefaultColor( m_boardAdapter.g_DefaultSolderPaste );
m_surfaceFinish->SetUserColors( &BOARD_ADAPTER::g_FinishColors );
m_surfaceFinish->SetDefaultColor( BOARD_ADAPTER::g_DefaultSurfaceFinish );
m_surfaceFinish->SetUserColors( &m_boardAdapter.g_FinishColors );
m_surfaceFinish->SetDefaultColor( m_boardAdapter.g_DefaultSurfaceFinish );
m_boardBody->SetUserColors( &BOARD_ADAPTER::g_BoardColors );
m_boardBody->SetDefaultColor( BOARD_ADAPTER::g_DefaultBoardBody );
m_boardBody->SetUserColors( &m_boardAdapter.g_BoardColors );
m_boardBody->SetDefaultColor( m_boardAdapter.g_DefaultBoardBody );
}
@@ -107,21 +108,3 @@ bool PANEL_3D_COLORS::TransferDataFromWindow()
return true;
}
void PANEL_3D_COLORS::ResetPanel()
{
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
m_backgroundTop->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_BACKGROUND_TOP ), false );
m_backgroundBottom->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_BACKGROUND_BOTTOM ), false );
m_silkscreenTop->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SILKSCREEN_TOP ), false );
m_silkscreenBottom->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SILKSCREEN_BOTTOM ), false );
m_solderMaskTop->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SOLDERMASK_TOP ), false );
m_solderMaskBottom->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SOLDERMASK_BOTTOM ), false );
m_solderPaste->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SOLDERPASTE ), false );
m_surfaceFinish->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_COPPER ), false );
m_boardBody->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_BOARD ), false );
m_boardStackupRB->SetValue( true );
}
+6 -2
View File
@@ -30,12 +30,16 @@
class PANEL_3D_COLORS : public PANEL_3D_COLORS_BASE
{
public:
explicit PANEL_3D_COLORS( wxWindow* aParent );
explicit PANEL_3D_COLORS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent );
/// Automatically called when clicking on the OK button
bool TransferDataFromWindow() override;
/// Automatically called after creating the dialog
bool TransferDataToWindow() override;
void ResetPanel() override;
private:
BOARD_ADAPTER& m_boardAdapter;
};
+41 -40
View File
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -11,35 +11,34 @@
///////////////////////////////////////////////////////////////////////////
PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name )
PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_environmentLable = new wxStaticText( this, wxID_ANY, _("Environment Colors"), wxDefaultPosition, wxDefaultSize, 0 );
m_environmentLable->Wrap( -1 );
bSizerMain->Add( m_environmentLable, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 13 );
wxBoxSizer* bSizerMargins;
bSizerMargins = new wxBoxSizer( wxVERTICAL );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxBOTTOM, 5 );
wxStaticBoxSizer* sbEnvironmentColors;
sbEnvironmentColors = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Environment Colors") ), wxVERTICAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 5, 0 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
backgroundTopLabel = new wxStaticText( this, wxID_ANY, _("Background gradient start:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundTopLabel = new wxStaticText( sbEnvironmentColors->GetStaticBox(), wxID_ANY, _("Background gradient start:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundTopLabel->Wrap( -1 );
fgSizer1->Add( backgroundTopLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_backgroundTop = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_backgroundTop = new COLOR_SWATCH( sbEnvironmentColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_backgroundTop, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
backgroundBotLabel = new wxStaticText( this, wxID_ANY, _("Background gradient end:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundBotLabel = new wxStaticText( sbEnvironmentColors->GetStaticBox(), wxID_ANY, _("Background gradient end:"), wxDefaultPosition, wxDefaultSize, 0 );
backgroundBotLabel->Wrap( -1 );
fgSizer1->Add( backgroundBotLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_backgroundBottom = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_backgroundBottom = new COLOR_SWATCH( sbEnvironmentColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_backgroundBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
@@ -48,49 +47,45 @@ PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, con
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
solderPasteLabel = new wxStaticText( this, wxID_ANY, _("Solder paste:"), wxDefaultPosition, wxDefaultSize, 0 );
solderPasteLabel = new wxStaticText( sbEnvironmentColors->GetStaticBox(), wxID_ANY, _("Solder paste:"), wxDefaultPosition, wxDefaultSize, 0 );
solderPasteLabel->Wrap( -1 );
fgSizer1->Add( solderPasteLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_solderPaste = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_solderPaste = new COLOR_SWATCH( sbEnvironmentColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_solderPaste, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( fgSizer1, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
sbEnvironmentColors->Add( fgSizer1, 0, wxBOTTOM, 10 );
bSizerMain->Add( 0, 15, 0, wxEXPAND, 5 );
bSizerMargins->Add( sbEnvironmentColors, 0, wxEXPAND|wxBOTTOM, 5 );
m_boardColorsLabel = new wxStaticText( this, wxID_ANY, _("Board Colors"), wxDefaultPosition, wxDefaultSize, 0 );
m_boardColorsLabel->Wrap( -1 );
bSizerMain->Add( m_boardColorsLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 13 );
wxStaticBoxSizer* sbBoardColors;
sbBoardColors = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Board Colors") ), wxVERTICAL );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline2, 0, wxEXPAND|wxBOTTOM, 5 );
m_boardStackupRB = new wxRadioButton( sbBoardColors->GetStaticBox(), wxID_ANY, _("Use board stackup colors"), wxDefaultPosition, wxDefaultSize, 0 );
sbBoardColors->Add( m_boardStackupRB, 0, wxBOTTOM, 5 );
m_boardStackupRB = new wxRadioButton( this, wxID_ANY, _("Use board stackup colors"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMain->Add( m_boardStackupRB, 0, wxTOP|wxBOTTOM|wxLEFT, 8 );
m_specificColorsRB = new wxRadioButton( this, wxID_ANY, _("Use colors:"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMain->Add( m_specificColorsRB, 0, wxTOP|wxBOTTOM|wxLEFT, 8 );
m_specificColorsRB = new wxRadioButton( sbBoardColors->GetStaticBox(), wxID_ANY, _("Use colors:"), wxDefaultPosition, wxDefaultSize, 0 );
sbBoardColors->Add( m_specificColorsRB, 0, wxTOP|wxBOTTOM, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 2, 5, 0 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
silkscreenTopLabel = new wxStaticText( this, wxID_ANY, _("Silkscreen top:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenTopLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Silkscreen top:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenTopLabel->Wrap( -1 );
fgSizer2->Add( silkscreenTopLabel, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 );
m_silkscreenTop = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_silkscreenTop = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_silkscreenTop, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
silkscreenBottomLabel = new wxStaticText( this, wxID_ANY, _("Silkscreen bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenBottomLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Silkscreen bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
silkscreenBottomLabel->Wrap( -1 );
fgSizer2->Add( silkscreenBottomLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_silkscreenBottom = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_silkscreenBottom = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_silkscreenBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
@@ -99,18 +94,18 @@ PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, con
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
solderMaskTopLabel = new wxStaticText( this, wxID_ANY, _("Solder mask top:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskTopLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Solder mask top:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskTopLabel->Wrap( -1 );
fgSizer2->Add( solderMaskTopLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_solderMaskTop = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_solderMaskTop = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_solderMaskTop, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
solderMaskBottomLabel = new wxStaticText( this, wxID_ANY, _("Solder mask bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskBottomLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Solder mask bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
solderMaskBottomLabel->Wrap( -1 );
fgSizer2->Add( solderMaskBottomLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_solderMaskBottom = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_solderMaskBottom = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_solderMaskBottom, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
@@ -119,11 +114,11 @@ PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, con
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
surfaceFinishLabel = new wxStaticText( this, wxID_ANY, _("Copper/surface finish:"), wxDefaultPosition, wxDefaultSize, 0 );
surfaceFinishLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Copper/surface finish:"), wxDefaultPosition, wxDefaultSize, 0 );
surfaceFinishLabel->Wrap( -1 );
fgSizer2->Add( surfaceFinishLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
m_surfaceFinish = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_surfaceFinish = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_surfaceFinish, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
@@ -132,15 +127,21 @@ PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, con
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
boardBodyLabel = new wxStaticText( this, wxID_ANY, _("Board body:"), wxDefaultPosition, wxDefaultSize, 0 );
boardBodyLabel = new wxStaticText( sbBoardColors->GetStaticBox(), wxID_ANY, _("Board body:"), wxDefaultPosition, wxDefaultSize, 0 );
boardBodyLabel->Wrap( -1 );
fgSizer2->Add( boardBodyLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 20 );
fgSizer2->Add( boardBodyLabel, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 );
m_boardBody = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_boardBody, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_boardBody = new COLOR_SWATCH( sbBoardColors->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_boardBody, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( fgSizer2, 1, wxEXPAND|wxLEFT, 8 );
sbBoardColors->Add( fgSizer2, 1, wxEXPAND, 5 );
bSizerMargins->Add( sbBoardColors, 0, wxEXPAND|wxTOP, 5 );
bSizerMain->Add( bSizerMargins, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
this->SetSizer( bSizerMain );
File diff suppressed because it is too large Load Diff
+3 -8
View File
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -12,15 +12,14 @@
#include <wx/intl.h>
class COLOR_SWATCH;
#include "widgets/resettable_panel.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statline.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobut.h>
#include <wx/panel.h>
@@ -30,21 +29,17 @@ class COLOR_SWATCH;
///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_3D_COLORS_BASE
///////////////////////////////////////////////////////////////////////////////
class PANEL_3D_COLORS_BASE : public RESETTABLE_PANEL
class PANEL_3D_COLORS_BASE : public wxPanel
{
private:
protected:
wxStaticText* m_environmentLable;
wxStaticLine* m_staticline1;
wxStaticText* backgroundTopLabel;
COLOR_SWATCH* m_backgroundTop;
wxStaticText* backgroundBotLabel;
COLOR_SWATCH* m_backgroundBottom;
wxStaticText* solderPasteLabel;
COLOR_SWATCH* m_solderPaste;
wxStaticText* m_boardColorsLabel;
wxStaticLine* m_staticline2;
wxRadioButton* m_boardStackupRB;
wxRadioButton* m_specificColorsRB;
wxStaticText* silkscreenTopLabel;
+67 -62
View File
@@ -22,15 +22,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <3d_enums.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <eda_3d_viewer_settings.h>
#include "panel_3D_display_options.h"
#include <3d_canvas/board_adapter.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <3d_viewer/tools/eda_3d_controller.h>
#include <tool/tool_manager.h>
PANEL_3D_DISPLAY_OPTIONS::PANEL_3D_DISPLAY_OPTIONS( wxWindow* aParent ) :
PANEL_3D_DISPLAY_OPTIONS_BASE( aParent )
PANEL_3D_DISPLAY_OPTIONS::PANEL_3D_DISPLAY_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) :
PANEL_3D_DISPLAY_OPTIONS_BASE( aParent ),
m_frame( aFrame ),
m_settings( aFrame->GetAdapter() ),
m_canvas( aFrame->GetCanvas() )
{
}
@@ -42,38 +45,40 @@ void PANEL_3D_DISPLAY_OPTIONS::OnCheckEnableAnimation( wxCommandEvent& event )
}
void PANEL_3D_DISPLAY_OPTIONS::loadViewSettings( EDA_3D_VIEWER_SETTINGS* aCfg )
{
// Check/uncheck checkboxes
m_checkBoxRealisticMode->SetValue( aCfg->m_Render.realistic );
m_checkBoxBoardBody->SetValue( aCfg->m_Render.show_board_body );
m_checkBoxAreas->SetValue( aCfg->m_Render.show_zones );
m_checkBoxSilkscreen->SetValue( aCfg->m_Render.show_silkscreen );
m_checkBoxSolderMask->SetValue( aCfg->m_Render.show_soldermask );
m_checkBoxSolderpaste->SetValue( aCfg->m_Render.show_solderpaste );
m_checkBoxAdhesive->SetValue( aCfg->m_Render.show_adhesive );
m_checkBoxComments->SetValue( aCfg->m_Render.show_comments );
m_checkBoxECO->SetValue( aCfg->m_Render.show_eco );
m_checkBoxSubtractMaskFromSilk->SetValue( aCfg->m_Render.subtract_mask_from_silk );
m_checkBoxClipSilkOnViaAnnulus->SetValue( aCfg->m_Render.clip_silk_on_via_annulus );
m_checkBoxRenderPlatedPadsAsPlated->SetValue( aCfg->m_Render.renderPlatedPadsAsPlated );
m_materialProperties->SetSelection( static_cast<int>( aCfg->m_Render.material_mode ) );
// Camera Options
m_checkBoxEnableAnimation->SetValue( aCfg->m_Camera.animation_enabled );
m_sliderAnimationSpeed->SetValue( aCfg->m_Camera.moving_speed_multiplier );
m_staticAnimationSpeed->Enable( aCfg->m_Camera.animation_enabled );
m_sliderAnimationSpeed->Enable( aCfg->m_Camera.animation_enabled );
m_spinCtrlRotationAngle->SetValue( aCfg->m_Camera.rotation_increment );
}
bool PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow()
{
EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
// Check/uncheck checkboxes
m_checkBoxRealisticMode->SetValue( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) );
m_checkBoxBoardBody->SetValue( m_settings.GetFlag( FL_SHOW_BOARD_BODY ) );
m_checkBoxAreas->SetValue( m_settings.GetFlag( FL_ZONE ) );
loadViewSettings( cfg );
m_checkBoxSilkscreen->SetValue( m_settings.GetFlag( FL_SILKSCREEN ) );
m_checkBoxSolderMask->SetValue( m_settings.GetFlag( FL_SOLDERMASK ) );
m_checkBoxSolderpaste->SetValue( m_settings.GetFlag( FL_SOLDERPASTE ) );
m_checkBoxAdhesive->SetValue( m_settings.GetFlag( FL_ADHESIVE ) );
m_checkBoxComments->SetValue( m_settings.GetFlag( FL_COMMENTS ) );
m_checkBoxECO->SetValue( m_settings.GetFlag( FL_ECO ) );
m_checkBoxSubtractMaskFromSilk->SetValue( m_settings.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) );
m_checkBoxClipSilkOnViaAnnulus->SetValue( m_settings.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) );
m_checkBoxRenderPlatedPadsAsPlated->SetValue(
m_settings.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) );
switch( m_settings.GetMaterialMode() )
{
default:
case MATERIAL_MODE::NORMAL: m_materialProperties->SetSelection( 0 ); break;
case MATERIAL_MODE::DIFFUSE_ONLY: m_materialProperties->SetSelection( 1 ); break;
case MATERIAL_MODE::CAD_MODE: m_materialProperties->SetSelection( 2 ); break;
}
// Camera Options
m_checkBoxEnableAnimation->SetValue( m_canvas->GetAnimationEnabled() );
m_sliderAnimationSpeed->SetValue( m_canvas->GetMovingSpeedMultiplier() );
m_staticAnimationSpeed->Enable( m_canvas->GetAnimationEnabled() );
m_sliderAnimationSpeed->Enable( m_canvas->GetAnimationEnabled() );
EDA_3D_CONTROLLER* ctrlTool = m_frame->GetToolManager()->GetTool<EDA_3D_CONTROLLER>();
m_spinCtrlRotationAngle->SetValue( ctrlTool->GetRotationIncrement() );
return true;
}
@@ -81,41 +86,41 @@ bool PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow()
bool PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow()
{
EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
// Set render mode
cfg->m_Render.realistic = m_checkBoxRealisticMode->GetValue();
m_settings.SetFlag( FL_USE_REALISTIC_MODE, m_checkBoxRealisticMode->GetValue() );
// Set visibility of items
cfg->m_Render.show_board_body = m_checkBoxBoardBody->GetValue();
cfg->m_Render.show_zones = m_checkBoxAreas->GetValue();
cfg->m_Render.subtract_mask_from_silk = m_checkBoxSubtractMaskFromSilk->GetValue();
cfg->m_Render.clip_silk_on_via_annulus = m_checkBoxClipSilkOnViaAnnulus->GetValue();
cfg->m_Render.renderPlatedPadsAsPlated = m_checkBoxRenderPlatedPadsAsPlated->GetValue();
m_settings.SetFlag( FL_SHOW_BOARD_BODY, m_checkBoxBoardBody->GetValue() );
m_settings.SetFlag( FL_ZONE, m_checkBoxAreas->GetValue() );
m_settings.SetFlag( FL_SUBTRACT_MASK_FROM_SILK, m_checkBoxSubtractMaskFromSilk->GetValue() );
m_settings.SetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS, m_checkBoxClipSilkOnViaAnnulus->GetValue() );
m_settings.SetFlag( FL_RENDER_PLATED_PADS_AS_PLATED,
m_checkBoxRenderPlatedPadsAsPlated->GetValue() );
cfg->m_Render.material_mode = static_cast<MATERIAL_MODE>( m_materialProperties->GetSelection() );
switch( m_materialProperties->GetSelection() )
{
default:
case 0: m_settings.SetMaterialMode( MATERIAL_MODE::NORMAL ); break;
case 1: m_settings.SetMaterialMode( MATERIAL_MODE::DIFFUSE_ONLY ); break;
case 2: m_settings.SetMaterialMode( MATERIAL_MODE::CAD_MODE ); break;
}
// Set Layer visibility
cfg->m_Render.show_silkscreen = m_checkBoxSilkscreen->GetValue();
cfg->m_Render.show_soldermask = m_checkBoxSolderMask->GetValue();
cfg->m_Render.show_solderpaste = m_checkBoxSolderpaste->GetValue();
cfg->m_Render.show_adhesive = m_checkBoxAdhesive->GetValue();
cfg->m_Render.show_comments = m_checkBoxComments->GetValue();
cfg->m_Render.show_eco = m_checkBoxECO->GetValue( );
m_settings.SetFlag( FL_SILKSCREEN, m_checkBoxSilkscreen->GetValue() );
m_settings.SetFlag( FL_SOLDERMASK, m_checkBoxSolderMask->GetValue() );
m_settings.SetFlag( FL_SOLDERPASTE, m_checkBoxSolderpaste->GetValue() );
m_settings.SetFlag( FL_ADHESIVE, m_checkBoxAdhesive->GetValue() );
m_settings.SetFlag( FL_COMMENTS, m_checkBoxComments->GetValue() );
m_settings.SetFlag( FL_ECO, m_checkBoxECO->GetValue( ) );
// Camera Options
cfg->m_Camera.animation_enabled = m_checkBoxEnableAnimation->GetValue();
cfg->m_Camera.moving_speed_multiplier = m_sliderAnimationSpeed->GetValue();
cfg->m_Camera.rotation_increment = m_spinCtrlRotationAngle->GetValue();
m_canvas->SetAnimationEnabled( m_checkBoxEnableAnimation->GetValue());
m_canvas->SetMovingSpeedMultiplier( m_sliderAnimationSpeed->GetValue());
EDA_3D_CONTROLLER* ctrlTool = m_frame->GetToolManager()->GetTool<EDA_3D_CONTROLLER>();
ctrlTool->SetRotationIncrement( m_spinCtrlRotationAngle->GetValue() );
// The 3D scene will be rebuilt by the caller
return true;
}
void PANEL_3D_DISPLAY_OPTIONS::ResetPanel()
{
EDA_3D_VIEWER_SETTINGS cfg;
cfg.Load(); // Loading without a file will init to defaults
loadViewSettings( &cfg );
}
+8 -3
View File
@@ -32,17 +32,22 @@
class PANEL_3D_DISPLAY_OPTIONS : public PANEL_3D_DISPLAY_OPTIONS_BASE
{
public:
explicit PANEL_3D_DISPLAY_OPTIONS( wxWindow* aParent );
explicit PANEL_3D_DISPLAY_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent );
void OnCheckEnableAnimation( wxCommandEvent& WXUNUSED( event ) ) override;
/// Automatically called when clicking on the OK button
bool TransferDataFromWindow() override;
/// Automatically called after creating the dialog
bool TransferDataToWindow() override;
void ResetPanel() override;
void TransferColorDataToWindow();
private:
void loadViewSettings( EDA_3D_VIEWER_SETTINGS* aCfg );
EDA_3D_VIEWER_FRAME* m_frame;
BOARD_ADAPTER& m_settings;
EDA_3D_CANVAS* m_canvas;
};
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
PANEL_3D_DISPLAY_OPTIONS_BASE::PANEL_3D_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name )
PANEL_3D_DISPLAY_OPTIONS_BASE::PANEL_3D_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxHORIZONTAL );
@@ -20,170 +20,143 @@ PANEL_3D_DISPLAY_OPTIONS_BASE::PANEL_3D_DISPLAY_OPTIONS_BASE( wxWindow* parent,
wxBoxSizer* bSizeLeft;
bSizeLeft = new wxBoxSizer( wxVERTICAL );
m_boardLayersLabel = new wxStaticText( this, wxID_ANY, _("Board Layers"), wxDefaultPosition, wxDefaultSize, 0 );
m_boardLayersLabel->Wrap( -1 );
bSizeLeft->Add( m_boardLayersLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 13 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizeLeft->Add( m_staticline2, 0, wxEXPAND|wxBOTTOM, 5 );
wxStaticBoxSizer* sbBoardLayers;
sbBoardLayers = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Board Layers") ), wxVERTICAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 1, 4, 0 );
fgSizer1 = new wxFlexGridSizer( 0, 1, 5, 0 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_checkBoxSilkscreen = new wxCheckBox( this, wxID_ANY, _("Show silkscreen layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxSilkscreen, 0, wxLEFT, 5 );
m_checkBoxSilkscreen = new wxCheckBox( sbBoardLayers->GetStaticBox(), wxID_ANY, _("Show silkscreen layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxSilkscreen, 0, 0, 5 );
m_checkBoxSubtractMaskFromSilk = new wxCheckBox( this, wxID_ANY, _("Clip silkscreen at solder mask edges"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxSubtractMaskFromSilk = new wxCheckBox( sbBoardLayers->GetStaticBox(), wxID_ANY, _("Clip silkscreen at solder mask edges"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxSubtractMaskFromSilk, 0, wxLEFT, 25 );
m_checkBoxClipSilkOnViaAnnulus = new wxCheckBox( this, wxID_ANY, _("Clip silkscreen at via annuli"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxClipSilkOnViaAnnulus = new wxCheckBox( sbBoardLayers->GetStaticBox(), wxID_ANY, _("Clip silkscreen at via annuli"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxClipSilkOnViaAnnulus, 0, wxLEFT, 25 );
m_checkBoxSolderMask = new wxCheckBox( this, wxID_ANY, _("Show solder mask layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxSolderMask, 0, wxTOP|wxLEFT, 5 );
m_checkBoxSolderMask = new wxCheckBox( sbBoardLayers->GetStaticBox(), wxID_ANY, _("Show solder mask layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxSolderMask, 0, wxTOP, 8 );
m_checkBoxSolderpaste = new wxCheckBox( this, wxID_ANY, _("Show solder paste layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxSolderpaste, 0, wxLEFT, 5 );
m_checkBoxSolderpaste = new wxCheckBox( sbBoardLayers->GetStaticBox(), wxID_ANY, _("Show solder paste layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxSolderpaste, 0, 0, 5 );
m_checkBoxAdhesive = new wxCheckBox( this, wxID_ANY, _("Show adhesive layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxAdhesive, 0, wxLEFT, 5 );
m_checkBoxAdhesive = new wxCheckBox( sbBoardLayers->GetStaticBox(), wxID_ANY, _("Show adhesive layers"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxAdhesive, 0, 0, 5 );
bSizeLeft->Add( fgSizer1, 0, wxEXPAND|wxALL, 5 );
sbBoardLayers->Add( fgSizer1, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizeLeft->Add( 0, 15, 0, wxEXPAND, 5 );
bSizeLeft->Add( sbBoardLayers, 0, wxEXPAND|wxALL, 5 );
m_userLayersLabel = new wxStaticText( this, wxID_ANY, _("User Layers (not shown in realistic mode)"), wxDefaultPosition, wxDefaultSize, 0 );
m_userLayersLabel->Wrap( -1 );
bSizeLeft->Add( m_userLayersLabel, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 13 );
wxStaticBoxSizer* sbUserLayers;
sbUserLayers = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Layers (not shown in realistic mode)") ), wxVERTICAL );
m_staticline31 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizeLeft->Add( m_staticline31, 0, wxEXPAND|wxBOTTOM, 5 );
m_checkBoxComments = new wxCheckBox( sbUserLayers->GetStaticBox(), wxID_ANY, _("Show comment and drawing layers"), wxDefaultPosition, wxDefaultSize, 0 );
sbUserLayers->Add( m_checkBoxComments, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_checkBoxECO = new wxCheckBox( sbUserLayers->GetStaticBox(), wxID_ANY, _("Show ECO layers"), wxDefaultPosition, wxDefaultSize, 0 );
sbUserLayers->Add( m_checkBoxECO, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
bSizeLeft->Add( 0, 5, 0, wxEXPAND, 5 );
m_checkBoxComments = new wxCheckBox( this, wxID_ANY, _("Show comment and drawing layers"), wxDefaultPosition, wxDefaultSize, 0 );
bSizeLeft->Add( m_checkBoxComments, 0, wxRIGHT|wxLEFT, 10 );
bSizeLeft->Add( sbUserLayers, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bSizeLeft->Add( 0, 4, 0, wxEXPAND, 5 );
m_checkBoxECO = new wxCheckBox( this, wxID_ANY, _("Show ECO layers"), wxDefaultPosition, wxDefaultSize, 0 );
bSizeLeft->Add( m_checkBoxECO, 0, wxRIGHT|wxLEFT, 10 );
bSizeLeft->Add( 0, 15, 0, wxEXPAND, 5 );
m_renderOptionsLabel = new wxStaticText( this, wxID_ANY, _("Render Options"), wxDefaultPosition, wxDefaultSize, 0 );
m_renderOptionsLabel->Wrap( -1 );
bSizeLeft->Add( m_renderOptionsLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 13 );
m_staticline4 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizeLeft->Add( m_staticline4, 0, wxEXPAND|wxBOTTOM, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 1, 4, 0 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_checkBoxBoardBody = new wxCheckBox( this, wxID_ANY, _("Show board body"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_checkBoxBoardBody, 0, wxRIGHT|wxLEFT, 5 );
m_checkBoxRealisticMode = new wxCheckBox( this, wxID_ANY, _("Realistic mode"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_checkBoxRealisticMode, 0, wxRIGHT|wxLEFT, 5 );
m_checkBoxAreas = new wxCheckBox( this, wxID_ANY, _("Show filled areas in zones"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_checkBoxAreas, 0, wxRIGHT|wxLEFT, 5 );
m_checkBoxRenderPlatedPadsAsPlated = new wxCheckBox( this, wxID_ANY, _("Use bare copper color for unplated copper"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRenderPlatedPadsAsPlated->SetToolTip( _("Use different colors for plated and unplated copper. (Slow)") );
fgSizer2->Add( m_checkBoxRenderPlatedPadsAsPlated, 0, wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerMaterials;
bSizerMaterials = new wxBoxSizer( wxHORIZONTAL );
m_materialPropertiesLabel = new wxStaticText( this, wxID_ANY, _("Material properties:"), wxDefaultPosition, wxDefaultSize, 0 );
m_materialPropertiesLabel->Wrap( -1 );
bSizerMaterials->Add( m_materialPropertiesLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxString m_materialPropertiesChoices[] = { _("Realistic"), _("Solid colors"), _("CAD colors") };
int m_materialPropertiesNChoices = sizeof( m_materialPropertiesChoices ) / sizeof( wxString );
m_materialProperties = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_materialPropertiesNChoices, m_materialPropertiesChoices, 0 );
m_materialProperties->SetSelection( 0 );
bSizerMaterials->Add( m_materialProperties, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer2->Add( bSizerMaterials, 1, wxEXPAND, 5 );
bSizeLeft->Add( fgSizer2, 1, wxEXPAND|wxTOP|wxLEFT, 5 );
bSizer7->Add( bSizeLeft, 0, wxEXPAND|wxRIGHT, 20 );
bSizer7->Add( bSizeLeft, 0, wxEXPAND|wxTOP|wxLEFT, 10 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
m_cameraOptionsLabel = new wxStaticText( this, wxID_ANY, _("Camera Options"), wxDefaultPosition, wxDefaultSize, 0 );
m_cameraOptionsLabel->Wrap( -1 );
bSizerRight->Add( m_cameraOptionsLabel, 0, wxTOP|wxRIGHT|wxLEFT, 13 );
wxStaticBoxSizer* sbRenderOptions;
sbRenderOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Render Options") ), wxVERTICAL );
m_staticline5 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerRight->Add( m_staticline5, 0, wxEXPAND|wxBOTTOM, 5 );
m_checkBoxRealisticMode = new wxCheckBox( sbRenderOptions->GetStaticBox(), wxID_ANY, _("Realistic mode"), wxDefaultPosition, wxDefaultSize, 0 );
sbRenderOptions->Add( m_checkBoxRealisticMode, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_checkBoxBoardBody = new wxCheckBox( sbRenderOptions->GetStaticBox(), wxID_ANY, _("Show board body"), wxDefaultPosition, wxDefaultSize, 0 );
sbRenderOptions->Add( m_checkBoxBoardBody, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_checkBoxAreas = new wxCheckBox( sbRenderOptions->GetStaticBox(), wxID_ANY, _("Show filled areas in zones"), wxDefaultPosition, wxDefaultSize, 0 );
sbRenderOptions->Add( m_checkBoxAreas, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
m_checkBoxRenderPlatedPadsAsPlated = new wxCheckBox( sbRenderOptions->GetStaticBox(), wxID_ANY, _("Use bare copper color for unplated copper"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRenderPlatedPadsAsPlated->SetToolTip( _("Use different colors for plated and unplated copper. (Slow)") );
sbRenderOptions->Add( m_checkBoxRenderPlatedPadsAsPlated, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
wxBoxSizer* bSizerMaterials;
bSizerMaterials = new wxBoxSizer( wxHORIZONTAL );
m_materialPropertiesLabel = new wxStaticText( sbRenderOptions->GetStaticBox(), wxID_ANY, _("Material properties:"), wxDefaultPosition, wxDefaultSize, 0 );
m_materialPropertiesLabel->Wrap( -1 );
bSizerMaterials->Add( m_materialPropertiesLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
wxString m_materialPropertiesChoices[] = { _("Realistic"), _("Solid colors"), _("CAD colors") };
int m_materialPropertiesNChoices = sizeof( m_materialPropertiesChoices ) / sizeof( wxString );
m_materialProperties = new wxChoice( sbRenderOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_materialPropertiesNChoices, m_materialPropertiesChoices, 0 );
m_materialProperties->SetSelection( 0 );
bSizerMaterials->Add( m_materialProperties, 0, wxALL, 5 );
sbRenderOptions->Add( bSizerMaterials, 1, wxEXPAND, 5 );
bSizerRight->Add( sbRenderOptions, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 );
wxStaticBoxSizer* sbCameraOptions;
sbCameraOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Camera Options") ), wxVERTICAL );
wxBoxSizer* bSizerRotAngle;
bSizerRotAngle = new wxBoxSizer( wxHORIZONTAL );
m_staticTextRotAngle = new wxStaticText( this, wxID_ANY, _("Rotation increment:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRotAngle = new wxStaticText( sbCameraOptions->GetStaticBox(), wxID_ANY, _("Rotation increment:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRotAngle->Wrap( -1 );
bSizerRotAngle->Add( m_staticTextRotAngle, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_spinCtrlRotationAngle = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 359, 10, 1 );
m_spinCtrlRotationAngle = new wxSpinCtrlDouble( sbCameraOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 359, 10, 1 );
m_spinCtrlRotationAngle->SetDigits( 0 );
bSizerRotAngle->Add( m_spinCtrlRotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_staticTextRotAngleUnits = new wxStaticText( this, wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRotAngleUnits = new wxStaticText( sbCameraOptions->GetStaticBox(), wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRotAngleUnits->Wrap( -1 );
bSizerRotAngle->Add( m_staticTextRotAngleUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bSizerRight->Add( bSizerRotAngle, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
sbCameraOptions->Add( bSizerRotAngle, 0, wxBOTTOM, 5 );
wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxVERTICAL );
m_staticline3 = new wxStaticLine( sbCameraOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
sbCameraOptions->Add( m_staticline3, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
m_checkBoxEnableAnimation = new wxCheckBox( this, wxID_ANY, _("Enable animation"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxEnableAnimation = new wxCheckBox( sbCameraOptions->GetStaticBox(), wxID_ANY, _("Enable animation"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxEnableAnimation->SetValue(true);
bSizer9->Add( m_checkBoxEnableAnimation, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerRight->Add( bSizer9, 0, wxEXPAND|wxLEFT, 5 );
sbCameraOptions->Add( m_checkBoxEnableAnimation, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerSlider;
bSizerSlider = new wxBoxSizer( wxHORIZONTAL );
m_staticAnimationSpeed = new wxStaticText( this, wxID_ANY, _("Animation speed:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticAnimationSpeed = new wxStaticText( sbCameraOptions->GetStaticBox(), wxID_ANY, _("Animation speed:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticAnimationSpeed->Wrap( -1 );
bSizerSlider->Add( m_staticAnimationSpeed, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
bSizerSlider->Add( m_staticAnimationSpeed, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_sliderAnimationSpeed = new wxSlider( this, wxID_ANY, 3, 1, 5, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS );
m_sliderAnimationSpeed = new wxSlider( sbCameraOptions->GetStaticBox(), wxID_ANY, 3, 1, 5, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS );
m_sliderAnimationSpeed->SetMinSize( wxSize( 100,-1 ) );
bSizerSlider->Add( m_sliderAnimationSpeed, 1, wxEXPAND|wxLEFT|wxRIGHT, 15 );
bSizerSlider->Add( m_sliderAnimationSpeed, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 );
bSizerRight->Add( bSizerSlider, 0, wxEXPAND|wxLEFT, 5 );
sbCameraOptions->Add( bSizerSlider, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 );
bSizer7->Add( bSizerRight, 0, wxEXPAND, 15 );
bSizerRight->Add( sbCameraOptions, 0, wxEXPAND|wxTOP|wxLEFT, 5 );
bSizerMain->Add( bSizer7, 1, 0, 5 );
bSizer7->Add( bSizerRight, 0, wxEXPAND|wxRIGHT|wxTOP, 10 );
bSizerMain->Add( bSizer7, 0, 0, 5 );
this->SetSizer( bSizerMain );
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -10,18 +10,18 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "widgets/resettable_panel.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statline.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/choice.h>
#include <wx/spinctrl.h>
#include <wx/statline.h>
#include <wx/slider.h>
#include <wx/panel.h>
@@ -31,41 +31,34 @@
///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_3D_DISPLAY_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class PANEL_3D_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL
class PANEL_3D_DISPLAY_OPTIONS_BASE : public wxPanel
{
private:
protected:
wxStaticText* m_boardLayersLabel;
wxStaticLine* m_staticline2;
wxCheckBox* m_checkBoxSilkscreen;
wxCheckBox* m_checkBoxSubtractMaskFromSilk;
wxCheckBox* m_checkBoxClipSilkOnViaAnnulus;
wxCheckBox* m_checkBoxSolderMask;
wxCheckBox* m_checkBoxSolderpaste;
wxCheckBox* m_checkBoxAdhesive;
wxStaticText* m_userLayersLabel;
wxStaticLine* m_staticline31;
wxCheckBox* m_checkBoxComments;
wxCheckBox* m_checkBoxECO;
wxStaticText* m_renderOptionsLabel;
wxStaticLine* m_staticline4;
wxCheckBox* m_checkBoxBoardBody;
wxCheckBox* m_checkBoxRealisticMode;
wxCheckBox* m_checkBoxBoardBody;
wxCheckBox* m_checkBoxAreas;
wxCheckBox* m_checkBoxRenderPlatedPadsAsPlated;
wxStaticText* m_materialPropertiesLabel;
wxChoice* m_materialProperties;
wxStaticText* m_cameraOptionsLabel;
wxStaticLine* m_staticline5;
wxStaticText* m_staticTextRotAngle;
wxSpinCtrlDouble* m_spinCtrlRotationAngle;
wxStaticText* m_staticTextRotAngleUnits;
wxStaticLine* m_staticline3;
wxCheckBox* m_checkBoxEnableAnimation;
wxStaticText* m_staticAnimationSpeed;
wxSlider* m_sliderAnimationSpeed;
// Virtual event handlers, override them in your derived class
// Virtual event handlers, overide them in your derived class
virtual void OnCheckRealisticMode( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCheckEnableAnimation( wxCommandEvent& event ) { event.Skip(); }
@@ -73,7 +66,6 @@ class PANEL_3D_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL
public:
PANEL_3D_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_3D_DISPLAY_OPTIONS_BASE();
};
+42 -46
View File
@@ -22,43 +22,43 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <3d_enums.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <eda_3d_viewer_settings.h>
#include <widgets/color_swatch.h>
#include "panel_3D_opengl_options.h"
#include <widgets/color_swatch.h>
#include <3d_canvas/board_adapter.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <3d_viewer/tools/eda_3d_controller.h>
PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS( wxWindow* aParent ) :
PANEL_3D_OPENGL_OPTIONS_BASE( aParent )
PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) :
PANEL_3D_OPENGL_OPTIONS_BASE( aParent ),
m_settings( aFrame->GetAdapter() ),
m_canvas( aFrame->GetCanvas() )
{
m_selectionColorSwatch->SetDefaultColor( COLOR4D( 0.0, 1.0, 0.0, 1.0 ) );
m_selectionColorSwatch->SetSupportsOpacity( false );
}
void PANEL_3D_OPENGL_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg )
{
m_checkBoxCuThickness->SetValue( aCfg->m_Render.opengl_copper_thickness );
m_checkBoxBoundingBoxes->SetValue( aCfg->m_Render.opengl_show_model_bbox );
m_checkBoxHighlightOnRollOver->SetValue( aCfg->m_Render.opengl_highlight_on_rollover );
m_choiceAntiAliasing->SetSelection( static_cast<int>( aCfg->m_Render.opengl_AA_mode ) );
m_selectionColorSwatch->SetSwatchColor( aCfg->m_Render.opengl_selection_color, false );
m_checkBoxDisableAAMove->SetValue( aCfg->m_Render.opengl_AA_disableOnMove );
m_checkBoxDisableMoveThickness->SetValue( aCfg->m_Render.opengl_thickness_disableOnMove );
m_checkBoxDisableMoveVias->SetValue( aCfg->m_Render.opengl_vias_disableOnMove );
m_checkBoxDisableMoveHoles->SetValue( aCfg->m_Render.opengl_holes_disableOnMove );
}
bool PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow()
{
EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
m_checkBoxCuThickness->SetValue( m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) );
m_checkBoxBoundingBoxes->SetValue( m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) );
m_checkBoxHighlightOnRollOver->SetValue( m_settings.GetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM ) );
loadSettings( cfg );
m_choiceAntiAliasing->SetSelection( static_cast<int>( m_settings.GetAntiAliasingMode() ) );
m_selectionColorSwatch->SetSwatchColor( COLOR4D( m_settings.m_OpenGlSelectionColor.r,
m_settings.m_OpenGlSelectionColor.g,
m_settings.m_OpenGlSelectionColor.b,
1.0 ),
false );
m_checkBoxDisableAAMove->SetValue(
m_settings.GetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE ) );
m_checkBoxDisableMoveThickness->SetValue(
m_settings.GetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE ) );
m_checkBoxDisableMoveVias->SetValue(
m_settings.GetFlag( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE ) );
m_checkBoxDisableMoveHoles->SetValue(
m_settings.GetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE ) );
return true;
}
@@ -66,28 +66,24 @@ bool PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow()
bool PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow()
{
EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
m_settings.SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, m_checkBoxCuThickness->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, m_checkBoxBoundingBoxes->GetValue() );
m_settings.SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, m_checkBoxHighlightOnRollOver->GetValue() );
cfg->m_Render.opengl_copper_thickness = m_checkBoxCuThickness->GetValue();
cfg->m_Render.opengl_show_model_bbox = m_checkBoxBoundingBoxes->GetValue();
cfg->m_Render.opengl_highlight_on_rollover = m_checkBoxHighlightOnRollOver->GetValue();
m_settings.SetAntiAliasingMode(
static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() ) );
m_settings.m_OpenGlSelectionColor = SFVEC3F( m_selectionColorSwatch->GetSwatchColor().r,
m_selectionColorSwatch->GetSwatchColor().g,
m_selectionColorSwatch->GetSwatchColor().b );
cfg->m_Render.opengl_AA_mode = static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() );
cfg->m_Render.opengl_selection_color = m_selectionColorSwatch->GetSwatchColor();
cfg->m_Render.opengl_AA_disableOnMove = m_checkBoxDisableAAMove->GetValue();
cfg->m_Render.opengl_thickness_disableOnMove = m_checkBoxDisableMoveThickness->GetValue();
cfg->m_Render.opengl_vias_disableOnMove = m_checkBoxDisableMoveVias->GetValue();
cfg->m_Render.opengl_holes_disableOnMove = m_checkBoxDisableMoveHoles->GetValue();
m_settings.SetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE,
m_checkBoxDisableAAMove->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE,
m_checkBoxDisableMoveThickness->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE,
m_checkBoxDisableMoveVias->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE,
m_checkBoxDisableMoveHoles->GetValue() );
return true;
}
void PANEL_3D_OPENGL_OPTIONS::ResetPanel()
{
EDA_3D_VIEWER_SETTINGS cfg;
cfg.Load(); // Loading without a file will init to defaults
loadSettings( &cfg );
}
+6 -4
View File
@@ -31,15 +31,17 @@
class PANEL_3D_OPENGL_OPTIONS : public PANEL_3D_OPENGL_OPTIONS_BASE
{
public:
explicit PANEL_3D_OPENGL_OPTIONS( wxWindow* aParent );
explicit PANEL_3D_OPENGL_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent );
/// Automatically called when clicking on the OK button
bool TransferDataFromWindow() override;
/// Automatically called after creating the dialog
bool TransferDataToWindow() override;
void ResetPanel() override;
private:
void loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg );
BOARD_ADAPTER& m_settings;
EDA_3D_CANVAS* m_canvas;
};
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -11,91 +11,74 @@
///////////////////////////////////////////////////////////////////////////
PANEL_3D_OPENGL_OPTIONS_BASE::PANEL_3D_OPENGL_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name )
PANEL_3D_OPENGL_OPTIONS_BASE::PANEL_3D_OPENGL_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_renderingLabel = new wxStaticText( this, wxID_ANY, _("Rendering Options"), wxDefaultPosition, wxDefaultSize, 0 );
m_renderingLabel->Wrap( -1 );
bSizerMain->Add( m_renderingLabel, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 13 );
bSizerMain->Add( 0, 3, 0, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxBOTTOM, 5 );
wxBoxSizer* bSizerMargins;
bSizerMargins = new wxBoxSizer( wxVERTICAL );
m_checkBoxBoundingBoxes = new wxCheckBox( this, wxID_ANY, _("Show model bounding boxes"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMargins->Add( m_checkBoxBoundingBoxes, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbSizerOpenGLRenderoptions;
sbSizerOpenGLRenderoptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Rendering Options") ), wxVERTICAL );
m_checkBoxCuThickness = new wxCheckBox( this, wxID_ANY, _("Show copper and tech layers thickness (very slow)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMargins->Add( m_checkBoxCuThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxBoundingBoxes = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Show model bounding boxes"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerOpenGLRenderoptions->Add( m_checkBoxBoundingBoxes, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxHighlightOnRollOver = new wxCheckBox( this, wxID_ANY, _("Highlight items on rollover"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerMargins->Add( m_checkBoxHighlightOnRollOver, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxCuThickness = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Show copper thickness"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerOpenGLRenderoptions->Add( m_checkBoxCuThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxHighlightOnRollOver = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Highlight items on rollover"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerOpenGLRenderoptions->Add( m_checkBoxHighlightOnRollOver, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxGridSizer* gSizer1;
gSizer1 = new wxGridSizer( 0, 2, 0, 0 );
m_staticText221 = new wxStaticText( this, wxID_ANY, _("Anti-aliasing:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText221 = new wxStaticText( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Anti-aliasing:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText221->Wrap( -1 );
gSizer1->Add( m_staticText221, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
wxString m_choiceAntiAliasingChoices[] = { _("Disabled"), _("2x"), _("4x"), _("8x") };
int m_choiceAntiAliasingNChoices = sizeof( m_choiceAntiAliasingChoices ) / sizeof( wxString );
m_choiceAntiAliasing = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceAntiAliasingNChoices, m_choiceAntiAliasingChoices, 0 );
m_choiceAntiAliasing = new wxChoice( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceAntiAliasingNChoices, m_choiceAntiAliasingChoices, 0 );
m_choiceAntiAliasing->SetSelection( 0 );
m_choiceAntiAliasing->SetToolTip( _("3D-Viewer must be closed and re-opened to apply this setting") );
gSizer1->Add( m_choiceAntiAliasing, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_selectionColorLabel = new wxStaticText( this, wxID_ANY, _("Selection color:"), wxDefaultPosition, wxDefaultSize, 0 );
m_selectionColorLabel = new wxStaticText( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Selection color:"), wxDefaultPosition, wxDefaultSize, 0 );
m_selectionColorLabel->Wrap( -1 );
gSizer1->Add( m_selectionColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_selectionColorSwatch = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_selectionColorSwatch = new COLOR_SWATCH( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
gSizer1->Add( m_selectionColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
bSizerMargins->Add( gSizer1, 0, 0, 5 );
sbSizerOpenGLRenderoptions->Add( gSizer1, 0, 0, 5 );
bSizerMain->Add( bSizerMargins, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerMargins->Add( sbSizerOpenGLRenderoptions, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerWhileMoving;
sbSizerWhileMoving = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("While Moving") ), wxVERTICAL );
m_checkBoxDisableAAMove = new wxCheckBox( sbSizerWhileMoving->GetStaticBox(), wxID_ANY, _("Disable anti-aliasing"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerWhileMoving->Add( m_checkBoxDisableAAMove, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxDisableMoveThickness = new wxCheckBox( sbSizerWhileMoving->GetStaticBox(), wxID_ANY, _("Disable thickness"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerWhileMoving->Add( m_checkBoxDisableMoveThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxDisableMoveVias = new wxCheckBox( sbSizerWhileMoving->GetStaticBox(), wxID_ANY, _("Disable vias"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerWhileMoving->Add( m_checkBoxDisableMoveVias, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxDisableMoveHoles = new wxCheckBox( sbSizerWhileMoving->GetStaticBox(), wxID_ANY, _("Disable holes"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerWhileMoving->Add( m_checkBoxDisableMoveHoles, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( 0, 15, 0, wxEXPAND, 5 );
m_movingLabel = new wxStaticText( this, wxID_ANY, _("While Moving"), wxDefaultPosition, wxDefaultSize, 0 );
m_movingLabel->Wrap( -1 );
bSizerMain->Add( m_movingLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 13 );
bSizerMargins->Add( sbSizerWhileMoving, 0, wxALL|wxEXPAND, 5 );
bSizerMain->Add( 0, 3, 0, wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline2, 0, wxEXPAND|wxBOTTOM, 5 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxVERTICAL );
m_checkBoxDisableAAMove = new wxCheckBox( this, wxID_ANY, _("Disable anti-aliasing"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_checkBoxDisableAAMove, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxDisableMoveThickness = new wxCheckBox( this, wxID_ANY, _("Disable thickness"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_checkBoxDisableMoveThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxDisableMoveVias = new wxCheckBox( this, wxID_ANY, _("Disable vias"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_checkBoxDisableMoveVias, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxDisableMoveHoles = new wxCheckBox( this, wxID_ANY, _("Disable holes"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_checkBoxDisableMoveHoles, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bSizer3, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bSizerMargins, 1, wxEXPAND|wxRIGHT, 5 );
this->SetSizer( bSizerMain );
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -12,17 +12,16 @@
#include <wx/intl.h>
class COLOR_SWATCH;
#include "widgets/resettable_panel.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statline.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/choice.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@@ -31,13 +30,11 @@ class COLOR_SWATCH;
///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_3D_OPENGL_OPTIONS_BASE
///////////////////////////////////////////////////////////////////////////////
class PANEL_3D_OPENGL_OPTIONS_BASE : public RESETTABLE_PANEL
class PANEL_3D_OPENGL_OPTIONS_BASE : public wxPanel
{
private:
protected:
wxStaticText* m_renderingLabel;
wxStaticLine* m_staticline1;
wxCheckBox* m_checkBoxBoundingBoxes;
wxCheckBox* m_checkBoxCuThickness;
wxCheckBox* m_checkBoxHighlightOnRollOver;
@@ -45,8 +42,6 @@ class PANEL_3D_OPENGL_OPTIONS_BASE : public RESETTABLE_PANEL
wxChoice* m_choiceAntiAliasing;
wxStaticText* m_selectionColorLabel;
COLOR_SWATCH* m_selectionColorSwatch;
wxStaticText* m_movingLabel;
wxStaticLine* m_staticline2;
wxCheckBox* m_checkBoxDisableAAMove;
wxCheckBox* m_checkBoxDisableMoveThickness;
wxCheckBox* m_checkBoxDisableMoveVias;
+186 -136
View File
@@ -22,98 +22,142 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <eda_3d_viewer_settings.h>
#include <base_units.h>
#include "panel_3D_raytracing_options.h"
#include <3d_canvas/board_adapter.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <3d_viewer/tools/eda_3d_controller.h>
#include <bitmaps.h>
#include <tool/tool_manager.h>
PANEL_3D_RAYTRACING_OPTIONS::PANEL_3D_RAYTRACING_OPTIONS( wxWindow* aParent ) :
PANEL_3D_RAYTRACING_OPTIONS_BASE( aParent )
PANEL_3D_RAYTRACING_OPTIONS::PANEL_3D_RAYTRACING_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame,
wxWindow* aParent ) :
PANEL_3D_RAYTRACING_OPTIONS_BASE( aParent ),
m_settings( aFrame->GetAdapter() ),
m_canvas( aFrame->GetCanvas() )
{
}
void PANEL_3D_RAYTRACING_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg )
void PANEL_3D_RAYTRACING_OPTIONS::ResetPanel()
{
m_cbRaytracing_renderShadows->SetValue( aCfg->m_Render.raytrace_shadows );
m_cbRaytracing_addFloor->SetValue( aCfg->m_Render.raytrace_backfloor );
m_cbRaytracing_showRefractions->SetValue( aCfg->m_Render.raytrace_refractions );
m_cbRaytracing_showReflections->SetValue( aCfg->m_Render.raytrace_reflections );
m_cbRaytracing_postProcessing->SetValue( aCfg->m_Render.raytrace_post_processing );
m_cbRaytracing_antiAliasing->SetValue( aCfg->m_Render.raytrace_anti_aliasing );
m_cbRaytracing_proceduralTextures->SetValue( aCfg->m_Render.raytrace_procedural_textures );
m_settings.m_RtCameraLightColor = SFVEC3F( 0.2f );
m_settings.m_RtLightColorTop = SFVEC3F( 0.247f );
m_settings.m_RtLightColorBottom = SFVEC3F( 0.247f );
m_numSamples_Shadows->SetValue( aCfg->m_Render.raytrace_nrsamples_shadows );
m_numSamples_Reflections->SetValue( aCfg->m_Render.raytrace_nrsamples_reflections );
m_numSamples_Refractions->SetValue( aCfg->m_Render.raytrace_nrsamples_refractions );
const std::vector<int> default_elevation =
{
67, 67, 67, 67, -67, -67, -67, -67,
};
m_spreadFactor_Shadows->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_shadows * 100.0f ) );
m_spreadFactor_Reflections->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_reflections * 100.0f ) );
m_spreadFactor_Refractions->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_refractions * 100.0f ) );
const std::vector<int> default_azimuth =
{
45, 135, 225, 315, 45, 135, 225, 315,
};
m_recursiveLevel_Reflections->SetValue( aCfg->m_Render.raytrace_recursivelevel_reflections );
m_recursiveLevel_Refractions->SetValue( aCfg->m_Render.raytrace_recursivelevel_refractions );
for( size_t i = 0; i < m_settings.m_RtLightSphericalCoords.size(); ++i )
{
m_settings.m_RtLightColor[i] = SFVEC3F( 0.168f );
auto transfer_color =
[]( COLOR4D aColor, COLOR_SWATCH *aTarget )
{
aTarget->SetSupportsOpacity( false );
aTarget->SetDefaultColor( KIGFX::COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
aTarget->SetSwatchColor( aColor, false );
};
m_settings.m_RtLightSphericalCoords[i].x =
( (float) default_elevation[i] + 90.0f ) / 180.0f;
auto transfer_value =
[]( wxTextCtrl* aCtrl, int aValue )
{
aCtrl->SetValue(
EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, aValue ) );
};
m_settings.m_RtLightSphericalCoords[i].y = (float) default_azimuth[i] / 180.0f;
}
transfer_color( aCfg->m_Render.raytrace_lightColorCamera, m_colourPickerCameraLight );
transfer_color( aCfg->m_Render.raytrace_lightColorTop, m_colourPickerTopLight );
transfer_color( aCfg->m_Render.raytrace_lightColorBottom, m_colourPickerBottomLight );
TransferColorDataToWindow();
}
transfer_color( aCfg->m_Render.raytrace_lightColor[0], m_colourPickerLight1 );
transfer_color( aCfg->m_Render.raytrace_lightColor[1], m_colourPickerLight2 );
transfer_color( aCfg->m_Render.raytrace_lightColor[2], m_colourPickerLight3 );
transfer_color( aCfg->m_Render.raytrace_lightColor[3], m_colourPickerLight4 );
transfer_color( aCfg->m_Render.raytrace_lightColor[4], m_colourPickerLight5 );
transfer_color( aCfg->m_Render.raytrace_lightColor[5], m_colourPickerLight6 );
transfer_color( aCfg->m_Render.raytrace_lightColor[6], m_colourPickerLight7 );
transfer_color( aCfg->m_Render.raytrace_lightColor[7], m_colourPickerLight8 );
void PANEL_3D_RAYTRACING_OPTIONS::TransferColorDataToWindow()
{
auto transfer_color = [] ( const SFVEC3F& aSource, COLOR_SWATCH *aTarget )
{
aTarget->SetSupportsOpacity( false );
aTarget->SetDefaultColor( KIGFX::COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
aTarget->SetSwatchColor( COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 ), false );
};
transfer_value( m_lightElevation1, aCfg->m_Render.raytrace_lightElevation[0] );
transfer_value( m_lightElevation2, aCfg->m_Render.raytrace_lightElevation[1] );
transfer_value( m_lightElevation3, aCfg->m_Render.raytrace_lightElevation[2] );
transfer_value( m_lightElevation4, aCfg->m_Render.raytrace_lightElevation[3] );
transfer_value( m_lightElevation5, aCfg->m_Render.raytrace_lightElevation[4] );
transfer_value( m_lightElevation6, aCfg->m_Render.raytrace_lightElevation[5] );
transfer_value( m_lightElevation7, aCfg->m_Render.raytrace_lightElevation[6] );
transfer_value( m_lightElevation8, aCfg->m_Render.raytrace_lightElevation[7] );
transfer_color( m_settings.m_RtCameraLightColor, m_colourPickerCameraLight );
transfer_color( m_settings.m_RtLightColorTop, m_colourPickerTopLight );
transfer_color( m_settings.m_RtLightColorBottom, m_colourPickerBottomLight );
transfer_value( m_lightAzimuth1, aCfg->m_Render.raytrace_lightAzimuth[0] );
transfer_value( m_lightAzimuth2, aCfg->m_Render.raytrace_lightAzimuth[1] );
transfer_value( m_lightAzimuth3, aCfg->m_Render.raytrace_lightAzimuth[2] );
transfer_value( m_lightAzimuth4, aCfg->m_Render.raytrace_lightAzimuth[3] );
transfer_value( m_lightAzimuth5, aCfg->m_Render.raytrace_lightAzimuth[4] );
transfer_value( m_lightAzimuth6, aCfg->m_Render.raytrace_lightAzimuth[5] );
transfer_value( m_lightAzimuth7, aCfg->m_Render.raytrace_lightAzimuth[6] );
transfer_value( m_lightAzimuth8, aCfg->m_Render.raytrace_lightAzimuth[7] );
transfer_color( m_settings.m_RtLightColor[0], m_colourPickerLight1 );
transfer_color( m_settings.m_RtLightColor[1], m_colourPickerLight2 );
transfer_color( m_settings.m_RtLightColor[2], m_colourPickerLight3 );
transfer_color( m_settings.m_RtLightColor[3], m_colourPickerLight4 );
transfer_color( m_settings.m_RtLightColor[4], m_colourPickerLight5 );
transfer_color( m_settings.m_RtLightColor[5], m_colourPickerLight6 );
transfer_color( m_settings.m_RtLightColor[6], m_colourPickerLight7 );
transfer_color( m_settings.m_RtLightColor[7], m_colourPickerLight8 );
m_spinCtrlLightElevation1->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[0].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation2->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[1].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation3->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[2].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation4->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[3].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation5->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[4].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation6->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[5].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation7->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[6].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation8->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[7].x * 180.0f - 90.0f ) );
m_spinCtrlLightAzimuth1->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[0].y * 180.0f ) );
m_spinCtrlLightAzimuth2->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[1].y * 180.0f ) );
m_spinCtrlLightAzimuth3->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[2].y * 180.0f ) );
m_spinCtrlLightAzimuth4->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[3].y * 180.0f ) );
m_spinCtrlLightAzimuth5->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[4].y * 180.0f ) );
m_spinCtrlLightAzimuth6->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[5].y * 180.0f ) );
m_spinCtrlLightAzimuth7->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[6].y * 180.0f ) );
m_spinCtrlLightAzimuth8->SetValue(
(int)( m_settings.m_RtLightSphericalCoords[7].y * 180.0f ) );
}
bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataToWindow()
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
m_checkBoxRaytracing_renderShadows->SetValue(
m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
m_checkBoxRaytracing_addFloor->SetValue( m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) );
m_checkBoxRaytracing_showRefractions->SetValue(
m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) );
m_checkBoxRaytracing_showReflections->SetValue(
m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) );
m_checkBoxRaytracing_postProcessing->SetValue(
m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) );
m_checkBoxRaytracing_antiAliasing->SetValue(
m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) );
m_checkBoxRaytracing_proceduralTextures->SetValue(
m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) );
loadSettings( cfg );
m_spinCtrl_NrSamples_Shadows->SetValue( m_settings.m_RtShadowSampleCount );
m_spinCtrl_NrSamples_Reflections->SetValue( m_settings.m_RtReflectionSampleCount );
m_spinCtrl_NrSamples_Refractions->SetValue( m_settings.m_RtRefractionSampleCount );
m_spinCtrlDouble_SpreadFactor_Shadows->SetValue( m_settings.m_RtSpreadShadows * 100.0f );
m_spinCtrlDouble_SpreadFactor_Reflections->SetValue(
m_settings.m_RtSpreadReflections * 100.0f );
m_spinCtrlDouble_SpreadFactor_Refractions->SetValue(
m_settings.m_RtSpreadRefractions * 100.0f );
m_spinCtrlRecursiveLevel_Reflections->SetValue( m_settings.m_RtRecursiveReflectionCount );
m_spinCtrlRecursiveLevel_Refractions->SetValue( m_settings.m_RtRecursiveRefractionCount );
TransferColorDataToWindow();
return true;
}
@@ -121,83 +165,89 @@ bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataToWindow()
bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow()
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
m_settings.SetFlag( FL_RENDER_RAYTRACING_SHADOWS,
m_checkBoxRaytracing_renderShadows->GetValue() );
m_settings.SetFlag( FL_RENDER_RAYTRACING_BACKFLOOR,
m_checkBoxRaytracing_addFloor->GetValue() );
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFRACTIONS,
m_checkBoxRaytracing_showRefractions->GetValue() );
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFLECTIONS,
m_checkBoxRaytracing_showReflections->GetValue() );
m_settings.SetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING,
m_checkBoxRaytracing_postProcessing->GetValue() );
m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING,
m_checkBoxRaytracing_antiAliasing->GetValue() );
m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES,
m_checkBoxRaytracing_proceduralTextures->GetValue() );
cfg->m_Render.raytrace_shadows = m_cbRaytracing_renderShadows->GetValue();
cfg->m_Render.raytrace_backfloor = m_cbRaytracing_addFloor->GetValue();
cfg->m_Render.raytrace_refractions = m_cbRaytracing_showRefractions->GetValue();
cfg->m_Render.raytrace_reflections = m_cbRaytracing_showReflections->GetValue();
cfg->m_Render.raytrace_post_processing = m_cbRaytracing_postProcessing->GetValue();
cfg->m_Render.raytrace_anti_aliasing = m_cbRaytracing_antiAliasing->GetValue();
cfg->m_Render.raytrace_procedural_textures = m_cbRaytracing_proceduralTextures->GetValue();
m_settings.m_RtShadowSampleCount = m_spinCtrl_NrSamples_Shadows->GetValue();
m_settings.m_RtReflectionSampleCount = m_spinCtrl_NrSamples_Reflections->GetValue();
m_settings.m_RtRefractionSampleCount= m_spinCtrl_NrSamples_Refractions->GetValue();
cfg->m_Render.raytrace_nrsamples_shadows = m_numSamples_Shadows->GetValue();
cfg->m_Render.raytrace_nrsamples_reflections = m_numSamples_Reflections->GetValue();
cfg->m_Render.raytrace_nrsamples_refractions = m_numSamples_Refractions->GetValue();
m_settings.m_RtSpreadShadows =
static_cast<float>( m_spinCtrlDouble_SpreadFactor_Shadows->GetValue() ) / 100.0f;
m_settings.m_RtSpreadReflections =
static_cast<float>( m_spinCtrlDouble_SpreadFactor_Reflections->GetValue() ) / 100.0f;
m_settings.m_RtSpreadRefractions =
static_cast<float>( m_spinCtrlDouble_SpreadFactor_Refractions->GetValue() ) / 100.0f;
cfg->m_Render.raytrace_spread_shadows =
EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::PERCENT,
m_spreadFactor_Shadows->GetValue() )
/ 100.0f;
cfg->m_Render.raytrace_spread_reflections =
EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::PERCENT,
m_spreadFactor_Reflections->GetValue() )
/ 100.0f;
cfg->m_Render.raytrace_spread_refractions =
EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::PERCENT,
m_spreadFactor_Refractions->GetValue() )
/ 100.0f;
m_settings.m_RtRecursiveReflectionCount = m_spinCtrlRecursiveLevel_Reflections->GetValue();
m_settings.m_RtRecursiveRefractionCount = m_spinCtrlRecursiveLevel_Refractions->GetValue();
cfg->m_Render.raytrace_recursivelevel_reflections = m_recursiveLevel_Reflections->GetValue();
cfg->m_Render.raytrace_recursivelevel_refractions = m_recursiveLevel_Refractions->GetValue();
auto transfer_color = [] ( SFVEC3F& aTarget, COLOR_SWATCH *aSource )
{
const COLOR4D color = aSource->GetSwatchColor();
cfg->m_Render.raytrace_lightColorCamera = m_colourPickerCameraLight->GetSwatchColor();
cfg->m_Render.raytrace_lightColorTop = m_colourPickerTopLight->GetSwatchColor();
cfg->m_Render.raytrace_lightColorBottom = m_colourPickerBottomLight->GetSwatchColor();
aTarget = SFVEC3F( color.r, color.g, color.b );
};
cfg->m_Render.raytrace_lightColor[0] = m_colourPickerLight1->GetSwatchColor();
cfg->m_Render.raytrace_lightColor[1] = m_colourPickerLight2->GetSwatchColor();
cfg->m_Render.raytrace_lightColor[2] = m_colourPickerLight3->GetSwatchColor();
cfg->m_Render.raytrace_lightColor[3] = m_colourPickerLight4->GetSwatchColor();
cfg->m_Render.raytrace_lightColor[4] = m_colourPickerLight5->GetSwatchColor();
cfg->m_Render.raytrace_lightColor[5] = m_colourPickerLight6->GetSwatchColor();
cfg->m_Render.raytrace_lightColor[6] = m_colourPickerLight7->GetSwatchColor();
cfg->m_Render.raytrace_lightColor[7] = m_colourPickerLight8->GetSwatchColor();
transfer_color( m_settings.m_RtCameraLightColor, m_colourPickerCameraLight );
transfer_color( m_settings.m_RtLightColorTop, m_colourPickerTopLight );
transfer_color( m_settings.m_RtLightColorBottom, m_colourPickerBottomLight );
auto get_value =
[]( wxTextCtrl* aCtrl )
{
return EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
aCtrl->GetValue() );
};
transfer_color( m_settings.m_RtLightColor[0], m_colourPickerLight1 );
transfer_color( m_settings.m_RtLightColor[1], m_colourPickerLight2 );
transfer_color( m_settings.m_RtLightColor[2], m_colourPickerLight3 );
transfer_color( m_settings.m_RtLightColor[3], m_colourPickerLight4 );
transfer_color( m_settings.m_RtLightColor[4], m_colourPickerLight5 );
transfer_color( m_settings.m_RtLightColor[5], m_colourPickerLight6 );
transfer_color( m_settings.m_RtLightColor[6], m_colourPickerLight7 );
transfer_color( m_settings.m_RtLightColor[7], m_colourPickerLight8 );
cfg->m_Render.raytrace_lightElevation[0] = get_value( m_lightElevation1 );
cfg->m_Render.raytrace_lightElevation[1] = get_value( m_lightElevation2 );
cfg->m_Render.raytrace_lightElevation[2] = get_value( m_lightElevation3 );
cfg->m_Render.raytrace_lightElevation[3] = get_value( m_lightElevation4 );
cfg->m_Render.raytrace_lightElevation[4] = get_value( m_lightElevation5 );
cfg->m_Render.raytrace_lightElevation[5] = get_value( m_lightElevation6 );
cfg->m_Render.raytrace_lightElevation[6] = get_value( m_lightElevation7 );
cfg->m_Render.raytrace_lightElevation[7] = get_value( m_lightElevation8 );
m_settings.m_RtLightSphericalCoords[0].x =
( m_spinCtrlLightElevation1->GetValue() + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[1].x =
( m_spinCtrlLightElevation2->GetValue() + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[2].x =
( m_spinCtrlLightElevation3->GetValue() + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[3].x =
( m_spinCtrlLightElevation4->GetValue() + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[4].x =
( m_spinCtrlLightElevation5->GetValue() + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[5].x =
( m_spinCtrlLightElevation6->GetValue() + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[6].x =
( m_spinCtrlLightElevation7->GetValue() + 90.0f ) / 180.0f;
m_settings.m_RtLightSphericalCoords[7].x =
( m_spinCtrlLightElevation8->GetValue() + 90.0f ) / 180.0f;
cfg->m_Render.raytrace_lightAzimuth[0] = get_value( m_lightAzimuth1 );
cfg->m_Render.raytrace_lightAzimuth[1] = get_value( m_lightAzimuth2 );
cfg->m_Render.raytrace_lightAzimuth[2] = get_value( m_lightAzimuth3 );
cfg->m_Render.raytrace_lightAzimuth[3] = get_value( m_lightAzimuth4 );
cfg->m_Render.raytrace_lightAzimuth[4] = get_value( m_lightAzimuth5 );
cfg->m_Render.raytrace_lightAzimuth[5] = get_value( m_lightAzimuth6 );
cfg->m_Render.raytrace_lightAzimuth[6] = get_value( m_lightAzimuth7 );
cfg->m_Render.raytrace_lightAzimuth[7] = get_value( m_lightAzimuth8 );
m_settings.m_RtLightSphericalCoords[0].y = m_spinCtrlLightAzimuth1->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[1].y = m_spinCtrlLightAzimuth2->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[2].y = m_spinCtrlLightAzimuth3->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[3].y = m_spinCtrlLightAzimuth4->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[4].y = m_spinCtrlLightAzimuth5->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[5].y = m_spinCtrlLightAzimuth6->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[6].y = m_spinCtrlLightAzimuth7->GetValue() / 180.0f;
m_settings.m_RtLightSphericalCoords[7].y = m_spinCtrlLightAzimuth8->GetValue() / 180.0f;
for( size_t i = 0; i < m_settings.m_RtLightSphericalCoords.size(); ++i )
{
m_settings.m_RtLightSphericalCoords[i].x =
glm::clamp( m_settings.m_RtLightSphericalCoords[i].x, 0.0f, 1.0f );
m_settings.m_RtLightSphericalCoords[i].y =
glm::clamp( m_settings.m_RtLightSphericalCoords[i].y, 0.0f, 2.0f );
}
return true;
}
void PANEL_3D_RAYTRACING_OPTIONS::ResetPanel()
{
EDA_3D_VIEWER_SETTINGS cfg;
cfg.Load(); // Loading without a file will init to defaults
loadSettings( &cfg );
}
@@ -31,15 +31,21 @@
class PANEL_3D_RAYTRACING_OPTIONS : public PANEL_3D_RAYTRACING_OPTIONS_BASE
{
public:
explicit PANEL_3D_RAYTRACING_OPTIONS( wxWindow* aParent );
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
explicit PANEL_3D_RAYTRACING_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent );
void ResetPanel() override;
/// Automatically called when clicking on the OK button
bool TransferDataFromWindow() override;
/// Automatically called after creating the dialog
bool TransferDataToWindow() override;
void TransferColorDataToWindow();
private:
void loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg );
BOARD_ADAPTER& m_settings;
EDA_3D_CANVAS* m_canvas;
};
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -14,34 +14,34 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_renderingLabel = new wxStaticText( this, wxID_ANY, _("Rendering Options"), wxDefaultPosition, wxDefaultSize, 0 );
m_renderingLabel->Wrap( -1 );
bSizerMain->Add( m_renderingLabel, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 13 );
wxBoxSizer* bSizerMargins;
bSizerMargins = new wxBoxSizer( wxVERTICAL );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxBOTTOM, 5 );
wxStaticBoxSizer* sbSizerRaytracingRenderOptions;
sbSizerRaytracingRenderOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Rendering Options") ), wxVERTICAL );
sbSizerRaytracingRenderOptions->SetMinSize( wxSize( -1,32 ) );
wxGridSizer* gSizer1;
gSizer1 = new wxGridSizer( 0, 1, 0, 20 );
m_cbRaytracing_proceduralTextures = new wxCheckBox( this, wxID_ANY, _("Procedural textures (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRaytracing_proceduralTextures->SetValue(true);
gSizer1->Add( m_cbRaytracing_proceduralTextures, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxRaytracing_proceduralTextures = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Procedural textures (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_proceduralTextures->SetValue(true);
gSizer1->Add( m_checkBoxRaytracing_proceduralTextures, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbRaytracing_addFloor = new wxCheckBox( this, wxID_ANY, _("Add floor (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRaytracing_addFloor->SetValue(true);
gSizer1->Add( m_cbRaytracing_addFloor, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxRaytracing_addFloor = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Add floor (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_addFloor->SetValue(true);
gSizer1->Add( m_checkBoxRaytracing_addFloor, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbRaytracing_antiAliasing = new wxCheckBox( this, wxID_ANY, _("Anti-aliasing (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRaytracing_antiAliasing->SetValue(true);
gSizer1->Add( m_cbRaytracing_antiAliasing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxRaytracing_antiAliasing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Anti-aliasing (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_antiAliasing->SetValue(true);
gSizer1->Add( m_checkBoxRaytracing_antiAliasing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbRaytracing_postProcessing = new wxCheckBox( this, wxID_ANY, _("Screen space ambient occlusions and global illumination reflections (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRaytracing_postProcessing->SetValue(true);
gSizer1->Add( m_cbRaytracing_postProcessing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_checkBoxRaytracing_postProcessing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Screen space ambient occlusions and global illumination reflections (slow)"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_postProcessing->SetValue(true);
gSizer1->Add( m_checkBoxRaytracing_postProcessing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( gSizer1, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
sbSizerRaytracingRenderOptions->Add( gSizer1, 1, wxEXPAND|wxBOTTOM, 5 );
wxFlexGridSizer* fgSizer111;
fgSizer111 = new wxFlexGridSizer( 0, 4, 4, 8 );
@@ -51,127 +51,130 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa
fgSizer111->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticText19 = new wxStaticText( this, wxID_ANY, _("Number of Samples"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText19 = new wxStaticText( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Number of Samples"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText19->Wrap( -1 );
fgSizer111->Add( m_staticText19, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
m_staticText201 = new wxStaticText( this, wxID_ANY, _("Spread Factor %"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText201 = new wxStaticText( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Spread Factor %"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText201->Wrap( -1 );
fgSizer111->Add( m_staticText201, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_staticText211 = new wxStaticText( this, wxID_ANY, _("Recursion Level"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText211 = new wxStaticText( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Recursion Level"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText211->Wrap( -1 );
fgSizer111->Add( m_staticText211, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_cbRaytracing_renderShadows = new wxCheckBox( this, wxID_ANY, _("Shadows:"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRaytracing_renderShadows->SetValue(true);
fgSizer111->Add( m_cbRaytracing_renderShadows, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_checkBoxRaytracing_renderShadows = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Shadows:"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_renderShadows->SetValue(true);
fgSizer111->Add( m_checkBoxRaytracing_renderShadows, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_numSamples_Shadows = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 64, 0 );
m_numSamples_Shadows->SetToolTip( _("Number of rays that will be cast, into light direction, to evaluate a shadow point") );
m_spinCtrl_NrSamples_Shadows = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 64, 0 );
m_spinCtrl_NrSamples_Shadows->SetToolTip( _("Number of rays that will be cast, into light direction, to evaluate a shadow point") );
fgSizer111->Add( m_numSamples_Shadows, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer111->Add( m_spinCtrl_NrSamples_Shadows, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_spreadFactor_Shadows = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer111->Add( m_spreadFactor_Shadows, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_spinCtrlDouble_SpreadFactor_Shadows = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 );
m_spinCtrlDouble_SpreadFactor_Shadows->SetDigits( 1 );
m_spinCtrlDouble_SpreadFactor_Shadows->SetToolTip( _("Random direction factor of the cast rays") );
fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Shadows, 0, wxRIGHT|wxLEFT, 5 );
fgSizer111->Add( 0, 0, 1, wxEXPAND, 5 );
m_cbRaytracing_showReflections = new wxCheckBox( this, wxID_ANY, _("Reflections:"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRaytracing_showReflections->SetValue(true);
fgSizer111->Add( m_cbRaytracing_showReflections, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_checkBoxRaytracing_showReflections = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Reflections:"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_showReflections->SetValue(true);
fgSizer111->Add( m_checkBoxRaytracing_showReflections, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_numSamples_Reflections = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 32, 0 );
m_numSamples_Reflections->SetToolTip( _("Number of rays that will be cast to evaluate a reflection point") );
m_spinCtrl_NrSamples_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 32, 0 );
m_spinCtrl_NrSamples_Reflections->SetToolTip( _("Number of rays that will be cast to evaluate a reflection point") );
fgSizer111->Add( m_numSamples_Reflections, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer111->Add( m_spinCtrl_NrSamples_Reflections, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_spreadFactor_Reflections = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer111->Add( m_spreadFactor_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_spinCtrlDouble_SpreadFactor_Reflections = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 );
m_spinCtrlDouble_SpreadFactor_Reflections->SetDigits( 1 );
m_spinCtrlDouble_SpreadFactor_Reflections->SetToolTip( _("Random direction factor of the cast rays") );
m_recursiveLevel_Reflections = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 );
m_recursiveLevel_Reflections->SetToolTip( _("Interactions number that a ray can travel through objects. (higher number of levels improve results, specially on very transparent boards)") );
fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer111->Add( m_recursiveLevel_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_spinCtrlRecursiveLevel_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 );
m_spinCtrlRecursiveLevel_Reflections->SetToolTip( _("Interactions number that a ray can travel through objects. (higher number of levels improve results, specially on very transparent boards)") );
m_cbRaytracing_showRefractions = new wxCheckBox( this, wxID_ANY, _("Refractions:"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRaytracing_showRefractions->SetValue(true);
fgSizer111->Add( m_cbRaytracing_showRefractions, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer111->Add( m_spinCtrlRecursiveLevel_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_numSamples_Refractions = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 );
m_numSamples_Refractions->SetToolTip( _("Number of rays that will be cast to evaluate a refraction point") );
m_checkBoxRaytracing_showRefractions = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Refractions:"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_showRefractions->SetValue(true);
fgSizer111->Add( m_checkBoxRaytracing_showRefractions, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer111->Add( m_numSamples_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_spinCtrl_NrSamples_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 );
m_spinCtrl_NrSamples_Refractions->SetToolTip( _("Number of rays that will be cast to evaluate a refraction point") );
m_spreadFactor_Refractions = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer111->Add( m_spreadFactor_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
fgSizer111->Add( m_spinCtrl_NrSamples_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_recursiveLevel_Refractions = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 7, 0 );
m_recursiveLevel_Refractions->SetToolTip( _("Number of bounces that a ray can hit reflective objects") );
m_spinCtrlDouble_SpreadFactor_Refractions = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 );
m_spinCtrlDouble_SpreadFactor_Refractions->SetDigits( 1 );
m_spinCtrlDouble_SpreadFactor_Refractions->SetToolTip( _("Random direction factor of the cast rays") );
fgSizer111->Add( m_recursiveLevel_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_spinCtrlRecursiveLevel_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 7, 0 );
m_spinCtrlRecursiveLevel_Refractions->SetToolTip( _("Number of bounces that a ray can hit reflective objects") );
fgSizer111->Add( m_spinCtrlRecursiveLevel_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( fgSizer111, 0, wxEXPAND|wxALL, 5 );
sbSizerRaytracingRenderOptions->Add( fgSizer111, 0, wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND, 5 );
bSizerMain->Add( 0, 20, 0, wxEXPAND, 5 );
sbSizerRaytracingRenderOptions->Add( 0, 3, 0, wxEXPAND, 5 );
m_lightsLabel = new wxStaticText( this, wxID_ANY, _("Lights Configuration"), wxDefaultPosition, wxDefaultSize, 0 );
m_lightsLabel->Wrap( -1 );
bSizerMain->Add( m_lightsLabel, 0, wxTOP|wxRIGHT|wxLEFT, 13 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline2, 0, wxEXPAND|wxBOTTOM, 5 );
bSizerMargins->Add( sbSizerRaytracingRenderOptions, 0, wxEXPAND|wxALL, 5 );
wxBoxSizer* bLightsSizer;
bLightsSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizerRaytracingLightConfiguration;
sbSizerRaytracingLightConfiguration = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Lights Configuration") ), wxVERTICAL );
wxBoxSizer* bTopLineSizer;
bTopLineSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxHORIZONTAL );
m_staticText17 = new wxStaticText( this, wxID_ANY, _("Ambient camera light:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText17 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Ambient camera light:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText17->Wrap( -1 );
bTopLineSizer->Add( m_staticText17, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSizer11->Add( m_staticText17, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_colourPickerCameraLight = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerCameraLight = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerCameraLight->SetMinSize( wxSize( 72,20 ) );
bTopLineSizer->Add( m_colourPickerCameraLight, 0, wxALL, 5 );
bSizer11->Add( m_colourPickerCameraLight, 0, wxALL, 5 );
bTopLineSizer->Add( 20, 0, 1, 0, 5 );
bSizer11->Add( 0, 0, 1, 0, 5 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("Top light:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Top light:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
bTopLineSizer->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSizer11->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_colourPickerTopLight = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerTopLight = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerTopLight->SetMinSize( wxSize( 72,20 ) );
bTopLineSizer->Add( m_colourPickerTopLight, 0, wxALL, 5 );
bSizer11->Add( m_colourPickerTopLight, 0, wxALL, 5 );
bTopLineSizer->Add( 20, 0, 1, 0, 5 );
bSizer11->Add( 0, 0, 1, 0, 5 );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Bottom light:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Bottom light:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
bTopLineSizer->Add( m_staticText6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSizer11->Add( m_staticText6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_colourPickerBottomLight = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerBottomLight = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerBottomLight->SetMinSize( wxSize( 72,20 ) );
bTopLineSizer->Add( m_colourPickerBottomLight, 0, wxALL, 5 );
bSizer11->Add( m_colourPickerBottomLight, 0, wxALL, 5 );
bTopLineSizer->Add( 20, 0, 0, wxEXPAND, 5 );
bLightsSizer->Add( bTopLineSizer, 0, wxEXPAND|wxALL, 5 );
sbSizerRaytracingLightConfiguration->Add( bSizer11, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
wxFlexGridSizer* fgSizer11;
fgSizer11 = new wxFlexGridSizer( 0, 9, 3, 0 );
fgSizer11 = new wxFlexGridSizer( 0, 9, 0, 0 );
fgSizer11->AddGrowableCol( 4 );
fgSizer11->SetFlexibleDirection( wxHORIZONTAL );
fgSizer11->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@@ -181,16 +184,16 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa
fgSizer11->Add( 0, 0, 0, 0, 5 );
m_staticText20 = new wxStaticText( this, wxID_ANY, _("Elevation (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText20 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Elevation (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText20->Wrap( -1 );
fgSizer11->Add( m_staticText20, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_staticText18 = new wxStaticText( this, wxID_ANY, _("Azimuth (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText18 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Azimuth (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText18->Wrap( -1 );
fgSizer11->Add( m_staticText18, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer11->Add( 30, 0, 0, 0, 5 );
fgSizer11->Add( 0, 0, 0, 0, 5 );
fgSizer11->Add( 0, 0, 0, 0, 5 );
@@ -198,151 +201,154 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa
fgSizer11->Add( 0, 0, 0, 0, 5 );
m_staticText27 = new wxStaticText( this, wxID_ANY, _("Elevation (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText27 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Elevation (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText27->Wrap( -1 );
fgSizer11->Add( m_staticText27, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 );
m_staticText28 = new wxStaticText( this, wxID_ANY, _("Azimuth (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText28 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Azimuth (deg)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText28->Wrap( -1 );
fgSizer11->Add( m_staticText28, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 );
m_staticText21 = new wxStaticText( this, wxID_ANY, _("Light 1:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText21 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 1:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText21->Wrap( -1 );
fgSizer11->Add( m_staticText21, 0, wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer11->Add( m_staticText21, 0, wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL, 5 );
m_colourPickerLight1 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight1->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight1 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight1->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight1, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer11->Add( m_colourPickerLight1, 0, wxALL, 5 );
m_lightElevation1 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_spinCtrlLightElevation1 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth1 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_spinCtrlLightAzimuth1 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
fgSizer11->Add( 10, 0, 0, 0, 5 );
m_staticText22 = new wxStaticText( this, wxID_ANY, _("Light 5:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText22 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 5:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText22->Wrap( -1 );
fgSizer11->Add( m_staticText22, 0, wxALIGN_CENTER|wxLEFT, 5 );
m_colourPickerLight5 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight5->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight5 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight5->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight5, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer11->Add( m_colourPickerLight5, 0, wxALL, 5 );
m_lightElevation5 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation5, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightElevation5 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth5 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth5, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightAzimuth5 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_staticText23 = new wxStaticText( this, wxID_ANY, _("Light 2:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText23 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 2:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText23->Wrap( -1 );
fgSizer11->Add( m_staticText23, 0, wxALIGN_CENTER|wxLEFT, 5 );
fgSizer11->Add( m_staticText23, 0, wxALIGN_CENTER, 5 );
m_colourPickerLight2 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight2->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight2 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight2->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer11->Add( m_colourPickerLight2, 0, wxALL, 5 );
m_lightElevation2 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightElevation2 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth2 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightAzimuth2 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
fgSizer11->Add( 0, 0, 0, 0, 5 );
m_staticText24 = new wxStaticText( this, wxID_ANY, _("Light 6:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText24 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 6:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText24->Wrap( -1 );
fgSizer11->Add( m_staticText24, 0, wxALIGN_CENTER|wxLEFT, 5 );
m_colourPickerLight6 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight6->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight6 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight6->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer11->Add( m_colourPickerLight6, 0, wxALL, 5 );
m_lightElevation6 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_spinCtrlLightElevation6 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth6 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_spinCtrlLightAzimuth6 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_staticText25 = new wxStaticText( this, wxID_ANY, _("Light 3:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText25 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 3:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText25->Wrap( -1 );
fgSizer11->Add( m_staticText25, 0, wxALIGN_CENTER|wxLEFT, 5 );
fgSizer11->Add( m_staticText25, 0, wxALIGN_CENTER, 5 );
m_colourPickerLight3 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight3->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight3 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight3->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer11->Add( m_colourPickerLight3, 0, wxALL, 5 );
m_lightElevation3 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_spinCtrlLightElevation3 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth3 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth3, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightAzimuth3 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
fgSizer11->Add( 0, 0, 0, 0, 5 );
m_staticText26 = new wxStaticText( this, wxID_ANY, _("Light 7:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText26 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 7:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText26->Wrap( -1 );
fgSizer11->Add( m_staticText26, 0, wxALIGN_CENTER|wxLEFT, 5 );
m_colourPickerLight7 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight7->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight7 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight7->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer11->Add( m_colourPickerLight7, 0, wxALL, 5 );
m_lightElevation7 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation7, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightElevation7 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth7 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth7, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightAzimuth7 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_staticText171 = new wxStaticText( this, wxID_ANY, _("Light 4:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText171 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 4:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText171->Wrap( -1 );
fgSizer11->Add( m_staticText171, 0, wxALIGN_CENTER|wxLEFT, 5 );
fgSizer11->Add( m_staticText171, 0, wxALIGN_CENTER, 5 );
m_colourPickerLight4 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight4->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight4 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight4->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight4, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer11->Add( m_colourPickerLight4, 0, wxALL, 5 );
m_lightElevation4 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation4, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightElevation4 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth4 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth4, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightAzimuth4 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
fgSizer11->Add( 0, 0, 0, 0, 5 );
m_staticText181 = new wxStaticText( this, wxID_ANY, _("Light 8:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText181 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 8:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText181->Wrap( -1 );
fgSizer11->Add( m_staticText181, 0, wxALIGN_CENTER|wxLEFT, 5 );
m_colourPickerLight8 = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight8->SetMinSize( wxSize( 40,20 ) );
m_colourPickerLight8 = new COLOR_SWATCH( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_colourPickerLight8->SetMinSize( wxSize( 72,20 ) );
fgSizer11->Add( m_colourPickerLight8, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer11->Add( m_colourPickerLight8, 0, wxALL, 5 );
m_lightElevation8 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightElevation8, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightElevation8 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 );
fgSizer11->Add( m_spinCtrlLightElevation8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
m_lightAzimuth8 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer11->Add( m_lightAzimuth8, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_spinCtrlLightAzimuth8 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
fgSizer11->Add( m_spinCtrlLightAzimuth8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 );
bLightsSizer->Add( fgSizer11, 0, wxALL, 5 );
sbSizerRaytracingLightConfiguration->Add( fgSizer11, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bLightsSizer, 0, 0, 5 );
bSizerMargins->Add( sbSizerRaytracingLightConfiguration, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bSizerMargins, 1, wxEXPAND, 5 );
this->SetSizer( bSizerMain );
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -13,16 +13,15 @@
#include "widgets/color_swatch.h"
#include "widgets/resettable_panel.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statline.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/spinctrl.h>
#include <wx/textctrl.h>
#include <wx/statbox.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@@ -36,28 +35,24 @@ class PANEL_3D_RAYTRACING_OPTIONS_BASE : public RESETTABLE_PANEL
private:
protected:
wxStaticText* m_renderingLabel;
wxStaticLine* m_staticline1;
wxCheckBox* m_cbRaytracing_proceduralTextures;
wxCheckBox* m_cbRaytracing_addFloor;
wxCheckBox* m_cbRaytracing_antiAliasing;
wxCheckBox* m_cbRaytracing_postProcessing;
wxCheckBox* m_checkBoxRaytracing_proceduralTextures;
wxCheckBox* m_checkBoxRaytracing_addFloor;
wxCheckBox* m_checkBoxRaytracing_antiAliasing;
wxCheckBox* m_checkBoxRaytracing_postProcessing;
wxStaticText* m_staticText19;
wxStaticText* m_staticText201;
wxStaticText* m_staticText211;
wxCheckBox* m_cbRaytracing_renderShadows;
wxSpinCtrl* m_numSamples_Shadows;
wxTextCtrl* m_spreadFactor_Shadows;
wxCheckBox* m_cbRaytracing_showReflections;
wxSpinCtrl* m_numSamples_Reflections;
wxTextCtrl* m_spreadFactor_Reflections;
wxSpinCtrl* m_recursiveLevel_Reflections;
wxCheckBox* m_cbRaytracing_showRefractions;
wxSpinCtrl* m_numSamples_Refractions;
wxTextCtrl* m_spreadFactor_Refractions;
wxSpinCtrl* m_recursiveLevel_Refractions;
wxStaticText* m_lightsLabel;
wxStaticLine* m_staticline2;
wxCheckBox* m_checkBoxRaytracing_renderShadows;
wxSpinCtrl* m_spinCtrl_NrSamples_Shadows;
wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Shadows;
wxCheckBox* m_checkBoxRaytracing_showReflections;
wxSpinCtrl* m_spinCtrl_NrSamples_Reflections;
wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Reflections;
wxSpinCtrl* m_spinCtrlRecursiveLevel_Reflections;
wxCheckBox* m_checkBoxRaytracing_showRefractions;
wxSpinCtrl* m_spinCtrl_NrSamples_Refractions;
wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Refractions;
wxSpinCtrl* m_spinCtrlRecursiveLevel_Refractions;
wxStaticText* m_staticText17;
COLOR_SWATCH* m_colourPickerCameraLight;
wxStaticText* m_staticText5;
@@ -70,36 +65,36 @@ class PANEL_3D_RAYTRACING_OPTIONS_BASE : public RESETTABLE_PANEL
wxStaticText* m_staticText28;
wxStaticText* m_staticText21;
COLOR_SWATCH* m_colourPickerLight1;
wxTextCtrl* m_lightElevation1;
wxTextCtrl* m_lightAzimuth1;
wxSpinCtrl* m_spinCtrlLightElevation1;
wxSpinCtrl* m_spinCtrlLightAzimuth1;
wxStaticText* m_staticText22;
COLOR_SWATCH* m_colourPickerLight5;
wxTextCtrl* m_lightElevation5;
wxTextCtrl* m_lightAzimuth5;
wxSpinCtrl* m_spinCtrlLightElevation5;
wxSpinCtrl* m_spinCtrlLightAzimuth5;
wxStaticText* m_staticText23;
COLOR_SWATCH* m_colourPickerLight2;
wxTextCtrl* m_lightElevation2;
wxTextCtrl* m_lightAzimuth2;
wxSpinCtrl* m_spinCtrlLightElevation2;
wxSpinCtrl* m_spinCtrlLightAzimuth2;
wxStaticText* m_staticText24;
COLOR_SWATCH* m_colourPickerLight6;
wxTextCtrl* m_lightElevation6;
wxTextCtrl* m_lightAzimuth6;
wxSpinCtrl* m_spinCtrlLightElevation6;
wxSpinCtrl* m_spinCtrlLightAzimuth6;
wxStaticText* m_staticText25;
COLOR_SWATCH* m_colourPickerLight3;
wxTextCtrl* m_lightElevation3;
wxTextCtrl* m_lightAzimuth3;
wxSpinCtrl* m_spinCtrlLightElevation3;
wxSpinCtrl* m_spinCtrlLightAzimuth3;
wxStaticText* m_staticText26;
COLOR_SWATCH* m_colourPickerLight7;
wxTextCtrl* m_lightElevation7;
wxTextCtrl* m_lightAzimuth7;
wxSpinCtrl* m_spinCtrlLightElevation7;
wxSpinCtrl* m_spinCtrlLightAzimuth7;
wxStaticText* m_staticText171;
COLOR_SWATCH* m_colourPickerLight4;
wxTextCtrl* m_lightElevation4;
wxTextCtrl* m_lightAzimuth4;
wxSpinCtrl* m_spinCtrlLightElevation4;
wxSpinCtrl* m_spinCtrlLightAzimuth4;
wxStaticText* m_staticText181;
COLOR_SWATCH* m_colourPickerLight8;
wxTextCtrl* m_lightElevation8;
wxTextCtrl* m_lightAzimuth8;
wxSpinCtrl* m_spinCtrlLightElevation8;
wxSpinCtrl* m_spinCtrlLightAzimuth8;
public:
+26 -118
View File
@@ -25,7 +25,6 @@
*/
#include "panel_preview_3d_model.h"
#include <dialogs/dialog_unit_entry.h>
#include <3d_canvas/eda_3d_canvas.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
@@ -39,42 +38,28 @@
#include <pgm_base.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <widgets/wx_infobar.h>
#include <widgets/infobar.h>
#include <eda_3d_viewer_settings.h>
#include <board_design_settings.h>
PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
FOOTPRINT* aFootprint,
std::vector<FP_3DMODEL>* aParentModelList ) :
PANEL_PREVIEW_3D_MODEL_BASE( aParent, wxID_ANY ),
m_parentFrame( aFrame ),
m_previewPane( nullptr ),
m_infobar( nullptr ),
m_boardAdapter(),
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( 2 * RANGE_SCALE_3D )
{
m_userUnits = m_parentFrame->GetUserUnits();
m_userUnits = aFrame->GetUserUnits();
m_dummyBoard = new BOARD();
m_dummyBoard->SetProject( &aFrame->Prj(), true );
// This board will only be used to hold a footprint for viewing
m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
BOARD_DESIGN_SETTINGS parent_bds = aFrame->GetDesignSettings();
BOARD_DESIGN_SETTINGS& dummy_bds = m_dummyBoard->GetDesignSettings();
dummy_bds.SetBoardThickness( parent_bds.GetBoardThickness() );
dummy_bds.SetEnabledLayers( LSET::FrontMask() | LSET::BackMask() );
BOARD_STACKUP& dummy_board_stackup = m_dummyBoard->GetDesignSettings().GetStackupDescriptor();
dummy_board_stackup.RemoveAll();
dummy_board_stackup.BuildDefaultStackupList( &dummy_bds, 2 );
m_selected = -1;
m_previewLabel->SetFont( KIUI::GetStatusFont( this ) );
// Set the bitmap of 3D view buttons:
m_bpvTop->SetBitmap( KiBitmap( BITMAPS::axis3d_top ) );
m_bpvFront->SetBitmap( KiBitmap( BITMAPS::axis3d_front ) );
@@ -84,7 +69,6 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_bpvBottom->SetBitmap( KiBitmap( BITMAPS::axis3d_bottom ) );
m_bpvISO->SetBitmap( KiBitmap( BITMAPS::ortho ) );
m_bpUpdate->SetBitmap( KiBitmap( BITMAPS::reload ) );
m_bpSettings->SetBitmap( KiBitmap( BITMAPS::options_3drender ) );
// Set the min and max values of spin buttons (mandatory on Linux)
// They are not used, so they are set to min and max 32 bits int values
@@ -104,16 +88,6 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_parentModelList = aParentModelList;
m_dummyFootprint = new FOOTPRINT( *aFootprint );
m_dummyFootprint->SetParentGroup( nullptr );
// Ensure the footprint is shown like in Fp editor: rot 0, not flipped
// to avoid mistakes when setting the3D shape position/rotation
if( m_dummyFootprint->IsFlipped() )
m_dummyFootprint->Flip( m_dummyFootprint->GetPosition(), false );
m_dummyFootprint->SetOrientation( ANGLE_0 );
m_dummyBoard->Add( m_dummyFootprint );
// Create the 3D canvas
@@ -123,11 +97,11 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
aFrame->Prj().Get3DCacheManager() );
m_boardAdapter.SetBoard( m_dummyBoard );
m_boardAdapter.m_IsBoardView = false;
m_boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless the 3D viewer options
loadSettings();
m_boardAdapter.SetFlag( FL_USE_SELECTION, false );
m_boardAdapter.SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, false );
// Create the manager
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
@@ -155,9 +129,6 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
this );
}
aFrame->Connect( UNITS_CHANGED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
nullptr, this );
#ifdef __WXOSX__
// Call layout once to get the proper button sizes after the bitmaps have been set
Layout();
@@ -175,7 +146,6 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_bpvBottom->SetMinSize( m_bpvBottom->GetSize() + borderFix );
m_bpvISO->SetMinSize( m_bpvISO->GetSize() + borderFix );
m_bpUpdate->SetMinSize( m_bpUpdate->GetSize() + borderFix );
m_bpSettings->SetMinSize( m_bpSettings->GetSize() + borderFix );
#endif
}
@@ -206,7 +176,7 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
// TODO(JE) use all control options
m_boardAdapter.m_MousewheelPanning = settings->m_Input.scroll_modifier_zoom != 0;
m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.scroll_modifier_zoom != 0 );
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
@@ -236,7 +206,9 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
if( cfg )
{
m_boardAdapter.m_Cfg = cfg;
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL );
m_boardAdapter.SetFlag( FL_USE_REALISTIC_MODE, cfg->m_Render.realistic );
m_boardAdapter.SetMaterialMode( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
m_previewPane->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
m_previewPane->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
@@ -252,7 +224,7 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
*/
static double rotationFromString( const wxString& aValue )
{
double rotation = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES, aValue );
double rotation = DoubleValueFromString( EDA_UNITS::DEGREES, aValue ) / 10.0;
if( rotation > MAX_ROTATION )
{
@@ -278,9 +250,9 @@ wxString PANEL_PREVIEW_3D_MODEL::formatScaleValue( double aValue )
wxString PANEL_PREVIEW_3D_MODEL::formatRotationValue( double aValue )
{
return wxString::Format( wxT( "%.2f%s" ),
return wxString::Format( wxT( "%.2f %s" ),
aValue,
EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
}
@@ -292,9 +264,9 @@ wxString PANEL_PREVIEW_3D_MODEL::formatOffsetValue( double aValue )
else if( m_userUnits == EDA_UNITS::MILS )
aValue /= 25.4 / 1e3;
return wxString::Format( wxT( "%.6f%s" ),
return wxString::Format( wxT( "%.6f %s" ),
aValue,
EDA_UNIT_UTILS::GetText( m_userUnits ) );
GetAbbreviatedUnitsLabel( m_userUnits ) );
}
@@ -349,26 +321,17 @@ void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event )
// Write settings back to the parent
FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected );
modelInfo->m_Scale.x = EDA_UNIT_UTILS::UI::DoubleValueFromString(
pcbIUScale, EDA_UNITS::UNSCALED, xscale->GetValue() );
modelInfo->m_Scale.y = EDA_UNIT_UTILS::UI::DoubleValueFromString(
pcbIUScale, EDA_UNITS::UNSCALED, yscale->GetValue() );
modelInfo->m_Scale.z = EDA_UNIT_UTILS::UI::DoubleValueFromString(
pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() );
modelInfo->m_Scale.x = DoubleValueFromString( EDA_UNITS::UNSCALED, xscale->GetValue() );
modelInfo->m_Scale.y = DoubleValueFromString( EDA_UNITS::UNSCALED, yscale->GetValue() );
modelInfo->m_Scale.z = DoubleValueFromString( EDA_UNITS::UNSCALED, zscale->GetValue() );
modelInfo->m_Rotation.x = rotationFromString( xrot->GetValue() );
modelInfo->m_Rotation.y = rotationFromString( yrot->GetValue() );
modelInfo->m_Rotation.z = rotationFromString( zrot->GetValue() );
modelInfo->m_Offset.x = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
xoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
modelInfo->m_Offset.y = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
yoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
modelInfo->m_Offset.z = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
zoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
modelInfo->m_Offset.x = DoubleValueFromString( m_userUnits, xoff->GetValue() ) / IU_PER_MM;
modelInfo->m_Offset.y = DoubleValueFromString( m_userUnits, yoff->GetValue() ) / IU_PER_MM;
modelInfo->m_Offset.z = DoubleValueFromString( m_userUnits, zoff->GetValue() ) / IU_PER_MM;
// Update the dummy footprint for the preview
UpdateDummyFootprint( false );
@@ -391,30 +354,6 @@ void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
}
void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
{
BOARD_DESIGN_SETTINGS bds = m_dummyBoard->GetDesignSettings();
int thickness = bds.GetBoardThickness();
WX_UNIT_ENTRY_DIALOG dlg( m_parentFrame, _( "Board Thickness: " ),
_( "Preview Settings" ), thickness );
if( dlg.ShowModal() != wxID_OK )
return;
bds.SetBoardThickness( (int) dlg.GetValue() );
BOARD_STACKUP& boardStackup = m_dummyBoard->GetDesignSettings().GetStackupDescriptor();
boardStackup.RemoveAll();
boardStackup.BuildDefaultStackupList( &bds, 2 );
UpdateDummyFootprint( true );
m_previewPane->ReloadRequest();
m_previewPane->Refresh();
}
void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign )
{
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
@@ -426,8 +365,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign
else if( spinCtrl == m_spinZscale )
textCtrl = zscale;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
textCtrl->GetValue() );
double curr_value = DoubleValueFromString( EDA_UNITS::UNSCALED, textCtrl->GetValue() );
curr_value += ( SCALE_INCREMENT * aSign );
curr_value = std::max( 1/MAX_SCALE, curr_value );
@@ -447,8 +385,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aS
else if( spinCtrl == m_spinZrot )
textCtrl = zrot;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
textCtrl->GetValue() );
double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ) / 10.0;
curr_value += ( ROTATION_INCREMENT * aSign );
curr_value = std::max( -MAX_ROTATION, curr_value );
@@ -470,9 +407,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign
textCtrl = zoff;
double step_mm = OFFSET_INCREMENT_MM;
double curr_value_mm =
EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, textCtrl->GetValue() )
/ pcbIUScale.IU_PER_MM;
double curr_value_mm = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM;
if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
{
@@ -499,8 +434,7 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelScale( wxMouseEvent& event )
if( event.GetWheelRotation() >= 0 )
step = -step;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
textCtrl->GetValue() );
double curr_value = DoubleValueFromString( EDA_UNITS::UNSCALED, textCtrl->GetValue() );
curr_value += step;
curr_value = std::max( 1/MAX_SCALE, curr_value );
@@ -522,8 +456,7 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event )
if( event.GetWheelRotation() >= 0 )
step = -step;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
textCtrl->GetValue() );
double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ) / 10.0;
curr_value += step;
curr_value = std::max( -MAX_ROTATION, curr_value );
@@ -553,9 +486,7 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset( wxMouseEvent& event )
if( event.GetWheelRotation() >= 0 )
step_mm = -step_mm;
double curr_value_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
textCtrl->GetValue() )
/ pcbIUScale.IU_PER_MM;
double curr_value_mm = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM;
curr_value_mm += step_mm;
curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
@@ -565,29 +496,6 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset( wxMouseEvent& event )
}
void PANEL_PREVIEW_3D_MODEL::onUnitsChanged( wxCommandEvent& aEvent )
{
double xoff_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
xoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
double yoff_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
yoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
double zoff_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
zoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
PCB_BASE_FRAME* frame = static_cast<PCB_BASE_FRAME*>( aEvent.GetClientData() );
m_userUnits = frame->GetUserUnits();
xoff->SetValue( formatOffsetValue( xoff_mm ) );
yoff->SetValue( formatOffsetValue( yoff_mm ) );
zoff->SetValue( formatOffsetValue( zoff_mm ) );
aEvent.Skip();
}
void PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint( bool aReloadRequired )
{
m_dummyFootprint->Models().clear();
+12 -8
View File
@@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2015-2022 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
@@ -23,13 +23,22 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file panel_prev_model.h
* @brief Defines a panel which is to be added to a wxFileDialog via
* SetExtraControl();
* The panel shows a preview of the footprint being edited and provides controls
* to set the offset/rotation/scale of each model 3d shape as per KiCad's
* current behavior. The panel may also be used in the 3D configuration dialog
* to tune the positioning of the models without invoking a file selector dialog.
*/
#ifndef PANEL_PREVIEW_3D_MODEL_H
#define PANEL_PREVIEW_3D_MODEL_H
#include "panel_preview_3d_model_base.h"
#include <vector>
#include <widgets/unit_binder.h>
#include <tool/tools_holder.h>
#include <3d_canvas/eda_3d_canvas.h>
#include <3d_viewer_id.h>
@@ -139,8 +148,6 @@ private:
void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
void onUnitsChanged( wxCommandEvent& aEvent );
wxString formatScaleValue( double aValue );
wxString formatRotationValue( double aValue );
wxString formatOffsetValue( double aValue );
@@ -172,8 +179,6 @@ private:
m_previewPane->Refresh();
}
void View3DSettings( wxCommandEvent& event ) override;
void View3DRight( wxCommandEvent& event ) override
{
m_previewPane->SetView3D( ID_VIEW3D_RIGHT );
@@ -190,7 +195,6 @@ private:
}
private:
PCB_BASE_FRAME* m_parentFrame;
EDA_3D_CANVAS* m_previewPane;
WX_INFOBAR* m_infobar;
BOARD_ADAPTER m_boardAdapter;
@@ -203,7 +207,7 @@ private:
std::vector<FP_3DMODEL>* m_parentModelList;
int m_selected; /// Index into m_parentInfoList
EDA_UNITS m_userUnits;
EDA_UNITS m_userUnits;
};
#endif // PANEL_PREVIEW_3D_MODEL_H
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Sep 12 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -21,7 +21,7 @@ PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWi
sbSizerScale = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Scale") ), wxVERTICAL );
wxFlexGridSizer* fgSizerScale;
fgSizerScale = new wxFlexGridSizer( 0, 3, 2, 3 );
fgSizerScale = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerScale->AddGrowableCol( 1 );
fgSizerScale->SetFlexibleDirection( wxBOTH );
fgSizerScale->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@@ -66,7 +66,7 @@ PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWi
sbSizerRotation = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Rotation") ), wxVERTICAL );
wxFlexGridSizer* fgSizerRotate;
fgSizerRotate = new wxFlexGridSizer( 0, 3, 2, 3 );
fgSizerRotate = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerRotate->AddGrowableCol( 1 );
fgSizerRotate->SetFlexibleDirection( wxBOTH );
fgSizerRotate->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@@ -111,7 +111,7 @@ PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWi
sbSizerOffset = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Offset") ), wxVERTICAL );
wxFlexGridSizer* fgSizerOffset;
fgSizerOffset = new wxFlexGridSizer( 0, 3, 2, 3 );
fgSizerOffset = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerOffset->AddGrowableCol( 1 );
fgSizerOffset->SetFlexibleDirection( wxBOTH );
fgSizerOffset->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@@ -159,7 +159,7 @@ PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWi
sbSizer4->Add( m_opacity, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
bSizerLeft->Add( sbSizer4, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerLeft->Add( sbSizer4, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
bSizermain->Add( bSizerLeft, 0, 0, 5 );
@@ -167,39 +167,37 @@ PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWi
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxHORIZONTAL );
wxStaticText* staticPreviewLabel;
staticPreviewLabel = new wxStaticText( this, wxID_ANY, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 );
staticPreviewLabel->Wrap( -1 );
staticPreviewLabel->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
m_previewLabel = new wxStaticText( this, wxID_ANY, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 );
m_previewLabel->Wrap( -1 );
m_previewLabel->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
bSizer6->Add( m_previewLabel, 1, wxEXPAND|wxLEFT|wxRIGHT, 10 );
bSizerRight->Add( bSizer6, 0, wxEXPAND, 5 );
bSizerRight->Add( staticPreviewLabel, 0, wxEXPAND|wxLEFT|wxRIGHT, 10 );
m_SizerPanelView = new wxBoxSizer( wxVERTICAL );
bSizerRight->Add( m_SizerPanelView, 1, wxEXPAND|wxBOTTOM, 5 );
bSizerRight->Add( m_SizerPanelView, 1, wxEXPAND|wxBOTTOM, 8 );
bSizermain->Add( bSizerRight, 1, wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizermain->Add( bSizerRight, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
wxBoxSizer* bSizer3DButtons;
bSizer3DButtons = new wxBoxSizer( wxVERTICAL );
bSizer3DButtons->Add( 0, 0, 0, wxEXPAND, 5 );
m_bpvISO = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
m_bpvISO->SetToolTip( _("Enable/disable orthographic projection") );
bSizer3DButtons->Add( m_bpvISO, 0, wxTOP, 14 );
bSizer3DButtons->Add( m_bpvISO, 0, wxTOP|wxBOTTOM, 5 );
bSizer3DButtons->Add( 0, 0, 1, wxEXPAND, 5 );
m_bpvLeft = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
bSizer3DButtons->Add( m_bpvLeft, 0, wxBOTTOM, 5 );
bSizer3DButtons->Add( m_bpvLeft, 0, wxALIGN_LEFT|wxALIGN_RIGHT|wxBOTTOM, 5 );
m_bpvRight = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
bSizer3DButtons->Add( m_bpvRight, 0, wxBOTTOM, 5 );
@@ -224,11 +222,8 @@ PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWi
bSizer3DButtons->Add( m_bpUpdate, 0, wxBOTTOM, 5 );
m_bpSettings = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizer3DButtons->Add( m_bpSettings, 0, 0, 5 );
bSizermain->Add( bSizer3DButtons, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5 );
bSizermain->Add( bSizer3DButtons, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
this->SetSizer( bSizermain );
@@ -281,7 +276,6 @@ PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWi
m_bpvTop->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DTop ), NULL, this );
m_bpvBottom->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DBottom ), NULL, this );
m_bpUpdate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DUpdate ), NULL, this );
m_bpSettings->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DSettings ), NULL, this );
}
PANEL_PREVIEW_3D_MODEL_BASE::~PANEL_PREVIEW_3D_MODEL_BASE()
@@ -332,6 +326,5 @@ PANEL_PREVIEW_3D_MODEL_BASE::~PANEL_PREVIEW_3D_MODEL_BASE()
m_bpvTop->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DTop ), NULL, this );
m_bpvBottom->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DBottom ), NULL, this );
m_bpUpdate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DUpdate ), NULL, this );
m_bpSettings->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL_BASE::View3DSettings ), NULL, this );
}
+79 -154
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="16" />
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@@ -87,13 +87,13 @@
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">3</property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizerScale</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">2</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
@@ -680,13 +680,13 @@
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">3</property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizerRotate</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">2</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
@@ -1273,13 +1273,13 @@
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">3</property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizerOffset</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">2</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
@@ -1847,7 +1847,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
@@ -1929,7 +1929,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT|wxEXPAND</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@@ -1937,79 +1937,68 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="border">10</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font">,90,90,11,70,0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Preview</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="name">bSizer6</property>
<property name="orient">wxHORIZONTAL</property>
<property name="moveable">1</property>
<property name="name">staticPreviewLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font">,90,90,11,70,0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Preview</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_previewLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="border">8</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
@@ -2023,7 +2012,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@@ -2031,8 +2020,18 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">14</property>
<property name="flag">wxTOP</property>
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
@@ -2116,7 +2115,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM</property>
<property name="flag">wxALIGN_LEFT|wxALIGN_RIGHT|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
@@ -2642,80 +2641,6 @@
<event name="OnButtonClick">View3DUpdate</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag"></property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">MyButton</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_bpSettings</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">View3DSettings</event>
</object>
</object>
</object>
</object>
</object>
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.9.0 Sep 12 2021)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -66,7 +66,6 @@ class PANEL_PREVIEW_3D_MODEL_BASE : public wxPanel
wxTextCtrl* zoff;
wxSpinButton* m_spinZoffset;
wxSlider* m_opacity;
wxStaticText* m_previewLabel;
wxBoxSizer* m_SizerPanelView;
wxBitmapButton* m_bpvISO;
wxBitmapButton* m_bpvLeft;
@@ -76,7 +75,6 @@ class PANEL_PREVIEW_3D_MODEL_BASE : public wxPanel
wxBitmapButton* m_bpvTop;
wxBitmapButton* m_bpvBottom;
wxBitmapButton* m_bpUpdate;
wxBitmapButton* m_bpSettings;
// Virtual event handlers, override them in your derived class
virtual void onMouseWheelScale( wxMouseEvent& event ) { event.Skip(); }
@@ -98,7 +96,6 @@ class PANEL_PREVIEW_3D_MODEL_BASE : public wxPanel
virtual void View3DTop( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DBottom( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DUpdate( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DSettings( wxCommandEvent& event ) { event.Skip(); }
public:

Some files were not shown because too many files have changed in this diff Show More