Compare commits

..

2855 Commits

Author SHA1 Message Date
Dick Hollenbeck 6675ae64cf refinements 2014-06-11 00:57:26 -05:00
Dick Hollenbeck a015fa53e6 Save the footprint editor's last footprint in the PROJECT RString facility. 2014-06-11 00:18:41 -05:00
Dick Hollenbeck e2360155a6 *) Remove more wxString static constructors which were crashing in PAGE_INFO assignment
to a new BOARD in the footprint editor.  This is PAGE_INFO::A4 and company.
   
*) Remove static storage of the BOARD in the module editor.
2014-06-11 00:00:30 -05:00
jean-pierre charras 869792f88d Plot SVG: fix issue with arcs (bug #1328155 ) both in Pcbnew and Eeschema. 2014-06-10 18:21:38 +02:00
Dick Hollenbeck c22ccaffc4 Remove class RETAINED_PATH, put is main member function into SEARCH_STACK.
Change class PROJECT to use a generalized wxString in place of the
RETAINED_PATH items, so that new session and project specific strings
of any purpose can be saved there, for the life of a session.
2014-06-10 10:56:43 -05:00
unknown 583fe1d524 VRML export rewritten 2014-06-08 12:35:42 +02:00
jean-pierre charras c4a0bf2b2d Page layout editor: fix bad initialization on startup, which can crash pl_editor when trying to edit an item.
Minor other fixes.
2014-06-07 18:20:23 +02:00
Maciej Suminski d3206d6883 Fixed layers switching in GAL. 2014-06-06 14:59:55 +02:00
Maciej Suminski a7c13a61c3 Removed an unused parameter from TOOL_BASE::getModel<T>() method. 2014-06-06 14:59:25 +02:00
jean-pierre charras 52b503c99c Pcbnew: fix an issue (crash) with very old .brd files. 2014-06-06 12:32:01 +02:00
jean-pierre charras 7d65b1e5e1 Pcbnew: fix an issue with very old .brd files. 2014-06-06 12:30:07 +02:00
Tomasz Wlostowski 5e4f412fd0 Clang-alike lightweight RTTI for pcbnew + type casting cleanup. 2014-06-06 11:44:21 +02:00
unknown 8f949caeb9 IDF tools: code cleanup and debugging 2014-06-05 20:37:04 +02:00
Bernhard Stegmaier 2bd17a5c8b Removed a few warnings. 2014-06-05 12:40:26 +02:00
Maciej Suminski c6a2eb6c9d Single items are dragged by their origin in GAL canvas. 2014-06-05 09:55:53 +02:00
Maciej Suminski eb449879b8 bugfix #1326155: pcbnew shows strange ratsnest lines in OpenGL mode. 2014-06-05 09:55:35 +02:00
Maciej Suminski 49b45b8ac5 Fixed: Modules become invisible after reloading a netlist, until GAL view is refreshed. 2014-06-05 09:54:47 +02:00
Maciej Suminski 35bc2efb61 Minor code cleaning. 2014-06-04 18:01:01 +02:00
Maciej Suminski 9989145fb1 Grid in GAL takes into account grid offset. 2014-06-04 17:56:44 +02:00
Maciej Suminski 554c474cf0 Placing the grid origin is possible with GAL. 2014-06-04 17:46:43 +02:00
Dick Hollenbeck eded969ca1 Fix off by one error in libpart editor when displaying duplicate pins, unit numbers.
Fix segfault when deleting last user path from eeschema libpaths and then pressing cancel.
2014-06-04 20:06:52 -05:00
jean-pierre charras a28f93ff3b Fix some compil warnings and Debug assertions. 2014-06-04 20:48:49 +02:00
jean-pierre charras 13345822bc Fix some compil warnings and Debug assertions 2014-06-04 19:34:23 +02:00
Dick Hollenbeck 9e6eba96fd remove global g_UserLibDirBuffer which was a project specific global, and no longer used with FP_LIB_TABLE support. 2014-06-03 10:59:52 -05:00
Dick Hollenbeck b3777d5317 wxFrame GetParent() strategy is obsolete, use Kiway().Player() 2014-06-03 10:31:58 -05:00
Maciej Suminski c48435407e PNS router handles net class settings (dependent on the selected start item). 2014-06-03 16:09:27 +02:00
Maciej Suminski 3f577bd16c Improved ratsnest updating in GAL. 2014-06-03 16:08:23 +02:00
Maciej Suminski dc9e175ac0 bugfix #1325743: cvpcb crashes when opening any netlist. 2014-06-03 09:32:57 +02:00
jean-pierre charras 66b7e82b75 Minor fixes ( including Bug #1325561 ) 2014-06-02 18:35:49 +02:00
jean-pierre charras 23398f9651 Minor fixes. 2014-06-02 18:16:06 +02:00
jean-pierre charras 5bb7f5c8d2 .kicad_mod files: always save the "last edited date" because only the footprint editor changes this parameter. Usefull to know if/when a footprint was actually modified.
Also fix a minor issue in footprint editor which always set the "modified" flag even when no change was made.
2014-06-02 12:46:29 +02:00
Maciej Suminski d2cca45511 bugfix 1325375: pcbnew crash while append a board 2014-06-02 11:41:54 +02:00
jean-pierre charras f503f99704 Suppress compil warnings 2014-06-01 20:22:51 +02:00
unknown 170f0a5021 idf tools: code cleanup and debugging 2014-06-01 18:55:53 +02:00
Tomasz Wlostowski e12654ac3d router: fix segfault on route-undo-route 2014-06-01 18:44:38 +02:00
jean-pierre charras 274b7ee845 Pcbnew: fix Bug #1325311 ("New Board" warning refusal broken) 2014-06-01 16:58:17 +02:00
jean-pierre charras 558a5a4948 Cosmetic enhancements: fix incorrect icons. 2014-05-31 17:49:15 +02:00
Maciej Suminski 27ebcf3325 PNS formatting code. 2014-05-31 16:04:25 +02:00
Maciej Suminski bc766093a3 Setting proper tool for submenus of CONTEXT_MENU class. 2014-05-31 16:04:10 +02:00
Maciej Suminski 3b54bb1614 Brighter colors for pad net labels. 2014-05-31 11:50:01 +02:00
Maciej Suminski 648d81b2f7 Fix for vertical/horizontal (using Ctrl/Shift + mousewheel) panning in GAL canvas. 2014-05-31 11:48:27 +02:00
Maciej Suminski f9d964b790 Fixed invisible buttons in PNS settings dialog (at least for some GTK themes). 2014-05-30 15:31:30 +02:00
unknown 16baa1f7f1 OSX install script fixes. 2014-05-29 20:35:49 +02:00
jean-pierre charras 49553e867a Idf tools: Minor change for OSX compatibility (some from a patch from stegmaier@sw-systems.de) 2014-05-29 18:17:08 +02:00
unknown 5723ac469b Idf tools: Minor change for OSX compatibility 2014-05-29 18:04:54 +02:00
jean-pierre charras 2c7da91b39 Pcbnew: fix a minor bug: in zones with no net, only the zone clerance was used to created clearence, regardless the pad or footprint local clerance.
Very minor other fixes.
2014-05-29 13:48:14 +02:00
Maciej Suminski bc8fe1cea1 bugfix 1324144: broken PNS dragging 2014-05-28 19:21:12 +02:00
unknown e8d7e55640 Add patch about idf export (from cirilo_bernardo), with a fix for Windows. 2014-05-28 14:24:44 +02:00
Maciej Suminski 021474ab2a bugfix #1323135: PNS creates vias with giant holes. 2014-05-28 13:16:15 +02:00
unknown ea7dd5ae58 Add patch about idf export (from cirilo_bernardo) 2014-05-28 08:26:46 +02:00
Dick Hollenbeck 9219155104 A hopeful fix for bug lp:1322354 2014-05-27 23:33:00 -05:00
Dick Hollenbeck 5e7c4d47aa remove unused single_top.c function. 2014-05-27 23:30:38 -05:00
Dick Hollenbeck a67a342bdf change to fatal error in kicad/kicad.cpp Kiface() stub. 2014-05-27 00:05:41 -05:00
jean-pierre charras 13431345cf Apply a workaround in 3D_draw.cpp to avoid crash in boost::polygon (try to fix Bug #1322804)
This workaround was already used (bzr 4301, in file plot_board_layers.cpp) also to avoid similar crashes (uses 18 segments instead of 16 to approximate a circle by segments).
Minor code cleanup in dialog_plot.
2014-05-26 08:54:04 +02:00
unknown 78801bfcb5 Fix kicad_plugin.cpp coding style fully broken by commit 4887 (patch from Orson, AKA maciej suminski). 2014-05-26 08:21:25 +02:00
Bernhard Stegmaier 1c0f4a4e30 mac fixes 2014-05-25 11:02:52 -05:00
Maciej Suminski 7f90e34e38 Bugfix #1322914: pcbnew crashes when opening a file 2014-05-25 17:36:24 +02:00
Tomasz Wlostowski 38ab6a8dc0 router: fix segfault when trying to shove a line that forms a closed loop. 2014-05-23 11:57:43 +02:00
Wayne Stambaugh 48562916c3 Add gerber file attributes to road map. 2014-05-22 16:10:49 -04:00
Wayne Stambaugh 67ed6cc430 Add DRC and website improvements to road map. 2014-05-22 15:50:49 -04:00
Maciej Suminski 35fd6c9458 Ratsnest is computed for legacy boards in GAL view. 2014-05-22 19:34:28 +02:00
Maciej Suminski 68ada9e169 Fix for context menu hanging up in GAL. 2014-05-22 17:59:36 +02:00
Tomasz Wlostowski 2e939bb9be math_util: speed up rescaling on 64-bit platforms by using native 128-bit types 2014-05-22 15:07:28 +02:00
Maciej Suminski 55b20ea70d Added missing changes required for updating footprints with the module editor. 2014-05-22 15:01:58 +02:00
Maciej Suminski 4d80e42219 Fixed bug 1321936: changing a footprint for a set of modules relocates them in GAL canvas.
Changes introduced by the module editor are updated in GAL canvas.
2014-05-22 12:06:45 +02:00
Maciej Suminski 4474896713 The GAL view uses colors settings from the legacy canvas.
Minor refactoring of PAINTER & RENDER_SETTINGS classes.
2014-05-21 23:13:30 +02:00
Lorenzo Marcantonio 3604fae918 Replaced the display line clipper with the way simpler (and faster) Cohen-Sutherland one.
A couple of trivial accessors made inline
2014-05-21 19:02:32 +02:00
Dick Hollenbeck 35d49085ae set( wxWidgets_CONFIG_OPTIONS --static=no ) for platforms using wx-config 2014-05-21 08:36:59 -05:00
Dick Hollenbeck 943d1b7db8 fix bug lp:1319839 2014-05-21 01:06:52 -05:00
Maciej Suminski 3a41f8ed03 Fixes the bug that causes pcbnew crash, when there are multiple net classes and the plot dialog was opened.
Changed NETCLASS* to boost::shared_ptr<NETCLASS>.
2014-05-20 11:29:37 +02:00
Dick Hollenbeck d8ad00673b fix compiler warnings 2014-05-19 17:27:09 -05:00
jean-pierre charras 08843f5845 Pcbnew: plot dialog: remove obscure and useless option about texts which are not value or reference.
cosmetic enhancement in dialog.
page layout: fix bug Bug #1320839 (canvas refresh countinously called when moving an item)
2014-05-19 20:24:07 +02:00
Wayne Stambaugh 20304ccc30 Add road map to developer's documentation.
- Create KiCad road map document.
- Add road map to developer's documentation.
- A separate road map build command to CMake so the road map can be built
  separately for use in websites.
- Update .bzrignore to ignore road map files generated by Doxygen.
2014-05-18 19:37:45 -04:00
Maciej Sumiński 522f18d847 Upstream merge. 2014-05-18 17:32:35 +02:00
Maciej Sumiński 467e9cb170 Merged the new Interactive Push and Shove router.
Do not pay attention to add/remove files - it seems there may be a bug in git-bzr-ng plugin. I have checked them, they stayed exactly the same as before.
2014-05-18 17:16:59 +02:00
jean-pierre charras 9b505817b7 Rework on DXF export. 2014-05-17 21:29:15 +02:00
Lorenzo Marcantonio 0c119ebab9 TRACK::GetTrack can now be told to confine search to the netlist and/or force the sequential (restartable) algorithm
Reworked the collinear track routines. Cleanup should be faster given the above modification.
2014-05-17 19:36:02 +02:00
jean-pierre charras ea9931bd05 Plot DXF: better generation of filled zone polygons. 2014-05-16 21:03:45 +02:00
Lorenzo Marcantonio 0c29fb6595 Pull unfilled polygon drawing thru the line clipper; GTK mess up even in this case and the sheet border lines glitch on the screen at high zoom otherwise in pcbnew. 2014-05-16 19:43:27 +02:00
Maciej Suminski c8311132da Removed header files from CMakeLists.txt. 2014-05-16 16:01:03 +02:00
Lorenzo Marcantonio 657a87697e Made the project default text size apply to all text things in eeschema, instead of the hardcoded value 2014-05-16 15:57:53 +02:00
Maciej Suminski c60698c24b Reformatted PNS code to conform the coding policy. 2014-05-16 13:37:31 +02:00
Maciej Suminski 58becbeb59 Workaround for Mac OS, fixes focus after a mouse click. 2014-05-15 17:08:15 +02:00
Maciej Suminski 319cb3e15c Minor BOARD_DESIGN_SETTINGS refactoring.
Removed SetCurrentClassName() (it was not used anywhere and less safe than SetCurrentClass()).
Added BOARD_DESIGN_SETTIGNS::GetDefault() to make some pieces of shorter and clearer.
2014-05-15 10:51:08 +02:00
Maciej Suminski b4df1618ed Scripting fix. 2014-05-15 10:11:17 +02:00
jean-pierre charras e23f2b7b7b DXF export: fix incorrect export of polygons having thick outline (like zones): Thick segments of outline were drawn like lines with no thickness.
Fix ( workaround only) crash (Windows only) when a quasi modal frame (like footprint viewer) was called from a dialog (like the component properties dialog in schematic editor).
Very minor other fixes.
2014-05-15 08:32:24 +02:00
Maciej Suminski 1a0054ea48 PNS router deselects all items when started. 2014-05-14 19:15:25 +02:00
Maciej Suminski fa5ddc068d Fixed freezing of GAL canvas if user chooses Cancel in the on close dialog.. 2014-05-14 19:04:21 +02:00
Maciej Suminski 6279f8b33d Undo/report support for track dragging (PNS). 2014-05-14 18:45:59 +02:00
Maciej Suminski 6f9ef9c20e PNS routing settings are stored between router invocations. 2014-05-14 16:53:49 +02:00
Maciej Suminski 84e4b8f04f PNS debug output is enabled with PNS_DEBUG define. 2014-05-14 16:40:56 +02:00
Maciej Suminski b59770e8ca TOOL_MANAGER is no longer static. Reworked autoregistration of TOOL_ACTIONs. 2014-05-14 16:29:53 +02:00
Maciej Suminski 01cde02ea2 Added missing dialog files for pcbnew. 2014-05-14 16:28:39 +02:00
Tomasz Włostowski 541222752a Long-awaited new version of the P&S router 2014-05-14 15:53:54 +02:00
Tomasz Włostowski fa9a2796be Switching top layer should update the layer widget 2014-05-14 13:54:59 +02:00
Tomasz Włostowski 072c980c7d geometry: GetShape()->Shape() in indexed shape containers 2014-05-14 13:53:02 +02:00
Tomasz Włostowski 9a572e1993 geometry: get rid of useless vertex references in SEG class 2014-05-14 13:52:29 +02:00
Tomasz Włostowski 6cb0d0cbfc VIEW: added CalculateExtents() method 2014-05-14 13:48:29 +02:00
Maciej Suminski 7b120f21be Fixed freezing of GAL canvas if user chooses Cancel in the on close dialog. 2014-05-14 12:08:29 +02:00
Maciej Suminski fa6ada69a6 Added a missing file. 2014-05-14 11:47:17 +02:00
Maciej Suminski 5ec247663e Various fixes to geometry & math library. 2014-05-14 11:45:01 +02:00
Maciej Suminski d85256bfa9 Moved background color settings from GAL to RENDER_SETTINGS. Added RENDER_SETTINGS::TranslateColor() to convert between EDA_COLOR_T and COLOR4D. 2014-05-14 10:35:12 +02:00
Maciej Suminski ccb956b7d3 Holding shift always activates extend current selection mode (in GAL canvas). 2014-05-14 09:56:35 +02:00
Maciej Suminski 1aa6d7f0f0 Via holes were always visible in GAL canvas - fixed. 2014-05-14 09:48:29 +02:00
Maciej Suminski a4805cc99d Disable autopanning when GAL panel does not have focus. 2014-05-14 09:42:16 +02:00
Lorenzo Marcantonio 9849f41b03 Various fixes to pin drawing code
- Better shape to the 60617 pin markers
- Made the markers' size proportional to the pin text
- Added the missing implementation in the pin plot routines
2014-05-13 21:24:12 +02:00
Maciej Suminski 3bcb728c84 Fixed modification point for EDIT_TOOL when the tool is not active. 2014-05-13 11:22:51 +02:00
Maciej Suminski 9d61f82f68 Moved NETCLASSES to BOARD_DESIGN_SETTINGS.
Most of the changes are just adding GetDesignSettings() before every occurence of m_NetClasses.
More complex changes:
class_netclass.cpp - NETCLASS does not store the pointer to the parent BOARD anymore. Added function SetParams( BOARD_DESIGN_SETTINGS& ).
class_netclass.h - Removed GetTrackMinWidth(), GetViaMinDiameter(), GetViaMinDrill(), GetuViaMinDiameter(), GetuViaMinDrill() as they were refering to BOARD_DESIGN_SETTINGS anyway (they are not net class specific).
kicad_plugin.cpp - filters out empty nets (that are anyway not saved) when storing net class information. Previously it was done in NETCLASS::Format() function.
2014-05-13 11:22:51 +02:00
Maciej Suminski 3b735771d8 Fixed namecase for private fields in BOARD_DESIGN_SETTINGS class.
Moved a few one-liners of BOARD_DESIGN_SETTINGS class to the header file.
2014-05-13 11:22:51 +02:00
Maciej Suminski d8af04a5e3 Moved most of the board design rules related fields & methods to BOARD_DESIGN_SETTINGS class. 2014-05-13 11:22:51 +02:00
Maciej Suminski 39587ee1b7 Custom width settings taken into account in wxUpdateUIEvent handlers. 2014-05-13 11:22:51 +02:00
Maciej Suminski a48377bcee Custom track/via size settings nicely cooperate with other options. 2014-05-13 11:22:51 +02:00
Maciej Suminski 82303217af Initial support for custom track width & via size. 2014-05-13 11:22:51 +02:00
Maciej Suminski f3e771ac1f Minor reorganization of handling custom events with CONTEXT_MENU. 2014-05-13 11:22:51 +02:00
Maciej Suminski b813799334 WX_UNIT_TEXT can handle default value. 2014-05-13 11:22:51 +02:00
Maciej Suminski bc372564cf Fixed custom event handlers for CONTEXT_MENU.
Moved menuCopy to CONTEXT_MENU copy constructor.
2014-05-13 11:22:51 +02:00
Maciej Suminski 7155e3a9db Recursive copy constructor for CONTEXT_MENU. 2014-05-13 11:22:51 +02:00
Maciej Suminski 5abb625ef5 Fixing memory leaks. 2014-05-13 11:22:51 +02:00
Maciej Suminski ff0ca7ee95 Fixed rotation/flip point. 2014-05-13 11:22:51 +02:00
Maciej Suminski cdcb10d8bc Pad properties are back. 2014-05-13 11:22:51 +02:00
Maciej Suminski 2c594c9b18 SELECTION_TOOL updates dragging offset after rotating/flipping.
Cursor position is saved as a field in order to avoid drifting of items while they are being dragged and rotated/flipped.
2014-05-13 11:22:51 +02:00
Maciej Suminski d08f8ed62d More compatibility fixes. 2014-05-13 11:22:51 +02:00
Maciej Suminski 20fc4a81b8 Added WX_UNIT_TEXT - wxWidget control for inputing sizes using different units (mm, inch, internal units). 2014-05-13 11:22:51 +02:00
Maciej Suminski ef7e71e93a Fixed jumpy zoom when hotkeys and scroll wheel were used alternatively. 2014-05-13 11:22:51 +02:00
Maciej Suminski f092fac22e Resolved HOME hot key conflict between menu entry (Zoom Page) and event assigned to the hot key in the ACTION_MANAGER.
Conflicts:
	pcbnew/menubar_pcbframe.cpp
2014-05-13 11:22:51 +02:00
Maciej Suminski eefeb7c0cf Added preference for selecting tracks/vias/graphics if there is a module present in the selection point. 2014-05-13 11:22:51 +02:00
Maciej Suminski 76c61e92f7 Ratsnest lines are highlighted together with all items in the same net. 2014-05-13 11:22:51 +02:00
Maciej Suminski a86387eec6 Better way of adding CONTEXT_MENU entries. 2014-05-13 11:22:50 +02:00
Maciej Suminski 641e6398fd Ratsnest was not refreshed on board reload - fixed. 2014-05-13 11:22:50 +02:00
Maciej Suminski 04c73b0ceb Merged lp:~cern-kicad/kicad/drawing_tool branch. 2014-05-13 10:19:37 +02:00
Maciej Suminski d3afc86040 Fixed ifdefs in rtree.h. 2014-05-13 10:01:06 +02:00
Lorenzo Marcantonio 96131f64b4 Added eeschema option for the default pin length 2014-05-12 18:57:46 +02:00
Maciej Suminski fcfc4210e8 Upstream merge. 2014-05-12 17:17:51 +02:00
Lorenzo Marcantonio b5ae5f3f4d More refactoring of the track cleanup code
Algorithm is still the same... now need to know what it really meant to do
2014-05-10 14:48:17 +02:00
Dick Hollenbeck 9cea792545 Modular-Kicad milestone B), minor portion:
*)  Implement a framework for "Data Load On Demand".

*)  Implement FP_LIB_TABLE* PROJECT::PcbFootprintLibs(), which is the first
    prototype.

This allows the project specific footprint tables to be part of the Module Editor
when invoked from Eeschema.
2014-05-09 13:35:48 -05:00
jean-pierre charras 7d85ad55fb Fix an annoying behavior of new quasi modal frames on Windows (when closing them, the caller frame was no more on top ) 2014-05-09 20:06:18 +02:00
Dick Hollenbeck 6961f9bca0 Try some new Mac support ideas. 2014-05-09 09:27:21 -05:00
unknown d63547c7dd OSX: fix incorrect path to launch pl_editor.
fix also a bug in python script round_value_robin.py.
2014-05-09 08:32:05 +02:00
Dick Hollenbeck 3605ab617c peggable checkout version in scripts/kicad-install.sh 2014-05-08 17:29:22 -05:00
Lorenzo Marcantonio 005708f30d Missing const caused unpickability of tracks 2014-05-06 17:14:47 +02:00
Dick Hollenbeck 5a3bf6c3d6 Allow building of a STABLE or TESTING version using kicad-install.sh. 2014-05-06 00:23:57 -05:00
Dick Hollenbeck bb9c11492c Fix new bug which crashed pcbnew running under kicad.exe while adding a new module in mod editor 2014-05-05 23:58:33 -05:00
Dick Hollenbeck 3d9d0247e7 Modular-Kicad milestone B), glamorous portions:
*) Eeschema can now show the footprint editor.

*) Eeschema can now invoke the footprint picker from the library part field editor.

*) KIWAY_PLAYER::ShowModal() takes aResultantFocusWindow that tells what window
   to give the focus to.  Required since frames are often near the top of the
   hierarchy and they are invoked by a peer, not a parent.
2014-05-05 12:28:40 -05:00
jean-pierre charras 50645cf465 Kicad: fix crash on exit, when Libedit was called during a session. It fixes also a crash if Libedit was called, closed and reopened.
Happens only if eeschema was called from the Kicad manager.
2014-05-05 17:15:54 +02:00
Maciej Suminski 6a58dc67e9 Upstream merge. 2014-05-05 10:51:31 +02:00
jean-pierre charras 65d02e479a footprint editor: fix crashes. In this fix, I removed the assumption the parent frame is the board editor.
However, this assumption is still present here and there  in the moduleframe code.
2014-05-05 09:46:07 +02:00
Dick Hollenbeck e3ebd725cd Quasimodo is not a monster, he is your friend. 2014-05-04 19:19:16 -05:00
Dick Hollenbeck 288e89e0da typeinfo.h missing in Debug build for wx2.8 2014-05-04 15:27:29 -05:00
Dick Hollenbeck 4d955fda7e wx 2.8 now builds, but the quasi-modal support seems broken on 2.8. Wanted others to be able to build at least. 2014-05-04 14:57:44 -05:00
Dick Hollenbeck ea06a99874 Modular-Kicad milestone B), minor portions:
*) KIWAY_PLAYER::IsModal() is now a retained state, controlled by SetModal()

*) Fully re-work the KIWAY_PLAYER::ShowModal() to use a nested event loop.

*) Add support to DIALOG_SHIM for a "quasi-modal" dialog presentation and mode.
   See top of dialog_shim.cpp about that for benefits and need.

*) You can now pick footprint from the schematic component field dialog, although
   if you do this before you open the BOARD, you will only get the global footprint
   libraries, not also the project specific ones.  Opening the BOARD first avoids this
   problem.

This is the first example of cross KIFACE invocation, it is also the first
instance of using a TOP_FRAME other than FRAME_PCB as the first thing. It works,
but it's missing support for opening the project specific table because
historically the FRAME_PCB did that. This is now starting to expose all the near
term needs for KIWAY_PLAYER <-> PROJECT interaction, independence and out of
sequence usage.

A fix for this will be coming in a few days.

However it mostly starts to show why the KIWAY is terribly useful and important.
2014-05-04 13:22:27 -05:00
Maciej Suminski f292a1db89 Clearing m_hiddentItems to avoid PNS crashes. 2014-05-04 20:20:49 +02:00
Lorenzo Marcantonio 467d8b41f8 Constification of HitTest and GetParent
In particular HitTest for zones *do not* select the nearest vertex/edge as a side effect
2014-05-04 19:08:36 +02:00
Dick Hollenbeck 9f834561c3 Change order of headers for wx 2.8, use wxWindowDisabler not ENABLE_DISABLE. 2014-05-03 19:44:57 -05:00
Dick Hollenbeck 1ab4fca573 Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY.  Now any major
   frame with a "change language" menu can change the language for all KIWAY_PLAYERs
   in the whole KIWAY.  Multiple KIWAYs are not supported yet.

*) Simplify "modal wxFrame" support, and add that support exclusively to
   KIWAY_PLAYER where it is inherited by all derivatives.  The function
   KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.

*) Remove the requirements and assumptions that the wxFrame hierarchy always
   had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
   and editors. This is no longer the case, nor required.

*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
   KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
   quickly.  It also gives control to the KIWAY as to frame hierarchical
   relationships.

*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
   the single KIWAY_PLAYER, see bullet immediately above.

*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
   gives the KIFACEs a chance to save their final configuration dope to disk.

*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
   these modal frames are distinctly different than their non-modal equivalents.
   KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
   so this is another important reason for having a dedicated FRAME_T for each
   modal wxFrame.

On balance, more lines were deleted than were added to achieve all this.
2014-05-03 12:40:19 -05:00
jean-pierre charras cd341cc301 Eeschema: fix unwanted creation of noname.pro (or other useless config file), when opening eeschema. Fix also an issue when saving the config (from save config menu) which saved the config file in an unknow folder. 2014-05-02 19:56:24 +02:00
unknown dfad6b79e6 Fix issue in bga footprint wizard. 2014-05-02 08:28:40 +02:00
Maciej Suminski 4f83504d7b Upstream merge. 2014-05-01 15:55:50 +02:00
Lorenzo Marcantonio 149e3cb2a3 Virtual split of TRACK/VIA::HitTest 2014-05-01 08:50:11 +02:00
Lorenzo Marcantonio 5e266fc0bf - Better way to iterate on vias in the track list (GetFirstVia)
- Converted the Next/Prev C casts to static casts and removed the type
  unsafe ones
- Splitted as virtual the VIA::Flip member instead of using RTTI
- Heavily refactored the 'unconnected track' cleanup routine
- Misc constification
2014-04-30 21:16:22 +02:00
jean-pierre charras e3d7af1833 Plots function: fix a bug about virtual PLOTTER::Text, which was not virtual for derived classes due to a missing parameter in ::Text in these classes. Noticeable only in SVG plot.
SVG plot, fix a missing reinitialization in plot lines, which could define a filled polyline, instead of a simple polyline
(these fixes solve Bug #1313084 )
2014-04-28 18:13:18 +02:00
Dick Hollenbeck 9f4da3732e Reverse Marco's patch, pending a proper review of my last patch from an English speaking Mac developer. 2014-04-28 04:23:39 -05:00
Marco Serantoni 8f45e1703c [MacOSX] Fixing issue with kiface libs, now are symbolic linked to the owner bundle 2014-04-27 16:30:49 +02:00
Marco Serantoni ec6b251ef4 [MacOSX] Fix for name collision with OSX headers, Maciej, Tomasz or others feel free to rework if you want/like 2014-04-27 16:28:37 +02:00
unknown 557311aad7 3D viewer: Commit patch to enable the rendering of wrl files generated with Meshlab. See https://bugs.launchpad.net/kicad/+bug/804778 2014-04-27 15:49:41 +02:00
jean-pierre charras b8d833a450 Pcbnew: fix bug #1313076 (Filled Zones on technical layers) does not show up on 3D rendering 2014-04-27 13:30:45 +02:00
Lorenzo Marcantonio 852f21a7dc Fixed bug in via cleanup control flow 2014-04-26 13:23:00 +02:00
Lorenzo Marcantonio f1069929df Reworked the endpoint designator constants FLG_BEGIN and FLG_END in a
ENDPOINT_T enum type
2014-04-25 19:13:33 +02:00
jean-pierre charras ead32f6885 eeschema: fix the very minor bug #1298094. But it was due to a bad bounding box calculation, which is now fixed. 2014-04-25 18:49:32 +02:00
Lorenzo Marcantonio 249003e594 Removed the ugly bit stuffing for the bottom via layer number
(just replaced it with a member)
2014-04-25 10:03:50 +02:00
Dick Hollenbeck 28497f10dd SEGVIA -> VIA for swig 2014-04-25 01:43:14 -05:00
Lorenzo Marcantonio 37adb11be5 TRACK/SEGVIA cleanup
- SEGVIA becomes VIA
- Drill size moved from TRACK to VIA
- Removed shape from TRACK, becomes ViaType in VIA
- GetTrace becomes GetTrack, for uniformity
- Some minor constification and typo fixes
2014-04-25 08:00:04 +02:00
jean-pierre charras 63d4051059 Pcbnew: fix Bug #1304418 . Fix also a related issue which crashes Pcbnew in some corner cases.
(for instance, when a footprint from the currently edited board is loaded in the footprint editor, and when the board is cleared or reloaded)
In footprint editor, the net names are no more shown od modifiable (becuase the footprint editor does not know anything about net names.
This change should allow the changes planned in pcbnew.
2014-04-24 20:54:49 +02:00
Dick Hollenbeck 7f27b30ac9 single_top w/o kiface whines and exits gracefully. 2014-04-24 13:31:11 -05:00
Dick Hollenbeck 2bc0a44764 comment fix, simplified unhandled IO_ERROR exception report in single_top.cpp. 2014-04-24 12:25:57 -05:00
Dick Hollenbeck fd480f6437 Add custom target on linux to make build-dir symlinks. 2014-04-24 12:21:34 -05:00
Dick Hollenbeck 0011fd5166 Add diagnostic message for missing *.kiface, which is now a fatal installation bug. 2014-04-24 06:30:14 -05:00
Andrey Fedorushkov 88ec4fe02f fix not correct build if BUILD_GITHUB_PLUGIN=ON in linux rpm-based distro 2014-04-24 09:44:27 +04:00
John Beard c5a14f28f1 Add John Beard's patch: new and useful footprint wizards (SIP/SIP, SOIC/SSOP/TSSOP/MSOP and BGA).
Add Python utility tools to make wizard scripts more easy to write.
2014-04-23 18:36:31 +02:00
Dick Hollenbeck 056e3aede2 the boost site is getting slower, somebody might need supply a better host and offer bandwidth there for downloading the boost tar. 2014-04-23 08:53:07 -05:00
Dick Hollenbeck 6a39ea5b43 KIWAY::Player() wxASSERT 2014-04-22 11:16:34 -05:00
Dick Hollenbeck 05b91bcbfb KIWAY::Player() wxASSERT 2014-04-22 11:10:07 -05:00
Dick Hollenbeck 4402c686d8 remove KIWAY_EXPRESS::kiway_express() typo, add comments. 2014-04-22 10:26:59 -05:00
Dick Hollenbeck 43ee7b1dc1 Teach cvpcb about new KIWAY based cross-probing, factor out MAIL_T into mail_type.h 2014-04-22 10:16:19 -05:00
Dick Hollenbeck 115124c528 Functional
*) void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, const std::string& aPayload, wxWindow* aSource=NULL );
*) virtual void KiwayMailIn( KIWAY_EXPRESS& aEvent );
*) enum MAIL_T expansion into the brave new world if cross KIWAY_PLAYER communications.

Let the KIWAY_PLAYING begin.....
through well conceived mail from one KIWAY_PLAYER to another.
Get thinking now.  Add a new MAIL_T value, then send ExpressMail(), 
and receive it in KiwayMailIn(), it's that easy.
2014-04-21 09:49:33 -05:00
Dick Hollenbeck 470b7eddb3 Get cross-probing working under the Kiway. 2014-04-21 01:51:33 -05:00
Dick Hollenbeck 0c65353c17 happy Easter 2014-04-21 01:28:17 -05:00
Dick Hollenbeck c32443fe35 add back missing pcbnew cross probing event handlers. eeschema launches kiface versions of pcbnew & cvpcb if not single. 2014-04-19 23:35:34 -05:00
Dick Hollenbeck 03c4145fa8 hook top frame with KIWAY::playerDestroyHandler() 2014-04-19 14:44:59 -05:00
Dick Hollenbeck 2459ed7320 KIWAY::dso_full_path() was more incomplete. 2014-04-19 13:58:32 -05:00
Dick Hollenbeck 23d150e618 *) Switch kicad.exe to using KIFACE modules for all major top level windows.
Eeschema, Pcbnew, and Cvpcb all run under the same process now,
    FOR THE VERY FIRST TIME!

*)  Added KIWAY::PlayerCreate(), PlayerClose(), and PlayersClose().

*)  Factored FRAME_T into <frame_type.h> from ID_DRAWFRAME_TYPE.

*)  Found that the following command line is helpful for collecting all the *.kiface
    files into the <build>/kicad/ directory so that kicad can find them.

      $ cp `find . -name '*.kiface'` kicad/

    Maybe somebody will want to rework how the CMake files are organized so all
    the binaries can go into the same place.  See python-a-mingw-us.

*)  This might fix the problem on the Mac where child process windows were not
    coming to the front.  See ->Raise() in kicad/mainframe.cpp.

*)  You can set USE_KIFACE to 0 in kicad/mainframe.cpp to chain load child exes
    instead of using the KIFACE modules directly, i.e. revert.
2014-04-19 13:47:20 -05:00
Nick Østergaard d7082b39bb Fix vertical offset for multiline text in VRML exporter. 2014-04-19 18:05:58 +02:00
Dick Hollenbeck ed25a1593e *) Add KIFACE_I::StartFlags() and IsSingle() so a KIFACE implementation can know
if it is running under single_top.cpp or under a project manager.

*)  Test Kiface().IsSingle() when adding menus, some operations are not permitted
    when running under a project manager and the KIWAY_PLAYER is pegged to a
    specific project.

*)  Implemented KIWAY::KiFACE() so it loads *.kiface files.  They still have to be
    in the same directory as the main *.exe launcher, so this presents some difficulty
    when the binaries are not yet installed but rather the *.kiface files are still
    in their original build directories.  For today, I simply copied _pcbnew.kiface
    to build/kicad/.

*)  Add a test case to kicad/mainframe.cpp just to get an early peek at loading
    _pcbnew.kiface under the C++ project manager.  Got that working for one
    specific invocation just for proof of concept.  Surprise, it works.
2014-04-17 21:05:40 -05:00
Maciej Suminski ca7d56cefd The kicad.exe project manager was not finding the kicad.pro file because it did
not know where the template directory was.
2014-04-17 17:02:36 -05:00
Maciej Suminski 1bba172393 Upstream merge. 2014-04-16 11:26:41 +02:00
Maciej Suminski 7e43e8e4dd wxWidgets 2.8 compatibility fixes. 2014-04-15 16:36:23 +02:00
Dick Hollenbeck b5a8c2a2a0 Don't know how it ever worked before, supporting project template kicad.pro 2014-04-15 00:55:15 -05:00
Dick Hollenbeck ac353fc037 PROJECT::configCreate() logic changes. 2014-04-15 00:34:28 -05:00
Dick Hollenbeck a340308dc1 improve help file finding after kiway breakage. 2014-04-14 13:49:52 -05:00
Lorenzo Marcantonio feaab95087 - Began rework/cleanup of the board cleanup routine
- Set the modified flag even for null segment removal
2014-04-13 20:24:44 +02:00
Dick Hollenbeck 14c2469a3f remove a static wxString constructor which was out of sequence with another dependent one, at least with one toolchain. 2014-04-13 07:48:58 -05:00
Dick Hollenbeck 14ed75b0a7 kicad-install.sh: only install global fp-lib-table if non-existent 2014-04-11 08:36:20 -05:00
Nick Østergaard 4e38c73586 bzr email happiness 2014-04-11 08:30:30 -05:00
Dick Hollenbeck 3c4cb06644 oops, wx2.8 compatibility fixes 2014-04-10 16:31:55 -05:00
Dick Hollenbeck b7937c5c79 oops, wx2.8 compatibility fixes 2014-04-10 16:24:15 -05:00
Dick Hollenbeck aa56df75bd catch some IO_ERRORs 2014-04-10 16:20:01 -05:00
Maciej Suminski 0f78123d69 Fix MinGW OpenMP link error. 2014-04-09 20:55:34 -04:00
Maciej Suminski e4a4578b40 Key events are handled by wxEVT_CHAR instead of wxEVT_KEY_[UP|DOWN]. Fixed issue of chars that require modifiers (e.g. ? is Shift+/ on US keyboard layout). 2014-04-09 17:33:22 +02:00
Maciej Suminski 1c35e7d6f6 Hot keys specific to a tool have priority over global hot keys (TOOL_ACTION scope: AS_GLOBAL/AS_CONTEXT is finally handled properly). 2014-04-09 17:05:05 +02:00
Maciej Suminski 24b8d96709 Fixed vias layer order. 2014-04-09 17:01:22 +02:00
Maciej Suminski 1a3f7989df Fixed ratsnest update after removing items. 2014-04-09 16:57:22 +02:00
Dick Hollenbeck 2249b3be12 Jettison FP_LIB_TABLE::ConvertFromLegacy() into a static function, where it
was used locally.  Then comment it out in favor of a newer strategy for
filling in nicknames in cvpcb. 

Add MODULE* FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
        throw( IO_ERROR, PARSE_ERROR );
from code found elsewhere.
2014-04-09 08:33:04 -05:00
Dick Hollenbeck 289c4c2f9d More migration towards single process, extend PROJECT::Config*() in proper direction, cleanups. 2014-04-07 23:55:53 -05:00
Maciej Suminski c5e84fe49a Upstream merge. 2014-04-07 18:00:13 +02:00
Maciej Suminski 3d9d94c18a GAL defaults to Cairo, so KiCad does not fail on completely OpenGL incapable systems.
Board is cached in GAL only when the canvas is activated.
2014-04-07 16:04:54 +02:00
Maciej Suminski 19f1adabea Fixed refreshing issues (DRC, new items after reloading netlist and probably many other places). 2014-04-07 15:35:50 +02:00
Maciej Suminski c225dbbba2 Fixed outline breaking for zones (points were not always created in the double click point). 2014-04-07 14:30:38 +02:00
Dick Hollenbeck f599033a1a Enhance scripts/library-repos-install.sh to create library-repos-install.bat and add that. 2014-04-07 07:28:44 -05:00
Maciej Suminski 877928a57a Items that may be modified using EDIT_POINTs used to stay selected after pressing ESC (only EDIT_POINTs got away) - fixed. 2014-04-07 13:59:27 +02:00
Maciej Suminski 8461a62c3a Fixed switching back to selection tool using the right toolbar buttons in pcbnew (GAL). 2014-04-07 13:50:18 +02:00
Maciej Suminski 2b328721d4 Formatted ttl library to comply with KiCad coding policy. 2014-04-07 13:32:09 +02:00
Dick Hollenbeck 31d231ed36 make kicad-install.sh executable 2014-04-06 14:21:10 -05:00
Dick Hollenbeck cd4feed7de use proper schematic parts library 2014-04-06 14:12:37 -05:00
Dick Hollenbeck ff4887b46c kicad-install.sh uses https protocol. 2014-04-06 13:50:59 -05:00
Dick Hollenbeck 4c780e7074 remove a warning message 2014-04-04 13:43:12 -05:00
jean-pierre charras 34dc6da5ad Pcbnew: commit forgotten change. 2014-04-04 20:35:07 +02:00
jean-pierre charras 030cee7ddf Footprint Editor: minor cosmetic enhancement (which could avoid a report like bug #1302255) 2014-04-04 20:28:35 +02:00
Maciej Suminski 5bd06278d3 Bruteforce module update after a netlist reload. 2014-04-04 17:42:35 +02:00
Maciej Suminski dfb461307a Added net highlighting. 2014-04-04 17:40:00 +02:00
Maciej Suminski e179d215a7 Corrected zone display settings for GAL. 2014-04-04 16:58:44 +02:00
Dick Hollenbeck b1e4eeb2b5 Rework FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer(), fix up comments and warnings. 2014-04-04 09:57:26 -05:00
Maciej Suminski ed43e47115 Elements visibility are updated in the GAL. 2014-04-04 16:48:45 +02:00
Maciej Suminski 1adc04caf6 High contrast color got blueish by accident - fixed. 2014-04-04 15:49:37 +02:00
Maciej Suminski 6e5c404f94 Edit->Global Deletions & Edit->Cleanup Tracks and Vias work in GAL, without toggling between canvases. 2014-04-04 15:43:30 +02:00
Maciej Suminski 7ae0fba8f1 Fixed crashes related to ratsnest on canvas change. 2014-04-04 13:03:41 +02:00
Maciej Suminski 52640fd5fd Fixed occasional crashes on undo/redo while dragging. 2014-04-04 12:56:50 +02:00
Maciej Suminski 9a6ab4e64f Fixed GAL canvas freeze when ordered twice to change to the same GAL canvas (e.g. double F11). 2014-04-04 12:01:30 +02:00
Maciej Suminski d5d4ae3305 Renamed [class_]drawpanel_gal.[cpp|h] to [class_]draw_panel_gal.[cpp|h] to follow current naming scheme. 2014-04-04 11:56:04 +02:00
Maciej Suminski d5b2a3b007 Added possibility of switching tools by the right toolbar buttons, without deactivating the current tool first (previously tools did not switch if there was one active). 2014-04-04 11:50:15 +02:00
Maciej Suminski b588456d6a TEXTE_MODULE relative position is updated when absolute position is changed (and viceversa). 2014-04-04 09:01:17 +02:00
jean-pierre charras f28484179d Cmakefiles: do not create map files on Windows, because creating map file generates hundred of useless warnings.
In PATCH_COMMAND, use patch instead of bzr patch if patch or patch.exe is found (mandatory to build Kicad on msys2 because 'bzr patch' does not work when using msys2)
2014-04-04 07:55:28 +02:00
jean-pierre charras c1804da8a2 Cmakefiles: do not create map file on Windows, because creating map file generates hundred of useless wranings.
In PATCH_COMMAND, use patch instead of bzr patch if patch or patch.exe is found (mandatory to use msys2 because bzr patch does not work when using msys2)
2014-04-03 13:55:02 +02:00
Maciej Suminski 0304286c2c Fix Clang build error when OpenMP is not found. 2014-04-03 06:54:08 -04:00
Maciej Suminski 33bad83ea7 Fixed missing transitions for EDIT_TOOLs. 2014-04-03 10:24:27 +02:00
Maciej Suminski 0e35ad6329 Fixed cancelling dialogs in DRAWING_TOOL. 2014-04-03 09:48:06 +02:00
jean-pierre charras 1cbcc8dc25 All: add 2 hotkeys to simulate a mouse left click (key return) and left dclick (key end) 2014-04-03 09:40:55 +02:00
Maciej Suminski bf92b0103a Converted std::bind1st to boost::bind. 2014-04-02 16:30:48 +02:00
Maciej Suminski 9ad3180f6c Added EC_SNAPLINE to make possible snapping EDIT_LINES by their ends rather than by its center. 2014-04-02 15:57:21 +02:00
Maciej Suminski 0e270eec05 Upstream merge. 2014-04-02 15:38:59 +02:00
Maciej Suminski 6e72301bd7 Refactoring EDIT_POINTS, part 3: constraints split to EDIT_POINTs and EDIT_LINEs. 2014-04-02 09:31:35 +02:00
Maciej Suminski a59d0f113b Refactoring EDIT_POINTS, part 2: replaced index numbers with constants. 2014-04-01 17:41:24 +02:00
Maciej Suminski 827fd67191 Refactoring EDIT_POINTS, part 1: separated functions that operate on EDIT_POINTS and EDIT_LINES. 2014-04-01 17:18:43 +02:00
Maciej Suminski 9b67ee04e6 If tool was previously active and it is called again, it is brought to the top of the active tool stack.
It fixes issue of dragging of items that have EDIT_POINTs, when dragging was activated by hovering over an item and using hot key.
2014-04-01 14:35:09 +02:00
Maciej Suminski 5127237b40 Fixed autopanning for POINT_EDITOR. 2014-04-01 14:13:00 +02:00
Maciej Suminski 2af184034b Activation of any drawing/placement tool clears current selection. 2014-04-01 14:06:19 +02:00
Maciej Suminski 96e9942a9b Fixed drifting for items dragged using EDIT_TOOL. 2014-04-01 13:30:31 +02:00
Wayne Stambaugh 603121f753 Fix OpenMP link error on MinGW. 2014-03-31 22:38:19 -04:00
jean-pierre charras b0020a904b Pcbnew: bug fix: sometimes (depending on a previous command) pcbnew could create an usual zone instead of a keepout zone when the" create keepout zone" tool is activated 2014-03-31 20:14:01 +02:00
jean-pierre charras be2238411d Finishing dialog_freeroute_exchange.cpp changes to run freeroute.jar if found in kicad binaries.
Very minor other fix
2014-03-29 21:00:14 +01:00
Lorenzo Marcantonio 939e3d589b Removed relic empty if 2014-03-29 18:34:13 +01:00
Lorenzo Marcantonio 6475d4496d Indentation was completely broken (editor tabbing issue, maybe?) 2014-03-29 12:22:20 +01:00
jean-pierre charras ef938bdf1f Eeschema: fix Bug #1298868 (Can't create new schematic from main toolbar icon) - Fix a bug I created in rev 4773 2014-03-28 14:23:26 +01:00
jean-pierre charras 285ef4dab6 Eeschema: fix Bug #1298868 (Can't create new schematic from main toolbar icon) 2014-03-28 14:08:48 +01:00
cdelbegu bc2cb06a0e Pcbnew - GAL: fix bug #1296811 (The grid can't be enable/disable via the layer manager) 2014-03-28 14:06:30 +01:00
Jean-Samuel Reynaud 8715df4ab0 Fix a mismatch between method signature in scripting/python_scripting.cpp and scripting/python_scripting.h 2014-03-28 07:27:58 -05:00
jean-pierre charras 4d02c43189 Fix (temporary fix) a bug I created in dialog_freeroute_exchange.cpp in bzr rev 4769 2014-03-27 19:28:10 +01:00
jean-pierre charras e962b9f4f6 Pcbnew: Fix bug #1296649 (Text on flipped modules incorrectly placed).
Dialog Freeroute: if freeroute.jar is find in kicad binaries, it is run as a standard java application, not as web applcation
Very minor other fixes
FPC_(SMD_type)_footprintwizard.py wizard finished.
2014-03-27 18:45:05 +01:00
Maciej Suminski 93065de210 >Added handled hotkeys:
- resetting relative coordinates
- switching units
- not official: changing transparency for layers (works only for main layers, does not work on vias/pads/etc.)
2014-03-24 18:28:21 +01:00
Maciej Suminski 3b05177a3a PCB_EDIT_FRAME::SetHighContrastLayer() went public.
Refactored code that handled zooming events.
Added PCB_RENDER_SETTINGS::Get/SetSketchMode().
PCBNEW_CONTROL reacts to hot keys changing display modes (sketch via/tracks, high contrast).
2014-03-24 17:20:23 +01:00
Maciej Suminski 6181ee494b Added PCBNEW_CONTROLS for handling miscellaneous hot keys (trying to be compatible with the default hot key settings). Currently there are a lot of stubs to be filled out (in pcbnew_controls.cpp).
Handled actions:
- switching layers
- switching grids
- changing track width & via size
2014-03-24 08:45:05 +01:00
jean-pierre charras 8faf3f740f Eeschema: does not close when the schematic file given in command line to run Eeschema is not found (i.e. when starting a new project). Otherwise one cannot start a new schematic project. 2014-03-23 07:44:15 +01:00
Marco Serantoni 8ef7b23c04 [MacOSX] forgot pl_editor, thanks Jean-Paul for pointing it 2014-03-23 02:50:33 +01:00
Marco Serantoni 36ea1e0b0f [MacOSX] Support for kiface in bundles, workaround for some cairo issues 2014-03-22 12:35:33 +01:00
jean-pierre charras edb2b3008c Minor fixes for Windows: move resources from dso to .exe, to have the application icon in executable, and therefore shown in shortcuts.
pcb_calculator: minor coding style fix.
2014-03-22 09:28:39 +01:00
Maciej Suminski 9330924636 Changed void BASE_SCREEN::GetGrids( GRIDS& aList ) to const GRIDS& BASE_SCREEN::GetGrids().
Refactored:
- EDA_DRAW_FRAME::SetNextGrid() & SetPrevGrid()
- PCB_BASE_FRAME::SetFastGrid1() & SetFastGrid2()
Removed a warning from RN_DATA::updateNet(int).
2014-03-21 18:00:11 +01:00
Dick Hollenbeck 2b6305ba48 single_top.c logic, improved OpenProjectFiles() documentation. 2014-03-21 11:59:19 -05:00
Maciej Suminski 1f38879fef FIxed too late deletion of TOOLs. 2014-03-21 17:55:46 +01:00
Dick Hollenbeck 630df1812f Enable GITHUB as default, include typeinfo into kiway_holder.cpp 2014-03-21 07:20:54 -05:00
jean-pierre charras 8137358e8e CvPcb: Fix crashes when starting cvPcb (could be Windows Specific) and after closing the footprint viewer. 2014-03-21 12:50:04 +01:00
Maciej Suminski 18f51a4dbe PCB_EDIT_FRAME::SetActiveLayer() & GetActiveLayer() made public. 2014-03-21 11:17:47 +01:00
Maciej Suminski 5eb4ecbf1c TOOL_EVENTs autoregister themselves in ACTION_MANAGER.
ROUTER_TOOL events have temporarily changed their hotkeys assignment.
2014-03-21 10:40:50 +01:00
Dick Hollenbeck e454408772 simplify and fix the technique used to get the project fp-lib-table 2014-03-20 20:24:35 -05:00
Wayne Stambaugh eb36fb9280 Fix windows build error for missing path separator definitions.
* Use wxFileName::GetPathSeparator() instead of redefining them.
2014-03-20 14:07:19 -04:00
Dick Hollenbeck 3b48abba6d documentation clarity 2014-03-20 11:32:34 -05:00
Dick Hollenbeck 2b39b1e7ea some doxygen fixes, comment fixes 2014-03-20 09:18:32 -05:00
Maciej Suminski 84161768fa Minor fixes (check for net codes size for ratsnest, cursor coordinates are not always shown as if the cursor was snapped). 2014-03-20 11:31:32 +01:00
Maciej Suminski b1a1b12e42 GAL zooms in and out using the default hot keys (F1/F2).
Screen size is saved in VECTOR2I instead of VECTOR2D.
2014-03-20 08:47:31 +01:00
Dick Hollenbeck 8b35a0a36f * KIWAY Milestone A): Make major modules into DLL/DSOs.
!   The initial testing of this commit should be done using a Debug build so that
    all the wxASSERT()s are enabled.  Also, be sure and keep enabled the
    USE_KIWAY_DLLs option.  The tree won't likely build without it.  Turning it
    off is senseless anyways.  If you want stable code, go back to a prior version,
    the one tagged with "stable".

*   Relocate all functionality out of the wxApp derivative into more finely
    targeted purposes:
    a) DLL/DSO specific
    b) PROJECT specific
    c) EXE or process specific
    d) configuration file specific data
    e) configuration file manipulations functions.

    All of this functionality was blended into an extremely large wxApp derivative
    and that was incompatible with the desire to support multiple concurrently
    loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
    An amazing amount of organization come from simply sorting each bit of
    functionality into the proper box.

*   Switch to wxConfigBase from wxConfig everywhere except instantiation.
*   Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
    PGM_SINGLE_TOP,
*   Remove "Return" prefix on many function names.
*   Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
*   Fix building boost for use in a DSO on linux.
*   Remove some of the assumptions in the CMakeLists.txt files that windows had
    to be the host platform when building windows binaries.
*   Reduce the number of wxStrings being constructed at program load time via
    static construction.
*   Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
    these functions are useful even when the wxConfigBase comes from another
    source, as is the case in the KICAD_MANAGER_FRAME.
*   Move the setting of the KIPRJMOD environment variable into class PROJECT,
    so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
*   Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
    its child wxFrames and wxDialogs now have a Kiway() member function which
    returns a KIWAY& that that window tree branch is in support of.  This is like
    wxWindows DNA in that child windows get this member with proper value at time
    of construction.
*   Anticipate some of the needs for milestones B) and C) and make code
    adjustments now in an effort to reduce work in those milestones.
*   No testing has been done for python scripting, since milestone C) has that
    being largely reworked and re-thought-out.
2014-03-20 01:47:30 -05:00
Dick Hollenbeck ca969f0884 merge tip in, resolve. 2014-03-20 01:24:33 -05:00
Dick Hollenbeck 88489e4af6 * KIWAY Milestone A): Make major modules into DLL/DSOs.
!   The initial testing of this commit should be done using a Debug build so that
    all the wxASSERT()s are enabled.  Also, be sure and keep enabled the
    USE_KIWAY_DLLs option.  The tree won't likely build without it.  Turning it
    off is senseless anyways.  If you want stable code, go back to a prior version,
    the one tagged with "stable".

*   Relocate all functionality out of the wxApp derivative into more finely
    targeted purposes:
    a) DLL/DSO specific
    b) PROJECT specific
    c) EXE or process specific
    d) configuration file specific data
    e) configuration file manipulations functions.

    All of this functionality was blended into an extremely large wxApp derivative
    and that was incompatible with the desire to support multiple concurrently
    loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
    An amazing amount of organization come from simply sorting each bit of
    functionality into the proper box.

*   Switch to wxConfigBase from wxConfig everywhere except instantiation.
*   Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
    PGM_SINGLE_TOP,
*   Remove "Return" prefix on many function names.
*   Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
*   Fix building boost for use in a DSO on linux.
*   Remove some of the assumptions in the CMakeLists.txt files that windows had
    to be the host platform when building windows binaries.
*   Reduce the number of wxStrings being constructed at program load time via
    static construction.
*   Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
    these functions are useful even when the wxConfigBase comes from another
    source, as is the case in the KICAD_MANAGER_FRAME.
*   Move the setting of the KIPRJMOD environment variable into class PROJECT,
    so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
*   Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
    its child wxFrames and wxDialogs now have a Kiway() member function which
    returns a KIWAY& that that window tree branch is in support of.  This is like
    wxWindows DNA in that child windows get this member with proper value at time
    of construction.
*   Anticipate some of the needs for milestones B) and C) and make code
    adjustments now in an effort to reduce work in those milestones.
*   No testing has been done for python scripting, since milestone C) has that
    being largely reworked and re-thought-out.
2014-03-19 19:42:08 -05:00
unknown 884219fd90 GAL: fix zooming using mouse wheel with wxWidgets 3.0. 2014-03-19 21:07:49 +01:00
jean-pierre charras 60c0b8de0d Pad editor dialog: Better tests and error messages about issues in pad settings. Fis also an other hard to translate error messge. 2014-03-19 21:06:09 +01:00
Maciej Suminski 25538205c9 Fixed a few ratsnest glitches in GAL. 2014-03-19 15:33:13 +01:00
Maciej Suminski b34f6bcd0b Cursor coordinates are updated in GAL canvases. 2014-03-19 14:26:02 +01:00
Maciej Suminski f0dfd89d26 Fixed undo for MARKER_PCBs. 2014-03-19 13:46:52 +01:00
Maciej Suminski 46efeb0a46 DRC markers are drawn in GAL canvases. 2014-03-19 13:42:46 +01:00
Maciej Suminski 1d804eba61 Fixed mouse wheel handling for GAL canvases with wx3.0. 2014-03-19 11:57:59 +01:00
Maciej Suminski 391d7df0b5 Changed cast from float to double in RN_POLY::HitTest. 2014-03-19 11:16:01 +01:00
jean-pierre charras 9020146df5 kicad-install.sh: fix bad url for legacy libraries. Add the same script hich does not need a bazaar account to download Kicad (using https instead of ssh to create branches) 2014-03-18 19:52:29 +01:00
Maciej Suminski 77f2287acc Break points for zones are not added in the same place as existing points. 2014-03-18 17:02:10 +01:00
Maciej Suminski e1ca953c40 Isolated EDIT_CONSTRAINTs to different .cpp/.h files. 2014-03-18 16:55:06 +01:00
Maciej Suminski b857ba58ca Instant dragging (without prior selection). 2014-03-18 16:25:46 +01:00
Maciej Suminski 140361e2c8 Splitting DRAWSEGMENTs with POINT_EDITOR. 2014-03-18 15:46:38 +01:00
Maciej Suminski 3aae81b307 Breaking outlines for zones using POINT_EDITOR. 2014-03-18 14:52:22 +01:00
Maciej Suminski b361baae42 Enabled autopanning while drawing zones. 2014-03-18 14:01:09 +01:00
Maciej Suminski d52568908f EC_CONVERGING handles colinear lines properly. 2014-03-18 13:57:10 +01:00
Maciej Suminski 6b99cbe9a5 Minor fixes to zone drawing tool. 2014-03-18 11:33:49 +01:00
jean-pierre charras df9c611f09 3D viewer: fix 3D grid artifact ( bug 1293873 ) 2014-03-18 11:31:13 +01:00
Maciej Suminski 5dd03b4ecd Fixed triple click bug while drawing zones with DRAWING_TOOL. 2014-03-18 11:09:43 +01:00
Maciej Suminski a3cd531e9e Yet another approach to EC_LINE and EC_CONVERGING edit constraints. 2014-03-18 11:05:24 +01:00
Maciej Suminski 86f84b9ed0 Comments. 2014-03-18 11:04:52 +01:00
unknown fc961993d5 Warning removal, patches from Camille 019 2014-03-16 18:40:23 +01:00
jean-pierre charras 8d7bcf4995 bitmap2component: add management of image resolution: Is read from file, when exists, and can be modified in bitmap2component.
It also fix issue #747631
2014-03-16 15:10:42 +01:00
Orson 2a1bb84cf7 Corrected the error message about required OpenGL version for GAL. Fixed pcb_calculator .desktop file. 2014-03-14 21:32:25 +01:00
Maciej Suminski 9134289303 ZONE_CONTAINERs are drawn as outlines while being edited using the POINT_EDITOR. 2014-03-14 16:05:30 +01:00
Maciej Suminski d19f57b0d5 Added EC_CONVERGING for zone areas modification. 2014-03-14 15:37:55 +01:00
Maciej Suminski f8a0869314 Templated EDIT_POINT_CONSTRAINT.
Removed EDIT_CONSTRAINT::Update() - replaced with resetting constraints.
EDIT_CONSTRAINT is stored in EDIT_POIN using boost::shared_ptr instead of pointer.
Added EDIT_LINE::GetEnd() & GetOrigin(). Overridden ApplyConstraint() for EDIT_LINE.
Side EDIT_POINTS for zones are drawn as circles.
2014-03-14 15:15:38 +01:00
jean-pierre charras 85e2613f0b Doc update 2014-03-14 08:37:04 +01:00
Marco Serantoni 55c3fce790 [MacOSX] Pcbnew crash on editing dimension's line width 2014-03-14 02:10:27 +01:00
Marco Serantoni 42c0340880 [MacOSX] New OSX build enviroment now supported 2014-03-14 02:07:44 +01:00
Marco Serantoni b5faf71be4 [MacOSX] New OSX enviroment seems to be more picky about options, this fixes the linker part 2014-03-14 00:44:46 +01:00
Maciej Suminski 657ac76bbf Fixes build error with the choosy CLANG (Thanks to Maciej Suminski) 2014-03-13 18:50:52 +01:00
Maciej Suminski 3700ab0555 Yet another approach to 45 degree constraints. 2014-03-13 11:48:19 +01:00
jean-pierre charras c16837d3b6 Footprint Editor: fix a crash when the dialog to set pad properties is called from the main toolbar (i.e. to define the default setting for new pads, and not to edit an existing pad) 2014-03-13 08:15:19 +01:00
Maciej Suminski 0cb0a451a4 Pcbnew: GAL canvas selection tool bug fixes.
* Fix Python scripting error causing pcbnew_wrap.cxx to fail to build.
* Fix OpenGL canvas ratsnest missing connections in copper zones.
2014-03-12 20:55:59 -04:00
Maciej Suminski d7efbd5044 Changed cast from float to double in RN_POLY::HitTest. 2014-03-12 22:42:08 +01:00
Maciej Suminski 1770e40aec Fixed 45 degree mode toggle. 2014-03-12 17:50:24 +01:00
Maciej Suminski af7454b767 Fixed erroneous hit testing for polygons in ratsnest for GAL. 2014-03-12 17:11:52 +01:00
Maciej Suminski 3e50e00f89 Moved panning boundaries and scale limits from VIEW to VIEW_CONTROL. 2014-03-12 17:09:53 +01:00
Maciej Suminski e35647b25b Changed the way of handling BOX2 traits (used std::numeric_limits). 2014-03-12 17:09:37 +01:00
Maciej Suminski 70c62508a5 Removed excessive variable (m_Corners) from MARKER_BASE. 2014-03-12 15:53:20 +01:00
Maciej Suminski f4f78722a7 Fixed erroneous hit testing for polygons in ratsnest for GAL. 2014-03-12 15:00:14 +01:00
Maciej Suminski 9b1b505731 Workarounded SWIG problems (does not support nested C++ classes, more on the subject: http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nested_classes). 2014-03-12 14:58:49 +01:00
Maciej Suminski babeea0c45 Switched order of EDIT_POINTs for DIMENSION, so in case when feature lines are of 0 length, then still can be stretched. 2014-03-12 10:53:42 +01:00
Maciej Suminski fac1cab1d9 Added new constraint for EDIT_POINTs (EPC_LINE).
Dimensions have EDIT_POINTs.
Different handling of 45 degree mode in POINT_EDITOR.
2014-03-12 10:46:11 +01:00
Maciej Suminski 3f4ba31188 Minor fix to SEG class. 2014-03-12 10:05:09 +01:00
Maciej Suminski 187f9ff0f4 Merge selection tool branch. 2014-03-11 20:45:01 -04:00
Maciej Suminski ba7cfecd5d Workarounded SWIG problems (does not support nested C++ classes, more on the subject: http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nested_classes). 2014-03-11 14:50:53 +01:00
Maciej Suminski 7b706ee873 Added a few settings to make the layer settings more similar to KiCad defaults (moved vias to VIA_THROUGH_VISIBLE, added a few rules for required layers). 2014-03-11 10:58:58 +01:00
Marco Serantoni 8809d5580e [MacOSX] fixes some interations with KicadOSXBuilder 2014-03-10 23:37:59 +01:00
Maciej Suminski e9aec03ce0 Cursor snaps to EDIT_POINTs.
Added POINT_EDITOR::isModified().
2014-03-10 16:25:40 +01:00
Maciej Suminski bf9a7511f3 Fixed a bug caused by removed VIEW_ITEMs that were marked for updating. 2014-03-10 16:01:15 +01:00
Maciej Suminski 517c555d6a Removed unnecessary casting. 2014-03-10 10:18:48 +01:00
jean-pierre charras edcf84a2a1 Finishing work on a better 3D viewer. this also fix bugs like Bug #1129630 . 2014-03-09 19:43:53 +01:00
jean-pierre charras 0fa01812eb Pcbnew: fix Bug #1289416 (Broken setting of layer list in D_PAD:: ViewGetLayers() for GAL). 2014-03-08 20:07:35 +01:00
jean-pierre charras f610294d27 Rework on 3D viewer (work in progress): Disable or enable layers, grid or 3D footprint shapes should be now faster. 2014-03-08 20:04:23 +01:00
Wayne Stambaugh 2ebd47c331 Pcbnew: make block rotate honor the rotation angle setting. (fixes lp:1281605)
* Make block rotate command honor the rotation angle setting.  Thank you
  Umesh Mohan <mohan.umesh@gmail.com> for the patch.
* Change block rotate undo command from UR_ROTATE to UR_CHANGED so consecutive
  rotations do not lead to round errors and for proper undo in case the user
  changes the rotation angle setting between block rotations.
2014-03-07 17:34:54 -05:00
Maciej Suminski 9d0b3649a1 Added documentation. Moved some functions from .h to .cpp files. 2014-03-07 10:26:33 +01:00
Cirilo Bernardo 699dbbf53f KiCad: improve gerber file extension wildcard so gerbers show up correctly in the file tree pane. 2014-03-06 16:44:48 -05:00
Wayne Stambaugh b2ce20783e Coding policy fixes. 2014-03-06 13:38:39 -05:00
Maciej Suminski 099f58a100 Added EDIT_LINEs for dragging zone outlines. 2014-03-06 17:34:04 +01:00
Maciej Suminski 3029f762bf 45 degrees mode for POINT_EDITOR. 2014-03-06 14:41:25 +01:00
Maciej Suminski 2bce2f96d8 Undo/redo support for POINT_EDITOR. 2014-03-06 12:36:20 +01:00
Maciej Suminski 8d38938da1 Auto zone refilling after using the POINT_EDITOR.
Minor code cleaning.
2014-03-06 11:49:08 +01:00
Maciej Suminski 21d2c19333 Merged selection_tool branch. 2014-03-06 10:43:40 +01:00
Maciej Suminski 4419ef42bb Merged upstream. 2014-03-06 09:42:16 +01:00
Maciej Suminski 8461fc2f3b Removed warnings. 2014-03-06 09:14:06 +01:00
jean-pierre charras eb8d78ea21 Fix a minor bug I created in commit 4733 2014-03-05 18:57:13 +01:00
jean-pierre charras f944c79269 Minor code cleanup in 3d viewer (remove dead or useless code). Some minor other fixes. 2014-03-05 18:40:23 +01:00
Maciej Suminski aa54a3e5a1 Fixed undo while PNS is active. 2014-03-05 16:44:08 +01:00
Maciej Suminski 1d6357a76a Squashed memory leaks. 2014-03-05 14:57:14 +01:00
Maciej Suminski c66a3232ac Removed a few memory leaks. 2014-03-03 17:15:41 +01:00
Martin Janitschke 7adb74699b Pcbnew: add option to merge non-plated through holes to drill file. (fixes lp:1133330) 2014-03-03 09:28:05 -05:00
Maciej Suminski b31fede98e Pcbnew: fixed SIGFPE arithetic exception. (fixes lp:128339, 1285969, and 1286426) 2014-03-02 20:18:26 -05:00
Martin Janitschke cef8e05eb0 Pcbnew: fix global deletion bug and minor dialog changes. (fixes lp:1263795)
* Handle different item global deletions correctly.  No more removing of text
  if graphics is selected.
* Layer settings are always obeyed for modules, zones, text, and graphics.
* Text will be removed from copper layers if all layers are selected or
  according to the current layer.
* Added check boxes for "normal" and "locked" footprints to be consistent
  with the naming for the track deletion options.
2014-03-01 12:20:22 -05:00
jean-pierre charras e28ead71b6 3D viewer: fix mirroring issue for texts in flipped footprints. 2014-02-28 18:46:18 +01:00
Fabrizio Tappero ccc11c8ed8 Commit patch about cvpcb, pcbnew and layout editor menu items, with 3 menu labels modified in Eeschema. 2014-02-28 18:31:00 +01:00
Maciej Suminski c5f04753f9 Zones are supported by POINT_EDITOR. 2014-02-28 18:24:29 +01:00
Maciej Suminski 9f4d338a02 Circles are supported by POINT_EDITOR. 2014-02-28 18:24:13 +01:00
Maciej Suminski 96ca762543 Fixed POINT_EDITOR crash on GAL change / board reload. 2014-02-28 17:20:10 +01:00
Maciej Suminski a1f80f20a7 Added TOOL_ACTION for updating EDIT_POINTS.
EDIT_POINTs show up when there is only one item selected (now after deselection as well).
2014-02-28 16:53:28 +01:00
Maciej Suminski 8d8c72856d Added TOOL_MANAGER & ACTION_MANAGER::RunAction( const TOOL_ACTION aAction ).
Selection clearing is invoked using TOOL_ACTION object rather than its name.
2014-02-28 15:46:05 +01:00
jean-pierre charras 7d1c0ec4db 3D viewer: shows now the texts of footprints (ref, value and others) when visible.
Fix also other very minor issues.
Realistic mode shows or not the copper thickness (depending on selected option in preferences) to speed up the screen redraw.
2014-02-28 11:51:47 +01:00
Maciej Suminski 16a68d8528 Fixes ratsnest crashing on zones with negative net codes. 2014-02-28 11:12:55 +01:00
Marco Serantoni 9c1f4efb6e Fix for bug #1285878, build fails with clean repository and high parallelism due missing dependance between router and pcbcommon 2014-02-27 23:56:16 +01:00
jean-pierre charras 41c4388d5c Fix Bug #1275544 (Page size dialog: page size drop-down doesn't handle mouse-click event) 2014-02-27 20:53:04 +01:00
Martin Janitschke f503ee945f make microwave toolbar accessible from menu (Bug #1285425 ) 2014-02-27 19:48:18 +01:00
Maciej Suminski 125ef0a679 Initial version of POINT_EDITOR. 2014-02-27 17:29:08 +01:00
Maciej Suminski 075283d9a8 SELECTION_TOOL emits event notifying about selecting/deselecting/clearing selection. 2014-02-27 17:27:58 +01:00
Maciej Suminski dbe19fc5f9 Added VIEW::ToWorld( double ).
TOOL_EVENT message is supposed to contain string as parameter.
Added missing header for class_drawsegment.h (KiROUND).
Renamed SELECTION_TOOL::containsSelected() to SELECTION_TOOL::selectionContains().
2014-02-27 16:13:27 +01:00
jean-pierre charras 7fa70d1885 Fix wx28 compatibility issue. 2014-02-27 09:05:28 +01:00
Marco Serantoni d39cc2d65f [MacOSX] Fixing some refresh issues when changing component on cvpcb 2014-02-27 01:57:18 +01:00
Marco Serantoni 9bdb0086b4 [MacOSX] Avoid race between cmake -E copy_directory, which triggers a build error when using an high parallelism 2014-02-26 21:46:25 +01:00
jean-pierre charras eb25a2d42b * fp_lib_table.cpp: fix an issue on Windows in ConvertFromLegacy: sometimes, because the comparison was case sensitive, lib nicknames were not found, although libs exist ( for instance if a path was given like f:\mypath instead of F:\mypath)
* getpart.cpp: fix a potential bug on a translatable string with has requirements in spelling.
* fix bug  #1066179
* kicad: fix erroneous labels in sub menus.
2014-02-26 15:06:24 +01:00
Maciej Suminski 476ec04b13 Minor changes to BRIGHT_BOX class. 2014-02-25 18:08:33 +01:00
Maciej Suminski 62a76f1ed2 Removed a few RecacheAllItems() calls, some of them changed to specific type recaching (using TYPE_COLLECTOR & VIEW_ITEM::ViewUpdate() ).
Removed OPENGL_GAL::SetStrokeColor().
2014-02-25 14:28:09 +01:00
Maciej Suminski e063962ce7 Renamed BOARD_CONNECTED_ITEM::GetNet() -> GetNetCode()
Renamed BOARD_CONNECTED_ITEM::SetNet() -> SetNetCode()
Added BOARD_CONNECTED_ITEM::GetNet() for accessing NETINFO_ITEM* of a given item.
Fixed module editor crash when launched to edit a module from a PCB.
Replaced some BOARD::FindNet( item->GetNet() ) calls with BOARD_CONNECTED_ITEM::GetNet().
2014-02-25 11:47:27 +01:00
Maciej Suminski c1b7ced4e7 Renamed BOARD_CONNECTED_ITEM::GetNet() -> GetNetCode()
Renamed BOARD_CONNECTED_ITEM::SetNet() -> SetNetCode()
Added BOARD_CONNECTED_ITEM::GetNet() for accessing NETINFO_ITEM* of a given item.
Fixed module editor crash when launched to edit a module from a PCB.
Replaced some BOARD::FindNet( item->GetNet() ) calls with BOARD_CONNECTED_ITEM::GetNet().
2014-02-25 11:40:34 +01:00
jean-pierre charras 250b558878 Viewlib: ensure in wxListBoxes the lib and the component are always shown as selected when a lib and component are specified (when called by the get component dialog for instance) 2014-02-24 20:07:24 +01:00
Maciej Suminski 374b15ff9e Minor code cleaning and optimizations. 2014-02-24 14:31:55 +01:00
Maciej Suminski de0e8bd519 Fixed a missing group clearing and update for restored VIEW_ITEMs.Fixed a missing group clearing and update for restored VIEW_ITEMs. 2014-02-24 12:56:47 +01:00
HennerZeller dd628646f2 Eeschema: * Preselect the currently chosen component in the browser when pressing the thumbnail view.
* Various smallish documentation updates in the component chooser area.
2014-02-24 11:52:08 +01:00
Maciej Suminski 0383f93aac Some variables initialized to NULL. 2014-02-24 11:17:49 +01:00
Henner Zeller 7ae0d3960f Eeschema: component selection dialog improvements.
* Pressing 'Enter' while the focus is in the tree did not work due to the
  double-click wxWidgets workaround.  Make it work.
* More clearly document what is happening and how it can be tested.
2014-02-23 20:27:07 -05:00
Nick Ostergaard c0e8c155bd Remove duplicate comments from CMakeList.txt. 2014-02-23 20:02:41 -05:00
Martin Janitschke 714fde2418 Fix 3D viewer crash bug. (fixes lp:673603 and lp:804778) 2014-02-23 19:53:55 -05:00
Henner Zeller 8479640252 Eeschema: fix build error when using wxWidgets 2.8 and other minor fixes.
* Fix string concatenation for _( "Unit" ) + wxT( " " ). This failed
  compiling against wxWidgets 2.8 (thanks Cirilo Bernardo ).
* Base the indentation on a measured observation with explanation
  (98%-ile of name-length found in library). The previously chosen 24
  character indentation was too wide for most.
* Don't use a #define spilling into the global namespace, but use
  a locally defined constant for COLUMN_DESCR_POS.
2014-02-23 09:15:01 -05:00
Blair Bonnett 649f8c2f7c Build documentation updates and comment spelling fixes. 2014-02-22 18:17:36 -05:00
jean-pierre charras eee9670f82 Eeschema: Remove usage of tabs in dialog_choose_component.cpp strings, because it does not work very well on Linux, and does not work on Windows.
This is replaced by the right number of space, using a fixed font (like in CvPcb)
Fix mismatch between icons and the actual rotation of components (CW instead of CCW) (bug 1022154 )
2014-02-22 18:50:20 +01:00
jean-pierre charras 07db739906 Eeschema: Remove usage of tabs in dialog_choose_component.cpp strings, because they do not work very well on Linux, and do not work on Windows.
Fix incorrect rotation of components (CCW instaed of CW)
2014-02-22 13:39:59 +01:00
Marco Serantoni 090eca72bc [MacOSX] Fixing resize issue in layer setup dialog 2014-02-21 17:38:29 +01:00
Maciej Suminski be6dc9d0af Revisiting GAL:
- VIEW_ITEM::ViewUpdate() does not update items immediately. Now it marks them to be updated and the real update occurs on the next rendering frame.
- VIEW::InvalidateItem() made private.
- VIEW_LAYER::enabled -> visible
- Some functions moved to header files.
2014-02-21 16:57:18 +01:00
Maciej Suminski 81b610df16 Upstream merge. 2014-02-21 11:05:28 +01:00
Maciej Suminski ee0b425538 Quick fix for unsupported pad types in PNS router. 2014-02-21 09:53:10 +01:00
Fabrizio Tappero f4c1bac7a8 Patch from Fabrizio Tappero: better kicad and eeschema menu entries and labels, which minor fixes. 2014-02-21 08:54:13 +01:00
Wayne Stambaugh f6fd93b67e Eeschema: minor component selection dialog improvements.
* Manually change fbp file minor version number so dialog could be edited
  with latest release version of wxFormBuilder.
* Give component view panel more weight for improved component view size.
* Add padding around dialog button sizer.
2014-02-20 19:29:31 -05:00
Wayne Stambaugh bad1183955 Minor coding policy fixes. 2014-02-20 19:06:37 -05:00
Marco Serantoni 8590d7dbb8 [MacOSX] New reorg for building system, typos and path refines 2014-02-19 22:39:21 +01:00
Henner Zeller 808cc9195d Eeschema: component selection dialog improvements.
* Improve component chooser redraw to fit in wxWidgets redraw strategies.
* Use LIB_COMPONENT::Draw and LIB_COMPONENT::GetBoundingBox for drawing the
  component
* Make resize redrawing work properly.
2014-02-19 11:44:48 -05:00
Maciej Suminski e4b2deed51 Removed some excessive variables. 2014-02-19 15:20:42 +01:00
Maciej Suminski 3dbb864e5e Continous mode for drawing tools (i.e. they do not finish after adding a single object). 2014-02-19 13:51:32 +01:00
unknown a3e7b856b1 GLM (tool for opengl) update to 0.9.4.6 2014-02-19 11:51:33 +01:00
Henner Zeller 4cdd8e754a Eeschema component selection dialog improvements.
* Allow to select units in components that have more than one right in the
  component chooser dialog.
* Keep chosen unit in history.
* Show preview of current component unit as thumbnail image next to the
  description box.
* Fixes lp:1280567
2014-02-18 16:41:27 -05:00
Marco Serantoni 0d68df1d93 [MacOSX] Fix for bugs #1258081 and #1267772 2014-02-18 21:30:17 +01:00
jean-pierre charras 26fd1960e6 Remove some fully outdated code (#pragma, from Henner Zeller's report, and some other things) 2014-02-18 12:41:53 +01:00
Marco Serantoni af075c1cb2 [MacOSX] Fix some small issues, this should be the least for scripting 2014-02-17 19:58:03 +01:00
unknown 19d3864a5d GLM (tool for opengl) update to 0.9.4.6 2014-02-17 19:42:52 +01:00
Maciej Suminski f01b2502c8 Added TOOL_ACTION for PNS router activation.
Most of the GAL tools are activated by corresponding buttons on the right toolbar.
Removed menu entry for PNS router (as it is activated as the usual "Add track" tool).
2014-02-17 18:21:00 +01:00
Maciej Suminski 0161fab1a3 Fixed wrongly formulated assert. 2014-02-17 17:20:44 +01:00
Maciej Suminski 364d0e0f02 Undo/redo support. 2014-02-17 14:53:01 +01:00
Maciej Suminski 7278716c65 Small leak fix. 2014-02-17 14:36:51 +01:00
Maciej Suminski e79d47fed2 Improved way of drawing 45-degree lines. 2014-02-17 11:33:03 +01:00
Maciej Suminski 6348c77788 Pcbnew: fix OpenGL PNS router track not shown bug. (fixes lp:1275319) 2014-02-15 18:54:51 -05:00
Marco Serantoni ea87d8247e [MacOSX] wxPython patch revised for http://trac.wxwidgets.org/ticket/15957 2014-02-15 19:09:14 +01:00
Marco Serantoni af54a74a24 [MacOSX] support for plugins in the bundle 2014-02-15 11:01:27 +01:00
Cirilo Bernardo 8123415163 Export VRML and IDF maintenance.
Fix minor bug in eeschema (opening a relative path does not work) (patch from HennerZeller).
2014-02-15 08:39:06 +01:00
Marco Serantoni 45f64652ef [MacOSX] Reorg and preparation to include scripts into Bundles 2014-02-14 22:09:48 +01:00
Henner Zeller 79807dd948 Eeschema: Better naming for private struct: public fields uppercase.
* make some more fields 'const' that can.
* Instead of previous/next _visible_ element, Go through
      previous and next element. Otherwise the cursor stops moving
      if the item is only partially visible.
2014-02-14 18:16:59 +01:00
Maciej Suminski 6d3e691dd9 Added a few asserts. Made some steps idiotproof. 2014-02-14 15:52:13 +01:00
Maciej Suminski 834dce571e New items are created using pointers (instead of copying automatic variables when drawing is finished). 2014-02-14 15:13:42 +01:00
Maciej Suminski 8aef3b30fa Refactorization: moved drawing 45 degree multiple line to a function. 2014-02-14 14:24:12 +01:00
Maciej Suminski 4c9e2acb02 GAL::GetGridPoint() returns point in world coordinates. 2014-02-14 14:16:08 +01:00
Maciej Suminski 1c7cc3229c Some more minor refactorization. 2014-02-14 11:35:48 +01:00
Maciej Suminski 881b24c6e4 Refactoring: zones and keepout areas are drawn using the same function. 2014-02-14 10:47:43 +01:00
Maciej Suminski b0aa561719 Refactoring: made VIEW, VIEW_CONTROLS, BOARD and PCB_EDIT_FRAME fields in DRAWING_TOOL. 2014-02-14 09:49:49 +01:00
Henner Zeller 4abc6ea0cb PATCH: making component choosing (much!) more usable 2014-02-14 09:07:20 +01:00
Henner Zeller 33c07934b6 PATCH: making component choosing (much!) more usable 2014-02-14 09:05:04 +01:00
Maciej Suminski 249de46078 Cursor is in world coordinates. 2014-02-13 20:23:28 +01:00
Maciej Suminski d19280aeb9 Small GAL refactorization, mostly correcting constness. 2014-02-13 19:31:27 +01:00
jean-pierre charras 9a56467e13 Fix a minor error in class D_PAD: void D_PAD::Flip( int Y ) changed to virtual void D_PAD::Flip( const wxPoint& aCentre ) (as defined in BOARD_ITEM)
Scripting: fix compatibility current pcbnew version in 2 examples and the default extension of board files  in board.i (was .kicad_brd, now is .kicad_pcb)
2014-02-13 18:27:48 +01:00
Maciej Suminski 1492f71d6c Added keepout areas drawing tool. 2014-02-13 16:24:33 +01:00
Maciej Suminski 88bc292a37 Added zone drawing tool. 2014-02-13 16:10:32 +01:00
Maciej Suminski ff12d3d2e5 Changed PCB_EDIT_FRAME::setTopLayer() to PCB_EDIT_FRAME::SetTopLayer() and changed to public (as it had exactly the same functionality). 2014-02-13 15:57:57 +01:00
Maciej Suminski 39de31f7b2 Placing modules with a minor bug. 2014-02-13 12:46:39 +01:00
Miguel Angel Ajo 750cf6a26e switching to the new python scripting console icon 2014-02-12 22:19:12 +01:00
Miguel Angel Ajo 7b754b723c Enforces python2.6 / 2.7, thanks to orsonmmz 2014-02-12 22:17:19 +01:00
Maciej Suminski 7cddc08e1f Merged fix from the selection_tool branch. 2014-02-12 18:04:27 +01:00
Maciej Suminski ddfdbb6ff0 NETINFO_ITEM for orphaned items now have empty netname and net code = 0 (to avoid problems).
Fixed case for the footprint legacy plugin when added module's do not have set parent (BOARD).
Added copyright notice for pcbnew/class_netinfolist.cpp (feel free to correct, it is just copied from corresponding header file).
2014-02-12 18:01:03 +01:00
Fabrizio Tappero 3f05c57f61 Some icons update 2014-02-12 14:56:52 +01:00
jean-pierre charras ddd39027e7 Fix issues in print mirror. (include some changes coming from Cirilo Berdarno's patch)
gr_basic.cpp: rewrite the function which draws the outlines of a thick segment.
2014-02-12 11:03:34 +01:00
Nick Østergaard 5a9d750f7d Fix wrong numbering in the QFP footprint wizard python script 2014-02-12 08:59:56 +01:00
Fabrizio Tappero b46b5352c4 Update icon_bitmap2component. 2014-02-12 08:53:55 +01:00
Marco Serantoni d6fcc48ed0 [MacOSX] Refines in building system, now bundles lib migration supports symbolic links 2014-02-12 00:13:14 +01:00
Henner Zeller a66758406e * Apply Henner Zeller's patch to add connecting line from reference and labels to component position whilst moving to help identify which component the reference or label belongs too 2014-02-11 21:54:30 +00:00
Fabrizio Tappero 6c8b0ea59c Icon update, and an other very minor fix. 2014-02-11 19:32:09 +01:00
Maciej Suminski 59a56fc820 Added PCB_TARGET placing tool. 2014-02-11 17:15:33 +01:00
Maciej Suminski 0eed6c360c Small fix for crippled polylines containing 0 points. 2014-02-11 15:01:49 +01:00
Maciej Suminski 46f3c2210d Fixed ratsnest related segfaults on BOARD destruction. 2014-02-11 14:39:14 +01:00
Maciej Suminski 962a0e16c5 Added DIMENSION drawing tool. 2014-02-11 14:38:44 +01:00
Maciej Suminski 8feab0ad66 Fixed ratsnest related segfaults on BOARD destruction. 2014-02-11 14:26:33 +01:00
Maciej Suminski 4eee9e18d5 Removed redundant fields DIMENSION::m_arrowD1O, m_arrowD2O, m_arrowG1O, m_arrowG2O (==m_crossBarO/F).
Added DIMENSION::SetOrigin(), DIMENSION::SetEnd(), DIMENSION::GetOrigin(), DIMENSION::GetEnd(), DIMENSION::GetHeight().
Fixed flipping for DIMENSION class.
Added an information that helps to understand roles of the points in the DIMENSION class.
Some minor changes to PCB_PAINTER (mainly using const COLOR4D& for taking the result of GetColor() function).
2014-02-11 13:22:30 +01:00
Lorenzo Marcantonio ae93328c21 - Do not autonumber NPTH pads on add in module editor (keep the number blank)
Factored out the next-pad-number function
2014-02-10 18:19:15 +01:00
Maciej Suminski 0dac3077bd Made rotate & flip tool actions generic.
Drawing tool reacts to rotate & flip events while placing a text.
2014-02-10 17:08:55 +01:00
Maciej Suminski 5491a468ba Basic text placing tool. 2014-02-10 15:40:25 +01:00
jean-pierre charras b704410dd2 Use environment KISYS3DMOD to know the default path for 3D shapes in footprint editors dialogs, and build short 3D file names.
This value is now shown in these dialogs.
2014-02-10 11:01:11 +01:00
Maciej Suminski aaf0c13838 Drawing arcs - version 1 2014-02-10 10:58:58 +01:00
jean-pierre charras c795d04614 fix linux compil. 2014-02-10 10:58:17 +01:00
jean-pierre charras b7d5bd5ab8 Use environment KISYS3DMOD to know defaut path for 3D shapes in footprint editors dialogs. 2014-02-10 10:30:08 +01:00
Miguel Angel Ajo b84ada1ab6 Fix py26 testing for OSX, assertIsNotNone unavailable for py26 2014-02-10 10:15:48 +01:00
jean-pierre charras 2451de0e1b Cosmetic enhancement: better icon for bitmap2component. 2014-02-09 21:06:05 +01:00
Miguel Angel Ajo 373a5b5bb7 BOARD saving test 2014-02-09 00:21:47 +01:00
Marco Serantoni a4fe76d2a7 [MacOSX] Setting Set3DShapesPath 2014-02-08 18:33:21 +01:00
Marco Serantoni 1cacfffd5f [MacOSX] Fixing build system, sorry guys, refining build system and make building smoother. 2014-02-08 16:15:06 +01:00
jean-pierre charras e88e8b1ed3 Add the environment variable KYSYS3DMOD to define a default path for 3D models.
If it is not defined by user, it is set to a legacy 3D files path.
The default value needs to be fixed on MACOSX.
This change could be better, but it is compatible with environment variables and the old way ( defined search paths) to find 3D shape files.
3D shapes files names can  also include an environment variable definition, like libraries names.
However using KYSYS3DMOD in these names is not required.
If the 3D filename is a legacy name, KYSYS3DMOD is automatically used as default path.
2014-02-08 12:54:24 +01:00
jean-pierre charras 0c615f78a1 Add the environment variable KYSYS3DMOD to define a default path for 3D models. 2014-02-08 11:44:55 +01:00
jean-pierre charras 42aeed5421 main CMakeLists: build lib-wxpython only if KICAD_SCRIPTING_WXPYTHON is ON 2014-02-08 08:42:41 +01:00
Miguel Angel Ajo 669912ea9b More BOARD unit tests 2014-02-08 01:02:29 +01:00
Marco Serantoni 6f6a79407b [MacOSX] Fixing qa, thanks Miguel Angel for the feedback 2014-02-08 00:40:11 +01:00
Marco Serantoni b93146ab87 [MacOSX] Adding patches for wxPython && http://trac.wxwidgets.org/ticket/15957 2014-02-07 23:00:19 +01:00
Maciej Suminski 9583c522dd Moved PCB_VISIBLE size check to .cpp. 2014-02-07 20:54:58 +01:00
Maciej Suminski 90c0e2e8f4 Right click on an item when there is nothing selected - enables the context menu. 2014-02-07 20:44:34 +01:00
jean-pierre charras aff1bdc853 Remove duplicate icon apply.svg (use ckecked_ok.svg instead which is the same icon).
Add a workaround to fix a new bug in wxWidgets 3.0 ( Windows specific ) which shows icons only with a size = 16x16 in menus which have attribute wxITEM_CHECK
2014-02-07 20:32:08 +01:00
Marco Serantoni c0b0918c45 [MacOSX] Fixing minor issue for wxPython 2014-02-07 20:19:53 +01:00
Maciej Suminski 68a1b06674 Corrected bounding box for arcs (DRAWSEGMENT). 2014-02-07 19:55:40 +01:00
Marco Serantoni 09636c1a88 [MacOSX] Automating building for OSX with KICAD_SCRIPTING, see Documentation/compiling/mac-osx.txt 2014-02-07 19:53:54 +01:00
Maciej Suminski 52e5d11d0a Corrected bounding box for arcs (DRAWSEGMENT). 2014-02-07 19:51:04 +01:00
Henner Zeller 110507449c * Bring CvPcb footprint window to the front when it has been obscured by another window 2014-02-07 18:38:41 +00:00
Brian Sidebotham da0e9c5299 * Add Henner's patch (with minimal changes) to ensure CVpcb footprint view window is always brought into view, even after being hidden by another window 2014-02-07 18:36:12 +00:00
Brian Sidebotham 109e628903 * Fix Project templates location under Linux, preserve Windows location 2014-02-07 18:19:53 +00:00
Brian Sidebotham d973165737 * Fix linux location for system project templates 2014-02-07 18:17:58 +00:00
jean-pierre charras 8ddba7a836 Minor fixes. 2014-02-07 17:09:15 +01:00
Cirilo Bbernardo 56c237410b IDF export: fix incorrect rotation of flipped items. 2014-02-07 17:01:46 +01:00
Maciej Suminski 5959e7c2ef Upstream merged. 2014-02-07 09:52:47 +01:00
Maciej Suminski 9f18e6f152 Reverted changes introduced by the revision 4655. 2014-02-06 21:34:03 +01:00
Maciej Suminski 171d3e1c88 Merged fix for wrong snapping. 2014-02-06 17:31:24 +01:00
Maciej Suminski 9f5d968476 Fixed snapping item in a wrong spot bug. 2014-02-06 17:29:13 +01:00
Maciej Suminski 93483241ed Actually added files for drawing tools. Added possibility of drawing circles. 2014-02-06 17:12:37 +01:00
jean-pierre charras 34724c8d99 add missing svg file 2014-02-06 16:54:55 +01:00
Fabrizio Tappero 00ee7cd462 Fix issues in icons with texts, from Fabrizio Tappero. 2014-02-06 16:49:37 +01:00
jean-pierre charras 11fcf7ab6e Fix some incorrect icons (which were using a not supported font for texts). Add ps_router icon from Konstantin Baranovskiy. 2014-02-06 15:13:31 +01:00
Maciej Suminski 3a25e108f5 Initial version of the drawing tool. 2014-02-06 15:09:38 +01:00
Maciej Suminski 5299e41ac4 Added TOOL_INTERACTIVE::Activate().
Removed an unnecessary header from class_board_item.h.
2014-02-06 14:45:33 +01:00
Maciej Suminski 37dc675b7a Merged the lp:~cern-kicad/kicad/selection_tool branch. 2014-02-06 12:48:18 +01:00
Maciej Suminski 8718c57d41 Fixed included headers. 2014-02-06 12:38:47 +01:00
Maciej Suminski 6732726f13 GAL::GetGridPoint() takes a const reference. 2014-02-06 12:38:06 +01:00
Maciej Suminski 9e4e5ddd03 Modifiers (Shift/Ctrl/Alt) are set also while moving the mouse cursor. 2014-02-06 10:43:19 +01:00
Fabrizio Tappero 96db0f38f7 New other icons from Fabrizio Tappero, and some svg file fixes 2014-02-06 09:29:45 +01:00
Fabrizio Tappero 793b144e3b New other icons from Fabrizio Tappero, and some svg file fixes. 2014-02-06 09:28:29 +01:00
Fabrizio Tappero 9427ce29d1 New icons from Fabrizio Tappero 2014-02-05 15:36:57 +01:00
Maciej Suminski 6d6181cdfa Minor optimizations. 2014-02-05 14:51:19 +01:00
Maciej Suminski b3c5980e61 Merged ratsnest_threadsafe branch. 2014-02-05 11:55:04 +01:00
Maciej Suminski c8c98753b5 Initialized value to suppress Valgrind warnings. 2014-02-05 11:33:45 +01:00
Maciej Suminski de0c476042 Fixed removal of items in the KiCad-default style. 2014-02-05 11:08:34 +01:00
Maciej Suminski cff1ea84ee Fixed bug introduced in the last commit. 2014-02-05 10:47:55 +01:00
Maciej Suminski aff5e66ab8 Some items were still marked as selected after undoing an operation. 2014-02-05 10:30:50 +01:00
Cirilo Bernardo 4010a5709c Apply IDF tools patch from Cirilo Bernardo 2014-02-05 10:29:01 +01:00
Cirilo Bernardo 82bfe0dbdf Apply IDF tools patch from Cirilo Bernardo 2014-02-05 10:27:21 +01:00
Maciej Suminski 7e8b1906b2 Grip margin is relative to the world's zoom. 2014-02-05 10:17:14 +01:00
Maciej Suminski cf9e5417d0 Added possibility for editing pads properties. 2014-02-05 09:05:27 +01:00
Miguel Angel Ajo 3d849fd87c Adding a first BOARD class tester, very basic 2014-02-04 22:16:32 +01:00
Maciej Suminski 244be39ffa Added KiCad-style modification methods (hover over an item and press a hot key, without selecting first).
Modification point is selected basing on the number of selected items.
Rotation angle setting (Preferences->General) is taken into account while rotating.
2014-02-04 17:27:00 +01:00
Maciej Suminski 9ee9c93ef8 Added 2 tool actions:
- pcbnew.InteractiveSelection.Single for selecting a single item
- pcbnew.InteractiveSelection.Clear for clearing the selection
Made SELECTION_TOOL::clearSelection private.
2014-02-04 16:03:56 +01:00
Maciej Suminski 980e325ba1 Edit tool may still be activated if it was invoked with no selected items. 2014-02-04 14:21:29 +01:00
Maciej Suminski e954736b5d Protection against non consecutive net codes. 2014-02-04 13:40:39 +01:00
Maciej Suminski 6e666b5d62 Modifiers (Alt/Shift/Control) are properly set for events when autopanning is active. 2014-02-04 13:38:18 +01:00
Maciej Suminski 0833cd4b61 SELECTION_TOOL::SELECTION::Clear made private, as there was no chance to call it outside the SELECTION_TOOL class. 2014-02-04 11:37:54 +01:00
Maciej Suminski 221b68d0b8 Snapping settings are valid while autopanning. 2014-02-04 09:44:16 +01:00
Dick Hollenbeck 3a0f1c4126 Windows name export tweak 2014-02-03 23:05:07 -06:00
Dick Hollenbeck a792a0e7ea remove wxApp()::FindLibraryPath() usages from Pcbnew. Use environment variable substitution. 2014-02-03 15:39:42 -06:00
Dick Hollenbeck cad85c8a7a KIWAY in progress... 2014-02-03 13:26:18 -06:00
Maciej Suminski 51bf04932b Enabled PNS for selected items. 2014-02-03 18:09:17 +01:00
Maciej Suminski 8cfc8b0157 Ratsnest lines for zones are removed when a zone is dragged. 2014-02-03 17:40:39 +01:00
Dick Hollenbeck c40d25df29 Initial KIWAY (modular-kicad) work. Various tweeks. 2014-02-03 09:21:04 -06:00
Dick Hollenbeck 5d4eab87f8 Initial KIWAY (modular-kicad) work. Various tweeks. 2014-02-03 09:10:37 -06:00
Maciej Suminski 7dc9eefc83 Minor changes (fix cvpcb build issue, wx2.8 compatibility, some other stuff). 2014-02-03 16:02:54 +01:00
Maciej Suminski d3ee4b1eda Takes into account hidden module text settings. 2014-02-03 07:22:31 -06:00
Maciej Suminski 82838e6770 Moved netnames (GAL specific layers) to a separate enum, to avoid saving/reading their settings from files.
Added a check for the number of PCB_VISIBLE elements.
Worksheet & general purpose overlay layers are visible by default.
2014-02-03 14:14:53 +01:00
Maciej Suminski f35e6412bd Minor changes. 2014-02-03 13:26:25 +01:00
Maciej Suminski 90e8aba660 Changed ROUTER_PREVIEW_ITEM layer. 2014-02-03 13:09:10 +01:00
Maciej Suminski eb053cac2b Changed BOARD_DESIGN_SETTINGS::m_VisibleElements from int to long, to assure at least 32 bits length (without depending on the platfrom int size). 2014-02-03 13:08:01 +01:00
Maciej Suminski 5a6f259f2c Fixed tracks of 0 width causing division by 0 error. 2014-02-03 13:05:27 +01:00
Miguel Angel Ajo b331a3b3fd Moved QA to root. 2014-02-02 22:50:45 +01:00
Dick Hollenbeck 0ec0b63ad2 Another attempt at wxFrame::SaveSettings() standard infrastructure. 2014-02-02 14:18:10 -06:00
jean-pierre charras 659c2184b3 Eeschema: Fix bug #1271155 relative to Grid selection in Eeschema. 2014-02-02 20:51:50 +01:00
Cirilo Bernardo 6bbd4defaf Dxf import fix (patch from Cirilo Bernardo, with a minor change) 2014-02-02 10:07:02 +01:00
jean-pierre charras ea4867d5b1 Kicad manager: code cleaning (better use of wxaui manager). Fix a very minor bug. 2014-02-02 10:02:29 +01:00
jean-pierre charras 8d14b4798e Kicad manager: code cleaning. Fix a very minor bug. 2014-02-01 19:27:18 +01:00
Carl Poirier 911ee57de6 Parallelized the RN_DATA::Recalculate() function. 2014-01-31 18:27:06 +01:00
Maciej Suminski 2536bae624 Added the dynamic ratsnest for the tracks that are currently routed with the PNS router. 2014-01-31 18:05:11 +01:00
Maciej Suminski 27ecb2c930 Undo/redo buffer fixed once again.. 2014-01-31 16:08:20 +01:00
Maciej Suminski 9ba5058e66 Minor change to clearing selection handling. 2014-01-31 14:52:01 +01:00
Maciej Suminski 7faf9fb9a4 Safer RN_NET::GetNodes() 2014-01-31 14:41:15 +01:00
Maciej Suminski 63196b5a8a Added missing operators==/!= for RN_NODE_PTR.
Moved ClearSimple() functions back to the header file.
2014-01-31 13:19:59 +01:00
Maciej Suminski 8d37c9122f Ratsnest is updated after backend switch. 2014-01-31 13:14:18 +01:00
Maciej Suminski 7caeff6af9 Ratsnest color is saved in RENDER_SETTINGS. Temporary ratsnest is drawn using a brightened color. 2014-01-31 11:16:01 +01:00
Maciej Suminski ecf6698d4f Fixed undo/redo while routing with the PNS error. 2014-01-30 17:11:40 +01:00
Maciej Suminski 48c10f9e5b Another way of handling items for the ratsnest (clearer and now finally supports undo/redo of the PNS created tracks). 2014-01-30 15:46:39 +01:00
Maciej Suminski 89463b0d2d Undo buffer for the PNS router. Still, it has a bug - it crashes when an undo/redo operation is performed while routing a track. 2014-01-30 11:32:08 +01:00
Maciej Suminski d2e865146b Added a new tool event: TA_UNDO_REDO, sent after undo/redo operation is issued. 2014-01-30 11:18:58 +01:00
jean-pierre charras 1283747b59 3d-frame: is now derived from EDA_BASE_FRAME. Remove duplicate code and some useless includes 2014-01-30 09:18:47 +01:00
jean-pierre charras a2df815ba6 Add specific bitmaps in export IDF and export DSN menus.
Add missing calls to Show( false ) to some main frames (Kicad, eeschema, gerbview), to force config saving when closing these windows.
Code cleanup and minor coding style fixes in footprint_wizard_frame.
2014-01-29 19:39:16 +01:00
Dick Hollenbeck cd7d6d470b Make option KICAD_KEEPCASE actually functional for Eeschema, and make the setting default ON.
The desire is to migrate designs *away from* case independence, and to create
designs which use literally (case specific) interpreted component names. But for
backwards compatibility, you may turn OFF this option if you really must.
(Remember that with KiCad using text data files, typically you would be better
off simply doctoring those files into a case literal state with a text editor
and move forward into the brave new world of case specificity. Also, BOM
generators may not work properly when you have this option turned OFF, the xml
export's referential integrity is broken on library part name. Hence the default
is ON now, as of 29-Jan-2014.
2014-01-29 12:02:02 -06:00
jean-pierre charras e8ef3c14d4 Add specific bitmaps in export IDF and export DSN menus.
Add missing calls to Show( false ) to some main frames (Kicad, eeschema, gerbview), to force config saving when closing these windows.
Code cleanup and minor coding style fixes  in footprint_wizard_frame
2014-01-29 18:01:42 +01:00
unknown 3a8ca47fce Pcbnew: export IDF fixes 2014-01-29 17:42:21 +01:00
Maciej Suminski 4566d8717a PNS_ITEM::m_parent: BOARD_ITEM->BOARD_CONNECTED_ITEM 2014-01-29 15:35:25 +01:00
Maciej Suminski c2a12d903f RN_DATA::GetNets() -> RN_DATA::GetNet() with an assert to check if someone calls it for the unconnected net.
Only items that belong to a net are removed from ratsnest.
2014-01-29 15:24:19 +01:00
Maciej Suminski 2171fd0b18 Ratsnest lines are drawn using a more transparent color.
BOARD::chainMarkedSegments() uses a safer method for gettings pads.
2014-01-29 14:51:50 +01:00
Maciej Suminski a051887971 Ratsnest is updated after rotation, flip, undo/redo operations.
Fixed crashes of ratsnest when a pointer for an item has changed after undo/redo operations.
Vias are properly removed from ratsnest (pcbnew/class_board.cpp).
2014-01-29 10:17:14 +01:00
Maciej Suminski 6e28e5bdf0 Added RN_DATA::Add()/Remove() methods.
RN_DATA::Update()/AddSimple() take BOARD_ITEM* as the parameter (instead of being split to versions with BOARD_CONNECTED_ITEM* and MODULE*), to make the code look clearer.
2014-01-28 16:30:58 +01:00
Maciej Suminski cd0d91a611 Added BOARD_[CONNECTED_]ITEM::IsConnected() for checking if a BOARD_ITEM is BOARD_CONNECTED_ITEM as well. 2014-01-28 16:23:08 +01:00
Dick Hollenbeck 176607db25 Add option --remove-orphaned-libraries to scripts/library-repos-install.sh 2014-01-28 08:23:01 -06:00
Maciej Suminski ea943ce605 Merged the netnames branch. 2014-01-28 11:59:04 +01:00
Maciej Suminski b114526b12 Upstream merge. 2014-01-28 10:43:55 +01:00
Maciej Suminski 58f813b6e8 Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).

Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.

- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).

- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.

- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok

Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 10:19:51 +01:00
Dick Hollenbeck c389c2f6e4 Add EDA_BASE_FRAME::Show() and call SaveSettings() only from there for all derived wxFrames. Remove calls to SaveSettings() elsewhere. 2014-01-27 19:29:26 -06:00
Marco Serantoni 144de5dd78 [MacOSX] KICAD_BUILD_DYNAMIC stabilized and almost working 2014-01-27 23:24:04 +01:00
jean-pierre charras 139ca8f6ef Bitmap2component: fix Bug #1273082 (patch from Wesley Dungan) 2014-01-27 18:22:49 +01:00
Dick Hollenbeck 741602c9cc Report findings of possible github zipfile caching in a comment, improve a Sprintf() setup. 2014-01-27 09:51:14 -06:00
Maciej Suminski 04ff538d11 Thread-safe version of Delaunay triangulation. 2014-01-27 11:42:47 +01:00
jean-pierre charras 825561d6f4 github_plugin.cpp: in error message relative to"cannot get zip archive...", line 496, make the sentence relative to http GET command not translatable
inside the full translated message.
2014-01-27 09:48:17 +01:00
Dick Hollenbeck d932043905 Remove g_LibraryNames and all supporting infrastructure from pcbnew. FP_LIB_TABLE is now local to major wxFrames. 2014-01-27 01:23:02 -06:00
Dick Hollenbeck 68d613ef0d Use factored SelectLibrary() from base class. Spelling and comments. 2014-01-27 00:41:40 -06:00
Maciej Suminski 6ffcddcb87 GAL takes into account hidden module text settings. 2014-01-26 22:02:48 +01:00
Maciej Suminski e9ece451af Fixes crash when there are no edges for a given net in the ratsnest. 2014-01-26 22:01:42 +01:00
jean-pierre charras 5d8db7fa96 Pcbnew: fix Bug #1272926 (Texts are now not accepted on edge cuts layer) 2014-01-26 18:30:20 +01:00
jean-pierre charras 608de9970b Pcbnew: fix bug #1272714 . Code cleanup: use 2 different enums for pad shapes and pad drill shapes. Remove never used pad shape. 2014-01-26 15:20:58 +01:00
Marco Serantoni 97de56756f [MacOSX] adding multiprocess building and initial support for KICAD_BUILD_DYNAMIC 2014-01-26 14:09:36 +01:00
Cirilo Bernardo 854f882090 add patch from Cirilo Bernardo (about IDF export) , and minor fixes. 2014-01-25 15:36:56 +01:00
jean-pierre charras 1119c1e68f add patch from Cirilo Bernardo, and minor fixes. 2014-01-25 13:23:29 +01:00
Marco Serantoni c5bc58ee46 [MacOSX] Adding wx-widgets building with patches for OSX preparing for dynamic.. 2014-01-24 22:09:31 +01:00
Marco Serantoni 0cd99fc3b3 [MacOSX] Fixing in the case -arch are not set with cairo 2014-01-22 19:01:36 +01:00
Dick Hollenbeck dadec3bd25 Increase boost download TIMEOUT to 10 minutes, offer a LOG_DOWNLOAD option for capturing download problems. 2014-01-22 07:44:02 -06:00
Dick Hollenbeck 6ac1bae539 fix 2014-01-21 09:25:43 -06:00
Dick Hollenbeck 068076a2c2 tugs and bugs 2014-01-21 00:59:32 -06:00
Dick Hollenbeck 51fe856360 freerouter does not understand "mixed" layers, export mixed as signal 2014-01-20 13:11:42 -06:00
Dick Hollenbeck c719b4f3c3 use changed URL to library repo. 2014-01-20 13:10:45 -06:00
Dick Hollenbeck f7f45dc4c8 Add EDA_APP::setLanguageId() accessor and fix FindwxWidgets.cmake for windows cross on linux. 2014-01-20 03:33:17 -06:00
jean-pierre charras dfbafdc3fb Code cleanup and minor fix in viewlib. 2014-01-19 17:36:12 +01:00
jean-pierre charras 2d62eab4b4 Fix some issues in modview, relative to few incorrect use of some wxAuiManager functions.
Fix not working + and - keys in layers manager.
Fix typo errors and modify some messages to make translator's life more easy.
2014-01-19 14:12:57 +01:00
unknown 4478c09544 Fix compile errors when wx3.x is built with --enable-stl 2014-01-18 03:07:05 -06:00
Dick Hollenbeck 438cdafd60 disable deprecation warnings in Debug build, change message in fp_lib_table.cpp 2014-01-18 03:04:12 -06:00
Wayne Stambaugh 53b6c1f39a CvPcb: fix no footprints shown in list when no legacy libraries are defined in project file. 2014-01-17 15:26:27 -05:00
Maciej Suminski d8ee9b8bca Added iterators for NETINFO_LIST (as net codes for existing net codes may be not consecutive). 2014-01-16 16:47:31 +01:00
Maciej Suminski 17027286bd wxWidgets 2.8 fix 2014-01-16 14:36:09 +01:00
Maciej Suminski babd441b7e NETINFO_ITEMs are not stored in a vector anymore, instead they are held in a unordered_map. Now, the net codes may be not consecutive. There is another way for assigning net codes (using a static int that holds a possible empty net code and a function that makes sure it is not used [getFreeNetCode()]).
Removed some unused fields (NETINFO_ITEM::m_NbNodes, m_NbLink, m_NbNoconn, m_Flag).
2014-01-16 14:20:51 +01:00
Maciej Suminski 41e4379924 BOARD_CONNECTED_ITEMs do not store net code anymore (m_NetCode field), instead net info is stored using a pointer to NETINFO_ITEM.
GetNet() refers to the net code stored in the NETINFO_ITEM. SetNet() finds an appropriate NETINFO_ITEM and uses it.
Removing GetNet() & SetNet() (and the whole net code idea) requires too many changes in the code (~250 references to the mentioned functions).
BOARD_CONNECTED_ITEMs by default get a pointer to NETINFO_ITEM that stores unconnected items. This requires for all BOARD_CONNECTED_ITEMs to have a parent (so BOARD* is accessible). The only orphaned item is BOARD_DESIGN_SETTINGS::m_Pad_Master, but it does not cause any issues so far.
Items that do not have access to a BOARD (do not have set parents) and therefore cannot get net assigned, by default get const static NETINFO_LIST::ORPHANED.

Performed tests:
- loaded .kicad_pcb, KiCad legacy board, Eagle 6.0 board, P-CAD board - all ok
- load a simple project, reload netlist after changing connections in eeschema - ok
- save & reload a board - ok, but still contain empty nets
- remove everything, restore with undo - ok
- remove everything, reload netlist - ok
- changing net names (all possibilites: empty->existing, empty->not existing, existing->empty, existing->not existing) - all ok
- zones: when net is changed to a net that does not have any nodes besides the zone itself, it does not get filled
2014-01-15 18:03:06 +01:00
Maciej Suminski d191e5038c Added NETINFO_LIST::UNCONNECTED constant. 2014-01-15 09:34:16 +01:00
Maciej Suminski 8571e3608c Removed:
- ZONE_CONTAINER::m_Netname field
- ZONE_CONTAINER::SetNetName()
- ZONE_CONTAINER::SetNet() [it uses the one in BOARD_CONNECTED_ITEM]
- ZONE_CONTAINER::GetNetName() [instead BOARD_CONNECTED_ITEM::GetNetname is used]
- ZONE_CONTAINER::SetNetNameFromNetCode()

Performed tests:
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
2014-01-14 11:41:06 +01:00
Maciej Suminski 08367867b9 Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.
D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.

I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.

Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
2014-01-14 10:41:52 +01:00
jean-pierre charras 0c540ebea6 Fix some issues in modview, relative to some a bad use of some wxAuiManager functions. 2014-01-13 16:09:52 +01:00
jean-pierre charras 269e88b18d Update demo files. A minor code cleaning. 2014-01-10 21:12:36 +01:00
Maciej Suminski c39b56891e Changed the way of looking up NETINFO_ITEM using net names (using boost::unordered_map). Added a hash function (wxString) for that. Introduced NETINFO_ITEM::GetNetItem( wxString ). BOARD::FindNet() uses the map.
Net codes are updated upon net list update. (BOARD::ReplaceNetlist())
Added in some places (mostly class_board.cpp) pad->SetNet() calls to synchronize net codes.
On creation of NETINFO_LIST, the first NETINFO_ITEM is added (the unconnected items net).
Removed COMPONENT_NET::m_netNumber, as it was not used anywhere.
Added an assert to D_PAD::GetNetname(), checking if net code and net name is consistent for unconnected pads. Added an assert for NETINFO_LIST::AppendNet() to assure that appended nets are unique.

It seems that at this point:
- Updating net lists works fine. The only difference between the file ouput is that after changes it contains empty nets as well.
- Nets are not saved in the lexical order. Still, net names and net codes are properly assigned to all items in the .kicad_pcb file. It is going to be addressed in the next commit. I believe it should not create any problems, as pads are sorted by their net names anyway (NETINFO_LIST::buildPadsFullList())

Performed tests:
- Created a blank PCB, saved as pic_programmer.kicad_pcb (from demos folder). Updated net lists. .kicad_pcb file (comparing to the results from master branch) differ with net order (as mentioned before), net codes and timestamps.
- Removed some of components from the above .kicad_pcb file and updated net lists. Modules reappeared. .kicad_pcb file differs in the same way as described above.
- Trying to change a pad net name (via properties dialog) results in assert being fired. It is done on purpose (as there is a call to GetNetname() and net name and net code do not match). This will not happen after the next commit.
- Prepared a simple project (starting with schematics). Imported net list, changed schematic, reimported net list - changes are applied.
- Eagle & KiCad legacy boards seem to load without any problem.
2014-01-10 18:04:07 +01:00
Maciej Suminski 3c79ed375c Made two functions immune to empty containers. 2014-01-10 17:19:33 +01:00
Brian Sidebotham 9a86def109 * Fix FindwxWidgets.cmake for V3.0 wxWidgets using 'win32' style find. i.e. for MinGW native build without msys or cygwin 2014-01-09 23:13:22 +00:00
Dick Hollenbeck faa6582adc file maintenance, update some scripts 2014-01-09 09:01:59 -06:00
Maciej Suminski f075166a21 Removed NETINFO_ITEM::SetNet() and NETINFO_ITEM::SetNetname() methods.
NETINFO_ITEM::m_Net and NETINFO_ITEM::m_Netname are const.

Changes to be verified:
- pcbnew/minimun_spanning_tree.cpp: It segfaults is m_Size == 0
- pcbnew/exporters/export_gencad.cpp: I removed the SetNetname() call, as it changes only the unconnected net and in the next line it returns if the net is unconnected. Still, I wonder if name for the unconnected net matters. What about tests that check if a net name is empty to decide if it is unconnected net or not.
2014-01-09 15:51:47 +01:00
jean-pierre charras 77bba5e9f9 Code cleanup: Pcbnew: move files relative to export functions to the new folder exporters
Pcbnew, Eeschema: remove include file <protos.h> from a lot of files which do not need it.
2014-01-08 20:29:46 +01:00
Dick Hollenbeck bbfd2fb66c Add KICAD_REPO_NAME to the about dialog and build_version.cpp 2014-01-08 08:47:39 -06:00
jean-pierre charras ec37f295c7 Code cleanup: Pcbnew: move files relative to exort functions to the new folder exporters
all: remove include <protos.h>  from a lot of  files which do not need it.
2014-01-08 15:18:51 +01:00
Maciej Sumiński af44f2c720 merge Orson's patch with changes 2014-01-07 20:02:03 -06:00
Dick Hollenbeck 913a9dcdc3 Fix option description, add mark_as_advanced(), and add a comment to KICAD_SKIP_BOOST 2014-01-07 20:00:47 -06:00
Maciej Sumiński 62b264f770 Remove assembly language files, and make building Boost optional.
https://lists.launchpad.net/kicad-developers/msg11965.html
2014-01-07 19:52:19 -06:00
Dick Hollenbeck edc2938fb8 Make KiCad compile with minimal warnings against SVN HEAD of wxWidgets as of today. 2014-01-07 19:34:04 -06:00
jean-pierre charras 2498414e91 Move files relative to export code to subdir exporters. 2014-01-07 21:41:32 +01:00
jean-pierre charras 3c5929258b Update demos. Fix pspice netlist issues when using ( and ) in net names ( parenthesis are replaced by underscore) . 2014-01-07 20:42:34 +01:00
Cirilo Bernardo 810a01b779 Commit patch about new better vrml export. patch to fix mirrored page layout when print mirrored is enabled ( page layout should not be mirrored) 2014-01-07 20:27:51 +01:00
Maciej Suminski a49015a317 Fixed snapping and ratsnest update for EDIT_TOOL. 2014-01-07 17:23:17 +01:00
Maciej Suminski 92816e4689 Delaunau triangulation algorithm was bailing out if run on an emprty container. 2014-01-07 15:52:10 +01:00
Maciej Suminski 56cd826400 Safer way for syncing pads in Push and Shover router. 2014-01-07 14:23:46 +01:00
Maciej Suminski aee4f33c09 Fixed Push and Shove and ratsnest cooperation (tracks added by PNS are taken into account while calculating ratsnest). 2014-01-07 14:22:37 +01:00
Maciej Suminski 3177f74540 Fixed snapping for Push and Shove router. 2014-01-07 14:21:37 +01:00
Maciej Suminski e8b7c6df54 Tools have possibility to react to GAL switching or model (board) reload. 2014-01-07 14:16:47 +01:00
Maciej Suminski a22364f545 Items removed from board are removed from ratsnest as well. Corrected the way of items removal from ratsnest. 2014-01-07 14:15:40 +01:00
Maciej Suminski 8626e906cb Removed TOOL_STATE.idle field, as it was redundant. 2014-01-07 14:11:53 +01:00
Maciej Suminski 980dec08cf Fixed bounding box for module texts. 2014-01-07 14:09:27 +01:00
Marco Serantoni ad2957d534 [MacOSX] Fixing STL && single processor building in pixman 2014-01-07 00:20:52 +01:00
jean-pierre charras 6742f54243 Better vrml export, from Cirilo Bernardo. 2014-01-06 21:14:24 +01:00
Maciej Suminski e2e68aea74 Upstream merge. 2014-01-06 10:29:31 +01:00
Marco Serantoni 5437f43790 [MacOSX] fixes some corner case compiling on x86 in boost 2014-01-04 14:40:22 +01:00
Marco Serantoni fc14556d43 [MacOSX] Added support in boost context for PPC processors, now is possible again compile kicad testing for PPC ( https://svn.boost.org/trac/boost/ticket/8266 ) 2014-01-04 03:13:18 +01:00
Dick Hollenbeck 4bd4c43d1a This is why we cannot have nice things. This is why we test our changes before committing.
Pray for angus johnson who is support too many languages, and needs to find a text editor that removes trailing whitespace.
2014-01-03 18:46:06 -06:00
Dick Hollenbeck f27e85eeb0 fix some compiler warnings 2014-01-03 18:07:20 -06:00
Dick Hollenbeck 16a70dd267 comment out broken tool_modview.cpp's useless footprint select button. somebody needs to fix this. 2014-01-03 17:19:54 -06:00
Dick Hollenbeck a53caab12b force switch to boost::context, add --force option to bzr clean-tree 2014-01-03 17:17:50 -06:00
Dick Hollenbeck 2cead53fc9 fix compiler warnings 2014-01-03 17:16:40 -06:00
jean-pierre charras 77defa69c6 Pcbnew: very minor fixes and update: update clipper version. uncrustify polytri/* and fix some warning compil. 2014-01-03 18:39:28 +01:00
Cirilo Bernardo 8c540c8b83 IDF3 wxDateTime patch to fix MinGW builds for missing localtime_r(). 2014-01-03 08:31:50 -05:00
Cirilo Bernado 0a415fad36 Adds basic IDF3 export (board and cutouts / holes only) 2014-01-02 10:28:10 +01:00
Cirilo Bernardo 95bb3d6bb1 Adds basic IDF3 export (board and cutouts / holes only) 2014-01-02 10:26:03 +01:00
Dick Hollenbeck 3142172cff 8 bit string relief via class UTF8 2014-01-01 20:17:07 -06:00
Dick Hollenbeck 074a265166 FIX: only invoke fp-lib-table options editor when table not empty. 2013-12-31 10:59:33 -06:00
Dick Hollenbeck ce3943446c Add bzr clean-tree to download_boost.cmake 2013-12-31 10:58:05 -06:00
Marco Serantoni 6c0c2b4365 [MacOSX] Reorganize OSX Library PATH, first the USER's one then the SYSTEM's one 2013-12-31 15:28:34 +01:00
Marco Serantoni 2fc8a05aec [MacOSX] Adding better support for Retina Display (NSHighResolutionCapable) 2013-12-31 12:03:02 +01:00
Marco Serantoni 3eab6c5af2 [MacOSX] Manage older OpenSSL API (needed for OSX 10.6) and probably older linuxes 2013-12-31 11:48:16 +01:00
Marco Serantoni d1bd519e7c [MacOSX] Manage older OpenSSL API (needed for OSX 10.6) and probably older linuxes 2013-12-31 11:45:17 +01:00
Marco Serantoni 0b62184c51 [MacOSX] Removing freetype dependecy for Cairo (uses cocoa font management) 2013-12-31 11:44:16 +01:00
Marco Serantoni 7ae4bc208a [MacOSX] disable -fvisibility due compiler blames.. 2013-12-31 11:42:25 +01:00
Dick Hollenbeck c28fbe566d minor tidying 2013-12-31 00:25:53 -06:00
Dick Hollenbeck 5ae8d9b220 Add -fvisibility options to significantly reduce binary sizes.
Switch to boost::context for all platforms, almost.
Please try your platform by commenting out fcontext.s in common/CMakeLists.txt.
2013-12-30 11:53:12 -06:00
Marco Serantoni 4d3ac11467 [MacOSX] fixes issues with previous OSX compilers gcc-4.2 and makes a better general beaviour of KICAD_BUILD_STATIC 2013-12-30 16:53:09 +01:00
Marco Serantoni 5777523b35 Fixing typo 2013-12-30 01:36:57 +01:00
Marco Serantoni e0eb666f6c [MacOSX]/All purpose - Support for static linking 2013-12-30 01:27:03 +01:00
jean-pierre charras 19ebe3feb8 eeschema: fix compil issue. Boost build: boost lib context built only on OSX (does not build on mingw, and not needed) 2013-12-29 23:05:06 +01:00
Marco Serantoni b9e9480e5c [MacOSX]/All purpose - Starting support to static linking 2013-12-29 20:38:12 +01:00
Marco Serantoni 70b7131ae7 [MacOSX] fixes a missing feature in boost and fixes static build with x86/i386 involved
(https://svn.boost.org/trac/boost/ticket/8266)
2013-12-29 20:36:30 +01:00
jean-pierre charras 7ec2c004a2 fix bugs 1264240, 1264247, 1264239, 1264233 (clang report errors) 2013-12-29 16:12:27 +01:00
jean-pierre charras 7e884e1eb1 Fix bugs 1264236, 1264238, 1264254 2013-12-29 12:01:54 +01:00
jean-pierre charras 7689d48632 Move HitTestForCorner and HitTestForEdge code from class_zone to polygon/PolyLine.cpp, to avoid redundant code.
Fix bug 1264248.
Fix a very minor issue in RemoveTrailingZeros, for countries where the separator in floating numbers is a comma.
2013-12-29 11:15:06 +01:00
Marco Serantoni 514c6c11ae Shows the current BZR version in version.h, not the last in the repository (Nick Østergaard) 2013-12-28 12:29:20 +01:00
jean-pierre charras e18828bed7 Dialog fp plugin option: Fix compil issue under gcc 4.4 (does not happen with 4.6 and later) about an overloaded function. 2013-12-27 12:44:40 +01:00
jean-pierre charras 0d52d9aa52 Pcbnew, 3D viewer: fix incorrect position of multiline texts. 2013-12-27 08:24:36 +01:00
Dick Hollenbeck bf9db2148c Hide m_galCanvas and m_galCanvasActive behind accessors. Fix DLIST concatonation API corner case. 2013-12-26 16:36:43 -06:00
unknown 768f7c0e45 Update freedesktop files according to http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html 2013-12-24 13:11:18 -06:00
Dick Hollenbeck d160459f4a FIX: avoid use of wxFileName::GetModificationTime() when it can fail. 2013-12-24 13:09:41 -06:00
Dick Hollenbeck 69b16484ec add mime type application/x-pcbnew-pcb, extend Desktop Exec to support a file to open on command line 2013-12-24 13:07:17 -06:00
Dick Hollenbeck 5f023e1e25 Update resources/linux/mime with zip from Fabrizio 2013-12-24 12:46:56 -06:00
Marco Serantoni b7996a4ad4 [MacOSX] Thanks for the hint, nullset@freenode, Merry Xmas ! 2013-12-24 19:16:56 +01:00
Baranovskiy Konstantin 447bb98480 Fix worksheet multiple line text plotting bug. (fixes lp:1261906) 2013-12-23 11:25:13 -05:00
Dick Hollenbeck 68d43a49df kicad-install.sh: abort on first failure. 2013-12-23 09:39:40 -06:00
Marco Serantoni 3353297858 [MacOSX] Fixing Zone visualization and removing not working code 2013-12-23 16:14:22 +01:00
jean-pierre charras f56e4fe1a4 specctra_export.cpp: Fix a conversion error from mils to mm I made i n may last commit, which set min dist to find a segment end for internal outlines holes to 1 mil instead of 10 mils. 2013-12-23 09:07:08 +01:00
Marco Serantoni 5a6e6b2733 [MacOSX] Cleanup 2013-12-22 20:52:52 +01:00
jean-pierre charras 58b96efe06 Fix broken download_boost.cmake. Fix minor other issues:
dialog fp lib table display not updated (Windows specific) when an option is changed from the lib table option editor
overloaded function in dialog_fp_lib_table.cpp not compiled with gcc 4.4.7 (try to fix Bug #1262002).
specctra_export.cpp: set min dist to find segment ends when building the board outline to 2 microns (should break anything, but should be enough to fix rounding issues when creating/importing board outlines with arcs)
2013-12-22 20:02:04 +01:00
Marco Serantoni 0328cfe83e [MacOSX] Fixing crash/missing refresh in pcb text 2013-12-22 18:39:37 +01:00
Marco Serantoni 4270fece64 [MacOSX] Fixing crash when changing module text properties - bug #1230090 2013-12-22 18:29:57 +01:00
Maciej Suminski 9cba0c0b02 Merge zone outline drawing fix request. 2013-12-22 11:30:46 -05:00
Maciej Suminski 64201d49f0 Merge aligned text fix request. 2013-12-22 11:07:47 -05:00
Marco Serantoni c801fcd835 [MacOSX] Treats LLVM as GCC + adds support for boost multiple processor(ppc/intel) and address(32/64 bit) 2013-12-22 15:55:05 +01:00
Maciej Suminski aac9946aef OpenGL canvas rats nest merge request. 2013-12-20 15:58:18 -05:00
Maciej Suminski 292a50f8c0 Fixed cursor force position option. 2013-12-20 16:07:58 +01:00
Maciej Suminski ebdddf0bc0 Ratsnest is updated, when there are tracks added using the P&S router. 2013-12-20 15:18:41 +01:00
Maciej Suminski a8ac725564 Fixed broken search filters. 2013-12-20 11:54:48 +01:00
Maciej Suminski 342684587a Upstream merge. 2013-12-20 10:15:00 +01:00
jean-pierre charras 9a532f2cda Undo the change in specctra_export I erroneously committed, which is not fully tested. 2013-12-19 12:43:16 +01:00
jean-pierre charras 909b7fb425 Dxf export: fix an issue in exported arcs. Update libdfx.
Pcbnew:, libedit, Save lib as...: the new .pretty lib format is the default, instead of legacy .mod format. The legacy format is still selectable in the file selection dialog.
2013-12-19 12:33:57 +01:00
Maciej Suminski 2027222074 Upstream merge 2013-12-19 11:15:27 +01:00
Maciej Suminski 93c3a64839 Module texts are undo/redoable. 2013-12-19 10:10:42 +01:00
Baranovskiy Konstantin 0913c5e167 Fix border and title block line thickness plotting bug. (fixes lp:1261899) 2013-12-18 13:11:15 -05:00
Wayne Stambaugh 9abad0063e CvPcb: reload footprint list when footprint library table is changed. (fixes lp:1261911) 2013-12-18 11:36:07 -05:00
Maciej Suminski 85aa4057f8 Fixed zone area removal (& undoing) using the EDIT_TOOL. 2013-12-18 17:16:15 +01:00
Maciej Suminski 9cd30339e1 Made pads & module texts unselectable 2013-12-18 16:26:21 +01:00
Wayne Stambaugh 4b851f9b98 Pcbnew: rotate footprint hot key fixes (fixes lp:1066182).
* Change general properties dialog to allow for entry of arbitrary rotation
  angles for greater than 0 to 90.
* Move global rotation angle variable into PCB_EDIT_FRAME object where it is
  used and add accessors.
* Change rotate footprint undo operation from UR_ROTATE_XXXX to UR_CHANGE.
* Create function to remove trailing zeros from floating point wxString
  objects.
2013-12-18 09:48:59 -05:00
Maciej Suminski 64c093109d Added possibility of removing selected items while dragging. 2013-12-18 15:38:38 +01:00
Maciej Suminski 667dd177ce More elegant way of handling interruption of current modifications. 2013-12-18 15:11:12 +01:00
Maciej Suminski b67c568545 Speed optimization during selection of multiple items.
Removed debug output.
2013-12-18 15:09:09 +01:00
Maciej Suminski 2fb36a9144 SELECTION_TOOL uses ITEMS_PICKED_LIST to store selected items.
Modifications done using the EDIT_TOOL are saved using the default KiCad's undo buffer.
If there is only one item selected, info about the item is displayed in the bottom status bar.
2013-12-18 14:33:34 +01:00
Maciej Suminski f06c0dc463 Added MODULE::RunOnChildren(). 2013-12-18 13:39:11 +01:00
Maciej Suminski ce1541e915 Added const modifiers where applicable (PICKED_ITEMS_LIST).
Added PICKED_ITEMS_LIST::FindItem().
2013-12-18 13:27:18 +01:00
Maciej Suminski 212f004cad Removed some debug logs. 2013-12-18 12:46:18 +01:00
Wayne Stambaugh a8339496e5 Pcbnew: change general properties dialog rotation angle to text edit control. 2013-12-17 16:38:20 -05:00
Wayne Stambaugh 9a183196a2 Merge changes from testing head. 2013-12-16 16:41:32 -05:00
Wayne Stambaugh 5a12aa9e1b Pcbnew: fix 45 degree rotation angle undo and global variable elimination. 2013-12-16 16:40:03 -05:00
Maciej Suminski 5c0d62ac2e Fixed drawing of rotated texts that are not horizontally center aligned. 2013-12-16 10:36:33 +01:00
jean-pierre charras 3d511efbb9 Pcbnew: remove broken patch for" Bug #1255059".
Minor change: Eeschema+Pcbnew: display timestamp in edit dialogs (for footprints, sheets, components)
2013-12-14 20:03:38 +01:00
Wayne Stambaugh 05a159d648 Pcbnew: minor Geda and KiCad plugin improvements.
* Make GPCB_PLUGIN::EnumerateFootprints() read the directory contents
  instead of loading the entire cache.
* Make KICAD_PLUGIN::EnumerateFootprints() read the directory contents
  instead of loading the entire cache.
2013-12-13 18:16:40 -05:00
Wayne Stambaugh 5a9aa812e2 Make old behavior the default in EnumerateFootprint() changes. 2013-12-13 18:14:30 -05:00
Wayne Stambaugh 35a9deb301 Pcbnew: minor Geda and KiCad plugin improvements.
* Make GPCB_PLUGIN::EnumerateFootprints() read the directory contents
  instead of loading the entire cache.
* Make KICAD_PLUGIN::EnumerateFootprints() read the directory contents
  instead of loading the entire cache.
2013-12-13 18:01:42 -05:00
Dick Hollenbeck c0ed445918 github_plugin.cpp was erroneously affected by rev 4552 patching. 2013-12-13 10:39:46 -06:00
Povilas Kanapickas f954ace66b Remove some uses of using namespace std. 2013-12-13 10:27:30 -06:00
Dick Hollenbeck 6776f8a79f kicad-install.sh and library-repos-install.sh utilize /etc/profile.d/kicad.sh for setting environment variables globally 2013-12-13 09:35:05 -06:00
Wayne Stambaugh ba345cb823 Pcbnew: Geda plugin fixes.
* Prevent cache from being reloaded on every footprint file read.
* Fix a bug forming wxFileName in GPCB_FP_CACHE::Load().
* Fix invalid file name time stamp debug assertion.
* Use FPID to set loaded footprint name.
* Remove file name <> from exception strings per UIPolicy.
2013-12-12 12:42:38 -05:00
Dick Hollenbeck 39abd88a54 remove USE_FP_LIB_TABLE code, make it the norm. Add lazy loading support to FOOTPRINT_INFO. 2013-12-12 10:01:03 -06:00
Wayne Stambaugh ecccdf0279 Fix footprint viewer perspective save bug. 2013-12-11 15:08:13 -05:00
Dick Hollenbeck 095e4a8799 Add strtok_r.c 2013-12-10 17:52:51 -06:00
Dick Hollenbeck a66ae2f51b FIX: make LEGACY_PLUGIN re-entrant. extern "C" strtok_r() put conditionally into libcommon. 2013-12-10 17:41:34 -06:00
Marco Mattila 781c6449d3 Fix wxWidgets 2.8 validator bug in footprint name entry dialog. (fixes lp:1259204) 2013-12-10 14:24:10 -05:00
Maciej Suminski eca952b8c5 Commit merge request lp:197913. 2013-12-10 12:14:30 -05:00
Maciej Suminski 13d4ee03b3 Commit merge request lp:197858 (fixes lp:1249736). 2013-12-10 08:43:04 -05:00
Dick Hollenbeck 22f9af6bf3 dialog perfection does not come easily. 2013-12-09 16:48:09 -06:00
Dick Hollenbeck d01c071d25 spinners initial values and limits. 2013-12-09 16:39:12 -06:00
Wayne Stambaugh 3f4bf9062c Fix frame perspective configuration entry name in basicframe.cpp. 2013-12-09 15:27:49 -05:00
Dick Hollenbeck 92e0d7bab2 molding mercury. 2013-12-09 13:06:47 -06:00
Dick Hollenbeck d9174a110b move ${Boost_LIBRARIES} into cvpcb, pcbnew, _pcbnew and out of github, because worker threads used regardless of github 2013-12-09 12:48:42 -06:00
Dick Hollenbeck f9c92b7c78 *) Change FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE*, const wxString*)
To use multiple working threads.  This entailed adding KiCad typedefs:
*) Add typedefs for MUTEX and MUTLOCK which mask the actual choices for the project.
*) Add FOOTPRINT_LIST::DisplayErrors( wxWindow* ) which is a single strategy for
   showing aggregated load errors.  Although what's there is only scaffolding
   and needs a volunteer who knows HTML pretty well.
*) Ensure all callers of ReadFootprintFiles() use the new DisplayErrors() function.   
*) Push utf8.cpp and utf8.h into common library for open use.
2013-12-09 12:09:58 -06:00
Maciej Suminski b73dc849a5 Comments. 2013-12-09 11:07:30 +01:00
Maciej Suminski 283788d91c Added removal of BOARD_ITEMs for the TOOL_FRAMEWORK. 2013-12-09 11:01:05 +01:00
Maciej Suminski 9b4b5c931e Moved Init() & Reset() from TOOL_INTERACTIVE to TOOL_BASE.
Added REASON enum for Reset() function, so tools will know why a reset occured.
Fixed SELECTION_TOOL (it was bailing out, when a new board was loaded and some items were still selected).
Added removal of VIEW_ITEM groups after changing layers and removing items.
2013-12-09 10:42:38 +01:00
Dick Hollenbeck bb87cd5fba fixes, a couple more unit tests. 2013-12-08 09:25:11 -06:00
Wayne Stambaugh 5d21c2d300 Enable building the footprint library table as the default. 2013-12-08 09:06:55 -05:00
scrizt da08a4129e Allow spoke width to equal minimum zone width in pcbnew (fix bug #1255059) 2013-12-08 12:00:20 +02:00
Dick Hollenbeck bff99dcf73 complete class UTF8.cpp 2013-12-08 00:48:25 -06:00
Dick Hollenbeck 1d7538a557 Documentation/guidelines/UIpolicies.txt should not speak of the unspeakable use of <> in quoted strings. 2013-12-07 22:49:44 -06:00
Dick Hollenbeck e483be7726 common/gal/stroke_font.cpp was segfaulting in wx 2.8 when drawing multi-line string. 2013-12-07 22:47:37 -06:00
Dick Hollenbeck 3b8a34bf25 eeschema/dialogs/dialog_lib_new_component.cpp was not expanding part name field nor setting initial focus. 2013-12-07 22:46:25 -06:00
Wayne Stambaugh 0f6dfb782e Pcbnew: footprint viewer wxAUI improvements.
* Make the tool bar dockable.
* Enable the overflow control in the tool bar in case the it does not fit in
  it's parent window.
* Fix some wxAuiPaneInfo usage issues.
* Remove unused wxAuiPaneInfo objects.
* Move perspective saving and loading into EDA_BASE_FRAME object in preparation
  for extending this to all frame windows.
2013-12-06 19:33:16 -05:00
Dick Hollenbeck c8aada9941 Move "code costly" functions in experimental class UTF8 to be not "inlined", prefering compactness. 2013-12-06 14:22:10 -06:00
jean-pierre charras 3d4fa72b51 Plot functions: some enhancements in mirror mode (Pcbnew specific): boards are mirrored horizontally, and the page layout is no more mirrored, and therefore is always readable. 2013-12-06 19:31:15 +01:00
unknown 936ffcaabc Bug fix: pcbnew hangs up on polygon movement 2013-12-06 15:34:39 +01:00
Maciej Suminski 84721d045e Removed unnecessary parts. 2013-12-06 15:01:36 +01:00
Dick Hollenbeck 0443c73aab UTF8::uni_iter made leaner. 2013-12-06 07:32:33 -06:00
Maciej Suminski d72ec51ccf Fixed an infinite loop in the destructor of ACTION_MANAGER; 2013-12-06 13:57:56 +01:00
Dick Hollenbeck 5778d74fbb sketch out class UTF8::uni_iter, add tools/make-UTF8.sh 2013-12-06 06:51:39 -06:00
Maciej Suminski b67faf780e Corrected drawing of zone outlines. 2013-12-06 11:25:23 +01:00
Maciej Suminski 3afbd8f2e1 Corrected polygon outline width. 2013-12-06 10:00:51 +01:00
Dick Hollenbeck fb771bf797 add a concept of an 8 bit string class for testing and experimentation. 2013-12-05 14:36:18 -06:00
Orson 46f42ba9c8 merge lp:~cern-kicad/kicad/bugfix_1256302 from Orson 2013-12-05 13:04:06 -06:00
Dick Hollenbeck bee41d9491 Switch STROKE_FONT::Draw() to take "const wxString&" rather than "wxString" by value. 2013-12-05 12:59:27 -06:00
Dick Hollenbeck f37fb67e5a merge lp:~cern-kicad/kicad/bugfix_1256302 from Orson 2013-12-05 12:55:07 -06:00
Maciej Suminski 940fc985e7 DIfferent handling of italic texts, depending on the mirroring setting. 2013-12-05 17:00:29 +01:00
Maciej Suminski 384abca49e Tilda handling for STROKE_FONT class. 2013-12-05 16:58:32 +01:00
Maciej Suminski c04eb822b7 Glyphs and their bounding boxes are held in vectors instead of deque.
Moved scaling of font glyphs to the moment when they are created (eliminated a few multiplications unnecessary variables).
Changed some magic numbers into constants.
2013-12-05 16:29:54 +01:00
Maciej Suminski 0a51662c0b Changed std::wstring to wxString. 2013-12-05 16:00:24 +01:00
Maciej Suminski 84af2eb8e1 Fixed SetCurrentContext() assert, that was firing on closure of pcbnew, when the OpenGL backend was active. 2013-12-05 14:54:30 +01:00
Maciej Suminski df5b9a1df0 Changed selection rules (pads&modules can be selected depending on the 'modules front/back' visibility instead of corresponding copper layers).
Fixed comments.
2013-12-05 14:52:08 +01:00
Maciej Suminski 0ac6e0614f ClearHotKey() function. 2013-12-05 14:48:44 +01:00
Maciej Suminski f3ef0fcf57 Removed warning. 2013-12-05 13:46:13 +01:00
Maciej Suminski 59f450bcfd Merged upstream 2013-12-05 13:24:27 +01:00
Dick Hollenbeck 53db1d2c9b From kicad-install.sh, issue instructional aid on setting KIGITHUB if not already set. 2013-12-04 16:19:55 -06:00
Maciej Suminski 45291ef571 The Selection Tool displays information about selected items. ClearSelection() made public. 2013-12-04 10:58:51 +01:00
Dick Hollenbeck 8cc9b69017 Add a test script for plugin testing, and some asserts, no bugs fixed. 2013-12-03 12:37:21 -06:00
Maciej Suminski 304d17dd32 The Selection Tool is always active. Removed entries for toolbar menu and hotkeys for the tool. 2013-12-03 17:11:22 +01:00
Maciej Suminski dc8997b1ac Merged upstream 2013-12-03 16:43:53 +01:00
Maciej Suminski e1bfcb1816 Renamed MOVE_TOOL to EDIT_TOOL. 2013-12-03 16:09:03 +01:00
Maciej Suminski af981b37fe Split rotate and flip operations into separate functions.
Added Properties action (display properties windows)
2013-12-03 15:57:09 +01:00
Maciej Suminski 4a4c0914bc Added TOOL_MANAGER::RunAction() function. 2013-12-03 15:41:41 +01:00
Maciej Suminski bc41f8298b Added some comments & asserts. 2013-12-03 15:17:43 +01:00
Maciej Suminski 12098fe113 Fixed non ASCII characters drawing using GAL. 2013-12-03 11:00:52 +01:00
jean-pierre charras 53053d0693 Pcbnew: fix issue in modedit, undo command: moved fields were not drawn afetr undo (due to incorrect flags state)
Fix incorrect initialization of lib names column in EDA_LIST_DIALOG. (Only the row 0 was initialized)
2013-12-03 09:50:58 +01:00
Dick Hollenbeck 829629d05f Fix important informational comment in library-repos-install.sh 2013-12-02 14:08:13 -06:00
Dick Hollenbeck 49233429e4 *) update scripts/kicad-install.sh to use Github plugin for system footprints.
*) Add scripts/library-repos-install.sh for downloading *.pretty libraries and possibly using them.
*) Remove template/fp-* files, they are now at https://github.com/KiCad/kicad-library/template/*
   so they can be maintained by the library team.  However note that it is possible to break
   kicad-install.sh with uncoordinated changes to that github repo.

It is best to delete your ~/kicad_sources/kicad-lib.bzr directory before running kicad-install.sh
at this or any newer version relative to an older library repo.
2013-12-02 12:21:06 -06:00
Maciej Suminski 47b6dd34af Pcbnew: fixed disappearance of selected items after GAL switching. 2013-12-02 13:04:26 -05:00
Robert Yates 4bd71d676f Boost::Context support for ARM platform. 2013-12-02 10:59:09 -05:00
Maciej Suminski a8bdd44cd1 Overridden ViewUpdate() for MODULE class, so it handles its pads, drawings and texts. 2013-12-02 14:35:05 +01:00
Maciej Suminski 9a860c355a Fixed disappearance of selected items after GAL switching. 2013-12-02 11:34:07 +01:00
Dick Hollenbeck c42a473521 library repo name has changed at launchpad, and will soon be switched to github. 2013-12-02 00:59:06 -06:00
Wayne Stambaugh 43eb124964 Pcbnew: footprint library table fixes.
* Replace illegal file system characters when reading legacy libraries to
  prevent FPID parsing errors and allow saving to PRETTY file format.
* Create validator to filter illegal file system characters from footprint
  name text edit controls to prevent issues when saving to PRETTY file format.
* Add missing source file licenses and some minor coding policy fixes.
2013-11-29 13:29:41 -05:00
Maciej Suminski a078fa6779 Storing the selected item position from a context menu. 2013-11-29 16:45:39 +01:00
Maciej Suminski 86a8bbee9a Added a missing file 2013-11-29 16:13:09 +01:00
Maciej Suminski 947a846d2e Moved the SELECTION_TOOL out of the KIGFX namespace. 2013-11-29 09:37:23 +01:00
jean-pierre charras 4897ea8c35 eeschema, Pcbnew: fix Bug #1255822 (incorrect position of multiline texts when plotting them) 2013-11-29 09:13:43 +01:00
Dick Hollenbeck fa2edf8547 *.kicad_mod omits (at 0 0) for brevity. 2013-11-28 10:40:23 -06:00
Dick Hollenbeck dcefaf675c API Documentation improvements, especially noticable when viewing doxygen output. 2013-11-28 09:41:10 -06:00
Maciej Suminski 4343c6a24f Automatic unregistration of tool actions during ACTION_MANAGER destruction. 2013-11-28 15:24:19 +01:00
Maciej Suminski fc7798b7d7 Double click support for the Tool Framework. 2013-11-28 15:19:50 +01:00
Dick Hollenbeck 82b2558d96 Even more clarification on "Github" plugin usage 2013-11-27 14:15:11 -06:00
Dick Hollenbeck 466ecca932 Better GITHUB class header documentation, better eeschema library field dialog stretching and title. 2013-11-27 14:06:41 -06:00
jean-pierre charras 96adde2d52 Pcbnew: fix Bug #1255568 (relative to .pos file creation). Minor compil warnings fixes 2013-11-27 20:38:59 +01:00
Jon Neal b2a71b505b FIX: Red Hat (and derivatives such as Fedora) support in kicad-install.sh 2013-11-27 08:13:06 -06:00
jean-pierre charras ecafc030ef Pcbnew: Autoplace functions: renamed spread footprint functions. Rewritten.
Now footprints, after loaded by reading a netlist are grouped by sheets by the footprints spread function, and the grouping is better.
Rename 2 files. Fix minor issues. Clean code
2013-11-27 14:20:42 +01:00
Robert Yates 6007dca4d1 Boost::Context support for ARM platform. 2013-11-27 09:48:31 +01:00
Maciej Suminski 08ecc5005f Profile counter simplified, so it should be more portable. 2013-11-27 09:46:59 +01:00
Dick Hollenbeck 7b70f2835c Ensure a unique FootprintEnumerate() return list in GITHUB_PLUGIN when using COW. 2013-11-27 00:51:49 -06:00
Dick Hollenbeck d8b046a361 *) Implement "Copy On Write" (COW) support in GITHUB_PLUGIN. See class header
comment for GITHUB_PLUGIN which should flow into Doxygen output.
*) Rewrote: 
        PCB_BASE_FRAME::Save_Module_In_Library(): now uses fp-lib-table and PROPERTIES.  
        PCB_EDIT_FRAME::ArchiveModulesOnBoard(): now can archive to any writable library type.
        PCB_BASE_FRAME::SelectLibrary(): is now generic for selecting a library, not just the active library.
2013-11-27 00:04:04 -06:00
Dick Hollenbeck 9ee683e971 FIX: work around for wx 2.8 bug affecting wxListCtrl column resizing. 2013-11-26 11:08:07 -06:00
Dick Hollenbeck 0b01c898f0 PLUGINs which implement FootprintLibOptions() should call base class's implementation too. 2013-11-26 11:06:54 -06:00
Andrey Fedorushkov 08e6ef95ab eeschema: fix parts range 1 to 26 in component 2013-11-26 13:15:20 +04:00
Maciej Suminski dd89260db3 Added ratsnest for GAL 2013-11-25 16:50:03 +01:00
jean-pierre charras 534a04206b Fix bugs in autoplac.cpp 2013-11-25 12:29:16 +01:00
Andrey Fedorushkov 25eaf50586 pcbnew: fix error build autoplace.cpp in linux gcc-4.8.2
template: add file fp-lib-table.for-eagle
2013-11-25 10:10:24 +04:00
jean-pierre charras e259a150fb All: GetBoundingBox returns now a const EDA_RECT.
Pcbnew: Code cleaning and bug fix in autoplace functions
Dialog exchange footprints has now a separate button to update the .cmp file, only on request.
2013-11-24 18:48:14 +01:00
jean-pierre charras 6bc8d6a231 Pcbnew: Fix a crash on exit when an item was previously deleted. Fix not working footprint exchange functions 2013-11-22 20:47:10 +01:00
jean-pierre charras 8122846078 Pcbnew: Code cleaning and some minor fixes. 2013-11-20 18:26:47 +01:00
Dick Hollenbeck 8fbdc6a50d Add template fp-lib-table for eagle-6.4.0 2013-11-20 10:38:06 -06:00
Dick Hollenbeck 2be3ebd401 FIX: regression loading of SMD pads within EAGLE_PLUGIN::FootprintLoad().
FIX: unique renaming of eagle footprints by substituting illegal : and / with URL encoding technique.
ADD: window resize border to DisplayError() windows.
2013-11-20 10:35:03 -06:00
Wayne Stambaugh f114bed0d2 Pcbnew: minor target properties dialog improvements.
* Make spacing between controls and dialog frame consistent.
* Use default size to allow wxWigdets to determine optimal dialog size.
* Set OK button as default so return key works properly.
2013-11-20 11:03:09 -05:00
Wayne Stambaugh 31deb4d25d Pcbnew: fix assertion when deleting BOARD_ITEM not linked to list. (fixes lp:1252696) 2013-11-19 16:51:33 -05:00
Dick Hollenbeck 413b776194 FIX: wx 2.8 convert to UTF8 differently than 2.9 caused problems in DIALOG_FP_PLUGIN_OPTIONS. 2013-11-19 14:38:29 -06:00
Wayne Stambaugh af18baba7b Pcbnew: fix graphic item undo/redo bug. (--fixes lp:1252264)
* Use std::swap for PCB_LINE_T items in SwapData().
* Use std::swap for PCB_MODULE_EDGE_T items in SwapData().
* Add assignment operator to EDGE_MODULE object.
* Move code from copy method to assignment operator.
* Minor coding policy fixes.
2013-11-19 13:58:12 -05:00
Dick Hollenbeck 527695bf53 Add a place-holder Description to fp-lib-table rows 2013-11-19 12:08:24 -06:00
Dick Hollenbeck bcd3470b20 *) Switch to later environment variable expansion in fp-lib-table.
*) Save library nickname in APP so upon module editor re-entry last is re-used.
*) Fix bug editing fp-lib-table Description field.
2013-11-19 11:24:45 -06:00
Carl Poirier fd86b347e6 update fp-lib-table to footprint library renaming efforts. 2013-11-19 11:24:19 -06:00
jean-pierre charras 801d72c55a Eeszchema: Minor fixes.
Code cleanup: remove m_Son member in EDA_ITEM which was never used.
2013-11-19 17:27:13 +01:00
Dick Hollenbeck 6ea28cb69d more useable, in the face of wx 2.8 vs. 3.0 differences. 2013-11-18 16:42:01 -06:00
Dick Hollenbeck 19196bede7 Work around wx 2.8 bug in wxListControl not honoring omissing of wxHSCROLL. 2013-11-18 16:03:34 -06:00
Dick Hollenbeck eed87fc699 more EDA_LIST_DIALOG usability enhancements, compiler warning, coding standards 2013-11-18 13:27:27 -06:00
jean-pierre charras 6c1a67684e Fix some minor issues 2013-11-18 18:52:18 +01:00
Dick Hollenbeck e5b6055e7d Show the "Description" field from fp-lib-table in pcbnew's module editor 'set current library' dialog. 2013-11-18 10:04:23 -06:00
jean-pierre charras 3ea78d07b1 Fix a compatibility issue for wxWidgets 3.0, when moving cursor by arrow keys.
Fix a very minor bug (2 duplicate lines when copying version informations to the clipboard)
2013-11-17 17:48:47 +01:00
Dick Hollenbeck c8c06ff230 EDA_LIST_DIALOG_BASE is used multiple times for different numbers of
columns.  DIALOG_SHIM would resize each separate usage to the same
size.  DIALOG_SHIM now supports and alternate m_hash_key in lieu
of the class name, optionally.
2013-11-17 00:04:20 -06:00
Baranovskiy Konstantin bbc596ad6c Fix justification of vertically aligned multi-line text. 2013-11-16 20:31:07 -05:00
Wayne Stambaugh 0930828a81 Eeschema: update component editor new component dialog with revise unit nomenclature. 2013-11-16 20:13:26 -05:00
Dick Hollenbeck 8c71406615 fix link error with multiply used edaapl.cpp 2013-11-15 09:12:07 -06:00
Dick Hollenbeck 1b01dba827 Show KISYSMOD in DIALOG_FP_LIB_TABLE even if it has not been referenced by a URI. 2013-11-15 08:36:11 -06:00
Dick Hollenbeck 4aa52ddd60 Show KIPRJMOD in DIALOG_FP_LIB_TABLE even if it has not been referenced by a URI. 2013-11-15 08:11:46 -06:00
Dick Hollenbeck b80de21136 Allowing pre-setting CMAKE_CXX_FLAGS on first CMake invocation 2013-11-15 08:10:29 -06:00
jean-pierre charras ca927e4227 Minor code cleaning: Remove unused file, remove obsolete or useless defines 2013-11-15 10:28:31 +01:00
jean-pierre charras f2c17a64fb Minor fix about version information when BUILD_GITHUB_PLUGIN is on 2013-11-15 08:24:10 +01:00
Dick Hollenbeck c793624195 TODO.txt 2013-11-14 16:52:28 -06:00
Maciej Sumiński 42d54163c5 add boost dependency on BZip2 by adding find_package( BZip2 REQUIRED ) 2013-11-14 16:51:11 -06:00
jean-pierre charras 5f2f80f480 rtree.h: suppress compil warnings about not initialized vars.
Pcbnew: add WIN32_LEAN_AND_MEAN define in github_plugin.cpp. Note: this define is already in use in avhttp build (Windows specific)
2013-11-14 19:00:57 +01:00
Wayne Stambaugh 88be1fee15 Minor copy version information improvements.
* Add build type (debug/release) for wxWidgets library  versions greater
  than 2.8.
* Add build type (debug/release) for KiCad.
* Add missing build options.
2013-11-14 09:21:32 -05:00
Wayne Stambaugh 0a6a44522a Update TODO.txt to reflect completed FP_LIB_TABLE items. 2013-11-13 15:57:51 -05:00
Dick Hollenbeck 0ba54b4b7c format string concatenation bug 2013-11-13 13:59:47 -06:00
Dick Hollenbeck 56b35ef6fb half way point for Carl's *.mod file renaming work 2013-11-13 13:58:50 -06:00
Maciej Suminski 03855be6f9 Merged rtree.h, to avoid code duplication.
Fixes the case, when waste is never greater then the worst case and seeds assignment does not occur.
2013-11-13 17:03:22 +01:00
Maciej Suminski 39b55e20c0 Fix wx2.8 strings compatibility. (fixes lp:1250876) 2013-11-13 10:27:14 -05:00
Maciej Suminski 24ab8e0b52 Fixed wx2.8 strings compatibility. 2013-11-13 15:52:06 +01:00
Dick Hollenbeck a961938716 change 2013-11-12 14:58:33 -06:00
Dick Hollenbeck 5c2b9d6011 Completion of DIALOG_FP_PLUGIN_OPTIONS 2013-11-12 14:49:17 -06:00
Maciej Suminski 66def25eab Commit Launchpad merge request 194664.
* Modify error handling for OpenGL backend.
* Correct Doxygen comments notation.
2013-11-12 14:29:01 -05:00
Brian Sidebotham 16b7338a59 Although CMake keeps time stamps to remember how far it got in an ExternalProject_Add()
build, it throws the time stamps away when there are edits to the CMakeLists.txt portion
pertaining to the external project.  Only a 'make clean' would remove the untarred tree.
This patch removes the need to do a make clean when changing the ExternalProject_Add()
text pertinent to patching.

Fixes bug 1250222 in KiCad-Winbuilder
2013-11-12 12:44:30 +00:00
Dick Hollenbeck 5b89f42738 wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser() now returns empty string on abort.
GITHUB_PLUGIN uses redirected URL to remove one HTTP hit time.
2013-11-11 19:14:17 -06:00
Wayne Stambaugh 882a0bcb7d Footprint library table fixes.
* Pcbnew: catch exceptions when saving changes to footprint library table.
* Pcbnew: update footprint viewer library list if open when footprint library
  table changes.
* CvPcb: update library list when footprint library table changes.
* Minor coding policy fixes.
2013-11-11 20:05:23 -05:00
Dick Hollenbeck 629d397508 *) Add PLUGIN::FootprintLibOptions( PROPERTIES* ), and extend DIALOG_FP_PLUGIN_OPTIONS to use it.
*) Move button handlers to LEFT MOUSE CLICK from COMMAND events, so wxGrid focus is not lost.
*) Sketch out the concept of COW support for the GITHUB_PLUGIN in its @todo.
2013-11-11 18:17:27 -06:00
Wayne Stambaugh 346384f8fc Escape " character to fix warning in TokenList2DsnLexer.cmake 2013-11-11 16:39:02 -05:00
Dick Hollenbeck fe4af49759 error: 'uintptr_t' was not declared in this scope.
https://svn.boost.org/trac/boost/ticket/8973
https://svn.boost.org/trac/boost/changeset/84950#file0
2013-11-11 08:50:45 -06:00
Maciej Suminski 5370236743 Corrected Doxygen comments notation. 2013-11-11 13:47:08 +01:00
Maciej Suminski ee289e4a30 Modified error handling for OpenGL backend, now error messages should be visible. 2013-11-11 10:48:49 +01:00
jean-pierre charras 83ccbc7add Pcbnew: fix a build issue when BUILD_GITHUB_PLUGIN is enabled. 2013-11-11 09:01:04 +01:00
Dick Hollenbeck aa633bf2c7 Support only one boost build subset, regardless of BUILD_GITHUB_PLUGIN.
This is so builders with multiple out of source build trees can all use
the same common boost install directory.  And the build system will not
vascillate between the fuller and lesser subsets of boost.
2013-11-10 18:47:54 -06:00
jean-pierre charras 621b92cd5e All: under mingw32+msys: fix an issue when using Cmake version >= 2.8.5 which uses by default a response file.
This response file is not expanded under mingw3 2 (mingw/gcc bug?), and the list of include paths, found in this file, is not taken in account.
Now, under mingw32+msys, when not cross-compiling, the response file is disabled.
Cvpcb, Pcbnew: fix a list of libs  which should be added only when cross-compiling:
Previously, they were always added, which creates an issue with mingw/msy/ gcc  2.8.
Now they are added only when cross-compiling (this issue was noticeable only with msys+mingw version  2.8)
2013-11-10 20:15:09 +01:00
Dick Hollenbeck 0d549ae203 python in kicad-install.sh, if user enables it 2013-11-10 00:31:13 -06:00
Wayne Stambaugh d944e67a69 Eeschema multiple unit component nomenclature improvements (fixes 1226874).
* Replace all occurrences of the word "part" with "unit" when referring to
  multiple unit components for improved consistency.
* Replace "shared by" with "common to" when referring to objects (lines, arcs,
  pins, etc.) that are common to all units.
* Improve wording in library component properties dialog.
2013-11-09 11:30:49 -05:00
Brian Sidebotham e2b13be7a0 * Remove erroneous comment about requiring perl for OpenSSL build 2013-11-08 17:54:00 +00:00
Brian Sidebotham 8750485c6d * Build OpenSSL from source using the OpenSSL-CMake project on Windows with MinGW when no specifying OPENSSL_ROOT_DIR 2013-11-08 07:06:14 +00:00
Colin Cooper 1f9c1e6627 kicad-install.h checks if bzr id set 2013-11-07 12:15:58 -06:00
Dick Hollenbeck 050e782df5 switch to static linking of libstdc++ on windows 2013-11-07 08:26:32 -06:00
jean-pierre charras 732f4856c6 Eeschema: Disable a debug option I enabled and forgot to remove. 2013-11-06 20:36:46 +01:00
Maciej Sumiński 27863c0bc9 Patches one by Lorenzo, one by Orson 2013-11-06 11:17:42 -06:00
Dick Hollenbeck f0215a7009 add fix_eagle_package_name() and apply it in two places to re-spell eagle package names 2013-11-06 10:53:44 -06:00
Wayne Stambaugh 3a06962045 Set project footprint library table path environment variable before loading table. 2013-11-06 11:10:44 -05:00
Dick Hollenbeck 6fffba5bb2 kicad-install.sh needed libcairo2-dev prerequisite 2013-11-06 08:37:39 -06:00
jean-pierre charras 2ace8e0a5e page layout editor: Add missing Info.plist for OSX.
Mingw, all: remove static link of libgcc, which can create issues when using dll version of wxWidgets.
Therefore libgcc_s_dw2-1.dll should be in the paths for executables.
2013-11-06 08:33:49 +01:00
Dick Hollenbeck 99e99e5b60 add libglew-dev prerequisite for debian systems, it pulls in libgl1-mesa-dev and libglu1-mesa-dev on its own 2013-11-06 00:14:15 -06:00
Edwin van den Oetelaar fc19e7dfdb Running a very common Ubuntu 12.4.3 building from repo could not find the GLEW library. 2013-11-06 00:11:58 -06:00
Wayne Stambaugh 2398fa4044 Eeschema: fix bug loading grid size from previous session. (fixes lp:1239445) 2013-11-05 16:14:09 -05:00
Maciej Suminski aedfb6e6fa Fixes missing worksheet layout when there is no PCB loaded and all random brightness changes for the Cairo rendering backend. 2013-11-05 15:22:49 -05:00
jean-pierre charras c760a1c545 Pcbnew: Fix incorrect bounding box calculation of texts. Only noticeable with boards conveted from Eagle, which are using other text justification than center.
Eagle plugin: filter and replace not allowed chars in FPID(-':' and '/')  by _ or -, if they are used in Eagle footprint names (otherwise, boards converted and saved under kicad_pcb format are not readable by Pcbnew).
2013-11-05 18:12:27 +01:00
jean-pierre charras bcb30ce933 Disable patch from Baranovskiy Konstantin about vertical justification of multiline texts, because it does not work for rotated/mirrored texts 2013-11-04 18:20:54 +01:00
jean-pierre charras a4c3485440 painter: better size of pad nums and pad netnames in opengl mode 2013-11-04 18:18:19 +01:00
Dick Hollenbeck e8e223630a filter better the unsupported layers coming into EAGLE_PLUGIN::Load() 2013-11-03 20:09:28 -06:00
Wayne Stambaugh 7b68bdce5f Fix debug builds on wxWidgets 2.8. 2013-11-03 13:15:46 -05:00
jean-pierre charras 8884e47051 Opengl display: fix incorrect text size of pad num and pad netname. 2013-11-03 15:06:16 +01:00
Dick Hollenbeck 7c352e2038 Orson's changes 2013-11-02 15:06:13 -05:00
Dick Hollenbeck 2b20d3ef64 make PROPERTIES::Value() not inline 2013-11-02 14:49:46 -05:00
Dick Hollenbeck 0d5a7f3224 *) Start removing some of the problematic "<%s>.." format strings, which won't
pass into an HTML rendering panel and otherwise look goofey.
*) Implement BOARD::Move() can call it from EAGLE_PLUGIN::Load().
*) When USE_FP_LIB_TABLE, tolerate blank nicknames in FPIDs coming from eeschema.
   See the switch for this in pcbnew/netlist.cpp as ALLOW_PARTIAL_FPID.
*) Add an assert and a try catch block to figure out that View does not
   like some eagle pcb board.  bitset::set() is getting a -1 value and firing
   an exception.
2013-11-01 19:24:38 -05:00
jean-pierre charras 4bc0cdd8b3 Footprint wizards: fix issues. 2013-11-01 21:51:37 +01:00
jean-pierre charras 3511c95836 Make footprint wizards compatible with FPID changes (MODULE::SetLibRef changed to MODULE::SetFPID) 2013-11-01 16:29:50 +01:00
jean-pierre charras 5456ada1bd Pcbnew, compiled with python support: Under windows, force python environment, if the folder python27_us is found in Kicad bin folder (<kicad>/bin, and if python27_us environment is not fully set (i.e. if python27_us is not in the path, or if PYTHONPATH id not defined.) 2013-11-01 14:02:10 +01:00
Orson 1fa3ef37c3 Fix redraw issue in modedit a modview, with GAL 2013-11-01 13:56:20 +01:00
Maciej Suminski a5d8c49d75 Added some comments and missing parameter names for pcb_painter.h. 2013-11-01 10:06:50 +01:00
Dick Hollenbeck 0e69125217 cvpcb was not filtering on the current library when USE_FP_LIB_TABLE.
<%s> being replaced with '%s' because the former in invisible in html panels.
Cure some compiler warnings.
2013-10-31 16:30:57 -05:00
Dick Hollenbeck 046ecb794d add --uninstall-libraries to kicad-install.sh 2013-10-31 14:12:14 -05:00
Wayne Stambaugh d61ebcf446 Shorten footprint library table environment variable KICAD_PRJ_PATH to KIPRJMOD. 2013-10-31 09:08:36 -04:00
jean-pierre charras cfb3c942d7 Pcbnew: fix a crash when a non ascii char (i.e. a char having a code > 127) is found in a text (see Bug #1246340).
Could be only a temporary fix (tested only with French non ascii chars).
2013-10-30 21:07:52 +01:00
Dick Hollenbeck e49a3275e2 more fp_lib_table dialog work 2013-10-30 10:33:51 -05:00
Dick Hollenbeck 30964aec70 merge lp:~cern-kicad/kicad/pcbnew_segfix from Orson 2013-10-30 07:46:36 -05:00
jean-pierre charras 4e39d09d1d Add undo command to dxf file import. Change improper use of __WXDEBUG__ to DEBUG in class_board_connected_item.cpp. 2013-10-30 13:14:45 +01:00
Maciej Suminski 162b70ce5d Fixed segfault occurring on rendering backend switch when pcbnew is run from the main KiCad dialog. 2013-10-30 11:50:09 +01:00
Dick Hollenbeck 4b49d5d355 memory leak, comments 2013-10-30 00:14:11 -05:00
Dick Hollenbeck 3e18a46758 merge in a year's worth of CERN work 2013-10-29 19:10:24 -05:00
Maciej Suminski d6edc898c5 Fix colorized framebuffer output on some GPUs. 2013-10-29 17:53:47 +01:00
Maciej Suminski 1dcaf135e5 Changed the used framebuffer object extension from ARB_framebuffer_object to EXT_framebuffer_object (compatibility reasons). 2013-10-29 17:28:29 +01:00
Maciej Suminski 25919e8393 Merged upstream. 2013-10-28 21:34:06 +01:00
Maciej Suminski 1080a4e6f9 GAL is not activated by default. Late OpenGL backend initializatization. 2013-10-28 16:51:56 +01:00
jean-pierre charras b97769bf5c dxf import: minor enhancements in dialog. Update libdfxw from git, and uncrustify it. add a test dfx file 2013-10-28 09:06:38 +01:00
Wayne Stambaugh d17c1c57be Eeschema find/replace bug fixes and improvements (fixes 1208616).
* Fix replace bug to handle case sensitivity properly.
* Fix replace bug where the item index was getting updated incorrectly.
* Fix replace infinite loop bug on replace all.
* Make find/replace view update code a separate function.
* Rearrange find/replace trace string to add tracing to EDA_ITEM::Replace().
* Add IsComplexHierarchy method to SCH_SHEET_LIST for future find/replace
  improvements.
2013-10-27 14:21:53 -04:00
jean-pierre charras fd1fc0f1d1 Fix typo 2013-10-26 20:17:44 +02:00
jean-pierre charras eeddfcbec2 Pcbnew, dxf import: Add dialog to choose the board import layer, and the position of dxf coordinates origin 2013-10-26 09:03:06 +02:00
jean-pierre charras fe2b9bd444 Add patch from Baranovskiy Konstantin about vertical justification of multiline texts.
Fix issues created by this patch.
Note, this fix slightly changes the vertical position of these texts.
This is not really a  problem in eeschema, but in pcbnew this is perhaps  more annoying, if the verical multiline text is critical.
Fix a very minor issue  for vertical justification of single line texts in dxf import.
2013-10-25 14:16:18 +02:00
jean-pierre charras 5ebb4b54d9 Pcbnew: First work to add a DXF file import to create board outlines. The DXF import is based on DXF lib import/export from LibreCad. 2013-10-24 20:47:07 +02:00
jean-pierre charras cdd2967087 Add a DXF file import to create board outlines 2013-10-24 18:44:38 +02:00
Dick Hollenbeck e61505149a more DIALOG_FP_PLUGIN_OPTIONS work, make PROPERTIES a map instead of a hashtable for alphabetical iteration. 2013-10-24 08:58:05 -05:00
Dick Hollenbeck 8dbe249bf9 script improvements 2013-10-24 08:57:01 -05:00
Dick Hollenbeck 38a0857a69 *) Factor out Cut, Copy, and Paste for wxGrid into class common/GRID_TRICKS.
*) Use it on 3 grids total in DIALOG_FP_PLUGIN_OPTIONS and DIALOG_FP_LIB_TABLE.
*) Fix bug when pasting "(fp_lib_table" text into FP_LIB_TABLE.
2013-10-23 13:56:03 -05:00
Dick Hollenbeck 2b1b586251 fixes 2013-10-23 06:40:17 -05:00
Dick Hollenbeck f36cdde500 Grab pending (unsaved) wxGridCellEditor cell text and stuff into fp_lib_table. 2013-10-22 14:29:37 -05:00
Dick Hollenbeck 6de1bfb64c When pasting into a fp_lib_table with no initial rows, start at column zero, not -1. 2013-10-22 09:29:48 -05:00
Dick Hollenbeck a5e82117cb Distro specific architecture in scripts/kicad-install.sh. 2013-10-22 09:28:30 -05:00
Camille 019 2b7d04368a Tidy up the gcc 4.7.0 - 2 optimization setting methodology. 2013-10-22 09:26:26 -05:00
jean-pierre charras a9dbdbc822 Pcbnew: fix bug 1199340 2013-10-20 17:39:15 +02:00
jean-pierre charras 6528829796 All: fix bug making IsOK dialog always returns false, regardless the button clicked. 2013-10-19 15:22:24 +02:00
jean-pierre charras 3ad682a898 pl_editor: add a PPI (pixel per inch) setup option for bitmaps. 2013-10-19 12:29:54 +02:00
jean-pierre charras 7aca2ee5be Remove duplicate files.
Page layout editor: Add bitmap items to the page layout existing items.
Now a bitmap image can be added to a page layout description. Currently the bitmap is expected having a 300 ppi definition.
Note: not all plotters can plot a bitmap, and in this case the bounding box is plotted instead of the bitmap
2013-10-18 19:38:03 +02:00
Wayne Stambaugh 1c99f118ff Fix bug due to change in the default global footprint library table file name. 2013-10-18 12:06:18 -04:00
jean-pierre charras b49be74501 page layout editor: now one can add a bitmap to the page layout 2013-10-18 17:42:48 +02:00
Wayne Stambaugh 55f69da613 Minor message box improvements
* Create a generic yes/no/cancel dialog from DIALOG_EXIT.
* Make DIALOG_EXIT return wxID_YES instead of wxID_OK so it is consistent
  with the standard message dialogs.
* Add missing license to confirm.h and confirm.cpp.
* Change Eeschema message dialog when loading a schematic if the current
  schematic is modified to be more consistent with the exit dialog.
* Change Pcbnew message dialog when loading a board if the current board
  is modified to be more consistent with the exit dialog.
* Remove some Eeschema block debug logging code left over from my last
  commit.
2013-10-18 09:32:22 -04:00
Dick Hollenbeck ae7966a20c fix template files installation 2013-10-18 08:18:45 -05:00
jean-pierre charras 2e92fdf272 Remove duplicate files 2013-10-18 12:33:50 +02:00
Andrey Fedorushkov cf9a3cdc38 fix auto install template files 2013-10-18 10:01:59 +04:00
Dick Hollenbeck 70951375c9 Add support for building *.deb file using CPack, install ~/fp-lib-table either from kicad-install.sh or from make install_user_configuration_files 2013-10-17 14:03:36 -05:00
Dick Hollenbeck 6329a0070d .bzrignore was ignored. 2013-10-17 14:02:11 -05:00
Dick Hollenbeck 29fae88610 add {Get,Set}ModuleLibraryNickname to EDA_APP, reformatting 2013-10-17 14:01:35 -05:00
Dick Hollenbeck ee0c0fa6ba fix expansion of dialog on stretching and initial view 2013-10-17 13:59:54 -05:00
Dick Hollenbeck 33822213e6 fix formatting goofs 2013-10-17 13:47:46 -05:00
Dick Hollenbeck cb05bedf08 Throw exception if accessing a GITHUB library from build not supporting GITHUB. 2013-10-17 13:46:20 -05:00
Dick Hollenbeck 4cf328c50b add script to build KiCad on Ubuntu/Debian/Mint linux 2013-10-17 10:33:46 -05:00
Wayne Stambaugh f44eb0f8ba Add PDF output to Pcbnew plot dialog. (fixes 1p:1188972) 2013-10-15 14:22:35 -04:00
Wayne Stambaugh 76c9029ec3 Eeschema block end handler code improvements.
* Merge HandleBlockEnd() and HandleBlockEndByPopUp() into as single block
  end function HandleBlockEnd().
* Replace all instances of HandleBlockEndByPopUp() with HandleBlockEnd().
* Change block hot keys to send command events instead of directly calling
  end block handler.
2013-10-15 12:18:30 -04:00
Maciej Suminski 68e3516075 Hides the GAL subwindow in cvpcb module view frame. 2013-10-15 15:15:29 +02:00
Brian Sidebotham 19ff8e95e5 Temporarily disable Boost.Context library build as it breaks MinGW builds by bringing in a dependency on MASM (The Microsoft Assembler) 2013-10-15 11:42:26 +01:00
Maciej Suminski 4bf49bf6a6 Renamed TOOL_MOUSE_BUTTONS constants to avoid name conflict with Windows MB_RIGHT constant. 2013-10-15 10:41:00 +02:00
Maciej Suminski 0e377e43cc Merge 2013-10-14 20:41:56 +02:00
Maciej Suminski f9f23806ed Mainly case changes. 2013-10-14 20:40:36 +02:00
Dick Hollenbeck 3569e16519 Planning for PCB_BASE_FRAME::Save_Module_In_Library and PCB_EDIT_FRAME::ArchiveModulesOnBoard rewrites 2013-10-14 11:54:00 -05:00
jean-pierre charras 2a40ddd5f9 Pcbnew: Fix issue when displaying net names and/or pad numbers including the "<" char in drc dialog, because drc dialog uses an wxHtmlWindow to display drc messages, and the "<" char has a special meaning and is not allowed in texts (now replaced by the" &lt;" sequence in messages displayed in html)
Eeschema: replace "<" and ">" by "(" and ")" in autogenerated net names, to avoid other issues in html messages.
Very minor other fixes.
2013-10-14 18:03:38 +02:00
Wayne Stambaugh efcd8987d9 Fix Pcbnew block rotate hot key and minor code cleaning. 2013-10-14 11:29:16 -04:00
Maciej Suminski e66a4ce337 Namespace KiGfx->KIGFX.
template<> -> template <>
Some more reformatting according to uncrustify results.
2013-10-14 16:13:35 +02:00
Maciej Suminski 6d19d7c257 Fixed unnecessary comment 2013-10-14 14:45:01 +02:00
Maciej Suminski 988aee863c Fixed unnecessary comment 2013-10-14 14:42:35 +02:00
Maciej Suminski 8253899a70 Converted tabs to spaces. Removed trailing whitespaces. 2013-10-14 13:43:57 +02:00
Maciej Suminski 4edca43531 Merged 'development' 2013-10-14 11:41:43 +02:00
Maciej Suminski a876fc788d Merged 'testing' 2013-10-14 11:40:14 +02:00
Maciej Suminski cc79e5ca83 Added error messages for OpenGL framebuffer errors. This should eliminate quiet segfaults in case of drivers that cannot handle multiple attachment points for framebuffers. 2013-10-14 11:39:21 +02:00
Maciej Suminski 8aeb204c8a Marked pnsrouter as dependent on boost 2013-10-14 08:37:58 +02:00
Wayne Stambaugh db73939504 Fix bug when creating initial global footprint library table on Windows. 2013-10-13 20:14:52 -04:00
Dick Hollenbeck de90187eb0 *) Switch over to FP_LIB_TABLE::Footprint*() functions.
*) Set environment variable KISYSMOD before loading FP_LIB_TABLE so that
   FP_LIB_TABLE::ROW::SetFullURI() can do substitution up front.
*) De-emphasize the lib path in some of the footprint frames but keep it
   so the footprint editor can export a current library to another.
   You can even export a GITHUB library to a pretty library for local 
   installation.
*) Start the PLUGIN options editor.
*) Enhance cursor positioning in DIALOG_FP_LIB_TABLE.
2013-10-13 16:33:58 -05:00
jean-pierre charras 8aa809d2bc specctra_export.cpp: fix a bug in my export function to 3D viewer which generates bad shapes for holes generated by outlines
inside the main board outlines.
specctra_export.cpp: always approximate arcs in outlines by 36 segm for 360 degrees,
even for arc angle which differs from 90 degrees.
90 degrees is the default when creating an arc, but the arc value can be edited and have any value between 0 and 360 degrees.
Previously, 9 segments were used regardless the arc angle.
2013-10-13 18:47:11 +02:00
Wayne Stambaugh 9e28d91879 Footprint library table improvements.
* Add save table and set project path environment variable code to
  FP_LIB_TABLE object.
* Add code to Pcbnew and CvPcb to set project path environment variable.
* Create empty footprint table in Pcbnew when new board created.
* Save current project specific footprint library table to path on file save
  as or empty project path.
* Fix a bug in Pcbnew in file save function that would silently overwrite
  an existing board file.
* Disable selecting the current library in the module editor when there are
  no libraries defined.
* Catch exceptions and report errors when writing footprint library tables.
* Fix Boost build CMakeFile to fix bug when bootstrapping a Boost build in
  MSys.
2013-10-13 12:29:20 -04:00
jean-pierre charras 2e89516b6e Remove wxUSE_UNICODE definition from CMakeLists.txt, because this define comes from wxWidgets and should not be made inside kicad
Remove KICAD_GOST option because it is  now useless: the 2 GOST options are now selectable at run time and are:
* specific page layouts (now user definable, and the GOST page layouts are available in template folder)
* notation for multiple parts per package (made in eeschema, preference menu)
2013-10-11 18:24:43 +02:00
Maciej Suminski f690b8e505 Fixed IDs for the push and shove router menu 2013-10-11 14:26:09 +02:00
Maciej Suminski 5964e4c332 Removed unused variable. 2013-10-08 10:17:49 +02:00
Brian Sidebotham 6033b200e6 * Fix building of Github plugin support for Windows using Mingw-w64
* Pre-built binaries for OpenSSL can be used from the LuaDist project: https://github.com/LuaDist/openssl/releases
* Building of Boost libraries fixed for Mingw-w64 for github plugin
2013-10-07 20:49:44 +01:00
jean-pierre charras 0ee33d34f2 3D-viewer: minor fixes and enhancements 2013-10-07 18:39:39 +02:00
jean-pierre charras 44cb99f663 3D-viewer: minor fixes and enhancements 2013-10-07 16:50:23 +02:00
jean-pierre charras 99170bc25b Pcbnew: 3D view: Better 3D rendering (fix some artifact issues). Add a realistic rendering mode. 2013-10-07 13:51:08 +02:00
Wayne Stambaugh 07640b1961 Fix footprint library editor bug.
* Don't convert footprint library path to wxFileName.  This removes a '/'
  from the GIT_HUB_PLUGIN uri which causes wxUri to choke and the incorrect
  plug in is selected.
2013-10-05 19:41:40 -04:00
Dick Hollenbeck e5cb41601e FP_LIB_TABLE::ROW::SetFullURI() does environment variable substitution up front.
We can now remove a few calls to FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
since its being done in above function.

DIALOG_FP_LIB_TABLE now handles table to copy cut copy paste from global to
project and reverse.  Fixed a problem with cursor position management when
switching between tables.
2013-10-05 05:34:55 -05:00
Dick Hollenbeck f9d8e64a31 Put FP_LIB_TABLE::Footprint*() functions on stage, but comment out lazy plugin lookup trick in FindRow() until these new API functions are used. 2013-10-04 23:53:15 -05:00
Dick Hollenbeck 7bfdb82225 DIALOG_FP_LIB_TABLE: disable row resizing, get rid of tooltips on grids 2013-10-04 23:41:15 -05:00
Dick Hollenbeck 04aefeae55 AutoSizeColumns(), and search for "(fp_lib_table" not "(fp_lib_table " 2013-10-04 23:21:58 -05:00
Dick Hollenbeck d6cad30c9f FP_LIB_TABLE::ROW::SetType() ensures sensible value of "KiCad" if nothing good comes in. 2013-10-04 17:40:25 -05:00
Dick Hollenbeck 28358306e1 Add keyboard support to DIALOG_FP_LIB_TABLE grid interface:
CTL+X, CTL+V, CTL+A, CTL+C
2013-10-04 17:23:53 -05:00
Dick Hollenbeck 5539a982b5 CTL_OMIT_PATH patch 2013-10-04 17:23:04 -05:00
Dick Hollenbeck ed22433178 Rebase a subset of Footprint*() PLUGIN API onto FP_LIB_TABLE 2013-10-04 14:09:10 -05:00
Dick Hollenbeck 127876bd1b Fix FP_LIB_TABLE::ROW operator=(), was not copying "description" field.
Remove tooltips from fp_lib_table wxGrid, were annoying and munging wxGrid's grid.
Change initial size of DIALOG_FP_LIB_TABLE.
2013-10-04 10:58:32 -05:00
jean-pierre charras c5cae05683 3D viewer: Preference menu: fix a bug which displays incorrectly the actual display options state (always shown off) when starting the 3D viewer 2013-10-04 16:52:09 +02:00
jean-pierre charras 2f3cbdd7c5 3D board display: better rendering of the board: the board polygon outlines (generated by the specctra function which calclaltes outlines) is now used to create the 3D body of the board,
in pcbnew and cvpcb.
2013-10-04 16:32:59 +02:00
jean-pierre charras 9c682e2cc0 Fix Cmakelists issues 2013-10-04 14:48:50 +02:00
jean-pierre charras f31dfd49d9 Move specctra.cpp, specctra_import.cpp and specctra_keywords.cpp compilation to pcbcommon lib because they containt functions used by the 3D viewer in Cvpcb and Pcbnew. 2013-10-04 14:22:33 +02:00
jean-pierre charras 731b356c95 3D board display: better rendering of the board: the board polygon outlines (generated by the specctra function) is now used to create the 3D body of the board. 2013-10-04 10:42:09 +02:00
Brian Sidebotham 6d48a01801 Removed some Microsoft Visual C centric definitions in CMakeModules/config.h.cmake which were tripping up the mingw-w64 build 2013-10-03 23:53:42 +01:00
Dick Hollenbeck 3ec06fa3cc DIALOG_FP_LIB_TABLE does not use wxSplitterWindow, it would not obey.
Paste popup menu in this dialog now allows pasting a (fp_lib_table)
s-expression element holding (lib) elements.  This provides an 
opportunity for GITHUB library publishers to put the table description
into their README.md file as a (fp_lib_table) element where it can
be quickly copied to clipboard and pasted into the fp lib table dialog.
This is a paste operation, and overwrites from the initial cursor position.
2013-10-03 17:12:56 -05:00
Dick Hollenbeck 5a1d4ad491 if https:// GET fails, report the URL 2013-10-03 10:12:25 -05:00
Dick Hollenbeck 581d67177d throw better IO_ERROR message on bad GITHUB URL, improved formatting and comments. 2013-10-03 08:40:00 -05:00
Dick Hollenbeck ac6347fece fix: https://answers.launchpad.net/kicad/+question/233824 2013-10-02 15:25:44 -05:00
Maciej Suminski ebb42aa419 Renamed WORKSHEET_ITEM to WORKSHEET_VIEWITEM. 2013-10-02 14:26:14 +02:00
Maciej Suminski 8223f9742e Fixed memory leak caused by ViewUpdate() with VIEW_ITEM::GEOMETRY/LAYER parameters. 2013-10-02 13:57:21 +02:00
Maciej Suminski dfdacba649 Worksheet is not selectable anymore. 2013-10-02 12:02:25 +02:00
Maciej Suminski eeeffd1ad1 Removed SELECTION layer. 2013-10-02 11:39:08 +02:00
Maciej Suminski 93fc797b2e Added missing ViewUpdate flag 2013-10-02 11:25:04 +02:00
Maciej Suminski 094d6de8e0 Fixed reset for the selection tool. 2013-10-02 11:21:17 +02:00
Maciej Suminski 3d9fc4c40f Moved VIEW_GROUP creation to the selection tool. In this way selected items are always drawn on overlay, not only when dragged. 2013-10-02 10:21:05 +02:00
Maciej Suminski 3cdc207b50 Added typedefs for VIEW_GROUP iterators. Fixed improper order of layer drawing for VIEW_GROUP items. 2013-10-02 10:19:48 +02:00
Maciej Suminski 5acd895e0d VIEW_GROUP now does not change depth during drawing. Introduced functions for manipulating stored items.
FIxed problem of overlay being covered by other layers while panning.
Few minor fixes.
2013-10-01 16:55:33 +02:00
Maciej Suminski 3715af2172 Comments, refactoring 2013-10-01 10:21:32 +02:00
Dick Hollenbeck be4d7a6249 Make environment variable wxGrid/table read-only in the fp lib table dialog.
Fix throwing of IO_ERROR in plugin.cpp by converting function name to wxString.GetData().
Switch to const PROPERTIES* in GITHUB PLUGIN functions.
2013-09-30 16:26:49 -05:00
Maciej Suminski 04db1ff7cb Added missing file 2013-09-30 16:28:21 +02:00
Maciej Suminski 5f1a04cfa0 Fixed Mac OS build & removed one warning. 2013-09-30 09:45:42 +02:00
jean-pierre charras 4783e22fdc Gerbview: fix incorrect printing of negative objects, when using black and white option
Enhancement in Excellon file reader: accept Feed Rate and Spindle Speed definitions in Tool information line (but does not use them)
Eeschema: better name for m_SheetList (changed to m_SheetPath) member of class NETLIST_OBJECT.
2013-09-30 08:36:40 +02:00
Maciej Sumiński db4903cdc4 Restored previous version of math_utils.h. WARNING: Mac OS build is probably broken now. 2013-09-29 21:29:28 +02:00
Maciej Sumiński 248e37c292 Fixed selection disambiguation menu for wx2.8 2013-09-29 21:23:45 +02:00
jean-pierre charras 8a8ba43bde Gerbview: fix incorrect printing of negative objects, when using black and white option.
Eeschema: better name for m_SheetList (changed to m_SheetPath) member of  class NETLIST_OBJECT.
2013-09-29 20:24:38 +02:00
Maciej Sumiński 5c0bc4913e wxWidgets 2.8 compatibility fix (removed wx/kbdstate.h) 2013-09-29 14:25:04 +02:00
Maciej Sumiński ca84ed7e63 Fixed menu entry ids for the p&s router context menu. 2013-09-29 13:56:32 +02:00
Maciej Sumiński a64fb40d7e Fixed strings for wxWidgets 2.8 2013-09-29 12:57:20 +02:00
Wayne Stambaugh d11102c643 Fix wxWidgets 2.8 compile error. 2013-09-28 18:53:55 -04:00
Maciej Suminski 745b5328eb Moved common actions to a separate file. 2013-09-27 20:52:34 +02:00
jean-pierre charras 5fefc74da4 Eeschema: fix isssues in net names selection for not named nets (i.e. nets without labels) 2013-09-27 19:58:58 +02:00
Maciej Suminski a3a73426bf Even more code comments and reformatting. 2013-09-27 18:51:21 +02:00
Maciej Suminski 276d867ab2 Some more comments and code formatting. 2013-09-27 16:23:43 +02:00
jean-pierre charras 49b6a1725f Eeschema: netlist generation: fix bad choice for the "best net name" when selecting a net name between labels connected to the same net.
Code cleanup and remove unused file.
2013-09-27 14:30:35 +02:00
Maciej Suminski 4c67f4cc26 Added missing header 2013-09-27 14:29:07 +02:00
Maciej Suminski b369cc4afc Merge kicad-pns-mac 2013-09-27 12:06:59 +02:00
Maciej Suminski 52a7f3e2dc Uncrustified the push&shove source, fixed some warnings. 2013-09-27 10:00:26 +02:00
Maciej Sumiński 85d1048762 Uncrustifying push&shove router 2013-09-26 23:53:54 +02:00
Wayne Stambaugh 8b80c79feb Footprint viewer improvements and code cleaning.
* Use wxAuiManager perspective to save and load window settings which should
  allow us to start using more advanced wxAui features like detachable tool
  bars and windows.
* Remove sash size change events, event handler, and sash width clamping code
  since it didn't work all that well anyway.
* Disable the close button on the footprint view pane.
* Update the footprint list box selection when iterating the list using the
  tool bar arrow buttons.
* Merge code from modview.cpp into modview_frame.cpp and remove modview.cpp.
2013-09-26 13:22:35 -04:00
Maciej Suminski 9bef4cb797 Added Init() to TOOL_INTERACTIVE, allowing to set up things that are needed to be initialized only once.
TOOL_ACTIONs can be run from CONTEXT_MENU after adding them.
Move tool actions are available to be run from CONTEXT_MENU displayed after right mouse button click on selected items.
Added some asserts to check the code.
2013-09-26 18:38:58 +02:00
Dick Hollenbeck 39edd3bdcd comment/doc cleanups 2013-09-26 10:02:46 -05:00
Maciej Suminski b4585ce13a Fixed premature highlighting of options in CONTEXT_MENU. 2013-09-26 14:29:47 +02:00
Maciej Suminski e47790c3f8 Different way of handling CONTEXT_MENU in the selection tool. Removed some unnecessary lines. 2013-09-26 14:09:56 +02:00
Maciej Suminski 5098088237 Added functions for handling hotkeys, interface for adding TOOL_ACTIONs to CONTEXT_MENU.
Less objects are allocated dynamically.
CONTEXT_MENU is being run using its copy (it saves a hassle of following the lifetime of object).
2013-09-26 14:09:18 +02:00
Maciej Suminski b1c0d614a3 Added some const modifiers. 2013-09-26 11:22:59 +02:00
Dick Hollenbeck 66c9d29539 Make pretty prettier by striving for single line module pads. Add slick std::string based strprintf(), twice. 2013-09-26 00:29:54 -05:00
jean-pierre charras 655c8e609d Eeschema: Rework on netlist generator: code cleaning and enhancement.
Mainly, fix an annoying issue about not named nets:
now, these nets are named from the component references and pin names which are connected.
therefore, unless the net or the footprint references are modified, the net name is not modified between 2 netlist calculations.

Netlist generation code still needs some code enhancement (mainly removing the global g_NetObjectslist variable).
2013-09-25 21:37:28 +02:00
Dick Hollenbeck 948a0713d5 Make PLUGIN::Footprint*() API functions take 'const' PROPERTIES*.
Add const PROPERTIES* to FootprintDelete().
Add {Get,Set}Properties() to FP_LIB_TABLE::ROW.
Touch up fp table dialog.
2013-09-25 14:17:06 -05:00
jean-pierre charras b43d883db6 Eeschema: Rework on netlist generator: code clenenig and enhancement.
Fix an annoying issue about not named nets:
now, these nets are named from the component references and pin names which are connected.
therefore, unless the net or the footprint references are modified, the net name is not modified between 2 netlist calculations.
2013-09-25 21:09:57 +02:00
Wayne Stambaugh 73367a10ea Fix debug build error in pcbnew/dialogs_fp_lib_table.cpp. 2013-09-25 09:51:54 -04:00
Dick Hollenbeck b9eba042c0 turn off new linker map generation in pcbnew 2013-09-24 16:26:23 -05:00
Dick Hollenbeck 17a33166a4 Set PROPERTIES* into FP_LIB_TABLE::ROW, which is a parsed (binary) form of the 'options'.
Write parser and formatter for options.  Write dialog verification used before saving
FP_LIB_TABLEs, triggered from OK button in table editor.
Switch PROPERTY's value column to std::string from wxString.
Add event handler to fp lib table dialog for upcoming options dialog.
2013-09-24 16:23:13 -05:00
Wayne Stambaugh ffbaf87dc9 Pcbnew footprint library plug in fixes and minor code cleaning.
* When loading footprint do not retest every footprint in cache.  Only test
  the footprint being loaded.  Fixes long load times on libraries with a lot
  of parts.
* Fix footprint name bug where file extension was added to the end of the
  footprint name.
* Fix bug in path equivalence test due to Posix path separators in footprint
  library table.  Convert paths to native separator before comparison.
* Fix a bug in FOOTPRINT_VIEWER_FRAME::OnActivate() which cause the footprint
  list to always get reloaded when using footprint library tables.
* Remove some unnecessary debugging messages.
* Add a few Doxygen comments to FP_CACHE in kicad_plugin.cpp.
2013-09-24 14:45:57 -04:00
Maciej Suminski 8ea74c38c3 Fixed cvpcb build. 2013-09-24 16:12:02 +02:00
Maciej Suminski 5789f20794 Added protection from redrawing while GAL backend is being switched. 2013-09-24 16:00:21 +02:00
Maciej Suminski 133e60410c Added rotate & flip to the pcbnew.InteractiveMove tool, hotkeys for them and undoing all the operations on cancelling the tool. 2013-09-24 15:49:43 +02:00
Maciej Suminski 57a8622e9a Added functions for refreshing the layer set occupied by a VIEW_ITEM. 2013-09-24 15:48:04 +02:00
Maciej Suminski 634039d81a Added possibility to cancel a tool that is not on the top of the tool stack. 2013-09-24 15:47:07 +02:00
Dick Hollenbeck b9c9990bdb Set FPID on GITHUB_PLUGIN::FootprintLoad() 2013-09-23 10:57:15 -05:00
Dick Hollenbeck 1e31e737f5 GITHUB_PLUGIN now builds under the scripting DSO on linux.
Enhance IO_MGR::GuessPluginTypeFromLibPath() to support the GITHUB plugin.
Build boost with -fPIC on Linux unconditionally, in preparation for
DLL/DSO build of kicad.
Add python script to test back to back reads of GITHUB plugin.
2013-09-23 10:19:39 -05:00
Maciej Suminski 5e3f579431 Fixed build for Mac OS 2013-09-23 17:02:25 +02:00
Maciej Suminski e9e4df8d01 FIxed TOOL_EVENT::Modifier() (now it returns value for current modifier, not only if there is one active or not). 2013-09-23 10:02:01 +02:00
Wayne Stambaugh a3cdc4fb83 Pcbnew footprint library table fixes.
* Make footprint editor work properly with library table.
* Fix bug in Eagle plugin when comparing file timestamps.
* Fix bug in footprint viewer when error occur loading footprints from
  the selected library.
* Fix error message display by in footprint viewer on library load error.
2013-09-22 13:20:46 -04:00
Dick Hollenbeck c034e5922f unique FPL_CACHE class names 2013-09-21 23:38:22 -05:00
Dick Hollenbeck 3d8d726a52 GITHUB_PLUGIN now works and can be used under Linux immediately.
Other platforms to follow as volunteers test support and get openssl in 
place.
2013-09-21 22:57:40 -05:00
Dick Hollenbeck 1b09ac4757 OOPS, add missing file for Windows GITHUB_PLUGIN 2013-09-21 22:24:11 -05:00
Wayne Stambaugh f7012d8275 Pcbnew footprint library table fixes.
* Make footprint viewer work properly with library table.
* Fix bug in Eagle plugin when enumerating footprints.
* Add missing P-CAD plugin from footprint library table editing dialog.
* Fix bug in FOOTPRINT_INFO::LoadLibraries when error occur loading footprints
  from libraries.
2013-09-21 20:28:02 -04:00
Build System e61950267b Fixes typo in doxygen-python, and fixes unitest TestCase().discover on python < 2.7 2013-09-22 02:34:15 +04:00
Miguel Angel Ajo 4c9ff08f4f missing QA tests for the python scripting QA 2013-09-22 00:27:41 +02:00
Miguel Angel Ajo 8668488a20 scripting QA tests, initial implementation 2013-09-22 00:04:59 +02:00
Miguel Angel Ajo 31f8dc5cbf Scripting build tools moved and renamed 2013-09-22 00:03:02 +02:00
Dick Hollenbeck a477129bc1 BUILD_GITHUB_PLUGIN will build GITHUB_PLUGIN on Linux now. Don't know if the parser works yet, but the FootprintEnumerate() function worked in testing. 2013-09-21 14:20:31 -05:00
jean-pierre charras c46b8aecbc Pcbnew: Block selection enhancement, from Bug #593997 (whishlist)
1. block created from-left-to-right selects only 100%inside selection objects (as it now does)
2.block created from-right-to-left selects all overlapping objects inside selection
From the patch sent by mathieulj (mathieulj), and some fixes and code cleaning.
2013-09-21 20:09:41 +02:00
jean-pierre charras a010b6177c Fix some minor issues in hotkey dialogs 2013-09-21 19:09:08 +02:00
Dick Hollenbeck d38b7012e9 temporarily disable GITHUB_PLUGIN 2013-09-21 11:07:26 -05:00
Dick Hollenbeck 6a6152eb0a temporarily disable GITHUB_PLUGIN 2013-09-21 11:06:15 -05:00
Dick Hollenbeck 15121e6d4e BUILD_GITHUB_PLUGIN issues. 2013-09-21 09:48:37 -05:00
Dick Hollenbeck a8e44d0093 remove some headers, no good for my head 2013-09-21 02:45:25 -05:00
Dick Hollenbeck fd8f74cf43 Early GITHUB_PLUGIN hopefull-ness 2013-09-21 02:30:23 -05:00
Build System 472e4da100 Adds target to build doxygen-python documentation, that take
pcbnew.py + doxygen-xml files, and build .i files with docstrings,
those .i files are included back again to build a pcbnew.py with
extended documentation from C++, finally we take the final pcbnew.py
to build the doxygen-python documentation
2013-09-20 21:01:21 +04:00
Maciej Suminski 607fe8ed4b Added missing files 2013-09-20 18:21:01 +02:00
Maciej Suminski a0a479eb53 Merged upstream. 2013-09-20 17:54:35 +02:00
Maciej Suminski 04cdb15ceb Changed the way of refreshing canvases (both standard & GAL). 2013-09-20 17:29:32 +02:00
Dick Hollenbeck 180e0a3645 BOM generators now report count of "interesting" components, rather than total components 2013-09-20 10:11:45 -05:00
Maciej Suminski c931800642 Restored previous function names. 2013-09-20 16:32:11 +02:00
Maciej Suminski e839d1a129 Merged kicad-gal 2013-09-20 15:48:27 +02:00
Maciej Suminski 1efec52b33 Added cursor for the move tool 2013-09-20 15:01:08 +02:00
jean-pierre charras 3799481c35 Pcbnew: better dialogs to select the active layer or a layer pair. Add an option (hotkey+popup menu) to place a via and select the new active layer
(useful for boards having more than 2 layers)
Eeschema:fix compatibility with old schematic files, when they  contain ERC markers.
Pcbnew: better test for allowed layers when creating/editing Dimensions and some other Graphic items
Drc:  fix comments and messages for some drc tests.
Fix minor bugs in cleanup dialog options and plot solder mask function (thanks to Lorenzo to locate these bugs)
2013-09-20 12:52:33 +02:00
Dick Hollenbeck c1025612d1 Lorenzo's help enabled a fix to UTF8 support in csv.writer in python bom generators. 2013-09-19 18:50:30 -05:00
Maciej Suminski e07a8fbe31 Removed TA_ActivateTool (now tools are invoked by sending TA_Action event, with the tool name as string parameter).
Developed TOOL_Action class & added ActionManager. Hot keys registered by tools are processed.
Selection & move tool can be invoked by a hot key.
2013-09-19 17:02:57 +02:00
Maciej Suminski 2d52cb1d55 Moved GalLayersOrder from layers_id_colors_and_visibility.h to PCB_BASE_FRAME. 2013-09-19 09:55:37 +02:00
Maciej Suminski a1cdbe5762 Merged kicad-pns-tom. 2013-09-19 09:33:07 +02:00
jean-pierre charras 2f3bbf1f59 Fix minor bugs in cleanup dialog options and plot solder mask function (thanks to Lorenzo to locate these bugs) 2013-09-18 21:22:25 +02:00
jean-pierre charras 7ceb13d041 Fix minor bugs in cleanup dialog options and plot solder mask function (thanks to Lorenzo to locate these bugs) 2013-09-18 21:21:11 +02:00
tomasz.wlostowski@cern.ch d04d93eb9b A very short insturction for the P&S Router. 2013-09-18 20:11:21 +02:00
tomasz.wlostowski@cern.ch f6a3bc9168 Merged Orson's latest changes. 2013-09-18 20:10:55 +02:00
tomasz.wlostowski@cern.ch dca79490da P&S router: some missing files 2013-09-18 19:56:37 +02:00
tomasz.wlostowski@cern.ch abf37168de Initial version of the P&S router. Buggy and crappy. 2013-09-18 19:55:16 +02:00
Maciej Suminski 67fadf0c94 Added missing files 2013-09-18 19:51:57 +02:00
tomasz.wlostowski@cern.ch 1b29805fc9 geometry/rtree.h: fix compiler warnings 2013-09-18 19:37:56 +02:00
Maciej Suminski fcd3bbecdf Added limits for VIEW scale values & panning area. 2013-09-18 17:36:54 +02:00
Maciej Suminski 3d767ffcc7 Moved Type() method from EDA_ITEM to VIEW_ITEM. 2013-09-18 17:04:07 +02:00
Maciej Suminski f88711ebf9 Merged Tom's branch 2013-09-18 16:59:08 +02:00
tomasz.wlostowski@cern.ch 17cd564ba6 PCB_EDIT_FRAME: public SetTopLayer() method 2013-09-18 13:37:20 +02:00
tomasz.wlostowski@cern.ch 8bb3bba7e8 PCB_PAINTER: fix segfault when item has no net assigned 2013-09-18 13:16:57 +02:00
tomasz.wlostowski@cern.ch 5d3dda7a9d VIEW_CONTROLS: added ForceCursorPosition() and ShowCursor() methods 2013-09-18 13:15:42 +02:00
Wayne Stambaugh 5761c182ee Fix std::string to wxString conversion bug in Pcbnew. (fixes lp:1226670) 2013-09-18 07:15:17 -04:00
tomasz.wlostowski@cern.ch 0e23e23a7c VIEW: added GetTopLayer() method 2013-09-18 13:14:57 +02:00
tomasz.wlostowski@cern.ch e2736f4db1 geometry: killed compiler warnings 2013-09-18 13:14:13 +02:00
tomasz.wlostowski@cern.ch 1ea78293d0 gal: make the cursor a bit bigger and hidden by default 2013-09-18 13:13:03 +02:00
Wayne Stambaugh df0a195f38 Fix two more FPID empty string parsing bugs. 2013-09-17 11:51:05 -04:00
Wayne Stambaugh b00d23c46c Fix board parsing error when module name is empty. (fixes lp:1226546) 2013-09-17 10:03:16 -04:00
Maciej Suminski ed4966a3ff Fixed random color of worksheet border. 2013-09-17 14:46:48 +02:00
Maciej Suminski b03359a3db The last fix to selection rules. 2013-09-17 13:47:33 +02:00
Maciej Suminski d4e07e981a Selection in high contrast mode selects only items that are shown as active. 2013-09-17 11:32:47 +02:00
Maciej Suminski 2d097d0fd7 Selection box color is put into render settings. Selection layer is removed from active layers. 2013-09-17 11:23:00 +02:00
Maciej Suminski 278b4547f4 Modules are marked to be on copper layer too. 2013-09-17 11:21:42 +02:00
Maciej Suminski ee84127892 Added get functions for high contrast mode fields. 2013-09-17 11:19:15 +02:00
Wayne Stambaugh 3724c40afd Fix but reading empty footprints in netlist. (fixes lp:1226283)
* Remove fp_lib token from board and s-expr netlist file format.
* Fix a bunch of Doxygen warnings.
* Remove some extra debug log messages.
2013-09-16 20:52:08 -04:00
Wayne Stambaugh eaada4cf1f Fix broken CvPcb footprint preview. (fixes lp:1226272) 2013-09-16 19:56:45 -04:00
Maciej Suminski 033b25de32 Reenabled snapping for tools. 2013-09-16 16:46:02 +02:00
Maciej Suminski 32a12d1d6f Unified marking of selected items. 2013-09-16 16:18:43 +02:00
Maciej Suminski fe27b0e2ba Changed to worksheet border color to match the rest of the worksheet layout. 2013-09-16 15:19:48 +02:00
Maciej Suminski 66fcd4c5a2 Fixed bounding box for dimension. 2013-09-16 14:44:03 +02:00
Maciej Suminski ccdeb6dc0a More careful check on the net number while drawing net labels for tracks. 2013-09-16 11:08:31 +02:00
Maciej Suminski b579262869 Better way of marking 'brightened' mode for items. 2013-09-16 11:00:59 +02:00
Maciej Suminski 11f1dd1623 Sorted out headers. 2013-09-16 09:52:47 +02:00
Maciej Suminski 6a9a25fc54 Fixed drawing outlined track segments. 2013-09-16 09:51:53 +02:00
Maciej Suminski ef47f6cfd2 Changed alignment. 2013-09-16 09:51:24 +02:00
Wayne Stambaugh cecd75063e CvPcb footprint library table implementation.
* Add code to CvPcb to handle assigning component footprints from the
  footprint library table instead of the search path method.
* Add code to CvPcb to allow editing of the footprint library table.
* CvPcb footprint and component panes display fully qualified FPID names.
* Make CvPcb library pane display footprint library table nicknames instead
  of library file names.
* Add code to FP_LIB_TABLE object to test the paths in the table against the
  list of libraries loaded from the project file.
* Add code to FP_LIB_TABLE to convert assigned footprints in a NETLIST from
  legacy format to footprint library table format.
* Split out COMPONENT_NET, COMPONENT, and NETLIST objects from netlist_reader
  files and create new pcb_netlist files.
* Fix minor wxListView scroll bar sizing issues.
* Add new token and code to save and load FPID nickname in board file.
* Add new token and code to save and load FPID nickname in s-expression net
  list file.
* Add WX_STRING_REPORT object to dump strings to a wxString object.
2013-09-14 16:33:22 -04:00
Maciej Suminski 6dad482efa Added more required layers for pads (adhesive, solder paste & solder mask) 2013-09-13 17:45:40 +02:00
tomasz.wlostowski@cern.ch 4aae4489b9 Merged Orson's branch 2013-09-13 15:45:03 +02:00
tomasz.wlostowski@cern.ch 1b00dede02 geometry: r-tree based shape index 2013-09-13 15:43:33 +02:00
Maciej Suminski 5700075b7a Added missing functions for checking type of keyboard event 2013-09-13 15:31:19 +02:00
Maciej Suminski 5a461f5bb3 Caps for lines are drawn only when segments are wider than 1.0 2013-09-13 15:30:45 +02:00
tomasz.wlostowski@cern.ch a6cbdccadc common/profile.h: fix incorrect #endif 2013-09-13 15:28:51 +02:00
tomasz.wlostowski@cern.ch b662a577ea polygon: added poly2tri library.
Requied for constrained Delaunay triangulation (P&S/ratsnest) and zone tesselation (GAL).
2013-09-13 15:28:20 +02:00
tomasz.wlostowski@cern.ch 128b1a423f SEG: added SquaredLength() method 2013-09-13 15:25:03 +02:00
Maciej Suminski 5e41599d13 Removed unnecessary debug message 2013-09-13 15:05:57 +02:00
Lorenzo Marcantonio 2cab94f56c Add missing file 2013-09-13 12:59:47 +02:00
jean-pierre charras eedd673d4c Pcbnew: Fix Bug #1224656 2013-09-13 11:58:51 +02:00
jean-pierre charras 25ffde5a42 Add export netlist IPC-D-356 from Lorenzo Marcantonio, with very minor fixes. 2013-09-13 11:57:31 +02:00
Lorenzo Marcantonio l.marcantonio@logossrl.com a06134cd6c Add export netlist IPC-D-356 from Lorenzo Marcantonio, with very minor fixes. 2013-09-13 11:49:55 +02:00
Maciej Suminski fa57fee9bb Removed VIEW_LAYER.isDirty flag. 2013-09-13 11:38:16 +02:00
Maciej Suminski 404bfdcf30 Changed VIEW::PrepareTargets() to more appropriate name VIEW::ClearTargets(). Added SELECTION layer to always-on-top list. 2013-09-13 11:28:47 +02:00
Maciej Suminski 87d81a6d92 Mouse movement events are sent during autopanning, as the cursor position changes in the world coordinates (even if it stays still in the screen coordinates). It allows tools to update their state, as if the mouse was moved. 2013-09-13 10:26:08 +02:00
Maciej Suminski 7d41dc1616 Currently selected layer is displayed on the top. 2013-09-12 18:24:53 +02:00
Maciej Suminski c1e1502d35 Merged Tom's branch 2013-09-12 17:42:28 +02:00
tomasz.wlostowski@cern.ch 73949712f6 added note why there's no P&S sources yet... 2013-09-12 11:49:24 +02:00
tomasz.wlostowski@cern.ch 61778974a4 EDA_DRAW_PANEL_GAL: redraw stuff in a single place, with "coalescing"
Redraws can be requested way too often than it is required. This commit adds redraw timeout:
- if the view became dirty and there has been no redraw for longer than certain time, it is redrawed immediately
- otherwise, we wait for the next frame

This in general improves smoothness of rendering.
2013-09-12 11:40:16 +02:00
tomasz.wlostowski@cern.ch c817deb652 CONTEXT_MENU: null pointer check bugfix. 2013-09-12 11:36:19 +02:00
tomasz.wlostowski@cern.ch 802a0117a7 COLOR4D: added Saturate(), FromHSV(), ToHSV() methods.
Used in highlighting/routing code.
2013-09-12 11:35:42 +02:00
Maciej Suminski 9b2a450133 Fixed rollback of traces movement. 2013-09-12 10:54:11 +02:00
Maciej Suminski fcfbe920d5 Removed selection disambiguation in case when there is a choice between a footprint and a smaller component (smaller components have priority). 2013-09-12 10:46:22 +02:00
Maciej Suminski b57331f450 Move tool is activated when drag event starts nearby selected items. 2013-09-12 10:24:23 +02:00
Maciej Suminski 944a61100b Fixed memory leaks in containers. 2013-09-12 09:44:57 +02:00
Maciej Suminski f8ae1a9997 Removed some potential memory leaks. 2013-09-11 19:37:52 +02:00
jean-pierre charras 8ea015aaab Eeschema: fix compatibility with old schematic files, which can contain markers.
Pcbnew: better test for allowed layers when creating/editing Dimensions and some other Graphic items
Drc: fix comments and messages for some drc tests.
To do: fix issues in active layer selection when creating a track and layer pair selection dialog
2013-09-11 17:30:21 +02:00
Maciej Suminski e38019d74e Removed some dead code. 2013-09-11 16:38:40 +02:00
Maciej Suminski 7da892b49a Added drawing of worksheet layout. 2013-09-11 14:42:12 +02:00
Maciej Suminski 60c84abfe4 Changed lifetime of RENDER_SETTINGS (now they are accessible right after PAINTER object is created). 2013-09-11 12:09:22 +02:00
Maciej Suminski efa1ac3807 Moved GetColor() from PAINTER to RENDER_SETTINGS. Fixed recaching of custom items. 2013-09-11 11:39:46 +02:00
Maciej Suminski f6b7ab7994 Changed some 'magic numbers' into constants. Added const modifier in appropriate spots. 2013-09-11 11:34:10 +02:00
Maciej Suminski c0b6d159fc Added one more function to convert colors. 2013-09-11 11:11:27 +02:00
Maciej Suminski fa85685baa Fixed COLOR4D( EDA_COLOR_T aColor ) and added asserts. 2013-09-11 10:30:39 +02:00
tomasz.wlostowski@cern.ch d1883bdd9d Merged kicad-gal-orson 2013-09-10 19:32:19 +02:00
tomasz.wlostowski@cern.ch b4ff4df808 pcbnew: start integrating P&S router 2013-09-10 19:26:44 +02:00
tomasz.wlostowski@cern.ch 3254bfa619 VIEW_GROUP: added FreeItems() method 2013-09-10 19:25:02 +02:00
tomasz.wlostowski@cern.ch bf26cf175f TOOL_MANAGER: open menu on right mouse button when requested 2013-09-10 19:23:15 +02:00
tomasz.wlostowski@cern.ch 2c287965fc TOOL_DISPATCHER: improve mouse handling 2013-09-10 19:22:38 +02:00
Maciej Suminski 4551ded37e Some more missing D()->DBG() changes. 2013-09-10 17:07:46 +02:00
Maciej Suminski b4d05af28f Modified default grid/origin settings. 2013-09-10 14:35:10 +02:00
Maciej Suminski eac742e3db Added const modifiers where applicable. 2013-09-10 14:31:52 +02:00
Maciej Suminski 57a1201b11 PCB items are refreshed on GAL switching (changes made using default renderer are displayed by GAL). 2013-09-10 13:57:28 +02:00
tomasz.wlostowski@cern.ch 85a8a71fc5 common: minimum version of the shape library 2013-09-10 13:43:09 +02:00
Maciej Suminski bd6bb510f8 Changed D() macro to DBG() because of conflict with glm::D().
Added const to GetColor() and GetType() functions in WS_DRAW_ITEM.
2013-09-10 10:47:42 +02:00
Maciej Suminski 0cf8221e62 Fixed hanging up of menu loop when user never moves mouse cursor into popup menu area. 2013-09-09 17:12:03 +02:00
tomasz.wlostowski@cern.ch 36d4e8fa62 PCB_PAINTER: added public GetLayerColor() method 2013-09-09 17:08:52 +02:00
tomasz.wlostowski@cern.ch a384290356 EDA_DRAWPANEL_GAL: set focus on mouse enter to catch all key events 2013-09-09 17:07:03 +02:00
tomasz.wlostowski@cern.ch 8b9226d820 math/vector2d.h: removed unused code, correct rounding in Resize() 2013-09-09 16:56:18 +02:00
tomasz.wlostowski@cern.ch 35e639c599 math/math_util.h: fixed signedness bug in rescale() 2013-09-09 16:55:01 +02:00
tomasz.wlostowski@cern.ch 3a7f5fcf03 math/box2.h: normalize on construction, minor compilation warning fix 2013-09-09 16:53:33 +02:00
Maciej Suminski 881cbd6d2f Small refactoring. 2013-09-09 14:31:27 +02:00
Maciej Suminski b319b710df Fixed color for drawing polygons on overlay. 2013-09-09 14:31:13 +02:00
Maciej Suminski dd1ad34cea Stops autopanning on left mouse button release. 2013-09-09 13:57:56 +02:00
Maciej Suminski 9406893722 Enabled snapping for the move tool. 2013-09-09 11:45:20 +02:00
Maciej Suminski cea4d89697 Tools are enabled to switch snapping cursor to grid. 2013-09-09 10:54:11 +02:00
Maciej Suminski 7bbd31fa2a Modified interfaces for [WX_]VIEW_CONTROLS. 2013-09-09 10:53:46 +02:00
Maciej Suminski c6d9a04dba Parts of MODULEs are not selectable in multiple selection mode. 2013-09-09 10:10:02 +02:00
Maciej Suminski 77fc1aecb2 First version of the move tool. 2013-09-09 09:34:52 +02:00
Wayne Stambaugh 24da541747 Convert footprint definitions from wxString to FPID.
* Use FPID instead of wxString in MODULE object.
* Use FPID instead of wxString when loading and saving files.
* Use FPID in COMPONENT object.
* Add wxString helper functions and comparison operators to FPID.
* Add fp_lib token to pcb and netlist file formats.
* Add code to load and save FPIDs to pcb file format.
* Fix segfault when deleting invalid footprint library tables in Pcbnew
  in non footprint library table build.
* Fix bug when counting the number of mod files in
  EDA_APP::SetFootprintLibTablePath();
2013-09-08 14:31:21 -04:00
Maciej Suminski 02f7e9c800 Changed focus owner of LayerWidget to EDA_DRAW_PANEL_GAL to make keyboard events work (apparently everything works fine, to be tested more extensively).
Removed unnecessary event hook from EDA_DRAW_PANEL_GAL.
2013-09-06 17:53:01 +02:00
Maciej Suminski cbbc2f42e8 Starts the GAL by default. 2013-09-06 17:06:33 +02:00
Maciej Suminski 7e73dad7b0 Some more spots where the GAL refresh was required. 2013-09-06 17:06:02 +02:00
Maciej Suminski bc67fc338e Smarter selection algorithm (does not allow to select both whole MODULE and its parts at the same time).
Cancel event works better (selection box does not appear after cancelling the selection tool).
Removed blinking selection box effect.
Model is accessed in more appropriate way (getModel() method).
2013-09-06 16:04:12 +02:00
Maciej Suminski 6054e7be0a Added a few comments. 2013-09-06 16:01:46 +02:00
Wayne Stambaugh a7f31c59a8 Footprint library table ground work.
* Remove defined CMAKE_INSTALL_PREFIX for Windows from main CMakeList.txt.
* Move footprint library path detection code from pcbnew.cpp to EDA_APP
  object.
* Add CMAKE_INSTALL_PREFIX to config.h.cmake.
* Simplify and fix search path list code.
* Add CMAKE_INSTALL_PREFIX to the list of search paths in case KiCad was
  installed using `make install`.
* Add default global footprint library table to CMake install.
* Add method to set footprint library table to PCB_BASE_FRAME object.
* Remove unused function EDA_APP::GetLibraryFile().
* Minor FP_LIB_TABLE object improvements.
2013-09-06 08:17:33 -04:00
Maciej Suminski 345e97f296 Solved refreshing issues. 2013-09-06 11:31:16 +02:00
Maciej Suminski 7716d4592d Fixed hotkeys for switching rendering backends. 2013-09-06 10:19:53 +02:00
Maciej Suminski 7e4eba9eed Some comments. 2013-09-04 16:25:57 +02:00
Maciej Suminski a1089c9dd6 More effective way of updating bounding boxes. IsCached() method made public. Removed some of unused fields from the layer description structure. 2013-09-04 16:23:26 +02:00
Maciej Suminski 9a032e7422 Moved selection marking boxes to a different layer. 2013-09-04 16:18:37 +02:00
Maciej Suminski 55dddb69f7 Improved selection rules. Added some comments to the selection tool. 2013-09-04 10:56:06 +02:00
jean-pierre charras 580d42a63e pcbnew: fix wxWidgets 2.8 compatibility issue (temporary fix, still have a minor cosmetic issue), and add missing file. 2013-09-03 21:37:52 +02:00
Maciej Suminski 1a1416aaa4 Fixed Cairo's render target setting. 2013-09-03 17:46:05 +02:00
jean-pierre charras 1d74450216 Pcbnew: use pcb layer box selector in dialog graphic item properties and pcb text properties. 2013-09-03 14:48:38 +02:00
Maciej Suminski 446a0a174e Module texts are now moveable, rotatable and flippable. 2013-09-03 14:15:37 +02:00
Maciej Suminski 6405273059 Support for trapezoidal pads. 2013-09-03 13:51:53 +02:00
jean-pierre charras bbd0a41191 Rework on layer box selector, to use it in dialogs (currently the active layer selector, the layer pair selector and the dimension editor dialog.
This rework solves Bug #1214545.
Work in progress: many dialogs do not yet use the layer box selector.
2013-09-02 17:49:29 +02:00
jean-pierre charras 7bc9003fb8 pcb layer box selector: ajust size when modifying the layer names, to show the full name. 2013-09-02 17:26:52 +02:00
Maciej Suminski 7c745cd9c6 Allow invoking GAL tools, only if GAL is active. 2013-09-02 16:44:13 +02:00
Maciej Suminski 202f7f9107 Added autopanning to the selection tool. 2013-09-02 16:29:10 +02:00
Maciej Suminski 1e1fbb4ccf Corrected behaviour of drag panning while autopanning is enabled. 2013-09-02 16:26:42 +02:00
Maciej Suminski 0b17e5d288 Added some comments and changed names of classes to match the coding rules. 2013-09-02 14:21:12 +02:00
Maciej Suminski 3b046c409b Changed way of naming VIEW_ITEM update flags to be more explicit.
VIEW_ITEMs save the layer numbers they use, it allowed to speed up removal of items.
2013-09-02 11:49:46 +02:00
jean-pierre charras 9eeb56fe3e minor changes and refinement in class pcb layer box 2013-09-02 11:06:17 +02:00
jean-pierre charras 3124f8133a Cleaning code for PCB_LAYER_BOX_SELECTOR class, and use it in edit dimension dialog. 2013-09-01 20:38:11 +02:00
Dick Hollenbeck f99ca77461 Use via layers which are determined in only one place, this is a cheap trick to support blind vias in the export. 2013-09-01 12:59:28 -05:00
Dick Hollenbeck 0bc1c08d4f Add <aliases> and <alias> to generic netlist XML format, required by new bom_csv_grouped_by_value.py support. 2013-09-01 12:52:46 -05:00
Dick Hollenbeck 3fcf44ae32 Clarify, extend, and rename ky*.py to kicad_netlist_reader.py.
Significantly enhance the bom_csv_grouped_by_value.py BOM generator.
IMO it at this moment, the best BOM production tool for KiCad.
2013-09-01 12:49:01 -05:00
Brian Sidebotham 4d1dc14b45 * Fix Bug 1219239 - EESCHEMA crashes when editing a template field in libedit through the context menu 2013-08-31 16:53:46 +01:00
jean-pierre charras e4710f54f8 add missing files 2013-08-30 21:37:56 +02:00
jean-pierre charras ce983ec34a Pcbnew: Redesign layer selection and layer pair selection (give them a look near the Layer selector in toolbarr) 2013-08-30 21:28:31 +02:00
Maciej Suminski bf9b535f66 Fixed warning. 2013-08-30 14:43:18 +02:00
Maciej Suminski a2f0110f3d Added selection box for DIMENSION. 2013-08-30 14:02:57 +02:00
Maciej Suminski 367924e669 Added stacking for tools. 2013-08-30 10:37:26 +02:00
Maciej Suminski 9c6998c6bc Added SELECTION_TOOL::GetSelection() 2013-08-30 10:23:18 +02:00
Maciej Suminski 1bf848e418 Unified Set/GetPosition() for BOARD_ITEMs. 2013-08-29 12:06:06 +02:00
Maciej Suminski d62e474850 Reduced displayed events information. 2013-08-29 12:03:57 +02:00
jean-pierre charras 7546333fbc Pl_Editor: fix some minor issues. 2013-08-29 09:20:09 +02:00
jean-pierre charras 405bb0ad90 Pcbnew: enhancements for blind/buried vias placement ( separate keys to add a buried via or a through via), and save" blind/buried vias allowed" option in .kicad_pcb file
Minor code cleaning.
Allows compiling under wxMSW-2.8.12, only for test purposes, because there are serious bugs for Kicad under wxWidgets version < 2.9.3.  (compil warning generated for these versions)
2013-08-28 19:32:49 +02:00
jean-pierre charras b7e9f8ce1e Pcbnew: enhancements for blind/buried vias palcement, and save blind/buried vias allowed option in .kicad_pcb file 2013-08-28 18:14:39 +02:00
Maciej Suminski 00a2da7d18 Fixed cursor drawing for OpenGL. 2013-08-28 17:06:07 +02:00
Maciej Suminski 86c29e23df Added cursor snapping. 2013-08-28 16:25:42 +02:00
jean-pierre charras 8765d96c4b Add missing file 2013-08-28 09:29:48 +02:00
jean-pierre charras ee6233b893 Add pl_editor_doc.icns, from Orson. Fix Bug #1217504 (bad look of Module Properties Dialog, 3D fields).
Add Dick's workaround in plot_board_layers.cpp to try to avoid crash in solder mask calculations, due to a bug in boost::polygon, in resize function.
2013-08-28 09:23:14 +02:00
Maciej Suminski cebdb43234 Added mouse cursor drawing.
Added flipping mode.
2013-08-27 18:08:32 +02:00
Maciej Suminski f65da3d98f Merged upstream and Mac OS X build fixes. 2013-08-27 11:03:06 +02:00
Maciej Suminski e6e13b2609 Fixed GLEW library detection for Mac OS X. 2013-08-27 10:32:39 +02:00
Maciej Suminski 96774bb98c Added missing Mac OS X icons for the pagelayout_editor. 2013-08-27 10:14:26 +02:00
Dick Hollenbeck 681301ab9b switch to newer boost version. 2013-08-26 15:19:04 -05:00
Dick Hollenbeck 0d68dfcbc1 enhanced beautification, better formatting, upgrade to 0.60 uncrustify.cfg 2013-08-26 15:15:00 -05:00
Maciej Suminski 0a17e9a236 Fix for wxWidgets 2.9.5 2013-08-26 14:23:17 +02:00
Maciej Suminski 8597d2c681 Fixed the 64 bit build. 2013-08-26 14:08:32 +02:00
Maciej Suminski eca53baf6f Fixed linking errors for apps other than pcbnew. 2013-08-26 10:43:22 +02:00
jean-pierre charras b7bc4ea43e Pcbnew: speedup netlist read, when some footprints are not found, by caching the non-existent footprint names, which are searched only once in libs.
When a non existent footprint is used by many components, this footprint was previoulsy searched in libs for each component, which is very time consumming.
2013-08-24 15:03:59 +02:00
jean-pierre charras 6ab2f35f74 Pcbnew: read netlist enhancements: add option to remove single pads nets, add enforce tests to report non existing netnames in zones.
Fix also some very minor errors in comments.
2013-08-24 10:08:55 +02:00
jean-pierre charras c015153e21 Pcbnew: add more test when reading a netlist file: verify if all pads found in netlist are found in corresponding footprints (no missing pads). 2013-08-23 11:22:19 +02:00
Maciej Suminski 7a74418c39 Removed some unnecessary stuff and added some comments to WX_VIEW_CONTROLS. 2013-08-23 10:56:52 +02:00
jean-pierre charras 6033b3599e Pcbnew: Fix a bug when reading a netlist which forces pcbnew to read lib files to find a footprint even if the right footprint is already loaded (which explains the long time to load netlists)
Netlist dialog: add option to report only most important messages. Useful for large boards.
class REPORTER: add features to allow a basic message filtering (flags to report all/warning/error messages)
Fix Bug #1214599 ( tools are deselected on Move command )
2013-08-23 08:38:57 +02:00
Maciej Suminski 37d98063f0 Added autopanning functionality to WX_VIEW_CONTROLS. 2013-08-22 18:42:53 +02:00
Maciej Suminski 7fe85b44f9 Modified InvokeTool(), so besides resetting the tool, it also send an ActivateTool event.
Added generation of CancelTool event upon ESC key press.
Minor bugfix.
2013-08-22 15:07:34 +02:00
Maciej Suminski 68125a7f50 Changed reaction of SELECTION_TOOL to ToolCancel event (first event clears selection, second one deactivates the tool). 2013-08-22 15:05:37 +02:00
Maciej Suminski 166879a1c8 Mark layers as dirty on VIEW_ITEM removal. 2013-08-22 15:04:14 +02:00
Maciej Suminski b518569674 Added handling keyboard events for the Tool framework. 2013-08-21 17:37:27 +02:00
Dick Hollenbeck 6a25e05e3c Lay basis for a more full featured usage of boost, including compiled libraries such as unit_test_framework, system, etc. Move headers now into boost_root/include/boost/. 2013-08-20 13:03:21 -05:00
Lorenzo Marcantonio 179862b10a Fixed issues when opening a pagelayout from the command line 2013-08-20 15:44:42 +02:00
Maciej Suminski 339cf51c0c Added VIEW_GROUP for grouping items to be displayed on a single layer. 2013-08-20 15:07:38 +02:00
Maciej Suminski c8d06997f5 Added InvokeTool() and FindTool() functions. 2013-08-20 14:49:08 +02:00
Maciej Suminski 57979f3c9b Smarter way of the overlay rendering (overlay is always refreshed, while cached&noncached targets only if the viewport or items have changed). 2013-08-19 11:02:38 +02:00
Maciej Suminski e70a0e4e0e Reformatting. 2013-08-19 09:47:36 +02:00
Maciej Suminski 6268fe957a Functions for direct item drawing. 2013-08-19 09:44:50 +02:00
jean-pierre charras 49ce5eecdf Pl_Editor: fix crash on Linux when closing Pl_Editor 2013-08-19 09:08:13 +02:00
jean-pierre charras 4e1da2b6d0 Pl_Editor: fix minor issues in multi-lines texts
Others: fix very minor issues.
2013-08-18 17:49:04 +02:00
Brian Sidebotham 3f7d24bccf * Fix the last parts of Bug 1204712 by removing DateAndTime from library file and documentation file formats. They weren't being loaded anyway. 2013-08-16 23:31:37 +01:00
Wayne Stambaugh de0c051e51 Fix layer alignment target default size. 2013-08-16 14:41:09 -04:00
Wayne Stambaugh 1ef99e657f Fix MinGW build issue for missing isinf() in PolyLine.cpp. 2013-08-16 10:25:34 -04:00
Marco Mattila 7cbe1c0a44 Pcbnew: fix filleting of zones with parallel adjacent edges 2013-08-16 14:51:35 +03:00
Lorenzo Marcantonio 8c45f18409 - Rogue int as LAYER_MSK (will break with more than 32 layers)
- Comment fix
2013-08-15 17:20:25 +02:00
Maciej Suminski ae3c02abae Build fix. 2013-08-15 16:23:54 +02:00
Maciej Suminski 543d4af682 Added resetting of tools after loading a new board. 2013-08-15 10:20:49 +02:00
Wayne Stambaugh 19c49fa82b Eeschema bus label test bug fixes. (fixes lp:1209424)
* Use a regular expression to enforce more stringent bus label testing.
* Add validator to edit label dialog to prevent space character from being
  used in labels.
2013-08-13 19:04:41 -04:00
jean-pierre charras a723b8de7a Pcbnew: fix Bug #1211468
Pl_Editor: fix copyright in files. Enhancement when creating new items.
2013-08-13 19:51:22 +02:00
Maciej Suminski 21c3926714 Fixed win32 builds. 2013-08-10 11:14:16 +02:00
Dick Hollenbeck 3d79bf82f4 REMOVE: vias from specctra DSN export which are not in a netclass. Use only netclass based via sizes in freerouter.
Some of the vias in the class-less list were setting the drill hole size to zero and this made no sense to freerouter.
2013-08-09 14:05:04 -05:00
Dick Hollenbeck 6338f88db1 User longer, more dis-ambiguating text for Show button 2013-08-09 14:03:26 -05:00
jean-pierre charras fdfe60dd09 Replace the wxFilePickedCtrl in Option Page dialog by an usual wxButton + wxTextCtrl, because under wxWdgets 2.8.12 the look and the behavior is very different between Windows and Linux. 2013-08-09 19:36:45 +02:00
jean-pierre charras cdff2d0d41 Replace the wxFilePickedCtrl in Option Page dialog by an usual wxButton + wxTextCtrl, because under wxWdgets 2.8.12 the look and the behavior is very different between Windows and Linux. 2013-08-09 18:19:52 +02:00
Maciej Suminski eb290bf362 Added some comments. 2013-08-09 15:21:31 +02:00
Maciej Suminski 18618deea3 Added selection boxes for texts. 2013-08-09 15:04:10 +02:00
Maciej Suminski 67b64f5ec6 Added the additive mode for the selection area. 2013-08-09 10:18:48 +02:00
jean-pierre charras f394f2c57f Eeschema: fix Bug #1210120 2013-08-09 08:51:14 +02:00
Maciej Suminski 46670c7eeb Multiple items selection tool. 2013-08-08 19:42:19 +02:00
Maciej Suminski eefc79b5b2 Reformatting. 2013-08-08 19:41:20 +02:00
Dick Hollenbeck 744dd4893d EHNANCE: add a "Show" button to the two text field properties
dialogs which allow editing of component properties.  The button
is active when the table row cursor is on the DATASHEET field only.
When active, and your datasheet is a URI, then your default
browser will be launced to show that datasheet if it can find it.
This incentivizes use of http:// links for datasheets.
2013-08-08 11:12:41 -05:00
Dick Hollenbeck 7eed86de38 ENHANCE: specctra export Edge.Cuts "endpoint mismatch error message" was not showing exact coordinates with sufficient resolution 2013-08-08 11:11:50 -05:00
Dick Hollenbeck 1c04f5a03c FIX: removed unwanted indent in *.kicad_pcb files ahead of "placed" and "locked" 2013-08-08 11:09:49 -05:00
Maciej Suminski 9d9d74faad Reformatting. 2013-08-08 14:59:59 +02:00
Maciej Suminski c2342776e1 Fixed disambiguation menu issue. 2013-08-08 14:50:32 +02:00
Maciej Suminski 09aa89f3f9 Added brightened mode for selecting items using disambiguation menu. 2013-08-08 12:30:00 +02:00
Maciej Suminski a8430e09f5 Added selection box for modules. 2013-08-08 11:53:29 +02:00
Maciej Suminski 768b039cde Added general purpose overlay layer and moved selection box to it. 2013-08-08 11:43:56 +02:00
Maciej Suminski 3f1b9a6b4a Different approach to item recaching. 2013-08-07 17:20:01 +02:00
jean-pierre charras 638e29b5d6 Eeschema: fix a crash when plotting a schematic.
Pcbnew: footprint wizard dialogs: minor fixes, and fixes a not working parameters dialog under Windows, due to an incorrect Printf format.
remove scripts/packagesrc.sh, fully outdated (still refers svn repo)  and not commented.
2013-08-07 15:22:59 +02:00
jean-pierre charras 5abc48269b merge with trunk 2013-08-07 12:13:54 +02:00
Maciej Suminski c81b17c1cb Some more reformatting and adding copyright notices. 2013-08-07 11:20:12 +02:00
Maciej Suminski c928bc8ce3 Fixed layers caching settings. Added some comments. 2013-08-07 10:52:50 +02:00
Maciej Suminski f33a4975ef Simplified color computation. 2013-08-07 09:51:39 +02:00
Maciej Suminski 5920137968 Removed frame limiter. 2013-08-07 09:37:28 +02:00
Dick Hollenbeck f636e1d45f REMOVE: check for repeat_item->Flags() == 0 in eeschema/hotkeys.cpp 2013-08-06 18:23:50 -05:00
Carl Poirier 7e6a243df9 REMOVE: USE_PCBNEW_NANOMETERS by making it the only way to go in pcbnew, effectively removing the deci-mils build. 2013-08-06 18:21:40 -05:00
Dick Hollenbeck ad7ba8f029 FIX: insert key must repeat text labels 2013-08-06 17:59:07 -05:00
Maciej Suminski 3096a26b59 Added GetTarget() for GALs. 2013-08-06 14:57:48 +02:00
Maciej Suminski ff2a719bf7 Code reformatting. 2013-08-06 10:30:09 +02:00
Maciej Suminski b6c4aaac8e Moved highlighted flag from VIEW_ITEM to EDA_ITEM. Added brightened and selected flag to EDA_ITEM. 2013-08-06 09:31:08 +02:00
Dick Hollenbeck f7ad4ca025 BUG FIX: eeschema as segfaulting on the 'Insert' key because the m_itemToRepeat
was simply a pointer to an object on the display list.  At times this object
would disappear from the display list, in the test case because of a concatonation
of two wires, and if you then tried to clone the non-existent object you'd get a 
crash.  This was not merely a bug, but a naive design choice. IMO.
Now the item to repeat is cloned, so will never also be on the display list.
2013-08-05 16:02:41 -05:00
Dick Hollenbeck 4666b7fb69 formatting and fix selection clarification bug in pcbnew, could not move reference text when hidden under another footprint 2013-08-05 15:47:34 -05:00
Dick Hollenbeck 125ce48525 add Brian to about dialog, scoot Wayne up, alphabetize the rest 2013-08-05 15:45:22 -05:00
Camille Delbegue 114d12b060 Remove a Clang warning and add a missing dependency to boost in cmake file. 2013-08-05 17:53:13 +02:00
Dick Hollenbeck bf1566884c 1) Remove requirement to define KICAD_TESTING_BRANCH. Instead the KICAD_STABLE_BRANCH
must be defined if that is the build type wanted. This only affects a text string
anyways, is not particularly important other than telling user from which code
branch  the source came.  

2) Change name of "testing" to "product" in that same description within
common/build_version.cpp.  "testing" made it sound frightenly unusable.
2013-08-05 10:38:50 -05:00
Maciej Suminski fa7b6a8cec Moved VIEW_ITEM::ViewGetRequiredLayers() functionality to the VIEW class. Now required layers are set per layer basis instead of per item. 2013-08-05 16:28:58 +02:00
jean-pierre charras 9855104120 Pcbnew: footprint wizard dialogs: minor fixes, and fixes a not working parmeters dialog under Windows, due to an incorrect Printf format. 2013-08-05 15:43:15 +02:00
Maciej Suminski 36f7125513 Upstream merge. 2013-08-05 14:46:05 +02:00
Maciej Suminski 6ebd5ddc53 Fixed bounding box for TEXTE_PCB class. 2013-08-05 14:06:01 +02:00
Brian Sidebotham 2bc4103ea9 * Added modified CMake FindPython... modules to support using Python-a-mingw-us distribution when building Windows scripting support using MinGW 2013-08-04 21:31:14 +01:00
Dick Hollenbeck 01eab7dccb ReturnStringFromValue() refinements 2013-08-03 15:20:55 -05:00
Dick Hollenbeck a95dee3d09 fix interface mapping slip-up in wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const 2013-08-03 13:57:15 -05:00
jean-pierre charras 891c85a2c1 Pcbnew: add hotkey Z to reset grid origin.
Save grid origin in .kicad_pcb files only if not 0,0 (to keep compatibility with previous versions of pcbnew, mainly the stable version)
Very minor other fixes (set modify flag when grid origin is moved from the dialog grid)
2013-08-03 18:16:57 +02:00
Dick Hollenbeck 386f9b2074 split expression into two lines for verification while using debugger that GetScreen() is a virtualized call. 2013-08-03 01:36:51 -05:00
Dick Hollenbeck 325d5a6bcd *) retain grid origin in the BOARD and save it in legacy and kicad board files.
*) add hotkey for setting the grid origin as 'S', in board editor, module editor.
*) re-position the function interface for cursor movement from BASE_SCREEN into
   class EDA_DRAW_FRAME.  This is a prelude to getting rid of BASE_SCREEN or
   splitting it up.
2013-08-03 00:15:23 -05:00
Maciej Suminski f05d7f4176 Merge. 2013-08-02 19:23:35 +02:00
Maciej Suminski a8ea2e05a4 Windows build fix. 2013-08-02 19:21:22 +02:00
tomasz.wlostowski@cern.ch 8bcb88d6fd pcbnew: fixed missing Select Tool icon warning 2013-08-02 19:18:58 +02:00
unknown f9bd431d56 pcbnew: removed printf() causing a bug 2013-08-02 17:57:28 +02:00
unknown 0c6e180937 Merged Orson's changes 2013-08-02 17:28:09 +02:00
unknown 2c5fcd7d2c pcbnew: tool initialization should belong to PCB_EDIT_FRAME to avoid linking errors on cvpcb. 2013-08-02 17:25:53 +02:00
unknown 1a19c761ae pcbnew: hooked Tool Framework into the edit panel. Added a sample selection tool (not fully functional). 2013-08-02 16:53:50 +02:00
unknown 71b8823625 PCB painter: improve label highlighting 2013-08-02 16:53:04 +02:00
unknown 24cab0eabd View: various fixes, added VIEW::IsDirty() 2013-08-02 16:51:38 +02:00
unknown 3e5c236942 Added COROUTINE and DELEGATE class examples. 2013-08-02 16:50:29 +02:00
unknown a3f74b2f68 Increased number of layers in the view (for overlay objects) 2013-08-02 16:49:07 +02:00
unknown 2d09237bd7 Added core tool framework files + boost::context assembly stuff (initial, very buggy and unfinished work). 2013-08-02 16:46:53 +02:00
Maciej Suminski d26b94db61 Added missing header. 2013-08-02 16:45:30 +02:00
Maciej Suminski 017c41bc5f Upstream merge. 2013-08-02 15:57:24 +02:00
Maciej Suminski d7857dd026 Fixed the tesselator, so now it works with Windows. 2013-08-02 10:55:40 +02:00
Maciej Suminski 7ac5a172fa Modified usage of wxStandardPaths to make it compatible with newer versions of wxWidgets. 2013-08-02 10:35:58 +02:00
Maciej Suminski f44a64a705 Modified way of handling OpenGL framebuffer errors.
Now it is more verbose and the status is checked at the right moment (previously it was fine with Linux, but on Windows it showed errors).
2013-08-02 10:34:23 +02:00
jean-pierre charras 490b630e2d Minor fixes. Minor code cleaning. Pcbnew: better iniatilization of members in DRAWSEGMENT, TRACK, EDGE_MOD (not bugs: just useful when using python scripting). 2013-07-31 18:41:32 +02:00
Maciej Suminski 1265dc6334 Added drawing of solderpaste layer for pads. 2013-07-31 14:51:20 +02:00
Maciej Suminski 69f994e1b2 Added missing outline for polygon segments. 2013-07-31 13:35:02 +02:00
Maciej Suminski 0f841f194f Fixed drawing of polygon segments (eg. microwave extension traces). 2013-07-31 11:36:46 +02:00
Maciej Suminski db6aecda47 New display style for grid (dotted). 2013-07-31 10:28:23 +02:00
Maciej Suminski 83ca78a5fb Fixed grid line drawing in OpenGL backend for some drivers. 2013-07-31 09:01:25 +02:00
Maciej Suminski 2f0ae47c8e Code refactoring. 2013-07-30 18:29:54 +02:00
Maciej Suminski 11a2d81738 Made GAL backends settings more consistent. Fixed grid line width in the OpenGL backend. 2013-07-30 17:09:06 +02:00
Maciej Suminski bb4ea2db67 Merge removal of the shaderless OpenGL backend. 2013-07-30 14:05:32 +02:00
Maciej Sumiński 70a2321cc1 Fixed smudging in the Cairo backend. 2013-07-30 13:58:03 +02:00
Maciej Suminski 2331742384 Removed shaderless OpenGL backend. 2013-07-29 16:38:07 +02:00
Maciej Suminski d41ea73765 Fixed top layer pads netnames issue. 2013-07-29 14:20:40 +02:00
Maciej Suminski 5a5616f258 Added initialization of variable, preventing unconditional jumps. Fixed typos in comments. 2013-07-29 14:12:27 +02:00
jean-pierre charras bd3108a40c Minor code cleaning. Pcbnew: better iniatilization of members in DRAWSEGMENT, TRACK, EDGE_MOD (useful when using python scripting). 2013-07-29 09:33:56 +02:00
Dick Hollenbeck 8c9a12e3a1 minor tweaks to debug statements and cmake 2013-07-28 11:30:39 -05:00
Ben Harris fe45fa81fc fix FP_CACHE::Load() 2013-07-28 11:30:02 -05:00
Dick Hollenbeck 3e30600f70 add script which converts footprint libraries from one format to another 2013-07-28 11:28:17 -05:00
Dick Hollenbeck 5c05ec5b98 $ iconv -f LATIN1 -t UTF-8 pic_sockets.sch -o /tmp/pic_sockets.sch
convert to UTF-8, eeschema cannot load LATIN1 strings anymore.
2013-07-28 10:21:43 -05:00
Dick Hollenbeck 7024117709 AUTHORS.txt LATIN1 to UTF-8 via: $ iconv -f LATIN1 -t UTF-8 AUTHORS.txt > /new/AUTHORS.txt
All source files are supposed to be UTF-8 now.  Although not a source file, my editor
was tripping on this file when grepping.
2013-07-28 09:47:13 -05:00
matheiulj fd38b708fb Fix pad bounding box calculation bug. (fixes lp:1202828) 2013-07-26 17:29:16 -04:00
Wayne Stambaugh 153020283c Fix minor debug build error. 2013-07-26 16:25:21 -04:00
Maciej Suminski b41d1e0eaf Added display of soldermask for pads. 2013-07-26 18:15:11 +02:00
Maciej Suminski fcbfd00b98 Added scalar addition and subtraction operators. 2013-07-26 18:12:22 +02:00
jean-pierre charras 51edb08796 Commit missing file 2013-07-26 15:20:08 +02:00
jean-pierre charras bb087fdc45 Pl_Editor: add undo/redo commands. 2013-07-26 14:50:29 +02:00
Maciej Suminski a4a2196cc2 Fixed profiling timers for compilation under Win32 (and hopefully Mac OS too). 2013-07-26 14:35:31 +02:00
Maciej Suminski 8ab96afd5b Moved multilayer pad netnames to the top. 2013-07-26 12:15:28 +02:00
Maciej Suminski f5b230a2ef Fixed recaching after changing display properties. 2013-07-26 10:05:57 +02:00
jean-pierre charras 076defb0a5 Pl_Editor: title block texts can be multiline (use" \n" : a '\' followed by a 'n' to create a new line inside a text)
Very minor code cleaning.
2013-07-25 20:58:46 +02:00
Maciej Suminski 76660ff15b Fixed high contrast mode in OpenGL. Split display settings loading into more appropriate places. 2013-07-25 18:04:15 +02:00
Maciej Suminski 60471ecc1e Added a layer compositor for the Cairo backend. 2013-07-25 14:40:04 +02:00
jean-pierre charras 9e68ba1ea3 Very minor code cleaning 2013-07-24 20:34:28 +02:00
Baranovskiy Konstantin 414dddbf59 Add GOST page layout description files in template 2013-07-24 17:57:38 +02:00
jean-pierre charras a0c61484d2 Pl_Editor: fix a very minor issue when displaying the page size in status bar. 2013-07-24 17:19:37 +02:00
jean-pierre charras 7f6787c8b8 Pl_Editor: add some hot keys. Fix some rounding issues. 2013-07-24 17:11:35 +02:00
Maciej Suminski 8c74dcde28 Fixed blending function for OpenGL compositing. Corrected documentation, removed unnecessary functions. 2013-07-24 15:06:59 +02:00
Maciej Suminski 27332a8a17 Header containing GLSL source code is generated only after change of any of shader source files. 2013-07-24 14:22:00 +02:00
jean-pierre charras 8733da346b Pl_Editor: bug fixes (default values not saved, and duplicate item names, when adding items) 2013-07-23 18:45:23 +02:00
Maciej Suminski e644f5be05 OpenGL multitarget rendering (compositing). 2013-07-23 18:39:07 +02:00
jean-pierre charras 7007601655 Fix an issue in Debug mode 2013-07-23 12:35:58 +02:00
Camille Delbegue b1fc1cd11e Pl_Editor: Fix wx28 compatibility 2013-07-23 08:18:59 +02:00
jean-pierre charras 919edcf1e1 Bug #1202761 (Off centre zoom ) 2013-07-22 20:38:04 +02:00
jean-pierre charras d99260c614 Initial release of pl_editor, the page layout and title block editor. 2013-07-22 18:46:44 +02:00
jean-pierre charras cf9d1ba541 Fix GOST compatibility. 2013-07-22 18:45:22 +02:00
Maciej Suminski d6628419c9 Changed rendering order of cached & noncached layers. 2013-07-22 13:14:53 +02:00
Maciej Suminski 75eb5491d5 Code refactorization. VBO_CONTAINER is split to [NON]CACHED_MANAGER, GPU_MANAGER and VERTEX_MANAGER. 2013-07-22 10:41:12 +02:00
jean-pierre charras c32d8f38ed pl_editor: add config options 2013-07-21 16:15:07 +02:00
jean-pierre charras 9f22c35519 Add margin values control in pl_editor, and remove margin definition from class PAGE_INFO. 2013-07-20 21:36:19 +02:00
Thiadmer Riemersma f775500932 Eeschema: fix subtle find bug when at the end of the search list. (fixes lp 1199689) 2013-07-20 13:13:40 -04:00
jean-pierre charras fdbdb76c39 Initial release of pl_editor, the page layout and title block editor. 2013-07-19 20:27:22 +02:00
Maciej Suminski af26e17fa7 Fixed comments. 2013-07-19 09:35:25 +02:00
Maciej Sumiński 769bf51359 Headers containing shader program sources are generated using CMake. 2013-07-17 23:55:59 +02:00
Maciej Suminski c81c316a46 Refactorization of VBO_CONTAINER. 2013-07-17 18:49:38 +02:00
Maciej Suminski e5192ceddd Fixed wrong memory freeing. 2013-07-17 14:16:37 +02:00
Maciej Suminski 89ddf97fa0 Different approach to coloring netname labels. 2013-07-17 14:02:08 +02:00
Maciej Suminski 79b2eb0ff7 Display preferences for showing netnames applies to the GAL backend. 2013-07-17 13:38:56 +02:00
Maciej Suminski 0ab0c7b8ed Restored missing Refresh() on switching the high contrast mode. 2013-07-17 10:26:29 +02:00
Maciej Suminski 1d582a515c Added an interface for highlighting. 2013-07-17 10:21:46 +02:00
Maciej Suminski a4a6064316 Fixed stroked circles width issue with OpenGL shaders. 2013-07-17 10:21:29 +02:00
Maciej Suminski 910d95a7b6 Moved bottom netnames layer over bottom tracks & pads. Changed int to LAYER_NUM where applicable. 2013-07-16 15:45:21 +02:00
Maciej Suminski 3cedadd738 Fixed OpenGL tracks transparency & netnames issue. 2013-07-16 15:44:08 +02:00
Maciej Suminski 3ba2d4428b Added support for multiple active layers (colored ones in the high contrast mode).
Added separate layers for pad netnames (now these are divided into multilayer/top/bottom pads).
More appropriate layers are selecting a copper layer in the high contrast mode (now it shows the copper layer itself, vias & multilayer pads and netnames).
2013-07-16 13:40:53 +02:00
Maciej Suminski 7a545df299 Moved rendering order settings to a more appropriate place. 2013-07-16 10:49:56 +02:00
Maciej Suminski 2b3d6075e2 1 pixel wide outlines for the Cairo and the OpenGL with shaders backends, but it breaks displaying outline in the shaderless OpenGL backend. 2013-07-16 09:27:28 +02:00
Maciej Suminski 1073a524b9 Refactored code responsible for high contrast mode. Now it allows to have more than one layer on the top.
Selecting layer using the dropdown list on the toolbar influences the layer displayed in high contrast mode.
2013-07-16 09:26:29 +02:00
Maciej Suminski 6dd9cb6fb8 1 pixel wide lines using OpenGL shaders. 2013-07-16 08:49:12 +02:00
Maciej Suminski 6789755b06 Stroked lines in Cairo GAL are always drawn at least 1 pixel wide. 2013-07-16 08:48:21 +02:00
Maciej Suminski e7dae3a9c1 Fixind GLM headers problem. 2013-07-16 08:42:44 +02:00
Wayne Stambaugh 1f78a15db2 Eeschema find bug fixes. (fixes lp:1199689)
* Force search when wrap past end of list option changes state.
* Fix SCH_FIELD::Matches() for bug in user defined fields which have an ID
  of -1.
* Minor improvements to the find data names to improve source code readability.
2013-07-14 14:08:20 -04:00
Maciej Suminski 79a4f42ef9 Fixed multiline vertical strings drawing bug. 2013-07-09 10:00:23 +02:00
Dick Hollenbeck 8fdf3799a2 dialog information hiding, initial Fit() 2013-07-09 00:48:26 -05:00
Dick Hollenbeck 4b095ab61f comment improvements 2013-07-09 00:22:08 -05:00
Dick Hollenbeck 757d617ef3 wxStandardPaths().GetExecutablePath(); is not wx 2.9.5 compatible, formatting improvements 2013-07-09 00:20:07 -05:00
Dick Hollenbeck 17923c0d9e treat chars as unsigned when hashing 2013-07-09 00:18:03 -05:00
Maciej Suminski c9f9db9069 Dynamic color setting for netnames. 2013-07-08 20:42:46 +02:00
Maciej Suminski 90d03c784c Dynamic font scaling for pads netnames. 2013-07-08 20:04:43 +02:00
Maciej Suminski ea436444f2 wxWidgets 2.8 compatibility fix.
Scripting engine build fix.
2013-07-08 17:14:16 +02:00
Maciej Suminski 209bb4290f Separate layers for each copper layer netnames. 2013-07-08 16:46:04 +02:00
Maciej Suminski 7d9d2e508d Remove updating of non-cached layers. 2013-07-08 15:24:44 +02:00
Maciej Suminski 5bd8e7d4e8 Upstream merge. 2013-07-08 15:05:12 +02:00
Maciej Suminski 30f19be555 Fixed 'disappearing via' issue. 2013-07-08 14:06:45 +02:00
Maciej Suminski 3e140ddcfe Lighter pads & tracks net names color. Proper rotation of text on symmetrical pads. 2013-07-08 13:57:09 +02:00
Maciej Suminski 81143324a5 Showing net names on pads. 2013-07-08 11:30:50 +02:00
Maciej Suminski fabb646a0b Showing net names on tracks. 2013-07-08 09:57:23 +02:00
Maciej Suminski 85131e359e Added 'required layers' option for drawn items. 2013-07-08 09:28:58 +02:00
Maciej Sumiński 5a0f8019c7 Removed some more KICAD_GAL ifdefs. 2013-07-07 20:02:06 +02:00
Maciej Sumiński f067dc8b32 Added possibility to change zoom using toolbar in GAL. 2013-07-07 19:30:44 +02:00
Maciej Sumiński 14110cdea8 Removed drawing hatch lines for polygons. 2013-07-07 18:55:23 +02:00
Maciej Sumiński f885296fb2 Removed KICAD_GAL CMake option. 2013-07-07 02:30:28 +02:00
jean-pierre charras a6c5f46f2d Eeschema: fix a *very subtle* bug noticeable only in complex hierachies, for multiple parts per package:
sometimes, the modified flag was set for these components just when switching from a sheet to an other sheet.
Pcbnew: fix Bug #1197414 (dragged track segments does not show clearance area)
2013-07-05 19:48:01 +02:00
Maciej Suminski 145ea35ac3 Fixed segmentation fault when there was no board loaded. 2013-07-05 15:48:45 +02:00
Maciej Suminski 1399ed198c Removed most of deprecated OpenGL calls. Items used to be drawn in immediate mode now are drawn using vertex arrays. 2013-07-05 14:01:33 +02:00
Maciej Suminski c2fb99ce49 Removed pointers where they were not necessary. 2013-07-05 09:31:04 +02:00
Maciej Suminski 53542a9d37 Added implementation of level of details per layer and item type pairs basis (items on every layer have a possibility to define the minimum VIEW scale to be shown). 2013-07-04 18:45:00 +02:00
Maciej Suminski e77690c268 Added the 'cached' parameter for VIEW_LAYER. The parameter decides if items drawn on the layer should be cached or drawn in immediate mode.
Removed m_useGroups from VIEW, as now groups are enabled per layer.
2013-07-04 17:02:20 +02:00
Maciej Suminski d8e45ef866 Fixed drawing circles and semicircles using display lists. 2013-07-04 16:27:27 +02:00
Maciej Suminski ffc24ad518 Added functions for changing settings of used font in GAL. 2013-07-04 14:24:41 +02:00
Maciej Suminski b79c17b43c Reduced frame limit. 2013-07-04 14:21:40 +02:00
Maciej Suminski be415dab1d Moved STROKE_FONT from PAINTER to GAL. 2013-07-04 11:37:43 +02:00
Maciej Suminski d0278dad15 Shaders can handle integer parameters (uniforms). 2013-07-03 13:08:43 +02:00
jean-pierre charras 927ff2bca7 Eeschema: fix bug Bug #1197103 and an other very minor bug. 2013-07-03 09:27:52 +02:00
Maciej Suminski fc7b9029c9 Fixed stroked semicircles Z coordinate in shaderless OpenGL backend. 2013-07-02 18:11:57 +02:00
Maciej Suminski 187b529dbb Added possibility to change display modes of zones. 2013-07-02 14:02:42 +02:00
Maciej Suminski 2061947138 Fixed stroke semicircles drawing using shaderless OpenGL backend. 2013-07-02 09:27:12 +02:00
Dick Hollenbeck 04c24cb686 dsnlexer.cpp's isNumber() was recently stupid-ized, un-stupid-ize it. 2013-07-01 09:37:03 -05:00
Maciej Suminski f38935459b Headers are regenerated only if shaders' source code was modified. 2013-07-01 15:47:44 +02:00
Maciej Suminski a6ce907a4f Faster polylines drawing using OpenGL backend.
Fixed drawing of lines' caps.
2013-07-01 15:23:43 +02:00
unknown f1dbfffd82 Removed different styles of line caps and line joins, leaving only round caps & joins.
Fixed drawing stroked semicircles using OpenGL backend.
2013-07-01 14:39:27 +02:00
Maciej Suminski a46d344db2 Mirrored text display bugfix. 2013-07-01 14:06:38 +02:00
Maciej Suminski 5476a03799 Changed std::map to boost::unordered_map for storing memory chunks and groups information. 2013-07-01 13:20:48 +02:00
Dick Hollenbeck d4569d66ac DSNLEXER::NextTok() organizes the specctraMode code better, into one if block mostly.
This keeps it out of the KiCad mode path, making that leaner and less confusing about
what is supported in KiCad mode.  Within KiCad mode, treat quoted vs. non-quoted tokens
as the two general categories, with non-quoted having sub-categories.  Eliminate  
an unimplemented, unused function declaration in DSNLEXER.
 
Improve the output formatting of THROW_PARSE_ERROR().
2013-07-01 01:47:36 -05:00
Dick Hollenbeck c4ce6d9ab1 Speed up DSNLEXER::findToken() to such an extent that it resulted in an approximate 13% reduction
in *.kicad_pcb file loading times.
2013-06-30 20:05:40 -05:00
Maciej Sumiński fa083142a7 Colors are stored as unsigned bytes instead of floats. 2013-06-30 22:45:31 +02:00
Karl Thorén 8aa8451434 All: Fix bug #1196277 (pcbnew does not save all parts of the title block to the kicad_pcb file) 2013-06-30 19:40:33 +02:00
Maciej Sumiński a1f81bbe97 Shaders are built-in instead of being loaded from external files. 2013-06-30 19:31:16 +02:00
Maciej Sumiński e9669c6594 More debug information in case of failure compilation of shaders. 2013-06-30 15:37:46 +02:00
Maciej Sumiński 690e7144c1 Made shaders compatible with Intel GPUs. 2013-06-30 15:37:35 +02:00
jean-pierre charras a53b3d496c Replace in EDA_TEXT::Draw the parameter EDA_DRAW_PANEL* aPanel by EDA_RECT* aClipBox, which is the actual parameter used by Draw.
This change make more easy to  use this function when a EDA_DRAW_PANEL canvas is not used to draw texts.
Remove dead code in worksheet.cpp.
2013-06-29 11:52:22 +02:00
Wayne Stambaugh be7f436951 Prevent GTK printing build error on Linux
* Do not fail to build when wxWidgets is built with either --with-gnomeprint
  or --with-gtkprint are not configured.  Only display warning.
* Move warning code from include/common.h to common/common.cpp so it only
  shows the warning once instead of every source file that includes common.h
2013-06-28 12:29:39 -04:00
jean-pierre charras 7708753ed3 Gerbview: remove fully outdated code (about reading DCode files) and fix erroneous comments. 2013-06-28 12:49:43 +02:00
Maciej Suminski 95d5ab706a VBO_CONTAINER: Changed new[]/delete[] pairs to realloc(), possibly reducing memory fragmentation and the container shrinking time. 2013-06-28 10:47:41 +02:00
jean-pierre charras 7afb4e68f1 Pcbnew: fix bug Bug #1194219 (Solder mask clearance ignored for oval pads )
When KISYSMOD is not defined , in GetAllFiles, skip hidden directories
Gerbview: fix a collision name for GetLayout method.
Eeschema: fix potential crash when editing a pin electrical type (The user was able to enter a non existing type)
2013-06-28 08:31:24 +02:00
Dick Hollenbeck 4caad33c9a fix legacy board file footprint name setting in MODULE 2013-06-27 16:34:01 -05:00
Dick Hollenbeck 1ece12b907 remove dialog_netlist.h 2013-06-27 15:34:30 -05:00
Dick Hollenbeck 88c2f8504e WTF 2013-06-27 15:33:28 -05:00
Wayne Stambaugh 9137a9ec80 Pcbnew: fix bug reading legacy board format. (fixes lp:1195368) 2013-06-27 16:27:29 -04:00
jean-pierre charras fad35e7e00 Minor fixes. Gerbview: fix a collision name for GetLayout method. 2013-06-27 21:12:01 +02:00
Maciej Suminski 009925724e Minor code cleaning. 2013-06-27 17:31:10 +02:00
Maciej Suminski 8504f30594 Proper handling of toggling outline display of items. 2013-06-27 17:23:54 +02:00
Maciej Suminski 96116659be Faster circles & semicircles drawing for the shaderless OpenGL backend. Removed unnecessary variables and computations. 2013-06-27 16:05:15 +02:00
Maciej Suminski 1e7df3606a Groups are stored in map instead of deque, so it allows easier adding & removing. 2013-06-27 11:54:49 +02:00
Maciej Suminski 603029b106 High contrast mode with showing the selected layer on the top. 2013-06-26 16:31:52 +02:00
Maciej Suminski 4ca54b2f1d Small speed up for the color change function (OpenGL_GAL). 2013-06-26 10:43:58 +02:00
Alexander Lunev 555e24dc59 pcad2kicadpcb: check for file format 2013-06-25 11:05:51 -05:00
Dick Hollenbeck a651aaea00 Add script to make a footprint library table from the KiCad Bazaar library repository, either in s-expr or CSV format. Add also the generation of such tables as of today. 2013-06-25 10:56:12 -05:00
Maciej Suminski 258b804941 Added possibility to change cached layer color (for the purpose of high contrast display). 2013-06-25 17:12:54 +02:00
Maciej Suminski dbb4e67737 Fixed warning about a not initialized variable. 2013-06-25 16:54:30 +02:00
Maciej Suminski ec1a5d1318 Added zoom in, zoom out & fit on screen view commands handling in GAL. 2013-06-25 09:15:57 +02:00
Maciej Suminski cdab6cfdbe Draw the origin marker in OpenGL with shaders GAL. 2013-06-24 16:02:18 +02:00
Maciej Suminski 33b3d5edfb Small improvements to SHADER class. 2013-06-24 15:40:31 +02:00
Maciej Suminski e1aa6f7e84 Grid settings apply to GAL based rendering. 2013-06-24 14:33:02 +02:00
Maciej Suminski bfc1665d87 Fixed hotkeys for switching GAL backends. 2013-06-24 13:46:24 +02:00
Maciej Suminski 9e937f8113 Added convertsion from wxColour to COLOR4D. 2013-06-24 10:32:08 +02:00
Maciej Suminski d114d9e386 Passing COLOR4D parameter using constant reference. 2013-06-24 10:21:34 +02:00
Maciej Suminski 4e8d1366b6 Added conversion from EDA_COLOR_T to COLOR4D. 2013-06-24 10:12:36 +02:00
Dick Hollenbeck 8afb0255f0 add CTL_OMIT_INITIAL_COMMENTS and CTL_FOR_BOARD PCB_IO::Format()ing flags 2013-06-24 00:30:22 -05:00
Dick Hollenbeck dac6c662c5 fix copy constructor with new MODULE::m_initial_comments member handling 2013-06-23 17:41:35 -05:00
Dick Hollenbeck 577229bb6e Support for 'initial single line comments' in the pretty footprint format.
This is limited to round tripping the lines of commented text in the
loading and saving to disk through PCBIO::Format() and PCBIO::Parse().
No editing of the comments is given.
2013-06-23 14:18:33 -05:00
Maciej Suminski b5fdf4f1da Shows single layer pads with proper colors. 2013-06-21 12:02:17 +02:00
Maciej Suminski bf7d383066 Changed atan2() to VECTOR2D::Angle() 2013-06-21 09:01:40 +02:00
Alexander Lunev 6e977b668c Fix an issue with setting the Reference and Value of a module.
The bug was revealed on re-opening the saved version of a file imported by pcad2kicadpcb.
2013-06-20 15:53:23 -05:00
Maciej Suminski fdc52d933a Fixed some minor rendering issues, mostyl for shaderless OpenGL GAL. 2013-06-20 16:37:21 +02:00
Maciej Suminski 316f7309a1 Bug fixes:
- VBO_CONTAINER::allocate() was returning wrong value in case of error
- framelimiter had wrong formula for computing destined period between frames
- removed _padding field from VBO_VERTEX, as it was not speeding up, but wasting memory
2013-06-20 13:16:12 +02:00
Maciej Suminski ff75a28080 Added a framerate limiter.
Now it does not use all the CPU power while panning even on simple boards.
2013-06-20 09:58:18 +02:00
jean-pierre charras e7b5e816d0 Pcbnew: netlist dialog: add silent mode option, and tool tip to the 2 options (dry run and silent mode)
dialog_display_info_HTML_base: derived now from dialog_shim.
2013-06-19 18:11:12 +02:00
Maciej Suminski db41bc2870 Changed order of used headers, so there is no need to include again 'wx/wx.h' needed by layers_id_color_and_visibility.h 2013-06-19 12:07:25 +02:00
Maciej Suminski 585aeb7f91 Moved fields containing information about currently used color, shader and transformation for vertices from VBO_ITEM to VBO_CONTAINER (OPENGL_GAL). 2013-06-19 10:50:46 +02:00
jean-pierre charras 1b644a164e Pcbnew fix Bug #1192203 (I hope ...)
Bitmap2component: add export for .kicad_mod new footprint file format, and export polygon descr for page layout description (.kicad_wks file)
2013-06-18 19:27:47 +02:00
Maciej Suminski c4e42f46a9 Removed unnecessary functions from VBO_VERTEX. 2013-06-18 17:53:12 +02:00
Maciej Suminski bff4d1239c Removed unnecessary casting from VIEW_ITEM to EDA_ITEM. Added Type() function to VIEW_ITEM. 2013-06-18 17:01:23 +02:00
Maciej Suminski 8a89e160ed Added VBO_CONTAINER as a faster storage for vertices (OPENGL_GAL), tuned for exchanging data with GPU.
Removed a few unnecessary variables and fields from OPENGL_GAL.
Added function GAL::ClearCache() for freeing memory used by cached items.
Fixed a few memory leaks (tesselator, PAINTER's settings & VIEW_ITEM's groups).
Changed a few functions into inlines.
2013-06-18 16:20:29 +02:00
Maciej Suminski 198052358e Added GAL_TYPE_NONE as an indicator of GAL uninitialized state. 2013-06-18 16:19:30 +02:00
jean-pierre charras 6730b7d656 Eeschema: Fix wx28 compatibility issue. 2013-06-17 21:01:47 +02:00
jean-pierre charras f917efd430 Eeschema: Add dialog and utilities (help files ...) to create BOMs from generic netlist, using python scripts or xsltproc+style sheet.
Remove dead code relative to old BOM generation.
Rename witha  more explicit name bom-example?.py , fix some issues and move them from script/bom-in-python/ky to script/bom-in-python
Rename ki.py utility to more explicit  ky_generic_netlist_reader.py
2013-06-15 20:02:52 +02:00
Wayne Stambaugh 7d51fc7dfb Pcbnew netlist read performance improvements.
* Do not search for footprint when no footprint is defined for a component
  in the netlist.
2013-06-15 12:55:51 -04:00
jean-pierre charras b192495bbc Eeschema: add dialog and utilities to create BOMs from generic netlist 2013-06-14 16:59:52 +02:00
Dick Hollenbeck 34a697fc37 fix error message in legacy_plugin 2013-06-13 11:17:25 -05:00
Dick Hollenbeck 2dda514cb0 better error reporting and parsing of bad legacy footprint libs 2013-06-13 11:09:35 -05:00
Dick Hollenbeck 82d667e30c various 2013-06-13 06:43:29 -05:00
Alexander Lunev 29b0b9cfcd Fix pcad2kicad issue, from A. Lunev, and a minor code cleaning in component_references_lister.cpp. 2013-06-12 21:43:22 +02:00
jean-pierre charras ed7f92ebc7 Eeschema: fix Bug #1189893 (ps plot file opened twice) 2013-06-11 16:27:07 +02:00
jean-pierre charras 93ae8f4066 Fix issue in auto panning while moving in EDA_DRAW_PANEL::OnMouseLeaving() 2013-06-10 15:23:58 +02:00
Dick Hollenbeck 6b030ac9be Rename invoke_a_dialog.h. Code an alternate implementation for std::string BOARD_ITEM::FormatInternalUnits( int aValue ), for verification. 2013-06-10 07:24:01 -05:00
Dick Hollenbeck 8470c44bb0 fix autopan non-response problem when dragging block to right or bottom 2013-06-09 13:14:01 -05:00
jean-pierre charras 4c75540ca2 Remove a useless message shown only in debug mode, about page layout file not found 2013-06-09 18:50:57 +02:00
jean-pierre charras 70f43b0003 Cvpcb: Bug fix: Select previous free component crashes Cvpcb when no previous free component found, and both Select next and previous free component where not working very well. 2013-06-09 18:36:54 +02:00
jean-pierre charras 91452f3b58 Custom page layout: add support for poly-polygons (useful for logos) 2013-06-08 20:19:09 +02:00
Wayne Stambaugh daeb396fd8 CvPcb focus and status bar improvements.
* Fixed status bar update bug that caused the selected footprint information
  to be overwritten.
* Remove unnecessary SetFocus() calls in list control OnChar() handlers.
2013-06-08 12:06:26 -04:00
Dick Hollenbeck ad649d9670 *) Introduce "invoke_a_dialog.h" to information hide between top frame
and various DIALOG classes called from top frames.  See comments in
   {eeschema,pcbnew}/invoke_a_dialog.h.
*) Move some dialog classes into *.cpp files from *.h files.
*) void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) was opening the modeless
   ERC dialog more than once if icon was clicked more than once.
*) Remove BOM stuff.
2013-06-07 15:56:55 -05:00
jean-pierre charras 0038722d0f Fix compil issue on wxWidgets 2.8.12, created by my last commit. 2013-06-07 19:35:09 +02:00
jean-pierre charras 6a00664b2a Plot files : fix Bug #1188664 (full filename instead of short file name, and swapping between sheet path and file name) 2013-06-07 18:37:44 +02:00
Wayne Stambaugh 2956543d27 CvPcb pin count filtering improvement. (fixes lp:1188325)
* Add option to MODULE::GetPadCount() to exclude non-plated through holes.
2013-06-07 09:17:52 -04:00
Wayne Stambaugh 0fcf722af4 Fix CvPcb library filtering bug. (fixes lp:1188321) 2013-06-07 08:15:32 -04:00
jean-pierre charras ceebdbfdd3 Mainly for testing purposes: page layout: if the environment variable KICAD_WKSFILE points a S expr page layout descr, this descr is used instead of internal descr.
Therefore one can use a custom page layout and title block.
Eeschema, dialog edit component: minor enhancement (the last selected notebook page is remembered during a session)
2013-06-07 13:09:18 +02:00
jean-pierre charras 1b05af7f8e page layout: if the environment variable KICAD_WKSFILE points a S expr page layout descr, this descr is used instead of internal descr. Mainly for testing purposes.
Eeschema, dialog edit component: minor enhancement (the last selected notebook page is remembered during a session)
2013-06-07 11:49:36 +02:00
jean-pierre charras 123b7b5537 Page layout: add comments, and fix a very minor issue.
Eeschema, dialog netlist: fix a bug when removing a plugin panel, when is is not the last.
dialog netlist:Add a predefined command string for python scripts, when creating a new netlist plugin entry.
2013-06-06 20:03:29 +02:00
Wayne Stambaugh 5fa1257e2c CvPcb filtering and other minor improvements.
* Change filtering from single selection to logically and each filter type.
* Remove clear filtering button and logic.
* Filter buttons now behave as true toggle buttons.
* Improve list control pane focus following when using arrow keys to change
  list pane.
* Remove unused parameters from list box constructors.
* Make tab key behave like right arrow key when moving focus to next list
  pane.
* Make list pane focus wrap around to next or previous control.
* Simplify component list filtering code.
* Improve status bar updating.
* Tell Bazaar to ignore .downloads-by-cmake instead of downloads-by-cmake.
2013-06-06 11:37:48 -04:00
Maciej Suminski 5c405a6f40 Removed some debug messages. 2013-06-06 11:54:37 +02:00
Maciej Suminski 03b5d6125b Removed indices storing from VBO_ITEM as they are always consecutive numbers. Removed storing pointers to VBO_ITEMs that have to be drawn - instead they are memcpied to mapped GPU memory.
Some functions of VBO_ITEM became inline.
2013-06-06 11:52:39 +02:00
Dick Hollenbeck 2376811df8 fix libeditframe.cpp, which in release build would not show multipart text in listbox. dialog uses DIALOG_SHIM. 2013-06-05 14:23:55 -05:00
jean-pierre charras c48997608d Fix a minor issue in page layout default descr. 2013-06-05 17:32:24 +02:00
Dick Hollenbeck 8a5285db41 downloads-by-cmake now configurable, fix wx2.8 compiler errors 2013-06-05 09:24:03 -05:00
jean-pierre charras c4d6fc943a Add info and comments about page layout description using S expressions 2013-06-05 15:21:14 +02:00
jean-pierre charras 3655df08ea All: use a S expression to describe the page layout (title block and grid references). Work in progress.
This should  allow users to define their own page layout.
2013-06-05 14:03:16 +02:00
Maciej Suminski 7858e6aa7c Changed data structure in VBO_ITEM. 2013-06-05 10:48:30 +02:00
Maciej Suminski c909988aa5 Upstream merge. 2013-06-05 10:01:53 +02:00
Dick Hollenbeck 5deaba9669 Fix wierd ConfigBaseWriteDouble's Printf( wxT("%12f"), aValue ); format string
which was creating silly strings like 

  PcbTextThickness="    0.300000"

in kicad.pro files.
2013-06-04 09:44:21 -05:00
Dick Hollenbeck f162b6662b comment 2013-06-04 09:44:08 -05:00
Maciej Suminski 2d5f342ee8 Switching to OpenGL using shaders backend on the fly (changed keyboard shortcuts: different backends are available using Alt+F9..F12). 2013-06-04 16:18:33 +02:00
Maciej Suminski 85a2aee79c Introducing shaders.
Shader's parameters are stored in VBO_ITEM. Changed VBO_ITEM data structure. Added UseShader() function for selecting shader for a given VBO_ITEM.
Added one main vertex & fragment shader program to be used for with all kinds of items (type of shader is selected using attributes that are stored in VBO). Currently available shaders are: at-least-1px-width line, filled circle and stroked circle.
Removed unnecessary param (aDepthOffset) from a few functions (OPENGL_GAL::drawSemiCircle(), OPENGL_GAL::drawLineCap()). Removed function OPENGL_GAL::DrawRoundedSegment(). Changed some asserts to debug info or error log.
2013-06-04 15:58:53 +02:00
Dick Hollenbeck a4cc671c22 speedups 2013-06-03 08:09:37 -05:00
Maciej Suminski 2912138ef2 Display linking errors in debug mode for shaders. Added SHADER::GetAttribute() function for getting shaders attribute location. 2013-06-03 10:54:24 +02:00
Dick Hollenbeck cdae489afa include only the boost headers in the scratch repo 2013-05-31 23:04:56 -05:00
Dick Hollenbeck 51ad0c18ff *) Refinements to ExternalProject_Add( boost )
*) Enhancements to make_lexer().
*) Support multi-threaded build.
*) Switch to "bzr patch" from patch.exe for Windows users.
2013-05-31 16:36:40 -05:00
Dick Hollenbeck 998255fb1b add copyright message to download_boost.cmake 2013-05-31 16:26:08 -05:00
Dick Hollenbeck edfb5811cf *) Refinements to ExternalProject_Add( boost )
*) Enhancements to make_lexer().
*) Support multi-threaded build.
*) Switch to "bzr patch" from patch.exe for Windows users.
2013-05-31 16:22:34 -05:00
Michal Jahelka c733b32672 Add filtering footprint list by library to CvPcb
* Add third list control with library names.
* Add button to toolbar to select filter by library name.
* Add bitmap for filter by library name toolbar button.
* Remove custom UI colors from list controls.
2013-05-31 13:33:46 -04:00
Dick Hollenbeck 38862c1a09 add support for exponents in dsnlexer.cpp's DSN_NUMBER token 2013-05-31 09:24:56 -05:00
Dick Hollenbeck 03161c81df remove boost and make it an external project, so the procedure for upgrading is better documented 2013-05-30 23:46:02 -05:00
Dick Hollenbeck 264c73747a factor out isNumber() in dsnlexer.cpp, add support for numbers with exponents, leave commented out for further testing 2013-05-30 20:20:37 -05:00
Dick Hollenbeck 5e53e410ce factor out isNumber() in dsnlexer.cpp, add support for numbers with exponents, leave commented out for further testing 2013-05-30 19:49:22 -05:00
Dick Hollenbeck b42ec57f6f fix buggy double2str() 2013-05-30 16:46:14 -05:00
jean-pierre charras 4d0f664f50 Pcbnew: Fix Bug #1185556. fix issue about Solder Paste Ratio value which was accepting only one digit in mantissa in 3 dialogs (now 6 digits in all dialogs).
fix potential issue in .kicad_pcb file creation, in some places where a %g or %.16g format was used:
al least under Mingw/gcc4.7.2, the floating number was written using scientific notation, not accepted by the S-expr reader.
2013-05-30 21:32:00 +02:00
jean-pierre charras 2ea3b8b068 Kicad template selector dialog: add an info line showing the template path in use. Fix very minor bug #1185462 2013-05-29 20:37:22 +02:00
jean-pierre charras 0810492a2c Fix issue created by the template selector change, on Linux. 2013-05-29 20:00:40 +02:00
jean-pierre charras c5178979ce Kicad template selector dialog: add info line showing the template path in use. 2013-05-29 14:03:03 +02:00
Wayne Stambaugh 08bdaf07be More Pcbnew footprint library table work in progress.
* Add footprint library table loading to footprint editor.
* Overload FOOTPRINT_INFO::ReadFootprintFiles() to read footprints from the
  footprint library tables.
* Fix a bug in FP_LIB_TABLE::IsEmpty() when the table has a fallback table.
* Add code to FOOTPRINT_EDIT_FRAME to use footprint library tables.
* Add an optional build time version of PCB_EDIT_FRAME::loadFootprints() to
  populate netlist footprints from footprint library table.
* Remove adding footprints to board whenever GetModuleLibrary() is called and
  move loading locally as required.
* Add missing source file license comments and coding policy fixes.
2013-05-28 12:54:59 -04:00
jean-pierre charras 832764aa3a Dialog page setting: replace wxStaticBoxSizer by wxBoxSizer + static text,
because under Linux and wxWidgets 2.9, wxStaticBoxSizer are very ugly (text not readable in this dialog)
(Does not happen with wxWidgets 2.8)
Eeschema hotkeys: remove duplicate keys in key editor.
2013-05-28 11:49:53 +02:00
jean-pierre charras 43c87d0cb6 eeschema: fix Bug #1184318 (Eeschema-Libedit: Reference moving+zooming issue)
and fix a minor issue in netlist dialog.
2013-05-28 10:05:10 +02:00
jean-pierre charras 6a6b944c00 eeschema: netlist dialog: fix a very minor issue. 2013-05-27 15:59:10 +02:00
jean-pierre charras 90eb83dcb2 Pcbnew: fix bug Bug #1184362 (Pcbnew losing user (custom) sheet size )
Fix minor issues in print/plot: filename not printed, sheetname incorrect in eeschema
2013-05-27 11:17:37 +02:00
Maciej Suminski 31b722f9d3 Added tesselation of polygons for VBO based rendering (OpenGL GAL). 2013-05-27 09:37:49 +02:00
Dick Hollenbeck e3351a9686 1) Add "rules" to base of tree for copying into BZR_HOME/rules.
File "rules" has instructional text as comments near top.

2) Convert all text files in repo to LF line ending form.
   Any checkout done with "rules" in play will convert the working
   tree to native line ending, while keeping repo as LF line ending.
2013-05-25 23:36:44 -05:00
jean-pierre charras 19dea9095e Pcbnew! fix Bug #1184030
very minor other chnages.
2013-05-25 18:10:19 +02:00
jean-pierre charras 3b023da602 Cvpcb fix bug #1183796 and fix bug when a fp lib is not found : the name of the missing file was not displayed in message window. 2013-05-25 17:02:16 +02:00
jean-pierre charras 33d0a72fce Netlist reader: fix issue when reading an ORCADPCB2 netlist (which fixes also bug 1184023) and fix a Cvpcb crash when trying to read an unknown netlist format. 2013-05-25 12:41:24 +02:00
jean-pierre charras 5136fc535f 3D viewer: fix Bug #1183581 (pcbnew 3D viewer: recent UI inconsistency )
Pcbnew: fix bug in drag module: connected tracks were not dragged.
worksheet: code cleaning.
2013-05-25 11:01:44 +02:00
Dick Hollenbeck 16a21ade8f remove "~" from empty *.lib component fields, replace with "", doctor old *.lib fields to blank if that was the intention 2013-05-24 18:58:29 -05:00
Dick Hollenbeck ec2b2dc291 copyright and formatting 2013-05-24 16:30:27 -05:00
jean-pierre charras 2703a5aebd Fix bug #1183802 : incorrect sheet Id (company name displayed instead of Id) 2013-05-24 16:06:58 +02:00
jean-pierre charras 4bdd21b281 More about worksheet code. 2013-05-24 10:59:40 +02:00
Lorenzo Marcantonio 499d41206e Make title block date field modifiable by hand. 2013-05-23 14:45:23 -04:00
jean-pierre charras ece008e790 Worksheet code: more cleanup, and fix compil issue with wxWidgets 2.8 2013-05-23 18:38:17 +02:00
Dick Hollenbeck d1cfa88bc0 fix license text in COPYRIGHT.txt, remove duplicate Documentation/copyright.txt 2013-05-23 08:43:42 -05:00
jean-pierre charras 0e28b55184 worksheet code cleaning and fix plot sheet filenames bug (mainly under Linux) (Bug #1182891 ) 2013-05-22 17:43:22 +02:00
jean-pierre charras afccbbe04d worksheetcode cleaning and fix plot sheet filename bug under Linux. 2013-05-22 17:08:57 +02:00
jean-pierre charras a4cec09781 Worksheet code: cleanup and remove useless parameters. 2013-05-22 10:45:25 +02:00
jean-pierre charras 54d70ec738 Remove duplicate code to draw and to plot title blocks (more than 1500 duplicate lines). Note: this is a work in progress.
Code cleanup
2013-05-21 09:44:46 +02:00
jean-pierre charras 39c3a38e2d Remove duplicate code to draw and to plot title blocks. 2013-05-21 09:18:25 +02:00
Wayne Stambaugh 699897ddf8 Pcbnew footprint library table work in progress.
* Add code for loading, modifying, and saving the global and project
  footprint library tables.
* Add code to load MODULE objects using the footprint library table to
  the footprint viewer.
* Add static methods to FP_LIB_TABLE to support loading footprint library
  tables.
2013-05-20 10:49:20 -04:00
jean-pierre charras 00d3af4816 Code cleaning and move worksheet code specific to title block and frame references shape in title_block_shapes.h and title_block_shapes_gost.h 2013-05-19 21:35:49 +02:00
jean-pierre charras ceadbbcdc1 Gerbview: fix bug #1176538 (incorrect flashed items size, when defined by aperture macros) 2013-05-18 18:56:03 +02:00
jean-pierre charras e703b53b3a Eeschema: fix Bug #1180902 (Libedit creates empty svg images) 2013-05-18 11:38:23 +02:00
jean-pierre charras f037cc3c74 3D viewer: Add more options, to show/hide technical layers. 2013-05-16 21:04:21 +02:00
Maciej Suminski 7dec942ef7 Different way of rendering groups (with a single DrawElements call) in OpenGL GAL. 2013-05-16 18:43:25 +02:00
Maciej Suminski 1d0ca22572 Different way of measuring render time. 2013-05-16 17:17:35 +02:00
Dick Hollenbeck a6decc3cc7 compiler warning from mailing list 2013-05-16 09:40:46 -05:00
Maciej Suminski b58cc107e6 Changed functions for adding vertices in VBO mode to make code easier to read and understand. 2013-05-16 14:47:34 +02:00
Maciej Suminski a593306a06 Fixed time measuring functions (only for profiling in debug) 2013-05-16 13:46:00 +02:00
Maciej Suminski 0177590699 Faster way of caching items for OPENGL GAL. 2013-05-16 10:35:16 +02:00
Maciej Suminski 787fe28fd0 Added functionality for transformation of VBO vertices, extended functions like translate, rotate, scale using glm library. Removed D() macro, as it was not used, but in conflict with glm library. Added VBO_ITEMs for circles, semicircles. Now almost everything is drawn using VBO (besides polygons and grid). 2013-05-15 16:48:10 +02:00
Maciej Suminski 541568e09f Layer depth is set during items caching (so now they are rendered on proper layers). 2013-05-15 16:47:17 +02:00
Maciej Suminski 5dd7ef6895 Assured that there are no excessive initializations 2013-05-15 16:47:01 +02:00
Dick Hollenbeck 153df79699 replace BOM dialog with a pointer to FAQ https://answers.launchpad.net/kicad/+faq/2265 2013-05-15 05:32:41 -05:00
Maciej Suminski 4ad9af71f5 All kind of items are loaded on SetBoard() again. 2013-05-15 09:17:48 +02:00
Maciej Suminski d76671a601 Items are not recached until GAL is changed (earlier it was done on every rendering backend switch). 2013-05-15 09:17:42 +02:00
Maciej Suminski ea094a4fbc Added some debug informations. 2013-05-15 09:17:36 +02:00
jean-pierre charras cb11dad4de Pcbnew: fix bug 1179877, due a bad default copy constructor, after my changes about CPOLYGONS_LIST class.
More about CPOLYGONS_LIST work.
2013-05-14 20:47:01 +02:00
Maciej Suminski 817cf192c8 Fixed build for eeschema. 2013-05-14 10:46:43 +02:00
Maciej Suminski aec00ab96f Removed double freeing of some of Cairo paths. 2013-05-14 10:42:56 +02:00
Maciej Suminski 48b288cdc2 Modified SetOffset (VBO_ITEM/OpenGL GAL) function. 2013-05-14 10:41:05 +02:00
Maciej Suminski 66d257f620 Drawing tracks using PushVertices, added some comments, fixed formatting. 2013-05-14 10:38:25 +02:00
Dick Hollenbeck dd14218c34 remove non-UTF8 encoded characters from source tree & format fix 2013-05-13 12:30:27 -05:00
Maciej Suminski 918231795b Added possibility of adding multiple vertices to VBO_ITEM at once 2013-05-13 11:14:35 +02:00
Maciej Suminski 9f71172437 Fixed Cairo issues and some possible memory leaks 2013-05-13 10:55:35 +02:00
Wayne Stambaugh 69e3b23960 Decouple PLOT_CONTROLLER from UI dependencies. 2013-05-10 15:22:29 -04:00
Maciej Suminski 7b426e8103 Fixed memleak, removed excessive recaching, still there is a problem with Cairo caching 2013-05-10 16:05:40 +02:00
Wayne Stambaugh 27e1043fc4 Fix footprint library search path bug. (fixes lp:1178427 2013-05-09 21:51:55 -04:00
jean-pierre charras 76518712c4 More work on CPOLYGONS_LIST class.
Pcbnew: fix minor bug about  plot line width.
2013-05-09 21:08:12 +02:00
Wayne Stambaugh 64843d6b0a Footprint library table work, minor fixes, and code cleaning.
* Fix a bug when full file name and path are passed to FOOTPRINT_INFO::
  ReadFootprintFiles() which I created in bug fix lp:593989.
* Fix a wxString debug assertion in EDA_APP::InitEDA_Appl() when the KICAD
  environment variable is defined as an empty string.
* Add error dialog when libraries cannot be found in system search path
  when loading footprint using the select footprint dialog.
* Add footprint library name column to the EDA_LIST_DIALOG when selecting
  footprints from the list.
* Allow reading all columns from the selected row in EDA_LIST_DIALOG.
* Remove redundant sort from EDA_LIST_DIALOG constructor
* Add library name member variable and accessors to FOOTPRINT_INFO.
* Make headers translatable for Eeschema select component from list dialog.
* Add some helper methods to FPID for identifying the FPID type and validity.
* Remove a bunch of trailing whitespace and add missing license comments.
2013-05-08 16:47:23 -04:00
jean-pierre charras 87fa661591 More work on CPOLYGONS_LIST class. 2013-05-08 20:20:58 +02:00
jean-pierre charras 2ec6d22131 Eechema: fix bug : when saving the schematic project, the lib cache was saved under the current sheet opened, not the root sheet.
Pcbnew: clamp default plot line width between 0.02 and 2 mm. the other bug (saving this parameter in internal units instead of mm is not fixed)
2013-05-07 20:32:06 +02:00
Lorenzo Marcantonio f6ac92dc39 Removed some spurious float casts
(explanation: float is implicitly promoted to double anyway, it's only useful
for storage; also a fp variable forces conversion of other int in the expression
without needing a cast)
Typo fixes in some comments 'floatting' -> 'floating' :D
2013-05-07 19:31:52 +02:00
Wayne Stambaugh be69f7ad20 Fix bug when footprint library file names contain dots. (fixes lp:593989) 2013-05-06 13:57:18 -04:00
Lorenzo Marcantonio 9a7cc494f7 Closes bug 1176915
Mass parameters in gerbers can't use scientific notation (altough some software 
allow it), so the %g format was not correct.
2013-05-06 19:47:01 +02:00
jean-pierre charras 8c3d4d4eda Eeschema: fix incorrect move command for bitmap items. 2013-05-06 15:38:14 +02:00
Lorenzo Marcantonio 636ca7a74b Removed Show code from BOARD_ITEM derived classes (as requested by Dick) 2013-05-05 12:23:18 +02:00
Lorenzo Marcantonio c57c1e94d1 Fixed LAYER_NUM usage in the specctra code.
A specctra layer is not a LAYER_NUM, so that's probably why it was difficult to use.
2013-05-05 12:11:30 +02:00
Lorenzo Marcantonio 1e1c2cbb7d Migrated the interfaces accepting angles to the double type
The plan goes like this:
- eeschema still uses int in decidegrees
- all the other things internally use double in decidegrees (or radians
  in temporaries)
- in pcbnew UI the unit is *still* int in decidegrees

The idea is to have better precision everywhere while keeping the user with int i
angles. Hopefully, if a fractional angle doesn't come in from the outside, everything
should *look* like an integer angle (unless I forgot something and it broke)

When the time comes, simply updating the UI for allowing doubles from the user should
be enough to get arbitrary angles in pcbnew.
2013-05-05 09:17:48 +02:00
Lorenzo Marcantonio 5399b6f438 More int casts to rounding conversions 2013-05-04 13:57:09 +02:00
jean-pierre charras 41b6c8434a All: use CPOLYGONS_LIST, a typedef of std::vector<CPolyPt> to handle a Corners Polygons List.
This is a starting point of some code enhancements relative to polygons in Pcbew and 3D viewer.
2013-05-03 19:51:10 +02:00
Felix Morgner 3031b9e6a5 Fixes implementation of MacOpenFile( const wxString& ) in KiCad.
Adds "kicad_pcb" to the list of file-extensions for PCBnew in its Info.plist 
to make Launch Services recognize the file associations.

Change 8 bit string to UTF8 so fancy mew in "um" can be shown.
2013-05-02 23:04:30 -05:00
Lorenzo Marcantonio 0d5331df59 Fixed bad computation in eeschema/transform (my fault)
Note: ArcTangente gives a double but *takes* ints, so it's not good to
use for nontrivial things
2013-05-02 22:53:12 +02:00
jean-pierre charras bca75d4930 Fix compil issue in Debug mode. 2013-05-02 20:42:08 +02:00
Lorenzo Marcantonio a70965eb6d Moved utilities for angles in trigo.h
New conversion routines and sin/cos implementation for angles in decidegrees
2013-05-02 20:06:58 +02:00
Dick Hollenbeck ad21bfda4d fix compiler warnings 2013-05-02 09:12:55 -05:00
jean-pierre charras fef46ffacf 3D viewer: Modify the way board items shapes are built:
* All items shapes are converted to polygons.
* Polygons are merged layer by layer (for calculation time reasons,zones are not merged)
* for copper layers, vias and pads holes are substracted from polygons (but, for calculation time reasons, not inside zones areas).
* the look is better, mainly when displaying the copper thickness
* solder and paste layers are now shown in 3D viewer.
* the code was seriously cleaned (but still needs to be enhanced).
* Note this is a work in progress which needs refinements.
2013-05-02 07:56:22 +02:00
jean-pierre charras f803745fc6 3D viewer: Modify yhe way board items shapes are built:
* All items shapes  are converted to polygons.
* Polygons are merged layer by layer (for calculation time reasons,zones are not merged)
* for copper layers, vias and pads holes are substracted from polygons (but, for calculation time reasons,  not inside zones areas).
* the look is better, mainly when displaying the copper thickness
* solder and paste layers are now shown in 3D viewer.
* the code was seriously cleaned (but still needs to be enhanced).
* Note this is a work in progress which needs refinements.
2013-05-01 21:01:14 +02:00
Lorenzo Marcantonio c36ab1c6ed Angle and distances cleanup (preparing for angles in doubles)
- Removed spurious int casts (these are truncated anyway and will break
  doubles)

- Applied the Distance, GetLineLength, EuclideanNorm, DEG2RAD, RAD2DEG
  ArcTangente and NORMALIZE* functions where possible

- ArcTangente now returns double and handles the 0,0 case like atan2, so
  it's no longer necessary to check for it before calling

- Small functions in trigo moved as inline
2013-05-01 19:32:36 +02:00
Dick Hollenbeck 28f9d7f28f remove temporary debug printf()s I no longer need. 2013-05-01 10:49:34 -05:00
Dick Hollenbeck 5b225186c4 fix 2 corner case bugs in specctra import 2013-05-01 10:48:00 -05:00
Dick Hollenbeck 09bb2a6054 pass round boards to freerouter via specctra_export 2013-05-01 08:36:26 -05:00
Dick Hollenbeck e1ea1237b7 fix goofy text messages, period after newline 2013-04-30 14:51:33 -05:00
Maciej Suminski fb65f5d1ae Improved recaching (all items when a board is loaded), still needs some fixing (mem leak). 2013-04-30 17:55:24 +02:00
Dick Hollenbeck ff439ecd7f wxString::Format() fix 2013-04-30 10:52:18 -05:00
Dr. Thomas Spindler 4cc4df87ff specctra_export supports interior polygons and circles on the Edge.Cuts layer.
Interior regions on Edge.Cuts are out as keepouts for specctra DSN file
and downstream routers.  Point to point matching during polygon assembly
can have individual thresholds, one for board edge and another for interior polygons.
This is more forgiving for sloppy graphical mousers, or those that work without
grid snap on.  Currently the threshold for board edge is at zero, meaning the
board edge has to be precisely defined as a polygon, just as before.  But it
is easily tunable for experimentation.
2013-04-30 10:25:41 -05:00
Maciej Suminski 56aabe20bc Introduction of VBO. Now only tracks are rendered in a very simple way. 2013-04-30 15:59:32 +02:00
Lorenzo Marcantonio 4b624381e0 Added include guard to math_for_graphics.h 2013-04-30 15:27:08 +02:00
Wayne Stambaugh c5508f34b3 Pcbnew bug and warning fixes.
* Fixed a bug in PCB_EDIT_FRAME::loadFootprints when no footprint libraries
  are found when attempting to load footprints.
* Add a warning to PCB_EDIT_FRAME::loadFootprints to inform the user when
  a footprint library file cannot be found in any of the standard library
  search paths.
* Changed FOOTPRINT_INFO::m_padCount to unsigned to prevent signed/unsigned
  comparison compiler warnings.
* Put NestedSpace() function in netlist_reader.cpp inside conditional debug
  build statement to prevent warning in release builds.
2013-04-29 17:00:24 -04:00
Felix Morgner 3c667d7652 merge with upstream 2013-04-29 12:56:12 -04:00
Felix Morgner 4664427784 * Set "Ctrl+Shift+S" as shortcut for "Save as..." in CvPcb and PCBnew.
This seems to me like the defacto standard for this menu command.
* Added a default filename for save as. Currently it's set to
  "Unnamed file" using _() so its translatable.
* Changed the save dialog in PCBnew to use the path of the "original"
  file as a base for the new file.
2013-04-29 12:50:10 -04:00
Dick Hollenbeck c747ffef95 fix compiler warnings, comments, debug crash, and conceptual issues in specctra 2013-04-29 11:35:07 -05:00
Felix Morgner b5b1777304 merge with upstream 2013-04-28 18:47:58 -04:00
Wayne Stambaugh 228004b472 More post Pcbnew NETLIST_READER change clean up.
* Fix both legacy and s-expression netlist readers when footprints are
  assigned in the netlist.
* Add some helper functions to NETLIST for detecting when footprints are set
  or not set and when they have been changed while loading the .cmp file.
* Rename a few functions to improve their readability.
2013-04-28 16:20:40 -04:00
Lorenzo Marcantonio a1f91c08ad Converted macros to inline template function 2013-04-28 17:43:26 +02:00
Lorenzo Marcantonio 96dc27d9e6 Removed the SAFE_DELETE macro.
In most case the assignment to null was not necessary since it was easily provable that the (local) variable wouldn't have referenced after that anyway.
2013-04-28 16:28:13 +02:00
Lorenzo Marcantonio 11f9f15199 Message fix: SMD is an acronym, should be upper case 2013-04-28 15:34:59 +02:00
jean-pierre charras 991a92429e Pcbbnew: fix bug Bug #1172892 (bad drill map file names, when a point is used inside a board file name) 2013-04-28 11:10:54 +02:00
Felix Morgner 4f17dc0716 merge with upstream 2013-04-27 17:58:38 -04:00
Dick Hollenbeck 37c7fa9fb4 Fix SVG plot with filename containing & character. 2013-04-26 21:12:57 -05:00
Felix Morgner fd2f700390 merge with upstream 2013-04-26 11:24:44 -04:00
Wayne Stambaugh 97255b2b7f Post Pcbnew NETLIST_READER change clean up.
* Tweak the NETLIST_READER code to allow for component footprint names that
  are not found in any library to generate a warning instead of an error and
  update the board accordingly.
* Don't display undo warning in netlist dialog when dry run option selected.
* Rename netlist_reader_common.cpp to netlist_reader.cpp
* Rename netlist_reader_firstformat.cpp to legacy_netlist_reader.cpp
* Rename netlist_reader_kicad.cpp to kicad_netlist_reader.cpp
* Remove cvpcb/read_write_cmpfile.cpp and move the single function it
  contained into cvframe.cpp
* Remove cvpcb/loadcmp.cpp and move the single function it contained into
  class_DisplayFootprintsFrame.cpp.
* Remove cvpcb/readschematicnetlist.cpp and move the single function it
  contained into cvframe.cpp.
* Remove cvpcb/setvisu.cpp and move the few functions it contained into
  the appropriate source file.
2013-04-26 11:11:52 -04:00
Felix Morgner 8d32141b8f resaved some files as UTF-8 to silence clangs warnings about illegal character encodings. 2013-04-25 18:31:14 -04:00
Felix Morgner 7700779e2c made changes compliant to style guide. 2013-04-25 13:27:43 -04:00
Felix Morgner 1cc9d2ce5a merge with upstream 2013-04-25 13:22:52 -04:00
Maciej Suminski b9980df1b7 Upstream merge. 2013-04-25 18:42:27 +02:00
Maciej Suminski af8b256a00 Changed non-shader primitives to GL_TRIANGLES. 2013-04-25 18:30:53 +02:00
Wayne Stambaugh 324c39931c Pcbnew NETLIST_READER improvements.
* Create separate NETLIST object to hold contents of netlist files.
* Read entire netlist and footprint link files before making applying
  changes to board.
* Add BOARD::ReplaceNetlist() function to eliminate the calls between the
  NETLIST_READER, PCB_EDIT_FRAME, and BOARD objects.
* Change placement of new components below the center of the current board
  or in the center of the page if the BOARD is empty.
* Add dry run option to netlist dialog to print changes to message control
  without making changes.
* Add button to netlist dialog to allow saving contents of message control
  to a file.
* Eliminate the need to compile netlist_reader_*.cpp in both CvPcb and Pcbnew.
* Add netlist_reader_*.cpp to the pcbcommon library.
* Remove redundant load component link file code from CvPcb.
* Modify CvPcb new to work with the new NETLIST_READER object.
* Add compare() function and < and == operators to FPID object.
* Add REPORTER class to hide an underlying string writing implementation for
  use in low level objects.  Thank you Dick for the idea.
* Lots of minor coding policy, Doxygen comment, and missing license fixes.
2013-04-25 12:29:35 -04:00
Dick Hollenbeck 113325673f pcb_parser failed on (fill yes (arc_segments 16) (thermal_gap 1.99898) (thermal_bridge_width 1.99898))
See http://tech.groups.yahoo.com/group/kicad-users/message/15105
2013-04-25 07:25:47 -05:00
Maciej Suminski 857b02706e Fixed tracks drawing using Cairo backend with caching turned on. 2013-04-25 10:26:32 +02:00
Maciej Suminski 1e0f1b39b0 Fixed color issue for stroked fonts with OpenGL backend and caching turned on. 2013-04-25 10:00:25 +02:00
jean-pierre charras 6a429facb6 Pcbnew, dialog SVG export: Fix Pcbnew crash when opening the dialog. 2013-04-25 09:05:33 +02:00
Maciej Suminski 8663a6c7a0 Added caching of multilayer items (storing multiple group ids for items). 2013-04-24 11:28:11 +02:00
Maciej Suminski b6ec124ceb Removed BeginLayer and EndLayer functions. Resolved Cairo layers drawing problem in a different way. 2013-04-24 09:48:34 +02:00
Maciej Suminski 85a3b72c71 wxWidgets 2.8 compatibility fix. 2013-04-23 18:20:45 +02:00
Maciej Suminski d9b489d471 Changed view control settings to KiCad default (panning, zooming, etc.) 2013-04-23 12:07:14 +02:00
Maciej Suminski 3289c6c305 Modified shaders' source path. 2013-04-23 09:52:51 +02:00
Felix Morgner ec83adde3f Updated the pcbnew Info.plist to associate .kicad_pcb files with pcbnew. 2013-04-22 12:20:34 -04:00
Maciej Suminski 206c8e1189 Drawing SMD pads with colors defined by "Pads Front"/"Pads Back" color settings. 2013-04-22 12:13:48 +02:00
Maciej Suminski 07545ba49c Fixed wheel scroll event on Windows 2013-04-22 11:08:02 +02:00
Maciej Suminski 8312497d6c Modified way of switching canvas 2013-04-22 11:07:38 +02:00
Felix Morgner eed2bed0bd changed implementation of MacOpenFile to make it open files when they are double clicked in Finder. 2013-04-21 20:31:09 -04:00
Wayne Stambaugh 49045cf08c Fix KiCad crash when no template is selected on new project from template. (fixes lp:1170973) 2013-04-21 15:44:57 -04:00
Maciej Suminski 55f7a99d1b Cairo now renders layers properly (colors are not saturated after layer composition), but slower. 2013-04-19 18:19:50 +02:00
Maciej Suminski 98addf78b4 Some cleanup. 2013-04-19 18:19:20 +02:00
jean-pierre charras 4b42ec3218 Pcbnew: fix bug in pcb_parser: incorrect pad local solder paste margin ratio value read when not 0. ( This also fixes bug 1170535 ) 2013-04-19 09:14:27 +02:00
Matthew Beckler e469d9d1f9 Fixes to scripting after refactoring & interface cleanups, 2013-04-18 23:23:11 +02:00
Miguel Angel Ajo d53d9d88fb Support to enable color from PLOT_CONTROLLER into plotters that start in B/W 2013-04-18 23:21:26 +02:00
Dick Hollenbeck ed484deec6 hide pageFmts[] since it is no longer NULL terminated and not global 2013-04-18 13:54:03 -05:00
Dick Hollenbeck df9502dd06 fix some compiler warnings 2013-04-18 12:03:47 -05:00
Dick Hollenbeck 6001254160 fix Lorenzo's bug introduced in rev. 4082 2013-04-18 12:03:25 -05:00
Maciej Suminski 2b0c4ba215 Turned on group recaching on GAL change. 2013-04-18 17:10:02 +02:00
Maciej Suminski 1e9088f7d2 Fixed non-GAL build. 2013-04-18 11:46:23 +02:00
Maciej Suminski ec9e283d34 Fixed resize issue (moved GAL panel into pane).
Tidied up event handlers.
2013-04-18 11:20:19 +02:00
Stefan Helmert 20e7d431a6 The internal BOM generator has bugs. I designed an XSL script, which converts the generated XML Partlist into
a CSV file for Libre Office or Open Office.  It is very easy to use. You can specify it as a plugin for 
Eeshema netlist generator.

It searches for all field names, generates the table headings accounting for all fields found in any part.
Then stuffs all the parts rows according to proper fields.
2013-04-17 09:57:47 -05:00
Maciej Suminski 6c745e6e9b Fix for drawing polygons. 2013-04-17 13:59:46 +02:00
Maciej Suminski d1635e17f6 Fixed drawing of PCB_TARGET items. 2013-04-17 13:12:54 +02:00
Maciej Suminski f9e5881b45 Removed unnecessary calls to cairo drawing functions. 2013-04-17 12:50:38 +02:00
Maciej Suminski 869505a659 Added const(..)& in GAL methods' parameters and change iterators to constant iterators. 2013-04-17 12:48:37 +02:00
Maciej Suminski 895d265603 Added GAL::DrawSegment for drawing rounded segments (used for drawing tracks). 2013-04-17 12:38:00 +02:00
Maciej Suminski e5e60c6bed Fixed drawing arcs in Cairo GAL. 2013-04-17 12:33:11 +02:00
Maciej Suminski 568e6c8093 More accurate rendering display of ZONE_CONTAINERs. 2013-04-17 12:30:21 +02:00
Maciej Suminski cf01f1a264 Fixed drawing polygons using Cairo-based GAL. 2013-04-16 14:55:21 +02:00
jean-pierre charras be7de02a1d Eeschema: fix bug #1168116. Netlist generation: remove dead code and fully outdated option pspice "use net number"
Pcbnew: layer manager: display tooltips using translated form (where internationalized, but always shown in English).
2013-04-16 12:53:23 +02:00
Maciej Suminski b8d88f0dc5 Removed flickering in Cairo-based rendering backend. 2013-04-16 11:43:13 +02:00
Maciej Suminski 698bc0cdac Cleanup 2013-04-16 11:16:27 +02:00
Maciej Suminski 48a7a863ae Inverted Y display axis while using Cairo-based rendering backend. 2013-04-15 17:59:38 +02:00
Maciej Suminski f2c4fa2b46 Introduced Cairo-based rendering backend using GAL.
Moved switching canvas routines to pcbnew, as they are used only there right now (otherwise libgal would have to be linked to every Kicad application).
2013-04-15 17:57:03 +02:00
Maciej Suminski f996d6cc7a Introduced SetGAL() functions that will allow changing GAL backend for rendering on the fly. 2013-04-15 16:03:05 +02:00
Lorenzo Marcantonio 0dbf3ef30a Changed format specifiers of some printf involved with size_t values to %zu to avoid runtime assertions. 2013-04-14 13:02:19 +02:00
Lorenzo Marcantonio 76b558c831 Closes bug 1168753.
Depending on build options seems that wx uses different types for size() so the Format string was not always correct. Put a fat warning in a comment too.
2013-04-14 10:26:42 +02:00
Matthew Beckler c10bb66b12 Match 'new char[]' with proper delete[] char* rather than delete char*. 2013-04-13 23:07:04 -05:00
Dick Hollenbeck 89a391d001 move project templates from source tree to library tree 2013-04-13 16:30:21 -05:00
Maciej Suminski 0fef63956f Fixed text display using Cairo. 2013-04-12 16:41:31 +02:00
Maciej Suminski 63c2af4fa4 Tesselation error fix.
Added missing callback function (combine callback).
2013-04-12 10:37:06 +02:00
Wayne Stambaugh 3ff7ddbea7 wxWidgets 2.8.12 build fix 2013-04-12 09:30:18 +02:00
Maciej Suminski 21733e7bda Copyright change 2013-04-12 09:16:52 +02:00
Dick Hollenbeck 3fa60aaed8 use lower case library names in *.pro & *.sch files, to match actual filenames in the template file set. Noticed on linux. 2013-04-11 14:04:30 -05:00
Lorenzo Marcantonio 9422e37c45 Set grid color for module editor and viewer (closes #1167884)
Also removed EDA_DRAW_FRAME::OnGrid which was totally dead (empty and unused)
2013-04-11 20:29:56 +02:00
Dick Hollenbeck c074c8c9d4 revert text strings for clarity 2013-04-11 13:00:36 -05:00
jean-pierre charras 27c4956046 All: fix a minor issue in drawtext.cpp
Pcbnew: load footprint from modview: Because modview allows user to choose the footprint library, the selected library is forced when the footprint is loaded.
I am not sure this is 100% better, but this new behavior has some advantages, mainly in the footprint editor (you can load a footprint outside the selected library)
2013-04-11 19:40:20 +02:00
Maciej Suminski ebbd7c48d3 Added multiline strings and text overbars rendering using GAL. 2013-04-11 14:21:59 +02:00
Maciej Suminski 079edee146 Copyright notices fix. 2013-04-11 10:04:38 +02:00
Dick Hollenbeck 87f9452bbe 2.9 wx rat race 2013-04-10 16:06:49 -05:00
Dick Hollenbeck 9c0c64e87b Make project templates work with KICAD_PTEMPLATES env var. 2013-04-10 15:31:40 -05:00
jean-pierre charras 3b65c120e8 Pcbnew: fix Bug #1167364
pcb_calculator: fix bug Bug #1167345
2013-04-10 21:20:35 +02:00
Lorenzo Marcantonio 3289835b53 Made overbar position independant of pen size for text, to fix graphics glitches with halo text.
Slightly retuned for compensating the new position.
2013-04-10 21:09:59 +02:00
Dick Hollenbeck 7745d37d6c revert to using quotes around variable text which may be blank 2013-04-10 10:08:01 -05:00
Maciej Suminski 37e440b093 Upstream merged 2013-04-10 15:03:35 +02:00
Maciej Suminski 7792364e8c Temporarily disabled display of netlabels on pads due to performance drop. 2013-04-10 13:47:19 +02:00
Maciej Suminski 3a4ad03492 Fix for compatibility with wxWidgets 2.8 & 2.9 at the same time. 2013-04-10 10:09:23 +02:00
jean-pierre charras cac7dbc607 All: fix some issues in messages to translate. Remove fully outdated files 2013-04-10 09:23:20 +02:00
Maciej Suminski 7326c9cb73 Removed OpenGL different drawing modes, as they were not used.
Removed DRAW_MODE_NORMAL, DRAW_MODE_PREPARE_EDGES, DRAW_MODE_DRAW_EDGES modes.
2013-04-10 09:09:48 +02:00
Lorenzo Marcantonio beb8e76bb4 Removed ugly usage of an extra layer slot for the layer count in gerbview
Fixed layer picker for exporting to pcbnew
Realigned pcb layer name with class BOARD
2013-04-10 09:03:19 +02:00
Lorenzo Marcantonio 43e37caf46 Fixed pad preview color 2013-04-09 21:20:21 +02:00
Lorenzo Marcantonio a985798a86 Better strings for the translators (converted concatenations to formats) 2013-04-09 19:49:01 +02:00
Lorenzo Marcantonio d09cca948f Hunted down hardcoded pixel size thresholds for drawing
Dynamic contrast for netname and pin numbers ('halo' text)
Handle netname drawing even on diagonal tracks
2013-04-09 19:16:53 +02:00
Lorenzo Marcantonio 3f52031b86 Factored out text anchor drawing
More layer classification cleanup
2013-04-09 18:00:46 +02:00
Maciej Suminski 7448116f37 Netnames and pad numbers are displayed on pads (using GAL) 2013-04-09 16:12:20 +02:00
Maciej Suminski 4e0d54fe21 Modified CMakeLists.txt in order to compile Kicad with KICAD_GAL=ON for Windows
Added settings that allow to use M cross environment (http://mxe.cc) to crosscompile Kicad for Windows.
2013-04-09 16:12:18 +02:00
Maciej Suminski 10d8275962 Fixed line style used for displaying texts. 2013-04-09 16:12:17 +02:00
Maciej Suminski 157cbc2f68 Fixed drawing of circles in certain circumstances using OpenGL. 2013-04-09 16:12:16 +02:00
Lorenzo Marcantonio 7d64d2e92a Printf was missing a GetChars 2013-04-09 04:31:36 +02:00
Wayne Stambaugh f86261c812 Fix compile bug in ptree.cpp with wxWidgets 2.9.x and MinGW. 2013-04-08 20:16:53 -04:00
Dick Hollenbeck e1eb33a320 Implement "KiCad s-epression" support for boost::property_tree's ptree, the 8
bit string version of property_tree. The ram resident structure of the ptree is
mostly compatible with one created using the xml_parser from
boost::property_tree, with slight differences in the way atoms are stored. The
result is you can use Format() to convert from xml to s-expression, but not the
other way around. You can write a simple s-expression beautifier in just a few
lines of code.

The main value however is the s-expression parser, i.e. Scan(), which is an
alternative to crafting a custom recursive descent parser for a particular
grammar. The tipping point depends on whether you want to read only a small
portion of a much larger document. If so, then using the ptree will likely be a
"faster to code" route. Documentation on how to navigate a ptree can be found on
the boost website and there are a number of examples in the
pcbnew/eagle_plugin.cpp file in this project. Powerful path navigation support
makes it easy to extract a subset of a ptree.
2013-04-08 16:04:45 -05:00
Maciej Suminski cadcc20ea6 Fixed distorted polygons' corner display 2013-04-08 11:01:49 +02:00
Maciej Suminski 56ad7642c9 Added outline display mode for pads, vias & tracks 2013-04-08 10:54:31 +02:00
Maciej Suminski d1695d3408 Added high contrast display mode using GAL rendering.
New methods in VIEW class: SetTopLayer(), EnableTopLayer() for managing the top layer display.
New method in PCB_RENDER_SETTINGS class: LoadDisplayOptions() for applying display settings like high-contrast, outline display of items, etc.
2013-04-08 10:50:47 +02:00
jean-pierre charras b51fbe5c50 Make some messages translatable.
Make dialog footprint wizard list resizable.
2013-04-08 09:13:26 +02:00
Marco Mattila 04c0ba65d2 Use the boundary of the object and not just the boundary of the text in SCH_TEXT hit testing. 2013-04-07 21:49:13 +03:00
Lorenzo Marcantonio c2f5e7d88c Support for a visibility flag and color selection to NPTH holes
(when disabled they are shown as standard holes, a lot less distracting
than the previous fixed yellow color)
2013-04-07 18:20:46 +02:00
Lorenzo Marcantonio f456a92f08 More cleanup on layer code usage
Better description for entities on right click menu and panel
Typo fixes and some comment reformats
2013-04-07 13:55:18 +02:00
Lorenzo Marcantonio 48419d8fd9 Removed arbitrary MAX_LAYER_ROWS limit (only used in one assertion, anyway) 2013-04-06 18:46:03 +02:00
Lorenzo Marcantonio 0ef5dbac4a Fixed some tab-induced disalignments
Charras beat me on fixing the include/sch_item_struct.h include issue from 4069
2013-04-06 14:28:02 +02:00
jean-pierre charras 8014e0d993 Gerbview, layer manager: add option (popup menu) to always keep layers not visible but the active layer, even when the active layer is changed.
Pcbnew: fix swig warning for operator EDA_COLOR_T::++  (changed to function EDA_COLOR_T:: NextColor)
2013-04-06 14:01:53 +02:00
Lorenzo Marcantonio 739238659e Cleanup of the eeschema 'layers' i.e. entitity colours. This also fixes
the spurious warning about stuff that couldn't be seen when changing
colours.
NOTE that the 'net name' layer is present and configurable but non used 
anywhere!
2013-04-06 07:01:48 +02:00
Lorenzo Marcantonio 6de593c771 Factored layer utility functions: classification, layer flip and mask flip 2013-04-05 21:04:58 +02:00
Lorenzo Marcantonio 4e9fd3ee9d New color palette 2013-04-05 19:23:56 +02:00
Lorenzo Marcantonio 900056be44 Typo fix 2013-04-05 17:09:04 +02:00
Maciej Suminski 221cb6d5b2 Fixed bug of displaying stroked rectangles on wrong layer depth. 2013-04-05 15:10:58 +02:00
Maciej Suminski 83e693c78a Fixed code formatting. 2013-04-05 15:10:31 +02:00
Lorenzo Marcantonio 8db5848e91 Removed the default generation of phantom text by the postscript plot driver.
It crashes Adobe's own implementation of postscript!
2013-04-05 10:55:46 +02:00
jean-pierre charras 27807f02c5 All: change some texts and messages hard to translate, or not translatable (and some incorrect messages).
Pcbnew, layer manager: add option (popup menu) to always keep copper layers not visible but the active layer, even when the active layer is changed.
Usefull for multilayer ( more than 4 layers) PCBs.
2013-04-05 09:38:00 +02:00
Lorenzo Marcantonio 30e31ff164 More work on EDA_COLOR_T and layers.
In particular the new mechanism for handling extended color palettes is in place,
included renaming the ini keys and saving the color name instead of its index; this means better forward compatibility with palette changes.

Since ini keys are changed, colors will be reset
2013-04-04 23:35:01 +02:00
Maciej Suminski ee0fe85cd0 Added setting active layer in PAINTER's render settings according to the PCB layer widget. 2013-04-04 14:17:40 +02:00
Maciej Suminski b2270b2f4f Added missing CMakeModules (Cairo & GLEW). 2013-04-04 11:52:16 +02:00
Maciej Suminski 141252b73f Added GetSettings() method for obtaining current rendering settings used by PAINTER class. 2013-04-04 11:23:23 +02:00
Maciej Suminski 7c4ac2e3a4 Added GetMinDepth()/GetMaxDepth() methods (useful for displaying things on the top or on the bottom). 2013-04-04 11:21:35 +02:00
Maciej Suminski 46b731b2d3 common/painter.cpp: Removed unnecessary header inclusion, added variable initialization
common/view/view.cpp: Added line to comply with coding style
2013-04-04 11:18:47 +02:00
jean-pierre charras bd76e47976 Pcbnew: fix Bug #1163201. Fix Bug #1162779. Fix incorrect comment in CMakeLists.txt. 2013-04-03 18:16:26 +02:00
Maciej Suminski bd2c878b35 Added painting of DIMENSION & PCB_TARGET items. Removed unnecessary header inclusion. 2013-04-03 11:19:13 +02:00
Maciej Suminski 84ee9591d1 Added loading layer visibility settings when loading a board. Minor code cleaning. 2013-04-03 11:19:08 +02:00
Lorenzo Marcantonio 15b27fa35f Meaningful tooltip for ECO layers 2013-04-02 19:11:42 +02:00
Lorenzo Marcantonio e41536484b Fixed idiotic merge error in busentry handling 2013-04-02 18:04:12 +02:00
Maciej Suminski d3004fc833 Showing module's value and reference text on proper layers. 2013-04-02 11:03:15 +02:00
Maciej Suminski 395c5fc922 Added possibility to show/hide layers using right sidebar (PCB layer widget) in the GAL rendered view. 2013-04-02 11:02:35 +02:00
Maciej Suminski c20de314cc Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
    - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
    - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
    - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
    - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
    - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
    - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
    - STROKE_FONT - Implements stroke font drawing using GAL methods.
                          
Most important changes to Kicad original code:
    * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
    * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
    * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
    * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
    * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
    * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
    * Removed tools/class_painter.h, as now it is extended and included in source code.
                         
Build changes:
    * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
    * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
    * GAL-related code is compiled into a static library (common/libgal).
    * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
                            
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 08:54:03 +02:00
jean-pierre charras 4881e6477f Eeschema: Minor changes in dialogs to ensure a better likeness between dialogs on Linux and Windows (mainly, remove some useless wxStaticBoxSizer in dialogs)
Update Clipper version.
2013-04-01 14:41:46 +02:00
Lorenzo Marcantonio 93609837dd Removed unused width attribute from schematic line 2013-04-01 13:59:19 +02:00
jean-pierre charras a8b3c20e66 Minor changes in dialogs to ensure a better likeness between dialogs on Linux and Windows (mainly, remove some wxStaticBoxSizer in dialogs) 2013-04-01 13:42:09 +02:00
jean-pierre charras db2fba1faa Minor changes in dialogs to ensure a better likeness between dialogs on Linux and Windows (mainly, remove some wxStaticBoxSizer in dialogs) 2013-04-01 12:50:01 +02:00
Lorenzo Marcantonio bf9cbb4491 Refactoring: split in two the SCH_BUS_ENTRY class 2013-04-01 12:35:20 +02:00
Lorenzo Marcantonio 18f32cfbd6 Removed unused defines 2013-04-01 07:53:38 +02:00
Lorenzo Marcantonio a5a3ef17b8 Converted the IS_BUS/IS_WIRE define to an enum 2013-04-01 07:47:44 +02:00
Lorenzo Marcantonio 326b827cc6 Better type safety to DANGLING_END_ITEM (SCH_ITEM* instead of void*) 2013-04-01 07:26:53 +02:00
Lorenzo Marcantonio 961efac8e2 Removed the long time dead SCH_POLYLINE class (schematic level polyline) 2013-03-31 22:40:22 +02:00
Lorenzo Marcantonio 418d26d250 Hide the anchor for hidden text (suggested by Sergey Borshch) 2013-03-31 20:57:31 +02:00
Lorenzo Marcantonio 07fb2a3e93 Implemented the LAYER_NUM typedef (LAYER was already taken as a class name...) to represent a layer number. 2013-03-31 15:27:46 +02:00
jean-pierre charras 5006cca67b Minor cosmetic fixes (mainly on Linux) in dialogs. 2013-03-31 14:44:23 +02:00
Wayne Stambaugh 735e3b71d6 Fix build errors in layer mask changes. 2013-03-30 19:41:08 -04:00
Lorenzo Marcantonio d9da8228d4 Minor flags and layer mask cleanup 2013-03-30 20:55:26 +01:00
Lorenzo Marcantonio b5a7e66134 Fixed the logic for "do you want to make the footprint visible" requester
(meaning was inverted)
2013-03-30 18:49:58 +01:00
Lorenzo Marcantonio 00bc96a2b7 - New typedef LAYER_MSK to encapsulate a layer bitmap
- Renamed ReturnMaskLayer to GetLayerMask (since it's a plain getter)
2013-03-30 18:24:04 +01:00
jean-pierre charras 5dd66771fb pcbnew: fix some cosmetic issues mainly on Linux ( these issues could be very dependant on wxWidgets/Gtk versions) 2013-03-30 15:06:05 +01:00
jean-pierre charras 6f19a7deac pcbnew: fix some cosmetic issues (could be very dependant on wxWidgets/Gtk versions) 2013-03-30 14:36:19 +01:00
jean-pierre charras 811585b00f Fix many issues in config functions, mainly a rounding issue when a double is stored in wxConfig file (was stored only using 4 digits in mantissa)
Remove dead or obsolete code.
2013-03-30 10:28:59 +01:00
Wayne Stambaugh f610377363 Fix field position bug in edit component dialog when OK button cancelled due to empty field. 2013-03-29 20:06:08 -04:00
jean-pierre charras 8c549a28df Fix rounding issue when a double is stored in a wxConfig file (wxWidgets 2.9.4 store only 4 digits in mantissa).
A new inline function ConfigBaseWriteDouble( config, key,  double_value )  is used instead of config->Write(  key, double_value ) which store 12 digits
2013-03-29 11:14:32 +01:00
Wayne Stambaugh cab22ffeac Fix a GOST compile error. 2013-03-28 16:49:17 -04:00
Lorenzo Marcantonio 60c9f576f6 Typedef STATUS_FLAGS to encapsulate EDA_ITEM bitmapped flags 2013-03-28 20:12:46 +01:00
Wayne Stambaugh b619c2069f Fix X3D patch commit coding policy issues. 2013-03-28 12:51:22 -04:00
Maciej Suminski 3efdcb95cd Added template RTREE and class VIEW_RTREE (R-tree for fast spatial indexing of VIEW items; for future usage in GAL) 2013-03-28 17:48:29 +01:00
Maciej Suminski 4b11862ecc Added class COLOR4D that contains color representation with 4 components (RGBA) (for future usage in GAL) 2013-03-28 17:42:15 +01:00
Maciej Suminski c5e9b187ae Added template MATRIX3x3 for handling general 3x3 matrices (for future usage in GAL) 2013-03-28 17:38:33 +01:00
Maciej Suminski 04fc574229 Replacement of classes BOX2 and VECTOR2 with their extended versions
include/vector2d.h: Removed old version
include/math/math_util.h: rescale() for VECTOR2
include/math/vector2d.h: New version of VECTOR2
include/math/box2.h: New version of BOX2
common/drawframe.cpp: Refactorization of code, so it is compatible with new classes
include/plot_common.h, pcbnew/basepcbframe.cpp: Changed header inclusion path
CMakeLists.txt: Added definition to turn on WX_COMPATIBILITY for replacement classes
2013-03-28 17:30:09 +01:00
jean-pierre charras f6b6665fed Pcbnew, Module Editor: fix bug Bug #1161114 (pad not visible after undoing a move pad) 2013-03-28 10:40:29 +01:00
Lorenzo Marcantonio 0da9086397 Extremely trivial stuff (mostly cosmetics) 2013-03-28 07:40:19 +01:00
Andrey Fedorushkov c5852c1237 all: new Russian GOST patch - author Konstantin Baranovskiy
pcbnew: fix print format in THROW_IO_ERROR
        fix properties file export_vrml.cpp
2013-03-28 00:38:20 +04:00
jean-pierre charras 5bbd7cb013 Better fix for bug #1155888 2013-03-27 20:36:10 +01:00
jean-pierre charras a3b4a09fd2 Commit patch for x3d file reader (with minor changes). Commit other minor patches and fixes 2013-03-27 19:34:23 +01:00
Lorenzo Marcantonio bf783c42bd Renamed global variables:
Drc_On => g_Drc_On
Route_Layer_TOP => g_Route_Layer_TOP
Route_Layer_BOTTOM => g_Route_Layer_BOTTOM
Track_45_Only_Allowed => g_Track_45_Only_Allowed
2013-03-27 19:32:12 +01:00
Dick Hollenbeck 57e832dc65 reference a test program in a comment 2013-03-27 09:01:50 -05:00
Dick Hollenbeck ab2d301968 remove interrim fix, no longer needed 2013-03-27 08:33:24 -05:00
Lorenzo Marcantonio f1f961a43e Removed unused define TEXT_VTAB_HEIGHT 2013-03-26 21:02:23 +01:00
jean-pierre charras 8e345bd09c Pcbnew: Fix Bug #1160396 2013-03-26 19:15:30 +01:00
Wayne Stambaugh 0996c307ac Fix field text position access bug in Eeschema. (fixes lp:1160214) 2013-03-26 13:25:18 -04:00
jean-pierre charras fb8e505590 Pcbnew: fix an issue when texts in footprints have a size = 60 mils (default size for texts). After saving and reading the .kicad_pcb file, the size was not correct. 2013-03-26 18:05:47 +01:00
jean-pierre charras ec2804a78a Pcbnew: Fix a collision name between 2 methods: EDA_ITEM::GetFlags() and ZONE_CONTAINER::GetFlags(), which creates a very strange behavior when creating/edition zones.
ZONE_CONTAINER::GetFlags() is now named  ZONE_CONTAINER::GetLocalFlags().
2013-03-26 10:58:40 +01:00
jean-pierre charras 29d2ee3273 Pcbnew: fix issue in zone keepout dialog: layers not displayed on Linux, and minor changes 2013-03-25 20:11:22 +01:00
jean-pierre charras 6e3e6a1944 Pcbnew: fix issue in zone keepout dialog: layers not displayed on Linux, and minor changes 2013-03-25 19:48:07 +01:00
Wayne Stambaugh 1005fd2872 Fix SCH_FIELD get reference designator text bug. (fixes lp:1159401) 2013-03-25 13:09:55 -04:00
jean-pierre charras ab666cc267 Pcbnew: fix issue in zone keepout dialog: layers not displayed on Linux 2013-03-25 18:02:29 +01:00
jean-pierre charras e79df21353 Very minor changes in dialog zones. 2013-03-25 14:37:48 +01:00
Andrey Fedorushkov ff0ddbcac0 eeschema: fix build when KICAD_GOST ON (insert in bzr4019) 2013-03-24 00:37:48 +04:00
jean-pierre charras d1604137cc Pcbnew, ModEdit: fix issue when setting anchor position, and minor code cleaning. 2013-03-23 14:30:00 +01:00
Wayne Stambaugh 969efff611 Encapsulation, bug, context menu string, and, coding policy fixes.
* Complete encapsulation of the ZONE_CONTAINER class.
* Fixed a bug in the EDA_TEXT::Format() default effects behavior due to
  improper conversion to internal units and missing test for default
  thickness.
* Improved grammar of some Pcbnew context menu strings.
* Moved some more cleverly hidden BOARD object methods into class_board.cpp.
* Lots of coding policy and documentation fixes.
2013-03-20 10:50:12 -04:00
Dick Hollenbeck 293f7cca28 Consistent with my email posting from a day or two ago, remove the translated
standard layer name support from BOARD::GetLayerName().  This function evolved
in a contorted direction over time, and was being asked to return one of 3
different kinds of layer names, even though it only took a boolean to control
that choice.  

Users are better served by forcing them to get to know the concise new 
English Standard layer names.  This is because these concise names show up
in the "pretty" footprint/module files as the standard representation of
both feature and copper layers.

Change the name of BOARD::GetDefaultLayerName() to GetStandardLayerName().
Drop boolean argument to both BOARD::GetStandardLayerName() and 
BOARD::GetLayerName().
2013-03-19 23:46:32 -05:00
Carl Poirier 45a48cfcb2 Add library column to component and module select dialog. 2013-03-18 21:25:19 -04:00
Wayne Stambaugh 822cc6a781 More encapsulation work.
* Complete encapsulation of the MODULE class.
* Complete encapsulation of the EDA_TEXT class.
* Encapsulate most of the ZONE_CONTAINER class.
* Add pcbcommon library as a dependency for reSWIGging the scripting
  support.  This should cover most dependency cases.
2013-03-18 15:36:07 -04:00
Miguel Angel Ajo 658f02a6b9 checkcoding.py refactor from Edwin van den Oetelaar, some extra refactorings by me, improvement suggestions from Carl Poirier 2013-03-18 12:22:31 +01:00
jean-pierre charras 8d675d9bc0 Pcbnew: fix Bug #1156193 . Fix compil issues when KICAD_SCRIPTING_WXPYTHON is not enabled and KICAD_SCRIPTING is enabled 2013-03-17 20:04:42 +01:00
Miguel Angel Ajo fdf135d877 ReloadPlugins() python function, and mtime stored in the KICAD_PLUGINS dictionary 2013-03-17 03:03:18 +01:00
Miguel Angel Ajo a2bb144556 New register() method in plugins, used by the loader to handle runtime plugin reloading 2013-03-17 02:18:09 +01:00
Miguel Angel Ajo c867ed9de4 Refactoring python to wxArrayString, and better exception error reporting 2013-03-17 02:14:46 +01:00
Miguel Angel Ajo 39ef596bdc Fix wxString.Print call to be compatible with wx2.8, thanks to Барановский Константин and Edwin van den Oetelaar for submiting same patch, same hour, are you twins? ;) 2013-03-17 00:51:43 +01:00
jean-pierre charras a9bcaa1493 Pcbnew: designe rule dialog: fix incorect size of track list grid 2013-03-16 12:12:18 +01:00
Miguel Angel Ajo f05163fbeb Allow plugins to be reloaded without closing/opening pcbnew, next step is plugin editor, just a few lines away... 2013-03-16 04:27:48 +01:00
Miguel Angel Ajo 7ad3e0c544 Also check coding style of new files, not only modified ones 2013-03-16 00:28:35 +01:00
Miguel Angel Ajo 24882a9324 tool for checking coding style 2013-03-16 00:21:53 +01:00
Miguel Angel Ajo 9bb6ead2b1 LOCALE_IO toggle implementation for locale switches on scripting; code cleanups to comply with kicad coding style policy 2013-03-15 17:35:24 +01:00
Miguel Angel Ajo d6bcbc5cdf Fixed wxGrid re-creation and missing icon for dialog 2013-03-15 15:50:54 +01:00
Miguel Angel Ajo dc4b261c68 wxT added to the locales fix, message box on python exceptions inside wizard, added some missing copyright notices 2013-03-15 14:27:18 +01:00
Miguel Angel Ajo 9262f13eef Fix for locales that set , as a decimal point (which is incompatible with python scripting), also fixed the m_Reference encapsulation in module to Reference() 2013-03-15 01:56:36 +01:00
Dick Hollenbeck 82998d0cc0 EAGLE_PLUGIN now establishes (trace_min), (via_min_size), (via_min_drill), and Default Net's (clearance)
by groking the eagle *.brd info.  This makes it more probable that fewer DRC errors come about on first 
DRC attempt.
2013-03-14 17:54:47 -05:00
jean-pierre charras 8949cfe584 3D viewer: fix very minor issues (better rendering of 3D view). 2013-03-14 17:11:05 +01:00
jean-pierre charras c10d1fe279 Very minor fixes, mainly for the stable version 2013-03-13 20:15:09 +01:00
jean-pierre charras 9ed5ee8310 Last (minor) fixes for the stable version 2013-03-13 20:06:46 +01:00
Wayne Stambaugh 7b266ef475 Pcbnew encapsulation and code cleaning.
* Encapsulate most of the MODULE class.
* Start encapsulating the DIMENSION class.
* Lay some groundwork for EDA_TEXT encapsulation.
* Move cleverly hidden MODULE functions into class_module.cpp.
* Use std::swap to exchange TEXTE_PCB values for undo/redo.
* Remove unused members from MODULE class.
* The usual coding policy and documentation fixes.
2013-03-13 14:53:58 -04:00
Dick Hollenbeck 09f1a4fbb8 EAGLE_PLUGIN cu layer map fix broke footprint library loading 2013-03-13 11:38:54 -05:00
Dick Hollenbeck c7f55381a5 EAGLE_PLUGIN cu layer map fix 2013-03-13 11:17:16 -05:00
jean-pierre charras 81f35ffe73 Pcbnew: fix a bug in autoplac.cpp 2013-03-12 17:37:41 +01:00
jean-pierre charras 597b362603 Pcbnew: Fix many minor issues in print dialog, mainly in modedit. 2013-03-12 16:17:44 +01:00
Miguel Angel Ajo 0163e4b4e4 Reverted back the ( i ) parameters for python, applied the PyGILState_Ensure from Dick into his PyLOCK class 2013-03-12 01:37:45 +01:00
jean-pierre charras 98a77ee649 Pcbnew: print dialog: code cleanup and bug fixes (added some fixes from Sergey A. Borshch) 2013-03-11 20:30:58 +01:00
Dick Hollenbeck c9edd2c8de improvements to python's GIL acquisition and release, but not done yet, since I think the GIL needs to be acquired even when not involving wxPython. 2013-03-11 03:09:48 -05:00
jean-pierre charras 379ad3a8e7 Kicad manager: fix bug: .kicad_pcb files not saved in zip file 2013-03-10 20:55:21 +01:00
jean-pierre charras aca64b5dda Pcbnew: fix issues: Ensure pads type connector have a drill size= 0, like SMD pads. Ensure keepout zones have no net. 2013-03-10 14:59:47 +01:00
Miguel Angel Ajo d34639b79b Project templates now can find the system templates from KICAD environment variable 2013-03-10 02:35:24 +01:00
jean-pierre charras 0d4b157207 Pcbnew: Partial merge from pcad2kicad (from Alexander Lunev). Fix an old bug related to pads with offset: sometimes the connection to a zone was not detected. 2013-03-09 20:36:31 +01:00
jean-pierre charras 58160d9624 Pcbnew: fix bug in export vrml (bad Z position of 3D shapes). Very minor code cleaning. 2013-03-08 08:29:30 +01:00
Wayne Stambaugh 57e34dfb3c Documentation and coding policy fixes.
* Fix all Doxygen warnings except polygon files.
* Add footprint library table tasks to TODO.txt.
* Add definition to drag.h to prevent nesting.
* Coding policy fixes.
2013-03-07 12:12:59 -05:00
Baranovskiy Konstantin 67ab19289d Width factor for DXF plotting text used an inverted aspect ratio. 2013-03-07 08:15:35 -06:00
jean-pierre charras 7718bf6858 Gerbview: Minor fixes 2013-03-06 20:32:59 +01:00
jean-pierre charras ee467d0203 Pcbnew: fix Bug #1148785 (pcbnew crashes when using only one layer in autorouter ) , and a minor bug in dialog cleanup. 2013-03-06 10:04:27 +01:00
jean-pierre charras 9b7265810b Pcbnew, module edit dialogs: fix some "cosmetic" issues. 2013-03-04 20:59:12 +01:00
jean-pierre charras 24dc1092b1 Refinements 2013-03-04 20:31:09 +01:00
jean-pierre charras ab953f1381 Refinements 2013-03-04 20:15:23 +01:00
jean-pierre charras 83174e996e Dialog edit module: remove some wxStaticBoxSizer sizers. 2013-03-04 19:49:32 +01:00
jean-pierre charras 38069048fd Still fix very minor issues in dialog_edit_module_for_BoardEditor.cpp 2013-03-04 17:57:24 +01:00
jean-pierre charras 9fda651595 Still fix minor issues in dialog_edit_module_for_BoardEditor.cpp (noticeable only for non English users) 2013-03-04 17:39:08 +01:00
Wayne Stambaugh cb13ae57bc Minor Pcbnew dialog spacing and consistency fixes. (fixes lp:1143465)
* Fix spacing and consistency issues and debug warning due to improper flex
  grid sizer in module editor module properties dialog.
* Fix spacing and consistency issues in Pcbnew module properties dialog.
* Fix spelling error in DRC dialog message box text.
2013-03-04 11:04:53 -05:00
jean-pierre charras 6a45d30715 Pcbnew: fix strange things in module edit dialogs. 2013-03-04 13:08:35 +01:00
Andrey Fedorushkov a43f24617d pcbnew: fix build in linux gcc-4.5.2 2013-03-02 20:32:05 +04:00
jean-pierre charras f11a148d2d Eeschema: fix broken mirroring for texts and labels in block mirror X and Y (this fixes Bug #1135505)
Pcbnew: add in module popup menu an option to edit the footprint in Modedit (like in Eeschema for components)
minor icons enhancements.
2013-03-01 20:59:29 +01:00
Wayne Stambaugh 73cf4c0e49 Update coding policy to remove support for MSVC. 2013-03-01 08:32:55 -05:00
Dick Hollenbeck 8ea3cd1cb5 Debug build fix 2013-02-28 22:20:29 -06:00
Dick Hollenbeck 62979ae06d parse *.kicad_pcb files with numeric net_names 2013-02-28 10:17:24 -06:00
Dick Hollenbeck 5e998288d6 specctra_export to handle Edge Cuts graphics in modules 2013-02-27 09:54:29 -06:00
jean-pierre charras e01b851e1c CMakeLists.txt: use elseif token instead of elif which create strange issues with some cmake versions.
Fix minor issues in nsis config files
2013-02-27 13:46:40 +01:00
jean-pierre charras 2e6a40be96 CMakeLists.txt: use elseif token instead of elif which create issues with some cmake version.
Fix minor issues in nsis config files
2013-02-27 08:19:42 +01:00
jean-pierre charras 02c1ec5efc Minor fixes and cleanup 2013-02-26 12:25:30 +01:00
jean-pierre charras 78a6ba31d8 Fix Bug #1132416. Minor update in templates. 2013-02-24 18:31:18 +01:00
Baranoviskiy Konstantin 1ae23df0ba Remove redundant Eeschema plot submenu on platforms that do not support plot to clipboard. 2013-02-23 15:08:28 -05:00
Wayne Stambaugh 36ba9a7309 Add build option to use footprint library table. 2013-02-23 14:30:43 -05:00
Anton Blanchard 7ee129b21a Fixes segfault in Pcbnew module editor when clicking delete tool where there is no object. 2013-02-22 18:29:44 -05:00
Wayne Stambaugh b3d4123007 Fix Eeschema plot dialog escape key handling bug on some Linux distros. 2013-02-22 16:59:53 -05:00
Wayne Stambaugh 5bfd330692 Minor dialog and footprint ID class fixes.
* Make Pcbnew net list dialog honor escape key on Linux.
* Make Pcbnew swap layers dialog honor escape key on Linux.
* Layout and UI policy fixes for Pcbnew swap layer and net list dialogs.
* Layout and UI policy fixes for Eeschema plot dialog.
* Rename fpip.h to fpid.h.
* Fix FPID class compiler errors.
* Restore fpid.cpp to Pcbnew static library source list.
2013-02-22 15:03:00 -05:00
Dick Hollenbeck 49125d1a7d wxID_CANCEL, 5 pixel border around sizers, resizable search combobox, dialog_shim usage on a few dialogs 2013-02-22 07:47:35 -06:00
jean-pierre charras 6050ef41a9 Pcbnew: Very minor fix in plot dialog. 2013-02-22 09:04:15 +01:00
Baranovskiy Konstantin 0d809688ee Eeschema border and title block DXF plot color bug fix. 2013-02-21 18:45:46 -05:00
jean-pierre charras da20e80de6 Pcbnew: plot Dialog: add a popup menu (try mouse right click in plot dialog) to selected/unselect groups of layers to plot.
All: For new zoom centering option: use Shift+Ctrl key instead of Alt key to select the new zoom centering, because Alt key has a special function under Windows.
2 very minor other changes.
2013-02-21 21:53:50 +01:00
Baranovskiy Konstantin 1f46bf2e28 DXF plot layer color bug fix. (fixes lp:1126403) 2013-02-20 15:26:34 -05:00
jean-pierre charras f345dbe7e4 Eeschema: Fix Bug #1130262 (Inverted pins are plotted with erroneous line width) 2013-02-20 12:46:38 +01:00
Wayne Stambaugh 490c8d856e Minor dialog spacing, grammar, and sizer fixes. 2013-02-19 14:43:48 -05:00
jean-pierre charras 897a5b8de6 Pcbnew: Export vrml: fix an issue for 3D shapes having a local offset defined: the local offset was not correctly scaled. 2013-02-19 10:21:55 +01:00
Wayne Stambaugh 155cb4f158 Minor dialog spacing, grammar, and UI policy fixes. 2013-02-18 15:14:53 -05:00
Emmeran 445cf5860a Adds zooming method for zooming relative to the crosshair instead of centering
the crosshair after zooming.

This method is only used when the ALT key is held while using the mousewheel or
if it's permanently enabled in the options dialog next to the middle mouse
button panning option.
2013-02-18 09:57:39 -06:00
Dick Hollenbeck 6cb1bae032 fp lib table work 2013-02-15 19:09:53 -06:00
Dick Hollenbeck c0c9d667cd typos and tooltip 2013-02-15 18:13:35 -06:00
Jacobo Aragunde Perez b946032f56 Plot dxf format: fix issue for some non latin1 chars. 2013-02-15 12:53:16 +01:00
Antia Puentes df8826240f Commit patch from Antia Puentes relative to bug Bug #1125047 : PcbNew: Insert a footprint in the board, from the Library Browser, by double clicking on it, with a change to avoid the button release event (from the double click) to be seen by the main window. 2013-02-14 22:20:56 +01:00
unknown 5dda4f95a6 MacOSX: now autoplace is drawn correctly 2013-02-14 20:57:19 +01:00
unknown f3822e6ffa MacOSX: Now Arcs are shown in edit mode 2013-02-14 20:56:45 +01:00
Wayne Stambaugh 084ad26b73 Add CheckCXXSymbolExists.cmake to fix configure bug using CMake versions prior to 2.8.6. (fixes lp:1124854) 2013-02-14 13:39:36 -05:00
jean-pierre charras fafecb491e Remove outdated (and/or erroneous) documentation. 2013-02-14 18:57:12 +01:00
Dick Hollenbeck 0e6a590305 -fPIC only for non-MINGW. See http://mingw.5.n7.nabble.com/Option-fPIC-not-supported-td18480.html 2013-02-14 09:31:56 -06:00
Dick Hollenbeck 0e8c9fda5e typo 2013-02-14 08:50:32 -06:00
Dick Hollenbeck d2ac283570 add -fPIC for all builds, even cross comiling to Windows from Linux, even non Debug and Release builds 2013-02-14 07:12:54 -06:00
jean-pierre charras 69bdc16751 Pcbnew: Pcad2kicad: remove dead code. 2013-02-13 18:19:46 +01:00
Antia Puentes b8325a38a1 Eeschema: force file ext in"Sheet Save As" command (Bug #1122212 ) 2013-02-13 18:18:23 +01:00
Wayne Stambaugh 403a1a7e1f Fix bug caused by setting default drill size in D_PAD (fixes lp:1123392).
* Add check for pad type and force drill size to zero if pad is surface
  mount in PCB_PARSER.
* Modify the D_PAD SetAttribute method to clear drill size if pad type is
  set to surface mount.
2013-02-12 20:01:22 -05:00
Dick Hollenbeck cf481d2fc4 fix compiler warnings on gcc 4.6.3, Debug build 2013-02-12 11:41:13 -06:00
Emmeran c3e3fc4dba converted linux to dos file endings for wxfb files 2013-02-12 05:30:28 +01:00
Emmeran 254ad1b26b moved changes to dialogs into fbp files 2013-02-12 05:18:22 +01:00
Emmeran 2c642afd04 tabs converted to spaces except wxstruct.h 2013-02-12 04:56:46 +01:00
Wayne Stambaugh e43fab7c01 Pcbnew pad properties dialog assertion and layout fixes.
* Fixed spacing issue in pad properties dialog.
* Remove wxSHAPED flag from pad drawing panel to prevent assertion in
  wxSizer.
* Used sane default pad size and drill size settings to prevent wxRound
  assertions.
* Add license to class_board_design_settings.cpp.
2013-02-11 20:07:04 -05:00
jean-pierre charras 55f2914163 Eeschema: All fixed fields are now always saved in libraries. Therefore the footprint field can be set in lib (size, visibility) and imported in schematic with its predefined attributes, even if the footprint text is not set. 2013-02-11 19:50:55 +01:00
Wayne Stambaugh 96d7ac7c6a Configuration and compile documentation improvements.
* Improve the stable and testing build version option logic.
* Use CMake FindPythonInterp to configure the Python interpreter.
* Use Python interpreter to determine the system Python module install
  path if not already defined on the command line.
* Add header symbol checks for asinh(), acosh(), and atanh().
* Add test source to check for isinf() which can be defined as a C++template.
* Replace conditional compile on windows systems for aXXXh() with CMake
  configuration tests.
* A few minor MSVC compile fixes.
* Fix incorrect python environment string in fixswigimports.py
* Create a separate document for KiCad CMake build options.
* Create a separate how to compile KiCad on Windows document.
2013-02-10 19:41:49 -05:00
jean-pierre charras c9be096e88 eeschema, libedit l fix a bug in lib_arc.cpp which creates incorrect arc start and arc end parameters after rotation or mirror.
the Bug #1121079 is due to this bug, but Bug #1121079 itself cannot be fixed because this is the data inside the lib which is broken.
2013-02-10 19:02:45 +01:00
jean-pierre charras e18b8642c4 Upgrade boost to version 1.53.0 and clipper to 5.03 2013-02-10 14:52:01 +01:00
jean-pierre charras dad83c9004 Pcbnew: Try to find a better workaround for zone fiill bug (crash or bad fil areasl in very rare cases).
pcbnew+Eeschema: Fix a very minor bug: filename not displayed in frame reference.
2013-02-09 21:03:20 +01:00
Wayne Stambaugh f0a86c360c Improve Eeschema find dialog behavior.
* Remove ignore mouse events before creating find dialog for true mode-less
  behavior as was originally intended.
2013-02-07 15:36:35 -05:00
Wayne Stambaugh c6444b7d05 Improve zone context menu descriptions, fixes lp:1116483 2013-02-07 12:56:41 -05:00
jean-pierre charras 6b81b6931f Pcbnew: rework on connection calculation: fix an issue for "composite" pads (complex pad build by association of some basic pads):
sometimes connections where not seen.
2013-02-07 18:40:50 +01:00
Jacobo Aragunde Perez b391fb3faf Commit patch for bug 1116059 (Inconsistency between confirmation dialogs) 2013-02-07 18:35:37 +01:00
Dick Hollenbeck 2649c38bf7 plotter output file being left open fix. 2013-02-06 09:21:37 -06:00
jean-pierre charras 81266f2f71 Kicad manager: fix a minor issue noticeable on Kubuntu 12.04 (bad size of buttons area) 2013-02-06 14:15:40 +01:00
jean-pierre charras 05189f9ff5 Eeschema, Libedit: fixes color artifacts when moving/placing a pin.
Very minor other fixes.
2013-02-06 12:54:51 +01:00
jean-pierre charras a3f8783dca Very minor changes (tooltips update, to synchronize them with the doc update) 2013-02-04 09:52:56 +01:00
Andreas Beutling c20d23a552 fix some errors in common_plotHPGL_functions.cpp 2013-02-03 18:53:48 -06:00
Emmeran d2ed926077 added option to allow zooming around the crosshair instead of the center; can be enabled via options or by holding alt while using the mousewheel 2013-02-02 20:10:48 +01:00
jean-pierre charras c0b3ad8253 Changes for CvPcb to eeschema stuff file: the stuff file generation from CvPcb is removed. Eeschema now imports footprints names from the .cmp usual file created by CvPcb or by Pcbnew (Why to use 2 file formats for the same thing?) .
Pcbnew: in netlist dialog: The user now can choose between the netlist and the .cmp file to import footprints names.
Therfore no need to delete the .cmp file when exists to use only the netlist.
This is useful for users who use CvPcb only once to fill footprints fields in schematic, and after edit/modify the footprints fields in schematic outside CvPcb.
2013-02-02 18:39:59 +01:00
Jacobo Aragunde Perez 30495f780a Commit fixes for bugs #1108773 and #1110651 and a bug fix improvement for #1101718 and #1102381. 2013-02-01 08:58:49 +01:00
Jacobo Aragunde Perez a2114c44ad Commit patch to fix bug 1108838 (+ fix a very minor fix in eeschema, when loading a new component) 2013-01-30 17:15:45 +01:00
jean-pierre charras 0f06a927ff Pcbnew: Workaround to fix a crash when filling zone in Pcbnew nanometers (see Bug #1106451 ). Also happens with one of my boards.
Could be a bug inside boost::polygon. This is a workaround, because one never knows if this kind of bug is fixed.
However it fixes this issue for the 2 boards.
2013-01-27 14:54:43 +01:00
jean-pierre charras c5c41b8ab5 Fix bug in TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist ), when aDist = 0. (fix Bug #1106744 ) 2013-01-27 11:06:09 +01:00
jean-pierre charras 1f4ca54938 Pcbnew: fix a very old bug in DRC, pad to pad drc tests: sometimes a test between a rectangular pad and an oval pad was skipped.
Segment Hit Test: enhanced detection near segment ends (noticeable for instance when clicking on short tracks in Pcbnew.
Remove duplicate code about segment hit test.
remove unused file.
2013-01-26 18:49:48 +01:00
jean-pierre charras 720e3e9272 Eeschema: fix a bug which crashes Eeschema (when a label is being created, and its type is changed by popup menu, for instance to a text, before it was put on schematic)
remove unused file and minor coding style fix
2013-01-25 18:29:54 +01:00
acobo Aragunde Perez a42400272d Eeschema: Add "append schematic" feature. Fix bug 1101718 <Empty plot filename> 2013-01-24 19:46:42 +01:00
Jacobo Aragunde Perez 19558b48c1 Eeschema: Add "append schematic" feature. Fix bug 1101718 <Empty plot filename> 2013-01-24 18:46:37 +01:00
Dick Hollenbeck 744d875838 fix intermittent build problem involving out of sequence python invocation 2013-01-23 10:35:40 -06:00
Dick Hollenbeck 59d2523c49 fix compiler warnings with gcc 4.6.3 on x86_64 linux 2013-01-23 10:13:42 -06:00
Jacobo Aragunde Perez 13fdde5e5d Eeschema: hotkey enhancement while moving a block or an item. 2013-01-21 21:16:04 +01:00
jean-pierre charras 86e73c1bae Gerbview: Fix a minor but annoying issue in gerbview config: colors setup is broken when running a testing version after an old gerbview version (due to a bug of this old version which breaks the color config) 2013-01-21 21:02:07 +01:00
Jacobo Aragunde Perez 6cd558fd5c Eeschema: fix Bug #1102381 <eeschema: -cache.lib file not created the first time you save a schematic> 2013-01-21 20:58:02 +01:00
Dick Hollenbeck 8f45c7d27e merge in branch fp-lib-table 2013-01-20 21:27:01 -06:00
Dick Hollenbeck 3518b18351 more fp lib table work 2013-01-20 21:12:16 -06:00
jean-pierre charras 6dea106650 Pcbnew: fix a minor bug I created in rev 3912.
Still try to find a better fix for Bug #1100876, however I am thinking the bug is not in Kicad:
looks like a buggy version of wxWidgets is used, which sends sometimes an unwanted wxCommandEvent event,
when an event::Check() is called inside a function called by a  wxUpdateUIEvent event.
2013-01-19 16:01:17 +01:00
jean-pierre charras 123a29d126 Pcbnew: Fix Bug #1097345 <module editor "change body item width (current)" does nothing.> 2013-01-19 13:58:54 +01:00
jean-pierre charras 9a8383de24 Pcbnew: fix bug Bug #1101399 (Custom page size gets reset after restarting pcbnew) (bug also in eeschema)
Try to find a better fix for Bug #1100876
2013-01-19 10:58:25 +01:00
jean-pierre charras 2453201d7b Try to fix Bug #1100876< Modes (track/footprint) not available.>
It could be a race condition when setting the tools state on and off in PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent ) on some Linux/wxWidgets versions
(does not happen on my computer)
2013-01-18 15:12:57 +01:00
Jacobo Aragunde Perez 14deef3adf Add patch from Jacobo Aragunde Perez <Log of opened and closed applications in KiCad launcher> 2013-01-18 11:44:35 +01:00
Jacobo Aragunde Perez 8c191e5ba8 Add patch from Jacobo Aragunde Perez <Log of opened and closed applications in KiCad launcher> 2013-01-18 11:42:23 +01:00
Dick Hollenbeck 20fc4a2efe fix goof-ed preprocessor test 2013-01-18 00:13:31 -06:00
Dick Hollenbeck 49a577dd59 Enhance DIALOG_SHIM to optionally call SetFocus() after the derived class's constructor has been called, for wx 2.8 and wxGTK 2013-01-18 00:04:25 -06:00
jean-pierre charras 8b8f5d45c9 Pcbnew: fix a minor bug: shape 3D filename not displayed in msg panel when clicking on a footprint. 2013-01-17 18:34:03 +01:00
jean-pierre charras cec687bad2 Scripting: fix erroneous extension for S exp board files, which prevent to open a .kicad_pcb file from a python script
Make scripting version compilable on platforms where the python executable is not python2:
Just define it by -DPYTHON_EXECUTABLE=<python executable filename> when running cmake (there was already a partial fix for this)
2013-01-16 20:15:56 +01:00
jean-pierre charras 9891e2d986 Scripting: fix erroneous extension for Sexp board files
Make scripting version compilable on platforms where the python executable is not python2 (define it by -DPYTHON_EXECUTABLE=<python executable filename>)
2013-01-16 13:38:30 +01:00
jean-pierre charras 24b23e2383 Pcbnew: store in configuration the default line width (now in mm), under a new keyword, to avoid a strange behavior of pcbnew in decimils version (old pcbnew versions), after running pcbnew in nanometers. 2013-01-15 10:31:11 +01:00
jean-pierre charras 413aa106a2 AUTHORS.txt: add some contributor names (I certainly forgot some other contributors, and I apologize).
Demos: convert .brd files to .kicad_pcb files and fix 2 broken files
2013-01-14 13:16:23 +01:00
jean-pierre charras 097dcd724f Kicad manager: fix a recent bug: project tree not updated when kicad is launched by a command line with a project name to open.
Pcbnew: export vrml:
* move dialog functions to a new file: dialog_export_vrml.cpp (to be consistent with other dialogs).
* fix some coding style issues
* added patch from Cirilo Bernardo.
2013-01-13 19:41:15 +01:00
jean-pierre charras 1454880fb7 Kicad manager: fix a recent bug: project tree not updated when kicad is launched by a command line with a project name to open.
pcbnew: export vrml:
* move dialog functions in a new file: dialog_export_vrml.cpp.
* fix coding style issues
* patch add from cirilo Bernardo.
2013-01-13 17:55:07 +01:00
Dick Hollenbeck c6a712dec3 pcbnew/CMakeLists.txt formatting and librt fix 2013-01-12 18:34:16 -06:00
Heikki Pulkkinen 2c888b86f5 protect data in class_track.h, switch to using member accessors 2013-01-12 18:04:00 -06:00
Wayne Stambaugh 7481dcf520 Base object decoupling improvements.
* Improve MSG_PANEL_ITEM to handle message panel information.
* Create containers for passing message panel items between objects and
  the message panel.
* Rename EDA_ITEM::DisplayInfo to EDA_ITEM::GetMsgPanelInfo.
* Remove all direct manipulation of EDA_DRAW_FRAME from all objects derived
  from EDA_ITEM.
2013-01-12 12:32:24 -05:00
jean-pierre charras 435a34cd60 3D viewer: allows import of models created with openscad and convertedvia meshconv to wrl (thanks to Georg Gast <georg@schorsch-tech.de>)
Export VRML: fix scaling issue for pcbnew - nanometers.
2013-01-12 11:35:08 +01:00
Miguel Angel Ajo 23ffcf8f89 MacOSX compilation fixes 2013-01-10 23:10:05 +01:00
jean-pierre charras 89d6a09401 Commit missing files. 2013-01-10 13:20:16 +01:00
jean-pierre charras b8fce6a8e1 EDA_LIST_DIALOG: add a filter option to select names to display is list, from a kamil zorychta's patch <kamil.zorychta@gmail.com>
Use wxFormBuilder to create EDA_LIST_DIALOG_BASE, like other dialogs.
Minor code cleanup (remove unused functions and coding style fixes) and minor bug fixes.
2013-01-10 13:18:43 +01:00
Wayne Stambaugh 523e7eb397 Pcbnew BOARD object encapsulation improvements. 2013-01-09 13:52:44 -05:00
jean-pierre charras 30a3668779 Pcbnew: Enhancement in connections calculations:
Until now, 2 tracks were seen as connected only if one end of the first track is *exactly* on one end of the other track.
Now the 2 ends are seen as connected when they are "near" i.e. the distance between the 2 ends is < track width/2
2013-01-08 18:58:06 +01:00
jean-pierre charras d95ea479c4 Pcbnew: Fix unwanted selection clarification popmenu in board editor after double clicking on a DRC Unconnected error
(For DRC clearance error, it was fixed  in bzr 3838, but forgotten for DRC Unconnected error)
2013-01-07 21:52:15 +01:00
jean-pierre charras baf18a6379 Pcbnew: Fix Bug #1096766 ( Can't create filled zones after keepout zones) 2013-01-07 08:46:01 +01:00
jean-pierre charras 92831ee7d4 Gerbview: add option to show negative objects. 2013-01-06 14:31:49 +01:00
Dick Hollenbeck de823996b5 when linking a DSO, require all symbols to be resolved 2013-01-04 17:02:10 -06:00
jean-pierre charras 936974f12c Pcbnew: fix link issue (undefined Read_GPCB_Descr symbol) in scripting mode. 2013-01-04 23:00:05 +01:00
Jacobo Aragunde Perez 0c88507dcf Prevent Pcbnew from opening the same file twice. 2013-01-04 18:47:59 +01:00
Jacobo Aragunde Perez 9184095b34 Eeschema:commit patch <Prevent Eeschema from opening the same file twice> with a small fix for windows. 2013-01-04 13:06:50 +01:00
Wayne Stambaugh f1eea58b6b Remove unused Geda footprint import source code file. 2013-01-03 16:51:26 -05:00
Wayne Stambaugh 49f2206ef0 Doxygen warning fixes. 2013-01-03 15:21:40 -05:00
jean-pierre charras 8f94a14063 Kicad manager: cleanup code, remove dead or not working code. Fix minor isssues 2013-01-03 20:25:12 +01:00
Dick Hollenbeck 9843e0c436 add eagle *.lbr lib path extension for future use 2013-01-03 10:33:22 -06:00
jean-pierre charras e3149cd2b0 Kicad: Fix a compil issue under Linux, and minor code cleaning, about wxFileWatcher 2013-01-02 23:12:16 +01:00
jean-pierre charras 7c5d2ab029 Kicad: Fix compil issue under Linux, and minor code cleaning, about wxFileWatcher 2013-01-02 22:49:56 +01:00
jean-pierre charras 6422be116b Eeschema, Libedit: Fix potential issues when using some hot keys. 2013-01-02 09:34:46 +01:00
jean-pierre charras 50eef193ff Eeschema, Libedit: fix potential bugs. 2013-01-02 08:55:48 +01:00
Dick Hollenbeck 8092d98ea3 1) Implement EAGLE_PLUGIN::FootprintLoad(), FootprintEnumerate(), and IsFootprintWritable().
2) Add PCAD_PLUGIN to _pcbnew.so for scripting, fixing a linking bug.
2013-01-01 22:05:48 -06:00
jean-pierre charras ed42891509 Eeschema: fix Bug #1095005 2013-01-01 21:52:37 +01:00
Brian Sidebotham 6124226428 switch a template's board format to kicad_pcb format 2013-01-01 14:48:32 -06:00
Brian Sidebotham 6c22590d4a Fixes a bug in the template file copying mechanism. The previous code failed to honour sub-directorys and flattened the whole tree whilst copying files.
I have fixed this so that sub-directories that are not the meta directory will get copied verbatim into the new project directory.
2013-01-01 14:39:25 -06:00
jean-pierre charras 950d9ae23a Kicad manager:
* Use the recent wxFileSystemWatcher to automatically update the tree project when a file is created/deleted/renamed in the project directory
(and if the file type is usually shown by the manager.)
Needs wxWidgets 2.9.4 or more recent.
* Also code cleanup, dead code or useless code removed.
2013-01-01 16:57:48 +01:00
jean-pierre charras a12ff75fee Kicad: files watcher: fix Linux specific issues 2013-01-01 15:06:49 +01:00
jean-pierre charras 681413bb97 Kicad manager: first use of wxFileSystemWatcher (only with wxWidgets >= 2.9.2) to monitor files list. 2012-12-31 09:12:29 +01:00
Wayne Stambaugh 1ebe2c8728 Fix Pcbnew s-expr file parser bug. 2012-12-30 10:40:05 -05:00
Antia Puentes 41dd21ac7b Eeschema: Allow to edit an schematic item while dragging 2012-12-29 13:55:36 +01:00
Alexander Lunef 6b6d9706bd Pcbnew: Add pcad2kicad pcb plugin, to import PCAD boards ( .pcb ASCII data file PCad 2000 format ) from Alexander Lunef 2012-12-29 10:54:25 +01:00
Wayne Stambaugh 1b57a79636 Add Pcbnew GEDA PCB module plugin support.
* Create new GEDA PCB plug in.
* Add support for opening GEDA PCB footprints with module editor.
* Make import footprint file dialog remember last selected footprint
  type during current session.
* Update module editor file import to use new GEDA PCB plug in.
* Let IO_MGR know about GEDA PCB plug in.
* Create a WHITESPACE_FILTER_READER to simplify parsing GEDA PCB footprint
  files.
2012-12-28 15:52:12 -05:00
jean-pierre charras a1f3b7d53f Eeschema: fix incorrect hotkey commands while moving/dragging a component. 2012-12-28 16:56:41 +01:00
jean-pierre charras 1118ef8f19 Pcbnew: board editor: allows pad edition by hotkey 'E' (was accessible only by mouse button right click)
All: minor code cleaning and very minor bug fixes.
2012-12-27 17:42:41 +01:00
unknown 4b9526adb1 MacOSX: deleted obsolete code 2012-12-23 11:57:02 +01:00
unknown ef3f42dfab MacOSX: fixing possible crash 2012-12-23 11:55:24 +01:00
unknown 6f018668c2 MacOSX: refresh overlay with new-deleted objects 2012-12-23 11:53:54 +01:00
jean-pierre charras f20d6e8d05 Eeschema: fix bug 1092864 2012-12-21 19:57:56 +01:00
jean-pierre charras 0574bf8aba Eeschema: fix bug 1092834 (Hotkey 'G' Drag label not working) 2012-12-21 13:56:17 +01:00
jean-pierre charras 7ea9f8ddcc Pcbnew: Rework on recovery files menu 2012-12-21 08:58:51 +01:00
Dick Hollenbeck e4d9cb77fc extend fp_lib_table on multiple row paste 2012-12-20 23:29:40 -06:00
jean-pierre charras 7eee33a6a0 Pcbnew: fix issue when loading a recovery backup board file.
Because now there are 2 formats, board backup files extensions are .brd-bak or .kicad_pcb-bak instead of the old .000 extension, depending on the initial file format.
2012-12-20 21:20:56 +01:00
jean-pierre charras 3bbafe14f5 Pcbnew: fix bug: missing call to SetFileFormatVersionAtLoad after loading a board, in legacy format. 2012-12-20 19:05:18 +01:00
Dick Hollenbeck 1dc048662b fix a fairly serious bug which would leave SOLDERMASK_LAYER_FRONT layer turned off in PADs, when loading *.kicad_pcb files 2012-12-20 00:56:17 -06:00
jean-pierre charras 7546651a30 Pcbnew: class DIMENSION: code cleaning 2012-12-19 20:31:36 +01:00
jean-pierre charras 6d16131b03 Pcbnew: fix minor bugs. Fix bug 1091593 and 1091693 . Minor code cleaning 2012-12-18 18:50:00 +01:00
Wayne Stambaugh 7eb196b4d1 Doxygen warning fixes. 2012-12-18 08:54:44 -05:00
jean-pierre charras 1e8f7f7ba8 Pcbnew: allows pcbnew to open a .kicad_pcb or a .brd file, from the command line. 2012-12-16 14:48:54 +01:00
jean-pierre charras eefbd1610e eeschema: make new netlist format (S expr netlist format) the default for Pcbnew netlists in dialog netlist.
Also move netlist_control.* to dialogs/dialog_netlist.*, to be consistent with other file dialogs.
2012-12-16 12:36:18 +01:00
jean-pierre charras 0f8af51da6 Pcbnew: add a dialog to load a legacy file in "old" projects, when the .kicad_pcb file is not existing, and the correspoinding .brd file exists.
Fix also an issue in pcb_parser when a netclass name is just a number (like a track width as name)
2012-12-15 14:39:36 +01:00
jean-pierre charras c14dad91b2 3d viewer: code cleaning. Display options are now stored in config. 2012-12-15 09:52:02 +01:00
Wayne Stambaugh 2538262531 Fix angle scaling error in Pcbnew s-expr file format parser. (fixes the arc bug part of lp:1090524) 2012-12-14 16:37:59 -05:00
Dick Hollenbeck 453a135a3e fix bug 2012-12-14 13:58:50 -06:00
Dick Hollenbeck 0cfa6d8097 fix pcbnew file save as problem, if previous file by same basename did not exist. Show default file ext. 2012-12-14 13:42:38 -06:00
jean-pierre charras 7e77f3b902 Kicad manager: shows *.kicad_pcb files the project tree. 2012-12-14 20:37:51 +01:00
Dick Hollenbeck 71d2467963 minor file save as fixes, move legacy header into its plugin 2012-12-14 12:14:28 -06:00
Dick Hollenbeck a6140c799d Switch over to *.kicad_pcb format as the default BOARD format.
Add KiCadPcbFileExt global.
2012-12-14 10:54:54 -06:00
Wayne Stambaugh bd7217b090 Fix minor version information text formmatting error. 2012-12-12 11:52:24 -05:00
jean-pierre charras cc45f4f212 Pcbnew: fix Bug #1089120. Also change "Length Die" expression to "Length Pad To Die" in code 2012-12-12 12:57:17 +01:00
Dick Hollenbeck d95710f8e0 allow . in layer names 2012-12-10 23:39:36 -06:00
Wayne Stambaugh b3703f1f91 Fix FreeRoute launcher Java executable path error on Windows (fixes lp:1087589) 2012-12-10 21:44:20 -05:00
jean-pierre charras 104d63fd7c Eeschema: Erc dialog: enhancement. Now not modal.
Pcbnew: Drc dialog: fix a old very minor bug.
Added: single click on an item in marker list moves the board  graphic cursor on the corresponding marker location on the board
Double clicking is not modified.
2012-12-10 20:08:09 +01:00
jean-pierre charras df994764a5 Pcbnew: Add a minimal test for illegal chars in footprints libname (like space and dir separtor)
Also a minor cosmetic enhancement
2012-12-10 12:18:42 +01:00
Dick Hollenbeck 764ef2dcc9 note that the clipboard format is spreadsheet compatible 2012-12-09 14:53:46 -06:00
Dick Hollenbeck 1dddc22a9b embellish fp_lib_table editor with beginnings of cut, copy, paste 2012-12-09 14:51:42 -06:00
Dick Hollenbeck ebac5c4a70 change spelling to jive with my email on developers list 2012-12-08 23:34:12 -06:00
Dick Hollenbeck 59a3715e40 more fp_lib_table work, enhance parser 2012-12-08 17:58:03 -06:00
jean-pierre charras 86bb2f325e Eeschema: fix compil issue with wxWidgets 2.8.12 2012-12-08 20:36:28 +01:00
jean-pierre charras eb370afe4a Eeschema: Add hotkey 'U' to edit reference. Better filtering for hotheys V, F, U: now the corresponding field is selected without selection list between component and the field. 2012-12-08 18:24:49 +01:00
jean-pierre charras fc06b1762f All: Fix an usually unwanted behavior in kicad: When closing a dialog (mainly ERC, DRC and recently a component selection by the library viewer on a double click) the mouse release left button event (which is seen by the parent after closing the dialog, becuse it is actually made in the parent) generate an unwanted command (item selection, component place ...)
This event can be now skipped if needed by calling  EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent() from the dialog.
Very minor other fixes
2012-12-07 11:05:19 +01:00
jean-pierre charras a1fed86b28 Try to fix an unwanted left mouse release button event, when closing a dialog on a click or double click,
and therefore when the mouse butoon is released in the parent window
Minor other fixes.
2012-12-06 22:53:00 +01:00
unknown a96a265a7b MacOSX: fixes refresh of lines and outlines when drawing 2012-12-06 19:10:58 +01:00
unknown a2d65bb523 MacOSX: Fixes the append always beaviour of cvpcb when reading netlists 2012-12-06 19:10:00 +01:00
unknown 7c966fa775 MacOSX: cleanups 3817 & completes 3820 2012-12-06 19:08:34 +01:00
Marco Mattila 8042d6f892 Update board modified state when (un)locking a module in pcbnew. 2012-12-06 12:13:19 +02:00
Dick Hollenbeck d4c8c0bb52 merge patch with refinement 2012-12-04 13:12:50 -06:00
Dick Hollenbeck 148d567aa4 Prevent the double click from being as a single click in the parent
window which would cause the part to be parked rather than staying
in drag mode.
2012-12-04 13:09:53 -06:00
Antia Puentes 85e96c92ed In eeschema, when inserting a component into the schematic using the
Library Browser tool, you have to select it in the components listbox
and then press the "Insert component into schematic" button to close the
window and return to the schematic.

The attached patch enables the selection and insertion of a component in
schematic by double clicking on it in the Library Browser component
listbox. As the double clicking should have effect only if the Library
Browser was launched to load a component in schematic, the patch checks
for NULL the m_Semaphore variable, used two distinguish the mode in
which the Library Browser is running (modal, used when inserting a
component in schematic, or non-modal).
2012-12-04 13:04:04 -06:00
Marco Mattila b25e440ba9 Fix BOM-by-reference generator to print the separator character instead of the ascii code 2012-12-03 17:06:49 +02:00
jean-pierre charras c4d874cdb1 Pcbnew: plot solder mask layer with min width value specified: algorithm modified to reduce artifacts. 2012-12-03 15:27:34 +01:00
jean-pierre charras 4e96cc4bbb Pcbnew: minor coding style fixes. Very minor fixes. Minor enhancements. Fix bug #1085523 2012-12-02 12:38:00 +01:00
jean-pierre charras 78f928544f Pcbnew: minor enhancements. 2012-12-01 21:03:33 +01:00
jean-pierre charras 0edbe77903 Eeschema: dialog ERC: minor enhancements and code cleaning. 2012-11-30 13:28:23 +01:00
Marco Mattila ccf8c3bd83 Fix pcbnew zone corner filleting 2012-11-30 07:51:47 +02:00
Heikki Pulkkinen f8020f4728 Pcbnew: commit patch from Heikki Pulkkinen (via displayed with its right size and clearance during track creation/edition) 2012-11-29 20:27:08 +01:00
Wayne Stambaugh 23bded5697 Pcbnew print fixes and improvements.
* Fix offset errors when scale factor greater is than one.
* Changed behavior of fit in page when not drawing border and
  title block to fit board outline in page.
* Fix offset errors when mirroring (still not 100% correct on MSW with
  wxWidgets 2.9.4).
* Lots of the usual code cleaning and simplifying.
2012-11-28 20:50:58 -05:00
jean-pierre charras 9df7292af6 Pcbvew: fix a strange bug which swap x and y values for pad offsets when reading a s expr *.kicad_pcb board file. 2012-11-28 19:04:57 +01:00
Dick Hollenbeck bcb05fbc14 merge in evolving fp lib_table work 2012-11-28 09:24:53 -06:00
Lorenzo Marcantonio 7adc495692 Added warning about gcc 4.7.1 miscompile in COMPILING.txt 2012-11-28 08:38:02 +01:00
jean-pierre charras 69f8ee8ee2 Polyline.cpp: fix a bad wxASSERT test which generate error messages in Debug mode when there is no error, in DEBUG mode, when filling zones with holes. 2012-11-27 21:12:39 +01:00
Dick Hollenbeck 4acb97e02e reverse throw() clauses to quiet SWIG errors 2012-11-27 13:57:38 -06:00
Dick Hollenbeck 7cd840bf83 richio improvements, fix dangling open file 2012-11-27 08:25:50 -06:00
Dick Hollenbeck 9577736788 start using FILE_LINE_READER( const wxString& ) 2012-11-27 08:14:15 -06:00
Dick Hollenbeck f7ec499ee9 Change READ_LINE classes to use less virtual functions, and READ_LINE::ReadLine() to return char*
which can eliminate a subsequent call to READ_LINE::Line() for a small performance gain.
2012-11-27 07:50:01 -06:00
Dick Hollenbeck a64e1b3397 Fix dangling open file introduced as recent workaround 2012-11-27 06:42:28 -06:00
Dick Hollenbeck abeba63ed5 Another constructor for FILE_LINE_READER which enables more consistent file open strategies, and only call setvbuf() when the file is at position 0 2012-11-27 06:33:12 -06:00
jean-pierre charras 0dd05887d2 Csv Boom file: fix a minor error in commit 3818 2012-11-26 20:14:38 +01:00
jean-pierre charras f8b3873b83 Eeschema: Fixes and enhancements in BOM list generation and BOM code:
* remove useless spaces in csv bom file format.
 * remove KICAD_GOST conditionnal compilation and merge KICAD_GOST code with the "normal" code.
 * Csv file format created by KICAD_GOST code is now available for everybody through the BOM dialog options (as it should).
 * fix coding style issues.
2012-11-26 18:28:54 +01:00
unknown 63362c97f5 MacOSX: a strange bug with setvbuf in FILE_LINE_READER disalign the netlist reader. 2012-11-25 13:17:02 +01:00
unknown b07b214293 MacOSX: Crash in pcbnew during edit footprint and changing layer from dialog (Fixes: #764678) 2012-11-25 09:08:25 +01:00
unknown e368ae3230 MacOSX: now editing Text on PCBNEW works nicelly as expected. 2012-11-25 00:23:36 +01:00
unknown 9cf627a656 MacOSX: Fixes Crash when adding text on pcbnew (bug #891347) 2012-11-24 23:03:30 +01:00
Marco Mattila 5d383f1885 Fix saving of local thermal parameters in pcbnew legacy_plugin. 2012-11-24 18:02:10 +02:00
jean-pierre charras f9b7ede7ff Pcbnew: fix bug1082146 (Keep-out areas get destroyed by "export settings to other zones" )
Eeschema: fix bug 1082107 (error message" component not found" when no component selected from select component dialog box)
2012-11-23 10:18:52 +01:00
jean-pierre charras a2a44bb7ef Pcbnew: fix bug1082146 (Keep-out areas get destroyed by "export settings to other zones" )
Eeschema: fix bug 1082107 (error message" component not found" when no component selected from select component dialog box)
2012-11-23 10:10:37 +01:00
jean-pierre charras 1f37ca437b BOM list code cleanup. 2012-11-22 21:33:52 +01:00
unknown ac77e047f4 MacOSX: disabling BufferedBitmap of OSX in gerbview, not supported nor accelerable and bitmap becomes too large in case of retina display to be usable 2012-11-20 20:19:24 +01:00
jean-pierre charras 02a6baad8a polygon: update clipper lib. 2012-11-20 12:42:39 +01:00
jean-pierre charras 799ef3bc0d Eeschema: item drag command: Fix issue for overlapping items (from a Younes Manton's idea)
Added: display info when clicking on labels.
2012-11-20 12:35:09 +01:00
unknown b337dccd0c MacOSX: problems with cvpcb after multiline patch:
1) OSX compiler is really choosy (class_components_listbox.cpp)
2) Old OSX code maked an endless loop (listboxes.cpp)
2012-11-19 22:34:25 +01:00
Dick Hollenbeck 8867bf262b Eliminate many assumptions in Pcbnew's library manager, pertaining to locality of libraries and
their type, by using the more abstract PLUGIN::Footprint*() functions.

This is an intermediate phase only, other changes will be necessary as library table support comes in.
Encapsulate usage of library path searching, since that will go away as library table support comes in.
Add FOOTPRINT_EDIT_FRAME::{get,set}LibPath() and FOOTPRINT_EDIT_FRAME::{get,set}LibNickName() functions
to provide this encapsulation.
2012-11-19 10:19:38 -06:00
jean-pierre charras 0543670734 Try to fix a compil issue with some wxWidget versions. 2012-11-19 15:32:34 +01:00
jean-pierre charras 9c66afb6fe Pcbnew: enhanced dialog for SVG export 2012-11-16 15:13:31 +01:00
Dick Hollenbeck 0dc8241605 Add *.kicad_mod as default import footprint extension. Turn on all Cu layers for thru hole pads in case loading non-wildcard s-expression footprint files. 2012-11-15 10:46:43 -06:00
Dick Hollenbeck 7ca5c4099e remove -std=c++0x compiler option since nobody is ready for it, and accordingly back into auto_ptr from unique_ptr 2012-11-15 10:04:10 -06:00
jean-pierre charras e40c8fa164 Pcbnew: fix incorrect filenames when plotting layers 2012-11-15 11:47:23 +01:00
jean-pierre charras df88d0cbea Fix compil issue under MinGW: for an obscure reason the option -std=c++0x creates error in wxWidget code:
some functions used in wxWidgets ( like _strdup and few other) are not defined when this option is set. 
but the equivalent option -std=gnu++0x works fine so it is used under mingw instead of  -std=c++0x.
(Under Linux/OSX  the option -std=c++0x is used)
2012-11-14 21:07:09 +01:00
Dick Hollenbeck f73e785662 1) Switch to boost hashtable support from wx macros which did not handle std::string.
This required the additional compiler command line option "-std=c++0x".

2) Switch to unique_ptr from auto_ptr which is C++ deprecated.

3) Change to new English layer names per mailing list discussion, see class_board.cpp.

4) When saving to *.kicad_pcb or *.kicad_mod, identify opportunities to use wildcard
   layer sets, for pads so far.

5) Switch to two std::string hashtables in pcb_parser.cpp, away from one wxString based one
   for layer names and layer sets mapping. One hashtable holds the mask, the other the index.
   Layer sets are only in the mask table.

6) Move "LOCALE_IO toggle" into PCB_IO::Format() since it is a public API function and
   caller should find it as convenient as possible to use.  LOCALE_IO should handle
   nesting OK in the case where public Format() is called from one of the Footprint*()
   functions.

7) Drop support for "export module to new library".  Creating new libraries will have to
   be handled in concert with library table entries, and we've talked recently about
   creating a better footprint library manager, one that resides in a DLL/DSO.  So
   this kind of functionality needs to be handled in there in the near future.

8) Change name of exported PCB_IO module/footprint to *.kicad_mod and not *.emp.
2012-11-14 01:15:59 -06:00
jean-pierre charras 1bb685cc57 pcbnew: fix minor issues.
pcb_calculator: fix a compil warning (gcc 4.7)
2012-11-12 17:19:10 +01:00
Dick Hollenbeck 5d4da5ede9 switch to new s-expression format for footprint exports, use english layernames for naked footprints, dodge conflict with pythons HAVE_GETC_UNLOCKED 2012-11-10 00:39:18 -06:00
Dick Hollenbeck fe295788e7 footprint save to use untranslated (English) layer names 2012-11-09 13:00:00 -06:00
Dick Hollenbeck f8b3eaedb5 populate PCB_PARSER::m_layerMap with English layernames so footprints
can be parsed, since they do not have an overriding layer name map
like a BOARD does.

Avoid doubly looking up hashtable entries in m_layerMap.

Minor code reformatting.
2012-11-09 00:58:00 -06:00
Dick Hollenbeck e5e83eba05 remove old sourceforge mailing list export file 2012-11-08 13:45:14 -06:00
jean-pierre charras 28a35c9883 Pcbnew: Add a min width parameter to plot solder mask layers.
* If this param is set to 0, the previous behavior is used.
* Else the solder mask is plotted as polygon, with shapes near than  this min width value are  merged.
Pcbnew in nanometer version: fix a serious rounding issue due to the fact dialogs were using 4 digits for mantissa.
* This is not enough for nanometer coordinates ( 8 are needed to display a value in inches),
*  so sometimes after closing a dialog, some coordinates were modified, although no new value was entered.
Minor other bug fixed.
2012-11-06 18:58:53 +01:00
jean-pierre charras d8a6c7c1bf Add a min width parameter to plot solder mask layers. 2012-11-05 21:20:34 +01:00
jean-pierre charras c8f6806287 Eeschema: fix an old bug: sometimes E hotkey (and some other' hot keys) was editing a previously selected item, not the item under the mouse cursor
Templates: remove useless backup files
2012-10-31 21:27:31 +01:00
Dick Hollenbeck 8bf57814a4 implement move up, move down in lib table editor 2012-10-31 09:41:47 -05:00
Dick Hollenbeck c2d4338024 remove unused #include <wxfstream.h> from several places 2012-10-29 16:56:18 -05:00
Dick Hollenbeck 6410862b15 add new templates to template/CMakeLists.txt, group all templates into one installation COMPONENT 2012-10-29 16:55:05 -05:00
Hans Henry von Tresckow 4845668a4a TI Stellaris Launchpad Boosterpack Template.
Here is a first cut at the 40pin booster pack template. I made 2
versions, BoosterPack40, which has the optional J5 connector and is
2"x1.7" and BoosterPack40_min, which is 2"x1.35" and leaves the
switches accessible.
2012-10-29 15:48:33 -05:00
Marco Mattila 146adbf831 Do not force vias to be substracted from silkscreen in pcbnew gerber plot 2012-10-28 22:51:47 +02:00
Dick Hollenbeck d1f291acb8 128 pixel icons from Frabrizio's script and tar file. 2012-10-28 14:10:07 -05:00
Dick Hollenbeck 4b7c3010e0 switch from STREAM_OUTPUTFORMATTER to FILE_OUTPUTFORMATTER mostly throughout,and minor richio factoring 2012-10-25 10:41:20 -05:00
Wayne Stambaugh 4039f66530 Add missing scripting build flags to EDA_BASE_FRAME::CopyVersionInfoToClipboard. 2012-10-25 10:27:35 -04:00
Dick Hollenbeck 4ce6362f4c streamline the FILE_OUTPUTFORMATTER API for ease of use 2012-10-25 02:10:59 -05:00
Dick Hollenbeck 5765ebef08 add class FILE_OUTPUTFORMATTER and use it in PCB_IO, since it is about 8-10 faster than STREAM_OUTPUTFORMATTER 2012-10-25 00:52:55 -05:00
Dick Hollenbeck a3eb501225 move wxString constructor outside loop for speed 2012-10-24 13:59:37 -05:00
Dick Hollenbeck 82706bf152 fix ownership issue in wxFFile vs. FILE_LINE_READER 2012-10-24 13:42:39 -05:00
Dick Hollenbeck 5e852ba1fd move PCB_PARSER into PCB_IO as a member 2012-10-24 13:20:33 -05:00
Dick Hollenbeck d49cdb2ded DSN_LEXER underneath PCB_PARSER does not own the LINE_READER it receives, fix memory leak 2012-10-24 12:38:10 -05:00
Wayne Stambaugh a8ad1f8097 Fix compile error against wxWidgets 2.8 brach. 2012-10-23 13:20:22 -04:00
jean-pierre charras 2ea3c4acac Eeschema: Bug fix (move component field was not undoable)
Minor enhancement in popup menus for wire and bus.
Kicad: stm32f0discovery template: very minor fix.
2012-10-23 18:37:19 +02:00
Dick Hollenbeck d1e3bad24f pcbnew import footprint fixed for legacy nanometer format 2012-10-22 15:41:26 -05:00
Kerusey Karyu 06f46e4b14 Fix error in stm32f100-discovery-shield.brd 2012-10-21 10:40:10 +02:00
Kerusey Karyu 54714fd989 Add stm32f100-discovery-shield template 2012-10-20 18:16:34 +02:00
jean-pierre charras 912d308b9d Kicad: bug fix in menubar when changing the selected locale.
fctsys.h: remove useless define.
Fix minor issues and add minor enhancements.
2012-10-18 21:31:40 +02:00
Dick Hollenbeck 0b71e4a98a more fp_lib_table work 2012-10-18 10:28:50 -05:00
Wayne Stambaugh 900bef9ccf Put KiCad on a diet to remove the uncessary slices of pi. (fixes 1066194) 2012-10-17 16:59:05 -04:00
Dick Hollenbeck 7106d1e605 more fp_lib_table work 2012-10-17 10:12:17 -05:00
jean-pierre charras 6840ec0d09 Fix a minor compatibility issue in .pro file for new boards, between decimils and nanometers versions of Pcbnew. 2012-10-17 12:57:21 +02:00
Dick Hollenbeck 0e8e811b14 decouple wxGridTableBase from FP_LIB_TABLE, this was poor information hiding 2012-10-16 20:00:25 -05:00
Dick Hollenbeck 3dc986bbf6 fp_lib_table dialog work 2012-10-16 01:56:57 -05:00
Dick Hollenbeck 34813dc07c remove one-ness bug from CMakeLists.txt 2012-10-16 00:28:39 -05:00
Wayne Stambaugh f79d75076c Only use -O1 GCC optimization level for versions 4.7 and above for now. 2012-10-15 21:42:50 -04:00
Dick Hollenbeck 57b5ce84a5 add dialog for fp_lib_table 2012-10-15 17:37:08 -05:00
Dick Hollenbeck 395338f46a add dialog for fp_lib_table 2012-10-15 17:30:01 -05:00
Wayne Stambaugh c33cd27626 Minor FP_LIB_ID object changes. 2012-10-15 16:48:01 -04:00
jean-pierre charras 2ca4512443 Kicad manager: project_template.cpp: accepts lower and upper case HTML keywords (compatibility with libreoffice) 2012-10-15 19:55:04 +02:00
Dick Hollenbeck 76b4dc7346 Commit Dick's changes to the FP_LIB_TABLE object. 2012-10-15 12:19:42 -04:00
Wayne Stambaugh 53609d2ecd Merge changes from testing branch. 2012-10-15 09:40:40 -04:00
Dick Hollenbeck d24054ac00 make nanometers the default board internal units within Pcbnew 2012-10-15 00:21:31 -05:00
Wayne Stambaugh 2c0619f69d Initial commit of footprint library table code. 2012-10-14 21:38:32 -04:00
jean-pierre charras f039aeb4c8 missing files 2012-10-14 19:00:47 +02:00
Brian Sidebotham ab0e47d402 Commit patch from Brian Sidebotham: Project template in Kicad manager 2012-10-14 18:57:11 +02:00
jean-pierre charras 03128b7530 Eeschema: always stores sheet filename in unix-like notation, and fix a bug when editing sheet file name.
Pcbnew: add PDF format  for drill map generation.
Plotter classes: tweaking code.
2012-10-13 20:54:33 +02:00
Andrey Fedorushkov ed3e79325f eeschema: fix segfault when edit text and empty editing text 2012-10-13 22:33:58 +04:00
unknown c4c715fcd0 OSX: Corrected issue with Menus, workaround/fix for an issue with Mountain Lion 2012-10-13 20:23:03 +02:00
Wayne Stambaugh 86b83ddbc9 Fix footprint library file extension bug in CvPcb and Pcbnew due to s-expression changes, fixes lp:1064593. 2012-10-09 15:18:12 -04:00
Wayne Stambaugh 62c43eaf53 Add Boost version to EDA_BASE_FRAME::CopyVersionInfoToClipboard(). 2012-10-09 11:31:55 -04:00
Wayne Stambaugh 33cf2243a8 Check for getc_unlocked() and fall back to getc() in richio if it's not available. 2012-10-09 10:31:36 -04:00
Dick Hollenbeck 02a1c2f096 optimize isSpace for negative 8 bit bytes 2012-10-08 15:01:17 -05:00
Dick Hollenbeck b841150c23 *) Use fgetc() technique to avoid strlen() in FILE_LINE_READER::ReadLine(),
which was having difficulty with embedded nuls in files coming from PCAD.

*) Make dsnlexer.cpp's isSpace() treat nuls as whitespace.
2012-10-08 14:34:46 -05:00
Dick Hollenbeck 3db19ba2eb eeschema erc dialog extends from DIALOG_SHIM 2012-10-08 14:34:04 -05:00
Dick Hollenbeck 22d1f50455 minor. 2012-10-08 14:30:38 -05:00
Wayne Stambaugh baee140518 Convert footpint library log functions to trace functions to reduce debug output. 2012-10-07 18:26:17 -04:00
Dick Hollenbeck deaa4529ae Commit Dick's INPUTSTREAM_LINE_READER patch. 2012-10-07 17:26:41 -04:00
Wayne Stambaugh bed29749f2 Pcbnew s-experssion footprint library implementation.
* Add footprint methods to PCB_IO.
* Add FP_CACHE and FP_CACHE_ITEM for handling new footprint library design.
* Add code to save legacy libraries in new format.
* Change behavior of BOARD_ITEM::GetLayerName() to return the default layer
  name when the item does not have a BOARD as a parent.
* Minor changes to the module output formatter when writing to module library
  files (no BOARD as parent).
* Add new (and some that I forgot along the way) CMake flags to
  EDA_BASE_FRAME::CopyVersionInfoToClipboard().
* Add -Wno-narrowing to GCC flags to stop GCC 4.7 from complaining about
  a conversion from int to unsigned in the Boost polygon library.
* Add INPUT_STREAM_READER to richio.cpp to allow using any object derived
  from wxInputStream as a LINE_READER (needs to be validated).
2012-10-07 11:37:25 -04:00
jean-pierre charras e57cbd3348 Dialog drill file: remove precision choice, because only one choice was acceptable
(the option with the smallest number of digits for coordinates created unacceptable truncation coordinates in Excellon drill files)
2012-10-05 21:04:17 +02:00
jean-pierre charras 2f788445a9 Pcbnew: drill files creation: better dialog to create driil files, map files and report file. Code cleaning 2012-10-05 14:25:12 +02:00
jean-pierre charras d4e55c69c1 Pcbnew: fix an issue when collecting vias (for instance when left clicking on a via, it was not always detected)
This bug was mainly noticeable when using buried vias (some were never detected)
Minor other fixes (typos, strings hard to translate ...)
2012-10-04 19:47:28 +02:00
jean-pierre charras d07351c8ba More dialogs derived from DIALO_SHIM 2012-10-04 08:57:15 +02:00
jean-pierre charras 2412caf494 Pcbnew: make all dialogs derived from DIALOG_SHIM. 2012-10-03 13:25:30 +02:00
jean-pierre charras 9b6f75afd3 Pcbnew: Make scripting version compilable under Windows 2012-10-01 08:04:06 +02:00
jean-pierre charras a4b2a6537c Make scripting version compilable under Windows 2012-09-30 19:50:17 +02:00
jean-pierre charras cfaa7d9e54 Eeschema: fix a bug in my previous commit 2012-09-28 20:45:04 +02:00
jean-pierre charras 0ca3012c67 Eeschema: code cleanup, remove dead code and some global and useless variables 2012-09-28 19:47:41 +02:00
jean-pierre charras 42ebece808 Eeschema: fix Bug #1057225 2012-09-27 20:18:56 +02:00
unknown 0d7510c129 [MacOSX] Updated Icons - Document ones still missing :( 2012-09-27 19:20:44 +02:00
Felix Morgner ebe697f62a Added support for multi-selection and multi-editing in cvpcb. 2012-09-26 15:57:58 -05:00
Felix Morgner 29240fd14b fixed code to better comply with the coding style guidelines 2012-09-26 19:22:48 +02:00
Felix Morgner 97f4d18a13 Added mutli-selection to cvpcb 2012-09-26 17:36:48 +02:00
unknown 8ef0dd69da MacOSX - Fixed some issues launching bundles/binaries 2012-09-26 00:33:42 +02:00
jean-pierre charras 30d41b33d1 Finishing code cleaning in plot functions. 2012-09-25 09:49:29 +02:00
jean-pierre charras 2ce06cfe08 Pcbnew: fix compil warning and a minor bug in plot negative (frame fer plotted in white therefore not visible).
minor code cleaning
2012-09-24 18:03:03 +02:00
jean-pierre charras 3b1a1125d2 convert_from_iu: erroneous definition of MILS_PER_IU, MM_PER_IU (and therefore Iu2Mils)
only for Pcbnew in Decimils version. These definitions are provided, but not yet used in code.
2012-09-24 08:46:20 +02:00
jean-pierre charras 93cdfb566b Pcbnew, plot functions: fix bug in SVG plotter, fix a minor other bug when using PS plotter (trcak width fine adjust not working)
and plot code cleaning continued
2012-09-24 08:39:59 +02:00
jean-pierre charras b61ac2069d pcb_calculator: fix compil issue about isinf (under mingw) 2012-09-22 17:45:15 +02:00
jean-pierre charras 6e8a71ec34 pcb_calculator: fix compil issue about isinf. 2012-09-22 14:13:57 +02:00
jean-pierre charras 3b3fc0151e Cvpcb: remove macros MAX, MIN, ABS (forgotten file in my last commit) 2012-09-22 13:29:30 +02:00
jean-pierre charras f5643f2332 All: remove macros MAX, MIN, ABS from macros.h and replace these macros by std::max, std::min and std::abs (mainly found in old code). 2012-09-22 13:19:37 +02:00
Dick Hollenbeck 38e5d961f6 switch all <math.h> includes to <cmath> includes on an attempt to dodge some abiguous references to atan2() 2012-09-21 12:02:54 -05:00
jean-pierre charras 5be15bed82 Pcbnew: some code cleanup in plot functions. 2012-09-21 10:20:38 +02:00
jean-pierre charras deb6aa8cc5 Fix incorrect titles in SVG export dialog 2012-09-20 21:15:14 +02:00
jean-pierre charras 3b3e19ee8a dcsvg (and therefore KicadSVGFileDC) is now unused. Use SVG plotter only to export a board SVG file.
SVG export does not use no more wxWidgets wxDC.
In pcbnew SVG files can be created by plot menu (in B&W) or export SVG menu (B&W or Color).
Export SVG menu is more suitable to create a view of a board, and plot menu is better to create a B&W document of silkscreen layers.
(In the future, the 2 menus could be merged, because they are not very different).
Note: pcbnew plot code is cleaned, mainly in dialog files, but still needs more cleanup.
2012-09-20 20:58:41 +02:00
Craig Southeren a713e47713 This fixes a MSVC compile error caused by a static scalar initialiser. 2012-09-20 08:54:35 -05:00
Craig Southeren abbc83bd51 Fix MSVC compile errors caused by struct forward declared as class 2012-09-20 08:38:50 -05:00
Dick Hollenbeck 7d4aaa8cdb fmin() was giving grief to MSVC, switch to std::min() 2012-09-20 08:22:33 -05:00
Dick Hollenbeck 06b3172333 This change fixes a compile error on MSVC 2012-09-20 08:15:12 -05:00
jean-pierre charras 2062cf8fe4 eeschema: plot functions: code cleaning.
SVG plotter: fix issues in draw arc and draw rectangle.
2012-09-18 16:50:30 +02:00
jean-pierre charras 3e15da5bcc Eescheam: plot HPGL: add comments and minor fix. 2012-09-18 10:39:56 +02:00
jean-pierre charras 520eace689 eeschema: plot dialog: minor fix 2012-09-17 21:28:17 +02:00
jean-pierre charras 9ed3c5dc46 Eeschema: Plot dialogs: unify 5 dialogs (which means 5 duplicate code) to only one plot dialog (like in Pcbnew)
remove duplicate code and clean it.
Simplify HPGL dialog: plot offet removed and replaced by only one option:
plot origin to center of sheet or not (some HPGL  plotters have the plot origin to center of the paper area,
and others have this origin at the bottom left corner)
This is surely enough.
2012-09-17 20:39:42 +02:00
Marco Mattila 7db3834f0b Move pcbnew pcb edge layer plot checkbox to common plot options 2012-09-17 21:14:41 +03:00
jean-pierre charras 5979b1a1b6 Add missing files 2012-09-17 19:56:40 +02:00
jean-pierre charras d283a8c878 Eeschema: Plot dialogs: unify 5 dialogs (which means 5 duplicate code) to only one plot dialog (like in Pcbnew)
clean duplicate code.
Simplify HPGL dialog: plot offet removed and replace by only one option (plot origin to center of sheet or not)
This is surely enought.
2012-09-17 19:42:27 +02:00
jean-pierre charras 3f2a258930 Pcbnew: added: SVG plotter. Need refinements, but works.
Mainly to plot drill maps, but can be used to plot boards, for documentation.
The print svg still exists, but the plot SVG has more options (mirroring, holes in pads),
however  print svg allows color print, and full board printing, and plot does not.
2012-09-15 14:13:03 +02:00
jean-pierre charras 550d36dc33 Pcbnew: fix minor issue when loading a foorprint: if the footprint name has lower case letters, the name was asked twice 2012-09-13 14:15:24 +02:00
jean-pierre charras 46b9d9e359 All: fix most of Doxygen warnings. 2012-09-12 19:28:55 +02:00
jean-pierre charras 3e084a3b0e Pcbnew: fix compil error I created in my previous commit.
All: fix some Doxygen warnings
2012-09-12 13:11:30 +02:00
jean-pierre charras 391a663360 All: better code to handle opened frames libview, libedit, modview, modedit.
Other minor fixes.
2012-09-12 11:53:11 +02:00
jean-pierre charras 068ae2f344 Code cleaning, minor fixes and minor coding style fixes. wxWidgets 2.9.4 compatibility fix( deprecated function MakeModal ) 2012-09-11 21:03:21 +02:00
jean-pierre charras 64dfea78b8 Pcbnew: drag functions: serious cleanup and better code. Use now the connectivity functions to find tracks connected to pads,
and therefore  tracks are now dragged when a end point is inside a pad, not necessary on the pad position.
However, drag functions still need more cleanup.
2012-09-11 09:33:17 +02:00
jean-pierre charras 3bbcd30396 Pcbnew: cleanup functions: now, cleanup uses same algorithm as connectivity calculations to detect pads connections, and is faster.
therefore tracks which have a end point inside a pad, but not necessaryexactly  to the pad position are seen as connected, and are no more removed.
Side effect: reconnect to pads option is removed, because it is useless.
TODO: use this algorithm in drag functions.
Minor other fixes
2012-09-07 21:29:44 +02:00
Dick Hollenbeck 09bfd3311c apply DIALOG_SHIM to dialog_lib_edit_text_base and make dialog_lib_edit_pin_base apportion more width for pin name 2012-09-07 11:15:18 -05:00
Lorenzo Marcantonio fdd0e02c35 Substituted the few remaining uses of long instead of time_t 2012-09-05 14:13:33 +02:00
jean-pierre charras 10b5322b87 The last one compil error fix. 2012-09-02 19:53:34 +02:00
jean-pierre charras f01feef636 fix compil errors 2012-09-02 18:38:52 +02:00
Lorenzo Marcantonio 1aed2b3114 Another fix for wx2.9 compilation (same issue as before, another call...) 2012-09-02 17:46:19 +02:00
Lorenzo Marcantonio adc9b70d72 Probable fix for compilation under wx 2.9 (doesnt hurt anyway) 2012-09-02 16:13:50 +02:00
Lorenzo Marcantonio 5f86a70891 Enforced EDA_COLOR_T type and minor const-ification 2012-09-02 14:06:47 +02:00
Lorenzo Marcantonio ea9a84b748 Enforced EDA_COLOR_T type and minor const-ification 2012-09-02 13:01:12 +02:00
Lorenzo Marcantonio c73ca9a6da Encapsulated drawmode as an enum for type checking 2012-09-01 15:38:27 +02:00
jean-pierre charras e467e58857 Modedit: very minor enhancements. 2012-08-31 21:19:48 +02:00
Marco Mattila bb73777a4a Take pad clearance into account in intersection detection during pcbnew zone filling. 2012-08-31 21:43:09 +03:00
jean-pierre charras a63a62f827 Pcbnew: fix bug: deleting a cutout in a zone was not undoable. 2012-08-31 17:59:14 +02:00
jean-pierre charras 1c6574e69d Fix 0 length segment in outline zone creation, that breaks zone chamfer option. 2012-08-31 15:58:23 +02:00
jean-pierre charras 313785b421 Pcbnew: in SVG export, add option to export only the board area, not the full page.
dialog plot functions: fix compil warnings with wxWidgets 2.8
2012-08-31 09:43:37 +02:00
Lorenzo Marcantonio b6261f3d80 Refactored PCB plot infrastructure
Removed filename from the BASE_SCREEN class
Scripting support for board plot
2012-08-30 21:25:12 +02:00
Lorenzo Marcantonio 3dc4de85b5 Fully encapsulated with accessors PCB_PLOT_PARAMS 2012-08-30 20:06:13 +02:00
Lorenzo Marcantonio bb0711eb3f Minor plot driver enhancements 2012-08-29 22:13:47 +02:00
Lorenzo Marcantonio 0cb647ee1e Removed g_pcb_plot_options from gerbview (which has no plotting anyway...) 2012-08-29 20:43:51 +02:00
Lorenzo Marcantonio 5a0c37e2b9 Removed PCB_BASE_FRAME::m_printBorderAndTitleBlock (all dead code) 2012-08-29 20:34:34 +02:00
Lorenzo Marcantonio 4a3ddd5b2c const-ifiation of member 2012-08-29 19:35:23 +02:00
Lorenzo Marcantonio e6095e6fd8 Added 'parachute' std::exception handling to python interface 2012-08-29 19:32:14 +02:00
Lorenzo Marcantonio 33d1d0f8e4 Added MEASUREMENT sysvar to DXF driver, marks explicitly the file as metric 2012-08-29 19:31:00 +02:00
Lorenzo Marcantonio d02025b0ed Fixed format string (spurious character was added) in HPGL driver 2012-08-29 19:29:45 +02:00
Lorenzo Marcantonio 28af99d95d Fixed compilation with unicode (wxString to printf without GetChars) 2012-08-29 19:28:33 +02:00
Lorenzo Marcantonio 619c8e689a Script plotting patch 2012-08-29 18:59:50 +02:00
jean-pierre charras c03355d67f Minor cosmetic enhancements.
Kicad manager: shows now svg files in tree files.
Pcbnew: fix incorrect printing (board out of page) when creating drill map in postscript format ( noticeable mainly for small boards)
2012-08-29 14:40:09 +02:00
Lorenzo Marcantonio 417572f3c5 Missing a wxT in call to LogDebug 2012-08-29 13:28:37 +02:00
Dick Hollenbeck c5ed76f104 wxFileName::CreateTemporaryFile() is switching to /tmp directory when no preceding path is present 2012-08-28 10:41:08 -05:00
jean-pierre charras 5721a279c8 Pcbnew: Fix bug 1042394 and very minor code cleaning. 2012-08-28 08:51:18 +02:00
jean-pierre charras 0cf8553b2e 3D viewer: code tweaking 2012-08-27 13:41:22 +02:00
jean-pierre charras 6d5b865741 3D viewer: fix a very minor issue, and more code cleaning. 2012-08-27 09:06:52 +02:00
jean-pierre charras 7b08e81991 3D viewer: fix very minor issue. Remove duplicate code 2012-08-26 20:10:28 +02:00
jean-pierre charras 6d4e0ff665 3D viewer:
*  serious code cleanup (remove duplicate code)
  *  shows (option in 3D preference menu) the copper items (tracks, zones...)  in 3D, using 35 microns copper thickness.
      However, because there are a lot more3D data to show (roughly 4 times more), this is slower.
2012-08-26 15:59:55 +02:00
Dick Hollenbeck bd6ea96ed6 wxServer was a confusing define, since it is also a wxWidgets class, do not use it 2012-08-24 06:31:09 -05:00
Gregor Riepl 9feccc625b The listener is opened on INADDR_ANY, so it will accept any network
connection, no matter if it is originating locally or from the outside
of the host. There is no check in place to discard non-local
connections. The only security against a malicious attack would be
provided by a local firewall, which is not guaranteed to be installed on
every workstation kicad is used on.

I tested this, and a host running eeschema accepts connections on TCP
port 4243 from other hosts on the internet.

A patch to remedy this potentially serious security hole is attached. It
creates the listener on localhost instead. A flag is provided to allow
the creation of sockets on 0.0.0.0 instead, if required. localhost is
the default.
2012-08-24 06:19:52 -05:00
Dick Hollenbeck 65949662f6 *) 64 bit size_t is not compatible with %u printf format control. use "%zu"
where the 'z' prefix is for size_t arguments.

*) minor beautification
2012-08-24 06:14:10 -05:00
jean-pierre charras 22defb9ad4 3d-viewer and polygon functions: remove duplicate code about conversion from basic shapes to polygons. 2012-08-23 21:15:58 +02:00
Marco Mattila 37cb4d00df Fix pcbnew thermal stub removal for pads with locally defined thermal properties. 2012-08-22 23:16:21 +03:00
jean-pierre charras a48c0ece4b 3D-viewer: code cleanup.
Eeschema: annotate and netlist dialogs: enhancements.
Minor  coding policy fixes and  changes.
2012-08-21 12:45:54 +02:00
Dick Hollenbeck b8c77dc417 work around wx2.8 wierdness 2012-08-16 10:34:41 -05:00
Dick Hollenbeck ed42ae5a79 fix problem with eeschema print dialog showing up on missing monitor 2012-08-15 12:55:48 -05:00
Dick Hollenbeck 20f83297ce legacy plugin fully support text horiz/vert justification, eagle plugin text fixes 2012-08-11 14:14:45 -05:00
jean-pierre charras 896dc0fcf6 3D-viewer: code cleaning. Added option in menu: show a 3D grid.
All: press ctrl+shift key when moving the mouse allows the graphic cursor to be moved outside the grid.
(useful to place graphic objects, texts in any position, regardless the current grid)
2012-08-11 14:52:13 +02:00
Dick Hollenbeck f8a238e670 fixes for plugins 2012-08-11 00:50:17 -05:00
Miguel Angel Ajo 3b8f2a551b pcbnew: Show/Hide button for scripting console 2012-08-10 23:53:50 +02:00
Miguel Angel Ajo 2263633df8 pcbnew: fix bug 1033510 that crashes pcbnew when no footprint wizard is selected 2012-08-06 22:41:41 +02:00
Miguel Angel Ajo 59b7a8ff8f pcbnew: footprint wizards now can export the output module to the library or board 2012-08-05 00:15:57 +02:00
jean-pierre charras 9e6b63e3da Pcbnew: fix a minor issue in non copper zones when creating the solid filled areas. 2012-08-04 18:33:04 +02:00
jean-pierre charras 5eb63c42f1 Remove Kbool from Kicad. Use Clipper instead.
Clipper is, by far, more easier to use than Kbool, and is currently actively maintained.
It is used only to normalize polygons, i.e. to convert self intersecting polygons to simple polygons,
which is not possible with boost::polygon.
2012-08-04 13:52:04 +02:00
jean-pierre charras 1bba1c5ee0 Remove Kbool from Kicad. Use Clipper instead, last changes 2012-08-04 13:47:24 +02:00
jean-pierre charras f7047d3cfa Remove Kbool from Kicad. Use Clipper instead. 2012-08-04 11:43:27 +02:00
jean-pierre charras cb16951519 Very minor fixes. 2012-08-03 17:43:15 +02:00
jean-pierre charras 14dc5709ee Eeschema: fix crash when changing a label type to an other label type during creation.
Pcbnew: code cleaning in polygon functions
2012-08-02 19:36:14 +02:00
jean-pierre charras 7d03b0af33 Polygon code cleanup 2012-08-02 19:32:42 +02:00
Miguel Angel Ajo 33f7d83c71 scripting + pcbnew: Merged with scripting branch, now it supports -DKICAD_SCRIPTING_WXPYTHON for full wx integration with python 2012-08-02 19:31:39 +02:00
Miguel Angel Ajo e469a6b3d8 pcbnew scripting: cleanup, renamed KICAD_SCRIPTING_EXPERIMENT to KICAD_SCRIPTING_WXPYTHON, now every flavour compiles 2012-08-02 19:24:53 +02:00
jean-pierre charras 2971ea6564 Eeschema: fix crash when changing a label type to a global label during creation.
Pcbnew: code cleaning in polygons
2012-08-02 15:23:53 +02:00
Miguel Angel Ajo 02ced9a339 scripting: fixed kicad compilation, cleanups 2012-08-02 09:47:30 +02:00
Miguel Angel Ajo 1960a8768e pcbnew: wxPyBeginBlockThreads before every python call 2012-08-01 14:50:21 +02:00
Miguel Angel Ajo f4c8abb1b4 Double Python initialization fixed 2012-08-01 13:54:20 +02:00
jean-pierre charras ab9630b825 PolyLine and math_for_graphics code cleanup: remove arc support in CPolyLine class:
This is an obscure legacy code from FreePCB, never used, never tested, never maintained.
2012-08-01 10:08:37 +02:00
jean-pierre charras e79d6ae971 Cleanup math_for_graphic code 2012-08-01 09:07:56 +02:00
Miguel Angel Ajo 0348e13258 pcbnew scripting: fixed for coding style policy 2012-07-31 23:00:33 +02:00
jean-pierre charras 40c7c7dae8 Remove freepcb arc legacy code from PolyLine. 2012-07-31 19:51:58 +02:00
jean-pierre charras 396695c866 Remove arcs support in zone outlines: this is a legacy code from FreePCB, never used, never tested, never maintained. 2012-07-31 15:12:51 +02:00
jean-pierre charras a07ae76bcc Fix issues in zones creation (DRC and merging) I created in 3658.1 2012-07-30 09:40:25 +02:00
Miguel Angel Ajo 0221700226 merged divertion 2012-07-30 00:24:40 +02:00
Miguel Angel Ajo d8f3424554 pcbnew: scripting, Capacitive Touch Slider Wizard 2012-07-29 23:40:41 +02:00
jean-pierre charras 623234c7c2 More work on a better support of polygons in Kicad (code cleaning). 2012-07-25 20:46:25 +02:00
jean-pierre charras 49aff4eba3 Start work on a better support of polygons in Kicad (code cleaning).
Some coding style policy fix.
2012-07-25 09:36:56 +02:00
Miguel Angel Ajo 9281d15c70 Footprint wizard converts from user units to internal units back and forth, so user can type in mm or mils now 2012-07-23 00:23:17 +02:00
Miguel Angel Ajo e482826ac3 .dso -> .pyd is the right extension for python .dll WIN32 2012-07-22 14:19:52 +02:00
Miguel Angel Ajo 49e2e292dd Adam Vašíček patches for WIN32 compilation of kicad scripting 2012-07-22 14:15:38 +02:00
jean-pierre charras d721f176f8 Eeschema: fix a bug that crashes eeschema (only when compiled in debug mode) when creating a new wire, and when any wire orientation is allowed. 2012-07-21 18:52:29 +02:00
Marco Mattila 58532cd8c5 Fix axis offset issue in pcbnew gerber circular interpolation. 2012-07-18 22:32:47 +03:00
Marco Mattila 37fe3ca01a Edit eeschema single part per line sorting code. 2012-07-17 22:13:35 +03:00
jean-pierre charras 1a01535313 Libedit and Modedit: fix minor, but annoying issues when editing items 2012-07-17 17:29:29 +02:00
Marco Mattila 2ba0f5d807 Fix eeschema single part per line bom generation. 2012-07-16 21:49:04 +03:00
Miguel Angel Ajo 48fa8fd20b Fixes Win32 compilation that my previous commit broke, thanks to JP 2012-07-16 16:48:51 +02:00
jean-pierre charras eeb179fc9a Pcbnew: Fix crash after opening footprint wizard 2012-07-16 15:34:08 +02:00
jean-pierre charras 76d1abb9ca Fix compil issues under mingw 2012-07-16 11:19:23 +02:00
Miguel Angel Ajo 68d2aed8af Python scripting and fixes for non-scripting compilation 2012-07-16 07:53:22 +02:00
Miguel Angel Ajo dfdecb7e0b Merged with testing 2012-07-15 22:38:25 +02:00
Miguel Angel Ajo 2b54414e60 Support for nanometer build, extra example 2012-07-15 22:01:05 +02:00
Marco Mattila 2f03f95e9d Use circular interpolation for circles and arcs in pcbnew gerber plots. 2012-07-15 20:28:52 +03:00
jean-pierre charras a828d714c6 Pcbnew: more about keepout areas: remove keepout for pads option and add keepout for copper zones option.
Export keepout to Specctra DSN file.
2012-07-14 18:27:25 +02:00
jean-pierre charras e36a3dd460 Pcbnew: Add keepout areas (Copper zones without tracks or/and vias).
This is *a work in progress*, so some features are missing, and/or could be modified.
Mainly keepout zones are not yet exported to autorouters, and pads are not taken in account.
Some code cleanup in polygon.*
2012-07-13 20:55:29 +02:00
jean-pierre charras b60fda3fec Eeschema: fix compatibility issue with wxWidgets 2.8.12 2012-07-12 17:01:14 +02:00
jean-pierre charras 590b237338 Eeschema: fix compatibility issue with wxWidgets 2.8.12 2012-07-12 16:59:06 +02:00
unknown 237592fbda All: Fix Assertion on sheet properties, in debug mode 2012-07-11 10:02:47 +02:00
jean-pierre charras 9a6a301c4f Eeschema: fix wrong bitmap size in hierarchy navigator tree 2012-07-10 14:26:26 +02:00
jean-pierre charras 064c057200 Pcbnew: commit Lorenzo Marcantonio's patch for THT thermals (added loading/saving using S. expr).
Fix incorrect import of smd pads from Gpcb.
Very minor change in dialog print.
2012-07-09 09:10:07 +02:00
Marco Mattila d1077e6171 Add rotation field to pcbnew text item property dialog. 2012-07-09 01:02:00 +03:00
Dick Hollenbeck b90e483117 fix for bug 1022026 2012-07-07 13:27:44 -05:00
Miguel Angel Ajo ad25f4c43a Cleanup toward test-merge 2012-07-06 21:10:55 +02:00
Wayne Stambaugh de22ae4a99 Save and load print parameters and minor code cleaning in new Pcbnew file format. 2012-07-05 13:02:45 -04:00
jean-pierre charras d166463bca Eeschema: bug fix: when creating new connections, junctions were not always automatically added when needed.
Fix an other minor bug.
2012-07-05 13:37:48 +02:00
jean-pierre charras ef326260c2 Pcbnew: fix incorrect detection of arcs having angles != 90 degrees 2012-07-05 11:29:42 +02:00
Marco Mattila a969e87f13 Add copy to text items in pcbnew. Automatically mirror text items added to back silkscreen (bug 1017446). 2012-07-04 22:50:47 +03:00
jean-pierre charras 532fb73c43 Pcbnew, gen Excellon files: fix truncation coordinates in decimal format, units = inches (old bug)
Coordinates were using always 3 digits (1/1000 inch  for mantissa). Uses now 4 digits max in inches and 3 digits max in mm
The resolution is therefore 1/10000 inch or 1/1000 mm. Note this is a limitation of Excellon format.
2012-07-03 15:46:58 +02:00
jean-pierre charras 0c79aa30ab Pcbnew: fix 2 minor issues, noticeable only in debug mode.
When reading board files, the net 0 was stored twice.
It creates only log messges in debug mode, because the list of nets is rebuild after reading files.
2012-06-30 10:20:04 +02:00
Miguel Angel Ajo cd68572df5 code cleanup and comments 2012-06-27 23:19:19 +02:00
jean-pierre charras a37cc75bd7 Pcbnew: save/load .kicad_pcb files: fix 2 minor issues.
Use now English layers names to build filenames in plot functions (for techical layers), because translated names create sometimes problems in filenames.
(should do not change anything for English users)
Fix compil issue under wxGTK 2.8.12, created by my recent commit.
Minor changes to make translations easier.
2012-06-27 22:11:04 +02:00
jean-pierre charras 3b8118ac0b Pcbnew: save/load .kicad_pcb files: fix 2 minor issues.
Use now English layers names to build filenames in plot functions (for techical layers), because translated names create sometimes  problems in filenames.
(should do not change anything for English users)
2012-06-27 22:07:37 +02:00
jean-pierre charras bdf725f86b Pcbnew: fix compil issue under wxGTK 2.8.12 2012-06-26 22:18:01 +02:00
jean-pierre charras c8866b7d4c Pcbnew: minor changes in pcb-parser.cpp and kicad_plugin.cpp to make translations easier.
Code cleaning in autoroute functions.
2012-06-26 19:57:37 +02:00
Jean-Pierre Charras 552b211124 Commit JP's custom page size fix for Pcbnew s-expressions file format with minor changes. Thanks JP. 2012-06-25 19:52:57 -04:00
jean-pierre charras 680fe999b2 All: fix a truncation issue in ReturnValueFromString that creates sometimes a small error for values entered in dialogs.
Pcbnew: fix a compatibility issue with nano version for zones parameters.
2012-06-25 22:59:19 +02:00
Miguel Angel Ajo 1e380374eb merge with lp:kicad 2012-06-25 22:51:19 +02:00
Dick Hollenbeck 25705ad61b use the same format string in the test program as in LEGACY_PLUGIN for record keeping purposes 2012-06-25 09:44:47 -05:00
Dick Hollenbeck 6351d5a283 remove "long double" dependency, mingw was falling over when using it. 2012-06-24 13:41:37 -05:00
Wayne Stambaugh 1666e12db2 Minor Pcbnew s-expression improvements.
* Put text effects on a single line.
* Remove size token when defining drill sizes.
* Don't save net in pad definition when pad has no connection.
2012-06-23 21:19:41 -04:00
Dick Hollenbeck 728cbcdff4 bzr add test program to verify new conversion strategy 2012-06-23 19:44:02 -05:00
Dick Hollenbeck bd047624e5 legacy_plugin was not round tripping nanometers, add test program to verify new conversion strategy 2012-06-23 18:21:03 -05:00
jean-pierre charras 0e8f5b8147 Fix an issue (only found using gcc under mingw) in dsnlexer.cpp, using ::isspace( ) function that accepts only a 7 bit ASCII value under gcc/ mingw. 2012-06-20 22:33:05 +02:00
jean-pierre charras 45d4353cf4 Pcbnew: small cosmetic enhancement: add a bitmap for zone duplicate command. 2012-06-20 11:57:36 +02:00
Moses McKnight c7455ca776 Commit patches from Moses McKnight, to avoid duplicate junctions. 2012-06-20 11:52:29 +02:00
jean-pierre charras 5def0c2eea Pcbnew: fix incorrect arc export in SVG file export.
Very minor other fixes.
2012-06-19 21:25:41 +02:00
Dick Hollenbeck 9e4090f601 DIMENSION::m_Value not being saved in LEGACY_PLUGIN using scaling, DIMENSION::AdjustDimensionDetails() uses arrowz appropriate to build 2012-06-18 23:53:08 -05:00
Dick Hollenbeck d1a8ecca70 a) (zone (fill (mode was wrong, b) put fill on one line 2012-06-18 23:23:42 -05:00
Dick Hollenbeck 69415616f8 parsing problem was unbalanced (smoothing) element 2012-06-18 23:08:00 -05:00
jean-pierre charras 7eec35e4ea Pcbnew: Fix an other compatibility issue in kicad nanometers. 2012-06-17 20:29:11 +02:00
jean-pierre charras f76bf37229 Pcbnew: fix issues in kicad nanometer in zone ediition and detection.
autoroute functions: code cleaning
2012-06-17 18:06:12 +02:00
Wayne Stambaugh 5c335f3acc Pcbnew s-expression file parser bug fixes and file size improvements.
* Use index when saving layers to handle translated layer names.
* Add LOCALE_IO switcher when loading s-expression format.
* Make SEGVIA default to through hole to improve file size.
* Don't save default orientation of 0 degrees in TEXTE_MODULE and TEXTE_PCB.
* Don't save default zone configuration parameters.
* Save multiple zone corners on a single line.
* Fixed missing ( check in graphic and module arc parsers.
* Consistency improvements for DRAWSEGMENT and EDGE_MODULE objects.
* Minor tweaks to D_PAD formatting.
2012-06-16 18:49:24 -04:00
jean-pierre charras 98f91f8b0a Pcbnew: automatic selection of plugin when loading a file with .kicad_pcb extension from history list.
Very minor other fixes
2012-06-14 21:10:32 +02:00
jean-pierre charras 93e568b254 fix incorrect use of KIROUND instead of KiROUND in parseBoardUnits( const char* aExpected ) (see comments in .h file)
very minor fix in pcb_parser.cpp
Fix scaling issue with nanometers in gpcb footprint import.
2012-06-14 08:29:54 +02:00
Andrey Fedorushkov e86579b576 pcbnew: minor fix printf in pcb_parser 2012-06-14 09:34:18 +04:00
Wayne Stambaugh 672ffefb5f Pcbnew s-expression file parser bug fixes.
* Change save order of drawings to match legacy file format object order.
* Set end point of SEGVIA to start point so the round trip back to legacy
  format is the same.
* Fixed bug saving and loading oval pad drill parameters.
* Fixed bug saving and loading rectangular pad deltas.
* Fixed missing layer for PCB_TARGET.
* Fixed EDA_TEXT italic bug.  Thanks Dick!
* Remove some left over debug logging statements.
2012-06-13 19:04:42 -04:00
Andrey Fedorushkov c500a6704e pcbnew: show clearance when move or drag via 2012-06-13 17:32:43 +04:00
jean-pierre charras 3e0c355d7b Pcbnew: fix issue about order of tracks this order was modified when reading and writing a board, even without any change in board.
Fix compil warnings and wx28 compatibility.
code cleaning in autoroute functions.
2012-06-11 14:04:34 +02:00
jean-pierre charras 87da1b2d0c fix compil warnings 2012-06-11 07:40:52 +02:00
Dick Hollenbeck 0d45084914 Commit Dick's Pcbnew s-expression file parser bug fixes.
* Apply Dick's patch along with a few minor changes to fix some clashes with
  changes in my branch.  Thanks Dick!
* Added missing DRAWSEGMENT line angle.
* Fix thru hole pad layer mask issue.
2012-06-10 20:47:15 -04:00
jean-pierre charras 9097433898 Pcbnew: Fix compil issues with wxWidgets 2.8.12
Some code cleaning in autoroute functions.
2012-06-10 18:21:18 +02:00
Dick Hollenbeck 0b704e356f CPolyPt constructors 2012-06-10 04:48:42 -05:00
Dick Hollenbeck d847d5b942 There was no reason for insertBeforeMe on track loading.
Tracks should be loaded in the same order as they were saved, no exceptions.
This is for the version control system user.
But even with this objective now implemented in LEGACY_PLUGIN, the TRACKS
are still going through a food processor after they are loaded, and the poor
version control system user has no relief, even with this patch.

TRACKS are always modified after being loaded, and I think this needs to be fixed still.
2012-06-09 19:39:40 -05:00
Wayne Stambaugh 694c900cd4 Added file include/convert_from_iu.h left out of last commit. 2012-06-09 14:00:30 -04:00
Wayne Stambaugh 9204086f41 Add Pcbnew s-expression file parser.
* Add s-expression file parser object and keyword files.
* Fix minor issues with s-expression file formatting.
* Fix a minor bug the zone container fill state parsing in the legacy plugin.
* Move EDA_TEXT visibility definition to eda_text.h.
* Add minor BOARD_ITEM object improvements to support s-expression file
  parser.
2012-06-09 13:00:13 -04:00
jean-pierre charras d8395dfeb6 Fix some minor bugs in plot functions 2012-06-09 11:38:58 +02:00
jean-pierre charras 39f84d7fe4 Pcbnew: Update incorrect or incomplete copyrights in many files.
Minor code cleaning in autoroute files.
2012-06-08 11:56:42 +02:00
Dick Hollenbeck bbc8c1121f EAGLE_PLUGIN::Load() is now completed. 2012-06-06 21:23:47 -05:00
Dick Hollenbeck 383ffdfe0a EAGLE_PLUGIN::Load() is now completed. 2012-06-06 20:49:43 -05:00
Ryan Bunch 8c89c1daf5 allow comments in library files 2012-06-06 09:12:39 -05:00
jean-pierre charras 706337b8ea Pcbnew: move files relative to autoroute/autoplace to autorouter folder.
fix nanometer compatibility.
minor code and comments cleaning (although theses files need a lot of code cleaning)
2012-06-05 21:09:30 +02:00
jean-pierre charras 9f67477858 Pcbnew: move files relative to autoroute/autoplace to autorouter folder.
fix nanometer compatibility.
minor code and comments cleaning (although theses files need a lot of code cleaning)
2012-06-05 21:07:33 +02:00
Marco Mattila b703d81561 Add missing checks and undo support to pcbnew zone duplication. 2012-06-05 14:44:22 +03:00
Dick Hollenbeck 9e8be6cd28 EAGLE_PLUGIN: read a portion of the design rules and calculate
pad and via sizes from those settings when diameter is not given
in the local object.  Calculation algorithms are inferred from the
UI help of the Eagle program.

For edge connector type of footprints, some copper pads can be on the
back side even within packages.

Flipping of packages to back was not being done correctly, but I think this 
is working now.

There are still remaining issues with text positioning that I am working on.
2012-06-04 23:39:37 -05:00
Marco Mattila 250960f771 Add zone duplication to pcbnew. 2012-06-04 22:04:12 +03:00
Miguel Angel Ajo bbfb0d669c merges tip, conflict resolved 2012-06-03 22:21:53 +02:00
Miguel Angel Ajo ad14802227 merge 1 with tip 2012-06-03 22:06:51 +02:00
jean-pierre charras d5b1087fb8 Appying lajos' patch to boost 1.49 2012-06-03 19:41:49 +02:00
jean-pierre charras 150b7cd4e2 Fix eagle_plugin issue (File not found) under Windows. 2012-06-03 17:47:53 +02:00
jean-pierre charras 20fc8ee3cc Eeschema: Fix incorrect display refresh when editing the reference of a component from the popup menu. 2012-06-03 13:16:08 +02:00
Marco Mattila 47877ec70c Do some ZONE_CONTAINED encapsulation. 2012-06-03 00:19:17 +03:00
Dick Hollenbeck 91e8aca0a9 EAGLE_PLUGIN: finish xpath error reporting mechanism for XML document traversal 2012-06-02 12:07:30 -05:00
jean-pierre charras f809cc2db7 CvPcb: fix focus issue when the display footprint frame is shown (the footprint list loses the focus each time a new footprint is selected, therefore the keyboard cannot be used to select footprints) 2012-06-01 14:03:50 +02:00
Dick Hollenbeck b07caa93c9 EAGLE_PLUGIN: load layer definitions, zone parameters, text positions.
Sketch for BOARD::Move().  Pass page_width and page_height to PLUGIN::Save().
2012-06-01 02:39:32 -05:00
jean-pierre charras a65c42b7d8 Cvpcb: code cleaning and minot fix 2012-05-31 19:41:37 +02:00
Dick Hollenbeck 583006b599 EAGLE_PLUGIN add mechanical "hole" support for both MODULEs and BOARD 2012-05-31 10:18:55 -05:00
jean-pierre charras 29b5837a91 Eeschema, Libedit: Fix bug that can crashes Eeschema: In libedit 2 mandatory fields could be deleted. Fixed now.
Very minor other fixes.
2012-05-31 15:47:02 +02:00
Dick Hollenbeck 26eadad611 EAGLE_PLUGIN now positions text correct for most cases 2012-05-30 16:40:32 -05:00
Marco Mattila 0aafa5a591 Add flip to pcbnew text fields. 2012-05-30 20:38:52 +03:00
Dick Hollenbeck 0a42863bd1 add translation to static file filters, comments 2012-05-30 09:14:42 -05:00
Dick Hollenbeck a1f23f3a4c generalize the BOARD loading process PCB_EDIT_FRAME::LoadOnePcbFile() to use any supported PLUGIN 2012-05-29 16:01:17 -05:00
Marco Mattila badef10f41 Derive pcbnew find dialog from DIALOG_SHIM. 2012-05-29 23:43:17 +03:00
Dick Hollenbeck f1284bd73c Mostly EAGLE_PLUGIN work:
* Derive the pcbnew copper zone and non-copper zone dialog windows from DIAG_SHIM,
  which injects some template code.
* Update UIpolicies.txt to talk about DIALOG_SHIM support.
* Add zone support to eagle_plugin.
* Organize ZONE_CONTAINER class declaration for future privacy and accessors.
2012-05-29 13:10:56 -05:00
jean-pierre charras d2926d2edf Pcbnew: menu Edit/Reset modules fields size: Add dialog to select what modules are modified. 2012-05-29 14:25:10 +02:00
Marco Mattila da45f02f6a Move pcbnew find dialog into dialogs subdirectory and use wxFormBuilder for it. 2012-05-28 23:01:51 +03:00
Lorenzo Marcantonio 67a3a7521f Rename BASE_SCREEN member m_NumberOfScreen to m_NumberOfScreens. 2012-05-26 20:19:12 -04:00
Lorenzo Marcantonio 699f87c617 Remove unused definitions in bitmaps.h. 2012-05-25 11:00:51 -04:00
Andrey Fedorushkov a568ed2bd8 eeschema: fix set bus width when define KICAD_GOST 2012-05-25 18:33:58 +04:00
jean-pierre charras 6b4366a0a4 Pcbnew: fix crash in legacy_plugin.cpp when reading old lib files.
fix a compil warning.
CvPcb: fix regressions :
 Shows now a void field instead of the dummy footprint name $nonane (whenthere is  no footprint selected in netlist).
 The active footprint selection changes only if a new component is selected from the component file,
 and does not change just when the next component is automatically selected, after a footprint selection.
 Speed up delete association and auto associe.
2012-05-25 08:58:52 +02:00
Lorenzo Marcantonio 5aa957bcff Rationalize numeric time stamps to type time_t. 2012-05-24 21:52:04 -04:00
Dick Hollenbeck f22b5abfac more amazing free eagle_plugin work 2012-05-24 10:00:59 -05:00
unknown 8811f5053d Commit patch from Brian Sidebotham (Bus width value option) 2012-05-24 08:51:52 +02:00
Dick Hollenbeck b16571bb86 more eagle plugin work 2012-05-23 20:18:30 -05:00
Andrey Fedorushkov d12cf29322 Pcbnew: fix control data valid in design rules when define USE_PCBNEW_NANOMETRES 2012-05-23 18:25:15 +04:00
jean-pierre charras 7c8c7984a1 Libedit: fix minor bug: Copy doc not working in Properties dialog. 2012-05-23 12:06:33 +02:00
Dick Hollenbeck a35ddcd0e1 more eagle_plugin work 2012-05-22 12:51:18 -05:00
Dick Hollenbeck ddc95bc7f7 fix bug added two revisions ago by me 2012-05-21 13:50:46 -05:00
jean-pierre charras ce99a71a52 Eeschema: Fix a minor issue in block command
Very minor code cleaning
2012-05-20 21:18:06 +02:00
Dick Hollenbeck 9882eef93a eagle plugin first work 2012-05-20 08:14:46 -05:00
jean-pierre charras 140667308d Very minor fixes. 2012-05-19 21:04:03 +02:00
jean-pierre charras f50859fd09 Pcbnew: fix bug Bug #1001107 (Solder Mask Ratio Clearance bad value)
Because this bug could create bad values in footprint libraries, this parameter is now checked
when reading a footprint description in legacy format
2012-05-18 10:33:57 +02:00
jean-pierre charras 86267bd8d6 Fix 2 minor warning compil (unused variables) 2012-05-16 22:44:21 +02:00
jean-pierre charras e5f6738280 Fix compil issues with gcc 4.6 and boost 1.49 2012-05-16 18:59:47 +02:00
Dick Hollenbeck d6acc8debe move boost update script to out of way place, fix bug in it 2012-05-16 07:01:40 -05:00
Miguel Angel Ajo 84c562de1c Footprint wizard, plus fixes 2012-05-16 11:35:18 +02:00
Dick Hollenbeck ddd6bb632a bring in skeleton for eagle_plugin and update boost for use of RapidXML within property_tree 2012-05-15 21:27:27 -05:00
Dick Hollenbeck 85b69b8689 move all hashtable declarations into include/hashtables.h, prepare for boost usage 2012-05-15 21:00:25 -05:00
Dick Hollenbeck b2837d38b8 update to boost 1.49.0 subset 2012-05-15 20:42:04 -05:00
Dick Hollenbeck 06582b4cf9 try to delete a footprint library before exporting or creating, quietly 2012-05-15 08:58:55 -05:00
henner zeller f5d0863b2e commit patch from henner zeller (make EDA_LIST_DIALOG resizable) 2012-05-14 17:23:20 +02:00
jean-pierre charras f05c0cd6ce Libedit: fix Bug #994014.
Pcbnew: fix Pcbnew name capitalization in messages.
About dialog: add a link to kicad-pcb.org
2012-05-13 17:31:58 +02:00
jean-pierre charras 223642904f Remove PCB_INTERNAL_UNIT define because it is no more used in code.
3D viewer: fix incorrect scaling factor when using nanometers.
Very minor other fixes
2012-05-11 11:02:35 +02:00
Miguel Angel Ajo 8317e918d9 wxGrid instead of list, now we do really have values... 2012-05-11 00:30:26 +02:00
Miguel Angel Ajo d497b62fb3 Cosmetic fixes, before moving to wxGrid 2012-05-10 22:49:07 +02:00
jean-pierre charras 014ba087a8 Gerbview: fix incorrect processing of ICI command in Excellon drill files. 2012-05-10 13:02:44 +02:00
Miguel Angel Ajo dfa1f480b5 Footprint wizard UI gets the module from python wizard, and show it 2012-05-10 10:53:05 +02:00
Miguel Angel Ajo 9ce8fcd268 * Read string array results from python methods~ 2012-05-10 08:44:08 +02:00
jean-pierre charras 6bd07d3d63 Fix capitalization issues in title bar and config files (broken by bzr rev 3543) 2012-05-10 08:25:27 +02:00
Miguel Angel Ajo 125d820dac footprint wizard UI and footprint wizard lists 2012-05-10 01:04:08 +02:00
Miguel Angel Ajo f77f7e645b * Footprint wizard UI: Added to module editor.
* Footprint wizard C++ generic classes
* Footprint wizard C++ to python wrappers 
* Automatic plugin loader from ~/.kicad/plugins
* Python plugin architecture: Footprint wizards
2012-05-09 19:37:25 +02:00
Dick Hollenbeck 82bee848a1 Fix some comments. Enhance LEGACY_PLUGIN such that it can tolerate, then fix bad legacy footprint libraries containing duplicate footprint names.
This may have been an undocumented bug from more than a year ago, which manifested itself in *.mod files containing duplicate names.
LEGACY_PLUGIN loads those now quietly, but appends "_v2", "_v3", etc. to each succeeding duplicate sharing the same name.
2012-05-08 19:26:15 -05:00
Dick Hollenbeck 41aa30c93f this helps zooming on some window types 2012-05-08 16:09:18 -05:00
Dick Hollenbeck 594c4102f6 Fix Pcbnew markers in nanometer build with proper scaling factor. Use double in Zoom() 2012-05-07 16:47:25 -05:00
Dick Hollenbeck cf1ae599f1 Make drawframe.cpp's StatusBar use field widths which are dynamically determined
base on expected text and current window font.

Expand the virtual world to 2.14 meters in the nanometer build of PCBNEW.
This seems to be holding up for now.
2012-05-06 18:32:01 -05:00
Dick Hollenbeck 9fbc499361 more nanometer work, see comment at line 66 of pcbnew/classpcb.cpp 2012-05-06 15:10:43 -05:00
jean-pierre charras 3d747571d6 Gerbview: Fix a compil issue in my last commit. 2012-05-06 21:41:53 +02:00
jean-pierre charras 036e02e052 Gerbview: Fix a compil issue in my last commit. 2012-05-06 21:29:52 +02:00
jean-pierre charras d03a9188ae Fix a grid selection issue when starting Eeschema or Gerbview:
Eeschema (also Libedit and Libview) now starts always to the default grid (50 mils)
Gerbview starts with the last selected grid, but the validity is tested.
In Pcbnew the grid value is always displayed, so it should always be good.
2012-05-06 20:04:14 +02:00
jean-pierre charras a07e6e4013 Fix grid selection issue when starting Eeschema or Gerbview:
Eeschema (also Libedit and Libview) starts always to the default grid (50 mils)
Gerbview starts with the last selected grid, but the validity is tested.
In Pcbnew the grid value is always displayed, so it should always be good.
2012-05-06 18:55:51 +02:00
Miguel Angel Ajo ea0562c124 KiCad scripting plugin architecture, footprint wizards first 2012-05-05 22:18:47 +02:00
Dick Hollenbeck 215b6cc634 move import directory to new branch kicad-contrib 2012-05-05 15:06:14 -05:00
Jerry Jacobs jerkejacobs@gmail.com f7460dfa9c Cosmetic UI changes mostly for Mac OS X, see CHANGELOG.txt 2012-05-05 18:03:21 +02:00
Jerry Jacobs jerkejacobs@gmail.com 92a285378a Cosmetic UI changes mostly for Mac OS X, see CHANGELOG.txt 2012-05-05 18:02:09 +02:00
Dick Hollenbeck d033f2235f Remove zip library by switching to wxZlibOutputStream for PDF plotter.
Delete LEGACY_PLUGIN cache after deleting library of same name.
Remove automatically generted freerouter help header.
Add Normalize() to BOX2.
Clamp some values in the virtual space of drawframe.cpp
2012-05-04 23:55:36 -05:00
jean-pierre charras 29016a1fe4 Commit missing files 2012-05-04 20:57:32 +02:00
jean-pierre charras d75596c9b8 Gerbview: remove dependencies from Pcbnew.
Should allow Pcbnew code easier to change and Gerbview code more understandable and easier to maintain.
Code cleaning (remove dead code, add comments).
Minor other enhancements.
2012-05-04 20:16:13 +02:00
jean-pierre charras 8ef3f8ade3 Gerbview: remove dependencies from Pcbnew.
Should allow Pcbnew code easier to change and Gerbview code more understandable and easier to maintain.
Code cleaning (remove dead code, add comments).
Minor other enhancements.
2012-05-04 19:44:42 +02:00
Lorenzo Marcantonio cdce807375 Commit patch from Lorenzo Marcantonio about plot functions enhancement.
Fix some warning compil issues.
Add zlib sources to avoid build issues under Windows (zlib not installed with mingw).
2012-05-03 22:17:34 +02:00
jean-pierre charras 4c9cf84dff Add missing files 2012-05-03 21:08:14 +02:00
jean-pierre charras f878e38d12 Add patch from Lorenzo Marcantonio. Fix some warning issues, and zlib issue under Windows (zlib sources added) 2012-05-03 20:37:56 +02:00
Frank Bennett 24c572b806 This import directory contains tools for importing
to Kicad from other EDA tools.

  edif2kicad        / EDIF to EEschema schematic import
    Tools with EDIF out writer:
       o OrCad
       o DataXpress
       o Viewlogic
       o IntuSoft ICAP
       o Protel nVisage
       o PADS ?
       o P-CAD ?
       o EDIF viewer (www.cimmetry.com)
       o EDIF translator (www.elgris.com/content/edif_overview.html)

  pcb123net2kicad   / converts a pcb123 netlist to Kicad default format
2012-05-02 13:58:54 -06:00
Miguel Angel Ajo abb05eae40 support for footprint library operations 2012-05-01 17:13:36 +02:00
jean-pierre charras 934271b272 Cvpcb: Fix Bug #992429 2012-05-01 12:43:16 +02:00
Miguel Angel Ajo a3366e6c95 merged to testing, fixed some scripting imports 2012-04-30 18:05:22 +02:00
Dick Hollenbeck 8971bf7546 Add tools/parser_gen.cpp which is the beginnings of an s-expression parser
generation tool.  For now, it is just an s-expression beautifier using
our "non-specctra mode" version of s-expressions.
2012-04-29 21:57:48 -05:00
jean-pierre charras 3a673cc06e Remove old function valeur_param(), that does not work in Kicad Nanometer 2012-04-27 16:41:51 +02:00
jean-pierre charras 8bf09f65cf Remove valeur_param(), that does not work in Kicad Nanometer 2012-04-27 16:15:11 +02:00
jean-pierre charras b7f5699b3e Fix some (not all) bad values displayed in NANOMETER mode. 2012-04-27 08:11:41 +02:00
jean-pierre charras 7d01550649 missing change. 2012-04-27 00:04:09 +02:00
jean-pierre charras 05aedc7c57 All: change MILS_TO_IU_SCALING_FACTOR constant to IU_PER_MILS ( and MM_TO_IU_SCALING_FACTOR to IU_PER_MM)
Also fix bug 985654.
2012-04-26 23:35:40 +02:00
jean-pierre charras 9af5367aee All: change MILS_TO_IU_SCALING_FACTOR constant to IU_PER_MILS ( and MM_TO_IU_SCALING_FACTOR to IU_PER_MM)
Also fix bug 985654.
2012-04-26 23:34:20 +02:00
jean-pierre charras 3c1015942d All: change MILS_TO_IU_SCALING_FACTOR constant to MILS_PER_IU ( and MM_TO_IU_SCALING_FACTOR to MM_PER_IU)
Also fix bug 985654.
2012-04-26 22:21:31 +02:00
jean-pierre charras 98329144a0 commit missing files 2012-04-25 21:46:30 +02:00
jean-pierre charras dc990a5309 Define MM_TO_IU_SCALING_FACTOR (scaling factor from mm to internal units) only in convert_to_biu.h
Other scaling factors (MILS_TO_IU_SCALING_FACTOR and DECIMILS_TO_IU_SCALING_FACTOR)
also defined only in convert_to_biu.h.
Allows different scaling value for Gerbview.
Needs more tests.
2012-04-25 21:33:24 +02:00
Dick Hollenbeck c28dc2bb13 I was disappointed when I disassembled the code using the KiROUND() inline function
solution to see that it was not pre-computing constants when used in static initializers.

So we have two use cases, and need two solutions to be optimal, since the compiler 
is too stupid to do the right thing.

I think we need something else for compile time computable constants, to be optimal 
in both use cases.  There is quite a bit of code savings by using a macro for that 
situation from my testing.  To fully capitalize on this, we need to go back and make 
Mm2mils() and what not macros also, or have MACRO versions of them too.
2012-04-25 09:12:25 -05:00
Miguel Angel Ajo c3fa406d60 C++ plugin exceptions correctly handled now 2012-04-24 22:28:23 +02:00
Dick Hollenbeck 3c84312ac5 TODO 2012-04-24 09:23:41 -05:00
Dick Hollenbeck a88656ea5a Somebody else spelled rectangle as badly as me, fix the mingw build 2012-04-23 21:39:56 -05:00
Dick Hollenbeck 86ad0d2c62 * Add DRECT, DPOINT, and DSIZE (double rect, point, and size) using Torsten's vector2d.h
as a starting point
* Make double Distance() take double arguments and remove internal range checking.
* Start on EDA_DRAW_FRAME::AdjustScrollBars() and use "double" for most all calculations
  in anticipation of setting INT_MAX INT_MIN limits eventually.
2012-04-23 16:56:26 -05:00
Miguel Angel Ajo 5512567d74 wxArrayString typemaps, class missing yet 2012-04-23 08:59:37 +02:00
Wayne Stambaugh d14d7f67b3 Pcbnew s-expression file format improvements.
* Move board item object Format() functions into PCB_IO object.
* Change file format to use layer names instead of numbers.
* Change file extension to kicad_pcb.
2012-04-22 11:16:39 -04:00
Miguel Angel Ajo f6b8a150bb merged to last testing, also added automatic file extension detection on save/load 2012-04-22 13:14:58 +02:00
Miguel Angel Ajo ba8ab188d8 Merged to testing, needs some fixes 2012-04-21 22:04:02 +02:00
Miguel Angel Ajo b188f76b65 Exceptions handled on board Load/Save 2012-04-20 23:20:56 +02:00
Dick Hollenbeck 48a745e934 todo 2012-04-19 15:28:54 -05:00
Dick Hollenbeck e1c9cbedd7 missing include 2012-04-19 15:07:36 -05:00
Dick Hollenbeck c53c5b47ea // Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did.  This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.


#include <stdio.h>
#include <assert.h>
#include <limits.h>

//-----<KiROUND KIT>------------------------------------------------------------

/**
 * KiROUND
 * rounds a floating point number to an int using
 * "round halfway cases away from zero".
 * In Debug build an assert fires if will not fit into an int.
 */

#if defined( DEBUG )

// DEBUG: a macro to capture line and file, then calls this inline

static inline int KiRound( double v, int line, const char* filename )
{
    v = v < 0 ? v - 0.5 : v + 0.5;
    if( v > INT_MAX + 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    else if( v < INT_MIN - 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    return int( v );
}

#define KiROUND( v )    KiRound( v, __LINE__, __FILE__ )

#else

// RELEASE: a macro so compile can pre-compute constants.

#define KiROUND( v )  int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )

#endif


//-----</KiROUND KIT>-----------------------------------------------------------

// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );


int main( int argc, char** argv )
{
    for( double d = double(INT_MAX)-1;  d < double(INT_MAX)+8;  d += 2.0 )
    {
        int i = KiROUND( d );

        printf( "t: %d  %.16g\n", i, d );
    }

    return 0;
}
2012-04-19 01:55:45 -05:00
Dick Hollenbeck 487ac04a1b use a block scope to invoke wxFFile's destructor before renaming temporary file 2012-04-18 07:24:40 -05:00
jean-pierre charras c98771f683 Make Gerbview working with USE_PCBNEW_NANOMETRES option ON 2012-04-18 09:07:13 +02:00
Dick Hollenbeck 9f990349ff PLUGIN API Doxygen comments 2012-04-17 09:54:48 -05:00
Dick Hollenbeck 3aed6de76e uncrustify math_for_graphics, add copyright legacy_plugin.h 2012-04-17 09:18:14 -05:00
Dick Hollenbeck 1be7a45f18 touch ups 2012-04-17 01:13:22 -05:00
Dick Hollenbeck 531228f3c0 LEGACY_PLUGIN is now in full use:
*) for footprint access into *.mod files and 
*) BOARD save/load

The item_io.cpp and ioascii.cpp have been set off to the side for reference
as *.notused, for awhile.

The CMake options USE_NEW_PCBNEW_LOAD and USE_NEW_PCBNEW_SAVE are gone,
this is now the mandatory usage of the LEGACY_PLUGIN.  This should reduce
code maintenance for awhile until the s-expression plugin comes into 
play.  But at least for legacy format, there is not two code bodies
to maintain any more.

A new LEGACY_PLUGIN footprint library caching scheme is in place which 
needs some testing.  It should not be any faster, but might give better 
results in a networked environment if there is *.mod files on the server.
2012-04-16 22:12:53 -05:00
Dick Hollenbeck 15a53269d2 cvpcb LEGACY_PLUGIN usage factoring 2012-04-16 21:58:03 -05:00
Dick Hollenbeck 7187639286 more footprint support for LEGACY_PLUGIN 2012-04-16 20:35:43 -05:00
Wayne Stambaugh fd72c74184 Removal of internal units.
* Remove internal units from BASE_SCREEN and it's derivatives.
* Remove internal units from EDA_DRAW_FRAME and it's derivatives.
* Use build time code to replace internal units conversions.
* Fix scaling bug in page layout sample window that I created in my
  last commit.
2012-04-16 19:31:29 -04:00
Wayne Stambaugh 9912fce370 More internal unit improvements.
* Move all convert from user to internal units into base_units.cpp.
* Remove internal units parameters from all moved conversion functions.
* Revise all source code that calls the moved conversion functions.
* Remove internal units from all dialog text control helper classes.
2012-04-16 13:39:32 -04:00
jean-pierre charras 063850bc20 Fix a serious bug in EDA_RECT::Intersects
Kicad manager: code cleaning. Dead code removed and minor fixes. support of new .kicad_brd extension.
2012-04-16 14:56:01 +02:00
Dick Hollenbeck fb8c1ad75b work on footprint plugin API 2012-04-15 22:18:41 -05:00
Wayne Stambaugh 805c6b9711 Pcbnew nanometer internal unit fixes.
* Scale page reference border and title block, grid sizes, and zoom factors
  correctly for nanometers.
2012-04-15 21:25:26 -04:00
lajos kamocsay e3fbd46a79 Commit patch fixing an issue in pan with middle mouse button (from lajos kamocsay)
Other minor fixes.
2012-04-15 12:33:35 +02:00
Miguel Angel Ajo 9fc9ca3265 merged testing branch 2012-04-14 23:18:27 +02:00
Wayne Stambaugh 40aee428b5 More internal unit improvements.
* Move all convert from internal to user units functions into separate file.
* Remove internal units parameter from all moved conversion functions.
* Revise all source code that calls the moved conversion functions.
* Compile these conversion routines separately for the appropriate pcb or
  schematic internal units.
* Move internal units specific status bar update code into the appropriate
  application for updating the status bar.
* Move millimeter user units rounding function to common.cpp.
2012-04-13 14:51:24 -04:00
jean-pierre charras b7fe42a545 Eeschema: BOM list generation: some fixes and enhancements.
drawframe.cpp: commit a fix about scrollbars  from lajos kamocsay
2012-04-13 20:44:02 +02:00
Wayne Stambaugh 5cbd311e80 Internal unit improvements and Pcbnew s-expression file format changes.
* Move EDA_TEXT object into separate header and source file.
* Compile EDA_TEXT class separately for BOARD_ITEM and SCH_ITEM units.
* Compile PAGE_INFO  class separately for BOARD_ITEM and SCH_ITEM units.
* Minor formatting tweaks to Pcbnew s-expression file.
* Move internal unit formatting functions into BOARD_ITEM and SCH_ITEM.
2012-04-12 17:31:31 -04:00
lajos kamocsay 4f74bf88f1 Fix small issue when panning with middle button. 2012-04-12 09:58:12 +02:00
Dick Hollenbeck 4df999cbe2 fix comment 2012-04-11 18:51:16 -05:00
Dick Hollenbeck 039fe4bddf * Coding standards, private functions are lowercase.
* Fix bug in PCBNEW dialog_pad_properties.cpp that I introduced several days ago.
  The m_Master_Pad stuff is stored in the PCB_EDIT_FRAME's BOARD_DESIGN_SETTINGS,
  not in the FOOTPRINT_EDIT_FRAME's BOARD_DESIGN_SETTINGS (i.e. not stored in 
  the module editor's dummy BOARD).  Now we properly initialize the
  DIALOG_PAD_PROPERTIES::m_Pad_Master reference to the correct master pad
  dope, instead of to the dummy module BOARD's master pad, which is not used.
2012-04-11 18:30:06 -05:00
jean-pierre charras 833bbc5b88 Eeschema: fix a bug in my previous commit. 2012-04-11 23:01:20 +02:00
jean-pierre charras c0dfc5bb89 All: new middle mouse pan feature, from lajos kamocsay (and jp charras for some enhancements).
If enable in preference menu, allow the pan with drag mouse with middle button down.
both unlimited and limited pan is allowed.
2012-04-11 20:54:20 +02:00
Dick Hollenbeck b1866205ed handle negative constants 2012-04-11 10:50:17 -05:00
lajos kamocsay 50067840c7 This is some boost weirdness. 2012-04-11 09:55:40 -05:00
Dick Hollenbeck aa6c9e7f21 improve comments in specctra stuff 2012-04-11 09:49:11 -05:00
jean-pierre charras cf4991979d Pcbnew nanometer: fix hatch lines issue in polyline.cpp
Some minor code cleaning.
2012-04-11 11:47:57 +02:00
Dick Hollenbeck 09cfdfd756 add PCNBEW nanometer support to specctra round-tripper, use micro-meters to do it. 2012-04-10 11:28:26 -05:00
Dick Hollenbeck 72970d8c7d remove #include <auto_ptr.h> 2012-04-09 08:56:30 -05:00
jean-pierre charras c3d320aa8c Move AddMenuItem inline functions outside wxstruct.h in a new file (menu_helpers.h)
Enhancements in AddMenuItem (that accepts now a menu type)
Partial use of the Edwin van den Oetelaar's patch (patch not fully working or correct)
2012-04-09 11:16:47 +02:00
Miguel Angel Ajo 3fcbc847a9 lajos kamocsay compilation patches 2012-04-09 08:53:24 +02:00
Miguel Angel Ajo 151fc3065b detect building status of the swig .py file (on parallel make builds). Fix unit conversion returns (From_xxx) to integer, what's all the wxPoint/wxRect/wx.. expect. Extended createPcb.py example 2012-04-09 08:19:57 +02:00
Alexander Zakamaldin 7eeb8a2c0c This bug is not evident for the first glance because most PS viewers fix this issue and print well.
But when using raw printing (for linux - 'lpr some_file.ps') the bug gets out.

Alexander.
2012-04-08 18:37:26 -05:00
Dick Hollenbeck 93437e3539 Add DMils2iu() for scaling deci-mils to internal units.
Instrument saveNETCLASS() with fmtBIU().
Can now round trip to mm board file using LEGACY_PLUGIN in DEBUG build.
2012-04-08 18:32:32 -05:00
Dick Hollenbeck ae81396710 *) Change LEGACY_PLUGIN to respect saving and loading of UNDEFINED_DRILL_DIAMETER.
*) Allow building without defining 
        USE_NEW_PCBNEW_LOAD & USE_NEW_PCBNEW_SAVE.
	pcbnew/files.cpp would not link.
2012-04-08 14:01:54 -05:00
Miguel Angel Ajo 7a61b1f4b9 missing script 2012-04-08 17:00:15 +02:00
Miguel Angel Ajo 6fd2e6ced0 Fix units.i and add some extra wrappers wxSizeMM, wxSizeMils wxRectMM wxRectMils 2012-04-08 16:59:12 +02:00
Miguel Angel Ajo f3ddaf5dce Fixed wxSize bug, wxPoint(double,double) support, units. Fixed GetBoard wasn't accessible at every build. Extended example for board creation (now adds pads). Also fixed the _pcbnew loading from pcbnew which should only go to the internal _pcbnew and not the _pcbnew.so/dso. Right installation path for _pcbnew.so (in linux only) 2012-04-08 16:25:49 +02:00
Wayne Stambaugh 961b408f10 Pcbnew s-expression file format changes.
* Save dialog now supports saving boards to new file format.
* Add CMake option to build s-expression file save.
* Add check to main CMakeList.txt file to make sure nanometers are
  enables when the new file format is built.
* Minor tweaks to object format functions for improved output.
* Rename kicad_plugin.h/cpp to legacy_plugin.h/cpp.
2012-04-07 14:05:56 -04:00
jean-pierre charras 18c5a9aef4 remove old xpm icons, no more used. 2012-04-07 16:34:56 +02:00
jean-pierre charras 880844d178 Remove old xpm icons files 2012-04-07 13:09:57 +02:00
Miguel Angel Ajo f55cf6f90d TODO.txt updated 2012-04-06 22:42:39 +02:00
Miguel Angel Ajo ea90b73781 Add method for MODULE in python that takes care of memory handling 2012-04-06 22:38:32 +02:00
Miguel Angel Ajo e81576b74e example for pcb creation in scripting 2012-04-06 21:48:00 +02:00
Miguel Angel Ajo 4de3380ca5 BOARD::Add now it's wrapped in python and clears the .thisown flag on python to avoid GC from deleting the object later (BOARD will do) 2012-04-06 21:46:45 +02:00
Dick Hollenbeck 7f2ecfe721 USE_NEW_PCBNEW_LOAD and USE_NEW_PCBNEW_SAVE are enabled by default.
This uses the new LEGACY_PLUGIN, so we can force more usage & testing of it
before ioascii.cpp and item_io.cpp are deleted, along with 
BOARD_ITEM::Save() and BOARD_ITEM::ReadDescr() associated functions.
2012-04-06 14:31:28 -05:00
Miguel Angel Ajo 62c00ba871 Compilation cleanup, TODO.txt update about library creation 2012-04-06 20:13:03 +02:00
jean-pierre charras d55c34f662 Pcbnew: fix Bug #975014 2012-04-06 20:03:16 +02:00
Miguel Angel Ajo 76821902c8 Added wxRect and wxSize wrappers to wx.i 2012-04-05 23:41:45 +02:00
jean-pierre charras 504fd3e282 Finish Pcb Calculator work 2012-04-05 20:56:06 +02:00
Dick Hollenbeck 86da74e0bc todo 2012-04-05 13:29:42 -05:00
Dick Hollenbeck 484bbcbfba Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
Andrey Fedorushkov 500e3b9d85 pcb_calc: fix build in linux distrib Mageia1 with wxgtk2.8-2.8.11-4.mga1 2012-04-04 21:08:16 +04:00
jean-pierre charras b299c85f98 pcb_calculator: fixes and enhancements (not finished) 2012-04-03 20:26:05 +02:00
jean-pierre charras 6a39f5bd1c pcb_calculator: enhancement in Regulators page dialog:
* support for 3 terminal regulators
* add a data file management to store parameters for regulators ( name, vref value, Iadj value, type)
Needs some refinements, but it is already very useable.

 Commit dialog page setting patch from Alexander Zakamaldin
2012-04-02 20:11:00 +02:00
Wayne Stambaugh 2cecd66a50 Initial Pcbnew s-expression file format commit.
* Add s-expression Format() function to all objects derived from
  BOARD_ITEM.
* Add s-expression Format() function to base objects as required.
* Add functions to convert coordinates from base internal units
  (nanometers) to millimeter string for writing to s-expression
  file.
* Add temporary dummy conversion functions to prevent link errors
  until schematic and board object and action code can be separated
  into DSO/DLL.
* Add CMake build option to build Pcbnew with nanometer internal
  units.
2012-04-01 16:51:56 -04:00
Alexander Zakamaldin ca15df807c fix minor issue a page layout in GOST mode 2012-03-29 08:47:29 +04:00
jean-pierre charras ce4d8d902d Libedit, dialog edit pin: fix wxDialogs tabbing order 2012-03-28 18:53:02 +02:00
jean-pierre charras 0f83413a8f Fix issues about translations:
Eeschema: one string with a bad char (\a, not useable in internationalized strings).
Dialog_page_settings: use not translated strings in code, so strings can be freely translated for the UI.
(Initial code was not working with existing translations)
Update 2 icons.
2012-03-27 18:41:13 +02:00
Wayne Stambaugh 12a5a2da41 Minor code improvements and coding policy fixes.
* BLOCK_SELECTOR class is not longer derived from EDA_ITEM.
* Encapsulate BLOCK_SELECTOR class member variables and add access methods.
* Move HandleBlockBegin() function from block_commande.cpp to drawframe.cpp.
* Remove virtual methods from top level derived objects per future
  coding policy change.
* Remove Doxygen copydoc statement from objects derived from EDA_ITEM
  since the comments are automatically copied to the derived object.
* Removed copy and pasted Doxygen comments from objects derived from
  EDA_ITEM.
2012-03-26 19:47:08 -04:00
Alexander Zakamaldin 15f53f6d97 Alexander's patches, with refinements from Dick 2012-03-26 16:52:53 -05:00
Alexander Zakamaldin 40d78f97e6 Alexander's patches, with refinements 2012-03-26 16:45:05 -05:00
Fabrizio Tappero cbe9446e50 Update icons 2012-03-24 16:38:55 +01:00
jean-pierre charras 890e7beb26 class EDA_RECT: is no more derived from EDA_ITEM, just from EDA_RECT (reason: does not use anything in EDA_ITEM)
issue in cast to wxRect fixed (EDA_RECT accepts negative size, but not wxRect, so the wxRectcast  is normalized now).
This fixes some bugs.
A minor other bug fix in Pcbnew.
2012-03-24 15:25:30 +01:00
Dick Hollenbeck 72926fd4ee Backout my usage of DIALOG_EXTEND_WITH_SHIM in favor of wxFormbuilder's
subclass DIALOG_SHIM support.
Tried dialog_drc but it has nesting problems due to use of DRCLISTBOX, which
needs to be put into its own header file to untangle.
2012-03-22 13:36:20 -05:00
Dick Hollenbeck 0d62f4706a Add include/dialog_shim.h and common/dialog_shim.cpp for use by wxformbuilder's "subclass a wxDialog" support.
This works, but in my version of wxformbuilder there is a bug which does not properly show the 
subclass property, even though it is still in play.  This happens after saving then loading the *.fbp file.
So it is a nuisance bug, but does not affect functionality.
2012-03-22 02:02:49 -05:00
jean-pierre charras da20193852 Pcbnew: Allows an offset for SMD type (and CONNECTOR type) pads. 2012-03-20 21:22:38 +01:00
Andrey Fedorushkov cdc07b5d4e eeschema: add forgotten major fix in bzr3471 2012-03-20 19:19:07 +04:00
Andrey Fedorushkov df0d018b40 eeschema: fix sorting parts generate BOM "Single part per line" 2012-03-20 18:41:57 +04:00
jean-pierre charras d02e5ecdc5 Update some icons with new icons from Fabrizio Tappero.
Remove 2 duplicate icons.
Minor cosmetic enhancements and fixes in popup menus.
2012-03-20 15:17:58 +01:00
Miguel Angel Ajo 7ee96336d7 Fixed Board.Save, listPcb.py +x and updated TODO.txt 2012-03-20 07:34:23 +01:00
Dick Hollenbeck 89ce14bfee start toying with DIALOG_SHIM 2012-03-19 15:57:19 -05:00
Dick Hollenbeck b5b6e9997d quiet warnings, add Clamp() 2012-03-19 11:29:24 -05:00
Miguel Angel Ajo 9ea12cf091 fixed DEBUG build dependency... 2012-03-19 16:39:50 +01:00
Miguel Angel Ajo 5d6ca51ea8 * cleanups: board.i board_item.i separated from pcbnew.i
* dlist.i empty list fixed (Segfault)
* units.i: FromMM FromMils ToMM ToMils
* added a little example (listPcb.py) that shows most items in a board
2012-03-19 12:21:29 +01:00
Miguel Angel Ajo 2d0a80bcbb std::vector and std::string items
DLIST iterator code, now we can do:

    for module in pcb.m_Modules:
    	print module.GetReference()

instead of:

    module = pcb.m_Modules

    while module:
	print module.GetReference()
	module = module.Next()

or even:
    module_list = list(pcb.m_Modules)
2012-03-19 09:36:38 +01:00
jean-pierre charras a2eea79ea8 Eeschema: fix a bug in bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ): ends point of resulting segment incorrects.
remove unused icon files.
2012-03-19 08:48:29 +01:00
Miguel Angel Ajo fe52062f04 fixed ident tabs 2012-03-19 08:40:43 +01:00
Miguel Angel Ajo 6c4f5c78d0 Cast() method to cast down classes from BOARD_ITEM to all childs 2012-03-18 22:35:51 +01:00
Miguel Angel Ajo d7a65ae09f Fixed some indent, and added some conditional compiles on pcbnew.cpp 2012-03-18 10:09:51 +01:00
Miguel Angel Ajo e97a630235 * More cleanup (common wrappers moved to scripting, instead of pcbnew/scripting)
* Added a first test 'testLoadSave.py'
2012-03-17 18:30:03 +01:00
Miguel Angel Ajo f66f15ce90 pcbnew_scripting_helpers.cpp/h to handle generic scripting tools
CMakeLists.txt options to build scripting or scripting modules
2012-03-17 16:17:13 +01:00
Wayne Stambaugh 7b6b9a6e22 Minor code and Doxygen comment improvements.
* Remove double Clone() function calls from all classes derived from
  EDA_ITEM.
* Lots of Doxygen comment warning fixes.
2012-03-17 10:39:27 -04:00
Joe Ferner 4d471306f4 Joe Ferner's merge 2012-03-16 22:01:53 -05:00
Dick Hollenbeck e3dbc609d1 cleanups 2012-03-16 21:11:44 -05:00
jean-pierre charras 67bb18921b Eeschema: fix bug Bug #956818 2012-03-16 20:08:57 +01:00
Joe Ferner 83c75f9291 Added a toolbar button to cvpcb to filter by pin/pad count. 2012-03-15 14:20:22 -04:00
Wayne Stambaugh fce606ed94 Hit test method rationalization and other minor improvements.
* All objects derived from EDA_ITEM now have consistent hit test method
  definitions.
* Remove double function calls from all classes derived from SCH_ITEM.
* Lots of Doxygen comment fixes.
2012-03-15 10:31:16 -04:00
jean-pierre charras 24a9663db4 Update compiling.txt doc. 2012-03-15 09:56:55 +01:00
Andrey Fedorushkov b7dba5f72b all: add display distance to local coordinates in status bar 2012-03-13 13:33:39 +04:00
Dick Hollenbeck 60d245e968 todo 2012-03-12 10:18:32 -05:00
jean-pierre charras 689324ad24 Eeschema: minor fixes:
* make 2 bitmaps more visible.
* fix incorrect screen redraw when rotating a component.
* netlist : the pcbnew advanced format can be now stored (persistant option) in project config.
2012-03-12 11:04:40 +01:00
Dick Hollenbeck 5a2d655c4a * Add PCB_EDIT_FRAME::syncLayerVisibilities(), PCB_LAYER_MANAGER::SyncLayerVisibilities().
* Save all visibilities, layer and render, in BOARD and restore on load.
2012-03-11 19:40:48 -05:00
Miguel Angel Ajo a6b258c953 build _pcbnew DSO/DLL 2012-03-11 20:48:43 +01:00
Miguel Angel Ajo 765df72a6e code cleanup, io_mgr and kicad_plugin included when enabled in cmake... 2012-03-11 20:07:10 +01:00
Miguel Angel Ajo 2b5b1b2a40 wxString, wxPoint and wxChar wrappers 2012-03-10 22:40:41 +01:00
jean-pierre charras 55b3776f42 Pcbnew: Fix Bug #951414 (Windows specific)
Ckecks more pad parameters in pad editor dialog (previously not tested, so a pad could have some very incorrect parameters)
2012-03-10 14:00:31 +01:00
jean-pierre charras f36217fb92 Pcbnew: regression fix when using the new netlist format:
* when a footprint has  many pads having the same pad name, only the first pad was connected to the net
2012-03-10 08:58:21 +01:00
jean-pierre charras 6881dae3bc Dialog exit: better icon.
Pcbnew:
 * graphic_item_properties_base.fbp * dialog pad edit: make some strings more easier to translate.
 * global pad edition: fix a bug that change pad position instead of pad size (round pas only).
Eeschema:
 * fix a bug: new created wires were not alwaes shows until the screen was redrawn.
2012-03-09 19:58:58 +01:00
Marco Mattila 02c7630bbb Fix compilation issue with KicadSVGFileDC. 2012-03-08 22:47:09 +02:00
Marco Mattila d80207d69e Add more pad local copper zone settings in pcbnew. Tune the pad properties dialog a little. 2012-03-08 22:44:03 +02:00
jean-pierre charras 09a999c8a1 All: added a standard exit dialog called by int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage )
Called when closing pcbnew, cvpcb and eeschema.
Minor code cleaning: remove duplicate or not used strings (mainly file extensions and wildcards)
2012-03-08 18:47:23 +01:00
jean-pierre charras e3dd66ddb4 All: try to fix incorrect acs in plot SVG under wxWidgets 2.9:
wxWidgets 2.9 knows wxSVGFILEDC device context.
Unfortunately, arcs are drawn as pies (this is a feature, not a bug).
This is not correct for Kicad.
So Kicad has its own wxSVGFILEDC (named KicadSVGFileDC) that is basically the same as wxSVGFILEDC,
but with arcs drawn as arcs, not pies.
Note also under wxWidgets 2.8 does not know wxSVGFILEDC , so kicad had already its own SVG device context.
2012-03-07 21:18:00 +01:00
Dick Hollenbeck f36ffece70 remove clamping from PAGE_INFO setters 2012-03-06 14:10:12 -06:00
jean-pierre charras d6d74ef77f Libedit: fix bug (svg export does not work)
other minor fixes.
2012-03-06 15:08:59 +01:00
Miguel Angel Ajo 279c944628 wxPoint + more lists 2012-03-05 23:49:49 +01:00
Alexander Zakamaldin ff624c35e3 Problem with the Help link "getting started in kicad" 2012-03-01 09:53:34 -06:00
Miguel Angel Ajo a6deca4da8 Added a starting scripting dialog for tests 2012-03-01 08:21:53 +01:00
Dick Hollenbeck 14d5685528 Load BOARD project settings before loading BOARD in case BOARD has
any configuration overrides.

Call SetDesignSettings() in PCB_BASE_FRAME::ReadSetup().
2012-02-29 09:25:38 -06:00
Miguel Angel Ajo cb13201fd5 SWIG+Python initial scripting support added.
It does nothing but loading and initializing right now.
2012-02-28 22:30:46 +01:00
jean-pierre charras e56b50474a Pcbnew: Hight contrast mode: commit last patch from Miguel Angel Ajo Pelayo, which also fixes an old bug.
All: prepare better compatibility with wxWidgets 2.9.4. Works fine with 2.8.x (I hope...)
2012-02-28 21:14:17 +01:00
Wayne Stambaugh 83b94092b6 Minor Eeschema LIB_ITEM object improvements. 2012-02-27 18:02:08 -05:00
Wayne Stambaugh fe8318d336 Fixes wxSingleChoiceDialog ambiguous constructor compile bug using wxWidgets 2.9.4 or greater. 2012-02-26 14:57:48 -05:00
jean-pierre charras 898c009f50 ModEdit (and ModView): make "invisible" texts visible. They are not visible in the board editor, but must be visible in the footprint editor.
Minor doc update.
2012-02-26 19:49:00 +01:00
Wayne Stambaugh b8bdc638bf Eeschema object list and other minor improvements.
* Convert Eeschema from manually linked list to DLIST for storing
  SCH_ITEM objects.
* Add helper functions to SCH_SCREEN for appending list of SCH_ITEM
  objects.
* Fix bug in wire editing code for accurate undo/redo behavior.
* Add member to DLIST to append another DLIST.
* Other minor code cleaning.
2012-02-26 13:39:39 -05:00
jean-pierre charras 3537b47ba8 Pcbnew: better icon for zone unfill. Minor code cleaning in 3D viewer 2012-02-25 20:55:40 +01:00
jean-pierre charras 9bde5a6482 Pcbnew: fix compil issue. 2012-02-25 08:55:14 +01:00
Marco Mattila f8b7583de5 Add module and pad local parameters for pad-zone connections (thermal, solid etc.) in pcbnew. 2012-02-25 01:23:46 +02:00
Simon Schubert d484fbd93c Pcbnew: fix bad arcs in plot postscript (from Simon Schubert) 2012-02-24 18:17:03 +01:00
Marco Mattila 214e5cc6e3 Fix wxUniCharRef casting issue in eeschema single part per line BOM generation code (?). 2012-02-24 17:00:56 +02:00
Marco Mattila a6c123d4e4 Add correct value sorting (1u < 1n) to bom exports. 2012-02-24 01:57:29 +02:00
jean-pierre charras 363a438fc6 Pcbnew: zone filling: fix broken thermal relief shape for oval pads. mainly noticeable for oval pads having very different X and Y sizes. 2012-02-23 15:59:57 +01:00
Marco Mattila 2c4975c5b5 Fix compiler warnings introduced in 3430. 2012-02-23 14:54:54 +02:00
Marco Mattila f8d96846d5 Fix eeschema component drawing issue during copy. Add hotkey for block save. 2012-02-23 01:35:26 +02:00
Dick Hollenbeck a57fd395fe Uncrustify 0.59 has some new options, it is still actively supported, now under GIT. 2012-02-22 16:00:55 -06:00
Marco Mattila 9feea24516 Make single part per line BOM generation compare all component fields. 2012-02-22 23:37:34 +02:00
jean-pierre charras 41f2b5ec8d Eeschema: Add better dialog to edit an existing field of the current edited component. 2012-02-22 15:04:48 +01:00
jean-pierre charras a8e9046c6c Libedit: Add better dialog to edit an existing field of the current edited component. 2012-02-21 18:47:30 +01:00
Dick Hollenbeck 67b1db7123 remove unneeded debug printf 2012-02-21 09:58:24 -06:00
Dick Hollenbeck 2a59f5ce00 fix infinite loop while generating drill file, bug introduced in 3419 2012-02-21 09:51:11 -06:00
jean-pierre charras 14cf2d9532 Fix 2 minor bugs:
* Pcbnew: in hight contrast mode the 'V' hotkey did not always refresh the screen.
* Eeschema: incorrect print scale when the option 'Show page limits' is disable.
2012-02-20 19:46:56 +01:00
Dick Hollenbeck c10d526385 update TODO.txt with personal items 2012-02-20 09:21:42 -06:00
Dick Hollenbeck 32efce9f86 Miguel's changes 2012-02-20 08:43:49 -06:00
Dick Hollenbeck 533d885923 * Remove virtual BOARD_ITEM::{Get,Set}Position() which in turn means all
derived classes' implementations of these functions become non virtual and
    can be truly _inlined_ for speed!  All GetPosition() in derived classes were also
    changed to return const wxPoint&, that is, a reference rather than a
    full copy of the position wxPoint. There was no need for polymorphism in
    {Get,Set}Position() since we never call these functions via generic pointer.
  * Remove BOARD::{Get,Set}Position() since they were only there to satisfy
    the pure virtuals established in BOARD_ITEM, which are now gone.
  * Added const wxPoint& CPolyLine::GetPos(), made CPolyLine::Get{X,Y}() inline.
  * Derive CPolyPt from wxPoint so we can return "const wxPoint&" fromt
    CPolyLine::GetPos().
2012-02-19 22:48:25 -06:00
Dick Hollenbeck 9903dd5ad9 see CHANGELOG.txt 2012-02-19 22:33:54 -06:00
jean-pierre charras ad5a85ed51 Fix @JP messages (no bugs, just comment lines)
Eeschema: Viewlib is now accessible from Libedit (to browse libs or load a component to edit)
Libedit: uses now the same dialog as the schematic editor to load a component
Some code cleaning.
2012-02-19 20:53:11 +01:00
Marco Mattila f25e5a1012 Use wxStandardPaths to find out the path to binaries in linux. 2012-02-19 21:13:53 +02:00
Miguel Angel Ajo acb7148ac4 Added hotkey for high contrast mode as 'H' 2012-02-19 18:33:06 +01:00
Dick Hollenbeck 585c87a8c6 * remove global g_Pad_Master global and put it into BOARD_DESIGN_SETTINGS
which is in turn already within BOARD.
  * encapsulate class D_PAD with accessors, making data private.
  * make D_PAD::GetBoundingRadius() do its longer calculation lazily, based on
    m_boundingRadius == -1.
2012-02-18 22:10:49 -06:00
Dick Hollenbeck 9d651f85f1 see CHANGELOG.txt 2012-02-18 22:02:19 -06:00
jean-pierre charras ddef0a729d Layers manager: add in popup menu option to hide all coppers layers but active layer.
Design rules: increase number of vias and tracks sizes
Pcbnew: netlist reader: change from my recent commits to keep netnames in pads for footprints not in netlist
(allow an user to place some footprints by hand, set pads netnames and do not lost these netnames when loading a netlsit)
Fix other very minor issues.
2012-02-17 20:43:43 +01:00
jean-pierre charras 7a0b449ac3 Kicad project manager: add .cmp, .drl .pos and .rpt files management.
Code cleaning and other minor fixes.
2012-02-16 21:03:33 +01:00
Dick Hollenbeck f8bcc9966d wxWidgets Debug builds apparently have some tricky technique to validate
the match between wxString::Format() or wxString::Printf() format strings
with passed arguments, but does this at runtime, not compile time.
Fix some mismatches.  size_t is a 64 bit type on x86_64 whereas int and
unsigned are 32 bit types.  On 32 bit machines they are all 32 bits so
this error is probably not triggered.
2012-02-16 00:17:01 -06:00
jean-pierre charras f300ddcada Cvpcb: fix compil error. 2012-02-15 17:28:33 +01:00
jean-pierre charras c28013930e Pcbnew: fix Bug #932509 2012-02-15 14:10:52 +01:00
jean-pierre charras 45b820abe2 Pcbnew: footprint placement file creation:
* Added a dialog to select options: one or 2 files, units (mm or inch), and force INSERT option.
 * code cleaning
 * Modify corresponding  icon in menu to show a footprint, not a schematic component.
2012-02-15 11:41:16 +01:00
jean-pierre charras 034177f0c0 Icons for modedit and modview: remove unused or duplicate icons files and rename files. Tweak some icons. 2012-02-13 15:27:34 +01:00
jean-pierre charras 5edbac54d3 Modedit: add dialog to edit footprint body items. Fix also minor issues about footprint body items edition. 2012-02-12 20:39:37 +01:00
Fabio Varesano 09bf5ca5a0 there was a 0 more in the scale factor for
the millimeters. The attacched patch fixes this and also the comments 
on the generated file to have "Unit = mm" instead of Inches.
2012-02-11 12:54:36 -06:00
jean-pierre charras 814f9ebc5b CvPcb: serious code cleaning. More comments. Remove useless files and some files renamed with a better name. 2012-02-11 10:04:26 +01:00
Dick Hollenbeck 6680975105 fix some warnings in Debug mode under wx 2.9.x 2012-02-10 16:26:42 -06:00
jean-pierre charras dfdbcd8325 Modview: fix minor issues. 2012-02-10 16:31:11 +01:00
jean-pierre charras 2820371a00 Pcbnew - ModView: add 3D view, and fix issues. 2012-02-10 09:49:43 +01:00
jean-pierre charras 5f1d1869e3 Pcbnew: Added: modview. This footprint viewer frame which has the same purpose as Viewlib in Eeschema.
this viewer is built using the new  FOOTPRINT_VIEWER_FRAME class.
2012-02-09 21:33:38 +01:00
Dick Hollenbeck a60a4405c8 fix portion of bug 928330 mentioned in comment #2 2012-02-09 09:00:37 -06:00
Dick Hollenbeck 24d596ee53 fix bug 921553 2012-02-08 09:06:06 -06:00
Dick Hollenbeck 0c37fcebe8 fix 2012-02-07 11:36:24 -06:00
Dick Hollenbeck 1ca7408701 typos 2012-02-06 09:31:36 -06:00
jean-pierre charras eceaf3bfb4 Pcbnew: fix Bug #927293. fix compil issue with wxWidgets 2.9.3 2012-02-06 10:10:32 +01:00
Dick Hollenbeck 68f8d44e0d * move globals into BOARD:
bool g_Zone_45_Only, is now in BOARD::m_zoneSettings.m_Zone_45_Only
    ZONE_SETTINGS g_Zone_Default_Setting is now in BOARD::m_zoneSettings
  * Changed classs ZONE_SETTING to class ZONE_SETTINGS.
  * Changed ZONE_SETTINGS::Import() to operator << ( ZONE_CONTAINER )
  * Added BOARD::{Get,Set}ZoneSettings().
  * Added PCB_BASE_FRAME::{Get,Set}ZoneSettings().
  * Save/load BOARD::m_zoneSettings.m_Zone_45_Only to/from BOARD file.
  * Removed PCB_EDIT_FRAME::InstallDialogNonCopperZonesEditor() in favor of
    ::InvokeNonCopperZonesEditor() declared in zones.h
  * Added ::InvokeCopperZonesEditor() declared in zones.h
  * Removed dialog_copper_zones.h since DIALOG class is now declared in *.cpp.
  * Renamed to enum ZONE_EDIT_T in zones.h
  * SetVisibleAlls() is not called as it was in two previous cases for several
    reasons.  BOARD_DESIGN_SETTINGS constructor controls what is visible initially.
    and in the near future so will the *.brd file.  I believe the user should
    have visibility setting rentention accross editing sessions of zones,
    fields, etc.
  * BOARD_DESIGN_SETTINGS constructor initializes hidden text as not visible.
  * Added PCB_EDIT_FRAME::SyncRenderStates() and PCB_LAYER_WIDGET::syncRenderStates()
    so the checkboxes can be set after loading a BOARD file containing previous
    visibility settings.
2012-02-06 01:16:47 -06:00
Dick Hollenbeck ab5f27c5af merge 2012-02-06 01:14:51 -06:00
Dick Hollenbeck f7d074d64c see CHANGELOG.txt 2012-02-05 23:44:19 -06:00
jean-pierre charras 6ad9366be0 Undo redo change and code cleanup. 2012-02-05 14:02:46 +01:00
jean-pierre charras 32cea2e656 Pcbnew: Fix incorrect behavior of undo/redo command (this issue happens only when a new track is created, and an old redundant track is deleted)
Minor code cleaning
2012-02-04 21:30:00 +01:00
Dick Hollenbeck 17cf16dd19 get rid of some globals, share BOARD_DESIGN_SETTINGS from PCB_EDIT_FRAME with FOOTPRINT_EDIT_FRAME 2012-02-02 11:45:37 -06:00
Dick Hollenbeck f533541b67 CHANGELOG.txt 2012-02-02 01:33:53 -06:00
Dick Hollenbeck f4ccffc754 Remove:
-wxSize         g_ModuleTextSize;      /* Default footprint texts size */
  -int            g_ModuleSegmentWidth;
  -int            g_ModuleTextWidth;

and add similarly named variables to BOARD_DESIGN_SETTINGS, which are 
in a BOARD.
2012-02-02 01:25:21 -06:00
Dick Hollenbeck 6a51e74319 put module text configuration variables into the BOARD 2012-02-02 01:23:00 -06:00
jean-pierre charras eb99d460a3 commint forgotten file 2012-02-01 21:17:43 +01:00
jean-pierre charras 25a92406ce Pcbnew and Cvpcb: more about new netlist support: see CHANGELOG (important changes).
Also commit updated icnos from Fabrizio.
2012-02-01 20:49:37 +01:00
Andrey Fedorushkov e2f76ff8e3 revert my bug commit 3389 2012-02-01 15:53:32 +04:00
Andrey Fedorushkov a7cfb276a6 fix bug plot arc to dxf-format in back_silkscreen, comment and draw layers 2012-02-01 15:42:18 +04:00
Andrey Fedorushkov a26ea8134c fix DXF plot arc 2012-02-01 13:36:43 +04:00
Dick Hollenbeck 892cf8be29 document KICAD_T enum better, remove PCB_ZONE_EDGE_T usages 2012-01-30 15:21:40 -06:00
Dick Hollenbeck 4880bc49e1 support new zone field ZPriority in kicad_plugin.cpp, enhance TESTLINE() so it does not match substrings 2012-01-30 09:53:28 -06:00
jean-pierre charras 068eb252c5 Pcbnew: added a priority level for zones: a zone with a hight priority can be now inside an other low priority zone.
useful for complex zones.
fix in footprint copy.
minor enhancement in netlist/ Footprints Test.
2012-01-30 14:43:02 +01:00
jean-pierre charras e784171e11 Pcbnew: Minor fix and enhancement. 2012-01-30 14:25:46 +01:00
jean-pierre charras 98db29d939 Add priority level to zones. 2012-01-29 20:29:19 +01:00
jean-pierre charras 6fddeb89bc New netlist format: Cvpcb: code cleaning. Pcbew: minor enhancements 2012-01-28 20:25:59 +01:00
jean-pierre charras e51810cb65 Restore INSTALL.txt, erroneously removed.
Pcbnew: minor code change in netlist functions.
2012-01-27 19:56:06 +01:00
Dick Hollenbeck 27ae0785c1 kicad CMakeList.txt library dependency order 2012-01-27 09:40:04 -06:00
Alain Portal 1dabea71da Fix build issues on RedHat based systems when using shared libraries. 2012-01-26 16:45:23 -05:00
unknown e6fe79daca MacOSX: Handling exec 2012-01-26 20:48:45 +01:00
jean-pierre charras dd54429ff6 Pcbnew: First draft to use a new netlist format ( containing the same info as the intermediate netlist, but using S expressions)
* Eeschema can generate this netlist format.
*   Pcbnew can use (automatic identification) the current format or the new format.
*   Cvpcb does not use yet the new format.
2012-01-26 10:37:36 +01:00
Dick Hollenbeck 47c9866131 tune the order of link libraries, based on estimated dependency sequence 2012-01-25 08:56:52 -06:00
unknown c39e8b142e MacOSX: Gerbview mouse fixed 2012-01-24 20:07:35 +01:00
unknown 1b54306b2f MacOSX: Fix in eeschema component move 2012-01-24 18:46:32 +01:00
Gerd v. Egidy 1a193d24ef bom-in-python script does not compile 2012-01-23 09:32:08 -06:00
Dick Hollenbeck d27bdd02ef add tools directory, move container_test.cpp there on standby 2012-01-23 09:25:46 -06:00
Dick Hollenbeck 9474623ff0 * Switch to C++'s true and false and away from C" TRUE and FALSE.
* Enhance class PLUGIN's comments to improve their value as instructional.
  * Switch #includes from "file.h" to <file.h>, and fiddle with search paths
    by using include_directories(BEFORE ...)
  * dialog_page_settings did not have symmetrical space on its right border.
    And it now remembers it last position and size within a program session.
  * base_screen.cpp is now compiled twice, once for {pcbnew,cvpcb} and once
    for eeschema, in preparation for "compile time" support of internal units
    rather than "runtime" support.
2012-01-22 23:17:34 -06:00
Dick Hollenbeck caf2439116 compile base_screen.cpp separately for {pcbnew,cvpcb} and eeschema, so we can diverge internal units at compile time, not runtime 2012-01-22 22:53:21 -06:00
Dick Hollenbeck 4ad507b4e9 dialog_page_settings needed right border space, retain last dialog size and position 2012-01-22 22:45:57 -06:00
Dick Hollenbeck 9e61e71cb1 switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
Dick Hollenbeck 1176351701 enhance comments since PLUGIN needs good documentation for others 2012-01-22 11:21:03 -06:00
Dick Hollenbeck ed835a4973 switch to C++'s false and true from C's FALSE and TRUE 2012-01-22 11:20:22 -06:00
jean-pierre charras 641c7a6d57 Eeschema: fix bug #919636
Pcbnew: 2 minor enhancements
2012-01-21 16:02:49 +01:00
jean-pierre charras 8bfbdc8cf5 Pcbnew: fix a serious bug: crashes when attempt to modify a zone that had lost its net (after eeschema changes for instance) 2012-01-19 19:12:30 +01:00
Lorenzo Marcantonio eae27b0baa This moves the 'Place Junction' button near the 'No Connection' one, to
keep all the labelling tools together in the eeschema toolbar.
2012-01-18 09:06:48 -06:00
Dick Hollenbeck 6281f981fa towards making KICAD_GOST a runtime option, hoping for unified paper size 2012-01-18 09:02:50 -06:00
unknown ee08bfb6aa Better icons in Eeschema from Fabrizio Tappero 2012-01-17 20:23:07 +01:00
Dick Hollenbeck 6a07109e10 set paper orientation into wxPrintData when possible 2012-01-17 09:34:05 -06:00
Alexander Zakamaldin 28d18a4f70 This patch is intended for poedit to do it's job better. 2012-01-17 09:02:17 -06:00
Dick Hollenbeck 14e81fca0e portrait setting was being overwritten in dialog_page_settings.cpp, add updatePortrait(), improve comments 2012-01-17 08:58:58 -06:00
Dick Hollenbeck 6d0cb74b64 try and support Electra *.ses files 2012-01-16 15:43:07 -06:00
Dick Hollenbeck 29b40bc75f switch to comboboxes on page size dialogs, fix PLUGIN header 2012-01-16 14:49:34 -06:00
Dick Hollenbeck d78bf5a93c switch to combobox on page size dialogs, fix PLUGIN header 2012-01-16 14:48:32 -06:00
Dick Hollenbeck f37b21bf6c fix order of cvpcb link libraries, make some PAGE_INFO functions inline 2012-01-15 23:38:11 -06:00
Dick Hollenbeck 7309784487 fix syntax error in kicad_plugin.cpp, carve out class_page_info.cpp, and add PAGE_INFO::Custom 2012-01-15 23:17:23 -06:00
Dick Hollenbeck 55426fb047 Add "portrait" support to the page size settings for all standard paper
sizes.  Tested with postscript output only.  Required minor file format changes
    to reflect the "portrait" setting.  common/dialogs/dialog_page_settings.cpp
    uses a checkbox but its name is "Landscape", which is inverted from portrait,
    but since it is the more common choice, I used that rather than portrait.
    The tooltip for that checkbox makes it clear.  No portrait mode is supported
    for "User" paper size.
2012-01-15 22:11:43 -06:00
Dick Hollenbeck a1172b6211 fix bug with user page size not taking effect immediately 2012-01-15 15:07:01 -06:00
Dick Hollenbeck 271a865d01 segment CHANGELOG.txt according to past years and current year 2012-01-14 20:11:35 -06:00
Dick Hollenbeck 5050dd13f4 commit CHANGELOG.txt before splitting into to years 2012-01-14 20:04:37 -06:00
Dick Hollenbeck 5ce81bf386 changes 2012-01-14 19:31:39 -06:00
Wayne Stambaugh 40fd3e9ae2 Pcbnew object improvements.
* Remove unnecessary copy constructors from board and module library
  objects.
* Add doClone() method to board and library objects.
* Add comment to class definitions where the default copy constructor
  generated by the compiler was adequate.
* Replace copy method with clone method where applicable.
* Remove DuplicateStruct() function.
* Remove track object copy function.
2012-01-14 14:50:32 -05:00
jean-pierre charras d8bffe12d7 Eeschema: Fix erroneous message [Read Only] after creating a new project, and obviously the corresponding schematic file does not yet exist (replaced by [no file]) 2012-01-14 12:52:46 +01:00
jean-pierre charras 7566aa2824 Code cleaning and better comments.
Gebview: fix issue in export to pcbnew (Track arc shapes are now exported, approximated by segments)
2012-01-13 19:35:46 +01:00
Dick Hollenbeck c97ede5c34 fix windows version of GetRunningMicroSecs() 2012-01-13 11:11:34 -06:00
Dick Hollenbeck a2416f0b3f add GetRunningMicroSecs() to libcommon for debug timing 2012-01-13 03:46:02 -06:00
unknown 89eefbdc6a MacOSX: Grid now is displayed correctly 2012-01-10 23:27:31 +01:00
unknown 44f64a852b MacOSX: Drag Modules and Tracks now works correctly 2012-01-10 22:55:07 +01:00
jean-pierre charras 11ecb09eab Pcbnew: fix issue when KICAD_NANOMETER is defined: when zones use htcth to show zones areas, hatch lines were incorrectly calculated (hunded of thousand lines created)
Eeschema: fix issue in search: search not made in reference strings.
Minor fixes, code cleaning and comment enhancements.
2012-01-10 21:12:46 +01:00
unknown e6f686533f MacOSX: Main issue catch! wxPen with size 0 draws NOTHING (8 months to spot it) 2012-01-10 20:52:48 +01:00
unknown c8dd7d95de MacOSX: compile error fix after r3329 2012-01-10 18:54:40 +01:00
Wayne Stambaugh 81a7af5704 Eeschema schematic object improvements.
* Remove unnecessary copy constructors from schematic and component
  library objects.
* Add comment to class definitions where the default copy constructor
  generated by the compiler was adequate.
* Add assignment operator to EDA_ITEM, SCH_ITEM, and all schematic
  objects where the default assignment operator generated by the
  compiler would not be adequate.
2012-01-09 15:26:55 -05:00
Andrey Fedorushkov e0dd754995 fix build when defined KICAD_GOST 2012-01-09 23:13:20 +04:00
Dick Hollenbeck 178e024721 ++all
* Carve out TITLE_BLOCK from BASE_SCREEN
  * Add include/hashtables.h and put class PROPERTIES in there.
    Change PROPERTIES to use "const char*" as the key instead of wxString.
++eeschema
  * Add shim class SCH_BASE_FRAME which introduces the data model SCH_SCREEN
    to the frame EESCHEMA frame class hierarchy and allows sharing of:
    SCH_SCREEN* GetScreen() const;                              // overload EDA_DRAW_FRAME
    void SetPageSettings( const PAGE_INFO& aPageSettings );     // overload EDA_DRAW_FRAME
    const PAGE_INFO& GetPageSettings () const;                  // overload EDA_DRAW_FRAME
    const wxSize GetPageSizeIU() const;                         // overload EDA_DRAW_FRAME
    const wxPoint& GetOriginAxisPosition() const;               // overload EDA_DRAW_FRAME
    void SetOriginAxisPosition( const wxPoint& aPosition );     // overload EDA_DRAW_FRAME
    const TITLE_BLOCK& GetTitleBlock() const;                   // overload EDA_DRAW_FRAME
    void SetTitleBlock( const TITLE_BLOCK& aTitleBlock );       // overload EDA_DRAW_FRAME
2012-01-09 11:32:27 -06:00
Dick Hollenbeck 99877adb39 ++eeschema
Add shim class SCH_BASE_FRAME which introduces the data model SCH_SCREEN
    to the frame class hierarchy.
2012-01-09 11:24:01 -06:00
Dick Hollenbeck 5d8779fac2 CHANGELOG.txt 2012-01-09 02:37:16 -06:00
Dick Hollenbeck 34e07ef245 carve out TITLE_BLOCK class from BASE_SCREEN, add hashtables.h for PROPERTIES 2012-01-09 02:35:06 -06:00
Александр Закамалдин c2f006f37a Patch drifted with time, and a patch hunk was erroneously applied by the patch program,
rather than being rejected.
2012-01-07 15:49:24 -06:00
Александр Закамалдин f19506c3ce This patch implements width tuning (width correction) for PS plotting of tracks, pads and vias.
This feature is very useful for electronics hobbyists who use DIY PCB technology 
(both toner transfer and photoresist methods).
Also width correction may be useful for PCB designers who take care of track width etching.
This patch also fixes some minor PS plotting issues.
2012-01-07 00:02:38 -06:00
jean-pierre charras 313a40875a Pcbnew: Now, archive modules function archives footprints with default orientation (0 degrees) and default side (Front layer) 2012-01-06 21:32:19 +01:00
jean-pierre charras c49acaddf4 Eeschema: add compil option in sch_field.cpp to go back to old behavior for field texts justifications (this option is not activated)
Note: only vertical texts have a modified behavior.
Minor other changes.
2012-01-06 20:00:59 +01:00
Dick Hollenbeck e2487270e5 improved comments 2012-01-05 12:16:21 -06:00
Dick Hollenbeck 2a29b56b12 add container_test 2012-01-05 11:29:17 -06:00
Dick Hollenbeck 746c533c3c Ki_PageDescr was re-written as a proper C++ class and renamed to PAGE_INFO.
It describes paper.  The m_Offset field was dropped since it was only used
    in HPGL plotting within EESCHEMA.  PAGE_INFO instance was moved out of
    BASE_SCREEN (which is on its way out) into both SCH_SCREEN and BOARD.


----------- This line and the following will be ignored --------------

modified:
  CMakeLists.txt
  common/CMakeLists.txt
  common/base_screen.cpp
  common/basicframe.cpp
  common/class_plotter.cpp
  common/common.cpp
  common/common_plotHPGL_functions.cpp
  common/common_plotPS_functions.cpp
  common/common_plot_functions.cpp
  common/dialogs/dialog_page_settings.cpp
  common/dialogs/dialog_page_settings.h
  common/dialogs/dialog_page_settings_base.cpp
  common/dialogs/dialog_page_settings_base.fbp
  common/dialogs/dialog_page_settings_base.h
  common/drawframe.cpp
  common/drawpanel.cpp
  common/pcbcommon.cpp
  common/projet_config.cpp
  common/worksheet.cpp
  cvpcb/class_DisplayFootprintsFrame.cpp
  cvpcb/class_footprints_listbox.cpp
  cvpcb/cvframe.cpp
  eeschema/dialogs/dialog_SVG_print.cpp
  eeschema/dialogs/dialog_SVG_print.h
  eeschema/dialogs/dialog_build_BOM.cpp
  eeschema/dialogs/dialog_plot_schematic_DXF.cpp
  eeschema/dialogs/dialog_plot_schematic_HPGL.cpp
  eeschema/dialogs/dialog_plot_schematic_PS.cpp
  eeschema/dialogs/dialog_print_using_printer.cpp
  eeschema/eeschema_config.cpp
  eeschema/files-io.cpp
  eeschema/libedit_plot_component.cpp
  eeschema/libeditframe.cpp
  eeschema/libeditframe.h
  eeschema/load_one_schematic_file.cpp
  eeschema/sch_screen.cpp
  eeschema/sch_sheet.h
  eeschema/schframe.cpp
  eeschema/viewlib_frame.cpp
  eeschema/viewlib_frame.h
  gerbview/dialogs/dialog_show_page_borders.cpp
  gerbview/dialogs/gerbview_dialog_display_options_frame.cpp
  gerbview/events_called_functions.cpp
  gerbview/gerbview.cpp
  gerbview/gerbview.h
  gerbview/gerbview_config.cpp
  gerbview/gerbview_frame.cpp
  gerbview/initpcb.cpp
  include/appl_wxstruct.h
  include/class_base_screen.h
  include/class_colors_design_settings.h
  include/class_pcb_screen.h
  include/class_sch_screen.h
  include/common.h
  include/pcbstruct.h
  include/plot_common.h
  include/wxBasePcbFrame.h
  include/wxEeschemaStruct.h
  include/wxstruct.h
  pcbnew/basepcbframe.cpp
  pcbnew/class_board.h
  pcbnew/class_pad.cpp
  pcbnew/class_pad.h
  pcbnew/class_track.h
  pcbnew/classpcb.cpp
  pcbnew/dialogs/dialog_SVG_print.cpp
  pcbnew/dialogs/dialog_gendrill.h
  pcbnew/dialogs/dialog_pad_properties.cpp
  pcbnew/export_gencad.cpp
  pcbnew/gen_drill_report_files.cpp
  pcbnew/gen_modules_placefile.cpp
  pcbnew/gendrill.cpp
  pcbnew/gendrill.h
  pcbnew/graphpcb.cpp
  pcbnew/initpcb.cpp
  pcbnew/io_mgr.h
  pcbnew/ioascii.cpp
  pcbnew/item_io.cpp
  pcbnew/kicad_plugin.cpp
  pcbnew/loadcmp.cpp
  pcbnew/minimun_spanning_tree.h
  pcbnew/moduleframe.cpp
  pcbnew/onleftclick.cpp
  pcbnew/pcbframe.cpp
  pcbnew/pcbnew_config.cpp
  pcbnew/pcbplot.h
  pcbnew/plotdxf.cpp
  pcbnew/plotgerb.cpp
  pcbnew/plothpgl.cpp
  pcbnew/plotps.cpp
  pcbnew/print_board_functions.cpp
  pcbnew/printout_controler.cpp
  pcbnew/printout_controler.h
  pcbnew/solve.cpp
  pcbnew/xchgmod.cpp
unknown:
  3239.patch
  3268.patch
  build/
  container_test.cpp
  debug/
  dick
  release/
  new/build/
  new/doxygen.sty
  pcbnew/basepcbframe.cpp.orig
  pcbnew/plotps.cpp.orig
pending merges:
  Dick Hollenbeck 2012-01-05 fix unreleased bug pertaining to "Sheet" line in a *.brd file
    Dick Hollenbeck 2012-01-05 [merge] merge in mainline into KICAD_PLUGIN work, which is for the PCBNEW nanometer support
    Dick Hollenbeck 2012-01-05 cannot use plugin until done
    Dick Hollenbeck 2012-01-05 finish up SCH_SHEET::{Set,Get}PageSettings() switch over
    Dick Hollenbeck 2012-01-04 remove page size globals from eeschema
    Dick Hollenbeck 2011-12-30 moving objects into BOARD which are saved in a *.brd file, for PLUGIN access
    Dick Hollenbeck 2011-12-22 [merge] merge in testing
    Dick Hollenbeck 2011-12-22 rename Ki_PageDescr to PAGE_INFO, encapsulate it in accessors, and move it into the BOARD
2012-01-05 10:40:36 -06:00
Dick Hollenbeck 3ddd2445e5 fix unreleased bug pertaining to "Sheet" line in a *.brd file 2012-01-05 10:37:51 -06:00
Dick Hollenbeck a682132503 merge in mainline into KICAD_PLUGIN work, which is for the PCBNEW nanometer support 2012-01-05 10:30:58 -06:00
Dick Hollenbeck 00bee0fa54 cannot use plugin until done 2012-01-05 09:36:45 -06:00
Dick Hollenbeck 4d25d2ffcc finish up SCH_SHEET::{Set,Get}PageSettings() switch over 2012-01-05 02:07:11 -06:00
Wayne Stambaugh 1db4a96c2c Eeschema schematic object improvements.
* Move SCH_ITEM::Place() code into SCH_EDIT_FRAME so schematic item
  objects no longer have any knowledge of the schematic frame window
  or undo/redo containers.
2012-01-04 17:08:46 -05:00
jean-pierre charras 8fef15cd56 Fix bug 910364: When a footprint saved in a .mod file is not on front layer and/or not with orientation 0 degree, the Module editor load it incorrectly.
note:  the Module editor save it with default orientation and layer, but the archive function does not, so some footprints can be not editable.
TODO: modify the Archive Function to use the default layer / orientation.
2012-01-04 20:10:33 +01:00
Dick Hollenbeck 64396d15c8 remove page size globals from eeschema 2012-01-04 00:18:38 -06:00
Wayne Stambaugh 5d209f798a Minor coding policy and code readability improvements. 2012-01-03 12:14:17 -05:00
Wayne Stambaugh 811006ed8f Remove unused EDA_ITEM list from BASE_SCREEN. 2012-01-02 15:45:46 -05:00
Dick Hollenbeck 555e9ed5fe moving objects into BOARD which are saved in a *.brd file, for PLUGIN access 2011-12-30 23:44:00 -06:00
jean-pierre charras 49eb11e135 Eeschema: Fix issue in Search/ReplaceAll
Pcbnew: fix a very minor issue.
2011-12-30 20:04:40 +01:00
jean-pierre charras a40cc0d9fc Commit forgotten file 2011-12-30 13:44:02 +01:00
jean-pierre charras 23078fe9c4 Pcbnew: Fix error message in Module Editor after a global pad change.
Minor other enhancements and code cleaning.
2011-12-30 13:29:54 +01:00
Wayne Stambaugh 254c6dc993 Encapsulation and other minor improvements.
* EDA_DRAW_PANEL completely encapsulated.
* Moved OSX m_overlay member from EDA_DRAW_PANEL to EDA_DRAW_FRAME where
  it is used.
* Doxygen comment warning fixes.
2011-12-29 15:11:42 -05:00
jean-pierre charras 66d0b809da Pcbnew: fix potential bug in connections calculations (see Bug #909298 ). 2011-12-28 16:14:46 +01:00
Wayne Stambaugh d0223dc1a0 Fix wxWidgets 2.8 build error. 2011-12-28 09:15:00 -05:00
jean-pierre charras 876b58cebc 3D view: Fix Bug #908871
Eeschema: fix a minor issue.
2011-12-27 19:08:50 +01:00
jean-pierre charras a21c2b4144 Eeschema: fix bug that creates duplicate segments instead of breaking them at junctions points.
Duplicate segments where created in drag command and netlist calculations.
2011-12-23 09:16:36 +01:00
Dick Hollenbeck b38bde7e12 merge in testing 2011-12-22 16:12:21 -06:00
Dick Hollenbeck 5cce143273 rename Ki_PageDescr to PAGE_INFO, encapsulate it in accessors, and move it into the BOARD 2011-12-22 15:57:50 -06:00
Guillaume Simard 75b97c9e0d While working on the layer changing patch, I found that changing track
size while routing (W, Ctrl+W) didn't update the track in the display
window (you had to move the mouse to get a refresh).
2011-12-22 09:41:16 -06:00
Wayne Stambaugh 91d3e9d924 More encapsulation improvements.
* EDA_DRAW_FRAME completely encapsulated.
* Encapsulate the the low hanging fruit in EDA_DRAW_PANEL.
2011-12-22 08:28:11 -05:00
jean-pierre charras b6819aa8dd Fix issue in GPcb footprints import.
Better code in test connections in zones.
Very minor other fixes
2011-12-22 09:07:50 +01:00
Wayne Stambaugh 60cb12c062 Eeschema find and replace improvements.
* Add check box and flag to ignore replacing the component reference
  designator field.
* Fix a resizing bug when switching between the find and replace modes of
  the find/replace dialog.
* Fix replace component reference designator field bug.
* Force rebuild of search list when schematic is modified and the replace
  dialog is closed.
* Prevent finding the next item when the find/replace dialog is closed.
* Respect warp mouse pointer setting when closing find/replace dialog.
* Fix duplicate mnemonic control accelerator keys in find/replace dialog.
2011-12-21 15:21:15 -05:00
Wayne Stambaugh 8ea57a4b36 More encapsulation work and other minor improvements.
* EDA_RECT and EDA_ITEM completely encapsulated.
* Removed unnecessary EDA_ITEM member m_Selected and replaced functionality
  with SELECTED flag bit.
2011-12-21 08:42:02 -05:00
Wayne Stambaugh dd96425a72 Removed -static-libgcc linker flag that caused Pcbnew to crash on Windows when raising an exception in release builds using MinGW GCC 4.6.1 2011-12-21 08:19:14 -05:00
Wayne Stambaugh 1bdcac1aac Fix debug assertion on wxWidgets 2.9.3. 2011-12-20 10:23:47 -05:00
jean-pierre charras 70443d06a2 Pcbnew: Enhanced algorithm to calculate board connections:
* A track is seen connected to a pad if the track end is inside the pad shape.
* Pads inside pads are now seen connected, if the center of the pad is *inside* the other pad.
* this is made to be sure a large copper area is shared by the 2 pads,  and to keep algorithm fast.
2011-12-19 12:58:24 +01:00
jean-pierre charras e23512d815 Cvpcb: fix incorrect behavior when clicking on a component 2011-12-18 21:22:16 +01:00
jean-pierre charras 8db20a6589 Minor enhancement and minor code cleaning. 2011-12-18 18:57:05 +01:00
jean-pierre charras e7787b18d3 fix bug: EDA_ITEM::m_forceVisible not initialized in constructor. 2011-12-18 16:26:09 +01:00
jean-pierre charras 7f7bbbcfb4 Some demo files updated. 2011-12-18 10:06:22 +01:00
jean-pierre charras 6a966bdb61 All: fix compatibility issues with wxWidgets 2.9.3
Minor cosmetic enhancements.
Pcbnew: more workd abput connection algorithms (work in progress)
2011-12-17 22:21:03 +01:00
Wayne Stambaugh 702ac16d12 Encapsulate EDA_APP class. 2011-12-16 15:12:49 -05:00
Alexander Zakamaldin 8c9150c223 fix 2011-12-16 12:15:24 -06:00
Dick Hollenbeck af4e13e528 improvements, hopefully 2011-12-16 11:03:25 -06:00
Wayne Stambaugh 8951032d07 More encapsulation work and other minor improvements.
* EDA_DRAW_FRAME completely encapsulated except for DrawFrame member.
* Moved members specific to Pcbnew from EDA_DRAW_FRAME to PCB_BASE_FRAME
  or PCB_EDIT_FRAME as appropriate.
* Replace EDA_TOOLBAR with wxAuiToolBar as EDA_TOOL bar provided no
  additional functionality and made code less readable.
* Remove EDA_TOOLBAR class definition from wxstruct.h and delete file
  wineda_toolbar.cpp.
* Rename tool bar members to something more descriptive since the
  horizontal and vertical references wont mean anything once the
  tool bars are movable.
* Lots of dead code removal.
2011-12-16 08:32:23 -05:00
Dick Hollenbeck a5a64daf75 fix bugs in kicad_plugin.cpp.
KICAD_PLUGIN::Load() is solid now, except for missing globals, which
still need to get moved into the class BOARD.

Same for KICAD_PLUGIN::Save(), only missing globals, which once they
are in the BOARD class, will be added.
2011-12-15 20:39:59 -06:00
Dick Hollenbeck b3e7510d31 plugin testing has started 2011-12-15 10:48:36 -06:00
Dick Hollenbeck 4bc6b69a96 legacy pcbnew plugin touch ups 2011-12-14 20:24:52 -06:00
Guillaume Simard 00b0d03dee fix 2011-12-14 16:35:03 -06:00
Guillaume Simard 1c24f3b14a Make CvPcb correctly preview the selected component footprint if one has already been assigned. 2011-12-14 15:23:32 -05:00
Wayne Stambaugh 65383f28a2 More EDA_DRAW_FRAME encapsulation work. 2011-12-14 15:03:15 -05:00
Dick Hollenbeck ef1c63169e fix EDA_ITEM::Show() prototype bug, fix KICAD_PLUGIN::Save() problem with netclasses. 2011-12-14 11:25:42 -06:00
jean-pierre charras 7cf1f011ef Pcbnew: fix issue when creating new tracks: sometimes a ratsnest remains active although a track exists. 2011-12-14 12:31:49 +01:00
Dick Hollenbeck 4aeeaed4c7 minor 2011-12-14 01:03:55 -06:00
Dick Hollenbeck ebe2f2b950 ++common
* changed all the RotatePoint() functions in trigo.{h,cpp} to take a double as the
    angle, which is still in tenths of degrees for now.
  * EDA_TEXT::m_Orient is now double, still in tenths of degrees (for a short while),
    but the double means parsing files and saving them use a different format string.
++pcbnew
  * DRAWSEGMENT::GetStart() and GetEnd() do not operate for S_ARC like they used to.
    They are now simply accessors for m_Start and m_End.  Use DRAWSEGMENT::GetArcStart()
    and GetArcEnd() and GetCenter() for arcs.  specctra_export.cpp was the only
    source file dependent on the old behavior.
  * DIMENSION::m_Text is now contained, not dynamically allocated.
  * more kicad_plugin work.
2011-12-13 22:43:51 -06:00
Dick Hollenbeck 9998946886 kicad_plugin 2011-12-13 22:29:25 -06:00
Guillaume Simard 0b16a37675 Add undo/redo support for Pcbnew auto place, auto move, and auto route features. 2011-12-13 15:42:42 -05:00
jean-pierre charras f860b5a058 pcbnew/class_track.h: remove duplicate class members. 2011-12-13 21:28:25 +01:00
Wayne Stambaugh 4f982ee3d1 Add Eeschema replace code.
* Enable replace toolbar button and menu entry.
* Improve find replace logging granularity.
* Fix find and replace dialog control hiding and disabling.
* Minor improvements to the SCH_FIND_REPLACE_DATA object.
* Move find collector list iterator into the collector object.
* Add visibility override flag to EDA_ITEM to temporarily show items that
  are hidden during find and replace.
2011-12-13 10:37:33 -05:00
Wayne Stambaugh 5f4acdee0e Fix infinite recursion bug in SCH_COMPONENT::SetTimeStamp(). 2011-12-12 15:59:43 -05:00
Wayne Stambaugh e640cc187b Fix a minor bug in my last commit that caused the debug build to fail. 2011-12-12 10:16:05 -05:00
Wayne Stambaugh d52fa9bcfc Encapsulate LABEL_OBJECT class and message panel window member of EDA_DRAW_FRAME. 2011-12-12 09:02:37 -05:00
Dick Hollenbeck 3029f0dd16 kicad_plugin work, and accessors along with making some fields protected or private 2011-12-12 02:39:41 -06:00
Dick Hollenbeck 9f69d80b12 plugin work, accessors 2011-12-12 02:37:05 -06:00
Dick Hollenbeck 573e154c18 ++PCBNew
* added BOARD::GetPad(int), made BOARD::m_NetInfo private, and contained
    within the BOARD, not dynamically allocated and owned via pointer.
  * added BOARD::GetPadCount()
  * changed NETINFO_LIST::GetCount() to GetNetCount()
  * added BOARD::GetNetCount()
  * more kicad_plugin work.
2011-12-09 23:47:13 -06:00
Dick Hollenbeck ad49eea20d more kicad_plugin work, make BOARD::m_NetInfo private 2011-12-09 23:33:24 -06:00
jean-pierre charras 1dfb8ee3ce Pcbnew: GPcb footprint import: fix incorrect pad size. 2011-12-09 18:43:34 +01:00
Wayne Stambaugh bca57a4330 Encapsulate SCH_EDIT_FRAME and LIB_EDIT_FRAME classes. 2011-12-09 11:37:11 -05:00
jean-pierre charras ea483333f4 Pcbnew: GPcb module import: fix incorrect position and size of texts. 2011-12-09 17:17:38 +01:00
jean-pierre charras 9f2d83c148 Pcbnew: fix bad initialization of default track width and vias sizes when starting pcbnew with no board loaded. 2011-12-09 11:36:00 +01:00
Wayne Stambaugh 4a59e203cb Encapsulate LIB_PIN class and begin encapsulating SCH_EDIT_FRAME class. 2011-12-08 16:05:43 -05:00
jean-pierre charras 697137585e Pcbnew: bug fix: some Global Design Rules not copied to the board after change. 2011-12-08 20:55:10 +01:00
jean-pierre charras 8031ec9d89 All: fix hotkey issue with wxWidgets-2.9.3 (Window only): hotkey events called twice.
* Fix compil issue about automatically created pcb_plot_params.h :
     pcb_plot_params.* moved from pcbnew to common because item_io.cpp (using this file) is compiled in common.
2011-12-08 19:23:44 +01:00
Wayne Stambaugh 54310ba2bc Encapsulate SCH_POLYLINE, SCH_SHEET, and SCH_TEXT classes. 2011-12-08 10:45:01 -05:00
Marco Mattila 60a894bded Fix thermal relief gap calculation for circular pads in pcbnew. 2011-12-08 01:58:43 +02:00
unknown f40cbb06d6 OSX: PCB Calculator correction 2011-12-07 22:06:02 +01:00
Wayne Stambaugh 01576229fe Encapsulate SCH_JUNCTION, SCH_LINE, and SCH_NO_CONNECT classes. 2011-12-07 15:19:29 -05:00
Wayne Stambaugh 6ad505b6e4 Encapsulate SCH_FIELD class. 2011-12-07 13:47:59 -05:00
jean-pierre charras 9c79b55078 All: fix a collision name between accessor function GetTimeStamp and GetTimeStamp in common.cpp.
In common.cpp GetTimeStamp is renamed GetNewTimeStamp (a better name).
Pcbnew: prepare work to calculate connections between pads that inteserct and therefore can be connected without any track (composite pads).
2011-12-07 16:49:32 +01:00
Wayne Stambaugh aac231c39a Encapsulate SCH_BUS_ENTRY class. 2011-12-07 09:08:52 -05:00
Dick Hollenbeck 6b577e1516 Collect all the PCBNew Save() and ReadDesc...() functions into new file item_io.cpp,
which should eventually go away in favor of kicad_plugin.cpp.
Add CMake options USE_NEW_PCBNEW_LOAD and USE_NEW_PCBNEW_SAVE, which should not be
used yet, and both default to OFF accordingly.
2011-12-06 23:39:18 -06:00
Dick Hollenbeck 79b4503d01 more plugin work 2011-12-06 23:28:49 -06:00
Wayne Stambaugh 1673a59a65 Encapsulate DANGLING_END_ITEM class. 2011-12-06 16:02:21 -05:00
Wayne Stambaugh ae395070d9 Zero memory to duplicate behavior changed when C malloc() was replaced by C++ new(). 2011-12-06 09:46:48 -05:00
jean-pierre charras eced38791a Pcbnew: remove global variables (g_TabOneLayerMask and g_ViaType_Name) 2011-12-06 09:35:13 +01:00
Dick Hollenbeck 7d3c3cc1e3 fix compile of kicad_plugin.cpp with wxWidgets 2.9.x 2011-12-06 00:19:36 -06:00
Dick Hollenbeck a26fdf3b54 Fix problem with BOARD bounding box in saved *.brd files,
and TEXTE_MODULE size in kicad_plugin.
Link in io_mgr and kicad_plugin but do not call them yet
2011-12-05 11:22:19 -06:00
Dick Hollenbeck b162585beb fix formatting problems that came about from incompatible tabbing in Lorenzo's patch 2011-12-05 01:03:57 -06:00
Dick Hollenbeck 77fb880f2d ++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
    having a BOARD being edited by more than one editor, it was a bad design.
    And this meant removing m_PcbFrame from BOARD.
  * removed BOARD::SetWindowFrame(), since BOARD::m_PcbFrame gone.
  * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
  * Added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
  * A couple of dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
    such as dialog_mask_clearance, dialog_drc, etc.
  * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
    with build_version.h's #define BOARD_FILE_VERSION, although there may be a
    better place for this constant.
  * Made the public functions in PARAM_CFG_ARRAY be type const.
    void SaveParam(..) const and void ReadParam(..) const
  * PARAM_CFG_BASE now has virtual destructor since we have various ways of
    destroying the derived classes and boost::ptr_vector must be told about this.
  * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
    an automatic PARAM_CFG_ARRAY which is on the stack.
  * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
    since it has to access the current BOARD and the BOARD can change.
    Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
  * Made the m_BoundingBox member private, this was a brutally hard task,
    and indicative of the lack of commitment to accessors and object oriented
    design on the part of KiCad developers.  We must do better.
    Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
  * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 00:28:17 -06:00
Dick Hollenbeck 46222d488e ++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
    having a BOARD being edited by more than one editor, it was a bad design.
    And this meant removing m_PcbFrame from BOARD.
  * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
  * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
  * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
  * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
    such as dialog_mask_clearance, dialog_drc, etc.
  * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
    with build_version.h's #define BOARD_FILE_VERSION, although there may be a
    better place for this constant.
  * Made the public functions in PARAM_CFG_ARRAY be type const.
    void SaveParam(..) const and void ReadParam(..) const
  * PARAM_CFG_BASE now has virtual destructor since we have various way of
    destroying the derived class and boost::ptr_vector must be told about this.
  * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
    an automatic PARAM_CFG_ARRAY which is on the stack.\
  * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
    since it has to access the current BOARD and the BOARD can change.
    Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
  * Made the m_BoundingBox member private, this was a brutally hard task,
    and indicative of the lack of commitment to accessors and object oriented
    design on the part of KiCad developers.  We must do better.
    Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
  * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 00:15:33 -06:00
jean-pierre charras c0abe47d87 Pcbnew:
Enhanced algorithms to calculate board connections:
    Previously, a track was seen connected to a pad only if the track end is
    exactly on the pad position.
    Now a track is seen connected to a pad if the track end is inside the pad shape.
    Algorithm to calculate pads connections to track is still very fast.
    However some other functions (drag pads, track len calculation ...)
    still need the track end exactly on the pad position.
Dead code removal.
2011-12-04 18:57:03 +01:00
jean-pierre charras d6321ab2a1 Pcbnew: fix Bug #899373 2011-12-03 15:04:17 +01:00
Dick Hollenbeck ca1cc1c76e First working version of KICAD_PLUGIN::Load(), short of some globals and minor conflicts 2011-12-02 15:58:27 -06:00
Dick Hollenbeck 92593c3ea9 First working copy of KICAD_PLUGIN::Load() 2011-12-02 15:56:47 -06:00
Dick Hollenbeck 4b2a89683a fix comments, add IO_MGR::Save() 2011-12-02 10:57:44 -06:00
Dick Hollenbeck a830db6d86 fix warnings and comment 2011-12-02 10:55:31 -06:00
Dick Hollenbeck 7fb62aedc7 Improved PLUGIN documentation in io_mgr.h 2011-12-02 10:28:00 -06:00
Lorenzo Marcantonio c7fa954449 Update to the GENCAD import export 2011-12-02 09:09:57 -06:00
Dick Hollenbeck a002e04838 KICAD_PLUG intermediate work, for eventual nanometer boards 2011-12-01 16:54:58 -06:00
Dick Hollenbeck fe38bab63e KICAD_PLUG work 2011-12-01 16:50:41 -06:00
Wayne Stambaugh 86e0c29c25 Improve Eeschema find code and add initial replace plumbing.
* Replace Eeschema find code with a collector based implementation.
* Fixed a search bug when all subsequent searches of an item would ignore
  the remaining valid child items when an item had more than one child
  item that matched the search criteria.
* Add SCH_FIND_COLLECTOR class to find all items that meet the specified
  search criteria.
* Add SCH_FIND_COLLECT0R_DATA to keep track of information for all matching
  items.
* Use collector to iterate over the list of items that match the search
  criteria rather than trying to start at the last matched item.
* Remove unused searching methods from sheet path and sheet path list
  objects.
* Add replace and replace all functionality to Eeschema find dialog.
* Push matching methods down to EDA_ITEM class so they can be used by
  other derived objects.
* Add method to EDA_ITEM to test if item supports replacing.
* Add flag to find/replace data to support replace feature.
* Disable wild card matching check box when dialog is in replace mode as
  wild card replacement is not supported at this time.
* The usual Doxygen comment and coding policy fixes.
2011-12-01 11:49:28 -05:00
Dick Hollenbeck e554792ea5 KICAD_PLUGIN alternate nanometer board loader work 2011-12-01 00:06:08 -06:00
Dick Hollenbeck a82f60e302 KICAD_PLUGIN alternate nanometer board loader work 2011-12-01 00:04:23 -06:00
Marco Mattila 072a7ac84a Don't subtract soldermask from other than silkscreen layers when plotting gerbers from pcbnew. 2011-12-01 00:06:27 +02:00
Dick Hollenbeck 8dcfd7be61 KICAD_PLUGIN and nanometer intermediate checkin, work in progress... 2011-11-30 15:15:56 -06:00
jean-pierre charras a401afe52e Pcbnew: Fix bug Bug #898178 2011-11-30 21:05:17 +01:00
jean-pierre charras f2ccc83a29 Add Bulgarian language. Update translators list.
Pcbnew: prepare work on new algos for connections calculations.
2011-11-30 12:45:49 +01:00
Dick Hollenbeck b0ccf97226 more KICAD_PLUGIN work progress 2011-11-30 01:43:46 -06:00
Dick Hollenbeck 77cccbc405 This patch restores some of the goodness in Vladimir's rev 3239, and in particular
the GetPosition() and SetPosition() changes.  It also starts towards making m_Orientation
and m_Thickness fields private with accessors, but does not complete this latter goal.
2011-11-29 11:25:30 -06:00
Dick Hollenbeck 6370db0587 intermediate check in to show progress on new nanometer file loader PLUGIN 2011-11-28 21:08:14 -06:00
Dick Hollenbeck b5c71915c7 initial work on PCBNew PLUGIN support, in preparation for nanometer board load and save 2011-11-27 22:32:29 -06:00
jean-pierre charras c96777369d Pcbnew: Fix issue in Undo/Redo command: for very large boards ( > 20000 items) this command could take a long time. Now fast. 2011-11-27 13:29:01 +01:00
jean-pierre charras 9d663c5819 Update version number 2011-11-26 21:02:59 +01:00
Dick Hollenbeck 218eaf92ec changes 2011-11-25 09:40:40 -06:00
Dick Hollenbeck bbc31e07e9 changes 2011-11-25 09:15:46 -06:00
Dick Hollenbeck db889737be add board internal units plan, first incomplete draft. 2011-11-25 02:03:55 -06:00
jean-pierre charras d16ddf42cb Fix a minor issue in my last commit 2011-11-24 22:07:03 +01:00
jean-pierre charras fa0f0bfad9 Eeschema: fix crash in intermediate netlist generation when a component has no pins (like logos or images).
Pcbnew: texts in dimensions can be now moved.
Gerbview: fix incorrect number of layers  in export to pcbnew function.
2011-11-24 20:57:41 +01:00
Dick Hollenbeck 23e28fdd93 Temporarily reverse out the evolving support for finer Board Internal Units (BIU)s. 2011-11-24 11:32:51 -06:00
Vladimir Uryvaev cb62a3b039 Debug bug:) fix. Wayne found it. 2011-11-18 03:16:36 +04:00
Wayne Stambaugh 0cb15dba0a Added new find replace image to bitmap header file. 2011-11-17 13:39:18 -05:00
Vladimir Ur 48112f1a50 Nanometric work
- D_PAD members converted;
- style improved;
- GetPosition made returning value, added SetPosition;
- highly experimental, test it please!
2011-11-17 21:47:27 +04:00
Fabrizio Tappero b99290a060 Change find image, add new find replace image, and remove unused image cpp files. 2011-11-17 11:32:01 -05:00
Wayne Stambaugh ce013119b9 Fix Eeschema find item bugs and other minor changes.
* Fix bug in hierarchical searches using sheet path pointers which are
  destroyed on every search.  Use human readable path as last sheet found
  in test to prevent comparison of deleted pointers.
* Fix a bug in SCH_COMPONENT::Matches() that would prevent searching for
  pins if the search all fields flags was not set.
* Fix a bug in SCH_COMPONENT::Matches() to use the sheet path to perform
  the comparison to the correct reference designator and unit number.
* Fix wrapping in sheet path and sheet path list MatchNextItem methods.
* Push search methods down to EDA_ITEM object so advanced searching can
  be performed on all items derived from EDA_ITEM.
* Add virtual method to EDA_ITEM object to test if item supports replacing
  text.
* Replace switch statement magic numbers in Eeschema socket connection code
  with Pcbnew for improved readability.
2011-11-16 20:06:08 -05:00
Dick Hollenbeck 851643110f fix compiler warning 2011-11-16 14:52:51 -06:00
Vladimir Ur 45d9f292f9 D_PAD conversion: m_Pos converted
PCB_ITEM: GetPosition -- removed reference
load/save length in config
2011-11-16 21:04:12 +04:00
jean-pierre charras b3723ae020 Pcbnew: fix a possible crash after a board cleanup 2011-11-15 20:21:16 +01:00
Vladimir Ur 498bb81c0a Some code restyling: VECTOR_PCB is an array. Cleanup uncontrolled definitions of abs, max, etc. max is now overloaded function and MAX is a macro. 2011-11-15 22:26:06 +04:00
Vladimir Ur cfbc1d6b70 Nanometric work. Design rules, D_PAD (except m_Pos) is now in new units. Metric files can be loaded w/o KICAD_NANOMETRE flag set but saved only with this flag, this could help to gain some compatibility during transition process. ifdef'd code is somewhat minimized by using transition macros. Some potential code bugs are commented. 2011-11-14 20:56:05 +04:00
jean-pierre charras 7355272818 Very minor fix 2011-11-12 19:53:04 +01:00
jean-pierre charras 3c49b63a6b Pcbnew: fix bad icon in ModEdit toolbar. 2011-11-12 11:51:20 +01:00
jean-pierre charras db7b0a2272 Forgotten change. 2011-11-12 10:58:20 +01:00
jean-pierre charras 42e99ac2eb Some better icons.
Fix bug 880132 (Justify not correct)
Note: justifications are now always relative to the text, in libedit (as before) and schematic editor:
if rotated, justification is rotated, because in Pcbnew rotation can have any value.
2011-11-12 10:51:06 +01:00
Wayne Stambaugh 6f86b4ec95 Remove message dialogs from COMPONENT_LIBRARY class.
* Move the component library save file creation and write error dialogs
  into the appropriate frame object.
* Change the save component library and document definitions take an
  OUTPUTFORMATTER object instead of a file name.
* Change the component alias save document definition function to take
  an OUTPUTFORMATTER object instead of a file handle.
2011-11-11 15:10:24 -05:00
Vladimir Ur 574b492479 Metric KiCad work continues. Partially processed D_PAD class. It is still need to be tested including all these import and export procedures... 2011-11-11 21:44:20 +04:00
Wayne Stambaugh c9cf188e08 Fix write file bug when file is in the project path and no path is defined. 2011-11-11 11:08:58 -05:00
jean-pierre charras b459a204a4 Eeschema: bug 880132 : partial fix.
Pcbnew: remove useless code.
Doc: remobe obsolete reference to MINIZIP (which do not exist now)
2011-11-11 08:00:51 +01:00
Wayne Stambaugh a8ca4dbc3a Fix for hidden find dialog when display settings change. 2011-11-10 12:01:33 -05:00
Wayne Stambaugh 21c4e4940b Memory allocation improvements and other minor fixes.
* Replace C malloc() and free() functions with C++ new and delete
  operators or the appropriate STL container.
* Add option to end mouse capture function to skip executing the end
  mouse capture callback.
* Lots of coding policy and Doxygen comment goodness.
2011-11-10 10:55:05 -05:00
jean-pierre charras ee6e44669f Pcbnew: remove dead or obsolete code. Add or fix some comments.
Add minor enhancements.
2011-11-10 09:21:11 +01:00
Vladimir Ur b84cab3fc0 General design rules tab converted to nanoscale. A bit of refactorisation in via sizes. And build key is KICAD_NANOMETRE not KICAD_NANOMETRIC (as I stated in previous commit). 2011-11-09 21:35:16 +04:00
Vladimir Ur a9edcb5f10 Work on internal (nano)metric length units started.
Added configuartion option KICAD_NANOMETRIC for this.
* With option set to false: *
- it should work and compile as usual
- some values are saved with decimal point (which should be backward/forward compatible as old versions should just drop fractional part)
* With option set to true: *
- lengths in Global Design Rules should be settable 1nm steps.
FROM/TO_LEGACY_LU(_DBL) macros introduced for easy interconnection between old and new units.
2011-11-09 17:25:49 +04:00
Dick Hollenbeck ee207e2249 sweet editor, compiler warning 2011-11-08 15:14:39 -06:00
Wayne Stambaugh 28f06953fc Minor fixes, dead code removal, and coding policy fixes.
* Use version of DateAndTime that returns a wxString and delete the
  version that takes a char* as it is no longer required.
* Merge StrNumICmp() and StrLenNumICmp() into StrLenNumCmp() to create a
  single function for comparing strings with integers and remove a lot
  of duplicate code.
* Remove unused strupper from string.cpp.
* Use wxArrayString for sorting the EDA_LIST_DIALOG contents.
2011-11-08 11:37:25 -05:00
jean-pierre charras 90e3024517 Pcbnew: code cleaning in ratsnest.cpp. Add comments. 2011-11-08 17:18:46 +01:00
jean-pierre charras 6222a3a8f7 Pcbnew: Fix a membar issue: Layer setup incorrect location (seems due to an error when using copy/paste editor command) 2011-11-07 21:34:35 +01:00
Wayne Stambaugh 14482a174b Fix cursor warping out of client when zooming bug.
* Modify algorithm to correctly calculate the virtual drawing size and
  offset required to place the drawing correctly under all conditions.
* Ignore default wxWidgets scroll keys on Windows in EDA_DRAW_PANEL key
  event handler.
2011-11-07 14:04:24 -05:00
jean-pierre charras a2395a0417 Pcbnew: Fix typo in 2 filenames. Add comments in ratsnest.cpp.
Fix bug 887202.
2011-11-07 19:04:19 +01:00
jean-pierre charras fb2fc2f43f Pcbnew: more work on a better algorithm to calculate the full ratsnest.
Lee algorithm replaced by a Minimun Spanning Tree algo (using Prim's algorithm ).
Tested on a 5350 pads board, it is more than 100 times faster.
Also fix a crash when clicking on tool  "delete selected items" (main horizontal toolbar),
and remove this tool (currently, no code in Pcbnew for this tool)
2011-11-06 17:16:19 +01:00
Dick Hollenbeck dccd6a0499 Change various KiCad case utilization to precisely "KiCad" 2011-11-04 10:53:37 -05:00
jean-pierre charras 01ffe94974 Pcbnew: connect.cpp: enhanced ( faster and more powerful ) algorithm to calculate connections between pads.
Code cleaning.
2011-11-03 20:07:59 +01:00
Wayne Stambaugh 67f51b6e69 Use output formatter to save component library files and objects. 2011-11-01 11:06:26 -04:00
jean-pierre charras 105eec0693 Pcbnew: Fix bug I created in my previous commit.
More about code refactoring in connect.cpp: RecalculateAllTracksNetcode() is 50 times faster with a board using 27000 tracks
Use right icon in pcbnew for load board and new board.
2011-11-01 09:51:27 +01:00
Dick Hollenbeck ea4dd30143 formatting and compiler warnings 2011-11-01 03:06:33 -05:00
Dick Hollenbeck abfa841a98 sweet editor now shows GAL canvas 2011-11-01 03:05:56 -05:00
Wayne Stambaugh 1003c372bf Use line reader to load component library files and objects. 2011-10-31 16:49:48 -04:00
jean-pierre charras ff99823130 Fix minor issue under wxWidgets 2.9.3 in DRC dialog display.
More work about code refactoring in connect.cpp
2011-10-31 21:29:46 +01:00
jean-pierre charras fe431f1e8e Pcbnew: starting work on better ratsnest and connections calculations algorithms.
This first draft should fix bug 851670 and is faster than existing alogorithm.
2011-10-31 14:44:13 +01:00
Dick Hollenbeck 2ee49802a9 sweet editor work 2011-10-30 00:02:23 -05:00
jean-pierre charras 2ab46f7fa3 Pcbnew: fix minor issue: Footprint bounding box was too large for very small footprints (like SM0204) due to the minimal size value used in calculations. 2011-10-29 14:01:59 +02:00
Wayne Stambaugh 77e721f7ce Unify Eeschema orient commands and other minor fixes.
* Create command event handler for orienting schematic items and block.
* Remove redundant orient item and block command handler code and IDs.
* Remove redundant cancel current command event table entry.
* Remove unnecessary schematic bitmap object virtual functions.
* Set path when saving schematic sheet files to prevent assertion in
  updated path and file write permission test function.
* Restore directory and file name write permission test function to it's
  previous behavior to prevent unexpected save results.
* Add an assertion to verify the path is not empty to directory and file
  write permission test function.
* Improve documentation for path and file write permission test function.
* Fix Doxygen link warnings.
2011-10-28 16:30:50 -04:00
Wayne Stambaugh d4d1491a81 Fix schematic library pin editing bug. Fixes lp:809506
* Change edit pin per part flag to only have effect when editing
  component with multiple parts or alternate body styles.
* Move global edit pin pert part variable into library editor frame
  object.
* Note that this only fixes the bug when the component does not have
  multiple parts or alternate body styles.
2011-10-28 09:43:37 -04:00
jean-pierre charras b2b86d2e04 Fix erroneous test for non writable folder, when trying to save a schematic file with no path in name.
(seems wxFileName.IsDirWritable() fails under Windows when the path is empty (does not use the CWD).)
2011-10-27 20:38:31 +02:00
Wayne Stambaugh 3f3e7fd9f5 Unify Eeschema drag item commands into a single event handler.
* Create command event handler for draggining all schematic items.
* Remove redundant delete item command handler code.
* Remove unused close current tool command ID from process special
  functions event handler.
2011-10-27 13:51:22 -04:00
Wayne Stambaugh deec9e9ac8 Unify Eeschema edit item commands into a single event handler.
* Create command event handler for editing all schematic and child items.
* Remove unique edit schematic item command IDs.
* Unify find item, undo, and redo hot key commands.
2011-10-27 09:34:28 -04:00
Vladimir Ur 5634eaaf7a PCBNEW favored module placed on OPPOSITE side selected layer become.
Now it select module from selected side if present. Especially handy in contrast view.
2011-10-27 17:01:32 +04:00
jean-pierre charras 05f8a7bfb7 Fix message in KiCad Dialog About (forgotten USE_BOOST_POLYGON_LIBRARY option removed). 2011-10-27 07:43:44 +02:00
Wayne Stambaugh c1aa4fc1d0 Factor Eeschema rotate item hot keys into a rotate event handler.
* Add a rotate event handler to schematic frame object.
* Remove unique rotate item command IDs.
* Use process event instead of post event to eliminate the need to clean
  up the command event client object from the heap.
* Unify find next item and next DRC error hot key commands.
* Unify move and rotate hot keys commands.
2011-10-26 16:46:04 -04:00
jean-pierre charras 51570c73e1 bitmap2component: code cleanup. 2011-10-26 13:06:04 +02:00
jean-pierre charras 6afafe1114 bitmap2component: use BOOST:POLYGON instead of KBool, and minor enhancements. 2011-10-26 11:53:42 +02:00
jean-pierre charras c431a1e701 remove useless USE_BOOST_POLYGON_LIBRARY cmake option, and remove unused files.
BOOST POLYGON is always used in zone filling functions.
Kbool is still in use in other calculations.
2011-10-25 18:24:56 +02:00
Andrey Fedorushkov 177103021e Pcbnew: add send msg to Eeschema when move module 2011-10-24 19:23:06 +04:00
Wayne Stambaugh 5dd4e8ff47 Factor Eeschema place item hot keys into select tool event handler. 2011-10-24 09:56:35 -04:00
Andrey Fedorushkov 8b36b16b03 Eeschema:
* Fix bug in draw reference for multiunit component
* Code cleanup for drag item
2011-10-24 17:11:11 +04:00
jean-pierre charras b04ea483a8 Make some messages translatable. 2011-10-22 20:21:57 +02:00
Wayne Stambaugh 55bb147862 Complete Eeschema unified move code.
* Schematic fields now use unified move code.
* Move the unified move code into file schedit.cpp
* Remove old schematic field move code.
2011-10-22 08:31:44 -04:00
Wayne Stambaugh f2ba32a950 Initial ground work to make schematic fields use unified move code.
* Remove external dependency for adding suffix to reference designator
  fields.
* Make schematic field get and set position methods transform coordinates
  relative to the parent component object that owns them.
* Make base text class get text method virtual so derived classes can
  change the base string according to their individual requirements.
* Fix a problem with default place schematic item add in last commit.
2011-10-21 14:17:51 -04:00
Wayne Stambaugh 35c893e84f More Eeschema schematic item move code unification.
* Tweak move item to support moving schematic sheet pin objects.
* Change schematic sheet pin set position to constrain position within
  the parent sheet.
* Schematic sheet pin moving now handled by unified move code.
* Remove old schematic sheet pin move code.
* Add custom client data object for passing hot key information to
  command event handlers.
* Fix a bug that prevented changes to schematic sheet pin objects from
  being undone.
2011-10-21 09:59:15 -04:00
Dick Hollenbeck cca9777064 commit Brian's BOM generation scripts so they don't get lost 2011-10-20 10:49:07 -05:00
Dick Hollenbeck 2f386b6be2 coding standards cleanups 2011-10-20 09:46:06 -05:00
Vladimir Ur 6d19312f51 Automatic footprint assignment now can be done without equ file, if conditions are met:
* symbol in sch library have only single footprint filter,
* footprint filter have no wildcards,
* according footprint exists in pcb lib.
This could remove need in long equ files for lots of ICs.
2011-10-20 15:28:37 +04:00
Dick Hollenbeck a16b8a5474 sweet editor using GAL, links but does not work 2011-10-19 23:08:15 -05:00
Wayne Stambaugh 27b72c4c89 Minor Eeschema fixes.
* Fix a set position method bug in schematic item that caused the fields
  to drawn in the wrong position.
* Group zoom hot keys to use the same command event in schematic and
  library editor frames.
2011-10-19 19:17:28 -04:00
Wayne Stambaugh dbdce87679 Eeschema schematic item move code unification.
* Add get and set position methods to all schematic items.
* Encapsulate schematic item position members.
* Add swap data method to schematic items that lacked one.
* Remove global swap data function used by undo and redo functions.
* Unify as many schematic move methods as possible.
* Remove unnecessary place schematic item methods.
* All schematic items are now moved in the same event handler.
* Fixed bug in hierarchical sheet get menu item string method.
* Make no connect and junction items movable, fixes lp:804048
2011-10-19 16:32:21 -04:00
Fabrizio Tappero 2fd37df46a icons update. 2011-10-19 20:55:21 +02:00
Wayne Stambaugh 32a55c5c6e Minor menu bar fixes.
* Fixed bug on Windows that prevented the menu short cuts from working
  properly.
* Fix duplicate menu short cut keys in KiCad, Pcbnew, and Eeschema.
* Add menu short cuts for all possible menu entries.
2011-10-18 15:59:19 -04:00
jean-pierre charras 481a3f1ba1 Eeschema, Libedit: Use 16x16 icons in comboboxes inside the pin editor dialog. This gives a better look to this dialog. 2011-10-18 21:18:04 +02:00
jean-pierre charras 74f6c56d27 Fix very minor issues and code cleaning 2011-10-18 19:28:49 +02:00
jean-pierre charras bcaf8c7e70 Eeschema: Fix confusing labels in libedit (for pins and graphic items sharing).
Fix icons in macro menu.
2011-10-18 12:18:05 +02:00
jean-pierre charras d1f4eecc3a Eeschema: Fix icons in macro menu.
Fix confusing labels in libedit (for pins and graphic items sharing)
2011-10-18 12:16:27 +02:00
jean-pierre charras 7f5fef431a Icons update 2011-10-18 10:28:12 +02:00
Wayne Stambaugh f6a0f2743e Minor dialog fixes and code cleaning.
* Grammar and spelling fixes in Eeschema, CvPcb, and Pcbnew path and
  library dialog tool tips.
* Translate the French file name subrill.cpp to highlight.cpp.
* Lots of coding style policy fixes.
2011-10-17 16:01:27 -04:00
jean-pierre charras 9b49ee6208 Replace icon_cvpcb.svg file (broken?)
Gerbview: very minor fix
2011-10-17 18:49:14 +02:00
jean-pierre charras 198e472ba3 Gerbview: minor enhancement.
All: fix some strings very hard to translate in messages.
2011-10-16 10:02:36 +02:00
Wayne Stambaugh 4226ac02dc More auto save improvements.
* Factor test for auto save file into base frame class.
* Added auto save feature to Eeschema for saving schematics, addresses
  launchpad question 173631.
* Add auto save interval control to Eeschema options dialog.
* Fix problem with subsequent auto saves in last commit.
2011-10-15 09:25:57 -04:00
jean-pierre charras 4606630f5a CvPcb: make footprint filter case insensitive (Fix Bug #873417 ) 2011-10-14 18:44:15 +02:00
Wayne Stambaugh 5d8d561565 Make CvPcb stay open on save the default behavior. Fixes 872265 2011-10-13 16:13:11 -04:00
Wayne Stambaugh 6a6ac8b47b Pcbnew auto save improvements.
* Factor auto save common code into base frame class so all frame windows
  can take advantage of the shiny new auto save goodness.
* Use a timer instead of depending on mouse and keyboard events to trigger
  an auto save.
* Check for auto save file when opening a board and ask user if they
  wish to use the auto save file or the last saved board file.
* Protect all base frame public members.
2011-10-13 15:56:32 -04:00
jean-pierre charras 6417d7f882 Pcbnew: Fix an issue when try to importing gpcb footprints 2011-10-13 20:37:43 +02:00
Wayne Stambaugh 93ee368556 Factor bus label parsing function into net list object. 2011-10-12 11:34:52 -04:00
Wayne Stambaugh d89171768b More Eeschema net list object generation improvements.
* Add net list object creation functions to schematic sheet and label
  objects.
* Remove function to add schematic object net list items as it is no
  longer needed.
* Add license statements to all modified files that required one.
2011-10-12 10:03:43 -04:00
Andrey Fedorushkov b73037a282 cvpcb: add send message to eeschema when selecting item in list components 2011-10-12 17:09:12 +04:00
Wayne Stambaugh 1888ac386f Eeschema net list object generation improvements.
* Add net list object creation functions to schematic component object.
* Remove external variables used by the verify bus label and parse bus
  label functions.
* Remove redundant net list object include sheet path member assignment.
* Add license statements to all modified files that required one.
2011-10-11 16:23:56 -04:00
Wayne Stambaugh 535958a274 Eeschema net list object generation improvements.
* Define function to allow schematic objects to create their own net list
  objects.
* Add net list object creation functions to schematic line, junction, and
  no connect objects.
* Add license statements to all modified files that required one.
2011-10-11 09:38:13 -04:00
Wayne Stambaugh 35e1f2abed Eeschema ERC improvements and other minor fixes.
* Move the hierarchical label connected test into the NETLIST_OBJECT class.
* ERC pin type strings can now be translated.
* Remove unused EDA_DRAW_PANEL attribute from all ERC test functions.
* Add get marker count method to SCH_SCREENS object.
* Redundant header removal.
* Lots of coding style policy fixes.
2011-10-07 10:41:30 -04:00
Wayne Stambaugh 6e5cfde4b1 Minor copy version information to clipboard improvements.
* Add KiCad build option states to copy version information to clipboard
  function.
* Add a note to the main CMakeList.txt file to let developers know that
  new option states should be added to the copy version information to
  clipboard function.
2011-10-05 14:26:22 -04:00
Fabrizio Tappero and jean-pierre charras 52828730cb Commit new icons from Fabrizio Tappero .
(With a minor change for icon_cvpcb.svg: better look on dark backgrounds)
Fix bug 668200.
2011-10-05 14:36:32 +02:00
jean-pierre charras e3eae253df Fix typo errors and make translations more easy. 2011-10-03 21:11:09 +02:00
Wayne Stambaugh 104123aa88 Fix error when opening component library file names with dot. 2011-10-02 16:24:41 -04:00
Wayne Stambaugh 71224984bb Fix Pcbnew KICAD_T enum names for consistency. 2011-10-01 15:24:27 -04:00
Wayne Stambaugh 181f4ab54c Application name capitalization fixes.
* Correct all user strings and comments for the correct capitalization of
  application names according to JP.  They are KiCad, Pcbnew, CvPcb,
  Eeschema, and GerbView.
* Add a note the the user interface policy about the correct capitalization.
2011-09-30 14:15:37 -04:00
Roman Bashkov 5d1f303a16 pcbnew:
* Add visible clearance when edit node or track segment,
  add parameter "show clearance for new or edited track with via area"
  in "Display options" menu.
2011-09-30 12:24:10 +04:00
Wayne Stambaugh 6a48348831 Minor PCBNew code fixes.
* Translate French code names and comments.
* Dead code removal.
* Hot key object and structure coding style policy fixes.
* Doxygen comment warning fixes.
2011-09-29 12:49:40 -04:00
Fabrizio Tappero 33be36f175 New icons 2011-09-28 21:12:10 +02:00
jean-pierre charras 1a63b68990 Pcbnew: Fix 2 minor bugs about pcb texts: flipped texts have an incorrect rotation angle,
and text dialog editor did not handle properly negative rotation angles values.
Eeschema: fix bug when rotating (only using the Rotate hotkey) a field.
2011-09-28 10:32:31 +02:00
jean-pierre charras 1e3963b75d Eeschema: fix bug when rotating (only using the Rotate hotkey) a field. 2011-09-28 09:38:58 +02:00
jean-pierre charras ca290eeb97 Pcbnew: Fix 2 minor bugs about pcb texts: flipped texts have an incorrect rotation angle,
and text dialog editor did not handle properly negative rotation angles values.
2011-09-28 08:10:15 +02:00
Wayne Stambaugh dbe7934931 Fix PCBNew segfault when adding a module. 2011-09-27 16:43:18 -04:00
Wayne Stambaugh ca12278e90 PCB common library global variable removal and other minor fixes.
* Move auto save time global variables into PCB_EDIT_FRAME object.
* Move footprint library name list global variable int PCB_EDIT_FRAME
  object.
* Improve library back up and temporary file error message strings and make
  them translatable.
* PCBNew string unification.
* Translate French code names and comments.
* Coding style policy and Doxygen comment fixes.
2011-09-26 16:32:56 -04:00
Wayne Stambaugh db0e93fa8e Minor common PCB library code fixes.
* More common header file compiler fixes.
* Translate French code naming and comments.
* Remove global variable ScreenPcb.
* Dead code removal.
2011-09-24 14:33:28 -04:00
jean-pierre charras c8a041fbeb Use accelerators from hot keys in place menu, from the Fabrizio's idea 2011-09-24 19:15:29 +02:00
Marco Mattila 273d14d8a0 Fix drawsegment bounding box and hittest issues in pcbnew. 2011-09-24 01:40:36 +03:00
jean-pierre charras 024592281f Preparing hotkeys/shortcuts changes in place menu. 2011-09-23 22:00:30 +02:00
Wayne Stambaugh 5dbcca1543 PCB common library header rationalization.
* All header files used to create the PCB common library now compile as
  stand alone code.  This prevents the need to define them in a specific
  order to make source code compile properly.  It should also now be
  possible to relocate the source code to build the common PCB library
  to a separate folder.
2011-09-23 09:57:12 -04:00
JP Charras and Fabrizio Tappero, fabrizio.tappero b57b079c9b Update .cpp icon files not updated in previous commit.
Fix minor issues.
Fic compil issue in dimension.cpp with wxMSW 2.8.12 (wxMSW 2.8.12 only).
2011-09-22 21:16:55 +02:00
12396 changed files with 1040670 additions and 6496353 deletions
+47
View File
@@ -0,0 +1,47 @@
boost_root
.downloads-by-cmake
Build
common/netlist_keywords.*
common/netlist_lexer.h
common/pcb_plot_params_lexer.h
common/page_layout/page_layout_reader_keywords.cpp
common/fp_lib_table_keywords.*
common/gal/opengl/shader_src.h
include/fp_lib_table_lexer.h
include/netlist_lexer.h
include/page_layout_reader_lexer.h
eeschema/cmp_library_lexer.h
eeschema/cmp_library_keywords.*
eeschema/dialogs/dialog_bom_cfg_keywords.cpp
eeschema/dialogs/dialog_bom_cfg_lexer.h
eeschema/dialogs/dialog_bom_help_html.h
eeschema/template_fieldnames_keywords.*
eeschema/template_fieldnames_lexer.h
pcbnew/dialogs/dialog_freeroute_exchange_help_html.h
pcbnew/pcb_plot_params_keywords.cpp
pcbnew/pcb_plot_params_lexer.h
Makefile
CMakeCache.txt
auto_renamed_to_cpp
Testing
version.h
config.h
install_manifest.txt
Documentation/doxygen
Documentation/development/doxygen
*.bak
common/pcb_plot_params_keywords.cpp
include/pcb_plot_params_lexer.h
pcbnew/specctra_keywords.cpp
pcbnew/specctra_lexer.h
pcb_calculator/pcb_calculator_datafile_keywords.cpp
pcb_calculator/pcb_calculator_datafile_lexer.h
new/html
new/sch_lib_table_keywords.cpp
new/sch_lib_table_lexer.h
new/sweet_keywords.cpp
new/sweet_lexer.h
bitmaps_png/png*
bitmaps_png/tmp
common/pcb_keywords.cpp
include/pcb_lexer.h
-5
View File
@@ -1,5 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-or-later
Checks: '-clang-diagnostic-*,clang-analyzer-*, bugprone-*, modernize-deprecated-headers, modernize-loop-convert, modernize-use-override, modernize-redundant-void-arg, modernize-use-emplace, modernize-use-noexcept, modernize-use-bool-literals, modernize-pass-by-value, modernize-use-equals-default, modernize-use-equals-delete, modernize-use-default-member-init, cppcoreguidelines-prefer-member-initializer, cppcoreguidelines-init-variables, cppcoreguidelines-pro-type-member-init'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
FormatStyle: 'file'
-32
View File
@@ -1,32 +0,0 @@
# Custom attribute to mark source files using KiCad C++ formatting
[attr]kicad-cpp-source text=auto whitepace=tab-in-indent format.clang-format-kicad
# Custom attribute to mark KiCad's own CMake files
[attr]kicad-cmake-source text=auto whitespace=tab-in-indent
# Custom attribute for auto-generated sources:
# * Do not perform whitespace checking
# * Do not format
[attr]generated whitespace=-tab-in-indent,-indent-with-non-tab -format.clang-format-kicad
# By default, all C and C++ files conform to KiCad formatting,
# unless overridden
*.c kicad-cpp-source
*.cpp kicad-cpp-source
*.h kicad-cpp-source
*.cmake kicad-cmake-source
*.txt kicad-cmake-source
*.md text=auto
# Compiled bitmap sources
bitmaps_png/cpp_*/*.cpp generated
# wxFormBuilder-generated files
**/dialog*/*_base.cpp generated
**/dialog*/*_base.h generated
# Lemon grammars
common/libeval/grammar.c generated
common/libeval/grammar.h generated
-49
View File
@@ -1,49 +0,0 @@
#!/usr/bin/env bash
#
# Git "hook chain", used to execute multiple scripts per hook.
# To use:
# * create a directory called <hookname>.d
# * add scripts to this directory (executable)
# * ln -s hook-chain <hookname>
#
# Now the scripts in that directory should be called in order.
#
# Set $HOOKCHAIN_DEBUG to see the names of invoked scripts.
#
# Based on script by Oliver Reflalo:
# https://stackoverflow.com/questions/8730514/chaining-git-hooks
#
hookname=`basename $0`
# Temp file for stdin, cleared at exit
FILE=`mktemp`
trap 'rm -f $FILE' EXIT
cat - > $FILE
# Git hooks directory (this dir)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Execute hooks in the directory one by one
for hook in $DIR/$hookname.d/*;
do
if [ -x "$hook" ]; then
if [ "$HOOKCHAIN_DEBUG" ]; then
echo "Running hook $hook"
fi
cat $FILE | $hook "$@"
status=$?
if [ $status -ne 0 ]; then
echo "Hook $hook failed with error code $status"
echo "To commit anyway, use --no-verify"
exit $status
else
if [ "$HOOKCHAIN_DEBUG" ]; then
echo "Hook passed: $hook"
fi
fi
fi
done
-1
View File
@@ -1 +0,0 @@
hook-chain
-91
View File
@@ -1,91 +0,0 @@
#!/usr/bin/env bash
#
# Runs clang-format on changed regions before commit.
#
# Remaining installation checks/instructions will be printed when you commit.
#
# Based on clang-format pre-commit hook by Alex Eagle
# https://gist.github.com/alexeagle/c8ed91b14a407342d9a8e112b5ac7dab
# Set kicad.check-format to allow this hook to run
# If not set, the hook always succeeds.
do_format=false
# Check if formatting is configured
if [ "$(git config --get kicad.check-format)" = true ]; then
do_format=true
fi
# Older env variable method
if [ ! -z "$KICAD_CHECK_FORMAT" ]; then
do_format=true
fi
if [ ! ${do_format} = true ]; then
# No formatting required
exit 0;
fi
check_clang_format() {
if hash git-clang-format 2>/dev/null; then
return
else
echo "SETUP ERROR: no git-clang-format executable found, or it is not executable"
exit 1
fi
}
check_git_config() {
if [[ "$(git config --get clangFormat.style)" != "file" ]]; then
echo "SETUP ERROR: git config clangFormat.style is wrong (should be 'file'). Fix this with:"
echo "git config clangFormat.style file"
exit 1
fi
}
get_filtered_filenames()
{
format_attr='clang-format-kicad'
# command to get list of candidate files
git_list_files='git diff --cached --name-only --diff-filter=ACM'
files=$(${git_list_files} |
# Filter for format-controlled files
git check-attr --stdin format.${format_attr} |
# output only the file names
grep ": set$" |
cut -d: -f1)
echo ${files}
}
check_clang_format
check_git_config
files_to_check=$(get_filtered_filenames)
if [ -z "${files_to_check}" ]; then
# No controlled files to check
exit 0;
fi
git_clang_format_cmd="git clang-format -v --diff -- ${files_to_check}"
readonly out=$(${git_clang_format_cmd})
# In these cases, there is no formatting issues, so we succeed
if [[ "$out" == *"no modified files to format"* ]]; then exit 0; fi
if [[ "$out" == *"clang-format did not modify any files"* ]]; then exit 0; fi
# Any other case implies formatting results
echo "ERROR: you need to run clang-format (e.g. using tools/check_coding.sh) on your commit"
# print the errors to show what's the issue
${git_clang_format_cmd}
# fail the pre-commit
exit 1
-2
View File
@@ -1,2 +0,0 @@
community_bridge: kicad
custom: "https://donate.cernandsocietyfoundation.cern/b/my-donation?cid=4&_cv=1"
-26
View File
@@ -1,26 +0,0 @@
name: 'Redirect PRs'
on:
pull_request:
types: opened
jobs:
lockdown:
runs-on: ubuntu-latest
steps:
- uses: dessant/repo-lockdown@v2
with:
github-token: ${{ github.token }}
pr-comment: >
Thank you for offering to help improve KiCad.
This repository is a one-way mirror that can not accept pull requests.
Please submit your merge request to the official KiCad repository
at https://gitlab.com/kicad/code/kicad/-/merge_requests
While we know that _your_ PR is not spam, we mark it as such to dissuade
the Hacktoberfest PRs. Please join us over at GitLab. You can even use
your GitHub credentials to log in there without creating a new account.
skip-closed-pr-comment: true
pr-labels: 'spam'
close-pr: true
lock-pr: true
pr-lock-reason: 'spam'
-132
View File
@@ -1,132 +0,0 @@
.downloads-by-cmake
.gdb_history
boost_root
/Build
/build
/cmake-build-*
common/fp_lib_table_keywords.cpp
common/drc_rules_keywords.cpp
common/drc_rules_lexer.h
common/netlist_keywords.*
common/netlist_lexer.h
common/pcb_plot_params_lexer.h
common/drawing_sheet/drawing_sheet_reader_keywords.cpp
common/lib_table_keywords.*
common/gal/opengl/shader_src.h
include/fp_lib_table_lexer.h
include/lib_table_lexer.h
include/netlist_lexer.h
include/page_layout_reader_lexer.h
eeschema/cmp_library_lexer.h
eeschema/cmp_library_keywords.*
eeschema/dialogs/dialog_bom_cfg_keywords.cpp
eeschema/dialogs/dialog_bom_cfg_lexer.h
common/template_fieldnames_keywords.cpp
common/template_fieldnames_lexer.h
eeschema/schematic_keywords.*
pcbnew/pcb_plot_params_keywords.cpp
pcbnew/pcb_plot_params_lexer.h
Makefile
CMakeCache.txt
.cache/
auto_renamed_to_cpp
Testing
version.h
config.h
install_manifest.txt
doxygen/out
*.bak
*.pyc
common/pcb_plot_params_keywords.cpp
include/pcb_plot_params_lexer.h
pcbnew/specctra_import_export/specctra_keywords.cpp
pcbnew/specctra_import_export/specctra_lexer.h
pcb_calculator/pcb_calculator_datafile_keywords.cpp
pcb_calculator/pcb_calculator_datafile_lexer.h
new/html
new/sch_lib_table_keywords.cpp
new/sch_lib_table_lexer.h
new/sweet_keywords.cpp
new/sweet_lexer.h
bitmaps_png/tmp
common/pcb_keywords.cpp
include/pcb_lexer.h
fp-info-cache
# demo project auxiliary files
demos/**/*-bak
demos/**/_autosave-*
demos/**/fp-info-cache
# MacOS package info created by CMake
bitmap2component/Info.plist
cvpcb/Info.plist
eeschema/Info.plist
gerbview/Info.plist
kicad/Info.plist
pagelayout_editor/Info.plist
pcb_calculator/Info.plist
pcbnew/Info.plist
# editor/OS fluff
.*.swp
*~
.idea
.DS_Store
*.png
*.kiface
*.o
*.o.*
*.a
*.a.*
*.orig
*.rej
*.so
*.old
*.gch
*.orig
*.patch
# These CMake files are wanted
!cmake/**/*.cmake
# Eclipse IDE
.settings/
.project
.cproject
.pydevproject
__pycache__
# Visual Studio
.vs/
.editorconfig
CMakeSettings.json
.vscode/
# Sublime Text
*.sublime-*
# KDevelop
.kdev4/
*.kdev4
# Translations
*.mo
i18n_status.svg
i18n_status.csv
# Project local settings files and backups (in demos and qa tests)
*.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/**/*
# Junk temp files generated by MSVC for resource files
/resources/msw/RC*
-48
View File
@@ -1,48 +0,0 @@
stages:
- build
- test
- report
default:
image:
name: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:36
entrypoint: ["/bin/sh", "-c"]
##########################################################################
# Test the formatting in a merge request using clang-format
##########################################################################
# The variable CI_COMMIT_BEFORE_SHA is not available in normal merge requests
# so we must build the commit hash ourselves, see:
# https://gitlab.com/gitlab-org/gitlab/-/issues/12850
test_formatting:
stage: test
needs: []
only:
- merge_requests
allow_failure: true
before_script:
# We must manually add the KiCad remote to ensure it is named sensibly
- git remote add product https://gitlab.com/kicad/code/kicad.git ||
git remote 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 fetch -n product
- git fetch -n source
# Get the SHAs of the commits
- "TARGET_HEAD_SHA=$(git rev-parse product/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME})"
- "SOURCE_HEAD_SHA=$(git rev-parse source/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME})"
- "MERGE_BASE_SHA=$(git merge-base ${TARGET_HEAD_SHA} ${SOURCE_HEAD_SHA})"
script:
- echo "Testing formatting from commit ${MERGE_BASE_SHA}"
- ./tools/check_coding.sh --diff --ci --commit ${MERGE_BASE_SHA}
include:
- local: '/.gitlab/templates.yml'
- local: '/.gitlab/Fedora-Linux-CI.yml'
- local: '/.gitlab/Ubuntu-20.04-CI.yml'
- local: '/.gitlab/Windows-CI.yml'
- local: '/.gitlab/coverity.yml'
- local: '/.gitlab/linux-metadata-validate.yml'
- local: '/.gitlab/doxygen.yml'
-165
View File
@@ -1,165 +0,0 @@
##########################################################################
# Build KiCad on Fedora and save the results
##########################################################################
.fedora_build_linux_base:
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
extends: .only_code
interruptible: false
cache:
key: "cache-fedora-linux"
paths:
- ccache/
before_script:
# CCache Config
- mkdir -p ccache
- export CCACHE_BASEDIR=${PWD}
- export CCACHE_DIR=${PWD}/ccache
script:
- mkdir -p build/linux
- cd build/linux
- cmake
-G Ninja
-DCMAKE_BUILD_TYPE=QABUILD
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SPICE=ON
-DKICAD_BUILD_I18N=ON
../../
- ninja 2>&1 | tee compilation_log.txt
- cd ../../
artifacts:
# Only save the artifacts that are needed for running the tests in the next stage
# and the compilation log. The entire build directory is too large to save as an
# artifact.
expire_in: 2 hrs
when: always
paths:
- build/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:
stage: report
extends: .only_code
when: always
script:
- echo "Uploading compilation log"
- cp build/linux/compilation_log.txt compilation_log.txt
artifacts:
expire_in: 1 year
expose_as: 'Build log'
name: "build_log.txt"
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:
stage: report
extends: .only_code
when: always
script:
- cat build/linux/compilation_log.txt | { grep "warning:" || test $? = 1; } | awk 'END{print "number_of_fedora_warnings "NR}' > metrics.txt
- cat metrics.txt
artifacts:
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
extends:
- .unit_test
- .only_code
parallel:
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
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"
-119
View File
@@ -1,119 +0,0 @@
##########################################################################
# Build KiCad on Ubuntu 20.04 and save the results
##########################################################################
.ubuntu20.04_build:
stage: build
tags:
- kicad-ubuntu20.04
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/ubuntu:20.04
only:
- branches@kicad/code/kicad
- tags@kicad/code/kicad
except:
- schedules
interruptible: false
cache:
key: "cache-ubuntu20.04-linux"
paths:
- ccache/
before_script:
# CCache Config
- mkdir -p ccache
- export CCACHE_BASEDIR=${PWD}
- export CCACHE_DIR=${PWD}/ccache
script:
- mkdir -p build/linux
- cd build/linux
- cmake
-G Ninja
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_BUILD_TYPE=Release
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SCRIPTING_WXPYTHON=ON
-DKICAD_USE_OCC=ON
-DKICAD_SPICE=ON
-DKICAD_BUILD_I18N=ON
-DKICAD_BUILD_PNS_DEBUG_TOOL=ON
../../
- ninja 2>&1 | tee compilation_log.txt
- cd ../../
artifacts:
# Only save the artifacts that are needed for running the tests in the next stage
# and the compilation log. The entire build directory is too large to save as an
# artifact.
expire_in: 2 hrs
when: always
paths:
- build/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:
stage: report
when: always
only:
- branches@kicad/code/kicad
- tags@kicad/code/kicad
except:
- schedules
needs:
- job: ubuntu20.04_build
artifacts: true
script:
- echo "Uploading compilation log"
- cp build/linux/compilation_log.txt compilation_log.txt
artifacts:
expire_in: 1 year
expose_as: 'Build log'
name: "build_log.txt"
paths:
- compilation_log.txt
# Report on the metrics of the code
.ubuntu20.04_report_metrics:
stage: report
when: always
only:
- branches@kicad/code/kicad
- tags@kicad/code/kicad
except:
- schedules
needs:
- job: ubuntu20.04_build
artifacts: true
script:
- cat build/linux/compilation_log.txt | { grep "warning:" || test $? = 1; } | awk 'END{print "number_of_ubuntu_20.04_warnings "NR}' > metrics.txt
- cat metrics.txt
artifacts:
reports:
metrics: metrics.txt
##########################################################################
# Run the code unit tests.
##########################################################################
.ubuntu20.04_qa:
extends:
- .unit_test
needs:
- job: ubuntu20.04_build
artifacts: true
tags:
- kicad-ubuntu20.04
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/ubuntu:20.04
only:
- branches@kicad/code/kicad
- tags@kicad/code/kicad
except:
- schedules
parallel:
matrix:
# The name of the test without the qa_ prefix
- TEST: [python, common, gerbview, pcbnew, eeschema, kimath, sexpr, kicad2step]
-47
View File
@@ -1,47 +0,0 @@
##########################################################################
# Build KiCad on Windows and save the results
##########################################################################
win64_build:
stage: build
tags:
- 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
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_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 ../../
artifacts:
# Only save the artifacts that are needed for running the tests in the next stage
# and the compilation log. The entire build directory is too large to save as an
# artifact.
expire_in: 2 hrs
when: always
paths:
- build/windows/compilation_log.txt
-70
View File
@@ -1,70 +0,0 @@
# This script is responsible for configuring the coverity file from the cache
# (e.g. extracting it or updating it if needed)
.coverity_cache_prep: &coverity_cache_prep |
echo "Downloading MD5 hash of current Coverity Scan version to compare against cache"
curl --output cov-analysis-linux64.md5 https://scan.coverity.com/download/linux64 \
--form project=$COVERITY_SCAN_PROJECT_NAME \
--form token=$COVERITY_SCAN_TOKEN \
--form md5=1
echo " *cov-analysis-linux64.tgz" >> cov-analysis-linux64.md5
(md5sum --ignore-missing -c cov-analysis-linux64.md5) || (
echo "Downloading new Coverity Scan version"
curl --output cov-analysis-linux64.tgz https://scan.coverity.com/download/linux64 \
--form project=$COVERITY_SCAN_PROJECT_NAME \
--form token=$COVERITY_SCAN_TOKEN
)
echo "Extracting Coverity Scan"
mkdir coverity/
tar xzf cov-analysis-linux64.tgz --strip-components=1 -C coverity
test -d coverity/bin
# This script is responsible for tar'ing and submitting the results of the build.
# These results will be saved for 1 day if the build fails.
.coverity_submit: &coverity_submit |
echo "Creating tar file of scan results"
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 \
--form token=$COVERITY_SCAN_TOKEN \
--form email=$GITLAB_USER_EMAIL \
--form file=@cov-int.tar.gz \
--form version="$KICAD_VERSION" \
--form description="$KICAD_VERSION / $CI_COMMIT_TITLE" 2>&1 \
| tee curl-response.txt
grep -q 'Build successfully submitted' curl-response.txt
Coverity:
tags:
- coverity
stage: build
image: registry.gitlab.com/kicad/kicad-ci/source_containers/master/fedora:37
only:
refs:
- schedules
variables:
- $SCHEDULED_JOB_NAME == "coverity"
cache:
key: coverity
paths:
- cov-analysis-linux64.tgz
before_script:
- export COVERITY_SCAN_PROJECT_NAME="kicad"
- test "$(git rev-parse --is-shallow-repository)" = "false" || (git fetch --unshallow)
- git fetch origin
script:
- *coverity_cache_prep
- cmake
-DCMAKE_BUILD_TYPE=Debug
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SCRIPTING_WXPYTHON=ON
-DKICAD_SPICE=ON
- coverity/bin/cov-build --dir cov-int make -j8
- *coverity_submit
artifacts:
expire_in: 1 year
expose_as: 'Coverity log'
name: "coverity_log.txt"
paths:
- cov-int/build-log.txt
-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
-39
View File
@@ -1,39 +0,0 @@
##########################################################################
# Run a validation of the metadata files for Linux
##########################################################################
validate_linux_metadata:
stage: test
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
# 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
only:
refs:
- master
- branches
- merge_requests
- pushes
changes:
# Only run if the resources, its tests, or the translations are updated
- resources/linux/**/*
- qa/resources/linux/**/*
- translation/**/*
except:
- schedules
# Only build the metadata files in this CI job
script:
- mkdir -p build/linux
- cd build/linux
- cmake
-DCMAKE_BUILD_TYPE=Debug
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_SCRIPTING_WXPYTHON=ON
-DKICAD_SPICE=ON
-DKICAD_BUILD_I18N=ON
../../
- make metadata
- cd ../../
- ./qa/resources/linux/verifyMetadataFiles.sh ./ ./build/linux
-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}
-37
View File
@@ -1,37 +0,0 @@
##########################################################################
# This will allow the job to run whenever code events trigger it.
##########################################################################
.only_code:
only:
- master
- branches
- merge_requests
- pushes
except:
- schedules
##########################################################################
# Define a template for all the unit tests, since each one is run in a separate
# job to make the display nicer.
##########################################################################
.unit_test:
stage: test
when: on_success
# We define this using a before script because GitLab cannot merge variable
# definitions across inheritance (so the variables block from this would disappear)
before_script:
- export BOOST_TEST_LOGGER='JUNIT,all,test_results.${TEST}.xml:HRF,warning'
- export CTEST_OUTPUT_ON_FAILURE=1
script:
- cd build/linux/qa
- ctest -R qa_${TEST}
# GitLab supports displaying the results in the GUI through JUNIT artifacts
# (https://docs.gitlab.com/ee/ci/junit_test_reports.html)
# so we upload the JUNIT results. Note that there is a bug with how paths
# are processed in the junit report (https://gitlab.com/gitlab-org/gitlab/-/issues/23835)
# so we can't use a glob and have to list out each hierarchy separately.
artifacts:
reports:
junit:
- build/linux/qa/*/*.xml
- build/linux/qa/*/*/*.xml
+215
View File
@@ -0,0 +1,215 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_aux.cpp
*/
#include <fctsys.h>
#include <common.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <class_board_design_settings.h>
#include <class_zone.h>
#include <class_text_mod.h>
#include <class_module.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
void S3D_MASTER::ObjectCoordsTo3DUnits( std::vector< S3D_VERTEX >& aVertices )
{
/* adjust object scale, rotation and offset position */
for( unsigned ii = 0; ii < aVertices.size(); ii++ )
{
aVertices[ii].x *= m_MatScale.x;
aVertices[ii].y *= m_MatScale.y;
aVertices[ii].z *= m_MatScale.z;
// adjust rotation
if( m_MatRotation.x )
RotatePoint( &aVertices[ii].y, &aVertices[ii].z, m_MatRotation.x * 10 );
if( m_MatRotation.y )
RotatePoint( &aVertices[ii].z, &aVertices[ii].x, m_MatRotation.y * 10 );
if( m_MatRotation.z )
RotatePoint( &aVertices[ii].x, &aVertices[ii].y, m_MatRotation.z * 10 );
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
#define SCALE_3D_CONV ((IU_PER_MILS * 1000) / UNITS3D_TO_UNITSPCB)
aVertices[ii].x += m_MatPosition.x * SCALE_3D_CONV;
aVertices[ii].y += m_MatPosition.y * SCALE_3D_CONV;
aVertices[ii].z += m_MatPosition.z * SCALE_3D_CONV;
}
}
void TransfertToGLlist( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits )
{
unsigned ii;
GLfloat ax, ay, az, bx, by, bz, nx, ny, nz, r;
/* ignore faces with less than 3 points */
if( aVertices.size() < 3 )
return;
/* calculate normal direction */
ax = aVertices[1].x - aVertices[0].x;
ay = aVertices[1].y - aVertices[0].y;
az = aVertices[1].z - aVertices[0].z;
bx = aVertices[aVertices.size() - 1].x - aVertices[0].x;
by = aVertices[aVertices.size() - 1].y - aVertices[0].y;
bz = aVertices[aVertices.size() - 1].z - aVertices[0].z;
nx = ay * bz - az * by;
ny = az * bx - ax * bz;
nz = ax * by - ay * bx;
r = sqrt( nx * nx + ny * ny + nz * nz );
if( r >= 0.000001 ) /* avoid division by zero */
{
nx /= r;
ny /= r;
nz /= r;
glNormal3f( nx, ny, nz );
}
/* glBegin/glEnd */
switch( aVertices.size() )
{
case 3:
glBegin( GL_TRIANGLES );
break;
case 4:
glBegin( GL_QUADS );
break;
default:
glBegin( GL_POLYGON );
break;
}
/* draw polygon/triangle/quad */
for( ii = 0; ii < aVertices.size(); ii++ )
{
glVertex3d( aVertices[ii].x * aBiuTo3DUnits,
aVertices[ii].y * aBiuTo3DUnits,
aVertices[ii].z * aBiuTo3DUnits );
}
glEnd();
}
VERTEX_VALUE_CTRL::VERTEX_VALUE_CTRL( wxWindow* aParent, wxBoxSizer* aBoxSizer )
{
wxString text;
wxFlexGridSizer* gridSizer = new wxFlexGridSizer( 0, 2, 0, 0 );
gridSizer->AddGrowableCol( 1 );
gridSizer->SetFlexibleDirection( wxHORIZONTAL );
gridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
aBoxSizer->Add( gridSizer, 0, wxEXPAND, 5 );
wxStaticText* msgtitle = new wxStaticText( aParent, wxID_ANY, wxT( "X:" ) );
gridSizer->Add( msgtitle, 0, wxALL , 5 );
m_XValueCtrl = new wxTextCtrl( aParent, wxID_ANY, wxEmptyString,
wxDefaultPosition,wxDefaultSize, 0 );
gridSizer->Add( m_XValueCtrl, 0, wxALL|wxEXPAND, 5 );
msgtitle = new wxStaticText( aParent, wxID_ANY, wxT( "Y:" ), wxDefaultPosition,
wxDefaultSize, 0 );
gridSizer->Add( msgtitle, 0, wxALL, 5 );
m_YValueCtrl = new wxTextCtrl( aParent, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0 );
gridSizer->Add( m_YValueCtrl, 0, wxALL|wxEXPAND, 5 );
msgtitle = new wxStaticText( aParent, wxID_ANY, wxT( "Z:" ), wxDefaultPosition,
wxDefaultSize, 0 );
gridSizer->Add( msgtitle, 0, wxALL, 5 );
m_ZValueCtrl = new wxTextCtrl( aParent, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0 );
gridSizer->Add( m_ZValueCtrl, 0, wxALL|wxEXPAND, 5 );
}
VERTEX_VALUE_CTRL::~VERTEX_VALUE_CTRL()
{
}
S3D_VERTEX VERTEX_VALUE_CTRL::GetValue()
{
S3D_VERTEX value;
double dtmp;
m_XValueCtrl->GetValue().ToDouble( &dtmp );
value.x = dtmp;
m_YValueCtrl->GetValue().ToDouble( &dtmp );
value.y = dtmp;
m_ZValueCtrl->GetValue().ToDouble( &dtmp );
value.z = dtmp;
return value;
}
void VERTEX_VALUE_CTRL::SetValue( S3D_VERTEX vertex )
{
wxString text;
text.Printf( wxT( "%f" ), vertex.x );
m_XValueCtrl->Clear();
m_XValueCtrl->AppendText( text );
text.Printf( wxT( "%f" ), vertex.y );
m_YValueCtrl->Clear();
m_YValueCtrl->AppendText( text );
text.Printf( wxT( "%f" ), vertex.z );
m_ZValueCtrl->Clear();
m_ZValueCtrl->AppendText( text );
}
void VERTEX_VALUE_CTRL::Enable( bool onoff )
{
m_XValueCtrl->Enable( onoff );
m_YValueCtrl->Enable( onoff );
m_ZValueCtrl->Enable( onoff );
}
-759
View File
@@ -1,759 +0,0 @@
/*
* 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
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define GLM_FORCE_RADIANS
#include <mutex>
#include <utility>
#include <wx/datetime.h>
#include <wx/dir.h>
#include <wx/log.h>
#include <wx/stdpaths.h>
#include <boost/version.hpp>
#if BOOST_VERSION >= 106800
#include <boost/uuid/detail/sha1.hpp>
#else
#include <boost/uuid/sha1.hpp>
#endif
#include "3d_cache.h"
#include "3d_info.h"
#include "3d_plugin_manager.h"
#include "sg/scenegraph.h"
#include "plugins/3dapi/ifsg_api.h"
#include <advanced_config.h>
#include <common.h> // For ExpandEnvVarSubstitutions
#include <filename_resolver.h>
#include <paths.h>
#include <pgm_base.h>
#include <project.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <wx_filename.h>
#define MASK_3D_CACHE "3D_CACHE"
static std::mutex mutex3D_cache;
static std::mutex mutex3D_cacheManager;
static bool isSHA1Same( const unsigned char* shaA, const unsigned char* shaB ) noexcept
{
for( int i = 0; i < 20; ++i )
{
if( shaA[i] != shaB[i] )
return false;
}
return true;
}
static bool checkTag( const char* aTag, void* aPluginMgrPtr )
{
if( nullptr == aTag || nullptr == aPluginMgrPtr )
return false;
S3D_PLUGIN_MANAGER *pp = (S3D_PLUGIN_MANAGER*) aPluginMgrPtr;
return pp->CheckTag( aTag );
}
static const wxString sha1ToWXString( const unsigned char* aSHA1Sum )
{
unsigned char uc;
unsigned char tmp;
char sha1[41];
int j = 0;
for( int i = 0; i < 20; ++i )
{
uc = aSHA1Sum[i];
tmp = uc / 16;
if( tmp > 9 )
tmp += 87;
else
tmp += 48;
sha1[j++] = tmp;
tmp = uc % 16;
if( tmp > 9 )
tmp += 87;
else
tmp += 48;
sha1[j++] = tmp;
}
sha1[j] = 0;
return wxString::FromUTF8Unchecked( sha1 );
}
class S3D_CACHE_ENTRY
{
public:
S3D_CACHE_ENTRY();
~S3D_CACHE_ENTRY();
void SetSHA1( const unsigned char* aSHA1Sum );
const wxString GetCacheBaseName();
wxDateTime modTime; // file modification time
unsigned char sha1sum[20];
std::string pluginInfo; // PluginName:Version string
SCENEGRAPH* sceneData;
S3DMODEL* renderData;
private:
// prohibit assignment and default copy constructor
S3D_CACHE_ENTRY( const S3D_CACHE_ENTRY& source );
S3D_CACHE_ENTRY& operator=( const S3D_CACHE_ENTRY& source );
wxString m_CacheBaseName; // base name of cache file (a SHA1 digest)
};
S3D_CACHE_ENTRY::S3D_CACHE_ENTRY()
{
sceneData = nullptr;
renderData = nullptr;
memset( sha1sum, 0, 20 );
}
S3D_CACHE_ENTRY::~S3D_CACHE_ENTRY()
{
delete sceneData;
if( nullptr != renderData )
S3D::Destroy3DModel( &renderData );
}
void S3D_CACHE_ENTRY::SetSHA1( const unsigned char* aSHA1Sum )
{
if( nullptr == aSHA1Sum )
{
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [BUG] NULL passed for aSHA1Sum" ),
__FILE__, __FUNCTION__, __LINE__ );
return;
}
memcpy( sha1sum, aSHA1Sum, 20 );
}
const wxString S3D_CACHE_ENTRY::GetCacheBaseName()
{
if( m_CacheBaseName.empty() )
m_CacheBaseName = sha1ToWXString( sha1sum );
return m_CacheBaseName;
}
S3D_CACHE::S3D_CACHE()
{
m_FNResolver = new FILENAME_RESOLVER;
m_project = nullptr;
m_Plugins = new S3D_PLUGIN_MANAGER;
}
S3D_CACHE::~S3D_CACHE()
{
FlushCache();
delete m_FNResolver;
delete m_Plugins;
}
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePath,
S3D_CACHE_ENTRY** aCachePtr )
{
if( aCachePtr )
*aCachePtr = nullptr;
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile, aBasePath );
if( full3Dpath.empty() )
{
// the model cannot be found; we cannot proceed
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [3D model] could not find model '%s'\n" ),
__FILE__, __FUNCTION__, __LINE__, aModelFile );
return nullptr;
}
// check cache if file is already loaded
std::lock_guard<std::mutex> lock( mutex3D_cache );
std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString >::iterator mi;
mi = m_CacheMap.find( full3Dpath );
if( mi != m_CacheMap.end() )
{
wxFileName fname( full3Dpath );
if( fname.FileExists() ) // Only check if file exists. If not, it will
{ // use the same model in cache.
bool reload = ADVANCED_CFG::GetCfg().m_Skip3DModelMemoryCache;
wxDateTime fmdate = fname.GetModificationTime();
if( fmdate != mi->second->modTime )
{
unsigned char hashSum[20];
getSHA1( full3Dpath, hashSum );
mi->second->modTime = fmdate;
if( !isSHA1Same( hashSum, mi->second->sha1sum ) )
{
mi->second->SetSHA1( hashSum );
reload = true;
}
}
if( reload )
{
if( nullptr != mi->second->sceneData )
{
S3D::DestroyNode( mi->second->sceneData );
mi->second->sceneData = nullptr;
}
if( nullptr != mi->second->renderData )
S3D::Destroy3DModel( &mi->second->renderData );
mi->second->sceneData = m_Plugins->Load3DModel( full3Dpath,
mi->second->pluginInfo );
}
}
if( nullptr != aCachePtr )
*aCachePtr = mi->second;
return mi->second->sceneData;
}
// a cache item does not exist; search the Filename->Cachename map
return checkCache( full3Dpath, aCachePtr );
}
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath )
{
return load( aModelFile, aBasePath );
}
SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** aCachePtr )
{
if( aCachePtr )
*aCachePtr = nullptr;
unsigned char sha1sum[20];
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
m_CacheList.push_back( ep );
wxFileName fname( aFileName );
ep->modTime = fname.GetModificationTime();
if( !getSHA1( aFileName, sha1sum ) || m_CacheDir.empty() )
{
// just in case we can't get a hash digest (for example, on access issues)
// or we do not have a configured cache file directory, we create an
// entry to prevent further attempts at loading the file
if( m_CacheMap.emplace( aFileName, ep ).second == false )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
m_CacheList.pop_back();
delete ep;
}
else
{
if( aCachePtr )
*aCachePtr = ep;
}
return nullptr;
}
if( m_CacheMap.emplace( aFileName, ep ).second == false )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * [BUG] duplicate entry in map file; key = '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
m_CacheList.pop_back();
delete ep;
return nullptr;
}
if( aCachePtr )
*aCachePtr = ep;
ep->SetSHA1( sha1sum );
wxString bname = ep->GetCacheBaseName();
wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && wxFileName::FileExists( cachename )
&& loadCacheData( ep ) )
return ep->sceneData;
ep->sceneData = m_Plugins->Load3DModel( aFileName, ep->pluginInfo );
if( !ADVANCED_CFG::GetCfg().m_Skip3DModelFileCache && nullptr != ep->sceneData )
saveCacheData( ep );
return ep->sceneData;
}
bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum )
{
if( aFileName.empty() )
{
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * [BUG] empty filename" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
if( nullptr == aSHA1Sum )
{
wxLogTrace( MASK_3D_CACHE, wxT( "%s\n * [BUG] NULL pointer passed for aMD5Sum" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
#ifdef _WIN32
FILE* fp = _wfopen( aFileName.wc_str(), L"rb" );
#else
FILE* fp = fopen( aFileName.ToUTF8(), "rb" );
#endif
if( nullptr == fp )
return false;
boost::uuids::detail::sha1 dblock;
unsigned char block[4096];
size_t bsize = 0;
while( ( bsize = fread( &block, 1, 4096, fp ) ) > 0 )
dblock.process_bytes( block, bsize );
fclose( fp );
unsigned int digest[5];
dblock.get_digest( digest );
// ensure MSB order
for( int i = 0; i < 5; ++i )
{
int idx = i << 2;
unsigned int tmp = digest[i];
aSHA1Sum[idx+3] = tmp & 0xff;
tmp >>= 8;
aSHA1Sum[idx+2] = tmp & 0xff;
tmp >>= 8;
aSHA1Sum[idx+1] = tmp & 0xff;
tmp >>= 8;
aSHA1Sum[idx] = tmp & 0xff;
}
return true;
}
bool S3D_CACHE::loadCacheData( S3D_CACHE_ENTRY* aCacheItem )
{
wxString bname = aCacheItem->GetCacheBaseName();
if( bname.empty() )
{
wxLogTrace( MASK_3D_CACHE,
wxT( " * [3D model] cannot load cached model; no file hash available" ) );
return false;
}
if( m_CacheDir.empty() )
{
wxLogTrace( MASK_3D_CACHE,
wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
return false;
}
wxString fname = m_CacheDir + bname + wxT( ".3dc" );
if( !wxFileName::FileExists( fname ) )
{
wxLogTrace( MASK_3D_CACHE, wxT( " * [3D model] cannot open file '%s'" ), fname.GetData() );
return false;
}
if( nullptr != aCacheItem->sceneData )
S3D::DestroyNode( (SGNODE*) aCacheItem->sceneData );
aCacheItem->sceneData = (SCENEGRAPH*)S3D::ReadCache( fname.ToUTF8(), m_Plugins, checkTag );
if( nullptr == aCacheItem->sceneData )
return false;
return true;
}
bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
{
if( nullptr == aCacheItem )
{
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * NULL passed for aCacheItem" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
if( nullptr == aCacheItem->sceneData )
{
wxLogTrace( MASK_3D_CACHE, wxT( "%s:%s:%d\n * aCacheItem has no valid scene data" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
wxString bname = aCacheItem->GetCacheBaseName();
if( bname.empty() )
{
wxLogTrace( MASK_3D_CACHE,
wxT( " * [3D model] cannot load cached model; no file hash available" ) );
return false;
}
if( m_CacheDir.empty() )
{
wxLogTrace( MASK_3D_CACHE,
wxT( " * [3D model] cannot load cached model; config directory unknown" ) );
return false;
}
wxString fname = m_CacheDir + bname + wxT( ".3dc" );
if( wxFileName::Exists( fname ) )
{
if( !wxFileName::FileExists( fname ) )
{
wxLogTrace( MASK_3D_CACHE,
wxT( " * [3D model] path exists but is not a regular file '%s'" ), fname );
return false;
}
}
return S3D::WriteCache( fname.ToUTF8(), true, (SGNODE*)aCacheItem->sceneData,
aCacheItem->pluginInfo.c_str() );
}
bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
{
if( !m_ConfigDir.empty() )
return false;
wxFileName cfgdir( ExpandEnvVarSubstitutions( aConfigDir, m_project ), wxEmptyString );
cfgdir.Normalize( FN_NORMALIZE_FLAGS );
if( !cfgdir.DirExists() )
{
cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
if( !cfgdir.DirExists() )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * failed to create 3D configuration directory '%s'" ),
__FILE__, __FUNCTION__, __LINE__, cfgdir.GetPath() );
return false;
}
}
m_ConfigDir = cfgdir.GetPath();
// inform the file resolver of the config directory
if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * could not set 3D Config Directory on filename resolver\n"
" * config directory: '%s'" ),
__FILE__, __FUNCTION__, __LINE__, m_ConfigDir );
}
// 3D cache data must go to a user's cache directory;
// unfortunately wxWidgets doesn't seem to provide
// functions to retrieve such a directory.
//
// 1. OSX: ~/Library/Caches/kicad/3d/
// 2. Linux: ${XDG_CACHE_HOME}/kicad/3d ~/.cache/kicad/3d/
// 3. MSWin: AppData\Local\kicad\3d
wxFileName cacheDir;
cacheDir.AssignDir( PATHS::GetUserCachePath() );
cacheDir.AppendDir( wxT( "3d" ) );
if( !cacheDir.DirExists() )
{
cacheDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
if( !cacheDir.DirExists() )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * failed to create 3D cache directory '%s'" ),
__FILE__, __FUNCTION__, __LINE__, cacheDir.GetPath() );
return false;
}
}
m_CacheDir = cacheDir.GetPathWithSep();
return true;
}
bool S3D_CACHE::SetProject( PROJECT* aProject )
{
m_project = aProject;
bool hasChanged = false;
if( m_FNResolver->SetProject( aProject, &hasChanged ) && hasChanged )
{
m_CacheMap.clear();
std::list< S3D_CACHE_ENTRY* >::iterator sL = m_CacheList.begin();
std::list< S3D_CACHE_ENTRY* >::iterator eL = m_CacheList.end();
while( sL != eL )
{
delete *sL;
++sL;
}
m_CacheList.clear();
return true;
}
return false;
}
void S3D_CACHE::SetProgramBase( PGM_BASE* aBase )
{
m_FNResolver->SetProgramBase( aBase );
}
FILENAME_RESOLVER* S3D_CACHE::GetResolver() noexcept
{
return m_FNResolver;
}
std::list< wxString > const* S3D_CACHE::GetFileFilters() const
{
return m_Plugins->GetFileFilters();
}
void S3D_CACHE::FlushCache( bool closePlugins )
{
std::list< S3D_CACHE_ENTRY* >::iterator sCL = m_CacheList.begin();
std::list< S3D_CACHE_ENTRY* >::iterator eCL = m_CacheList.end();
while( sCL != eCL )
{
delete *sCL;
++sCL;
}
m_CacheList.clear();
m_CacheMap.clear();
if( closePlugins )
ClosePlugins();
}
void S3D_CACHE::ClosePlugins()
{
if( m_Plugins )
m_Plugins->ClosePlugins();
}
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName, const wxString& aBasePath )
{
S3D_CACHE_ENTRY* cp = nullptr;
SCENEGRAPH* sp = load( aModelFileName, aBasePath,&cp );
if( !sp )
return nullptr;
if( !cp )
{
wxLogTrace( MASK_3D_CACHE,
wxT( "%s:%s:%d\n * [BUG] model loaded with no associated S3D_CACHE_ENTRY" ),
__FILE__, __FUNCTION__, __LINE__ );
return nullptr;
}
if( cp->renderData )
return cp->renderData;
S3DMODEL* mp = S3D::GetModel( sp );
cp->renderData = mp;
return mp;
}
void S3D_CACHE::CleanCacheDir( int aNumDaysOld )
{
wxDir dir;
wxString fileSpec = wxT( "*.3dc" );
wxArrayString fileList; // Holds list of ".3dc" files found in cache directory
size_t numFilesFound = 0;
wxFileName thisFile;
wxDateTime lastAccess, thresholdDate;
wxDateSpan durationInDays;
// Calc the threshold date above which we delete cache files
durationInDays.SetDays( aNumDaysOld );
thresholdDate = wxDateTime::Now() - durationInDays;
// If the cache directory can be found and opened, then we'll try and clean it up
if( dir.Open( m_CacheDir ) )
{
thisFile.SetPath( m_CacheDir ); // Set the base path to the cache folder
// Get a list of all the ".3dc" files in the cache directory
numFilesFound = dir.GetAllFiles( m_CacheDir, &fileList, fileSpec );
for( unsigned int i = 0; i < numFilesFound; i++ )
{
// Completes path to specific file so we can get its "last access" date
thisFile.SetFullName( fileList[i] );
// Only get "last access" time to compare against. Don't need the other 2 timestamps.
if( thisFile.GetTimes( &lastAccess, nullptr, nullptr ) )
{
if( lastAccess.IsEarlierThan( thresholdDate ) )
{
// This file is older than the threshold so delete it
wxRemoveFile( thisFile.GetFullPath() );
}
}
}
}
}
void PROJECT::Cleanup3DCache()
{
std::lock_guard<std::mutex> lock( mutex3D_cacheManager );
// Get the existing cache from the project
S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( GetElem( ELEM_3DCACHE ) );
if( cache )
{
// We'll delete ".3dc" cache files older than this many days
int clearCacheInterval = 0;
if( Pgm().GetCommonSettings() )
clearCacheInterval = Pgm().GetCommonSettings()->m_System.clear_3d_cache_interval;
// An interval of zero means the user doesn't want to ever clear the cache
if( clearCacheInterval > 0 )
cache->CleanCacheDir( clearCacheInterval );
}
}
S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir )
{
std::lock_guard<std::mutex> lock( mutex3D_cacheManager );
// Get the existing cache from the project
S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( GetElem( ELEM_3DCACHE ) );
if( !cache )
{
// Create a cache if there is not one already
cache = new S3D_CACHE();
wxFileName cfgpath;
cfgpath.AssignDir( SETTINGS_MANAGER::GetUserSettingsPath() );
cfgpath.AppendDir( wxT( "3d" ) );
cache->SetProgramBase( &Pgm() );
cache->Set3DConfigDir( cfgpath.GetFullPath() );
SetElem( ELEM_3DCACHE, cache );
aUpdateProjDir = true;
}
if( aUpdateProjDir )
cache->SetProject( this );
return cache;
}
FILENAME_RESOLVER* PROJECT::Get3DFilenameResolver()
{
return Get3DCacheManager()->GetResolver();
}
-185
View File
@@ -1,185 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_cache.h
*/
#ifndef CACHE_3D_H
#define CACHE_3D_H
#include "3d_info.h"
#include <core/typeinfo.h>
#include "string_utils.h"
#include <list>
#include <map>
#include "plugins/3dapi/c3dmodel.h"
#include <project.h>
#include <wx/string.h>
class PGM_BASE;
class S3D_CACHE_ENTRY;
class SCENEGRAPH;
class FILENAME_RESOLVER;
class S3D_PLUGIN_MANAGER;
/**
* Cache for storing the 3D shapes. This cache is able to be stored as a project
* element (since it inherits from PROJECT::_ELEM).
*/
class S3D_CACHE : public PROJECT::_ELEM
{
public:
S3D_CACHE();
virtual ~S3D_CACHE();
KICAD_T Type() noexcept override
{
return S3D_CACHE_T;
}
/**
* Sets the configuration directory to be used by the model manager for storing 3D
* model manager configuration data and the model cache.
*
* The config directory may only be set once in the lifetime of the object.
*
* @param aConfigDir is the configuration directory to use for 3D model manager data
* @return true on success
*/
bool Set3DConfigDir( const wxString& aConfigDir );
/**
* Set the current project's working directory; this affects the model search path.
*/
bool SetProject( PROJECT* aProject );
/**
* Set the filename resolver's pointer to the application's PGM_BASE instance.
*
* The pointer is used to extract the local environment variables.
*/
void SetProgramBase( PGM_BASE* aBase );
/**
* Attempt to load the scene data for a model.
*
* It will consult the internal cache list and load from cache if possible before invoking
* the load() function of the available plugins. The model may fail to load if, for example,
* the plugin does not support rendering of the 3D model.
*
* @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 );
FILENAME_RESOLVER* GetResolver() noexcept;
/**
* Return the list of file filters retrieved from the plugins.
*
* This will contain at least the default "All Files (*.*)|*.*"
*
* @return a pointer to the filter list.
*/
std::list< wxString > const* GetFileFilters() const;
/**
* Free all data in the cache and by default closes all plugins.
*/
void FlushCache( bool closePlugins = true );
/**
* Unload plugins to free memory.
*/
void ClosePlugins();
/**
* Attempt to load the scene data for a model and to translate it into an S3D_MODEL
* structure for display by a renderer.
*
* @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 );
/**
* Delete up old cache files in cache directory.
*
* Deletes ".3dc" files in the cache directory that are older than \a aNumDaysOld.
*
* @param aNumDaysOld is age threshold to delete ".3dc" cache files.
*/
void CleanCacheDir( int aNumDaysOld );
private:
/**
* Find or create cache entry for file name
*
* Searches the cache list for the given filename and retrieves the cache data; a cache
* entry is created if one does not already exist.
*
* @param aFileName is the file name (full or partial path).
* @param aCachePtr is an optional return address for cache entry pointer.
* @return SCENEGRAPH object associated with file name or NULL on error.
*/
SCENEGRAPH* checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** aCachePtr = nullptr );
/**
* Calculate the SHA1 hash of the given file.
*
* @param aFileName file name (full path).
* @param aSHA1Sum a 20 byte character array to hold the SHA1 hash.
* @return true on success, otherwise false.
*/
bool getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum );
// load scene data from a cache file
bool loadCacheData( S3D_CACHE_ENTRY* aCacheItem );
// save scene data to a cache file
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 );
/// cache entries
std::list< S3D_CACHE_ENTRY* > m_CacheList;
/// mapping of file names to cache names and data
std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString > m_CacheMap;
FILENAME_RESOLVER* m_FNResolver;
S3D_PLUGIN_MANAGER* m_Plugins;
PROJECT* m_project;
wxString m_CacheDir;
wxString m_ConfigDir; /// base configuration path for 3D items
};
#endif // CACHE_3D_H
-52
View File
@@ -1,52 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2015 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_info.h
* defines the basic data associated with a single 3D model.
*/
#ifndef INFO_3D_H
#define INFO_3D_H
#include <wx/string.h>
#include <plugins/3dapi/sg_base.h>
class FP_3DMODEL;
struct S3D_INFO
{
S3D_INFO();
S3D_INFO( const FP_3DMODEL& aModel );
SGPOINT m_Scale; ///< scaling factors for the 3D footprint shape
SGPOINT m_Rotation; ///< an X,Y,Z rotation (unit = degrees) for the 3D shape
SGPOINT m_Offset; ///< an offset (unit = inch) for the 3D shape
wxString m_Filename; ///< The 3D shape filename in 3D library
};
#endif // INFO_3D_H
-501
View File
@@ -1,501 +0,0 @@
/*
* 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.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <utility>
#include <iostream>
#include <sstream>
#include <wx/dir.h>
#include <wx/dynlib.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"
#include "plugins/ldr/3d/pluginldr3D.h"
/**
* Flag to enable 3D plugin manager debug tracing.
*
* Use "KI_TRACE_EDA_3D_VIEWER" to enable.
*
* @ingroup trace_env_vars
*/
#define MASK_3D_PLUGINMGR "3D_PLUGIN_MANAGER"
S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER()
{
// create the initial file filter list entry
m_FileFilters.emplace_back( _( "All Files" ) + wxT( " (*.*)|*.*" ) );
// discover and load plugins
loadPlugins();
#ifdef DEBUG
if( !m_ExtMap.empty() )
{
std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::const_iterator sM = m_ExtMap.begin();
std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::const_iterator eM = m_ExtMap.end();
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * Extension [plugin name]:\n" ) );
while( sM != eM )
{
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " + '%s' [%s]\n" ), sM->first.GetData(),
sM->second->GetKicadPluginName() );
++sM;
}
}
else
{
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * No plugins available\n" ) );
}
if( !m_FileFilters.empty() )
{
/// list of file filters
std::list< wxString >::const_iterator sFF = m_FileFilters.begin();
std::list< wxString >::const_iterator eFF = m_FileFilters.end();
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * File filters:\n" ) );
while( sFF != eFF )
{
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " + '%s'\n" ), (*sFF).GetData() );
++sFF;
}
}
else
{
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * No file filters available\n" ) );
}
#endif // DEBUG
}
S3D_PLUGIN_MANAGER::~S3D_PLUGIN_MANAGER()
{
std::list< KICAD_PLUGIN_LDR_3D* >::iterator sP = m_Plugins.begin();
std::list< KICAD_PLUGIN_LDR_3D* >::iterator eP = m_Plugins.end();
while( sP != eP )
{
(*sP)->Close();
delete *sP;
++sP;
}
m_Plugins.clear();
}
void S3D_PLUGIN_MANAGER::loadPlugins( void )
{
std::list<wxString> searchpaths;
std::list<wxString> pluginlist;
wxFileName fn;
#ifndef __WXMAC__
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
{
// 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 ) )
{
checkPluginPath( testpath + subdir, searchpaths );
while( debugPluginDir.GetNext( &subdir ) )
checkPluginPath( testpath + subdir, searchpaths );
}
}
fn.AssignDir( PATHS::GetStockPlugins3DPath() );
checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );
#else
// Search path on OS X is
// (1) Machine /Library/Application Support/kicad/PlugIns/3d
checkPluginPath( PATHS::GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
// (2) Bundle kicad.app/Contents/PlugIns/3d
fn.AssignDir( PATHS::GetStockPlugins3DPath() );
checkPluginPath( fn.GetPathWithSep(), searchpaths );
#endif
std::list< wxString >::iterator sPL = searchpaths.begin();
std::list< wxString >::iterator ePL = searchpaths.end();
while( sPL != ePL )
{
wxLogTrace( MASK_3D_PLUGINMGR, wxT( "%s:%s:%d * [DEBUG] searching path: '%s'" ),
__FILE__, __FUNCTION__, __LINE__, (*sPL).ToUTF8() );
listPlugins( *sPL, pluginlist );
++sPL;
}
if( pluginlist.empty() )
return;
sPL = pluginlist.begin();
ePL = pluginlist.end();
while( sPL != ePL )
{
KICAD_PLUGIN_LDR_3D* pp = new KICAD_PLUGIN_LDR_3D;
if( pp->Open( sPL->ToUTF8() ) )
{
wxLogTrace( MASK_3D_PLUGINMGR, wxT( "%s:%s:%d * [DEBUG] adding plugin" ),
__FILE__, __FUNCTION__, __LINE__ );
m_Plugins.push_back( pp );
int nf = pp->GetNFilters();
wxLogTrace( MASK_3D_PLUGINMGR, wxT( "%s:%s:%d * [DEBUG] adding %d filters" ),
__FILE__, __FUNCTION__, __LINE__, nf );
for( int i = 0; i < nf; ++i )
{
char const* cp = pp->GetFileFilter( i );
if( cp )
addFilterString( wxString::FromUTF8Unchecked( cp ) );
}
addExtensionMap( pp );
// close the loaded library
pp->Close();
}
else
{
wxLogTrace( MASK_3D_PLUGINMGR, wxT( "%s:%s:%d * [DEBUG] deleting plugin" ),
__FILE__, __FUNCTION__, __LINE__ );
delete pp;
}
++sPL;
}
wxLogTrace( MASK_3D_PLUGINMGR, wxT( "%s:%s:%d * [DEBUG] plugins loaded" ),
__FILE__, __FUNCTION__, __LINE__ );
}
void S3D_PLUGIN_MANAGER::listPlugins( const wxString& aPath, std::list< wxString >& aPluginList )
{
// list potential plugins given a search path
wxString nameFilter; // filter for user-loadable libraries (aka footprints)
wxString lName; // stores name of enumerated files
wxString fName; // full name of file
wxDir wd;
wd.Open( aPath );
if( !wd.IsOpened() )
return;
nameFilter = wxT( "*" );
#ifndef __WXMAC__
nameFilter.Append( wxDynamicLibrary::GetDllExt( wxDL_MODULE ) );
#else
// wxDynamicLibrary::GetDllExt( wxDL_MODULE ) will return ".bundle" on OS X.
// This might be correct, but cmake builds a ".so" for a library MODULE.
// 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" ) );
#endif
wxString lp = wd.GetNameWithSep();
if( wd.GetFirst( &lName, nameFilter, wxDIR_FILES ) )
{
fName = lp + lName;
checkPluginName( fName, aPluginList );
while( wd.GetNext( &lName ) )
{
fName = lp + lName;
checkPluginName( fName, aPluginList );
}
}
wd.Close();
}
void S3D_PLUGIN_MANAGER::checkPluginName( const wxString& aPath,
std::list< wxString >& aPluginList )
{
// check the existence of a plugin name and add it to the list
if( aPath.empty() || !wxFileName::FileExists( aPath ) )
return;
wxFileName path( ExpandEnvVarSubstitutions( aPath, nullptr ) );
path.Normalize( FN_NORMALIZE_FLAGS );
// determine if the path is already in the list
wxString wxpath = path.GetFullPath();
std::list< wxString >::iterator bl = aPluginList.begin();
std::list< wxString >::iterator el = aPluginList.end();
while( bl != el )
{
if( 0 == (*bl).Cmp( wxpath ) )
return;
++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() );
}
void S3D_PLUGIN_MANAGER::checkPluginPath( const wxString& aPath,
std::list< wxString >& aSearchList )
{
if( aPath.empty() )
return;
wxLogTrace( MASK_3D_PLUGINMGR, wxT( " * [INFO] checking if valid plugin directory '%s'\n" ),
aPath.GetData() );
wxFileName path;
path.AssignDir( aPath );
path.Normalize( FN_NORMALIZE_FLAGS );
if( !wxFileName::DirExists( path.GetFullPath() ) )
return;
// determine if the directory is already in the list
wxString wxpath = path.GetFullPath();
std::list< wxString >::iterator bl = aSearchList.begin();
std::list< wxString >::iterator el = aSearchList.end();
while( bl != el )
{
if( 0 == (*bl).Cmp( wxpath ) )
return;
++bl;
}
aSearchList.push_back( wxpath );
}
void S3D_PLUGIN_MANAGER::addFilterString( const wxString& aFilterString )
{
// add an entry to the file filter list
if( aFilterString.empty() )
return;
std::list< wxString >::iterator sFF = m_FileFilters.begin();
std::list< wxString >::iterator eFF = m_FileFilters.end();
while( sFF != eFF )
{
if( 0 == (*sFF).Cmp( aFilterString ) )
return;
++sFF;
}
m_FileFilters.push_back( aFilterString );
return;
}
void S3D_PLUGIN_MANAGER::addExtensionMap( KICAD_PLUGIN_LDR_3D* aPlugin )
{
// add entries to the extension map
if( nullptr == aPlugin )
return;
int nExt = aPlugin->GetNExtensions();
wxLogTrace( MASK_3D_PLUGINMGR, wxT( "%s:%s:%d * [INFO] adding %d extensions" ),
__FILE__, __FUNCTION__, __LINE__, nExt );
for( int i = 0; i < nExt; ++i )
{
char const* cp = aPlugin->GetModelExtension( i );
wxString ws;
if( cp )
ws = wxString::FromUTF8Unchecked( cp );
if( !ws.empty() )
{
m_ExtMap.emplace( ws, aPlugin );
}
}
}
std::list< wxString > const* S3D_PLUGIN_MANAGER::GetFileFilters( void ) const noexcept
{
return &m_FileFilters;
}
SCENEGRAPH* S3D_PLUGIN_MANAGER::Load3DModel( const wxString& aFileName, std::string& aPluginInfo )
{
wxFileName raw( aFileName );
wxString ext_to_find = raw.GetExt();
#ifdef _WIN32
// note: plugins only have a lowercase filter within Windows; including an uppercase
// filter will result in duplicate file entries and should be avoided.
ext_to_find.MakeLower();
#endif
// .gz files are compressed versions that may have additional information in the previous extension
if( ext_to_find == wxT( "gz" ) )
{
wxFileName second( raw.GetName() );
ext_to_find = second.GetExt() + wxT( ".gz" );
}
std::pair < std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::iterator,
std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::iterator > items;
items = m_ExtMap.equal_range( ext_to_find );
std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::iterator sL = items.first;
while( sL != items.second )
{
if( sL->second->CanRender() )
{
SCENEGRAPH* sp = sL->second->Load( aFileName.ToUTF8() );
if( nullptr != sp )
{
sL->second->GetPluginInfo( aPluginInfo );
return sp;
}
}
++sL;
}
return nullptr;
}
void S3D_PLUGIN_MANAGER::ClosePlugins( void )
{
std::list< KICAD_PLUGIN_LDR_3D* >::iterator sP = m_Plugins.begin();
std::list< KICAD_PLUGIN_LDR_3D* >::iterator eP = m_Plugins.end();
wxLogTrace( MASK_3D_PLUGINMGR, wxT( "%s:%s:%d * [INFO] closing %d extensions" ),
__FILE__, __FUNCTION__, __LINE__, static_cast<int>( m_Plugins.size() ) );
while( sP != eP )
{
(*sP)->Close();
++sP;
}
}
bool S3D_PLUGIN_MANAGER::CheckTag( const char* aTag )
{
if( nullptr == aTag || aTag[0] == 0 || m_Plugins.empty() )
return false;
std::string tname = aTag;
std::string pname; // plugin name
size_t cpos = tname.find( ':' );
// if there is no colon or plugin name then the tag is bad
if( cpos == std::string::npos || cpos == 0 )
return false;
pname = tname.substr( 0, cpos );
std::string ptag; // tag from the plugin
std::list< KICAD_PLUGIN_LDR_3D* >::iterator pS = m_Plugins.begin();
std::list< KICAD_PLUGIN_LDR_3D* >::iterator pE = m_Plugins.end();
while( pS != pE )
{
ptag.clear();
(*pS)->GetPluginInfo( ptag );
// if the plugin name matches then the version
// must also match
if( !ptag.compare( 0, pname.size(), pname ) )
{
if( ptag.compare( tname ) )
return false;
return true;
}
++pS;
}
return true;
}
-101
View File
@@ -1,101 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_plugin_manager.h
* manages 3D model plugins
*/
#ifndef PLUGIN_MANAGER_3D_H
#define PLUGIN_MANAGER_3D_H
#include <map>
#include <list>
#include <string>
#include <wx/string.h>
class wxWindow;
class KICAD_PLUGIN_LDR_3D;
class SCENEGRAPH;
class S3D_PLUGIN_MANAGER
{
public:
S3D_PLUGIN_MANAGER();
virtual ~S3D_PLUGIN_MANAGER();
/**
* Return the list of file filters; this will contain at least the default
* "All Files (*.*)|*.*" and the file filters supported by any available plugins.
*
* @return a pointer to the internal filter list.
*/
std::list< wxString > const* GetFileFilters( void ) const noexcept;
SCENEGRAPH* Load3DModel( const wxString& aFileName, std::string& aPluginInfo );
/**
* Iterate through all discovered plugins and closes them to reclaim memory.
*
* The individual plugins will be automatically reloaded as calls are made to load
* specific models.
*/
void ClosePlugins( void );
/**
* Check the given tag and returns true if the plugin named in the tag is not loaded
* or the plugin is loaded and the version matches.
*/
bool CheckTag( const char* aTag );
private:
/// load plugins
void loadPlugins( void );
/// list potential plugins
void listPlugins( const wxString& aPath, std::list< wxString >& aPluginList );
/// check the existence of a plugin name and add it to the list
void checkPluginName( const wxString& aPath, std::list< wxString >& aPluginList );
/// check the existence of a path and add it to the path search list
void checkPluginPath( const wxString& aPath, std::list< wxString >& aSearchList );
/// add an entry to the file filter list
void addFilterString( const wxString& aFilterString );
/// add entries to the extension map
void addExtensionMap( KICAD_PLUGIN_LDR_3D* aPlugin );
/// list of discovered plugins
std::list< KICAD_PLUGIN_LDR_3D* > m_Plugins;
/// mapping of extensions to available plugins
std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* > m_ExtMap;
/// list of file filters
std::list< wxString > m_FileFilters;
};
#endif // PLUGIN_MANAGER_3D_H
-1
View File
@@ -1 +0,0 @@
add_subdirectory( sg )
-111
View File
@@ -1,111 +0,0 @@
include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/3d-viewer
)
set( SG_FILES
sg_base.cpp
sg_node.cpp
sg_helpers.cpp
scenegraph.cpp
sg_appearance.cpp
sg_faceset.cpp
sg_shape.cpp
sg_colors.cpp
sg_coords.cpp
sg_normals.cpp
sg_index.cpp
sg_coordindex.cpp
ifsg_node.cpp
ifsg_transform.cpp
ifsg_appearance.cpp
ifsg_index.cpp
ifsg_coordindex.cpp
ifsg_colors.cpp
ifsg_coords.cpp
ifsg_faceset.cpp
ifsg_normals.cpp
ifsg_shape.cpp
ifsg_api.cpp
)
if( MINGW )
list( APPEND SG_FILES ${CMAKE_SOURCE_DIR}/common/streamwrapper.cpp )
endif( MINGW )
add_library( kicad_3dsg SHARED ${SG_FILES} )
if( APPLE )
# puts library into the main kicad.app bundle in build tree
set_target_properties( kicad_3dsg PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${OSX_BUNDLE_BUILD_LIB_DIR}"
INSTALL_NAME_DIR "${OSX_BUNDLE_BUILD_LIB_DIR}"
)
endif()
find_file( S3DSG_VERSION_FILE sg_version.h
PATHS ${CMAKE_SOURCE_DIR}/include/plugins/3dapi NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
if( NOT ${S3DSG_VERSION_FILE} STREQUAL "S3DSG_VERSION_FILE-NOTFOUND" )
# extract the "#define KICADSG_VERSION_*" lines
file( STRINGS ${S3DSG_VERSION_FILE} _version
REGEX "^[' ','\t']*#define[' ','\t']*KICADSG_VERSION_.*" )
foreach( SVAR ${_version} )
string( REGEX MATCH KICADSG_VERSION_[M,A,J,O,R,I,N,P,T,C,H,E,V]* _VARNAME ${SVAR} )
string( REGEX MATCH [0-9]+ _VALUE ${SVAR} )
if( NOT ${_VARNAME} STREQUAL "" )
if( NOT ${_VALUE} STREQUAL "" )
set( ${_VARNAME} ${_VALUE} )
else()
set( ${_VARNAME} 0 )
endif()
endif()
endforeach()
if( NOT KICADSG_VERSION_MAJOR AND NOT ${KICADSG_VERSION_MAJOR} STREQUAL "0" )
message( FATAL_ERROR "Cannot determine the S3DSG library version" )
endif()
#ensure that NOT SG_VERSION* will evaluate to '0'
if( NOT KICADSG_VERSION_MINOR )
set( KICADSG_VERSION_MINOR 0 )
endif()
if( NOT KICADSG_VERSION_PATCH )
set( KICADSG_VERSION_PATCH 0 )
endif()
set_target_properties( kicad_3dsg
PROPERTIES SOVERSION
${KICADSG_VERSION_MAJOR}.${KICADSG_VERSION_MINOR}.${KICADSG_VERSION_PATCH} )
message( STATUS "S3DSG version: ${KICADSG_VERSION_MAJOR}.${KICADSG_VERSION_MINOR}.${KICADSG_VERSION_PATCH}" )
else()
message( FATAL_ERROR "Cannot determine the S3DSG library version" )
endif()
unset( S3DSG_VERSION_FILE CACHE )
# Define a flag to expose the appropriate EXPORT macro at build time
target_compile_definitions( kicad_3dsg PRIVATE -DCOMPILE_SGLIB )
target_link_libraries( kicad_3dsg ${wxWidgets_LIBRARIES} )
# Don't specify the ARCHIVE DESTINATION parameter to prevent
# the install of the import library on Windows
# https://cmake.org/pipermail/cmake/2011-November/047746.html
install( TARGETS
kicad_3dsg
RUNTIME DESTINATION ${KICAD_LIB}
LIBRARY DESTINATION ${KICAD_LIB}
COMPONENT binary
)
if( KICAD_WIN32_INSTALL_PDBS )
# Get the PDBs to copy over for MSVC
install(FILES $<TARGET_PDB_FILE:kicad_3dsg> DESTINATION ${KICAD_BIN})
endif()
-527
View File
@@ -1,527 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <memory>
#include <wx/filename.h>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_api.h"
#include "plugins/3dapi/sg_version.h"
#include "streamwrapper.h"
#include "3d_cache/sg/sg_node.h"
#include "3d_cache/sg/scenegraph.h"
#include "3d_cache/sg/sg_appearance.h"
#include "3d_cache/sg/sg_shape.h"
#include "3d_cache/sg/sg_helpers.h"
// version format of the cache file
#define SG_VERSION_TAG "VERSION:2"
static void formatMaterial( SMATERIAL& mat, SGAPPEARANCE const* app )
{
float v0, v1, v2;
app->ambient.GetColor( v0, v1, v2 );
mat.m_Ambient.x = v0;
mat.m_Ambient.y = v1;
mat.m_Ambient.z = v2;
app->diffuse.GetColor( v0, v1, v2 );
mat.m_Diffuse.x = v0;
mat.m_Diffuse.y = v1;
mat.m_Diffuse.z = v2;
mat.m_Ambient.x *= v0;
mat.m_Ambient.y *= v1;
mat.m_Ambient.z *= v2;
app->emissive.GetColor( v0, v1, v2 );
mat.m_Emissive.x = v0;
mat.m_Emissive.y = v1;
mat.m_Emissive.z = v2;
app->specular.GetColor( v0, v1, v2 );
mat.m_Specular.x = v0;
mat.m_Specular.y = v1;
mat.m_Specular.z = v2;
mat.m_Shininess = app->shininess;
mat.m_Transparency = app->transparency;
}
bool S3D::WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
bool reuse, bool renameNodes )
{
if( nullptr == filename || filename[0] == 0 )
return false;
wxString ofile = wxString::FromUTF8Unchecked( filename );
if( wxFileName::Exists( ofile ) )
{
if( !overwrite )
return false;
// make sure we make no attempt to write a directory
if( !wxFileName::FileExists( ofile ) )
return false;
}
wxCHECK( aTopNode && aTopNode->GetNodeType() == S3D::SGTYPE_TRANSFORM, false );
OPEN_OSTREAM( op, filename );
if( op.fail() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] failed to open file '%s'" ),
__FILE__, __FUNCTION__, __LINE__, filename );
return false;
}
op.imbue( std::locale::classic() );
op << "#VRML V2.0 utf8\n";
if( renameNodes )
{
aTopNode->ResetNodeIndex();
aTopNode->ReNameNodes();
}
aTopNode->WriteVRML( op, reuse );
if( !op.fail() )
{
CLOSE_STREAM( op );
return true;
}
CLOSE_STREAM( op );
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] problems encountered writing file '%s'" ),
__FILE__, __FUNCTION__, __LINE__, filename );
return false;
}
void S3D::ResetNodeIndex( SGNODE* aNode )
{
wxCHECK( aNode, /* void */ );
aNode->ResetNodeIndex();
}
void S3D::RenameNodes( SGNODE* aNode )
{
wxCHECK( aNode, /* void */ );
aNode->ReNameNodes();
}
void S3D::DestroyNode( SGNODE* aNode ) noexcept
{
wxCHECK( aNode, /* void */ );
delete aNode;
}
bool S3D::WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode,
const char* aPluginInfo )
{
if( nullptr == aFileName || aFileName[0] == 0 )
return false;
wxString ofile = wxString::FromUTF8Unchecked( aFileName );
wxCHECK( aNode, false );
if( wxFileName::Exists( ofile ) )
{
if( !overwrite )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] file exists not overwriting '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
return false;
}
// make sure we make no attempt to write a directory
if( !wxFileName::FileExists( aFileName ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] specified path is a directory '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
return false;
}
}
OPEN_OSTREAM( output, aFileName );
if( output.fail() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] failed to open file '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
return false;
}
output << "(" << SG_VERSION_TAG << ")";
if( nullptr != aPluginInfo && aPluginInfo[0] != 0 )
output << "(" << aPluginInfo << ")";
else
output << "(INTERNAL:0.0.0.0)";
bool rval = aNode->WriteCache( output, nullptr );
CLOSE_STREAM( output );
if( !rval )
{
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [INFO] problems encountered writing cache file '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
// delete the defective file
wxRemoveFile( ofile );
}
return rval;
}
SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr,
bool (*aTagCheck)( const char*, void* ) )
{
if( nullptr == aFileName || aFileName[0] == 0 )
return nullptr;
wxString ofile = wxString::FromUTF8Unchecked( aFileName );
if( !wxFileName::FileExists( aFileName ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] no such file '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
return nullptr;
}
std::unique_ptr<SGNODE> np = std::make_unique<SCENEGRAPH>( nullptr );
OPEN_ISTREAM( file, aFileName );
if( file.fail() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] failed to open file '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aFileName );
return nullptr;
}
// from SG_VERSION_TAG 1, read the version tag; if it's not the expected tag
// then we fail to read the cache file
do
{
std::string name;
char schar;
file.get( schar );
if( '(' != schar )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; missing left parenthesis"
" at position '%d'" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( file.tellg() ) );
CLOSE_STREAM( file );
return nullptr;
}
file.get( schar );
while( ')' != schar && file.good() )
{
name.push_back( schar );
file.get( schar );
}
if( name.compare( SG_VERSION_TAG ) )
{
CLOSE_STREAM( file );
return nullptr;
}
} while( 0 );
// from SG_VERSION_TAG 2, read the PluginInfo string and check that it matches
// version tag; if it's not the expected tag then we fail to read the file
do
{
std::string name;
char schar;
file.get( schar );
if( '(' != schar )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; missing left parenthesis"
" at position '%d'" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( file.tellg() ) );
CLOSE_STREAM( file );
return nullptr;
}
file.get( schar );
while( ')' != schar && file.good() )
{
name.push_back( schar );
file.get( schar );
}
// check the plugin tag
if( nullptr != aTagCheck && nullptr != aPluginMgr
&& !aTagCheck( name.c_str(), aPluginMgr ) )
{
CLOSE_STREAM( file );
return nullptr;
}
} while( 0 );
bool rval = np->ReadCache( file, nullptr );
CLOSE_STREAM( file );
if( !rval )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] problems encountered reading cache file "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
aFileName );
return nullptr;
}
return np.release();
}
S3DMODEL* S3D::GetModel( SCENEGRAPH* aNode )
{
if( nullptr == aNode )
return nullptr;
if( aNode->GetNodeType() != S3D::SGTYPE_TRANSFORM )
return nullptr;
S3D::MATLIST materials;
std::vector< SMESH > meshes;
// the materials list shall have a default color; although the VRML
// default is an opaque black, the default used here shall be a median
// gray in hopes that it may help highlight faulty models; this color is
// also typical of MCAD applications. When a model has no associated
// material color it shall be assigned the index 0.
SGAPPEARANCE app( nullptr );
app.ambient = SGCOLOR( 0.6f, 0.6f, 0.6f );
app.diffuse = SGCOLOR( 0.6f, 0.6f, 0.6f );
app.specular = app.diffuse;
app.shininess = 0.05f;
app.transparency = 0.0f;
materials.matorder.push_back( &app );
materials.matmap.emplace( &app, 0 );
if( aNode->Prepare( nullptr, materials, meshes ) )
{
if( meshes.empty() )
return nullptr;
S3DMODEL* model = S3D::New3DModel();
// add all the materials
size_t j = materials.matorder.size();
SMATERIAL* lmat = new SMATERIAL[j];
for( size_t i = 0; i < j; ++i )
formatMaterial( lmat[i], materials.matorder[i] );
model->m_Materials = lmat;
model->m_MaterialsSize = j;
// add all the meshes
j = meshes.size();
SMESH* lmesh = new SMESH[j];
for( size_t i = 0; i < j; ++i )
lmesh[i] = meshes[i];
model->m_Meshes = lmesh;
model->m_MeshesSize = j;
return model;
}
size_t j = meshes.size();
for( size_t i = 0; i < j; ++i )
S3D::Free3DMesh( meshes[i] );
return nullptr;
}
void S3D::Destroy3DModel( S3DMODEL** aModel )
{
if( nullptr == aModel || nullptr == *aModel )
return;
S3DMODEL* m = *aModel;
S3D::FREE_S3DMODEL( *m );
delete m;
*aModel = nullptr;
}
void Free3DModel( S3DMODEL& aModel )
{
S3D::FREE_S3DMODEL( aModel );
}
void S3D::Free3DMesh( SMESH& aMesh )
{
S3D::FREE_SMESH( aMesh );
}
S3DMODEL* S3D::New3DModel( void )
{
S3DMODEL* mp = new S3DMODEL;
S3D::INIT_S3DMODEL( *mp );
return mp;
}
void S3D::Init3DMaterial( SMATERIAL& aMat )
{
S3D::INIT_SMATERIAL( aMat );
}
void S3D::Init3DMesh( SMESH& aMesh )
{
S3D::INIT_SMESH( aMesh );
}
void S3D::GetLibVersion( unsigned char* Major, unsigned char* Minor, unsigned char* Patch,
unsigned char* Revision ) noexcept
{
if( Major )
*Major = KICADSG_VERSION_MAJOR;
if( Minor )
*Minor = KICADSG_VERSION_MINOR;
if( Revision )
*Revision = KICADSG_VERSION_REVISION;
if( Patch )
*Patch = KICADSG_VERSION_PATCH;
}
SGVECTOR S3D::CalcTriNorm( const SGPOINT& p1, const SGPOINT& p2, const SGPOINT& p3 )
{
glm::dvec3 tri = glm::dvec3( 0.0, 0.0, 0.0 );
glm::dvec3 pts[3];
pts[0] = glm::dvec3( p1.x, p1.y, p1.z );
pts[1] = glm::dvec3( p2.x, p2.y, p2.z );
pts[2] = glm::dvec3( p3.x, p3.y, p3.z );
// degenerate points are given a default 0, 0, 1 normal
if( S3D::degenerate( pts ) )
return SGVECTOR( 0.0, 0.0, 1.0 );
// normal
tri = glm::cross( pts[1] - pts[0], pts[2] - pts[0] );
glm::normalize( tri );
return SGVECTOR( tri.x, tri.y, tri.z );
}
S3D::SGTYPES S3D::GetSGNodeType( SGNODE* aNode )
{
if( nullptr == aNode )
return SGTYPE_END;
return aNode->GetNodeType();
}
SGNODE* S3D::GetSGNodeParent( SGNODE* aNode )
{
if( nullptr == aNode )
return nullptr;
return aNode->GetParent();
}
bool S3D::AddSGNodeRef( SGNODE* aParent, SGNODE* aChild )
{
if( nullptr == aParent || nullptr == aChild )
return false;
return aParent->AddRefNode( aChild );
}
bool S3D::AddSGNodeChild( SGNODE* aParent, SGNODE* aChild )
{
if( nullptr == aParent || nullptr == aChild )
return false;
return aParent->AddChildNode( aChild );
}
void S3D::AssociateSGNodeWrapper( SGNODE* aObject, SGNODE** aRefPtr )
{
if( nullptr == aObject || nullptr == aRefPtr || aObject != *aRefPtr )
return;
aObject->AssociateWrapper( aRefPtr );
}
-284
View File
@@ -1,284 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_appearance.h"
#include "3d_cache/sg/sg_appearance.h"
extern char BadParent[];
extern char WrongParent[];
IFSG_APPEARANCE::IFSG_APPEARANCE( bool create )
{
m_node = nullptr;
if( !create )
return ;
m_node = new SGAPPEARANCE( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_APPEARANCE::IFSG_APPEARANCE( SGNODE* aParent )
{
m_node = new SGAPPEARANCE( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
IFSG_APPEARANCE::IFSG_APPEARANCE( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
BadParent );
}
#endif
m_node = new SGAPPEARANCE( nullptr );
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_APPEARANCE::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_APPEARANCE != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_APPEARANCE::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SGAPPEARANCE( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGAPPEARANCE" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_APPEARANCE::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
bool IFSG_APPEARANCE::SetEmissive( float aRVal, float aGVal, float aBVal )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetEmissive( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetEmissive( const SGCOLOR* aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetEmissive( aRGBColor );
}
bool IFSG_APPEARANCE::SetEmissive( const SGCOLOR& aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetEmissive( aRGBColor );
}
bool IFSG_APPEARANCE::SetDiffuse( float aRVal, float aGVal, float aBVal )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetDiffuse( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetDiffuse( const SGCOLOR* aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetDiffuse( aRGBColor );
}
bool IFSG_APPEARANCE::SetDiffuse( const SGCOLOR& aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetDiffuse( aRGBColor );
}
bool IFSG_APPEARANCE::SetSpecular( float aRVal, float aGVal, float aBVal )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetSpecular( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetSpecular( const SGCOLOR* aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetSpecular( aRGBColor );
}
bool IFSG_APPEARANCE::SetSpecular( const SGCOLOR& aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetSpecular( aRGBColor );
}
bool IFSG_APPEARANCE::SetAmbient( float aRVal, float aGVal, float aBVal )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetAmbient( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetAmbient( const SGCOLOR* aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetAmbient( aRGBColor );
}
bool IFSG_APPEARANCE::SetAmbient( const SGCOLOR& aRGBColor )
{
wxCHECK( m_node, false );
return ( (SGAPPEARANCE*) m_node )->SetAmbient( aRGBColor );
}
bool IFSG_APPEARANCE::SetShininess( float aShininess ) noexcept
{
wxCHECK( m_node, false );
if( aShininess < 0 || aShininess > 1.0 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] shininess out of range [0..1]" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
( (SGAPPEARANCE*) m_node )->shininess = aShininess;
return true;
}
bool IFSG_APPEARANCE::SetTransparency( float aTransparency ) noexcept
{
wxCHECK( m_node, false );
if( aTransparency < 0 || aTransparency > 1.0 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] transparency out of range [0..1]" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
( (SGAPPEARANCE*) m_node )->transparency = aTransparency;
return true;
}
-189
View File
@@ -1,189 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_colors.h"
#include "3d_cache/sg/sg_colors.h"
extern char BadParent[];
extern char WrongParent[];
IFSG_COLORS::IFSG_COLORS( bool create )
{
m_node = nullptr;
if( !create )
return;
m_node = new SGCOLORS( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_COLORS::IFSG_COLORS( SGNODE* aParent )
{
m_node = new SGCOLORS( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d" ), __FILE__, __FUNCTION__, __LINE__ );
return;
}
m_node->AssociateWrapper( &m_node );
}
IFSG_COLORS::IFSG_COLORS( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
// Braces needed due to dangling else warning from wxLogTrace macro
if( !pp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
BadParent );
}
#endif
m_node = new SGCOLORS( nullptr );
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_COLORS::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_COLORS != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COLORS::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SGCOLORS( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGCOLORS" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COLORS::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
bool IFSG_COLORS::GetColorList( size_t& aListSize, SGCOLOR*& aColorList )
{
wxCHECK( m_node, false );
return ( (SGCOLORS*) m_node )->GetColorList( aListSize, aColorList );
}
bool IFSG_COLORS::SetColorList( size_t aListSize, const SGCOLOR* aColorList )
{
wxCHECK( m_node, false );
( (SGCOLORS*) m_node )->SetColorList( aListSize, aColorList );
return true;
}
bool IFSG_COLORS::AddColor( double aRedValue, double aGreenValue, double aBlueValue )
{
wxCHECK( m_node, false );
( (SGCOLORS*) m_node )->AddColor( aRedValue, aGreenValue, aBlueValue );
return true;
}
bool IFSG_COLORS::AddColor( const SGCOLOR& aColor )
{
wxCHECK( m_node, false );
( (SGCOLORS*) m_node )->AddColor( aColor );
return true;
}
-152
View File
@@ -1,152 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_coordindex.h"
#include "3d_cache/sg/sg_coordindex.h"
extern char BadParent[];
extern char WrongParent[];
IFSG_COORDINDEX::IFSG_COORDINDEX( bool create )
{
m_node = nullptr;
if( !create )
return;
m_node = new SGCOORDINDEX( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_COORDINDEX::IFSG_COORDINDEX( SGNODE* aParent )
{
m_node = new SGCOORDINDEX( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
IFSG_COORDINDEX::IFSG_COORDINDEX( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
if( !pp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
BadParent );
return;
}
m_node = new SGCOORDINDEX( nullptr );
if( !m_node->SetParent( pp ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
delete m_node;
m_node = nullptr;
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_COORDINDEX::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_COORDINDEX != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COORDINDEX::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SGCOORDINDEX( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGCOORDINDEX" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COORDINDEX::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
-189
View File
@@ -1,189 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_coords.h"
#include "3d_cache/sg/sg_coords.h"
extern char BadParent[];
extern char WrongParent[];
IFSG_COORDS::IFSG_COORDS( bool create )
{
m_node = nullptr;
if( !create )
return ;
m_node = new SGCOORDS( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_COORDS::IFSG_COORDS( SGNODE* aParent )
{
m_node = new SGCOORDS( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
IFSG_COORDS::IFSG_COORDS( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( !pp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
BadParent );
}
#endif
m_node = new SGCOORDS( nullptr );
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_COORDS::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_COORDS != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COORDS::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SGCOORDS( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGCOORDS" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COORDS::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
bool IFSG_COORDS::GetCoordsList( size_t& aListSize, SGPOINT*& aCoordsList )
{
wxCHECK( m_node, false );
return ( (SGCOORDS*) m_node )->GetCoordsList( aListSize, aCoordsList );
}
bool IFSG_COORDS::SetCoordsList( size_t aListSize, const SGPOINT* aCoordsList )
{
wxCHECK( m_node, false );
( (SGCOORDS*) m_node )->SetCoordsList( aListSize, aCoordsList );
return true;
}
bool IFSG_COORDS::AddCoord( double aXValue, double aYValue, double aZValue )
{
wxCHECK( m_node, false );
( (SGCOORDS*) m_node )->AddCoord( aXValue, aYValue, aZValue );
return true;
}
bool IFSG_COORDS::AddCoord( const SGPOINT& aPoint )
{
wxCHECK( m_node, false );
( (SGCOORDS*) m_node )->AddCoord( aPoint );
return true;
}
-161
View File
@@ -1,161 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_faceset.h"
#include "3d_cache/sg/sg_faceset.h"
extern char BadParent[];
extern char WrongParent[];
IFSG_FACESET::IFSG_FACESET( bool create )
{
m_node = nullptr;
if( !create )
return ;
m_node = new SGFACESET( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_FACESET::IFSG_FACESET( SGNODE* aParent )
{
m_node = new SGFACESET( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
IFSG_FACESET::IFSG_FACESET( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
BadParent );
}
#endif
m_node = new SGFACESET( nullptr );
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_FACESET::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_FACESET != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_FACESET::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SGFACESET( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGFACESET" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_FACESET::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
bool IFSG_FACESET::CalcNormals( SGNODE** aPtr )
{
if( m_node )
return ( (SGFACESET*) m_node )->CalcNormals( aPtr );
return false;
}
-64
View File
@@ -1,64 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_index.h"
#include "3d_cache/sg/sg_coordindex.h"
IFSG_INDEX::IFSG_INDEX() : IFSG_NODE()
{
}
bool IFSG_INDEX::GetIndices( size_t& nIndices, int*& aIndexList )
{
wxCHECK( m_node, false );
return ( (SGINDEX*) m_node )->GetIndices( nIndices, aIndexList );
}
bool IFSG_INDEX::SetIndices( size_t nIndices, int* aIndexList )
{
wxCHECK( m_node, false );
( (SGINDEX*) m_node )->SetIndices( nIndices, aIndexList );
return true;
}
bool IFSG_INDEX::AddIndex( int aIndex )
{
wxCHECK( m_node, false );
( (SGINDEX*) m_node )->AddIndex( aIndex );
return true;
}
-165
View File
@@ -1,165 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_node.h"
#include "3d_cache/sg/sg_node.h"
#include "plugins/3dapi/ifsg_api.h"
// collection of common error strings used by the wrappers
char BadObject[] = " * [BUG] operating on an invalid wrapper (object may have been deleted)";
char BadOperand[] = " * [BUG] parameter aNode is an invalid wrapper; its data may have been deleted";
char BadParent[] = " * [BUG] invalid parent node (data may have been deleted)";
char WrongParent[] = " * [BUG] parent node type is incompatible";
IFSG_NODE::IFSG_NODE()
{
m_node = nullptr;
}
IFSG_NODE::~IFSG_NODE()
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
}
void IFSG_NODE::Destroy( void )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
delete m_node;
m_node = nullptr;
}
SGNODE* IFSG_NODE::GetRawPtr( void ) noexcept
{
return m_node;
}
S3D::SGTYPES IFSG_NODE::GetNodeType( void ) const
{
wxCHECK( m_node, S3D::SGTYPE_END );
return m_node->GetNodeType();
}
SGNODE* IFSG_NODE::GetParent( void ) const
{
wxCHECK( m_node, nullptr );
return m_node->GetParent();
}
bool IFSG_NODE::SetParent( SGNODE* aParent )
{
wxCHECK( m_node, false );
return m_node->SetParent( aParent );
}
const char* IFSG_NODE::GetName( void )
{
wxCHECK( m_node, nullptr );
return m_node->GetName();
}
bool IFSG_NODE::SetName( const char* aName )
{
wxCHECK( m_node, false );
m_node->SetName( aName );
return true;
}
const char* IFSG_NODE::GetNodeTypeName( S3D::SGTYPES aNodeType ) const
{
wxCHECK( m_node, nullptr );
return m_node->GetNodeTypeName( aNodeType );
}
SGNODE* IFSG_NODE::FindNode( const char* aNodeName )
{
wxCHECK( m_node, nullptr );
return m_node->FindNode( aNodeName, nullptr );
}
bool IFSG_NODE::AddRefNode( SGNODE* aNode )
{
wxCHECK( m_node, false );
return m_node->AddRefNode( aNode );
}
bool IFSG_NODE::AddRefNode( IFSG_NODE& aNode )
{
wxCHECK( m_node, false );
SGNODE* np = aNode.GetRawPtr();
wxCHECK( np, false );
return m_node->AddRefNode( np );
}
bool IFSG_NODE::AddChildNode( SGNODE* aNode )
{
wxCHECK( m_node, false );
return m_node->AddChildNode( aNode );
}
bool IFSG_NODE::AddChildNode( IFSG_NODE& aNode )
{
wxCHECK( m_node, false );
SGNODE* np = aNode.GetRawPtr();
wxCHECK( np, false );
return m_node->AddChildNode( np );
}
-187
View File
@@ -1,187 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_normals.h"
#include "3d_cache/sg/sg_normals.h"
extern char BadParent[];
extern char WrongParent[];
IFSG_NORMALS::IFSG_NORMALS( bool create )
{
m_node = nullptr;
if( !create )
return;
m_node = new SGNORMALS( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_NORMALS::IFSG_NORMALS( SGNODE* aParent )
{
m_node = new SGNORMALS( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
IFSG_NORMALS::IFSG_NORMALS( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
BadParent );
}
#endif
m_node = new SGNORMALS( nullptr );
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_NORMALS::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_NORMALS != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_NORMALS::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SGNORMALS( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGNORMALS" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_NORMALS::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
bool IFSG_NORMALS::GetNormalList( size_t& aListSize, SGVECTOR*& aNormalList )
{
wxCHECK( m_node, false );
return ( (SGNORMALS*) m_node )->GetNormalList( aListSize, aNormalList );
}
bool IFSG_NORMALS::SetNormalList( size_t aListSize, const SGVECTOR* aNormalList )
{
wxCHECK( m_node, false );
( (SGNORMALS*) m_node )->SetNormalList( aListSize, aNormalList );
return true;
}
bool IFSG_NORMALS::AddNormal( double aXValue, double aYValue, double aZValue )
{
wxCHECK( m_node, false );
( (SGNORMALS*) m_node )->AddNormal( aXValue, aYValue, aZValue );
return true;
}
bool IFSG_NORMALS::AddNormal( const SGVECTOR& aNormal )
{
wxCHECK( m_node, false );
( (SGNORMALS*) m_node )->AddNormal( aNormal );
return true;
}
-152
View File
@@ -1,152 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_shape.h"
#include "3d_cache/sg/sg_shape.h"
extern char BadParent[];
extern char WrongParent[];
IFSG_SHAPE::IFSG_SHAPE( bool create )
{
m_node = nullptr;
if( !create )
return ;
m_node = new SGSHAPE( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_SHAPE::IFSG_SHAPE( SGNODE* aParent )
{
m_node = new SGSHAPE( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
IFSG_SHAPE::IFSG_SHAPE( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( !pp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
BadParent );
}
#endif
m_node = new SGSHAPE( nullptr );
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_SHAPE::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_SHAPE != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_SHAPE::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SGSHAPE( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGSHAPE" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_SHAPE::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
-192
View File
@@ -1,192 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_transform.h"
#include "3d_cache/sg/scenegraph.h"
extern char WrongParent[];
IFSG_TRANSFORM::IFSG_TRANSFORM( bool create )
{
m_node = nullptr;
if( !create )
return;
m_node = new SCENEGRAPH( nullptr );
m_node->AssociateWrapper( &m_node );
}
IFSG_TRANSFORM::IFSG_TRANSFORM( SGNODE* aParent )
{
m_node = new SCENEGRAPH( nullptr );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
}
bool IFSG_TRANSFORM::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = nullptr;
if( !aNode )
return false;
if( S3D::SGTYPE_TRANSFORM != aNode->GetNodeType() )
{
return false;
}
m_node = aNode;
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_TRANSFORM::NewNode( SGNODE* aParent )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = new SCENEGRAPH( aParent );
if( aParent != m_node->GetParent() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SCENEGRAPH" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
delete m_node;
m_node = nullptr;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_TRANSFORM::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
wxCHECK( np, false );
return NewNode( np );
}
bool IFSG_TRANSFORM::SetRotation( const SGVECTOR& aRotationAxis, double aAngle )
{
wxCHECK( m_node, false );
( (SCENEGRAPH*) m_node )->rotation_axis = aRotationAxis;
( (SCENEGRAPH*) m_node )->rotation_angle = aAngle;
return true;
}
bool IFSG_TRANSFORM::SetScale( const SGPOINT& aScale ) noexcept
{
wxCHECK( m_node, false );
( (SCENEGRAPH*) m_node )->scale = aScale;
return true;
}
bool IFSG_TRANSFORM::SetScale( double aScale )
{
wxCHECK( m_node, false );
if( aScale < 1e-8 && aScale > -1e-8 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] |scale| is < 1e-8 - this seems strange" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
( (SCENEGRAPH*) m_node )->scale = SGPOINT( aScale, aScale, aScale );
return true;
}
bool IFSG_TRANSFORM::SetTranslation( const SGPOINT& aTranslation ) noexcept
{
wxCHECK( m_node, false );
( (SCENEGRAPH*) m_node )->translation = aTranslation;
return true;
}
bool IFSG_TRANSFORM::SetScaleOrientation( const SGVECTOR& aScaleAxis, double aAngle )
{
wxCHECK( m_node, false );
( (SCENEGRAPH*) m_node )->scale_axis = aScaleAxis;
( (SCENEGRAPH*) m_node )->scale_angle = aAngle;
return true;
}
bool IFSG_TRANSFORM::SetCenter( const SGPOINT& aCenter ) noexcept
{
wxCHECK( m_node, false );
( (SCENEGRAPH*) m_node )->center = aCenter;
return true;
}
-733
View File
@@ -1,733 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define GLM_FORCE_RADIANS
#include <iostream>
#include <sstream>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <wx/log.h>
#include "3d_cache/sg/scenegraph.h"
#include "3d_cache/sg/sg_shape.h"
#include "3d_cache/sg/sg_helpers.h"
SCENEGRAPH::SCENEGRAPH( SGNODE* aParent ) : SGNODE( aParent )
{
m_SGtype = S3D::SGTYPE_TRANSFORM;
rotation_angle = 0.0;
scale_angle = 0.0;
scale.x = 1.0;
scale.y = 1.0;
scale.z = 1.0;
if( nullptr != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] inappropriate parent to SCENEGRAPH (type %d)" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeType() );
}
else if( nullptr != aParent && S3D::SGTYPE_TRANSFORM == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SCENEGRAPH::~SCENEGRAPH()
{
// drop references
DROP_REFS( SCENEGRAPH, m_RTransforms );
DROP_REFS( SGSHAPE, m_RShape );
// delete owned objects
DEL_OBJS( SCENEGRAPH, m_Transforms );
DEL_OBJS( SGSHAPE, m_Shape );
}
bool SCENEGRAPH::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a transform may be parent to a transform
if( nullptr != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
SGNODE* SCENEGRAPH::FindNode(const char *aNodeName, const SGNODE *aCaller)
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
FIND_NODE( SCENEGRAPH, aNodeName, m_Transforms, aCaller );
FIND_NODE( SGSHAPE, aNodeName, m_Shape, aCaller );
// query the parent if appropriate
if( aCaller == m_Parent || nullptr == m_Parent )
return nullptr;
return m_Parent->FindNode( aNodeName, this );
}
void SCENEGRAPH::unlinkNode( const SGNODE* aNode, bool isChild )
{
if( nullptr == aNode )
return;
switch( aNode->GetNodeType() )
{
case S3D::SGTYPE_TRANSFORM:
UNLINK_NODE( S3D::SGTYPE_TRANSFORM, SCENEGRAPH, aNode, m_Transforms, m_RTransforms,
isChild );
break;
case S3D::SGTYPE_SHAPE:
UNLINK_NODE( S3D::SGTYPE_SHAPE, SGSHAPE, aNode, m_Shape, m_RShape, isChild );
break;
default:
break;
}
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] unlinkNode() did not find its target" ),
__FILE__, __FUNCTION__, __LINE__ );
}
void SCENEGRAPH::unlinkChildNode( const SGNODE* aNode )
{
unlinkNode( aNode, true );
return;
}
void SCENEGRAPH::unlinkRefNode( const SGNODE* aNode )
{
unlinkNode( aNode, false );
return;
}
bool SCENEGRAPH::addNode( SGNODE* aNode, bool isChild )
{
wxCHECK( aNode, false );
ADD_NODE( S3D::SGTYPE_TRANSFORM, SCENEGRAPH, aNode, m_Transforms, m_RTransforms, isChild );
ADD_NODE( S3D::SGTYPE_SHAPE, SGSHAPE, aNode, m_Shape, m_RShape, isChild );
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] object '%s' is not a valid type for this object (%d)" ),
__FILE__, __FUNCTION__, __LINE__,
aNode->GetName(),
aNode->GetNodeType() );
return false;
}
bool SCENEGRAPH::AddRefNode( SGNODE* aNode )
{
return addNode( aNode, false );
}
bool SCENEGRAPH::AddChildNode( SGNODE* aNode )
{
return addNode( aNode, true );
}
void SCENEGRAPH::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
// rename all shapes
do
{
std::vector< SGSHAPE* >::iterator sL = m_Shape.begin();
std::vector< SGSHAPE* >::iterator eL = m_Shape.end();
while( sL != eL )
{
(*sL)->ReNameNodes();
++sL;
}
} while( 0 );
// rename all transforms
do
{
std::vector< SCENEGRAPH* >::iterator sL = m_Transforms.begin();
std::vector< SCENEGRAPH* >::iterator eL = m_Transforms.end();
while( sL != eL )
{
(*sL)->ReNameNodes();
++sL;
}
} while( 0 );
}
bool SCENEGRAPH::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( m_Transforms.empty() && m_RTransforms.empty() && m_Shape.empty() && m_RShape.empty() )
{
return false;
}
std::string tmp;
if( aReuseFlag )
{
if( !m_written )
{
aFile << "DEF " << GetName() << " Transform {\n";
m_written = true;
}
else
{
aFile << "USE " << GetName() << "\n";
return true;
}
}
else
{
aFile << " Transform {\n";
}
// convert center to 1VRML unit = 0.1 inch
SGPOINT pt = center;
pt.x /= 2.54;
pt.y /= 2.54;
pt.z /= 2.54;
S3D::FormatPoint( tmp, pt );
aFile << " center " << tmp << "\n";
S3D::FormatOrientation( tmp, rotation_axis, rotation_angle );
aFile << " rotation " << tmp << "\n";
S3D::FormatPoint( tmp, scale );
aFile << " scale " << tmp << "\n";
S3D::FormatOrientation( tmp, scale_axis, scale_angle );
aFile << " scaleOrientation " << tmp << "\n";
// convert translation to 1VRML unit = 0.1 inch
pt = translation;
pt.x /= 2.54;
pt.y /= 2.54;
pt.z /= 2.54;
S3D::FormatPoint( tmp, pt );
aFile << " translation " << tmp << "\n";
aFile << " children [\n";
if( !m_Transforms.empty() )
{
std::vector< SCENEGRAPH* >::iterator sL = m_Transforms.begin();
std::vector< SCENEGRAPH* >::iterator eL = m_Transforms.end();
while( sL != eL )
{
(*sL)->WriteVRML( aFile, aReuseFlag );
++sL;
}
}
if( !m_RTransforms.empty() )
{
std::vector< SCENEGRAPH* >::iterator sL = m_RTransforms.begin();
std::vector< SCENEGRAPH* >::iterator eL = m_RTransforms.end();
while( sL != eL )
{
(*sL)->WriteVRML( aFile, aReuseFlag );
++sL;
}
}
if( !m_Shape.empty() )
{
std::vector< SGSHAPE* >::iterator sL = m_Shape.begin();
std::vector< SGSHAPE* >::iterator eL = m_Shape.end();
while( sL != eL )
{
(*sL)->WriteVRML( aFile, aReuseFlag );
++sL;
}
}
if( !m_RShape.empty() )
{
std::vector< SGSHAPE* >::iterator sL = m_RShape.begin();
std::vector< SGSHAPE* >::iterator eL = m_RShape.end();
while( sL != eL )
{
(*sL)->WriteVRML( aFile, aReuseFlag );
++sL;
}
}
aFile << "] }\n";
return true;
}
bool SCENEGRAPH::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode && nullptr != m_Parent )
{
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK( parentNode == m_Parent, false );
if( nullptr == m_Parent )
{
// ensure unique node names
ResetNodeIndex();
ReNameNodes();
}
if( aFile.fail() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
aFile << "[" << GetName() << "]";
S3D::WritePoint( aFile, center );
S3D::WritePoint( aFile, translation );
S3D::WriteVector( aFile, rotation_axis );
aFile.write( (char*)&rotation_angle, sizeof( rotation_angle ) );
S3D::WritePoint( aFile, scale );
S3D::WriteVector( aFile, scale_axis );
aFile.write( (char*)&scale_angle, sizeof( scale_angle ) );
// Transfer ownership of any Transform references which hadn't been written
size_t asize = m_RTransforms.size();
size_t i;
for( i = 0; i < asize; ++i )
{
if( !m_RTransforms[i]->isWritten() )
{
m_RTransforms[i]->SwapParent( this );
--asize;
--i;
}
}
// Transfer ownership of any Shape references which hadn't been written
asize = m_RShape.size();
for( i = 0; i < asize; ++i )
{
if( !m_RShape[i]->isWritten() )
{
m_RShape[i]->SwapParent( this );
--asize;
--i;
}
}
asize = m_Transforms.size();
aFile.write( (char*)&asize, sizeof( size_t ) );
asize = m_RTransforms.size();
aFile.write( (char*)&asize, sizeof( size_t ) );
asize = m_Shape.size();
aFile.write( (char*)&asize, sizeof( size_t ) );
asize = m_RShape.size();
aFile.write( (char*)&asize, sizeof( size_t ) );
asize = m_Transforms.size();
// write child transforms
for( i = 0; i < asize; ++i )
{
if( !m_Transforms[i]->WriteCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [INFO] bad stream while writing child transforms" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
}
// write referenced transform names
asize = m_RTransforms.size();
for( i = 0; i < asize; ++i )
aFile << "[" << m_RTransforms[i]->GetName() << "]";
// write child shapes
asize = m_Shape.size();
for( i = 0; i < asize; ++i )
{
if( !m_Shape[i]->WriteCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [INFO] bad stream while writing child shapes" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
}
// write referenced transform names
asize = m_RShape.size();
for( i = 0; i < asize; ++i )
aFile << "[" << m_RShape[i]->GetName() << "]";
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SCENEGRAPH::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
wxCHECK( m_Transforms.empty() && m_RTransforms.empty() && m_Shape.empty() && m_RShape.empty(),
false );
std::string name; // name of the node
if( nullptr == parentNode )
{
// we need to read the tag and verify its type
if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; tag mismatch at position "
"%ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
m_Name = name;
}
// read fixed member data
S3D::ReadPoint( aFile, center );
S3D::ReadPoint( aFile, translation );
S3D::ReadVector( aFile, rotation_axis );
aFile.read( (char*)&rotation_angle, sizeof( rotation_angle ) );
S3D::ReadPoint( aFile, scale );
S3D::ReadVector( aFile, scale_axis );
aFile.read( (char*)&scale_angle, sizeof( scale_angle ) );
size_t sizeCT = 0; // child transforms
size_t sizeRT = 0; // referenced transforms
size_t sizeCS = 0; // child shapes
size_t sizeRS = 0; // referenced shapes
aFile.read( (char*)&sizeCT, sizeof( size_t ) );
aFile.read( (char*)&sizeRT, sizeof( size_t ) );
aFile.read( (char*)&sizeCS, sizeof( size_t ) );
aFile.read( (char*)&sizeRS, sizeof( size_t ) );
size_t i;
// read child transforms
for( i = 0; i < sizeCT; ++i )
{
if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child transform tag "
"at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
SCENEGRAPH* sp = new SCENEGRAPH( this );
sp->SetName( name.c_str() );
if( !sp->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data while reading transform "
"%ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
}
// read referenced transforms
for( i = 0; i < sizeRT; ++i )
{
if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref transform tag at "
"position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
SGNODE* sp = FindNode( name.c_str(), this );
if( !sp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: cannot find ref "
"transform at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
if( S3D::SGTYPE_TRANSFORM != sp->GetNodeType() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: type is not TRANSFORM "
"at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
AddRefNode( sp );
}
// read child shapes
for( i = 0; i < sizeCS; ++i )
{
if( S3D::SGTYPE_SHAPE != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child shape tag at "
"position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
SGSHAPE* sp = new SGSHAPE( this );
sp->SetName( name.c_str() );
if( !sp->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; corrupt data while "
"reading shape at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
}
// read referenced shapes
for( i = 0; i < sizeRS; ++i )
{
if( S3D::SGTYPE_SHAPE != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref shape tag at "
"position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
SGNODE* sp = FindNode( name.c_str(), this );
if( !sp )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: cannot find ref shape "
"at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
if( S3D::SGTYPE_SHAPE != sp->GetNodeType() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: type is not SGSHAPE at "
"position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
AddRefNode( sp );
}
if( aFile.fail() )
return false;
return true;
}
bool SCENEGRAPH::Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
std::vector< SMESH >& meshes )
{
// calculate the accumulated transform
double rX, rY, rZ;
// rotation
rotation_axis.GetVector( rX, rY, rZ );
glm::dmat4 rM = glm::rotate( glm::dmat4( 1.0 ), rotation_angle, glm::dvec3( rX, rY, rZ ) );
// translation
glm::dmat4 tM = glm::translate( glm::dmat4( 1.0 ), glm::dvec3( translation.x, translation.y,
translation.z ) );
// center
glm::dmat4 cM = glm::translate( glm::dmat4( 1.0 ), glm::dvec3( center.x, center.y, center.z ) );
glm::dmat4 ncM = glm::translate( glm::dmat4( 1.0 ), glm::dvec3( -center.x, -center.y,
-center.z ) );
// scale
glm::dmat4 sM = glm::scale( glm::dmat4( 1.0 ), glm::dvec3( scale.x, scale.y, scale.z ) );
// scaleOrientation
scale_axis.GetVector( rX, rY, rZ );
glm::dmat4 srM = glm::rotate( glm::dmat4( 1.0 ), scale_angle, glm::dvec3( rX, rY, rZ ) );
glm::dmat4 nsrM = glm::rotate( glm::dmat4( 1.0 ), -scale_angle, glm::dvec3( rX, rY, rZ ) );
// resultant point:
// P' = T x C x R x SR x S x -SR x -C x P
// resultant transform:
// tx0 = tM * cM * rM * srM * sM * nsrM * ncM
glm::dmat4 tx0;
if( nullptr != aTransform )
tx0 = (*aTransform) * tM * cM * rM * srM * sM * nsrM * ncM;
else
tx0 = tM * cM * rM * srM * sM * nsrM * ncM;
bool ok = true;
// prepare all shapes
do
{
std::vector< SGSHAPE* >::iterator sL = m_Shape.begin();
std::vector< SGSHAPE* >::iterator eL = m_Shape.end();
while( sL != eL && ok )
{
ok = (*sL)->Prepare( &tx0, materials, meshes );
++sL;
}
sL = m_RShape.begin();
eL = m_RShape.end();
while( sL != eL && ok )
{
ok = (*sL)->Prepare( &tx0, materials, meshes );
++sL;
}
} while( 0 );
// prepare all transforms
do
{
std::vector< SCENEGRAPH* >::iterator sL = m_Transforms.begin();
std::vector< SCENEGRAPH* >::iterator eL = m_Transforms.end();
while( sL != eL && ok )
{
ok = (*sL)->Prepare( &tx0, materials, meshes );
++sL;
}
sL = m_RTransforms.begin();
eL = m_RTransforms.end();
while( sL != eL && ok )
{
ok = (*sL)->Prepare( &tx0, materials, meshes );
++sL;
}
} while( 0 );
return ok;
}
-109
View File
@@ -1,109 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file scenegraph.h
*/
#ifndef SCENE_GRAPH_H
#define SCENE_GRAPH_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGSHAPE;
/**
* Define the basic data set required to represent a 3D model.
*
* This model must remain compatible with VRML2.0 in order to facilitate VRML export of
* scene graph data created by available 3D plugins.
*/
class SCENEGRAPH : public SGNODE
{
public:
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
SCENEGRAPH( SGNODE* aParent );
virtual ~SCENEGRAPH();
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) override;
bool AddRefNode( SGNODE* aNode ) override;
bool AddChildNode( SGNODE* aNode ) override;
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
bool Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
std::vector< SMESH >& meshes );
private:
void unlinkNode( const SGNODE* aNode, bool isChild );
bool addNode( SGNODE* aNode, bool isChild );
public:
// note: order of transformation is Translate, Rotate, Offset
SGPOINT center;
SGPOINT translation;
SGVECTOR rotation_axis;
double rotation_angle; // radians
SGPOINT scale;
SGVECTOR scale_axis;
double scale_angle; // radians
private:
// The following are items which may be defined for reuse
// in a VRML output file. They do not necessarily correspond
// to the use of DEF within a VRML input file; it is the
// responsibility of the plugin to perform any necessary
// conversions to comply with the restrictions imposed by
// this scene graph structure
std::vector< SCENEGRAPH* > m_Transforms; // local Transform nodes
std::vector< SGSHAPE* > m_Shape; // local Shape nodes
std::vector< SCENEGRAPH* > m_RTransforms; // referenced Transform nodes
std::vector< SGSHAPE* > m_RShape; // referenced Shape nodes
};
/*
p.120
Transform {
center 0 0 0
children []
rotation 0 0 1 0
scale 1 1 1
scaleOrientation 0 0 1 0
translation 0 0 0
bboxCenter 0 0 0
bboxSize -1 -1 -1
}
*/
#endif // SCENE_GRAPH_H
-363
View File
@@ -1,363 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <utility>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_appearance.h"
#include "3d_cache/sg/sg_helpers.h"
SGAPPEARANCE::SGAPPEARANCE( SGNODE* aParent ) : SGNODE( aParent )
{
m_SGtype = S3D::SGTYPE_APPEARANCE;
// defaults in accord with VRML2.0 spec
ambient.SetColor( 0.05317f, 0.17879f, 0.01804f );
shininess = 0.2f;
transparency = 0.0f;
diffuse.SetColor( 0.8f, 0.8f, 0.8f );
if( nullptr != aParent && S3D::SGTYPE_SHAPE != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] inappropriate parent to SGAPPEARANCE (type %s )" ),
__FILE__, __FUNCTION__, __LINE__, aParent->GetNodeType() );
}
else if( nullptr != aParent && S3D::SGTYPE_SHAPE == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SGAPPEARANCE::~SGAPPEARANCE()
{
}
bool SGAPPEARANCE::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a SGSHAPE may be parent to a SGAPPEARANCE
if( nullptr != aParent && S3D::SGTYPE_SHAPE != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
bool SGAPPEARANCE::SetEmissive( float aRVal, float aGVal, float aBVal )
{
return emissive.SetColor( aRVal, aGVal, aBVal );
}
bool SGAPPEARANCE::SetEmissive( const SGCOLOR* aRGBColor )
{
wxCHECK_MSG( aRGBColor, false, wxT( "NULL pointer passed for aRGBColor" ) );
return emissive.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetEmissive( const SGCOLOR& aRGBColor )
{
return emissive.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetDiffuse( float aRVal, float aGVal, float aBVal )
{
return diffuse.SetColor( aRVal, aGVal, aBVal );
}
bool SGAPPEARANCE::SetDiffuse( const SGCOLOR* aRGBColor )
{
wxCHECK_MSG( aRGBColor, false, wxT( "NULL pointer passed for aRGBColor" ) );
return diffuse.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetDiffuse( const SGCOLOR& aRGBColor )
{
return diffuse.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetSpecular( float aRVal, float aGVal, float aBVal )
{
return specular.SetColor( aRVal, aGVal, aBVal );
}
bool SGAPPEARANCE::SetSpecular( const SGCOLOR* aRGBColor )
{
wxCHECK_MSG( aRGBColor, false, wxT( "NULL pointer passed for aRGBColor" ) );
return specular.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetSpecular( const SGCOLOR& aRGBColor )
{
return specular.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetAmbient( float aRVal, float aGVal, float aBVal )
{
return ambient.SetColor( aRVal, aGVal, aBVal );
}
bool SGAPPEARANCE::SetAmbient( const SGCOLOR* aRGBColor )
{
wxCHECK_MSG( aRGBColor, false, wxT( "NULL pointer passed for aRGBColor" ) );
return ambient.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetAmbient( const SGCOLOR& aRGBColor )
{
return ambient.SetColor( aRGBColor );
}
SGNODE* SGAPPEARANCE::FindNode( const char* aNodeName, const SGNODE* aCaller) noexcept
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
return nullptr;
}
void SGAPPEARANCE::unlinkChildNode( const SGNODE* aCaller ) noexcept
{
wxCHECK_MSG( aCaller, /* void */,
wxT( "unexpected code branch; node should have no children or refs" ) );
}
void SGAPPEARANCE::unlinkRefNode( const SGNODE* aCaller ) noexcept
{
wxCHECK_MSG( aCaller, /* void */,
wxT( "unexpected code branch; node should have no children or refs" ) );
}
bool SGAPPEARANCE::AddRefNode( SGNODE* aNode ) noexcept
{
wxCHECK_MSG( aNode, false, wxT( "this node does not accept children or refs" ) );
// This is redundant but it keeps gcc from generating a warning on debug builds.
return false;
}
bool SGAPPEARANCE::AddChildNode( SGNODE* aNode ) noexcept
{
wxCHECK_MSG( aNode, false, wxT( "this node does not accept children or refs" ) );
// This is redundant but it keeps gcc from generating a warning on debug builds.
return false;
}
void SGAPPEARANCE::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
}
bool SGAPPEARANCE::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( aReuseFlag )
{
if( !m_written )
{
aFile << " appearance DEF " << GetName() << " Appearance {\n";
m_written = true;
}
else
{
aFile << " appearance USE " << GetName() << "\n";
return true;
}
}
else
{
aFile << " appearance Appearance {\n";
}
aFile << " material Material {\n";
std::string tmp;
float ambr, ambg, ambb;
ambient.GetColor( ambr, ambg, ambb );
float amb = ( 0.212671 * ambr + 0.71516 * ambg + 0.072169 * ambb );
diffuse.GetColor( ambr, ambg, ambb );
float den = ( 0.212671 * ambr + 0.71516 * ambg + 0.072169 * ambb );
if( den < 0.004f )
den = 0.004f;
amb /= den;
if( amb > 1.0f )
amb = 1.0f;
S3D::FormatFloat( tmp, amb );
aFile << " ambientIntensity " << tmp << "\n";
float red, green, blue;
diffuse.GetColor( red, green, blue );
S3D::FormatFloat( tmp, red );
aFile << " diffuseColor " << tmp << " ";
S3D::FormatFloat( tmp, green );
aFile << tmp << " ";
S3D::FormatFloat( tmp, blue);
aFile << tmp << "\n";
emissive.GetColor( red, green, blue );
S3D::FormatFloat( tmp, red );
aFile << " emissiveColor " << tmp << " ";
S3D::FormatFloat( tmp, green );
aFile << tmp << " ";
S3D::FormatFloat( tmp, blue);
aFile << tmp << "\n";
S3D::FormatFloat( tmp, shininess );
aFile << " shininess " << tmp << "\n";
specular.GetColor( red, green, blue );
S3D::FormatFloat( tmp, red );
aFile << " specularColor " << tmp << " ";
S3D::FormatFloat( tmp, green );
aFile << tmp << " ";
S3D::FormatFloat( tmp, blue);
aFile << tmp << "\n";
S3D::FormatFloat( tmp, transparency );
aFile << " transparency " << tmp << "\n";
aFile << "} }\n";
return true;
}
bool SGAPPEARANCE::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode )
{
wxCHECK_MSG( m_Parent, false, wxT( "corrupt data; m_aParent is NULL" ) );
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK_MSG( parentNode == m_Parent, false, wxT( "corrupt data; parentNode != m_aParent" ) );
if( !aFile.good() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
aFile << "[" << GetName() << "]";
S3D::WriteColor( aFile, ambient );
aFile.write( (char*) &shininess, sizeof( shininess ) );
aFile.write( (char*) &transparency, sizeof( transparency ) );
S3D::WriteColor( aFile, diffuse );
S3D::WriteColor( aFile, emissive );
S3D::WriteColor( aFile, specular );
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SGAPPEARANCE::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
S3D::ReadColor( aFile, ambient );
aFile.read( (char*) &shininess, sizeof( shininess ) );
aFile.read( (char*) &transparency, sizeof( transparency ) );
S3D::ReadColor( aFile, diffuse );
S3D::ReadColor( aFile, emissive );
S3D::ReadColor( aFile, specular );
if( aFile.fail() )
return false;
return true;
}
-83
View File
@@ -1,83 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_appearance.h
*/
#ifndef SG_APPEARANCE_H
#define SG_APPEARANCE_H
#include "3d_cache/sg/sg_node.h"
/**
* Defines the generic material appearance of a scenegraph object.
*/
class SGAPPEARANCE : public SGNODE
{
public:
void unlinkChildNode( const SGNODE* aNode ) noexcept override;
void unlinkRefNode( const SGNODE* aNode ) noexcept override;
SGAPPEARANCE( SGNODE* aParent );
virtual ~SGAPPEARANCE();
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
bool SetEmissive( float aRVal, float aGVal, float aBVal );
bool SetEmissive( const SGCOLOR* aRGBColor );
bool SetEmissive( const SGCOLOR& aRGBColor );
bool SetDiffuse( float aRVal, float aGVal, float aBVal );
bool SetDiffuse( const SGCOLOR* aRGBColor );
bool SetDiffuse( const SGCOLOR& aRGBColor );
bool SetSpecular( float aRVal, float aGVal, float aBVal );
bool SetSpecular( const SGCOLOR* aRGBColor );
bool SetSpecular( const SGCOLOR& aRGBColor );
bool SetAmbient( float aRVal, float aGVal, float aBVal );
bool SetAmbient( const SGCOLOR* aRGBColor );
bool SetAmbient( const SGCOLOR& aRGBColor );
SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override;
bool AddRefNode( SGNODE* aNode ) noexcept override;
bool AddChildNode( SGNODE* aNode ) noexcept override;
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
float shininess; // default 0.2
float transparency; // default 0.0
SGCOLOR ambient; // default 0.05317 0.17879 0.01804
SGCOLOR diffuse; // default 0.8 0.8 0.8
SGCOLOR emissive; // default 0.0 0.0 0.0
SGCOLOR specular; // default 0.0 0.0 0.0
};
#endif // SG_APPEARANCE_H
-276
View File
@@ -1,276 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cmath>
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/sg_base.h"
SGCOLOR::SGCOLOR()
{
red = 0.0;
green = 0.0;
blue = 0.0;
}
SGCOLOR::SGCOLOR( float aRVal, float aGVal, float aBVal )
{
if( !checkRange( aRVal, aGVal, aBVal ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid value passed to constructor" ),
__FILE__, __FUNCTION__, __LINE__ );
red = 0.0;
green = 0.0;
blue = 0.0;
return;
}
red = aRVal;
green = aGVal;
blue = aBVal;
}
void SGCOLOR::GetColor( float& aRedVal, float& aGreenVal, float& aBlueVal ) const noexcept
{
aRedVal = red;
aGreenVal = green;
aBlueVal = blue;
}
void SGCOLOR::GetColor( SGCOLOR& aColor ) const noexcept
{
aColor.red = red;
aColor.green = green;
aColor.blue = blue;
}
void SGCOLOR::GetColor( SGCOLOR* aColor ) const noexcept
{
wxCHECK_MSG( aColor, /* void */, wxT( "NULL pointer passed for aRGBColor" ) );
aColor->red = red;
aColor->green = green;
aColor->blue = blue;
}
bool SGCOLOR::SetColor( float aRedVal, float aGreenVal, float aBlueVal )
{
if( !checkRange( aRedVal, aGreenVal, aBlueVal ) )
return false;
red = aRedVal;
green = aGreenVal;
blue = aBlueVal;
return true;
}
bool SGCOLOR::SetColor( const SGCOLOR& aColor ) noexcept
{
red = aColor.red;
green = aColor.green;
blue = aColor.blue;
return true;
}
bool SGCOLOR::SetColor( const SGCOLOR* aColor ) noexcept
{
wxCHECK_MSG( aColor, false, wxT( "NULL pointer passed for aRGBColor" ) );
red = aColor->red;
green = aColor->green;
blue = aColor->blue;
return true;
}
bool SGCOLOR::checkRange( float aRedVal, float aGreenVal, float aBlueVal ) const noexcept
{
bool ok = true;
if( aRedVal < 0.0 || aRedVal > 1.0 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid RED value: %g" ),
__FILE__, __FUNCTION__, __LINE__, aRedVal );
ok = false;
}
if( aGreenVal < 0.0 || aGreenVal > 1.0 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid GREEN value: %g" ),
__FILE__, __FUNCTION__, __LINE__, aGreenVal );
ok = false;
}
if( aBlueVal < 0.0 || aBlueVal > 1.0 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid BLUE value: %g" ),
__FILE__, __FUNCTION__, __LINE__, aBlueVal );
ok = false;
}
return ok;
}
SGPOINT::SGPOINT()
{
x = 0.0;
y = 0.0;
z = 0.0;
}
SGPOINT::SGPOINT( double aXVal, double aYVal, double aZVal ) noexcept
{
x = aXVal;
y = aYVal;
z = aZVal;
}
void SGPOINT::GetPoint( const double& aXVal, const double& aYVal, const double& aZVal ) noexcept
{
x = aXVal;
y = aYVal;
z = aZVal;
}
void SGPOINT::GetPoint( const SGPOINT& aPoint ) noexcept
{
x = aPoint.x;
y = aPoint.y;
z = aPoint.z;
}
void SGPOINT::GetPoint( const SGPOINT* aPoint ) noexcept
{
wxCHECK_MSG( aPoint, /* void */, wxT( "NULL pointer passed for aPoint" ) );
x = aPoint->x;
y = aPoint->y;
z = aPoint->z;
}
void SGPOINT::SetPoint( double aXVal, double aYVal, double aZVal ) noexcept
{
x = aXVal;
y = aYVal;
z = aZVal;
}
void SGPOINT::SetPoint( const SGPOINT& aPoint ) noexcept
{
x = aPoint.x;
y = aPoint.y;
z = aPoint.z;
}
SGVECTOR::SGVECTOR()
{
vx = 0.0;
vy = 0.0;
vz = 1.0;
}
SGVECTOR::SGVECTOR( double aXVal, double aYVal, double aZVal )
{
vx = aXVal;
vy = aYVal;
vz = aZVal;
normalize();
}
void SGVECTOR::GetVector( double& aXVal, double& aYVal, double& aZVal ) const noexcept
{
aXVal = vx;
aYVal = vy;
aZVal = vz;
}
void SGVECTOR::SetVector( double aXVal, double aYVal, double aZVal )
{
vx = aXVal;
vy = aYVal;
vz = aZVal;
normalize();
}
void SGVECTOR::SetVector( const SGVECTOR& aVector )
{
aVector.GetVector( vx, vy, vz );
}
void SGVECTOR::normalize( void ) noexcept
{
double dx = vx * vx;
double dy = vy * vy;
double dz = vz * vz;
double dv2 = sqrt( dx + dy + dz );
if( ( dx + dy + dz ) < 1e-8 )
{
// use the default; the numbers are too small to be believable
vx = 0.0;
vy = 0.0;
vz = 1.0;
return;
}
vx /= dv2;
vy /= dv2;
vz /= dv2;
}
SGVECTOR& SGVECTOR::operator=( const SGVECTOR& source ) noexcept
{
vx = source.vx;
vy = source.vy;
vz = source.vz;
return *this;
}
-304
View File
@@ -1,304 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_colors.h"
#include "3d_cache/sg/sg_helpers.h"
SGCOLORS::SGCOLORS( SGNODE* aParent ) : SGNODE( aParent )
{
m_SGtype = S3D::SGTYPE_COLORS;
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] inappropriate parent to SGCOLORS (type %s)" ),
__FILE__, __FUNCTION__, __LINE__, aParent->GetNodeType() );
}
else if( nullptr != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SGCOLORS::~SGCOLORS()
{
colors.clear();
}
bool SGCOLORS::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a SGFACESET may be parent to a SGCOLORS
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
SGNODE* SGCOLORS::FindNode(const char* aNodeName, const SGNODE *aCaller) noexcept
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
return nullptr;
}
void SGCOLORS::unlinkChildNode( const SGNODE* aCaller ) noexcept
{
wxCHECK( aCaller, /* void */ );
}
void SGCOLORS::unlinkRefNode( const SGNODE* aCaller ) noexcept
{
wxCHECK( aCaller, /* void */ );
}
bool SGCOLORS::AddRefNode( SGNODE* aNode ) noexcept
{
wxCHECK( aNode, false );
return false;
}
bool SGCOLORS::AddChildNode( SGNODE* aNode ) noexcept
{
wxCHECK( aNode, false );
return false;
}
bool SGCOLORS::GetColorList( size_t& aListSize, SGCOLOR*& aColorList )
{
if( colors.empty() )
{
aListSize = 0;
aColorList = nullptr;
return false;
}
aListSize = colors.size();
aColorList = &colors[0];
return true;
}
void SGCOLORS::SetColorList( size_t aListSize, const SGCOLOR* aColorList )
{
colors.clear();
if( 0 == aListSize || nullptr == aColorList )
return;
for( size_t i = 0; i < aListSize; ++i )
colors.push_back( aColorList[i] );
return;
}
void SGCOLORS::AddColor( double aRedValue, double aGreenValue, double aBlueValue )
{
colors.emplace_back( aRedValue, aGreenValue, aBlueValue );
return;
}
void SGCOLORS::AddColor( const SGCOLOR& aColor )
{
colors.push_back( aColor );
return;
}
void SGCOLORS::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
}
bool SGCOLORS::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( colors.empty() )
return false;
if( aReuseFlag )
{
if( !m_written )
{
aFile << "color DEF " << GetName() << " Color { color [\n ";
m_written = true;
}
else
{
aFile << "color USE " << GetName() << "\n";
return true;
}
}
else
{
aFile << "color Color { color [\n ";
}
std::string tmp;
size_t n = colors.size();
bool nline = false;
for( size_t i = 0; i < n; )
{
S3D::FormatColor( tmp, colors[i] );
float r,g,b;
colors[i].GetColor(r, g, b);
aFile << tmp ;
++i;
if( i < n )
{
aFile << ",";
if( nline )
{
aFile << "\n ";
nline = false;
}
else
{
nline = true;
}
}
}
aFile << "] }\n";
return true;
}
bool SGCOLORS::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode )
{
wxCHECK( m_Parent, false );
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK( parentNode == m_Parent, false );
if( !aFile.good() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
aFile << "[" << GetName() << "]";
size_t ncolors = colors.size();
aFile.write( (char*)&ncolors, sizeof(size_t) );
for( size_t i = 0; i < ncolors; ++i )
S3D::WriteColor( aFile, colors[i] );
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SGCOLORS::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
wxCHECK( colors.empty(), false );
size_t ncolors;
aFile.read( (char*) &ncolors, sizeof( size_t ) );
SGCOLOR tmp;
if( aFile.fail() )
return false;
for( size_t i = 0; i < ncolors; ++i )
{
if( !S3D::ReadColor( aFile, tmp ) || aFile.fail() )
return false;
colors.push_back( tmp );
}
return true;
}
-67
View File
@@ -1,67 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_colors.h
*/
#ifndef SG_COLORS_H
#define SG_COLORS_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
/**
* Define an RGB color set for a scenegraph object.
*/
class SGCOLORS : public SGNODE
{
public:
SGCOLORS( SGNODE* aParent );
virtual ~SGCOLORS();
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
void unlinkChildNode( const SGNODE* aNode ) noexcept override;
void unlinkRefNode( const SGNODE* aNode ) noexcept override;
SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override;
bool AddRefNode( SGNODE* aNode ) noexcept override;
bool AddChildNode( SGNODE* aNode ) noexcept override;
bool GetColorList( size_t& aListSize, SGCOLOR*& aColorList );
void SetColorList( size_t aListSize, const SGCOLOR* aColorList );
void AddColor( double aRedValue, double aGreenValue, double aBlueValue );
void AddColor( const SGCOLOR& aColor );
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
std::vector< SGCOLOR > colors;
};
#endif // SG_COLORS_H
-50
View File
@@ -1,50 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "3d_cache/sg/sg_coordindex.h"
SGCOORDINDEX::SGCOORDINDEX( SGNODE* aParent ) : SGINDEX( aParent )
{
m_SGtype = S3D::SGTYPE_COORDINDEX;
if( nullptr != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SGCOORDINDEX::~SGCOORDINDEX()
{
}
void SGCOORDINDEX::GatherCoordIndices( std::vector< int >& aIndexList )
{
if( index.empty() )
return;
aIndexList.insert( aIndexList.end(), index.begin(), index.end() );
}
-54
View File
@@ -1,54 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_coordindex.h
*/
#ifndef SG_COORDINDEX_H
#define SG_COORDINDEX_H
#include "3d_cache/sg/sg_index.h"
/**
* An object to maintain a coordinate index list.
*
* Users must ensure that coordinate indices are specified as triplets (triangular faces)
* since no checking is performed. In instances where it is not possible to determine which
* side of the triangle is to be rendered (for example IGES entities) then the user must
* supply each triplet in both point orders.
*/
class SGCOORDINDEX : public SGINDEX
{
public:
SGCOORDINDEX( SGNODE* aParent );
virtual ~SGCOORDINDEX();
/**
* Add all coordinate indices to the given list in preparation for a normals calculation.
*/
void GatherCoordIndices( std::vector< int >& aIndexList );
};
#endif // SG_COORDINDEX_H
-363
View File
@@ -1,363 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_coords.h"
#include "3d_cache/sg/sg_helpers.h"
#include "3d_cache/sg/sg_normals.h"
#include "3d_cache/sg/sg_faceset.h"
SGCOORDS::SGCOORDS( SGNODE* aParent ) : SGNODE( aParent )
{
m_SGtype = S3D::SGTYPE_COORDS;
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] inappropriate parent to SGCOORDS (type %s)" ),
__FILE__, __FUNCTION__, __LINE__, aParent->GetNodeType() );
}
else if( nullptr != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SGCOORDS::~SGCOORDS()
{
coords.clear();
}
bool SGCOORDS::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a SGFACESET may be parent to a SGCOORDS
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
SGNODE* SGCOORDS::FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
return nullptr;
}
void SGCOORDS::unlinkChildNode( const SGNODE* aCaller ) noexcept
{
wxCHECK( aCaller, /* void */ );
}
void SGCOORDS::unlinkRefNode( const SGNODE* aCaller ) noexcept
{
wxCHECK( aCaller, /* void */ );
}
bool SGCOORDS::AddRefNode( SGNODE* aNode ) noexcept
{
wxCHECK( aNode, false );
return false;
}
bool SGCOORDS::AddChildNode( SGNODE* aNode ) noexcept
{
wxCHECK( aNode, false );
return false;
}
bool SGCOORDS::GetCoordsList( size_t& aListSize, SGPOINT*& aCoordsList )
{
if( coords.empty() )
{
aListSize = 0;
aCoordsList = nullptr;
return false;
}
aListSize = coords.size();
aCoordsList = &coords[0];
return true;
}
void SGCOORDS::SetCoordsList( size_t aListSize, const SGPOINT* aCoordsList )
{
coords.clear();
if( 0 == aListSize || nullptr == aCoordsList )
return;
for( size_t i = 0; i < aListSize; ++i )
coords.push_back( aCoordsList[i] );
}
void SGCOORDS::AddCoord( double aXValue, double aYValue, double aZValue )
{
coords.emplace_back( aXValue, aYValue, aZValue );
}
void SGCOORDS::AddCoord( const SGPOINT& aPoint )
{
coords.push_back( aPoint );
}
void SGCOORDS::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
}
bool SGCOORDS::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( coords.empty() )
return false;
if( aReuseFlag )
{
if( !m_written )
{
aFile << " coord DEF " << GetName() << " Coordinate { point [\n ";
m_written = true;
}
else
{
aFile << " coord USE " << GetName() << "\n";
return true;
}
}
else
{
aFile << " coord Coordinate { point [\n ";
}
std::string tmp;
size_t n = coords.size();
bool nline = false;
SGPOINT pt;
for( size_t i = 0; i < n; )
{
// ensure VRML output has 1U = 0.1 inch as per legacy kicad expectations
pt = coords[i];
pt.x /= 2.54;
pt.y /= 2.54;
pt.z /= 2.54;
S3D::FormatPoint( tmp, pt );
aFile << tmp ;
++i;
if( i < n )
{
aFile << ",";
if( nline )
{
aFile << "\n ";
nline = false;
}
else
{
nline = true;
}
}
}
aFile << "] }\n";
return true;
}
bool SGCOORDS::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode )
{
wxCHECK( m_Parent, false );
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK( parentNode == m_Parent, false );
if( !aFile.good() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
aFile << "[" << GetName() << "]";
size_t npts = coords.size();
aFile.write( (char*)&npts, sizeof(size_t) );
for( size_t i = 0; i < npts; ++i )
S3D::WritePoint( aFile, coords[i] );
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SGCOORDS::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
wxCHECK( coords.empty(), false );
size_t npts;
aFile.read( (char*) &npts, sizeof( size_t ) );
SGPOINT tmp;
if( aFile.fail() )
return false;
for( size_t i = 0; i < npts; ++i )
{
if( !S3D::ReadPoint( aFile, tmp ) || aFile.fail() )
return false;
coords.push_back( tmp );
}
return true;
}
bool SGCOORDS::CalcNormals( SGFACESET* callingNode, SGNODE** aPtr )
{
if( aPtr )
*aPtr = nullptr;
if( nullptr == m_Parent || nullptr == callingNode )
return false;
// the parent and all references must have indices; collect all
// indices into one std::vector<>
std::vector< int > ilist;
SGNORMALS* np = nullptr;
if( callingNode == m_Parent )
{
((SGFACESET*)m_Parent)->GatherCoordIndices( ilist );
std::list< SGNODE* >::iterator sB = m_BackPointers.begin();
std::list< SGNODE* >::iterator eB = m_BackPointers.end();
while( sB != eB )
{
SGFACESET* fp = (SGFACESET*)(*sB);
fp->GatherCoordIndices( ilist );
++sB;
}
np = ( (SGFACESET*) m_Parent )->m_Normals;
if( !np )
np = new SGNORMALS( m_Parent );
}
else
{
callingNode->GatherCoordIndices( ilist );
np = callingNode->m_Normals;
if( !np )
np = new SGNORMALS( callingNode );
}
if( S3D::CalcTriangleNormals( coords, ilist, np->norms ) )
{
if( aPtr )
*aPtr = np;
return true;
}
delete np;
return false;
}
-75
View File
@@ -1,75 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_coords.h
*/
#ifndef SG_COORDS_H
#define SG_COORDS_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGFACESET;
/**
* Define a vertex coordinate set for a scenegraph object.
*/
class SGCOORDS : public SGNODE
{
public:
SGCOORDS( SGNODE* aParent );
virtual ~SGCOORDS();
void unlinkChildNode( const SGNODE* aNode ) noexcept override;
void unlinkRefNode( const SGNODE* aNode ) noexcept override;
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override;
bool AddRefNode( SGNODE* aNode ) noexcept override;
bool AddChildNode( SGNODE* aNode ) noexcept override;
bool GetCoordsList( size_t& aListSize, SGPOINT*& aCoordsList );
void SetCoordsList( size_t aListSize, const SGPOINT* aCoordsList );
void AddCoord( double aXValue, double aYValue, double aZValue );
void AddCoord( const SGPOINT& aPoint );
/**
* Calculate normals for this coordinate list and sets the normals list in the
* parent #SGFACESET.
*/
bool CalcNormals( SGFACESET* callingNode, SGNODE** aPtr = nullptr );
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
std::vector< SGPOINT > coords;
};
#endif // SG_COORDS_H
-992
View File
@@ -1,992 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_faceset.h"
#include "3d_cache/sg/sg_colors.h"
#include "3d_cache/sg/sg_coords.h"
#include "3d_cache/sg/sg_normals.h"
#include "3d_cache/sg/sg_coordindex.h"
#include "3d_cache/sg/sg_helpers.h"
SGFACESET::SGFACESET( SGNODE* aParent ) : SGNODE( aParent )
{
m_SGtype = S3D::SGTYPE_FACESET;
m_Colors = nullptr;
m_Coords = nullptr;
m_CoordIndices = nullptr;
m_Normals = nullptr;
m_RColors = nullptr;
m_RCoords = nullptr;
m_RNormals = nullptr;
valid = false;
validated = false;
if( nullptr != aParent && S3D::SGTYPE_SHAPE != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] inappropriate parent to SGFACESET (type %s)" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeType() );
}
else if( nullptr != aParent && S3D::SGTYPE_SHAPE == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SGFACESET::~SGFACESET()
{
// drop references
if( m_RColors )
{
m_RColors->delNodeRef( this );
m_RColors = nullptr;
}
if( m_RCoords )
{
m_RCoords->delNodeRef( this );
m_RCoords = nullptr;
}
if( m_RNormals )
{
m_RNormals->delNodeRef( this );
m_RNormals = nullptr;
}
// delete owned objects
if( m_Colors )
{
m_Colors->SetParent( nullptr, false );
delete m_Colors;
m_Colors = nullptr;
}
if( m_Coords )
{
m_Coords->SetParent( nullptr, false );
delete m_Coords;
m_Coords = nullptr;
}
if( m_Normals )
{
m_Normals->SetParent( nullptr, false );
delete m_Normals;
m_Normals = nullptr;
}
if( m_CoordIndices )
{
m_CoordIndices->SetParent( nullptr, false );
delete m_CoordIndices;
m_CoordIndices = nullptr;
}
}
bool SGFACESET::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a SGSHAPE may be parent to a SGFACESET
if( nullptr != aParent && S3D::SGTYPE_SHAPE != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
SGNODE* SGFACESET::FindNode(const char *aNodeName, const SGNODE *aCaller)
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
SGNODE* np = nullptr;
if( m_Colors )
{
np = m_Colors->FindNode( aNodeName, this );
if( np )
return np;
}
if( m_Coords )
{
np = m_Coords->FindNode( aNodeName, this );
if( np )
return np;
}
if( m_CoordIndices )
{
np = m_CoordIndices->FindNode( aNodeName, this );
if( np )
return np;
}
if( m_Normals )
{
np = m_Normals->FindNode( aNodeName, this );
if( np )
return np;
}
// query the parent if appropriate
if( aCaller == m_Parent || nullptr == m_Parent )
return nullptr;
return m_Parent->FindNode( aNodeName, this );
}
void SGFACESET::unlinkNode( const SGNODE* aNode, bool isChild )
{
if( nullptr == aNode )
return;
valid = false;
validated = false;
if( isChild )
{
if( aNode == m_Colors )
{
m_Colors = nullptr;
return;
}
if( aNode == m_Coords )
{
m_Coords = nullptr;
return;
}
if( aNode == m_Normals )
{
m_Normals = nullptr;
return;
}
if( aNode == m_CoordIndices )
{
m_CoordIndices = nullptr;
return;
}
}
else
{
if( aNode == m_RColors )
{
delNodeRef( this );
m_RColors = nullptr;
return;
}
if( aNode == m_RCoords )
{
delNodeRef( this );
m_RCoords = nullptr;
return;
}
if( aNode == m_RNormals )
{
delNodeRef( this );
m_RNormals = nullptr;
return;
}
}
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] unlinkNode() did not find its target" ),
__FILE__, __FUNCTION__, __LINE__ );
}
void SGFACESET::unlinkChildNode( const SGNODE* aNode )
{
unlinkNode( aNode, true );
}
void SGFACESET::unlinkRefNode( const SGNODE* aNode )
{
unlinkNode( aNode, false );
}
bool SGFACESET::addNode( SGNODE* aNode, bool isChild )
{
wxCHECK( aNode, false );
valid = false;
validated = false;
if( S3D::SGTYPE_COLORS == aNode->GetNodeType() )
{
if( m_Colors || m_RColors )
{
if( aNode != m_Colors && aNode != m_RColors )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] assigning multiple Colors nodes" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
return true;
}
if( isChild )
{
m_Colors = (SGCOLORS*)aNode;
m_Colors->SetParent( this );
}
else
{
m_RColors = (SGCOLORS*)aNode;
m_RColors->addNodeRef( this );
}
return true;
}
if( S3D::SGTYPE_COORDS == aNode->GetNodeType() )
{
if( m_Coords || m_RCoords )
{
if( aNode != m_Coords && aNode != m_RCoords )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] assigning multiple Colors nodes" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
return true;
}
if( isChild )
{
m_Coords = (SGCOORDS*)aNode;
m_Coords->SetParent( this );
}
else
{
m_RCoords = (SGCOORDS*)aNode;
m_RCoords->addNodeRef( this );
}
return true;
}
if( S3D::SGTYPE_NORMALS == aNode->GetNodeType() )
{
if( m_Normals || m_RNormals )
{
if( aNode != m_Normals && aNode != m_RNormals )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] assigning multiple Normals nodes" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
return true;
}
if( isChild )
{
m_Normals = (SGNORMALS*)aNode;
m_Normals->SetParent( this );
}
else
{
m_RNormals = (SGNORMALS*)aNode;
m_RNormals->addNodeRef( this );
}
return true;
}
if( S3D::SGTYPE_COORDINDEX == aNode->GetNodeType() )
{
if( m_CoordIndices )
{
if( aNode != m_CoordIndices )
{
wxLogTrace( MASK_3D_SG,
wxT( "%s:%s:%d * [BUG] assigning multiple CoordIndex nodes" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
return true;
}
m_CoordIndices = (SGCOORDINDEX*)aNode;
m_CoordIndices->SetParent( this );
return true;
}
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] object type '%s' is not a valid type for "
"this object '%d'" ),
__FILE__, __FUNCTION__, __LINE__,
aNode->GetName(),
aNode->GetNodeType() );
return false;
}
bool SGFACESET::AddRefNode( SGNODE* aNode )
{
return addNode( aNode, false );
}
bool SGFACESET::AddChildNode( SGNODE* aNode )
{
return addNode( aNode, true );
}
void SGFACESET::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
// rename all Colors and Indices
if( m_Colors )
m_Colors->ReNameNodes();
// rename all Coordinates and Indices
if( m_Coords )
m_Coords->ReNameNodes();
if( m_CoordIndices )
m_CoordIndices->ReNameNodes();
// rename all Normals and Indices
if( m_Normals )
m_Normals->ReNameNodes();
}
bool SGFACESET::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( ( nullptr == m_Coords && nullptr == m_RCoords ) || ( nullptr == m_CoordIndices ) )
{
return false;
}
if( aReuseFlag )
{
if( !m_written )
{
aFile << " geometry DEF " << GetName() << " IndexedFaceSet {\n";
m_written = true;
}
else
{
aFile << "USE " << GetName() << "\n";
return true;
}
}
else
{
aFile << " geometry IndexedFaceSet {\n";
}
if( m_Coords )
m_Coords->WriteVRML( aFile, aReuseFlag );
if( m_RCoords )
m_RCoords->WriteVRML( aFile, aReuseFlag );
if( m_CoordIndices )
m_CoordIndices->WriteVRML( aFile, aReuseFlag );
if( m_Normals || m_RNormals )
aFile << " normalPerVertex TRUE\n";
if( m_Normals )
m_Normals->WriteVRML( aFile, aReuseFlag );
if( m_RNormals )
m_RNormals->WriteVRML( aFile, aReuseFlag );
if( m_Colors )
m_Colors->WriteVRML( aFile, aReuseFlag );
if( m_RColors )
m_RColors->WriteVRML( aFile, aReuseFlag );
aFile << "}\n";
return true;
}
bool SGFACESET::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode )
{
wxCHECK( m_Parent, false );
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK( parentNode == m_Parent, false );
if( !aFile.good() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
// check if any references are unwritten and swap parents if so
if( nullptr != m_RCoords && !m_RCoords->isWritten() )
m_RCoords->SwapParent( this );
if( nullptr != m_RNormals && !m_RNormals->isWritten() )
m_RNormals->SwapParent( this );
if( nullptr != m_RColors && !m_RColors->isWritten() )
m_RColors->SwapParent( this );
aFile << "[" << GetName() << "]";
#define NITEMS 7
bool items[NITEMS];
int i;
for( i = 0; i < NITEMS; ++i )
items[i] = 0;
i = 0;
if( nullptr != m_Coords )
items[i] = true;
++i;
if( nullptr != m_RCoords )
items[i] = true;
++i;
if( nullptr != m_CoordIndices )
items[i] = true;
++i;
if( nullptr != m_Normals )
items[i] = true;
++i;
if( nullptr != m_RNormals )
items[i] = true;
++i;
if( nullptr != m_Colors )
items[i] = true;
++i;
if( nullptr != m_RColors )
items[i] = true;
for( int jj = 0; jj < NITEMS; ++jj )
aFile.write( (char*) &items[jj], sizeof( bool ) );
if( items[0] )
m_Coords->WriteCache( aFile, this );
if( items[1] )
aFile << "[" << m_RCoords->GetName() << "]";
if( items[2] )
m_CoordIndices->WriteCache( aFile, this );
if( items[3] )
m_Normals->WriteCache( aFile, this );
if( items[4] )
aFile << "[" << m_RNormals->GetName() << "]";
if( items[5] )
m_Colors->WriteCache( aFile, this );
if( items[6] )
aFile << "[" << m_RColors->GetName() << "]";
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SGFACESET::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
if( m_Coords || m_RCoords || m_CoordIndices || m_Colors || m_RColors || m_Normals
|| m_RNormals )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] non-empty node" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
#define NITEMS 7
bool items[NITEMS];
for( int i = 0; i < NITEMS; ++i )
aFile.read( (char*) &items[i], sizeof( bool ) );
if( ( items[0] && items[1] ) || ( items[3] && items[4] ) || ( items[5] && items[6] ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; multiple item definitions "
"at position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
std::string name;
if( items[0] )
{
if( S3D::SGTYPE_COORDS != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child coords tag at "
"position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
m_Coords = new SGCOORDS( this );
m_Coords->SetName( name.c_str() );
if( !m_Coords->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; corrupt data while "
"reading coords '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
}
if( items[1] )
{
if( S3D::SGTYPE_COORDS != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref coords tag at "
"position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
SGNODE* np = FindNode( name.c_str(), this );
if( !np )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; cannot find ref "
"coords '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
if( S3D::SGTYPE_COORDS != np->GetNodeType() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; type is not SGCOORDS "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
m_RCoords = (SGCOORDS*)np;
m_RCoords->addNodeRef( this );
}
if( items[2] )
{
if( S3D::SGTYPE_COORDINDEX != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad coord index tag at "
"position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
m_CoordIndices = new SGCOORDINDEX( this );
m_CoordIndices->SetName( name.c_str() );
if( !m_CoordIndices->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data while reading coord "
"index '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
}
if( items[3] )
{
if( S3D::SGTYPE_NORMALS != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child normals tag "
"at position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
m_Normals = new SGNORMALS( this );
m_Normals->SetName( name.c_str() );
if( !m_Normals->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data while reading normals "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
}
if( items[4] )
{
if( S3D::SGTYPE_NORMALS != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref normals tag at "
"position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
SGNODE* np = FindNode( name.c_str(), this );
if( !np )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt: cannot find ref normals "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
if( S3D::SGTYPE_NORMALS != np->GetNodeType() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt: type is not SGNORMALS '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
m_RNormals = (SGNORMALS*)np;
m_RNormals->addNodeRef( this );
}
if( items[5] )
{
if( S3D::SGTYPE_COLORS != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child colors tag "
"at position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
m_Colors = new SGCOLORS( this );
m_Colors->SetName( name.c_str() );
if( !m_Colors->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data while reading colors "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
}
if( items[6] )
{
if( S3D::SGTYPE_COLORS != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref colors tag at "
"position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return false;
}
SGNODE* np = FindNode( name.c_str(), this );
if( !np )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: cannot find ref colors "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
if( S3D::SGTYPE_COLORS != np->GetNodeType() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: type is not SGCOLORS "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
m_RColors = (SGCOLORS*)np;
m_RColors->addNodeRef( this );
}
if( aFile.fail() )
return false;
return true;
}
bool SGFACESET::validate( void )
{
// verify the integrity of this object's data
if( validated )
return valid;
// ensure we have at least coordinates and their normals
if( ( nullptr == m_Coords && nullptr == m_RCoords )
|| ( nullptr == m_Normals && nullptr == m_RNormals )
|| ( nullptr == m_CoordIndices ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; no vertices, vertex indices, "
"or normals" ),
__FILE__, __FUNCTION__, __LINE__ );
validated = true;
valid = false;
return false;
}
// check that there are >3 vertices
SGCOORDS* coords = m_Coords;
if( nullptr == coords )
coords = m_RCoords;
size_t nCoords = 0;
SGPOINT* lCoords = nullptr;
coords->GetCoordsList( nCoords, lCoords );
if( nCoords < 3 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; fewer than 3 vertices" ),
__FILE__, __FUNCTION__, __LINE__ );
validated = true;
valid = false;
return false;
}
// check that nVertices is divisible by 3 (facets are triangles)
size_t nCIdx = 0;
int* lCIdx = nullptr;
m_CoordIndices->GetIndices( nCIdx, lCIdx );
if( nCIdx < 3 || ( nCIdx % 3 > 0 ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; no vertex indices or not "
"multiple of 3" ),
__FILE__, __FUNCTION__, __LINE__ );
validated = true;
valid = false;
return false;
}
// check that vertex[n] >= 0 and < nVertices
for( size_t i = 0; i < nCIdx; ++i )
{
if( lCIdx[i] < 0 || lCIdx[i] >= (int)nCoords )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; vertex index out of "
"bounds" ),
__FILE__, __FUNCTION__, __LINE__ );
validated = true;
valid = false;
return false;
}
}
// check that there are as many normals as vertices
size_t nNorms = 0;
SGVECTOR* lNorms = nullptr;
SGNORMALS* pNorms = m_Normals;
if( nullptr == pNorms )
pNorms = m_RNormals;
pNorms->GetNormalList( nNorms, lNorms );
if( nNorms != nCoords )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; number of normals (%ul) does "
"not match number of vertices (%ul)" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( nNorms ),
static_cast<unsigned long>( nCoords ) );
validated = true;
valid = false;
return false;
}
// if there are colors then ensure there are as many colors as vertices
SGCOLORS* pColors = m_Colors;
if( nullptr == pColors )
pColors = m_RColors;
if( nullptr != pColors )
{
// we must have at least as many colors as vertices
size_t nColor = 0;
SGCOLOR* pColor = nullptr;
pColors->GetColorList( nColor, pColor );
}
validated = true;
valid = true;
return true;
}
void SGFACESET::GatherCoordIndices( std::vector< int >& aIndexList )
{
if( m_CoordIndices )
m_CoordIndices->GatherCoordIndices( aIndexList );
}
bool SGFACESET::CalcNormals( SGNODE** aPtr )
{
SGCOORDS* coords = m_Coords;
if( m_RCoords )
coords = m_RCoords;
if( nullptr == coords || coords->coords.empty() )
return false;
if( m_Normals && !m_Normals->norms.empty( ) )
return true;
if( m_RNormals && !m_RNormals->norms.empty( ) )
return true;
return coords->CalcNormals( this, aPtr );
}
-117
View File
@@ -1,117 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_faceset.h
*/
#ifndef SG_FACESET_H
#define SG_FACESET_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGCOLORS;
class SGCOORDS;
class SGNORMALS;
class SGCOLORINDEX;
class SGCOORDINDEX;
/**
* Define an indexed face set for a scenegraph.
*/
class SGFACESET : public SGNODE
{
public:
SGFACESET( SGNODE* aParent );
virtual ~SGFACESET();
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
SGNODE* FindNode( const char* aNodeName, const SGNODE* aCaller ) override;
bool AddRefNode( SGNODE* aNode ) override;
bool AddChildNode( SGNODE* aNode ) override;
bool CalcNormals( SGNODE** aPtr );
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
/**
* Add all internal coordinate indices to the given list in preparation for a normals
* calculation.
*/
void GatherCoordIndices( std::vector< int >& aIndexList );
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
// validate the data held by this face set
bool validate( void );
// owned objects
SGCOLORS* m_Colors;
SGCOORDS* m_Coords;
SGCOORDINDEX* m_CoordIndices;
SGNORMALS* m_Normals;
// referenced objects
SGCOLORS* m_RColors;
SGCOORDS* m_RCoords;
SGNORMALS* m_RNormals;
private:
bool valid;
bool validated;
void unlinkNode( const SGNODE* aNode, bool isChild );
bool addNode( SGNODE* aNode, bool isChild );
};
/*
p.88
IndexedFaceSet {
color NULL
coord NULL
normal NULL
texCoord NULL
ccw TRUE
colorIndex []
colorPerVertex TRUE
convex TRUE
coordIndex []
creaseAngle 0
normalIndex []
normalPerVertex TRUE
solid TRUE
texCoordIndex []
}
*/
#endif // SG_FACESET_H
-490
View File
@@ -1,490 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <utility>
#include <wx/log.h>
#include "3d_cache/sg/sg_helpers.h"
#include "3d_cache/sg/sg_node.h"
void S3D::FormatFloat( std::string& result, double value )
{
if( value < 1e-8 && value > -1e-8 )
{
result = "0";
return;
}
// note: many VRML implementations use float so we use the max.
// precision here of 8 digits.
std::ostringstream out;
out << std::setprecision( 8 ) << value;
result = out.str();
size_t p = result.find( '.' );
// trim trailing 0 if appropriate
if( std::string::npos == p )
return;
p = result.find_first_of( "eE" );
if( std::string::npos == p )
{
while( '0' == *( result.rbegin() ) )
result.erase( result.size() - 1 );
return;
}
if( '0' != result.at( p - 1 ) )
return;
// trim all 0 to the left of 'p'
std::string tmp = result.substr( p );
result = result.substr( 0, p );
while( '0' == *( result.rbegin() ) )
result.erase( result.size() - 1 );
result.append( tmp );
}
void S3D::FormatOrientation( std::string& result, const SGVECTOR& axis, double rotation )
{
double aX;
double aY;
double aZ;
axis.GetVector( aX, aY, aZ );
FormatFloat( result, aX );
std::string tmp;
FormatFloat( tmp, aY );
result.append( " " );
result.append( tmp );
FormatFloat( tmp, aZ );
result.append( " " );
result.append( tmp );
FormatFloat( tmp, rotation );
result.append( " " );
result.append( tmp );
}
void S3D::FormatPoint( std::string& result, const SGPOINT& point )
{
FormatFloat( result, point.x );
std::string tmp;
FormatFloat( tmp, point.y );
result.append( " " );
result.append( tmp );
FormatFloat( tmp, point.z );
result.append( " " );
result.append( tmp );
}
void S3D::FormatVector( std::string& result, const SGVECTOR& aVector )
{
double X, Y, Z;
aVector.GetVector( X, Y, Z );
FormatFloat( result, X );
std::string tmp;
FormatFloat( tmp, Y );
result.append( " " );
result.append( tmp );
FormatFloat( tmp, Z );
result.append( " " );
result.append( tmp );
}
void S3D::FormatColor( std::string& result, const SGCOLOR& aColor )
{
float R, G, B;
aColor.GetColor( R, G, B );
FormatFloat( result, R );
std::string tmp;
FormatFloat( tmp, G );
result.append( " " );
result.append( tmp );
FormatFloat( tmp, B );
result.append( " " );
result.append( tmp );
}
bool S3D::WritePoint( std::ostream& aFile, const SGPOINT& aPoint )
{
aFile.write( (char*) &aPoint.x, sizeof( aPoint.x ) );
aFile.write( (char*) &aPoint.y, sizeof( aPoint.y ) );
aFile.write( (char*) &aPoint.z, sizeof( aPoint.z ) );
if( aFile.fail() )
return false;
return true;
}
bool S3D::WriteVector( std::ostream& aFile, const SGVECTOR& aVector )
{
double x, y, z;
aVector.GetVector( x, y, z );
aFile.write( (char*) &x, sizeof( double ) );
aFile.write( (char*) &y, sizeof( double ) );
aFile.write( (char*) &z, sizeof( double ) );
if( aFile.fail() )
return false;
return true;
}
bool S3D::WriteColor( std::ostream& aFile, const SGCOLOR& aColor )
{
float r, g, b;
aColor.GetColor( r, g, b );
aFile.write( (char*) &r, sizeof( float ) );
aFile.write( (char*) &g, sizeof( float ) );
aFile.write( (char*) &b, sizeof( float ) );
if( aFile.fail() )
return false;
return true;
}
S3D::SGTYPES S3D::ReadTag( std::istream& aFile, std::string& aName )
{
char schar;
aFile.get( schar );
if( '[' != schar )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; missing left bracket at "
"position %d" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<int>( aFile.tellg() ) );
return S3D::SGTYPE_END;
}
std::string name;
aFile.get( schar );
while( ']' != schar && aFile.good() )
{
name.push_back( schar );
aFile.get( schar );
}
if( schar != ']' )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; could not find right "
"bracket" ),
__FILE__, __FUNCTION__, __LINE__ );
return S3D::SGTYPE_END;
}
aName = name;
size_t upos = name.find( '_' );
if( std::string::npos == upos )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; no underscore in name '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return S3D::SGTYPE_END;
}
name = name.substr( 0, upos );
S3D::SGTYPES types[S3D::SGTYPE_END] = {
SGTYPE_TRANSFORM,
SGTYPE_APPEARANCE,
SGTYPE_COLORS,
SGTYPE_COLORINDEX,
SGTYPE_FACESET,
SGTYPE_COORDS,
SGTYPE_COORDINDEX,
SGTYPE_NORMALS,
SGTYPE_SHAPE
};
for( int i = 0; i < S3D::SGTYPE_END; ++i )
{
if( !name.compare( S3D::GetNodeTypeName( types[i] ) ) )
return types[i];
}
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; no node type matching '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return S3D::SGTYPE_END;
}
bool S3D::ReadPoint( std::istream& aFile, SGPOINT& aPoint )
{
aFile.read( (char*) &aPoint.x, sizeof( aPoint.x ) );
aFile.read( (char*) &aPoint.y, sizeof( aPoint.y ) );
aFile.read( (char*) &aPoint.z, sizeof( aPoint.z ) );
if( aFile.fail() )
return false;
return true;
}
bool S3D::ReadVector( std::istream& aFile, SGVECTOR& aVector )
{
double x, y, z;
aFile.read( (char*) &x, sizeof( double ) );
aFile.read( (char*) &y, sizeof( double ) );
aFile.read( (char*) &z, sizeof( double ) );
aVector.SetVector( x, y, z );
if( aFile.fail() )
return false;
return true;
}
bool S3D::ReadColor( std::istream& aFile, SGCOLOR& aColor )
{
float r, g, b;
aFile.read( (char*) &r, sizeof( float ) );
aFile.read( (char*) &g, sizeof( float ) );
aFile.read( (char*) &b, sizeof( float ) );
aColor.SetColor( r, g, b );
if( aFile.fail() )
return false;
return true;
}
bool S3D::degenerate( glm::dvec3* pts ) noexcept
{
double dx, dy, dz;
dx = pts[1].x - pts[0].x;
dy = pts[1].y - pts[0].y;
dz = pts[1].z - pts[0].z;
if( ( dx*dx + dy*dy + dz*dz ) < 1e-15 )
return true;
dx = pts[2].x - pts[0].x;
dy = pts[2].y - pts[0].y;
dz = pts[2].z - pts[0].z;
if( ( dx*dx + dy*dy + dz*dz ) < 1e-15 )
return true;
dx = pts[2].x - pts[1].x;
dy = pts[2].y - pts[1].y;
dz = pts[2].z - pts[1].z;
if( ( dx*dx + dy*dy + dz*dz ) < 1e-15 )
return true;
return false;
}
static void calcTriad( glm::dvec3* pts, glm::dvec3& tri )
{
if( S3D::degenerate( pts ) )
{
// degenerate points should contribute nothing to the result
tri = glm::dvec3( 0.0, 0.0, 0.0 );
return;
}
// normal * 2 * area
tri = glm::cross( pts[1] - pts[0], pts[2] - pts[0] );
}
bool S3D::CalcTriangleNormals( std::vector< SGPOINT > coords, std::vector< int >& index,
std::vector< SGVECTOR >& norms )
{
size_t vsize = coords.size();
if( vsize < 3 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] invalid vertex set (fewer than 3 "
"vertices)" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
size_t isize = index.size();
if( 0 != isize % 3 || index.empty() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] invalid index set (not multiple of 3)" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
if( !norms.empty() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] normals set is not empty" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
std::map< int, std::list< glm::dvec3 > >vmap;
int p1, p2, p3;
// create the map of indices to facet sets
for( size_t i = 0; i < isize; )
{
p1 = index[i++];
p2 = index[i++];
p3 = index[i++];
if( p1 < 0 || p1 >= (int)vsize || p2 < 0 || p2 >= (int)vsize || p3 < 0 || p3 >= (int)vsize )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] invalid index set; index out of bounds";
wxLogTrace( MASK_3D_SG, wxT( "%s\n" ), ostr.str().c_str() );
#endif
return false;
}
glm::dvec3 tri;
glm::dvec3 trip[3];
trip[0] = glm::dvec3( coords[p1].x, coords[p1].y, coords[p1].z );
trip[1] = glm::dvec3( coords[p2].x, coords[p2].y, coords[p2].z );
trip[2] = glm::dvec3( coords[p3].x, coords[p3].y, coords[p3].z );
calcTriad( trip, tri );
std::map< int, std::list< glm::dvec3 > >::iterator ip = vmap.find( p1 );
if( ip != vmap.end() )
{
ip->second.push_back( tri );
}
else
{
vmap.emplace( p1, std::list < glm::dvec3 >( 1, tri ) );
}
ip = vmap.find( p2 );
if( ip != vmap.end() )
{
ip->second.push_back( tri );
}
else
{
vmap.emplace( p2, std::list < glm::dvec3 >( 1, tri ) );
}
ip = vmap.find( p3 );
if( ip != vmap.end() )
{
ip->second.push_back( tri );
}
else
{
vmap.emplace( p3, std::list < glm::dvec3 >( 1, tri ) );
}
}
std::map< int, std::list< glm::dvec3 > >::iterator sM = vmap.begin();
std::map< int, std::list< glm::dvec3 > >::iterator eM = vmap.end();
size_t idx = 0;
while( sM != eM )
{
size_t item = sM->first;
// assign any skipped coordinates a normal of (0,0,1)
while( item > idx )
{
norms.emplace_back( 0, 0, 1 );
++idx;
}
std::list< glm::dvec3 >::iterator sT = sM->second.begin();
std::list< glm::dvec3 >::iterator eT = sM->second.end();
glm::dvec3 norm( 0.0, 0.0, 0.0 );
while( sT != eT )
{
norm += *sT;
++sT;
}
norms.emplace_back( norm.x, norm.y, norm.z );
++idx;
++sM;
}
if( norms.size() != coords.size() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] number of normals does not equal number "
"of vertices" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
return true;
}
-273
View File
@@ -1,273 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_helpers.h
*
* Define a number of macros to aid in repetitious code which is probably best expressed
* as a preprocessor macro rather than as a template. This header also declares a number
* of functions which are only of use within the sg_* classes.
*/
#ifndef SG_HELPERS_H
#define SG_HELPERS_H
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include "plugins/3dapi/sg_base.h"
#include "plugins/3dapi/sg_types.h"
#include <glm/glm.hpp>
class SGNORMALS;
class SGCOORDS;
class SGCOORDINDEX;
// Function to drop references within an SGNODE
// The node being destroyed must remove itself from the object reference's
// backpointer list in order to avoid a segfault.
#define DROP_REFS( aType, aList ) \
do \
{ \
std::vector<aType*>::iterator sL = aList.begin(); \
std::vector<aType*>::iterator eL = aList.end(); \
while( sL != eL ) \
{ \
( (SGNODE*) *sL )->delNodeRef( this ); \
++sL; \
} \
aList.clear(); \
} while( 0 )
// Function to delete owned objects within an SGNODE
// The owned object's parent is set to NULL before
// deletion to avoid a redundant 'unlinkChildNode' call.
#define DEL_OBJS( aType, aList ) \
do \
{ \
std::vector<aType*>::iterator sL = aList.begin(); \
std::vector<aType*>::iterator eL = aList.end(); \
while( sL != eL ) \
{ \
( (SGNODE*) *sL )->SetParent( nullptr, false ); \
delete *sL; \
++sL; \
} \
aList.clear(); \
} while( 0 )
// Function to unlink a child or reference node when that child or
// reference node is being destroyed.
#define UNLINK_NODE( aNodeID, aType, aNode, aOwnedList, aRefList, isChild ) \
do \
{ \
if( aNodeID == aNode->GetNodeType() ) \
{ \
std::vector<aType*>* oSL; \
std::vector<aType*>::iterator sL; \
std::vector<aType*>::iterator eL; \
if( isChild ) \
{ \
oSL = &aOwnedList; \
sL = oSL->begin(); \
eL = oSL->end(); \
while( sL != eL ) \
{ \
if( (SGNODE*) *sL == aNode ) \
{ \
oSL->erase( sL ); \
return; \
} \
++sL; \
} \
} \
else \
{ \
oSL = &aRefList; \
sL = oSL->begin(); \
eL = oSL->end(); \
while( sL != eL ) \
{ \
if( (SGNODE*) *sL == aNode ) \
{ \
delNodeRef( this ); \
oSL->erase( sL ); \
return; \
} \
++sL; \
} \
} \
return; \
} \
} while( 0 )
// Function to check a node type, check for an existing reference,
// and add the node type to the reference list if applicable
#define ADD_NODE( aNodeID, aType, aNode, aOwnedList, aRefList, isChild ) \
do \
{ \
if( aNodeID == aNode->GetNodeType() ) \
{ \
std::vector<aType*>::iterator sL; \
sL = std::find( aOwnedList.begin(), aOwnedList.end(), aNode ); \
if( sL != aOwnedList.end() ) \
return true; \
sL = std::find( aRefList.begin(), aRefList.end(), aNode ); \
if( sL != aRefList.end() ) \
return true; \
if( isChild ) \
{ \
SGNODE* ppn = (SGNODE*) aNode->GetParent(); \
if( nullptr != ppn ) \
{ \
if( this != ppn ) \
{ \
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; \
std::cerr << " * [BUG] object '" << aNode->GetName(); \
std::cerr << "' has multiple parents '" << ppn->GetName() << "', '"; \
std::cerr << m_Name << "'\n"; \
return false; \
} \
} \
aOwnedList.push_back( (aType*) aNode ); \
aNode->SetParent( this, false ); \
} \
else \
{ \
/*if( nullptr == aNode->GetParent() ) { \
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; \
std::cerr << " * [BUG] object '" << aNode->GetName(); \
std::cerr << "' has no parent\n"; \
std::cerr << " * [INFO] possible copy assignment or copy constructor bug\n"; \
return false; \
} */ \
aRefList.push_back( (aType*) aNode ); \
aNode->addNodeRef( this ); \
} \
return true; \
} \
} while( 0 )
// Function to find a node object given a (non-unique) node name
#define FIND_NODE( aType, aName, aNodeList, aCallingNode ) \
do \
{ \
std::vector<aType*>::iterator sLA = aNodeList.begin(); \
std::vector<aType*>::iterator eLA = aNodeList.end(); \
SGNODE* psg = nullptr; \
while( sLA != eLA ) \
{ \
if( (SGNODE*) *sLA != aCallingNode ) \
{ \
psg = (SGNODE*) ( *sLA )->FindNode( aName, this ); \
if( nullptr != psg ) \
return psg; \
} \
++sLA; \
} \
} while( 0 )
namespace S3D
{
bool degenerate( glm::dvec3* pts ) noexcept;
//
// Normals calculations from triangles
//
/*
* Take an array of 3D coordinates and its corresponding index set and calculates
* the normals assuming that indices are given in CCW order.
*
* Care must be taken in using this function to ensure that:
* -# All coordinates are indexed; unindexed coordinates are assigned normal(0,0,1);
* when dealing with VRML models which may list and reuse one large coordinate set it
* is necessary to gather all index sets and perform this operation only once.
* -# Index sets must represent triangles (multiple of 3 indices) and must not be
* degenerate, that is all indices and coordinates in a triad must be unique.
*
* @param coords is the array of 3D vertices.
* @param index is the array of 3x vertex indices (triads).
* @param norms is an empty array which holds the normals corresponding to each vector.
* @return true on success; otherwise false.
*/
bool CalcTriangleNormals( std::vector< SGPOINT > coords, std::vector< int >& index,
std::vector< SGVECTOR >& norms );
// formats a floating point number for text output to a VRML file
void FormatFloat( std::string& result, double value );
// format orientation data for VRML output
void FormatOrientation( std::string& result, const SGVECTOR& axis, double rotation );
// format point data for VRML output
void FormatPoint( std::string& result, const SGPOINT& point );
// format vector data for VRML output
void FormatVector( std::string& result, const SGVECTOR& aVector );
// format Color data for VRML output
void FormatColor( std::string& result, const SGCOLOR& aColor );
//
// Cache related WRITE functions
//
// write out an XYZ vertex
bool WritePoint( std::ostream& aFile, const SGPOINT& aPoint );
// write out a unit vector
bool WriteVector( std::ostream& aFile, const SGVECTOR& aVector );
// write out an RGB color
bool WriteColor( std::ostream& aFile, const SGCOLOR& aColor );
/**
* Read the text tag of a binary cache file which is the NodeTag and unique ID number combined.
*
* @param aFile is a binary file open for reading.
* @param aName will hold the tag name on successful return.
* @return will be the NodeType which the tag represents or S3D::SGTYPES::SGTYPE_END on
* failure.
*/
S3D::SGTYPES ReadTag( std::istream& aFile, std::string& aName );
// read an XYZ vertex
bool ReadPoint( std::istream& aFile, SGPOINT& aPoint );
// read a unit vector
bool ReadVector( std::istream& aFile, SGVECTOR& aVector );
// read an RGB color
bool ReadColor( std::istream& aFile, SGCOLOR& aColor );
}
#endif // SG_HELPERS_H
-329
View File
@@ -1,329 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_index.h"
SGINDEX::SGINDEX( SGNODE* aParent ) : SGNODE( aParent )
{
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] inappropriate parent to SGINDEX (type "
"'%d')" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeType() );
}
}
SGINDEX::~SGINDEX()
{
index.clear();
}
bool SGINDEX::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a SGFACESET may be parent to a SGINDEX and derived types
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
SGNODE* SGINDEX::FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
return nullptr;
}
void SGINDEX::unlinkChildNode( const SGNODE* aCaller ) noexcept
{
// Node should have no children or refs.
wxCHECK( false, /* void */ );
}
void SGINDEX::unlinkRefNode( const SGNODE* aCaller ) noexcept
{
// Node should have no children or refs.
wxCHECK( false, /* void */ );
}
bool SGINDEX::AddRefNode( SGNODE* aNode ) noexcept
{
// Node should have no children or refs.
wxCHECK( false, false );
return false;
}
bool SGINDEX::AddChildNode( SGNODE* aNode ) noexcept
{
// Node should have no children or refs.
wxCHECK( false, false );
return false;
}
bool SGINDEX::GetIndices( size_t& nIndices, int*& aIndexList )
{
if( index.empty() )
{
nIndices = 0;
aIndexList = nullptr;
return false;
}
nIndices = index.size();
aIndexList = & index[0];
return true;
}
void SGINDEX::SetIndices( size_t nIndices, int* aIndexList )
{
index.clear();
if( 0 == nIndices || nullptr == aIndexList )
return;
for( size_t i = 0; i < nIndices; ++i )
index.push_back( aIndexList[i] );
return;
}
void SGINDEX::AddIndex( int aIndex )
{
index.push_back( aIndex );
}
void SGINDEX::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
}
bool SGINDEX::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( index.empty() )
return false;
if( S3D::SGTYPE_COORDINDEX == m_SGtype )
return writeCoordIndex( aFile );
return writeColorIndex( aFile );
}
bool SGINDEX::writeCoordIndex( std::ostream& aFile )
{
size_t n = index.size();
wxCHECK_MSG( n % 3 == 0, false, wxT( "Coordinate index is not divisible by three (violates "
"triangle constraint)" ) );
aFile << " coordIndex [\n ";
// indices to control formatting
int nv0 = 0;
int nv1 = 0;
for( size_t i = 0; i < n; )
{
aFile << index[i];
++i;
if( ++nv0 == 3 )
{
aFile << ",-1";
++nv1;
nv0 = 0;
}
if( i < n )
{
aFile << ",";
if( nv1 == 8 )
{
nv1 = 0;
aFile << "\n ";
}
}
}
aFile << "]\n";
return true;
}
bool SGINDEX::writeColorIndex( std::ostream& aFile )
{
aFile << " colorIndex [\n ";
return writeIndexList( aFile );
}
bool SGINDEX::writeIndexList( std::ostream& aFile )
{
// index to control formatting
int nv = 0;
size_t n = index.size();
for( size_t i = 0; i < n; )
{
aFile << index[i];
++i;
if( i < n )
{
aFile << ",";
if( ++nv == 20 )
{
aFile << "\n ";
nv = 0;
}
}
}
aFile << "]\n";
return true;
}
bool SGINDEX::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode )
{
wxCHECK( m_Parent, false );
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK( parentNode == m_Parent, false );
if( !aFile.good() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
aFile << "[" << GetName() << "]";
size_t npts = index.size();
aFile.write( (char*)&npts, sizeof(size_t) );
for( size_t i = 0; i < npts; ++i )
aFile.write( (char*)&index[i], sizeof(int) );
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SGINDEX::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
wxCHECK( index.empty(), false );
size_t npts;
aFile.read( (char*)&npts, sizeof(size_t) );
int tmp;
if( aFile.fail() )
return false;
for( size_t i = 0; i < npts; ++i )
{
aFile.read( (char*) &tmp, sizeof( int ) );
if( aFile.fail() )
return false;
index.push_back( tmp );
}
return true;
}
-98
View File
@@ -1,98 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_index.h
*/
#ifndef SG_INDEX_H
#define SG_INDEX_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
/**
* Define a generic index interface for a scenegraph object.
*/
class SGINDEX : public SGNODE
{
public:
SGINDEX( SGNODE* aParent );
virtual ~SGINDEX();
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
SGNODE* FindNode(const char* aNodeName, const SGNODE* aCaller) noexcept override;
bool AddRefNode( SGNODE* aNode ) noexcept override;
bool AddChildNode( SGNODE* aNode ) noexcept override;
void unlinkChildNode( const SGNODE* aCaller ) noexcept override;
void unlinkRefNode( const SGNODE* aCaller ) noexcept override;
/**
* Retrieve the number of indices and a pointer to the list.
*
* @note The returned pointer may be invalidated by future operations on the SGNODE. The
* caller must make immediate use of the data and must not rely on the pointer's
* validity in the future.
*
* @param nIndices will hold the number of indices in the list.
* @param aIndexList will store a pointer to the data.
* @return true if there was available data (nIndices > 0) otherwise false.
*/
bool GetIndices( size_t& nIndices, int*& aIndexList );
/**
* Set the number of indices and creates a copy of the given index data.
*
* @param nIndices the number of indices to be stored.
* @param aIndexList the index data.
*/
void SetIndices( size_t nIndices, int* aIndexList );
/**
* Add a single index to the list.
*
* @param aIndex is the index to add.
*/
void AddIndex( int aIndex );
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
protected:
bool writeCoordIndex( std::ostream& aFile );
bool writeColorIndex( std::ostream& aFile );
bool writeIndexList( std::ostream& aFile );
public:
// for internal SG consumption only
std::vector< int > index;
};
#endif // SG_INDEX_H
-346
View File
@@ -1,346 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_node.h"
#include "plugins/3dapi/c3dmodel.h"
static const std::string node_names[S3D::SGTYPE_END + 1] = {
"TXFM",
"APP",
"COL",
"COLIDX",
"FACE",
"COORD",
"COORDIDX",
"NORM",
"SHAPE",
"INVALID"
};
static unsigned int node_counts[S3D::SGTYPE_END] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
char const* S3D::GetNodeTypeName( S3D::SGTYPES aType ) noexcept
{
return node_names[aType].c_str();
}
static void getNodeName( S3D::SGTYPES nodeType, std::string& aName )
{
if( nodeType < 0 || nodeType >= S3D::SGTYPE_END )
{
aName = node_names[S3D::SGTYPE_END];
return;
}
unsigned int seqNum = node_counts[nodeType];
++node_counts[nodeType];
std::ostringstream ostr;
ostr << node_names[nodeType] << "_" << seqNum;
aName = ostr.str();
}
SGNODE::SGNODE( SGNODE* aParent )
{
m_Parent = aParent;
m_Association = nullptr;
m_written = false;
m_SGtype = S3D::SGTYPE_END;
}
SGNODE::~SGNODE()
{
if( m_Parent )
m_Parent->unlinkChildNode( this );
if( m_Association )
*m_Association = nullptr;
std::list< SGNODE* >::iterator sBP = m_BackPointers.begin();
std::list< SGNODE* >::iterator eBP = m_BackPointers.end();
while( sBP != eBP )
{
(*sBP)->unlinkRefNode( this );
++sBP;
}
}
S3D::SGTYPES SGNODE::GetNodeType( void ) const noexcept
{
return m_SGtype;
}
SGNODE* SGNODE::GetParent( void ) const noexcept
{
return m_Parent;
}
bool SGNODE::SwapParent( SGNODE* aNewParent )
{
if( aNewParent == m_Parent )
return true;
if( nullptr == aNewParent )
return false;
if( nullptr == m_Parent )
{
if( aNewParent->AddChildNode( this ) )
return true;
return false;
}
if( aNewParent->GetNodeType() != m_Parent->GetNodeType() )
return false;
SGNODE* oldParent = m_Parent;
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
aNewParent->unlinkRefNode( this );
aNewParent->AddChildNode( this );
oldParent->AddRefNode( this );
return true;
}
const char* SGNODE::GetName( void )
{
if( m_Name.empty() )
getNodeName( m_SGtype, m_Name );
return m_Name.c_str();
}
void SGNODE::SetName( const char* aName )
{
if( nullptr == aName || 0 == aName[0] )
getNodeName( m_SGtype, m_Name );
else
m_Name = aName;
}
const char* SGNODE::GetNodeTypeName( S3D::SGTYPES aNodeType ) const noexcept
{
return node_names[aNodeType].c_str();
}
void SGNODE::addNodeRef( SGNODE* aNode )
{
if( nullptr == aNode )
return;
std::list< SGNODE* >::iterator np =
std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
if( np != m_BackPointers.end() )
return;
m_BackPointers.push_back( aNode );
}
void SGNODE::delNodeRef( const SGNODE* aNode )
{
if( nullptr == aNode )
return;
std::list< SGNODE* >::iterator np =
std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
if( np != m_BackPointers.end() )
{
m_BackPointers.erase( np );
return;
}
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] delNodeRef() did not find its target, this "
"node type %d, referenced node type %d" ),
__FILE__, __FUNCTION__, __LINE__,
m_SGtype,
aNode->GetNodeType() );
}
void SGNODE::AssociateWrapper( SGNODE** aWrapperRef ) noexcept
{
wxCHECK( aWrapperRef && *aWrapperRef == this, /* void */ );
// if there is an existing association then break it and emit a warning
// just in case the behavior is undesired
if( m_Association )
{
*m_Association = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [WARNING] association being broken with "
"previous wrapper" ),
__FILE__, __FUNCTION__, __LINE__ );
}
m_Association = aWrapperRef;
}
void SGNODE::DisassociateWrapper( SGNODE** aWrapperRef ) noexcept
{
if( !m_Association )
return;
wxCHECK( aWrapperRef, /* void */ );
wxCHECK( *aWrapperRef == *m_Association && aWrapperRef == m_Association, /* void */ );
m_Association = nullptr;
}
void SGNODE::ResetNodeIndex( void ) noexcept
{
for( int i = 0; i < (int)S3D::SGTYPE_END; ++i )
node_counts[i] = 1;
}
bool S3D::GetMatIndex( MATLIST& aList, SGNODE* aNode, int& aIndex )
{
aIndex = 0;
wxCHECK( aNode && S3D::SGTYPE_APPEARANCE == aNode->GetNodeType(), false );
SGAPPEARANCE* node = (SGAPPEARANCE*)aNode;
std::map< SGAPPEARANCE const*, int >::iterator it = aList.matmap.find( node );
if( it != aList.matmap.end() )
{
aIndex = it->second;
return true;
}
int idx = (int)aList.matorder.size();
aList.matorder.push_back( node );
aList.matmap.emplace( node, idx );
aIndex = idx;
return true;
}
void S3D::INIT_SMATERIAL( SMATERIAL& aMaterial )
{
aMaterial = {};
}
void S3D::INIT_SMESH( SMESH& aMesh ) noexcept
{
aMesh = {};
}
void S3D::INIT_S3DMODEL( S3DMODEL& aModel ) noexcept
{
aModel = {};
}
void S3D::FREE_SMESH( SMESH& aMesh ) noexcept
{
if( nullptr != aMesh.m_Positions )
{
delete [] aMesh.m_Positions;
aMesh.m_Positions = nullptr;
}
if( nullptr != aMesh.m_Normals )
{
delete [] aMesh.m_Normals;
aMesh.m_Normals = nullptr;
}
if( nullptr != aMesh.m_Texcoords )
{
delete [] aMesh.m_Texcoords;
aMesh.m_Texcoords = nullptr;
}
if( nullptr != aMesh.m_Color )
{
delete [] aMesh.m_Color;
aMesh.m_Color = nullptr;
}
if( nullptr != aMesh.m_FaceIdx )
{
delete [] aMesh.m_FaceIdx;
aMesh.m_FaceIdx = nullptr;
}
aMesh.m_VertexSize = 0;
aMesh.m_FaceIdxSize = 0;
aMesh.m_MaterialIdx = 0;
}
void S3D::FREE_S3DMODEL( S3DMODEL& aModel )
{
if( nullptr != aModel.m_Materials )
{
delete [] aModel.m_Materials;
aModel.m_Materials = nullptr;
}
aModel.m_MaterialsSize = 0;
if( nullptr != aModel.m_Meshes )
{
for( unsigned int i = 0; i < aModel.m_MeshesSize; ++i )
FREE_SMESH( aModel.m_Meshes[i] );
delete [] aModel.m_Meshes;
aModel.m_Meshes = nullptr;
}
aModel.m_MeshesSize = 0;
}
-236
View File
@@ -1,236 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_node.h
*/
#ifndef SG_NODE_H
#define SG_NODE_H
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <map>
#include <glm/glm.hpp>
#include "plugins/3dapi/c3dmodel.h"
#include "plugins/3dapi/sg_base.h"
#include "plugins/3dapi/sg_types.h"
class SGNODE;
class SGAPPEARANCE;
namespace S3D
{
/**
* Return the name of the given type of node
*/
char const* GetNodeTypeName( S3D::SGTYPES aType ) noexcept;
struct MATLIST
{
std::vector< SGAPPEARANCE const* > matorder; // materials in order of addition
std::map< SGAPPEARANCE const*, int > matmap; // mapping from material to index
};
bool GetMatIndex( MATLIST& aList, SGNODE* aNode, int& aIndex );
void INIT_SMATERIAL( SMATERIAL& aMaterial );
void INIT_SMESH( SMESH& aMesh ) noexcept;
void INIT_S3DMODEL( S3DMODEL& aModel ) noexcept;
void FREE_SMESH( SMESH& aMesh) noexcept;
void FREE_S3DMODEL( S3DMODEL& aModel );
}
/**
* The base class of all Scene Graph nodes.
*/
class SGNODE
{
public:
SGNODE( SGNODE* aParent );
virtual ~SGNODE();
/**
* Return the type of this node instance.
*/
S3D::SGTYPES GetNodeType( void ) const noexcept;
/**
* Returns a pointer to the parent SGNODE of this object or NULL if the object has
* no parent (ie. top level transform).
*/
SGNODE* GetParent( void ) const noexcept;
/**
* Set the parent #SGNODE of this object.
*
* @param aParent [in] is the desired parent node
* @return true if the operation succeeds; false if the given node is not allowed to
* be a parent to the derived object.
*/
virtual bool SetParent( SGNODE* aParent, bool notify = true ) = 0;
/**
* Swap the ownership with the given parent.
*
* This operation may be required when reordering nodes for optimization.
*
* @param aNewParent will become the new parent to the object; it must be the same type
* as the parent of this instance.
*/
bool SwapParent( SGNODE* aNewParent );
const char* GetName( void );
void SetName(const char *aName);
const char * GetNodeTypeName( S3D::SGTYPES aNodeType ) const noexcept;
/**
* Search the tree of linked nodes and return a reference to the first node found with
* the given name.
*
* The reference is then typically added to another node via AddRefNode().
*
* @param aNodeName is the name of the node to search for.
* @param aCaller is a pointer to the node invoking this function.
* @return is a valid node pointer on success, otherwise NULL.
*/
virtual SGNODE* FindNode( const char *aNodeName, const SGNODE *aCaller ) = 0;
virtual bool AddRefNode( SGNODE* aNode ) = 0;
virtual bool AddChildNode( SGNODE* aNode ) = 0;
/**
* Associate this object with a handle to itself.
*
* The handle is typically held by an IFSG* wrapper and the pointer which it refers to
* is set to NULL upon destruction of this object. This mechanism provides a scheme
* by which a wrapper can be notified of the destruction of the object which it wraps.
*/
void AssociateWrapper( SGNODE** aWrapperRef ) noexcept;
/**
* Remove the association between an IFSG* wrapper object and this object.
*/
void DisassociateWrapper( SGNODE** aWrapperRef ) noexcept;
/**
* Reset the global SG* node indices in preparation for write operations.
*/
void ResetNodeIndex( void ) noexcept;
/**
* Rename a node and all its child nodes in preparation for write operations.
*/
virtual void ReNameNodes( void ) = 0;
/**
* Writes this node's data to a VRML file.
*
* This includes all data of child and referenced nodes.
*/
virtual bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) = 0;
/**
* Write this node's data to a binary cache file.
*
* The data includes all data of children and references to children. If this function
* is invoked by the user, parentNode must be set to NULL in order to ensure coherent data.
*/
virtual bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) = 0;
/**
* Reads binary format data from a cache file.
*
* To read a cache file, open the file for reading and invoke this function from a new
* #SCENEGRAPH node.
*/
virtual bool ReadCache( std::istream& aFile, SGNODE* parentNode ) = 0;
/**
* Remove references to an owned child.
*
* This is invoked by the child upon destruction to ensure that the parent has no
* invalid references.
*
* @param aNode is the child which is being deleted.
*/
virtual void unlinkChildNode( const SGNODE* aNode ) = 0;
/**
* Remove pointers to a referenced node.
*
* This is invoked by the referenced node upon destruction to ensure that the referring
* node has no invalid references.
*
* @param aNode is the node which is being deleted.
*/
virtual void unlinkRefNode( const SGNODE* aNode ) = 0;
/**
* Add a pointer to a node which references this node, but does not own.
*
* Such back-pointers are required to ensure that invalidated references are removed
* when a node is deleted.
*
* @param aNode is the node holding a reference to this object.
*/
void addNodeRef( SGNODE* aNode );
/**
* Remove a pointer to a node which references this node, but does not own.
*
* @param aNode is the node holding a reference to this object.
*/
void delNodeRef( const SGNODE* aNode );
/**
* Return true if the object had already been written to a cache file or VRML file
*
* For internal use only.
*/
bool isWritten( void ) noexcept
{
return m_written;
}
protected:
std::list< SGNODE* > m_BackPointers; ///< nodes which hold a reference to this.
SGNODE* m_Parent; ///< Pointer to parent node; may be NULL for top level transform.
S3D::SGTYPES m_SGtype; ///< Type of Scene Graph node.
std::string m_Name; ///< name to use for referencing the entity by name.
bool m_written; ///< Set to true when the object has been written after a ReNameNodes().
private:
SGNODE** m_Association; ///< Handle to the instance held by a wrapper.
};
#endif // SG_NODE_H
-299
View File
@@ -1,299 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_normals.h"
#include "3d_cache/sg/sg_helpers.h"
SGNORMALS::SGNORMALS( SGNODE* aParent ) : SGNODE( aParent )
{
m_SGtype = S3D::SGTYPE_NORMALS;
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] inappropriate parent to SGNORMALS "
"(type %d)" ),
__FILE__, __FUNCTION__, __LINE__,
aParent->GetNodeType() );
}
else if( nullptr != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SGNORMALS::~SGNORMALS()
{
norms.clear();
}
bool SGNORMALS::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a SGFACESET may be parent to a SGNORMALS
if( nullptr != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
SGNODE* SGNORMALS::FindNode( const char* aNodeName, const SGNODE* aCaller ) noexcept
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
return nullptr;
}
void SGNORMALS::unlinkChildNode( const SGNODE* aCaller ) noexcept
{
wxCHECK( false, /* void */ );
}
void SGNORMALS::unlinkRefNode( const SGNODE* aCaller ) noexcept
{
wxCHECK( false, /* void */ );
}
bool SGNORMALS::AddRefNode( SGNODE* aNode ) noexcept
{
wxCHECK( false, false );
return false;
}
bool SGNORMALS::AddChildNode( SGNODE* aNode ) noexcept
{
wxCHECK( false, false );
return false;
}
bool SGNORMALS::GetNormalList( size_t& aListSize, SGVECTOR*& aNormalList )
{
if( norms.empty() )
{
aListSize = 0;
aNormalList = nullptr;
return false;
}
aListSize = norms.size();
aNormalList = &norms[0];
return true;
}
void SGNORMALS::SetNormalList( size_t aListSize, const SGVECTOR* aNormalList )
{
norms.clear();
if( 0 == aListSize || nullptr == aNormalList )
return;
for( int i = 0; i < (int)aListSize; ++i )
norms.push_back( aNormalList[i] );
}
void SGNORMALS::AddNormal( double aXValue, double aYValue, double aZValue )
{
norms.emplace_back( aXValue, aYValue, aZValue );
}
void SGNORMALS::AddNormal( const SGVECTOR& aNormal )
{
norms.push_back( aNormal );
}
void SGNORMALS::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
}
bool SGNORMALS::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( norms.empty() )
return false;
if( aReuseFlag )
{
if( !m_written )
{
aFile << " normal DEF " << GetName() << " Normal { vector [\n ";
m_written = true;
}
else
{
aFile << " normal USE " << GetName() << "\n";
return true;
}
}
else
{
aFile << " normal Normal { vector [\n ";
}
std::string tmp;
size_t n = norms.size();
bool nline = false;
for( size_t i = 0; i < n; )
{
S3D::FormatVector( tmp, norms[i] );
aFile << tmp ;
++i;
if( i < n )
{
aFile << ",";
if( nline )
{
aFile << "\n ";
nline = false;
}
else
{
nline = true;
}
}
}
aFile << "] }\n";
return true;
}
bool SGNORMALS::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode )
{
wxCHECK( m_Parent, false );
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK( parentNode == m_Parent, false );
if( !aFile.good() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
aFile << "[" << GetName() << "]";
size_t npts = norms.size();
aFile.write( (char*)&npts, sizeof(size_t) );
for( size_t i = 0; i < npts; ++i )
S3D::WriteVector( aFile, norms[i] );
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SGNORMALS::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
wxCHECK( norms.empty(), false );
size_t npts;
aFile.read( (char*) &npts, sizeof( size_t ) );
SGVECTOR tmp;
if( aFile.fail() )
return false;
for( size_t i = 0; i < npts; ++i )
{
if( !S3D::ReadVector( aFile, tmp ) || aFile.fail() )
return false;
norms.push_back( tmp );
}
return true;
}
-67
View File
@@ -1,67 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_normals.h
*/
#ifndef SG_NORMALS_H
#define SG_NORMALS_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
/**
* Define a set of vertex normals for a scene graph object
*/
class SGNORMALS : public SGNODE
{
public:
SGNORMALS( SGNODE* aParent );
virtual ~SGNORMALS();
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
SGNODE* FindNode( const char* aNodeName, const SGNODE* aCaller ) noexcept override;
bool AddRefNode( SGNODE* aNode ) noexcept override;
bool AddChildNode( SGNODE* aNode ) noexcept override;
bool GetNormalList( size_t& aListSize, SGVECTOR*& aNormalList );
void SetNormalList( size_t aListSize, const SGVECTOR* aNormalList );
void AddNormal( double aXValue, double aYValue, double aZValue );
void AddNormal( const SGVECTOR& aNormal );
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
void unlinkChildNode( const SGNODE* aNode ) noexcept override;
void unlinkRefNode( const SGNODE* aNode ) noexcept override;
std::vector< SGVECTOR > norms;
};
#endif // SG_NORMALS_H
-783
View File
@@ -1,783 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "3d_cache/sg/sg_shape.h"
#include "3d_cache/sg/sg_faceset.h"
#include "3d_cache/sg/sg_appearance.h"
#include "3d_cache/sg/sg_helpers.h"
#include "3d_cache/sg/sg_coordindex.h"
#include "3d_cache/sg/sg_coords.h"
#include "3d_cache/sg/sg_colors.h"
#include "3d_cache/sg/sg_normals.h"
SGSHAPE::SGSHAPE( SGNODE* aParent ) : SGNODE( aParent )
{
m_SGtype = S3D::SGTYPE_SHAPE;
m_Appearance = nullptr;
m_RAppearance = nullptr;
m_FaceSet = nullptr;
m_RFaceSet = nullptr;
if( nullptr != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
{
m_Parent = nullptr;
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] inappropriate parent to SGSHAPE (type %d)" ),
__FILE__, __FUNCTION__, __LINE__, aParent->GetNodeType() );
}
else if( nullptr != aParent && S3D::SGTYPE_TRANSFORM == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
}
SGSHAPE::~SGSHAPE()
{
// drop references
if( m_RAppearance )
{
m_RAppearance->delNodeRef( this );
m_RAppearance = nullptr;
}
if( m_RFaceSet )
{
m_RFaceSet->delNodeRef( this );
m_RFaceSet = nullptr;
}
// delete objects
if( m_Appearance )
{
m_Appearance->SetParent( nullptr, false );
delete m_Appearance;
m_Appearance = nullptr;
}
if( m_FaceSet )
{
m_FaceSet->SetParent( nullptr, false );
delete m_FaceSet;
m_FaceSet = nullptr;
}
}
bool SGSHAPE::SetParent( SGNODE* aParent, bool notify )
{
if( nullptr != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = nullptr;
if( nullptr == aParent )
return true;
}
// only a SGTRANSFORM may be parent to a SGSHAPE
if( nullptr != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
return false;
m_Parent = aParent;
if( m_Parent )
m_Parent->AddChildNode( this );
return true;
}
SGNODE* SGSHAPE::FindNode( const char* aNodeName, const SGNODE* aCaller )
{
if( nullptr == aNodeName || 0 == aNodeName[0] )
return nullptr;
if( !m_Name.compare( aNodeName ) )
return this;
SGNODE* tmp = nullptr;
if( nullptr != m_Appearance )
{
tmp = m_Appearance->FindNode( aNodeName, this );
if( tmp )
{
return tmp;
}
}
if( nullptr != m_FaceSet )
{
tmp = m_FaceSet->FindNode( aNodeName, this );
if( tmp )
{
return tmp;
}
}
// query the parent if appropriate
if( aCaller == m_Parent || nullptr == m_Parent )
return nullptr;
return m_Parent->FindNode( aNodeName, this );
}
void SGSHAPE::unlinkNode( const SGNODE* aNode, bool isChild )
{
if( nullptr == aNode )
return;
if( isChild )
{
if( aNode == m_Appearance )
{
m_Appearance = nullptr;
return;
}
if( aNode == m_FaceSet )
{
m_FaceSet = nullptr;
return;
}
}
else
{
if( aNode == m_RAppearance )
{
delNodeRef( this );
m_RAppearance = nullptr;
return;
}
if( aNode == m_RFaceSet )
{
delNodeRef( this );
m_RFaceSet = nullptr;
return;
}
}
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] unlinkNode() did not find its target" ),
__FILE__, __FUNCTION__, __LINE__ );
}
void SGSHAPE::unlinkChildNode( const SGNODE* aNode )
{
unlinkNode( aNode, true );
}
void SGSHAPE::unlinkRefNode( const SGNODE* aNode )
{
unlinkNode( aNode, false );
}
bool SGSHAPE::addNode( SGNODE* aNode, bool isChild )
{
wxCHECK( aNode, false );
if( S3D::SGTYPE_APPEARANCE == aNode->GetNodeType() )
{
if( m_Appearance || m_RAppearance )
{
if( aNode != m_Appearance && aNode != m_RAppearance )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] assigning multiple Appearance "
"nodes" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
return true;
}
if( isChild )
{
m_Appearance = (SGAPPEARANCE*)aNode;
m_Appearance->SetParent( this );
}
else
{
m_RAppearance = (SGAPPEARANCE*)aNode;
m_RAppearance->addNodeRef( this );
}
return true;
}
if( S3D::SGTYPE_FACESET == aNode->GetNodeType() )
{
if( m_FaceSet || m_RFaceSet )
{
if( aNode != m_FaceSet && aNode != m_RFaceSet )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] assigning multiple FaceSet nodes" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
return true;
}
if( isChild )
{
m_FaceSet = (SGFACESET*)aNode;
m_FaceSet->SetParent( this );
}
else
{
m_RFaceSet = (SGFACESET*)aNode;
m_RFaceSet->addNodeRef( this );
}
return true;
}
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] object %s is not a valid type for this "
"object (%d)" ),
__FILE__, __FUNCTION__, __LINE__, aNode->GetName(), aNode->GetNodeType() );
return false;
}
bool SGSHAPE::AddRefNode( SGNODE* aNode )
{
return addNode( aNode, false );
}
bool SGSHAPE::AddChildNode( SGNODE* aNode )
{
return addNode( aNode, true );
}
void SGSHAPE::ReNameNodes( void )
{
m_written = false;
// rename this node
m_Name.clear();
GetName();
// rename Appearance
if( m_Appearance )
m_Appearance->ReNameNodes();
// rename FaceSet
if( m_FaceSet )
m_FaceSet->ReNameNodes();
}
bool SGSHAPE::WriteVRML( std::ostream& aFile, bool aReuseFlag )
{
if( !m_Appearance && !m_RAppearance && !m_FaceSet && !m_RFaceSet )
{
return false;
}
if( aReuseFlag )
{
if( !m_written )
{
aFile << "DEF " << GetName() << " Shape {\n";
m_written = true;
}
else
{
aFile << " USE " << GetName() << "\n";
return true;
}
}
else
{
aFile << " Shape {\n";
}
if( m_Appearance )
m_Appearance->WriteVRML( aFile, aReuseFlag );
if( m_RAppearance )
m_RAppearance->WriteVRML( aFile, aReuseFlag );
if( m_FaceSet )
m_FaceSet->WriteVRML( aFile, aReuseFlag );
if( m_RFaceSet )
m_RFaceSet->WriteVRML( aFile, aReuseFlag );
aFile << "}\n";
return true;
}
bool SGSHAPE::WriteCache( std::ostream& aFile, SGNODE* parentNode )
{
if( nullptr == parentNode )
{
wxCHECK( m_Parent, false );
SGNODE* np = m_Parent;
while( nullptr != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, nullptr ) )
{
m_written = true;
return true;
}
return false;
}
wxCHECK( parentNode == m_Parent, false );
if( !aFile.good() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] bad stream" ),
__FILE__, __FUNCTION__, __LINE__ );
return false;
}
// check if any references are unwritten and swap parents if so
if( nullptr != m_RAppearance && !m_RAppearance->isWritten() )
m_RAppearance->SwapParent(this);
if( nullptr != m_RFaceSet && !m_RFaceSet->isWritten() )
m_RFaceSet->SwapParent( this );
aFile << "[" << GetName() << "]";
#define NITEMS 4
bool items[NITEMS];
int i;
for( i = 0; i < NITEMS; ++i )
items[i] = 0;
i = 0;
if( nullptr != m_Appearance )
items[i] = true;
++i;
if( nullptr != m_RAppearance )
items[i] = true;
++i;
if( nullptr != m_FaceSet )
items[i] = true;
++i;
if( nullptr != m_RFaceSet )
items[i] = true;
for( int jj = 0; jj < NITEMS; ++jj )
aFile.write( (char*)&items[jj], sizeof(bool) );
if( items[0] )
m_Appearance->WriteCache( aFile, this );
if( items[1] )
aFile << "[" << m_RAppearance->GetName() << "]";
if( items[2] )
m_FaceSet->WriteCache( aFile, this );
if( items[3] )
aFile << "[" << m_RFaceSet->GetName() << "]";
if( aFile.fail() )
return false;
m_written = true;
return true;
}
bool SGSHAPE::ReadCache( std::istream& aFile, SGNODE* parentNode )
{
wxCHECK( m_Appearance == nullptr && m_RAppearance == nullptr && m_FaceSet == nullptr &&
m_RFaceSet == nullptr, false );
#define NITEMS 4
bool items[NITEMS];
for( int i = 0; i < NITEMS; ++i )
aFile.read( (char*)&items[i], sizeof(bool) );
if( ( items[0] && items[1] ) || ( items[2] && items[3] ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; multiple item definitions "
"at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
std::string name;
if( items[0] )
{
if( S3D::SGTYPE_APPEARANCE != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child appearance "
"tag at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
m_Appearance = new SGAPPEARANCE( this );
m_Appearance->SetName( name.c_str() );
if( !m_Appearance->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data while reading appearance "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__, name );
return false;
}
}
if( items[1] )
{
if( S3D::SGTYPE_APPEARANCE != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref appearance tag "
"at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
SGNODE* np = FindNode( name.c_str(), this );
if( !np )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: cannot find ref "
"appearance '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
if( S3D::SGTYPE_APPEARANCE != np->GetNodeType() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: type is not "
"SGAPPEARANCE '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
m_RAppearance = (SGAPPEARANCE*)np;
m_RAppearance->addNodeRef( this );
}
if( items[2] )
{
if( S3D::SGTYPE_FACESET != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child face set tag "
"at position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
m_FaceSet = new SGFACESET( this );
m_FaceSet->SetName( name.c_str() );
if( !m_FaceSet->ReadCache( aFile, this ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data while reading face set "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__, name );
return false;
}
}
if( items[3] )
{
if( S3D::SGTYPE_FACESET != S3D::ReadTag( aFile, name ) )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref face set tag at "
"position %ul" ),
__FILE__, __FUNCTION__, __LINE__,
static_cast<unsigned long>( aFile.tellg() ) );
return false;
}
SGNODE* np = FindNode( name.c_str(), this );
if( !np )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: cannot find ref face "
"set '%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
if( S3D::SGTYPE_FACESET != np->GetNodeType() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: type is not SGFACESET "
"'%s'" ),
__FILE__, __FUNCTION__, __LINE__,
name );
return false;
}
m_RFaceSet = (SGFACESET*)np;
m_RFaceSet->addNodeRef( this );
}
if( aFile.fail() )
return false;
return true;
}
bool SGSHAPE::Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
std::vector< SMESH >& meshes )
{
SMESH m;
S3D::INIT_SMESH( m );
SGAPPEARANCE* pa = m_Appearance;
SGFACESET* pf = m_FaceSet;
if( nullptr == pa )
pa = m_RAppearance;
if( nullptr == pf )
pf = m_RFaceSet;
// no face sets = nothing to render, which is valid though pointless
if( nullptr == pf )
return true;
if( !pf->validate() )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; inconsistent data" ),
__FILE__, __FUNCTION__, __LINE__ );
return true;
}
if( nullptr == pa )
{
m.m_MaterialIdx = 0;
}
else
{
int idx;
if( !S3D::GetMatIndex( materials, pa, idx ) )
{
m.m_MaterialIdx = 0;
}
else
{
m.m_MaterialIdx = idx;
}
}
SGCOLORS* pc = pf->m_Colors;
SGCOORDS* pv = pf->m_Coords;
SGCOORDINDEX* vidx = pf->m_CoordIndices;
SGNORMALS* pn = pf->m_Normals;
if( nullptr == pc )
pc = pf->m_RColors;
if( nullptr == pv )
pv = pf->m_RCoords;
if( nullptr == pn )
pn = pf->m_RNormals;
// set the vertex points and indices
size_t nCoords = 0;
SGPOINT* pCoords = nullptr;
pv->GetCoordsList( nCoords, pCoords );
size_t nColors = 0;
SGCOLOR* pColors = nullptr;
if( pc )
{
// check the vertex colors
pc->GetColorList( nColors, pColors );
if( nColors < nCoords )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; not enough colors per "
"vertex (%ul vs %ul)" ),
__FILE__, __FUNCTION__, __LINE__, static_cast<unsigned long>( nColors ),
static_cast<unsigned long>( nCoords ) );
return true;
}
}
// set the vertex indices
size_t nvidx = 0;
int* lv = nullptr;
vidx->GetIndices( nvidx, lv );
// note: reduce the vertex set to include only the referenced vertices
std::vector< int > vertices; // store the list of temp vertex indices
std::map< int, unsigned int > indexmap; // map temp vertex to true vertex
std::map< int, unsigned int >::iterator mit;
for( unsigned int i = 0; i < nvidx; ++i )
{
mit = indexmap.find( lv[i] );
if( mit == indexmap.end() )
{
indexmap.emplace( lv[i], vertices.size() );
vertices.push_back( lv[i] );
}
}
if( vertices.size() < 3 )
{
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad model; not enough vertices" ),
__FILE__, __FUNCTION__, __LINE__ );
return true;
}
// construct the final vertex/color list
SFVEC3F* lColors = nullptr;
SFVEC3F* lCoords = new SFVEC3F[ vertices.size() ];
int ti;
if( pc )
{
lColors = new SFVEC3F[vertices.size()];
m.m_Color = lColors;
}
if( pc )
{
for( size_t i = 0; i < vertices.size(); ++i )
{
ti = vertices[i];
glm::dvec4 pt( pCoords[ti].x, pCoords[ti].y, pCoords[ti].z, 1.0 );
pt = (*aTransform) * pt;
pColors[ti].GetColor( lColors[i].x, lColors[i].y, lColors[i].z );
lCoords[i] = SFVEC3F( pt.x, pt.y, pt.z );
}
}
else
{
for( size_t i = 0; i < vertices.size(); ++i )
{
ti = vertices[i];
glm::dvec4 pt( pCoords[ti].x, pCoords[ti].y, pCoords[ti].z, 1.0 );
pt = (*aTransform) * pt;
lCoords[i] = SFVEC3F( pt.x, pt.y, pt.z );
}
}
m.m_VertexSize = (unsigned int) vertices.size();
m.m_Positions = lCoords;
unsigned int* lvidx = new unsigned int[ nvidx ];
for( unsigned int i = 0; i < nvidx; ++i )
{
mit = indexmap.find( lv[i] );
lvidx[i] = mit->second;
}
m.m_FaceIdxSize = (unsigned int )nvidx;
m.m_FaceIdx = lvidx;
// set the per-vertex normals
size_t nNorms = 0;
SGVECTOR* pNorms = nullptr;
double x, y, z;
pn->GetNormalList( nNorms, pNorms );
SFVEC3F* lNorms = new SFVEC3F[ vertices.size() ];
for( size_t i = 0; i < vertices.size(); ++i )
{
ti = vertices[i];
pNorms[ti].GetVector( x, y, z );
glm::dvec4 pt( x, y, z, 0.0 );
pt = (*aTransform) * pt;
lNorms[i] = SFVEC3F( pt.x, pt.y, pt.z );
}
m.m_Normals = lNorms;
meshes.push_back( m );
return true;
}
-88
View File
@@ -1,88 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file sg_shape.h
*/
#ifndef SG_SHAPE_H
#define SG_SHAPE_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGAPPEARANCE;
class SGFACESET;
/**
* Define a complex 3D shape for a scenegraph object.
*/
class SGSHAPE : public SGNODE
{
public:
SGSHAPE( SGNODE* aParent );
virtual ~SGSHAPE();
virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
SGNODE* FindNode(const char* aNodeName, const SGNODE* aCaller) override;
bool AddRefNode( SGNODE* aNode ) override;
bool AddChildNode( SGNODE* aNode ) override;
void ReNameNodes( void ) override;
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
bool Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
std::vector< SMESH >& meshes );
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
private:
void unlinkNode( const SGNODE* aNode, bool isChild );
bool addNode( SGNODE* aNode, bool isChild );
public:
// owned node
SGAPPEARANCE* m_Appearance;
SGFACESET* m_FaceSet;
// referenced nodes
SGAPPEARANCE* m_RAppearance;
SGFACESET* m_RFaceSet;
};
/*
p.107
Shape {
appearance NULL
geometry NULL
}
*/
#endif // SG_SHAPE_H
+689
View File
@@ -0,0 +1,689 @@
/**
* @file 3d_canvas.cpp
*/
#include <fctsys.h>
#include <trigo.h>
#include <wx/image.h>
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include <wx/dataobj.h>
#include <wx/clipbrd.h>
#include <wx/wupdlock.h>
#include <gestfich.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <3d_viewer_id.h>
// -----------------
// helper function (from wxWidgets, opengl/cube.cpp sample
// -----------------
void CheckGLError()
{
GLenum errLast = GL_NO_ERROR;
for ( ; ; )
{
GLenum err = glGetError();
if ( err == GL_NO_ERROR )
return;
// normally the error is reset by the call to glGetError() but if
// glGetError() itself returns an error, we risk looping forever here
// so check that we get a different error than the last time
if ( err == errLast )
{
wxLogError(wxT("OpenGL error state couldn't be reset."));
return;
}
errLast = err;
wxLogError(wxT("OpenGL error %d"), err);
}
}
/*
* EDA_3D_CANVAS implementation
*/
BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas )
EVT_PAINT( EDA_3D_CANVAS::OnPaint )
// key event:
EVT_CHAR( EDA_3D_CANVAS::OnChar )
// mouse events
EVT_RIGHT_DOWN( EDA_3D_CANVAS::OnRightClick )
EVT_MOUSEWHEEL( EDA_3D_CANVAS::OnMouseWheel )
EVT_MOTION( EDA_3D_CANVAS::OnMouseMove )
// other events
EVT_ERASE_BACKGROUND( EDA_3D_CANVAS::OnEraseBackground )
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, EDA_3D_CANVAS::OnPopUpMenu )
END_EVENT_TABLE()
EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) :
wxGLCanvas( parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE )
{
m_init = false;
// Clear all gl list identifiers:
for( int ii = GL_ID_BEGIN; ii < GL_ID_END; ii++ )
m_glLists[ii] = 0;
// Explicitly create a new rendering context instance for this canvas.
m_glRC = new wxGLContext( this );
DisplayStatus();
}
EDA_3D_CANVAS::~EDA_3D_CANVAS()
{
ClearLists();
m_init = false;
delete m_glRC;
}
void EDA_3D_CANVAS::ClearLists( GLuint aGlList )
{
if( aGlList )
{
if( m_glLists[aGlList] > 0 )
glDeleteLists( m_glLists[aGlList], 1 );
m_glLists[aGlList] = 0;
return;
}
for( int ii = GL_ID_BEGIN; ii < GL_ID_END; ii++ )
{
if( m_glLists[ii] > 0 )
glDeleteLists( m_glLists[ii], 1 );
m_glLists[ii] = 0;
}
}
void EDA_3D_CANVAS::OnChar( wxKeyEvent& event )
{
SetView3D( event.GetKeyCode() );
event.Skip();
}
void EDA_3D_CANVAS::SetView3D( int keycode )
{
int ii;
double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
switch( keycode )
{
case WXK_LEFT:
m_draw3dOffset.x -= delta_move;
break;
case WXK_RIGHT:
m_draw3dOffset.x += delta_move;
break;
case WXK_UP:
m_draw3dOffset.y += delta_move;
break;
case WXK_DOWN:
m_draw3dOffset.y -= delta_move;
break;
case WXK_HOME:
g_Parm_3D_Visu.m_Zoom = 1.0;
m_draw3dOffset.x = m_draw3dOffset.y = 0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case WXK_END:
break;
case WXK_F1:
g_Parm_3D_Visu.m_Zoom /= 1.4;
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
g_Parm_3D_Visu.m_Zoom = 0.01;
break;
case WXK_F2:
g_Parm_3D_Visu.m_Zoom *= 1.4;
break;
case '+':
break;
case '-':
break;
case 'r':
case 'R':
m_draw3dOffset.x = m_draw3dOffset.y = 0;
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case 'x':
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
g_Parm_3D_Visu.m_ROTZ = -90;
g_Parm_3D_Visu.m_ROTX = -90;
break;
case 'X':
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
g_Parm_3D_Visu.m_ROTZ = 90;
g_Parm_3D_Visu.m_ROTX = -90;
break;
case 'y':
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
g_Parm_3D_Visu.m_ROTX = -90;
break;
case 'Y':
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
g_Parm_3D_Visu.m_ROTX = -90;
g_Parm_3D_Visu.m_ROTZ = -180;
break;
case 'z':
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case 'Z':
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
g_Parm_3D_Visu.m_ROTX = -180;
break;
default:
return;
}
DisplayStatus();
Refresh( false );
}
void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event )
{
if( event.ShiftDown() )
{
if( event.GetWheelRotation() < 0 )
{
/* up */
SetView3D( WXK_UP );
}
else
{
/* down */
SetView3D( WXK_DOWN );
}
}
else if( event.ControlDown() )
{
if( event.GetWheelRotation() > 0 )
{
/* right */
SetView3D( WXK_RIGHT );
}
else
{
/* left */
SetView3D( WXK_LEFT );
}
}
else
{
if( event.GetWheelRotation() > 0 )
{
g_Parm_3D_Visu.m_Zoom /= 1.4;
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
g_Parm_3D_Visu.m_Zoom = 0.01;
}
else
g_Parm_3D_Visu.m_Zoom *= 1.4;
DisplayStatus();
Refresh( false );
}
g_Parm_3D_Visu.m_Beginx = event.GetX();
g_Parm_3D_Visu.m_Beginy = event.GetY();
}
void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
{
wxSize size( GetClientSize() );
double spin_quat[4];
if( event.Dragging() )
{
if( event.LeftIsDown() )
{
/* drag in progress, simulate trackball */
trackball( spin_quat,
(2.0 * g_Parm_3D_Visu.m_Beginx - size.x) / size.x,
(size.y - 2.0 * g_Parm_3D_Visu.m_Beginy) / size.y,
( 2.0 * event.GetX() - size.x) / size.x,
( size.y - 2.0 * event.GetY() ) / size.y );
add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat );
}
else if( event.MiddleIsDown() )
{
/* middle button drag -> pan */
/* Current zoom and an additional factor are taken into account
* for the amount of panning. */
const double PAN_FACTOR = 8.0 * g_Parm_3D_Visu.m_Zoom;
m_draw3dOffset.x -= PAN_FACTOR *
( g_Parm_3D_Visu.m_Beginx - event.GetX() ) / size.x;
m_draw3dOffset.y -= PAN_FACTOR *
(event.GetY() - g_Parm_3D_Visu.m_Beginy) / size.y;
}
/* orientation has changed, redraw mesh */
DisplayStatus();
Refresh( false );
}
g_Parm_3D_Visu.m_Beginx = event.GetX();
g_Parm_3D_Visu.m_Beginy = event.GetY();
}
/* Construct and display a popup menu when the right button is clicked.
*/
void EDA_3D_CANVAS::OnRightClick( wxMouseEvent& event )
{
wxPoint pos;
wxMenu PopUpMenu;
pos.x = event.GetX();
pos.y = event.GetY();
wxMenuItem* item = new wxMenuItem( &PopUpMenu, ID_POPUP_ZOOMIN, _( "Zoom +" ) );
item->SetBitmap( KiBitmap( zoom_in_xpm ));
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_ZOOMOUT, _( "Zoom -" ) );
item->SetBitmap( KiBitmap( zoom_out_xpm ));
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZPOS, _( "Top View" ) );
item->SetBitmap( KiBitmap( axis3d_top_xpm ));
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZNEG, _( "Bottom View" ) );
item->SetBitmap( KiBitmap( axis3d_bottom_xpm ));
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_XPOS, _( "Right View" ) );
item->SetBitmap( KiBitmap( axis3d_right_xpm ));
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_XNEG, _( "Left View" ) );
item->SetBitmap( KiBitmap( axis3d_left_xpm ));
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_YPOS, _( "Front View" ) );
item->SetBitmap( KiBitmap( axis3d_front_xpm ));
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_YNEG, _( "Back View" ) );
item->SetBitmap( KiBitmap( axis3d_back_xpm ));
PopUpMenu.Append( item );
PopUpMenu.AppendSeparator();
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_LEFT, _( "Move left <-" ) );
item->SetBitmap( KiBitmap( left_xpm ));
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_RIGHT, _( "Move right ->" ) );
item->SetBitmap( KiBitmap( right_xpm ));
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_UP, _( "Move Up ^" ) );
item->SetBitmap( KiBitmap( up_xpm ));
PopUpMenu.Append( item );
item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_DOWN, _( "Move Down" ) );
item->SetBitmap( KiBitmap( down_xpm ));
PopUpMenu.Append( item );
PopupMenu( &PopUpMenu, pos );
}
void EDA_3D_CANVAS::OnPopUpMenu( wxCommandEvent& event )
{
int key = 0;
switch( event.GetId() )
{
case ID_POPUP_ZOOMIN:
key = WXK_F1;
break;
case ID_POPUP_ZOOMOUT:
key = WXK_F2;
break;
case ID_POPUP_VIEW_XPOS:
key = 'x';
break;
case ID_POPUP_VIEW_XNEG:
key = 'X';
break;
case ID_POPUP_VIEW_YPOS:
key = 'y';
break;
case ID_POPUP_VIEW_YNEG:
key = 'Y';
break;
case ID_POPUP_VIEW_ZPOS:
key = 'z';
break;
case ID_POPUP_VIEW_ZNEG:
key = 'Z';
break;
case ID_POPUP_MOVE3D_LEFT:
key = WXK_LEFT;
break;
case ID_POPUP_MOVE3D_RIGHT:
key = WXK_RIGHT;
break;
case ID_POPUP_MOVE3D_UP:
key = WXK_UP;
break;
case ID_POPUP_MOVE3D_DOWN:
key = WXK_DOWN;
break;
default:
return;
}
SetView3D( key );
}
void EDA_3D_CANVAS::DisplayStatus()
{
wxString msg;
msg.Printf( wxT( "dx %3.2f" ), m_draw3dOffset.x );
Parent()->SetStatusText( msg, 1 );
msg.Printf( wxT( "dy %3.2f" ), m_draw3dOffset.y );
Parent()->SetStatusText( msg, 2 );
msg.Printf( wxT( "View: %3.1f" ), 45 * g_Parm_3D_Visu.m_Zoom );
Parent()->SetStatusText( msg, 3 );
}
void EDA_3D_CANVAS::OnPaint( wxPaintEvent& event )
{
wxPaintDC dc( this );
Redraw();
event.Skip();
}
void EDA_3D_CANVAS::OnEraseBackground( wxEraseEvent& event )
{
// Do nothing, to avoid flashing.
}
/* Initialize broad parameters for OpenGL */
void EDA_3D_CANVAS::InitGL()
{
wxSize size = GetClientSize();
if( !m_init )
{
m_init = true;
g_Parm_3D_Visu.m_Zoom = 1.0;
m_ZBottom = 1.0;
m_ZTop = 10.0;
glDisable( GL_CULL_FACE ); // show back faces
glEnable( GL_DEPTH_TEST ); // Enable z-buferring
glEnable( GL_ALPHA_TEST );
glEnable( GL_LINE_SMOOTH );
// glEnable(GL_POLYGON_SMOOTH); // creates issues with some graphic cards
glShadeModel( GL_SMOOTH );
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
// speedups
glEnable( GL_DITHER );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
// Initialize alpha blending function.
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
// set viewing projection
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
#define MAX_VIEW_ANGLE 160.0 / 45.0
if( g_Parm_3D_Visu.m_Zoom > MAX_VIEW_ANGLE )
g_Parm_3D_Visu.m_Zoom = MAX_VIEW_ANGLE;
if( Parent()->ModeIsOrtho() )
{
// OrthoReductionFactor is chosen so as to provide roughly the same size as
// Perspective View
const double orthoReductionFactor = 400 / g_Parm_3D_Visu.m_Zoom;
// Initialize Projection Matrix for Ortographic View
glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor,
-size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 10 );
}
else
{
// Ratio width / height of the window display
double ratio_HV = (double) size.x / size.y;
// Initialize Projection Matrix for Perspective View
gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 10 );
}
// position viewer
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0F, 0.0F, -( m_ZBottom + m_ZTop) / 2 );
// clear color and depth buffers
glClearColor( g_Parm_3D_Visu.m_BgColor.m_Red,
g_Parm_3D_Visu.m_BgColor.m_Green,
g_Parm_3D_Visu.m_BgColor.m_Blue, 1 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Setup light sources:
SetLights();
CheckGLError();
}
/* Initialize OpenGL light sources. */
void EDA_3D_CANVAS::SetLights()
{
double light;
GLfloat light_color[4];
/* set viewing projection */
light_color[3] = 1.0;
GLfloat Z_axis_pos[4] = { 0.0, 0.0, 3.0, 0.0 };
GLfloat lowZ_axis_pos[4] = { 0.0, 0.0, -3.0, 0.5 };
/* activate light */
light = 1.0;
light_color[0] = light_color[1] = light_color[2] = light;
glLightfv( GL_LIGHT0, GL_POSITION, Z_axis_pos );
glLightfv( GL_LIGHT0, GL_DIFFUSE, light_color );
light = 0.3;
light_color[0] = light_color[1] = light_color[2] = light;
glLightfv( GL_LIGHT1, GL_POSITION, lowZ_axis_pos );
glLightfv( GL_LIGHT1, GL_DIFFUSE, light_color );
glEnable( GL_LIGHT0 ); // White spot on Z axis
glEnable( GL_LIGHT1 ); // White spot on Z axis ( bottom)
glEnable( GL_LIGHTING );
}
/* Create a Screenshot of the current 3D view.
* Output file format is png or jpeg, or image is copied to the clipboard
*/
void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{
wxFileName fn( Parent()->GetDefaultFileName() );
wxString FullFileName;
wxString file_ext, mask;
bool fmt_is_jpeg = false;
if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
fmt_is_jpeg = true;
if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
FullFileName = Parent()->GetDefaultFileName();
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
// Be sure the screen area destroyed by the file dialog is redrawn before making
// a screen copy.
// Without this call, under Linux the screen refresh is made to late.
wxYield();
}
struct vieport_params
{
GLint originx;
GLint originy;
GLint x;
GLint y;
} viewport;
// Build image from the 3D buffer
wxWindowUpdateLocker noUpdates( this );
glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport );
unsigned char* pixelbuffer = (unsigned char*) malloc( viewport.x * viewport.y * 3 );
unsigned char* alphabuffer = (unsigned char*) malloc( viewport.x * viewport.y );
wxImage image( viewport.x, viewport.y );
glPixelStorei( GL_PACK_ALIGNMENT, 1 );
glReadBuffer( GL_BACK_LEFT );
glReadPixels( viewport.originx, viewport.originy,
viewport.x, viewport.y,
GL_RGB, GL_UNSIGNED_BYTE, pixelbuffer );
glReadPixels( viewport.originx, viewport.originy,
viewport.x, viewport.y,
GL_ALPHA, GL_UNSIGNED_BYTE, alphabuffer );
image.SetData( pixelbuffer );
image.SetAlpha( alphabuffer );
image = image.Mirror( false );
wxBitmap bitmap( image );
if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject;
dobjBmp->SetBitmap( bitmap );
if( wxTheClipboard->Open() )
{
if( !wxTheClipboard->SetData( dobjBmp ) )
wxMessageBox( _( "Failed to copy image to clipboard" ) );
wxTheClipboard->Flush(); /* the data in clipboard will stay
* available after the
* application exits */
wxTheClipboard->Close();
}
}
else
{
wxImage image = bitmap.ConvertToImage();
if( !image.SaveFile( FullFileName,
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
wxMessageBox( _( "Can't save file" ) );
image.Destroy();
}
}
+169
View File
@@ -0,0 +1,169 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_viewer.h
*/
#ifndef _3D_CANVAS_H_
#define _3D_CANVAS_H_
#include <wx/glcanvas.h>
#ifdef __WXMAC__
# ifdef __DARWIN__
# include <OpenGL/glu.h>
# else
# include <glu.h>
# endif
#else
# include <GL/glu.h>
#endif
#include <3d_struct.h>
class BOARD_DESIGN_SETTINGS;
class EDA_3D_FRAME;
class S3D_VERTEX;
class VIA;
class D_PAD;
// We are using GL lists to store layers and other items
// to draw or not
// GL_LIST_ID are the GL lists indexes in m_glLists
enum GL_LIST_ID
{
GL_ID_BEGIN = 0,
GL_ID_AXIS = GL_ID_BEGIN, // list id for 3D axis
GL_ID_GRID, // list id for 3D grid
GL_ID_BOARD, // List id for copper layers
GL_ID_TECH_LAYERS, // List id for non copper layers (masks...)
GL_ID_AUX_LAYERS, // List id for user layers (draw, eco, comment)
GL_ID_3DSHAPES_SOLID, // List id for 3D shapes, non transparent entities
GL_ID_3DSHAPES_TRANSP, // List id for 3D shapes, transparent entities
GL_ID_END
};
class EDA_3D_CANVAS : public wxGLCanvas
{
private:
bool m_init;
GLuint m_glLists[GL_ID_END]; // GL lists
wxGLContext* m_glRC;
wxRealPoint m_draw3dOffset; // offset to draw the 3D mesh.
double m_ZBottom; // position of the back layer
double m_ZTop; // position of the front layer
public:
EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList = 0 );
~EDA_3D_CANVAS();
EDA_3D_FRAME* Parent() const { return static_cast<EDA_3D_FRAME*>( GetParent() ); }
BOARD* GetBoard() { return Parent()->GetBoard(); }
/**
* Function ClearLists
* Clear the display list.
* @param aGlList = the list to clear.
* if 0 (default) all lists are cleared
*/
void ClearLists( GLuint aGlList = 0 );
// Event functions:
void OnPaint( wxPaintEvent& event );
void OnEraseBackground( wxEraseEvent& event );
void OnChar( wxKeyEvent& event );
void OnMouseWheel( wxMouseEvent& event );
void OnMouseMove( wxMouseEvent& event );
void OnRightClick( wxMouseEvent& event );
void OnPopUpMenu( wxCommandEvent& event );
void TakeScreenshot( wxCommandEvent& event );
void OnEnterWindow( wxMouseEvent& event );
// Display functions
void SetView3D( int keycode );
void DisplayStatus();
void Redraw();
void Render();
/**
* Function CreateDrawGL_List
* Prepares the parameters of the OpenGL draw list
* creates the OpenGL draw list items (board, grid ...
*/
void CreateDrawGL_List();
void InitGL();
void SetLights();
void SetOffset(double aPosX, double aPosY)
{
m_draw3dOffset.x = aPosX;
m_draw3dOffset.y = aPosY;
}
/**
* Function BuildBoard3DView
* Called by CreateDrawGL_List()
* Populates the OpenGL GL_ID_BOARD draw list with board items only on copper layers.
* 3D footprint shapes, tech layers and aux layers are not on this list
*/
void BuildBoard3DView();
/**
* Function BuildTechLayers3DView
* Called by CreateDrawGL_List()
* Populates the OpenGL GL_ID_BOARD draw list with items on tech layers
*/
void BuildTechLayers3DView();
/**
* Function BuildFootprintShape3DList
* Called by CreateDrawGL_List()
* Fills the OpenGL GL_ID_3DSHAPES_SOLID and GL_ID_3DSHAPES_TRANSP
* draw lists with 3D footprint shapes
* @param aOpaqueList is the gl list for non transparent items
* @param aTransparentList is the gl list for non transparent items,
* which need to be drawn after all other items
*/
void BuildFootprintShape3DList( GLuint aOpaqueList,
GLuint aTransparentList);
/**
* Function BuildBoard3DAuxLayers
* Called by CreateDrawGL_List()
* Fills the OpenGL GL_ID_AUX_LAYERS draw list
* with items on aux layers only
*/
void BuildBoard3DAuxLayers();
void Draw3DGrid( double aGriSizeMM );
void Draw3DAxis();
void Draw3DViaHole( const VIA * aVia );
void Draw3DPadHole( const D_PAD * aPad );
DECLARE_EVENT_TABLE()
};
#endif /* _3D_CANVAS_H_ */
-758
View File
@@ -1,758 +0,0 @@
/*
* 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.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "../3d_rendering/camera.h"
#include "board_adapter.h"
#include <board_design_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <board_stackup_manager/stackup_predefined_prms.h>
#include <3d_rendering/raytracing/shapes2D/polygon_2d.h>
#include <board.h>
#include <dialogs/dialog_color_picker.h>
#include <3d_math.h>
#include "3d_fastmath.h"
#include <geometry/geometry_utils.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;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_MaskColors;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_PasteColors;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_FinishColors;
CUSTOM_COLORS_LIST BOARD_ADAPTER::g_BoardColors;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundTop;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundBot;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSilkscreen;
KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderMask;
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;
/**
* 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.
*
* @ingroup trace_env_vars
*/
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_boardPos = VECTOR2I();
m_boardSize = VECTOR2I();
m_boardCenter = SFVEC3F( 0.0f );
m_boardBoundingBox.Reset();
m_throughHoleIds.Clear();
m_throughHoleOds.Clear();
m_throughHoleAnnularRings.Clear();
m_copperLayersCount = 2;
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;
m_averageViaHoleDiameter = 0.0f;
m_holeCount = 0;
m_averageHoleDiameter = 0.0f;
m_averageTrackWidth = 0.0f;
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 );
m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
m_platedPadsFront = nullptr;
m_platedPadsBack = nullptr;
m_frontPlatedPadPolys = nullptr;
m_backPlatedPadPolys = nullptr;
if( !g_ColorsLoaded )
{
#define ADD_COLOR( list, r, g, b, a, name ) \
list.emplace_back( r/255.0, g/255.0, b/255.0, a, name )
ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, NotSpecifiedPrm() ); // White
ADD_COLOR( g_SilkscreenColors, 20, 51, 36, 1.0, wxT( "Green" ) );
ADD_COLOR( g_SilkscreenColors, 181, 19, 21, 1.0, wxT( "Red" ) );
ADD_COLOR( g_SilkscreenColors, 2, 59, 162, 1.0, wxT( "Blue" ) );
ADD_COLOR( g_SilkscreenColors, 11, 11, 11, 1.0, wxT( "Black" ) );
ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, wxT( "White" ) );
ADD_COLOR( g_SilkscreenColors, 32, 2, 53, 1.0, wxT( "Purple" ) );
ADD_COLOR( g_SilkscreenColors, 194, 195, 0, 1.0, wxT( "Yellow" ) );
ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, NotSpecifiedPrm() ); // Green
ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, wxT( "Green" ) );
ADD_COLOR( g_MaskColors, 91, 168, 12, 0.83, wxT( "Light Green" ) );
ADD_COLOR( g_MaskColors, 13, 104, 11, 0.83, wxT( "Saturated Green" ) );
ADD_COLOR( g_MaskColors, 181, 19, 21, 0.83, wxT( "Red" ) );
ADD_COLOR( g_MaskColors, 210, 40, 14, 0.83, wxT( "Light Red" ) );
ADD_COLOR( g_MaskColors, 239, 53, 41, 0.83, wxT( "Red/Orange" ) );
ADD_COLOR( g_MaskColors, 2, 59, 162, 0.83, wxT( "Blue" ) );
ADD_COLOR( g_MaskColors, 54, 79, 116, 0.83, wxT( "Light Blue 1" ) );
ADD_COLOR( g_MaskColors, 61, 85, 130, 0.83, wxT( "Light Blue 2" ) );
ADD_COLOR( g_MaskColors, 21, 70, 80, 0.83, wxT( "Green/Blue" ) );
ADD_COLOR( g_MaskColors, 11, 11, 11, 0.83, wxT( "Black" ) );
ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, wxT( "White" ) );
ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, wxT( "Purple" ) );
ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, wxT( "Light Purple" ) );
ADD_COLOR( g_MaskColors, 194, 195, 0, 0.83, wxT( "Yellow" ) );
ADD_COLOR( g_PasteColors, 128, 128, 128, 1.0, wxT( "Grey" ) );
ADD_COLOR( g_PasteColors, 90, 90, 90, 1.0, wxT( "Dark Grey" ) );
ADD_COLOR( g_PasteColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
ADD_COLOR( g_FinishColors, 184, 115, 50, 1.0, wxT( "Copper" ) );
ADD_COLOR( g_FinishColors, 178, 156, 0, 1.0, wxT( "Gold" ) );
ADD_COLOR( g_FinishColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
ADD_COLOR( g_FinishColors, 160, 160, 160, 1.0, wxT( "Tin" ) );
ADD_COLOR( g_BoardColors, 51, 43, 22, 0.83, wxT( "FR4 natural, dark" ) );
ADD_COLOR( g_BoardColors, 109, 116, 75, 0.83, wxT( "FR4 natural" ) );
ADD_COLOR( g_BoardColors, 252, 252, 250, 0.90, wxT( "PTFE natural" ) );
ADD_COLOR( g_BoardColors, 205, 130, 0, 0.68, wxT( "Polyimide" ) );
ADD_COLOR( g_BoardColors, 92, 17, 6, 0.90, wxT( "Phenolic natural" ) );
ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 1" ) );
ADD_COLOR( g_BoardColors, 160, 123, 54, 0.83, wxT( "Brown 2" ) );
ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 3" ) );
ADD_COLOR( g_BoardColors, 213, 213, 213, 1.0, wxT( "Aluminum" ) );
g_DefaultBackgroundTop = COLOR4D( 0.80, 0.80, 0.90, 1.0 );
g_DefaultBackgroundBot = COLOR4D( 0.40, 0.40, 0.50, 1.0 );
g_DefaultSilkscreen = COLOR4D( 0.94, 0.94, 0.94, 1.0 );
g_DefaultSolderMask = COLOR4D( 0.08, 0.20, 0.14, 0.83 );
g_DefaultSolderPaste = COLOR4D( 0.50, 0.50, 0.50, 1.0 );
g_DefaultSurfaceFinish = COLOR4D( 0.75, 0.61, 0.23, 1.0 );
g_DefaultBoardBody = COLOR4D( 0.43, 0.45, 0.30, 0.90 );
g_ColorsLoaded = true;
}
#undef ADD_COLOR
}
BOARD_ADAPTER::~BOARD_ADAPTER()
{
destroyLayers();
}
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 );
if( m_board && !m_board->IsLayerEnabled( aLayer ) )
return false;
// see if layer needs to be shown
// check the flags
switch( aLayer )
{
case B_Adhes:
case F_Adhes:
return m_Cfg->m_Render.show_adhesive;
case B_Paste:
case F_Paste:
return m_Cfg->m_Render.show_solderpaste;
case B_SilkS:
case F_SilkS:
return m_Cfg->m_Render.show_silkscreen;
case B_Mask:
case F_Mask:
return m_Cfg->m_Render.show_soldermask;
case Dwgs_User:
case Cmts_User:
return !m_Cfg->m_Render.realistic && m_Cfg->m_Render.show_comments;
case Eco1_User:
case Eco2_User:
return !m_Cfg->m_Render.realistic && m_Cfg->m_Render.show_eco;
case Edge_Cuts:
return !m_Cfg->m_Render.realistic && !m_Cfg->m_Render.show_board_body;
case Margin:
return !m_Cfg->m_Render.realistic;
case B_Cu:
case F_Cu:
return !m_board || m_board->IsLayerVisible( aLayer ) || m_Cfg->m_Render.realistic
|| m_board->IsFootprintHolder();
default:
// the layer is an internal copper layer, used the visibility
return m_board && m_board->IsLayerVisible( aLayer );
}
}
bool BOARD_ADAPTER::IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const
{
if( m_IsPreviewer ) // In panel Preview, footprints are always shown, of course
return true;
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;
}
int BOARD_ADAPTER::GetHolePlatingThickness() const noexcept
{
return m_board ? m_board->GetDesignSettings().GetHolePlatingThickness()
: DEFAULT_COPPER_THICKNESS;
}
unsigned int BOARD_ADAPTER::GetCircleSegmentCount( float aDiameter3DU ) const
{
wxASSERT( aDiameter3DU > 0.0f );
return GetCircleSegmentCount( (int)( aDiameter3DU / m_biuTo3Dunits ) );
}
unsigned int BOARD_ADAPTER::GetCircleSegmentCount( int aDiameterBIU ) const
{
wxASSERT( aDiameterBIU > 0 );
return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, FULL_CIRCLE );
}
void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningReporter )
{
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Build board outline" ) );
wxString msg;
const bool haveOutline = createBoardPolygon( &msg );
if( aWarningReporter )
{
if( !haveOutline )
aWarningReporter->Report( msg, RPT_SEVERITY_WARNING );
else
aWarningReporter->Report( wxEmptyString );
}
BOX2I bbbox;
if( m_board )
{
bbbox = m_board->ComputeBoundingBox( !m_board->IsFootprintHolder()
&& m_Cfg->m_Render.realistic
&& haveOutline );
}
// Gives a non null size to avoid issues in zoom / scale calculations
if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
bbbox.Inflate( pcbIUScale.mmToIU( 10 ) );
m_boardSize = bbbox.GetSize();
m_boardPos = bbbox.Centre();
wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
m_copperLayersCount = m_board ? m_board->GetCopperLayerCount() : 2;
// Ensure the board has 2 sides for 3D views, because it is hard to find
// a *really* single side board in the true life...
if( m_copperLayersCount < 2 )
m_copperLayersCount = 2;
// 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;
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;
}
}
// 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)
// ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
// | | Top = Bottom + m_copperThickness
// |__________________________________|
// == == == == <- Bottom = -m_epoxyThickness / 2.0,
// Top = Bottom - m_copperThickness
unsigned int layer;
for( layer = 0; layer < m_copperLayersCount; ++layer )
{
// This approximates internal layer positions (because we're treating all the dielectric
// layers as having the same thickness). But we don't render them anyway so it doesn't
// really matter.
m_layerZcoordBottom[layer] = m_boardBodyThickness3DU / 2.0f -
(m_boardBodyThickness3DU * layer / (m_copperLayersCount - 1) );
if( layer < (m_copperLayersCount / 2) )
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] + m_frontCopperThickness3DU;
else
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] - m_backCopperThickness3DU;
}
#define layerThicknessMargin 1.1
const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
// Fill remaining unused copper layers and back layer zpos with -m_boardBodyThickness / 2.0
for( ; layer < MAX_CU_LAYERS; layer++ )
{
m_layerZcoordBottom[layer] = -( m_boardBodyThickness3DU / 2.0f );
m_layerZcoordTop[layer] = -( m_boardBodyThickness3DU / 2.0f ) - m_backCopperThickness3DU;
}
// This is the top of the copper layer thickness.
const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
// calculate z position for each non copper layer
// Solder mask and Solder paste have the same Z position
for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
{
float zposTop;
float zposBottom;
switch( layer_id )
{
case B_Adhes:
zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
zposTop = zposBottom - m_nonCopperLayerThickness3DU;
break;
case F_Adhes:
zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
zposTop = zposBottom + m_nonCopperLayerThickness3DU;
break;
case B_Mask:
zposBottom = zpos_copperTop_back;
zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
break;
case B_Paste:
zposBottom = zpos_copperTop_back;
zposTop = zpos_copperTop_back - m_solderPasteLayerThickness3DU;
break;
case F_Mask:
zposBottom = zpos_copperTop_front;
zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
break;
case F_Paste:
zposBottom = zpos_copperTop_front;
zposTop = zpos_copperTop_front + m_solderPasteLayerThickness3DU;
break;
case B_SilkS:
zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
zposTop = zposBottom - m_nonCopperLayerThickness3DU;
break;
case F_SilkS:
zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
zposTop = zposBottom + m_nonCopperLayerThickness3DU;
break;
// !TODO: review
default:
zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
zposBottom = zposTop - m_nonCopperLayerThickness3DU;
break;
}
m_layerZcoordTop[layer_id] = zposTop;
m_layerZcoordBottom[layer_id] = zposBottom;
}
m_boardCenter = SFVEC3F( m_boardPos.x * m_biuTo3Dunits, m_boardPos.y * m_biuTo3Dunits, 0.0f );
SFVEC3F boardSize = SFVEC3F( m_boardSize.x * m_biuTo3Dunits, m_boardSize.y * m_biuTo3Dunits,
0.0f );
boardSize /= 2.0f;
SFVEC3F boardMin = ( m_boardCenter - boardSize );
SFVEC3F boardMax = ( m_boardCenter + boardSize );
boardMin.z = m_layerZcoordTop[B_Adhes];
boardMax.z = m_layerZcoordTop[F_Adhes];
m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
#endif
if( aStatusReporter )
aStatusReporter->Report( _( "Create layers" ) );
createLayers( aStatusReporter );
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
auto to_SFVEC4F =
[]( const COLOR4D& src )
{
return SFVEC4F( src.r, src.g, src.b, src.a );
};
m_BgColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_TOP ) );
m_BgColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ) );
m_SolderPasteColor = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERPASTE ) );
if( m_board && colors->GetUseBoardStackupColors() )
{
const BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor();
auto findColor =
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
{
if( aColorName.StartsWith( wxT( "#" ) ) )
{
return KIGFX::COLOR4D( aColorName );
}
else
{
for( const CUSTOM_COLOR_ITEM& color : aColorSet )
{
if( color.m_ColorName == aColorName )
return color.m_Color;
}
}
return KIGFX::COLOR4D();
};
m_SilkScreenColorTop = to_SFVEC4F( g_DefaultSilkscreen );
m_SilkScreenColorBot = to_SFVEC4F( g_DefaultSilkscreen );
m_SolderMaskColorTop = to_SFVEC4F( g_DefaultSolderMask );
m_SolderMaskColorBot = to_SFVEC4F( g_DefaultSolderMask );
KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
for( const BOARD_STACKUP_ITEM* stackupItem : stackup.GetList() )
{
wxString colorName = stackupItem->GetColor();
switch( stackupItem->GetType() )
{
case BS_ITEM_TYPE_SILKSCREEN:
if( stackupItem->GetBrdLayerId() == F_SilkS )
m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
else
m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
break;
case BS_ITEM_TYPE_SOLDERMASK:
if( stackupItem->GetBrdLayerId() == F_Mask )
m_SolderMaskColorTop = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
else
m_SolderMaskColorBot = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
break;
case BS_ITEM_TYPE_DIELECTRIC:
{
KIGFX::COLOR4D layerColor = findColor( colorName, g_BoardColors );
if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
bodyColor = layerColor;
else
bodyColor = bodyColor.Mix( layerColor, 1.0 - layerColor.a );
bodyColor.a += ( 1.0 - bodyColor.a ) * layerColor.a / 2;
break;
}
default:
break;
}
}
if( bodyColor != COLOR4D( 0, 0, 0, 0 ) )
m_BoardBodyColor = to_SFVEC4F( bodyColor );
else
m_BoardBodyColor = to_SFVEC4F( g_DefaultBoardBody );
const wxString& finishName = stackup.m_FinishType;
if( finishName.EndsWith( wxT( "OSP" ) ) )
{
m_CopperColor = to_SFVEC4F( findColor( wxT( "Copper" ), g_FinishColors ) );
}
else if( finishName.EndsWith( wxT( "IG" ) )
|| finishName.EndsWith( wxT( "gold" ) ) )
{
m_CopperColor = to_SFVEC4F( findColor( wxT( "Gold" ), g_FinishColors ) );
}
else if( finishName.StartsWith( wxT( "HAL" ) )
|| finishName.StartsWith( wxT( "HASL" ) )
|| finishName.EndsWith( wxT( "tin" ) )
|| finishName.EndsWith( wxT( "nickel" ) ) )
{
m_CopperColor = to_SFVEC4F( findColor( wxT( "Tin" ), g_FinishColors ) );
}
else if( finishName.EndsWith( wxT( "silver" ) ) )
{
m_CopperColor = to_SFVEC4F( findColor( wxT( "Silver" ), g_FinishColors ) );
}
else
{
m_CopperColor = to_SFVEC4F( g_DefaultSurfaceFinish );
}
}
else
{
m_SilkScreenColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ) );
m_SilkScreenColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ) );
m_SolderMaskColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_BOTTOM ) );
m_SolderMaskColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ) );
m_CopperColor = to_SFVEC4F( colors->GetColor( LAYER_3D_COPPER ) );
m_BoardBodyColor = to_SFVEC4F( colors->GetColor( LAYER_3D_BOARD ) );
}
}
bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
{
m_board_poly.RemoveAllContours();
if( !m_board )
return false;
bool success;
if( m_board->IsFootprintHolder() )
{
if( !m_board->GetFirstFootprint() )
{
if( aErrorMsg )
*aErrorMsg = _( "No footprint loaded." );
return false;
}
// max dist from one endPt to next startPt
int chainingEpsilon = m_board->GetOutlinesChainingEpsilon();
success = BuildFootprintPolygonOutlines( m_board, m_board_poly,
m_board->GetDesignSettings().m_MaxError,
chainingEpsilon );
// Make polygon strictly simple to avoid issues (especially in 3D viewer)
m_board_poly.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
if( !success && aErrorMsg )
{
*aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
"a full analysis." );
}
}
else
{
success = m_board->GetBoardPolygonOutlines( m_board_poly );
if( !success && aErrorMsg )
*aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
}
return success;
}
float BOARD_ADAPTER::GetFootprintZPos( bool aIsFlipped ) const
{
if( aIsFlipped )
{
if( m_Cfg->m_Render.show_solderpaste )
return m_layerZcoordBottom[B_SilkS];
else
return m_layerZcoordBottom[B_Paste];
}
else
{
if( m_Cfg->m_Render.show_solderpaste )
return m_layerZcoordTop[F_SilkS];
else
return m_layerZcoordTop[F_Paste];
}
}
SFVEC4F BOARD_ADAPTER::GetLayerColor( PCB_LAYER_ID aLayerId ) const
{
wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
const COLOR4D color = m_colors->GetColor( aLayerId );
return SFVEC4F( color.r, color.g, color.b, color.a );
}
SFVEC4F BOARD_ADAPTER::GetItemColor( int aItemId ) const
{
return GetColor( m_colors->GetColor( aItemId ) );
}
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;
}
-493
View File
@@ -1,493 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef BOARD_ADAPTER_H
#define BOARD_ADAPTER_H
#include <array>
#include <vector>
#include "../3d_rendering/raytracing/accelerators/container_2d.h"
#include "../3d_rendering/raytracing/accelerators/container_3d.h"
#include "../3d_rendering/raytracing/shapes3D/bbox_3d.h"
#include "../3d_rendering/camera.h"
#include "../3d_enums.h"
#include "../3d_cache/3d_cache.h"
#include "../common_ogl/ogl_attr_list.h"
#include "../3d_viewer/eda_3d_viewer_settings.h"
#include <layer_ids.h>
#include <pad.h>
#include <pcb_track.h>
#include <pcb_base_frame.h>
#include <pcb_text.h>
#include <pcb_shape.h>
#include <pcb_dimension.h>
#include <zone.h>
#include <footprint.h>
#include <reporter.h>
#include <dialogs/dialog_color_picker.h>
class COLOR_SETTINGS;
class PCB_TEXTBOX;
/// A type that stores a container of 2d objects for each layer id
typedef std::map<PCB_LAYER_ID, BVH_CONTAINER_2D*> MAP_CONTAINER_2D_BASE;
/// A type that stores polysets for each layer id
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
/// -(RANGE_SCALE_3D/2) .. +(RANGE_SCALE_3D/2)
#define RANGE_SCALE_3D 8.0f
/**
* Helper class to handle information needed to display 3D board.
*/
class BOARD_ADAPTER
{
public:
BOARD_ADAPTER();
~BOARD_ADAPTER();
/**
* Update the cache manager pointer.
*
* @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; }
/**
* Check if a layer is enabled.
*
* @param aLayer layer ID to get status.
*/
bool Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const;
/**
* Test if footprint should be displayed in relation to attributes and the flags.
*/
bool IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const;
/**
* Set current board to be rendered.
*
* @param aBoard board to process.
*/
void SetBoard( BOARD* aBoard ) noexcept { m_board = aBoard; }
const BOARD* GetBoard() const noexcept { return m_board; }
void ReloadColorSettings() noexcept;
/**
* Function to be called by the render when it need to reload the settings for the board.
*
* @param aStatusReporter the pointer for the status reporter.
* @param aWarningReporter pointer for the warning reporter.
*/
void InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningReporter );
/**
* Board integer units To 3D units.
*
* @return the conversion factor to transform a position from the board to 3D units.
*/
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; }
/**
* Get the board body thickness, including internal copper layers (in 3D units).
*/
float GetBoardBodyThickness() const noexcept { return m_boardBodyThickness3DU; }
/**
* Get the non copper layers thickness (in 3D units).
*/
float GetNonCopperLayerThickness() const noexcept { return m_nonCopperLayerThickness3DU; }
/**
* Get the copper layer thicknesses (in 3D units).
*/
float GetFrontCopperThickness() const noexcept { return m_frontCopperThickness3DU; }
float GetBackCopperThickness() const noexcept { return m_backCopperThickness3DU; }
/**
* Get the hole plating thickness (NB: in BOARD UNITS!).
*/
int GetHolePlatingThickness() const noexcept;
/**
* Get the board size.
*
* @return size in BIU units.
*/
VECTOR2I GetBoardSize() const noexcept { return m_boardSize; }
/**
* Get the board center.
*
* @return position in BIU units.
*/
VECTOR2I 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; }
/**
* Get the position of the footprint in 3d integer units considering if it is flipped or not.
*
* @param aIsFlipped true for use in footprints on Front (top) layer, false
* if footprint is on back (bottom) layer.
* @return the Z position of 3D shapes, in 3D integer units.
*/
float GetFootprintZPos( bool aIsFlipped ) const ;
/**
* Get the current polygon of the epoxy board.
*
* @return the shape polygon
*/
const SHAPE_POLY_SET& GetBoardPoly() const noexcept { return m_board_poly; }
/**
* Get the technical color of a layer.
*
* @param aLayerId the layer to get the color information.
* @return the color in SFVEC3F format.
*/
SFVEC4F GetLayerColor( PCB_LAYER_ID aLayerId ) const;
/**
* Get the technical color of a layer.
*
* @param aItemId the item id to get the color information.
* @return the color in SFVEC3F format.
*/
SFVEC4F GetItemColor( int aItemId ) const;
/**
* @param[in] aColor is the color mapped.
* @return the color in SFVEC3F format
*/
SFVEC4F GetColor( const COLOR4D& aColor ) const;
SFVEC2F GetSphericalCoord( int i ) const;
/**
* Get the top z position.
*
* @param aLayerId layer id.
* @return position in 3D units.
*/
float GetLayerTopZPos( PCB_LAYER_ID aLayerId ) const noexcept
{
return m_layerZcoordTop[aLayerId];
}
/**
* Get the bottom z position.
*
* @param aLayerId layer id.
* @return position in 3D units.
*/
float GetLayerBottomZPos( PCB_LAYER_ID aLayerId ) const noexcept
{
return m_layerZcoordBottom[aLayerId];
}
/**
* Get the map of containers that have the objects per layer.
*
* @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& 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; }
/**
* Get through hole outside diameter 2D polygons.
*
* The outside diameter 2D polygon is the hole diameter plus the plating thickness.
*
* @return a container with through hold outside diameter 2D polygons.
*/
const SHAPE_POLY_SET& GetThroughHoleOdPolys() const noexcept
{
return m_throughHoleOdPolys;
}
const BVH_CONTAINER_2D& GetThroughHoleAnnularRings() const noexcept
{
return m_throughHoleAnnularRings;
}
const SHAPE_POLY_SET& GetThroughHoleAnnularRingPolys() const noexcept
{
return m_throughHoleAnnularRingPolys;
}
const SHAPE_POLY_SET& GetOuterNonPlatedThroughHolePoly() const noexcept
{
return m_nonPlatedThroughHoleOdPolys;
}
/**
* @return a container with through hole via hole outside diameters.
*/
const BVH_CONTAINER_2D& GetThroughHoleViaOds() const noexcept
{
return m_throughHoleViaOds;
}
const SHAPE_POLY_SET& GetThroughHoleViaOdPolys() const noexcept
{
return m_throughHoleViaOdPolys;
}
unsigned int GetViaCount() const noexcept { return m_viaCount; }
unsigned int GetHoleCount() const noexcept { return m_holeCount; }
/**
* @return via hole average diameter dimension in 3D units.
*/
float GetAverageViaHoleDiameter() const noexcept { return m_averageViaHoleDiameter; }
/**
* @return the average diameter of through holes in 3D units.
*/
float GetAverageHoleDiameter() const noexcept { return m_averageHoleDiameter; }
/**
* @return average track width in 3D units.
*/
float GetAverageTrackWidth() const noexcept { return m_averageTrackWidth; }
/**
* @param aDiameter3DU diameter in 3DU.
* @return number of sides that should be used in a circle with \a aDiameter3DU.
*/
unsigned int GetCircleSegmentCount( float aDiameter3DU ) const;
/**
* @param aDiameterBIU diameter in board internal units.
* @return number of sides that should be used in circle with \a aDiameterBIU.
*/
unsigned int GetCircleSegmentCount( int aDiameterBIU ) const;
/**
* Get map of polygon's layers.
*
* @return the map with polygon's layers.
*/
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; }
private:
/**
* Create the board outline polygon.
*
* @return false if the outline could not be created
*/
bool createBoardPolygon( wxString* aErrorMsg );
void createLayers( REPORTER* aStatusReporter );
void destroyLayers();
// Helper functions to create the board
void createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer );
void createPadWithMargin( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayer, const VECTOR2I& aMargin ) const;
OBJECT_2D* createPadWithDrill( const PAD* aPad, int aInflateValue );
void addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, bool aSkipPlatedPads, bool aSkipNonPlatedPads );
void addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId );
void addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
const BOARD_ITEM* aItem );
void addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner );
void addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D_BASE* aDstContainer,
const BOARD_ITEM* aOwner );
void addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner );
void addSolidAreasShapes( const ZONE* aZone, 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 buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer, int aWidth );
// Helper functions to create poly contours
void buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aBuffer, int aWidth) const;
void transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aBuffer ) const;
public:
static CUSTOM_COLORS_LIST g_SilkscreenColors;
static CUSTOM_COLORS_LIST g_MaskColors;
static CUSTOM_COLORS_LIST g_PasteColors;
static CUSTOM_COLORS_LIST g_FinishColors;
static CUSTOM_COLORS_LIST g_BoardColors;
static KIGFX::COLOR4D g_DefaultBackgroundTop;
static KIGFX::COLOR4D g_DefaultBackgroundBot;
static KIGFX::COLOR4D g_DefaultSilkscreen;
static KIGFX::COLOR4D g_DefaultSolderMask;
static KIGFX::COLOR4D g_DefaultSolderPaste;
static KIGFX::COLOR4D g_DefaultSurfaceFinish;
static KIGFX::COLOR4D g_DefaultBoardBody;
public:
EDA_3D_VIEWER_SETTINGS* m_Cfg;
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
SFVEC4F m_BgColorBot; ///< background bottom color
SFVEC4F m_BgColorTop; ///< background top color
SFVEC4F m_BoardBodyColor; ///< in realistic mode: FR4 board color
SFVEC4F m_SolderMaskColorBot; ///< in realistic mode: solder mask color ( bot )
SFVEC4F m_SolderMaskColorTop; ///< in realistic mode: solder mask color ( top )
SFVEC4F m_SolderPasteColor; ///< in realistic mode: solder paste color
SFVEC4F m_SilkScreenColorBot; ///< in realistic mode: SilkScreen color ( bot )
SFVEC4F m_SilkScreenColorTop; ///< in realistic mode: SilkScreen color ( top )
SFVEC4F m_CopperColor; ///< in realistic mode: copper color
private:
BOARD* m_board;
S3D_CACHE* m_3dModelManager;
RENDER_SETTINGS* m_renderSettings;
COLOR_SETTINGS* m_colors;
VECTOR2I m_boardPos; ///< Board center position in board internal units.
VECTOR2I m_boardSize; ///< Board size in board internal units.
SFVEC3F m_boardCenter; ///< 3D center position of the board in 3D units.
BBOX_3D m_boardBoundingBox; ///< 3D bounding box of the board in 3D units.
MAP_POLY m_layers_poly; ///< Amalgamated polygon contours for various types of
///< items
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)
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys; ///< NPTH outer diameters
SHAPE_POLY_SET m_throughHoleOdPolys; ///< PTH outer diameters
SHAPE_POLY_SET m_throughHoleViaOdPolys; ///< Via hole outer diameters
SHAPE_POLY_SET m_throughHoleAnnularRingPolys; ///< Via annular ring outer diameters
SHAPE_POLY_SET m_board_poly; ///< Board outline polygon.
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
unsigned int m_copperLayersCount;
double m_biuTo3Dunits; ///< Scale factor to convert board internal units to
///< 3D units normalized between -1.0 and 1.0.
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordTop; ///< Top (End) Z position of each
///< layer in 3D units.
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordBottom; ///< Bottom (Start) Z position of
///< each layer in 3D units.
float m_frontCopperThickness3DU;
float m_backCopperThickness3DU;
float m_boardBodyThickness3DU;
float m_nonCopperLayerThickness3DU;
float m_solderPasteLayerThickness3DU;
unsigned int m_trackCount;
float m_averageTrackWidth;
unsigned int m_viaCount;
float m_averageViaHoleDiameter;
unsigned int m_holeCount;
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.
*/
static const wxChar* m_logTrace;
};
class EDA_3D_BOARD_HOLDER
{
public:
virtual BOARD_ADAPTER& GetAdapter() = 0;
virtual CAMERA& GetCurrentCamera() = 0;
virtual ~EDA_3D_BOARD_HOLDER() {};
};
#endif // BOARD_ADAPTER_H
@@ -1,849 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file create_graphic_brd_items.cpp
* @brief This file implements the creation of 2D graphic primitives of pcb items:
* pads, tracks, drawsegments, texts....
* It is based on the function found in the files:
* board_items_to_polygon_shape_transform.cpp
*/
#include "../3d_rendering/raytracing/shapes2D/ring_2d.h"
#include "../3d_rendering/raytracing/shapes2D/filled_circle_2d.h"
#include "../3d_rendering/raytracing/shapes2D/round_segment_2d.h"
#include "../3d_rendering/raytracing/shapes2D/triangle_2d.h"
#include "fp_textbox.h"
#include <board_adapter.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_text.h>
#include <fp_shape.h>
#include <board_design_settings.h>
#include <pcb_painter.h> // for PCB_RENDER_SETTINGS
#include <zone.h>
#include <fp_text.h>
#include <pcb_textbox.h>
#include <convert_basic_shapes_to_polygon.h>
#include <trigo.h>
#include <geometry/shape_segment.h>
#include <geometry/geometry_utils.h>
#include <geometry/shape_circle.h>
#include <geometry/shape_rect.h>
#include <geometry/shape_simple.h>
#include <utility>
#include <vector>
#include <wx/log.h>
#include <macros.h>
#include <callback_gal.h>
#define TO_3DU( x ) ( ( x ) * m_biuTo3Dunits )
#define TO_SFVEC2F( vec ) SFVEC2F( TO_3DU( vec.x ), TO_3DU( -vec.y ) )
void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aItem )
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
float penWidth_3DU = TO_3DU( aText->GetEffectiveTextPenWidth() );
KIFONT::FONT* font = aText->GetFont();
if( !font )
font = KIFONT::FONT::GetFont( wxEmptyString, aText->IsBold(), aText->IsItalic() );
if( aItem && aItem->IsKnockout() )
{
int maxError = m_board->GetDesignSettings().m_MaxError;
SHAPE_POLY_SET finalPoly;
if( aItem->Type() == PCB_FP_TEXT_T )
{
static_cast<const FP_TEXT*>( aItem )->TransformTextToPolySet( finalPoly, 0, maxError,
ERROR_INSIDE );
}
else if( aItem->Type() == PCB_TEXT_T )
{
static_cast<const PCB_TEXT*>( aItem )->TransformTextToPolySet( finalPoly, 0, maxError,
ERROR_INSIDE );
}
// Do not call finalPoly.Fracture() here: ConvertPolygonToTriangles() call it
// if needed, and Fracture() called twice can create bad results and is useless
ConvertPolygonToTriangles( finalPoly, *aContainer, m_biuTo3Dunits, *aItem );
}
else
{
CALLBACK_GAL callback_gal( empty_opts,
// Stroke callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
{
const SFVEC2F pt1_3DU = TO_SFVEC2F( aPt1 );
const SFVEC2F pt2_3DU = TO_SFVEC2F( aPt2 );
if( penWidth_3DU == 0.0 )
{
// Don't attempt to render degenerate shapes
}
else if( Is_segment_a_circle( pt1_3DU, pt2_3DU ) )
{
// Cannot add segments that have the same start and end point
aContainer->Add( new FILLED_CIRCLE_2D( pt1_3DU, penWidth_3DU / 2,
*aItem ) );
}
else
{
aContainer->Add( new ROUND_SEGMENT_2D( pt1_3DU, pt2_3DU, penWidth_3DU,
*aItem ) );
}
},
// Triangulation callback
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
{
aContainer->Add( new TRIANGLE_2D( TO_SFVEC2F( aPt1 ), TO_SFVEC2F( aPt2 ),
TO_SFVEC2F( aPt3 ), *aItem ) );
} );
attrs.m_Angle = aText->GetDrawRotation();
font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs );
}
}
void BOARD_ADAPTER::addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner )
{
addText( aDimension, aContainer, aDimension );
const int linewidth = aDimension->GetLineThickness();
for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
{
switch( shape->Type() )
{
case SH_SEGMENT:
{
const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( seg.A ), TO_SFVEC2F( seg.B ),
TO_3DU( linewidth ), *aOwner ) );
break;
}
case SH_CIRCLE:
{
int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
int delta = aDimension->GetLineThickness() / 2;
aContainer->Add( new RING_2D( TO_SFVEC2F( shape->Centre() ), TO_3DU( radius - delta ),
TO_3DU( radius + delta ), *aOwner ) );
break;
}
default:
break;
}
}
}
void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aContainer,
PCB_LAYER_ID aLayerId )
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
addText( &aFootprint->Reference(), aContainer, &aFootprint->Reference() );
if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
addText( &aFootprint->Value(), aContainer, &aFootprint->Value() );
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
switch( item->Type() )
{
case PCB_FP_TEXT_T:
{
FP_TEXT* text = static_cast<FP_TEXT*>( item );
if( text->GetLayer() == aLayerId && text->IsVisible() )
addText( text, aContainer, text );
break;
}
case PCB_FP_TEXTBOX_T:
{
FP_TEXTBOX* textbox = static_cast<FP_TEXTBOX*>( item );
if( textbox->GetLayer() == aLayerId )
{
if( textbox->IsBorderEnabled() )
addShape( textbox, aContainer, aFootprint );
addText( textbox, aContainer, aFootprint );
}
break;
}
case PCB_FP_DIM_ALIGNED_T:
case PCB_FP_DIM_CENTER_T:
case PCB_FP_DIM_ORTHOGONAL_T:
case PCB_FP_DIM_RADIAL_T:
case PCB_FP_DIM_LEADER_T:
{
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
if( dimension->GetLayer() == aLayerId )
addShape( dimension, aContainer, aFootprint );
break;
}
case PCB_FP_SHAPE_T:
{
FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
if( shape->GetLayer() == aLayerId )
addShape( shape, aContainer, aFootprint );
break;
}
default:
break;
}
}
}
void BOARD_ADAPTER::createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer )
{
SFVEC2F start3DU = TO_SFVEC2F( aTrack->GetStart() );
SFVEC2F end3DU = TO_SFVEC2F( aTrack->GetEnd() );
switch( aTrack->Type() )
{
case PCB_VIA_T:
{
const float radius3DU = TO_3DU( aTrack->GetWidth() / 2 );
if( radius3DU > 0.0 )
aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius3DU, *aTrack ) );
break;
}
case PCB_ARC_T:
{
const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
if( arc->IsDegenerated() )
{
// Draw this very small arc like a track segment (a PCB_TRACE_T)
PCB_TRACK track( arc->GetParent() );
track.SetStart( arc->GetStart() );
track.SetEnd( arc->GetEnd() );
track.SetWidth( arc->GetWidth() );
track.SetLayer( arc->GetLayer() );
createTrack( &track, aDstContainer );
return;
}
VECTOR2D center( arc->GetCenter() );
EDA_ANGLE arc_angle = arc->GetAngle();
double radius = arc->GetRadius();
int arcsegcount = GetArcToSegmentCount( radius, ARC_HIGH_DEF, arc_angle );
int circlesegcount;
// Avoid arcs that cannot be drawn
if( radius < std::numeric_limits<double>::min() || arc_angle.IsZero() )
break;
// We need a circle to segment count. However, the arc angle can be small, and the
// radius very big. so we calculate a reasonable value for circlesegcount.
if( arcsegcount <= 1 ) // The arc will be approximated by a segment
{
circlesegcount = 1;
}
else
{
circlesegcount = KiROUND( arcsegcount * 360.0 / std::abs( arc_angle.AsDegrees() ) );
circlesegcount = std::max( 1, std::min( circlesegcount, 128 ) );
}
transformArcToSegments( VECTOR2I( center.x, center.y ), arc->GetStart(), arc_angle,
circlesegcount, arc->GetWidth(), aDstContainer, *arc );
break;
}
case PCB_TRACE_T: // Track is a usual straight segment
{
if( aTrack->GetWidth() == 0 )
{
// Don't attempt to render degenerate shapes
}
else if( Is_segment_a_circle( start3DU, end3DU ) )
{
// Cannot add segments that have the same start and end point
aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aTrack->GetWidth() / 2 ),
*aTrack ) );
}
else
{
aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aTrack->GetWidth() ),
*aTrack ) );
}
break;
}
default:
break;
}
}
void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aContainer,
PCB_LAYER_ID aLayer, const VECTOR2I& aMargin ) const
{
SHAPE_POLY_SET poly;
int maxError = GetBoard()->GetDesignSettings().m_MaxError;
VECTOR2I clearance = aMargin;
// Our shape-based builder can't handle negative or differing x:y clearance values (the
// former are common for solder paste while the later get generated when a relative paste
// margin is used with an oblong pad). So we apply this huge hack and fake a larger pad to
// run the general-purpose polygon builder on.
// Of course being a hack it falls down when dealing with custom shape pads (where the size
// is only the size of the anchor), so for those we punt and just use aMargin.x.
if( ( clearance.x < 0 || clearance.x != clearance.y )
&& aPad->GetShape() != PAD_SHAPE::CUSTOM )
{
VECTOR2I dummySize = VECTOR2I( aPad->GetSize() ) + clearance + clearance;
if( dummySize.x <= 0 || dummySize.y <= 0 )
return;
PAD dummy( *aPad );
dummy.SetSize( wxSize( dummySize.x, dummySize.y ) );
dummy.TransformShapeToPolygon( poly, aLayer, 0, maxError, ERROR_INSIDE );
clearance = { 0, 0 };
}
else
{
auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
for( const SHAPE* shape : padShapes->Shapes() )
{
switch( shape->Type() )
{
case SH_SEGMENT:
{
const SHAPE_SEGMENT* seg = static_cast<const SHAPE_SEGMENT*>( shape );
const SFVEC2F a3DU = TO_SFVEC2F( seg->GetSeg().A );
const SFVEC2F b3DU = TO_SFVEC2F( seg->GetSeg().B );
const double width3DU = TO_3DU( seg->GetWidth() + clearance.x * 2 );
if( width3DU == 0.0 )
{
// Don't attempt to render degenerate shapes
}
else if( Is_segment_a_circle( a3DU, b3DU ) )
{
// Cannot add segments that have the same start and end point
aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
}
else
{
aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
}
break;
}
case SH_CIRCLE:
{
const SHAPE_CIRCLE* circle = static_cast<const SHAPE_CIRCLE*>( shape );
const double radius3DU = TO_3DU( circle->GetRadius() + clearance.x );
const SFVEC2F center3DU = TO_SFVEC2F( circle->GetCenter() );
// Don't render zero radius circles
if( radius3DU > 0.0 )
aContainer->Add( new FILLED_CIRCLE_2D( center3DU, radius3DU, *aPad ) );
break;
}
case SH_RECT:
{
const SHAPE_RECT* rect = static_cast<const SHAPE_RECT*>( shape );
poly.NewOutline();
poly.Append( rect->GetPosition() );
poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
poly.Append( rect->GetPosition() + rect->GetSize() );
poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
break;
}
case SH_SIMPLE:
poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
break;
case SH_POLY_SET:
poly = *(SHAPE_POLY_SET*) shape;
break;
case SH_ARC:
{
const SHAPE_ARC* arc = static_cast<const SHAPE_ARC*>( shape );
SHAPE_LINE_CHAIN l = arc->ConvertToPolyline( maxError );
for( int i = 0; i < l.SegmentCount(); i++ )
{
SHAPE_SEGMENT seg( l.Segment( i ).A, l.Segment( i ).B, arc->GetWidth() );
const SFVEC2F a3DU = TO_SFVEC2F( seg.GetSeg().A );
const SFVEC2F b3DU = TO_SFVEC2F( seg.GetSeg().B );
const double width3DU = TO_3DU( arc->GetWidth() + clearance.x * 2 );
if( width3DU == 0.0 )
{
// Don't attempt to render degenerate shapes
}
else if( Is_segment_a_circle( a3DU, b3DU ) )
{
// Cannot add segments that have the same start and end point
aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
}
else
{
aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
}
}
break;
}
default:
UNIMPLEMENTED_FOR( SHAPE_TYPE_asString( shape->Type() ) );
break;
}
}
}
if( !poly.IsEmpty() )
{
if( clearance.x )
poly.Inflate( clearance.x, 32 );
// Add the PAD polygon
ConvertPolygonToTriangles( poly, *aContainer, m_biuTo3Dunits, *aPad );
}
}
OBJECT_2D* BOARD_ADAPTER::createPadWithDrill( const PAD* aPad, int aInflateValue )
{
if( !aPad->HasHole() )
{
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
return nullptr;
}
std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
if( slot->GetSeg().A == slot->GetSeg().B )
{
return new FILLED_CIRCLE_2D( TO_SFVEC2F( slot->GetSeg().A ),
TO_3DU( slot->GetWidth() / 2 + aInflateValue ),
*aPad );
}
else
{
return new ROUND_SEGMENT_2D( TO_SFVEC2F( slot->GetSeg().A ),
TO_SFVEC2F( slot->GetSeg().B ),
TO_3DU( slot->GetWidth() + aInflateValue * 2 ),
*aPad );
}
}
void BOARD_ADAPTER::addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aContainer,
PCB_LAYER_ID aLayerId, bool aSkipPlatedPads, bool aSkipNonPlatedPads )
{
for( PAD* pad : aFootprint->Pads() )
{
if( !pad->IsOnLayer( aLayerId ) )
continue;
if( IsCopperLayer( aLayerId ) )
{
// Skip pad annulus when there isn't one (note: this is more discerning than
// pad->IsOnLayer(), which doesn't check for NPTH pads with holes that consume
// the entire pad).
if( !pad->IsOnCopperLayer() )
continue;
// Skip pad annulus when not connected on this layer (if removing is enabled)
if( !pad->FlashLayer( aLayerId ) )
continue;
}
VECTOR2I margin( 0, 0 );
switch( aLayerId )
{
case F_Cu:
if( aSkipPlatedPads && pad->FlashLayer( F_Mask ) )
continue;
if( aSkipNonPlatedPads && !pad->FlashLayer( F_Mask ) )
continue;
break;
case B_Cu:
if( aSkipPlatedPads && pad->FlashLayer( B_Mask ) )
continue;
if( aSkipNonPlatedPads && !pad->FlashLayer( B_Mask ) )
continue;
break;
case F_Mask:
case B_Mask:
margin.x += pad->GetSolderMaskExpansion();
margin.y += pad->GetSolderMaskExpansion();
break;
case F_Paste:
case B_Paste:
margin += pad->GetSolderPasteMargin();
break;
default:
break;
}
createPadWithMargin( pad, aContainer, aLayerId, margin );
}
}
// based on TransformArcToPolygon function from
// common/convert_basic_shapes_to_polygon.cpp
void BOARD_ADAPTER::transformArcToSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount,
int aWidth, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM& aOwner )
{
// Don't attempt to render degenerate shapes
if( aWidth == 0 )
return;
VECTOR2I arc_start, arc_end;
EDA_ANGLE arcAngle( aArcAngle );
EDA_ANGLE delta = ANGLE_360 / aCircleToSegmentsCount; // rotate angle
arc_end = arc_start = aStart;
if( arcAngle != ANGLE_360 )
RotatePoint( arc_end, aCentre, -arcAngle );
if( arcAngle < ANGLE_0 )
{
std::swap( arc_start, arc_end );
arcAngle = -arcAngle;
}
// Compute the ends of segments and creates poly
VECTOR2I curr_end = arc_start;
VECTOR2I curr_start = arc_start;
for( EDA_ANGLE ii = delta; ii < arcAngle; ii += delta )
{
curr_end = arc_start;
RotatePoint( curr_end, aCentre, -ii );
const SFVEC2F start3DU = TO_SFVEC2F( curr_start );
const SFVEC2F end3DU = TO_SFVEC2F( curr_end );
if( Is_segment_a_circle( start3DU, end3DU ) )
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
else
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
curr_start = curr_end;
}
if( curr_end != arc_end )
{
const SFVEC2F start3DU = TO_SFVEC2F( curr_end );
const SFVEC2F end3DU = TO_SFVEC2F( arc_end );
if( Is_segment_a_circle( start3DU, end3DU ) )
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
else
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
}
}
void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner )
{
// The full width of the lines to create
// The extra 1 protects the inner/outer radius values from degeneracy
const int linewidth = aShape->GetWidth() + 1;
PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
{
switch( aShape->GetShape() )
{
case SHAPE_T::CIRCLE:
{
const SFVEC2F center3DU = TO_SFVEC2F( aShape->GetCenter() );
float inner_radius3DU = TO_3DU( aShape->GetRadius() - linewidth / 2 );
float outer_radius3DU = TO_3DU( aShape->GetRadius() + linewidth / 2 );
if( inner_radius3DU < 0 )
inner_radius3DU = 0.0;
if( aShape->IsFilled() )
{
aContainer->Add( new FILLED_CIRCLE_2D( center3DU, outer_radius3DU,
*aOwner ) );
}
else if( outer_radius3DU > inner_radius3DU )
{
aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU,
*aOwner ) );
}
break;
}
case SHAPE_T::RECT:
if( aShape->IsFilled() )
{
SHAPE_POLY_SET polyList;
aShape->TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
ERROR_INSIDE );
polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
}
else
{
std::vector<VECTOR2I> pts = aShape->GetRectCorners();
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[0] ), TO_SFVEC2F( pts[1] ),
TO_3DU( linewidth ), *aOwner ) );
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[1] ), TO_SFVEC2F( pts[2] ),
TO_3DU( linewidth ), *aOwner ) );
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[2] ), TO_SFVEC2F( pts[3] ),
TO_3DU( linewidth ), *aOwner ) );
aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[3] ), TO_SFVEC2F( pts[0] ),
TO_3DU( linewidth ), *aOwner ) );
}
break;
case SHAPE_T::ARC:
{
unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
transformArcToSegments( aShape->GetCenter(), aShape->GetStart(), aShape->GetArcAngle(),
segCount, linewidth, aContainer, *aOwner );
break;
}
case SHAPE_T::SEGMENT:
{
const SFVEC2F start3DU = TO_SFVEC2F( aShape->GetStart() );
const SFVEC2F end3DU = TO_SFVEC2F( aShape->GetEnd() );
const double linewidth3DU = TO_3DU( linewidth );
if( linewidth3DU == 0.0 )
{
// Don't attempt to render degenerate shapes
}
else if( Is_segment_a_circle( start3DU, end3DU ) )
{
// Cannot add segments that have the same start and end point
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, linewidth3DU / 2, *aOwner ) );
}
else
{
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth3DU, *aOwner ) );
}
break;
}
case SHAPE_T::BEZIER:
case SHAPE_T::POLY:
{
SHAPE_POLY_SET polyList;
aShape->TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
ERROR_INSIDE );
// Some polygons can be a bit complex (especially when coming from a
// picture ot a text converted to a polygon
// So call Simplify before calling ConvertPolygonToTriangles, just in case.
polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
if( polyList.IsEmpty() ) // Just for caution
break;
ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
break;
}
default:
wxFAIL_MSG( wxT( "BOARD_ADAPTER::addShape no implementation for " )
+ aShape->SHAPE_T_asString() );
break;
}
}
else if( linewidth > 0 )
{
std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
SFVEC2F a3DU;
SFVEC2F b3DU;
double width3DU = TO_3DU( linewidth );
const PCB_PLOT_PARAMS& plotParams = aShape->GetBoard()->GetPlotOptions();
KIGFX::PCB_RENDER_SETTINGS renderSettings;
renderSettings.SetDashLengthRatio( plotParams.GetDashedLineDashRatio() );
renderSettings.SetGapLengthRatio( plotParams.GetDashedLineGapRatio() );
for( SHAPE* shape : shapes )
{
STROKE_PARAMS::Stroke( shape, lineStyle, linewidth, &renderSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b )
{
a3DU = TO_SFVEC2F( a );
b3DU = TO_SFVEC2F( b );
if( Is_segment_a_circle( a3DU, b3DU ) )
aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aOwner ) );
else
aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aOwner ) );
} );
}
for( SHAPE* shape : shapes )
delete shape;
}
}
void BOARD_ADAPTER::addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner )
{
addText( aTextBox, aContainer, aOwner );
if( !aTextBox->IsBorderEnabled() )
return;
// We cannot use PCB_TEXTBOX::TransformShapeToPolygon because it convert the textbox
// as filled polygon even if there's no background colour.
// So for polygon, we use PCB_SHAPE::TransformShapeToPolygon
if( aTextBox->GetShape() == SHAPE_T::RECT )
addShape( static_cast<const PCB_SHAPE*>( aTextBox ), aContainer, aOwner );
else
{
SHAPE_POLY_SET polyList;
aTextBox->PCB_SHAPE::TransformShapeToPolygon( polyList, UNDEFINED_LAYER, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
}
}
void BOARD_ADAPTER::addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* aContainer,
PCB_LAYER_ID aLayerId )
{
// This convert the poly in outline and holes
ConvertPolygonToTriangles( *aZone->GetFilledPolysList( aLayerId ), *aContainer,
m_biuTo3Dunits, *aZone );
}
void BOARD_ADAPTER::buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aContainer,
int aWidth )
{
if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
{
const SFVEC2F center3DU = TO_SFVEC2F( aPad->ShapePos() );
const int radius = aPad->GetSize().x / 2;
const float inner_radius3DU = TO_3DU( radius - aWidth / 2 );
const float outer_radius3DU = TO_3DU( radius + aWidth / 2 );
aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU, *aPad ) );
return;
}
// For other shapes, add outlines as thick segments in polygon buffer
const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon( ERROR_INSIDE );
const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
for( int j = 0; j < path.PointCount(); j++ )
{
SFVEC2F start3DU = TO_SFVEC2F( path.CPoint( j ) );
SFVEC2F end3DU = TO_SFVEC2F( path.CPoint( j + 1 ) );
if( aWidth == 0 )
{
// Don't attempt to render degenerate shapes
}
else if( Is_segment_a_circle( start3DU, end3DU ) )
{
// Cannot add segments that have the same start and end point
aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), *aPad ) );
}
else
{
aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), *aPad ) );
}
}
}
File diff suppressed because it is too large Load Diff
-89
View File
@@ -1,89 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file create_layer_poly.cpp
* @brief This file implements the creation of the pcb board items in the poly
* contours format.
*/
#include "board_adapter.h"
#include <board_design_settings.h>
#include <convert_basic_shapes_to_polygon.h>
#include <fp_shape.h>
#include <footprint.h>
/*
* This is used to draw pad outlines on silk layers.
*/
void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aBuffer,
int aWidth ) const
{
int maxError = m_board->GetDesignSettings().m_MaxError;
if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
{
TransformRingToPolygon( aBuffer, aPad->ShapePos(), aPad->GetSize().x / 2, aWidth, maxError,
ERROR_INSIDE );
return;
}
// For other shapes, add outlines as thick segments in polygon buffer
const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon( ERROR_INSIDE );
const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
for( int ii = 0; ii < path.PointCount(); ++ii )
{
const VECTOR2I& a = path.CPoint( ii );
const VECTOR2I& b = path.CPoint( ii + 1 );
TransformOvalToPolygon( aBuffer, a, b, aWidth, maxError, ERROR_INSIDE );
}
}
void BOARD_ADAPTER::transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aBuffer ) const
{
int maxError = m_board->GetDesignSettings().m_MaxError;
for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
if( item->Type() == PCB_FP_SHAPE_T )
{
FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
if( shape->GetLayer() == aLayer )
shape->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
}
else if( BaseType( item->Type() ) == PCB_DIMENSION_T )
{
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
if( dimension->GetLayer() == aLayer )
dimension->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
}
}
}
File diff suppressed because it is too large Load Diff
-340
View File
@@ -1,340 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef EDA_3D_CANVAS_H
#define EDA_3D_CANVAS_H
#include <atomic>
#include "board_adapter.h"
#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 <wx/image.h>
#include <wx/timer.h>
class WX_INFOBAR;
class wxStatusBar;
class BOARD;
class RENDER_3D_RAYTRACE;
class RENDER_3D_OPENGL;
/**
* Implement a canvas based on a wxGLCanvas
*/
class EDA_3D_CANVAS : public HIDPI_GL_3D_CANVAS
{
public:
/**
* Create a new 3D Canvas with an attribute list.
*
* @param aParent the parent creator of this canvas.
* @param aAttribList a list of openGL options created by GetOpenGL_AttributesList.
* @param aBoard The board.
* @param aSettings the settings options to be used by this canvas.
*/
EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList,
BOARD_ADAPTER& aSettings, CAMERA& aCamera, S3D_CACHE* a3DCachePointer );
~EDA_3D_CANVAS();
/**
* Set a dispatcher that processes events and forwards them to tools.
*
* #DRAW_PANEL_GAL does not take over the ownership. Passing NULL disconnects all event
* handlers from the DRAW_PANEL_GAL and parent frame.
*
* @param aEventDispatcher is the object that will be used for dispatching events.
*/
void SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher );
void SetStatusBar( wxStatusBar* aStatusBar )
{
m_parentStatusBar = aStatusBar;
}
void SetInfoBar( WX_INFOBAR* aInfoBar )
{
m_parentInfoBar = aInfoBar;
}
void ReloadRequest( BOARD* aBoard = nullptr, S3D_CACHE* aCachePointer = nullptr );
/**
* Query if there is a pending reload request.
*
* @return true if it wants to reload, false if there is no reload pending.
*/
bool IsReloadRequestPending() const
{
if( m_3d_render )
return m_3d_render->IsReloadRequestPending();
else
return false;
}
/**
* @return the current render ( a RENDER_3D_RAYTRACE* or a RENDER_3D_OPENGL* render )
*/
RENDER_3D_BASE* GetCurrentRender() const { return m_3d_render; }
/**
* Request to render the current view in Raytracing mode.
*/
void RenderRaytracingRequest();
/**
* Request a screenshot and output it to the \a aDstImage
*
* @param aDstImage - Screenshot destination image
*/
void GetScreenshot( wxImage& aDstImage );
/**
* Helper function to call view commands.
*
* @param aKeycode ascii key commands.
* @return true if the key code was handled, false if no command found for this code.
*/
bool SetView3D( int aKeycode );
/**
* Enable or disable camera animation when switching to a pre-defined view.
*/
void SetAnimationEnabled( bool aEnable ) { m_animation_enabled = aEnable; }
bool GetAnimationEnabled() const { return m_animation_enabled; }
/**
* Set the camera animation moving speed multiplier option.
*
* @param aMultiplier one of the possible integer options: [1,2,3,4,5].
*/
void SetMovingSpeedMultiplier( int aMultiplier ) { m_moving_speed_multiplier = aMultiplier; }
int GetMovingSpeedMultiplier() const { return m_moving_speed_multiplier; }
int GetProjectionMode() const { return (int) m_camera.GetProjection(); };
void SetProjectionMode( int aMode ) { m_camera.SetProjection( (PROJECTION_TYPE) aMode ); }
/**
* Notify that the render engine was changed.
*/
void RenderEngineChanged();
/**
* Update the status bar with the position information.
*/
void DisplayStatus();
/**
* Schedule a refresh update of the canvas.
*
* @param aRedrawImmediately true will request a redraw, false will schedule a redraw
* after a short timeout.
*/
void Request_refresh( bool aRedrawImmediately = true );
/**
* Used to forward events to the canvas from popups, etc.
*/
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;
}
/**
* The actual function to repaint the canvas.
*
* It is usually called by OnPaint() but because it does not use a wxPaintDC it can be
* called outside a wxPaintEvent
*/
void DoRePaint();
private:
// The wxPaintEvent event. mainly calls DoRePaint()
void OnPaint( wxPaintEvent& aEvent );
void OnEraseBackground( wxEraseEvent& event );
void OnRefreshRequest( wxEvent& aEvent );
void OnMouseWheel( wxMouseEvent& event );
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
void OnMagnify( wxMouseEvent& event );
#endif
void OnMouseMove( wxMouseEvent& event );
void OnLeftDown( wxMouseEvent& event );
void OnLeftUp( wxMouseEvent& event );
void OnMiddleUp( wxMouseEvent& event );
void OnMiddleDown( wxMouseEvent& event );
void OnTimerTimeout_Editing( wxTimerEvent& event );
void OnCloseWindow( wxCloseEvent& event );
void OnResize( wxSizeEvent& event );
void OnTimerTimeout_Redraw( wxTimerEvent& event );
DECLARE_EVENT_TABLE()
/**
*Stop the editing time so it will not timeout.
*/
void stop_editingTimeOut_Timer();
/**
* Reset the editing timer.
*/
void restart_editingTimeOut_Timer();
/**
* Start a camera movement.
*
* @param aMovingSpeed the time speed.
* @param aRenderPivot if it should display pivot cursor while move.
*/
void request_start_moving_camera( float aMovingSpeed = 2.0f, bool aRenderPivot = true );
/**
* This function hits a ray to the board and start a movement.
*/
void move_pivot_based_on_cur_mouse_position();
/**
* Render the pivot cursor.
*
* @param t time between 0.0 and 1.0.
* @param aScale scale to apply on the cursor.
*/
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.
*/
bool initializeOpenGL();
/**
* Free created targets and openGL context.
*/
void releaseOpenGL();
RAY getRayAtCurrentMousePosition();
private:
TOOL_DISPATCHER* m_eventDispatcher;
wxStatusBar* m_parentStatusBar; // Parent statusbar to report progress
WX_INFOBAR* m_parentInfoBar;
wxGLContext* m_glRC; // Current OpenGL context
bool m_is_opengl_initialized;
bool m_is_opengl_version_supported;
wxTimer m_editing_timeout_timer; // Expires after some time signaling that
// the mouse / keyboard movements are over
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_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
bool m_animation_enabled; // Camera animation enabled
int m_moving_speed_multiplier; // Camera animation speed multiplier option
BOARD_ADAPTER& m_boardAdapter; // Pre-computed 3D info and settings
RENDER_3D_BASE* m_3d_render;
RENDER_3D_RAYTRACE* m_3d_render_raytracing;
RENDER_3D_OPENGL* m_3d_render_opengl;
bool m_opengl_supports_raytracing;
bool m_render_raytracing_was_requested;
ACCELERATOR_3D* m_accelerator3DShapes; // used for mouse over searching
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
* "KI_TRACE_EDA_3D_CANVAS". See the wxWidgets documentation on wxLogTrace for
* more information.
*/
static const wxChar* m_logTrace;
};
#endif // EDA_3D_CANVAS_H
-161
View File
@@ -1,161 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eda_3d_canvas_pivot.cpp
* @brief Implementation of a 3d cursor
*/
#include "../common_ogl/openGL_includes.h"
#include "../common_ogl/ogl_utils.h"
#include "eda_3d_canvas.h"
static void pivot_render_triangles( float t )
{
wxASSERT( t >= 0.0f );
SFVEC3F vertexPointer[12];
const float u = 1.0f / 6.0f;
vertexPointer[0] = SFVEC3F( ( -3.0f + t ) * u, -2.0f * u, 0.0f );
vertexPointer[1] = SFVEC3F( ( -3.0f + t ) * u, 2.0f * u, 0.0f );
vertexPointer[2] = SFVEC3F( ( -1.0f + t ) * u, 0.0f * u, 0.0f );
vertexPointer[3] = SFVEC3F( -2.0f * u, ( -3.0f + t ) * u, 0.0f );
vertexPointer[4] = SFVEC3F( 2.0f * u, ( -3.0f + t ) * u, 0.0f );
vertexPointer[5] = SFVEC3F( 0.0f * u, ( -1.0f + t ) * u, 0.0f );
vertexPointer[6] = SFVEC3F( ( 3.0f - t ) * u, -2.0f * u, 0.0f );
vertexPointer[7] = SFVEC3F( ( 3.0f - t ) * u, 2.0f * u, 0.0f );
vertexPointer[8] = SFVEC3F( ( 1.0f - t ) * u, 0.0f * u, 0.0f );
vertexPointer[9] = SFVEC3F( 2.0f * u, ( 3.0f - t ) * u, 0.0f );
vertexPointer[10] = SFVEC3F( -2.0f * u, ( 3.0f - t ) * u, 0.0f );
vertexPointer[11] = SFVEC3F( 0.0f * u, ( 1.0f - t ) * u, 0.0f );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, vertexPointer );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glDrawArrays( GL_TRIANGLES, 0, 4 * 3 );
glDisable( GL_BLEND );
glDisableClientState( GL_VERTEX_ARRAY );
}
void EDA_3D_CANVAS::render_pivot( float t, float aScale )
{
wxASSERT( aScale >= 0.0f );
wxASSERT( t >= 0.0f );
if( t > 1.0f )
t = 1.0f;
const SFVEC3F &lookAtPos = m_camera.GetLookAtPos_T1();
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, 1.0f, 0.0f, 0.75f - t * 0.75f );
// Translate to the look at position
glTranslatef( lookAtPos.x, lookAtPos.y, lookAtPos.z );
glScalef( aScale, aScale, aScale );
pivot_render_triangles( t * 0.5f );
t = t * 0.80f;
glScalef( 1.0f - t, 1.0f - t, 1.0f - t );
glColor4f( 0.0f, 1.0f, 0.0f, 0.8f - t );
glPushMatrix();
glRotatef( t * 90.0f, 0.0f, 0.0f, 1.0f );
pivot_render_triangles( t * 0.5f );
glPopMatrix();
glPushMatrix();
glRotatef( -t * 90.0f, 0.0f, 0.0f, 1.0f );
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 );
}
+179
View File
@@ -0,0 +1,179 @@
/**
* @file 3d_class.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <3d_viewer.h>
S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
EDA_ITEM( father, NOT_USED )
{
m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0;
m_SpecularColor.x = m_SpecularColor.y = m_SpecularColor.z = 1.0;
m_AmbientIntensity = 1.0;
m_Transparency = 0.0;
m_Shininess = 1.0;
m_Name = name;
}
void S3D_MATERIAL::SetMaterial()
{
S3D_MASTER * s3dParent = (S3D_MASTER *) GetParent();
s3dParent->SetLastTransparency( m_Transparency );
if( ! s3dParent->IsOpenGlAllowed() )
return;
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glColor4f( m_DiffuseColor.x * m_AmbientIntensity,
m_DiffuseColor.y * m_AmbientIntensity,
m_DiffuseColor.z * m_AmbientIntensity,
1.0 - m_Transparency );
#if 0
glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR );
glColor3f( m_SpecularColor.x, m_SpecularColor.y, m_SpecularColor.z );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
#endif
}
bool S3D_MASTER::IsOpenGlAllowed()
{
if( m_loadNonTransparentObjects ) // return true for non transparent objects only
{
if( m_lastTransparency == 0.0 )
return true;
}
if( m_loadTransparentObjects ) // return true for transparent objects only
if( m_lastTransparency != 0.0 )
return true;
return false;
}
void S3D_MASTER::Insert( S3D_MATERIAL* aMaterial )
{
aMaterial->SetNext( m_Materials );
m_Materials = aMaterial;
}
void S3D_MASTER::Copy( S3D_MASTER* pattern )
{
SetShape3DName( pattern->GetShape3DName() );
m_MatScale = pattern->m_MatScale;
m_MatRotation = pattern->m_MatRotation;
m_MatPosition = pattern->m_MatPosition;
m_3D_Drawings = NULL;
m_Materials = NULL;
}
S3D_MASTER::S3D_MASTER( EDA_ITEM* aParent ) :
EDA_ITEM( aParent, NOT_USED )
{
m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0;
m_lastTransparency = 0.0;
m_3D_Drawings = NULL;
m_Materials = NULL;
m_ShapeType = FILE3D_NONE;
}
S3D_MASTER:: ~S3D_MASTER()
{
STRUCT_3D_SHAPE* next;
S3D_MATERIAL* nextmat;
for( ; m_3D_Drawings != NULL; m_3D_Drawings = next )
{
next = m_3D_Drawings->Next();
delete m_3D_Drawings;
}
for( ; m_Materials != NULL; m_Materials = nextmat )
{
nextmat = m_Materials->Next();
delete m_Materials;
}
}
bool S3D_MASTER::Is3DType( enum FILE3D_TYPE aShapeType )
{
// type 'none' is not valid and will always return false
if( aShapeType == FILE3D_NONE )
return false;
// no one is interested if we have no file
if( m_Shape3DName.empty() )
return false;
if( aShapeType == m_ShapeType )
return true;
return false;
}
void S3D_MASTER::SetShape3DName( const wxString& aShapeName )
{
m_ShapeType = FILE3D_NONE;
m_Shape3DName = aShapeName;
if( m_Shape3DName.empty() )
return;
wxFileName fn = m_Shape3DName;
wxString ext = fn.GetExt();
if( ext == wxT( "wrl" ) || ext == wxT( "x3d" ) )
m_ShapeType = FILE3D_VRML;
else if( ext == wxT( "idf" ) )
m_ShapeType = FILE3D_IDF;
else
m_ShapeType = FILE3D_UNKNOWN;
return;
}
STRUCT_3D_SHAPE::STRUCT_3D_SHAPE( EDA_ITEM* aParent ) :
EDA_ITEM( aParent, NOT_USED )
{
m_3D_Coord = NULL;
m_3D_CoordIndex = NULL;
m_3D_Points = 0;
}
STRUCT_3D_SHAPE:: ~STRUCT_3D_SHAPE()
{
delete m_3D_Coord;
delete m_3D_CoordIndex;
}
File diff suppressed because it is too large Load Diff
+419
View File
@@ -0,0 +1,419 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_draw_basic_functions.cpp
*/
#include <fctsys.h>
#include <trigo.h>
#include <convert_basic_shapes_to_polygon.h>
#include <3d_viewer.h>
#include <info3d_visu.h>
#include <3d_draw_basic_functions.h>
// Imported function:
extern void TransfertToGLlist( std::vector<S3D_VERTEX>& aVertices, double aBiuTo3DUnits );
extern void CheckGLError();
// Number of segments to approximate a circle by segments
#define SEGM_PER_CIRCLE 16
#ifndef CALLBACK
#define CALLBACK
#endif
// CALLBACK functions for GLU_TESS
static void CALLBACK tessBeginCB( GLenum which );
static void CALLBACK tessEndCB();
static void CALLBACK tessErrorCB( GLenum errorCode );
static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data );
// 2 helper functions to set the current normal vector for gle items
static inline void SetNormalZpos()
{
glNormal3f( 0.0, 0.0, 1.0 );
}
static inline void SetNormalZneg()
{
glNormal3f( 0.0, 0.0, -1.0 );
}
/* Draw3D_VerticalPolygonalCylinder is a helper function.
*
* draws a "vertical cylinder" having a polygon shape
* from Z position = aZpos to aZpos + aHeight
* Used to create the vertical sides of 3D horizontal shapes with thickness.
*/
static void Draw3D_VerticalPolygonalCylinder( const CPOLYGONS_LIST& aPolysList,
int aHeight, int aZpos,
bool aInside, double aBiuTo3DUnits )
{
if( aHeight == 0 )
return;
std::vector<S3D_VERTEX> coords;
coords.resize( 4 );
// Init Z position of the 4 points of a GL_QUAD
if( aInside )
{
coords[0].z = aZpos;
coords[1].z = aZpos + aHeight;
}
else
{
coords[0].z = aZpos + aHeight;
coords[1].z = aZpos;
}
coords[2].z = coords[1].z;
coords[3].z = coords[0].z;
// Draw the vertical polygonal side
int startContour = 0;
for( unsigned ii = 0; ii < aPolysList.GetCornersCount(); ii++ )
{
unsigned jj = ii + 1;
if( aPolysList.IsEndContour( ii ) || jj >= aPolysList.GetCornersCount() )
{
jj = startContour;
startContour = ii + 1;
}
// Build the 4 vertices of each GL_QUAD
coords[0].x = aPolysList.GetX( ii );
coords[0].y = -aPolysList.GetY( ii );
coords[1].x = coords[0].x;
coords[1].y = coords[0].y; // only z change
coords[2].x = aPolysList.GetX( jj );
coords[2].y = -aPolysList.GetY( jj );
coords[3].x = coords[2].x;
coords[3].y = coords[2].y; // only z change
// Creates the GL_QUAD
TransfertToGLlist( coords, aBiuTo3DUnits );
}
}
void SetGLColor( EDA_COLOR_T color, double alpha )
{
double red, green, blue;
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
red = colordata.m_Red / 255.0;
blue = colordata.m_Blue / 255.0;
green = colordata.m_Green / 255.0;
glColor4f( red, green, blue, alpha );
}
/* draw all solid polygons found in aPolysList
* aZpos = z position in board internal units
* aThickness = thickness in board internal units
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits )
{
GLUtesselator* tess = gluNewTess();
gluTessCallback( tess, GLU_TESS_BEGIN, ( void (CALLBACK*) () )tessBeginCB );
gluTessCallback( tess, GLU_TESS_END, ( void (CALLBACK*) () )tessEndCB );
gluTessCallback( tess, GLU_TESS_ERROR, ( void (CALLBACK*) () )tessErrorCB );
gluTessCallback( tess, GLU_TESS_VERTEX, ( void (CALLBACK*) () )tessCPolyPt2Vertex );
GLdouble v_data[3];
double zpos = ( aZpos + (aThickness / 2) ) * aBiuTo3DUnits;
g_Parm_3D_Visu.m_CurrentZpos = zpos;
v_data[2] = aZpos + (aThickness / 2);
// Set normal to toward positive Z axis, for a solid object only (to draw the top side)
if( aThickness )
SetNormalZpos();
// gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
// Draw solid areas contained in this list
CPOLYGONS_LIST polylist = aPolysList; // temporary copy for gluTessVertex
for( int side = 0; side < 2; side++ )
{
int startContour = 1;
for( unsigned ii = 0; ii < polylist.GetCornersCount(); ii++ )
{
if( startContour == 1 )
{
gluTessBeginPolygon( tess, NULL );
gluTessBeginContour( tess );
startContour = 0;
}
v_data[0] = polylist.GetX( ii ) * aBiuTo3DUnits;
v_data[1] = -polylist.GetY( ii ) * aBiuTo3DUnits;
// gluTessVertex store pointers on data, not data, so do not store
// different corners values in a temporary variable
// but send pointer on each CPolyPt value in polylist
// before calling gluDeleteTess
gluTessVertex( tess, v_data, &polylist[ii] );
if( polylist.IsEndContour( ii ) )
{
gluTessEndContour( tess );
gluTessEndPolygon( tess );
startContour = 1;
}
}
if( aThickness == 0 )
break;
// Prepare the bottom side of solid areas
zpos = ( aZpos - (aThickness / 2) ) * aBiuTo3DUnits;
g_Parm_3D_Visu.m_CurrentZpos = zpos;
v_data[2] = zpos;
// Now;, set normal to toward negative Z axis, for the solid object bottom side
SetNormalZneg();
}
gluDeleteTess( tess );
if( aThickness == 0 )
return;
// Build the 3D data : vertical side
Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2), false, aBiuTo3DUnits );
}
/* draw the solid polygon found in aPolysList
* The first polygon is the main polygon, others are holes
* See Draw3D_SolidHorizontalPolyPolygons for more info
*/
void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness,
double aBiuTo3DUnits )
{
CPOLYGONS_LIST polygon;
ConvertPolysListWithHolesToOnePolygon( aPolysList, polygon );
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, aThickness, aBiuTo3DUnits );
}
/* draw a cylinder (a tube) using 3D primitives.
* the cylinder axis is parallel to the Z axis
* If aHeight = height of the cylinder is 0, only one ring will be drawn
* If aThickness = 0, only one cylinder will be drawn
*/
void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
int aHeight, int aThickness,
int aZpos, double aBiuTo3DUnits )
{
const int slice = SEGM_PER_CIRCLE;
CPOLYGONS_LIST outer_cornerBuffer;
TransformCircleToPolygon( outer_cornerBuffer, aCenterPos,
aRadius + (aThickness / 2), slice );
std::vector<S3D_VERTEX> coords;
coords.resize( 4 );
CPOLYGONS_LIST inner_cornerBuffer;
if( aThickness ) // build the the vertical inner polygon (hole)
TransformCircleToPolygon( inner_cornerBuffer, aCenterPos,
aRadius - (aThickness / 2), slice );
if( aHeight )
{
// Draw the vertical outer side
Draw3D_VerticalPolygonalCylinder( outer_cornerBuffer,
aHeight, aZpos, false, aBiuTo3DUnits );
if( aThickness )
// Draws the vertical inner side (hole)
Draw3D_VerticalPolygonalCylinder( inner_cornerBuffer,
aHeight, aZpos, true, aBiuTo3DUnits );
}
if( aThickness )
{
// draw top (front) and bottom (back) horizontal sides (rings)
SetNormalZpos();
outer_cornerBuffer.Append( inner_cornerBuffer );
CPOLYGONS_LIST polygon;
ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon );
// draw top (front) horizontal ring
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos + aHeight, 0, aBiuTo3DUnits );
if( aHeight )
{
// draw bottom (back) horizontal ring
SetNormalZneg();
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits );
}
}
SetNormalZpos();
}
/*
* Function Draw3D_ZaxisOblongCylinder:
* draw a segment with an oblong hole.
* Used to draw oblong holes
* If aHeight = height of the cylinder is 0, only one ring will be drawn
* If aThickness = 0, only one cylinder will be drawn
*/
void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
int aRadius, int aHeight, int aThickness,
int aZpos, double aBiuTo3DUnits )
{
const int slice = SEGM_PER_CIRCLE;
// Build the points to approximate oblong cylinder by segments
CPOLYGONS_LIST outer_cornerBuffer;
int segm_width = (aRadius * 2) + aThickness;
TransformRoundedEndsSegmentToPolygon( outer_cornerBuffer, aAxis1Pos,
aAxis2Pos, slice, segm_width );
// Draw the oblong outer cylinder
if( aHeight )
Draw3D_VerticalPolygonalCylinder( outer_cornerBuffer, aHeight, aZpos,
false, aBiuTo3DUnits );
if( aThickness )
{
CPOLYGONS_LIST inner_cornerBuffer;
segm_width = aRadius * 2;
TransformRoundedEndsSegmentToPolygon( inner_cornerBuffer, aAxis1Pos,
aAxis2Pos, slice, segm_width );
// Draw the oblong inner cylinder
if( aHeight )
Draw3D_VerticalPolygonalCylinder( inner_cornerBuffer, aHeight,
aZpos, true, aBiuTo3DUnits );
// Build the horizontal full polygon shape
// (outer polygon shape - inner polygon shape)
outer_cornerBuffer.Append( inner_cornerBuffer );
CPOLYGONS_LIST polygon;
ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon );
// draw top (front) horizontal side (ring)
SetNormalZpos();
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos + aHeight, 0, aBiuTo3DUnits );
if( aHeight )
{
// draw bottom (back) horizontal side (ring)
SetNormalZneg();
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits );
}
}
SetNormalZpos();
}
/* draw a thick segment using 3D primitives, in a XY plane
* wxPoint aStart, wxPoint aEnd = YX position of end in board units
* aWidth = width of segment in board units
* aThickness = thickness of segment in board units
* aZpos = z position of segment in board units
*/
void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd,
int aWidth, int aThickness, int aZpos, double aBiuTo3DUnits )
{
CPOLYGONS_LIST cornerBuffer;
const int slice = SEGM_PER_CIRCLE;
TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth );
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits );
}
void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint,
double aArcAngle, int aWidth, int aThickness,
int aZpos, double aBiuTo3DUnits )
{
const int slice = SEGM_PER_CIRCLE;
CPOLYGONS_LIST cornerBuffer;
TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle,
slice, aWidth );
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits );
}
// /////////////////////////////////////////////////////////////////////////////
// GLU_TESS CALLBACKS
// /////////////////////////////////////////////////////////////////////////////
void CALLBACK tessBeginCB( GLenum which )
{
glBegin( which );
}
void CALLBACK tessEndCB()
{
glEnd();
}
void CALLBACK tessCPolyPt2Vertex( const GLvoid* data )
{
// cast back to double type
const CPolyPt* ptr = (const CPolyPt*) data;
glVertex3d( ptr->x * g_Parm_3D_Visu.m_BiuTo3Dunits,
-ptr->y * g_Parm_3D_Visu.m_BiuTo3Dunits,
g_Parm_3D_Visu.m_CurrentZpos );
}
void CALLBACK tessErrorCB( GLenum errorCode )
{
#if defined(DEBUG)
const GLubyte* errorStr;
errorStr = gluErrorString( errorCode );
// DEBUG //
DBG( printf( "Tess ERROR: %s\n", errorStr ); )
#endif
}
+129
View File
@@ -0,0 +1,129 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_draw_basic_functions.h
*/
#ifndef _3D_DRAW_BASIC_FUNCTIONS_H_
#define _3D_DRAW_BASIC_FUNCTIONS_H_
// angle increment to draw a circle, approximated by segments
#define ANGLE_INC( x ) ( 3600 / (x) )
/** draw all solid polygons found in aPolysList
* @param aPolysList = the poligon list to draw
* @param aZpos = z position in board internal units
* @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw the solid polygon found in aPolysList
* The first polygonj is the main polygon, others are holes
* @param aPolysList = the polygon with holes to draw
* @param aZpos = z position in board internal units
* @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits );
/** draw a thick segment using 3D primitives, in a XY plane
* @param aStart = YX position of start point in board units
* @param aEnd = YX position of end point in board units
* @param aWidth = width of segment in board units
* @param aThickness = thickness of segment in board units
* @param aZpos = z position of segment in board units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd,
int aWidth, int aThickness, int aZpos,
double aBiuTo3DUnits );
/** draw an arc using 3D primitives, in a XY plane
* @param aCenterPos = XY position of the center in board units
* @param aStartPoint = start point coordinate of arc in board units
* @param aWidth = width of the circle in board units
* @param aArcAngle = arc angle in 1/10 degrees
* @param aWidth = thickness of arc
* @param aThickness = thickness of segment in board units
* @param aZpos = z position of segment in board units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
*/
void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint,
double aArcAngle, int aWidth, int aThickness,
int aZpos, double aBiuTo3DUnits );
/** draw a thick cylinder (a tube) using 3D primitives.
* the cylinder axis is parallel to the Z axis
* @param aCenterPos = XY position of the axis cylinder ( board internal units)
* @param aRadius = radius of the cylinder ( board internal units)
* @param aHeight = height of the cylinder ( boardinternal units)
* @param aThickness = tichkness of tube ( boardinternal units)
* @param aZpos = Z position of the bottom side of the cylinder ( board internal units)
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
*
* If aHeight = height of the cylinder is 0, only one ring will be drawn
* If aThickness = 0, only one cylinder (not a tube) will be drawn
*/
void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
int aHeight, int aThickness,
int aZpos, double aBiuTo3DUnits );
/** draw an oblong cylinder (oblong tube) using 3D primitives.
* the cylinder axis are parallel to the Z axis
* @param aAxis1Pos = position of the first axis cylinder
* @param aAxis2Pos = position of the second axis cylinder
* @param aRadius = radius of the cylinder ( board internal units )
* @param aHeight = height of the cylinder ( board internal units )
* @param aThickness = tichkness of tube ( board internal units )
* @param aZpos = Z position of the bottom side of the cylinder ( board internal units )
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
*/
void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
int aRadius, int aHeight, int aThickness,
int aZpos, double aBiuTo3DUnits );
/**
* Set the current 3D color from a Kicad color, with optional transparency
* @param aColor = a EDA_COLOR_T kicad color index
* @param aTransparency = the color transparency (default = 1.0 = no transparency)
*/
void SetGLColor( EDA_COLOR_T aColor, double aTransparency = 1.0 );
#endif // _3D_DRAW_BASIC_FUNCTIONS_H_
-77
View File
@@ -1,77 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_enums.h
* @brief declared enumerations and flags
*/
#ifndef _3D_ENUMS_H_
#define _3D_ENUMS_H_
/// Rotation direction for the 3d canvas
enum class ROTATION_DIR
{
X_CW,
X_CCW,
Y_CW,
Y_CCW,
Z_CW,
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
};
/// Render engine mode
enum class RENDER_ENGINE
{
OPENGL = 0,
RAYTRACING = 1,
};
/// 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
};
#endif // _3D_ENUMS_H_
-68
View File
@@ -1,68 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_fastmath.cpp
* @brief
*/
#include "3d_fastmath.h"
// Fast Float Random Numbers
// a small and fast implementation for random float numbers in the range [-1,1]
// References : Posted by dominik.ries[AT]gmail[DOT]com
// http://www.musicdsp.org/showone.php?id=273
// set the initial seed to whatever you like
static int s_randSeed = 1;
// fast rand float, using full 32bit precision
// returns in the range [-1, 1] (not confirmed)
float Fast_RandFloat()
{
s_randSeed *= 16807;
return (float)s_randSeed * 4.6566129e-010f;
}
// Fast rand, as described here:
// http://wiki.osdev.org/Random_Number_Generator
static unsigned long int s_nextRandSeed = 1;
int Fast_rand( void ) // RAND_MAX assumed to be 32767
{
s_nextRandSeed = s_nextRandSeed * 1103515245 + 12345;
return (unsigned int)(s_nextRandSeed >> 16) & 0x7FFF;
}
void Fast_srand( unsigned int seed )
{
s_nextRandSeed = seed;
}
-176
View File
@@ -1,176 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_fastmath.h
* @brief Defines math related functions
*/
#ifndef _3D_FASTMATH_H
#define _3D_FASTMATH_H
#include <cmath>
#include <cstdint>
#include <cstring>
// Define this flag to use fast math optimizations
#define FASTMATH_USE
#define L1_CACHE_LINE_SIZE 64
#ifdef FASTMATH_USE
#define INTFLOORF(s) (lrintf( (s) - (0.5f - FLT_EPSILON) ))
#else
#define INTFLOORF(s) ((int)( floor(s) ))
#endif
// Fast Float Random Numbers
// a small and fast implementation for random float numbers in the range [-1,1]
// This is not thread safe
float Fast_RandFloat();
int Fast_rand( void );
void Fast_srand( unsigned int seed );
/**
* This part contains some functions from the PBRT 3 source code.
* https://github.com/mmp/pbrt-v3/blob/master/src/core/pbrt.h
*/
/*
pbrt source code is Copyright(c) 1998-2015
Matt Pharr, Greg Humphreys, and Wenzel Jakob.
This file is part of pbrt.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Global Inline Functions
inline uint32_t FloatToBits( float f )
{
uint32_t ui;
memcpy( &ui, &f, sizeof( float ) );
return ui;
}
inline float BitsToFloat( uint32_t ui )
{
float f;
memcpy( &f, &ui, sizeof (uint32_t ) );
return f;
}
inline uint64_t FloatToBits( double f )
{
uint64_t ui;
memcpy( &ui, &f, sizeof( double ) );
return ui;
}
inline double BitsToFloat( uint64_t ui )
{
double f;
memcpy( &f, &ui, sizeof( uint64_t ) );
return f;
}
inline float NextFloatUp( float v )
{
// Handle infinity and negative zero for _NextFloatUp()_
if( std::isinf( v ) && (v > 0.) )
return v;
if( v == -0.f )
v = 0.f;
// Advance _v_ to next higher float
uint32_t ui = FloatToBits( v );
if( v >= 0. )
++ui;
else
--ui;
return BitsToFloat( ui );
}
inline float NextFloatDown( float v )
{
// Handle infinity and positive zero for _NextFloatDown()_
if( std::isinf( v ) && (v < 0.) )
return v;
if( v == 0.f )
v = -0.f;
uint32_t ui = FloatToBits( v );
if( v > 0. )
--ui;
else
++ui;
return BitsToFloat( ui );
}
#endif // 3D_FASTMATH_H
+529
View File
@@ -0,0 +1,529 @@
/**
* @file 3d_frame.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <wx/colordlg.h>
#include <3d_viewer_id.h>
#include <wxBasePcbFrame.h>
INFO3D_VISU g_Parm_3D_Visu;
// Key to store 3D Viewer config:
static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
static const wxChar keyShowGridSize[] = wxT( "Grid3DSize" );
static const wxChar keyShowZones[] = wxT( "ShowZones" );
static const wxChar keyShowFootprints[] = wxT( "ShowFootprints" );
static const wxChar keyShowCopperThickness[] = wxT( "ShowCopperThickness" );
static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
static const wxChar keyShowSolderPasteLayers[] =wxT( "ShowSolderPasteLayers" );
static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
BEGIN_EVENT_TABLE( EDA_3D_FRAME, EDA_BASE_FRAME )
EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, EDA_3D_FRAME::Process_Zoom )
EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
EDA_3D_FRAME::Process_Special_Functions )
EVT_TOOL( ID_TOOL_SET_VISIBLE_ITEMS, EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( wxID_EXIT, EDA_3D_FRAME::Exit3DFrame )
EVT_MENU( ID_MENU_SCREENCOPY_PNG, EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_SCREENCOPY_JPEG, EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_MENU3D_GRID, ID_MENU3D_GRID_END,
EDA_3D_FRAME::On3DGridSelection )
EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow )
END_EVENT_TABLE()
EDA_3D_FRAME::EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent,
const wxString& aTitle, long style ) :
KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle,
wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) )
{
m_canvas = NULL;
m_reloadRequest = false;
m_ortho = false;
// Give it an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
SetIcon( icon );
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line
static const int dims[5] = { -1, 100, 100, 100, 140 };
CreateStatusBar( 5 );
SetStatusWidths( 5, dims );
CreateMenuBar();
ReCreateMainToolbar();
// Make a EDA_3D_CANVAS
int attrs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 };
m_canvas = new EDA_3D_CANVAS( this, attrs );
m_auimgr.SetManagedWindow( this );
EDA_PANEINFO horiztb;
horiztb.HorizontalToolbarPane();
m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() );
m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.Update();
// 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();
}
void EDA_3D_FRAME::Exit3DFrame( wxCommandEvent& event )
{
Close( true );
}
void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
if( Parent() )
Parent()->m_Draw3DFrame = NULL;
Destroy();
}
void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
{
EDA_BASE_FRAME::LoadSettings( aCfg );
INFO3D_VISU& prms = g_Parm_3D_Visu;
aCfg->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
aCfg->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
aCfg->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
bool tmp;
aCfg->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
aCfg->Read( keyShowAxis, &tmp, true );
prms.SetFlag( FL_AXIS, tmp );
aCfg->Read( keyShowGrid, &tmp, true );
prms.SetFlag( FL_GRID, tmp );
aCfg->Read( keyShowGridSize, &prms.m_3D_Grid, 10.0 );
prms.SetFlag( FL_MODULE, tmp );
aCfg->Read( keyShowFootprints, &tmp, true );
prms.SetFlag( FL_MODULE, tmp );
aCfg->Read( keyShowCopperThickness, &tmp, false );
prms.SetFlag( FL_USE_COPPER_THICKNESS, tmp );
aCfg->Read( keyShowZones, &tmp, true );
prms.SetFlag( FL_ZONE, tmp );
aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
prms.SetFlag( FL_ADHESIVE, tmp );
aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
prms.SetFlag( FL_SILKSCREEN, tmp );
aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
prms.SetFlag( FL_SOLDERMASK, tmp );
aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
prms.SetFlag( FL_SOLDERPASTE, tmp );
aCfg->Read( keyShowCommentsLayer, &tmp, true );
prms.SetFlag( FL_COMMENTS, tmp );
aCfg->Read( keyShowEcoLayers, &tmp, true );
prms.SetFlag( FL_ECO, tmp );
aCfg->Read( keyShowBoardBody, &tmp, true );
prms.SetFlag( FL_SHOW_BOARD_BODY, tmp );
}
void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
{
EDA_BASE_FRAME::SaveSettings( aCfg );
INFO3D_VISU& prms = g_Parm_3D_Visu;
aCfg->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
aCfg->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
aCfg->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
aCfg->Write( keyShowGrid, prms.GetFlag( FL_GRID ) );
aCfg->Write( keyShowGridSize, prms.m_3D_Grid );
aCfg->Write( keyShowFootprints, prms.GetFlag( FL_MODULE ) );
aCfg->Write( keyShowCopperThickness, prms.GetFlag( FL_USE_COPPER_THICKNESS ) );
aCfg->Write( keyShowZones, prms.GetFlag( FL_ZONE ) );
aCfg->Write( keyShowAdhesiveLayers, prms.GetFlag( FL_ADHESIVE ) );
aCfg->Write( keyShowSilkScreenLayers, prms.GetFlag( FL_SILKSCREEN ) );
aCfg->Write( keyShowSolderMaskLayers, prms.GetFlag( FL_SOLDERMASK ) );
aCfg->Write( keyShowSolderPasteLayers, prms.GetFlag( FL_SOLDERPASTE ) );
aCfg->Write( keyShowCommentsLayer, prms.GetFlag( FL_COMMENTS ) );
aCfg->Write( keyShowEcoLayers, prms.GetFlag( FL_ECO ) );
aCfg->Write( keyShowBoardBody, prms.GetFlag( FL_SHOW_BOARD_BODY ) );
}
void EDA_3D_FRAME::Process_Zoom( wxCommandEvent& event )
{
int ii;
switch( event.GetId() )
{
case ID_ZOOM_PAGE:
for( ii = 0; ii < 4; ii++ )
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
g_Parm_3D_Visu.m_Zoom = 1.0;
m_canvas->SetOffset( 0.0, 0.0 );
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case ID_ZOOM_IN:
g_Parm_3D_Visu.m_Zoom /= 1.2;
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
g_Parm_3D_Visu.m_Zoom = 0.01;
break;
case ID_ZOOM_OUT:
g_Parm_3D_Visu.m_Zoom *= 1.2;
break;
case ID_ZOOM_REDRAW:
break;
default:
return;
}
m_canvas->Refresh( false );
m_canvas->DisplayStatus();
}
void EDA_3D_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
}
void EDA_3D_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
{
}
double EDA_3D_FRAME::BestZoom()
{
return 1.0;
}
void EDA_3D_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
}
void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
#define ROT_ANGLE 10.0
int id = event.GetId();
bool isChecked = event.IsChecked();
switch( id )
{
case ID_TOOL_SET_VISIBLE_ITEMS:
Install_3D_ViewOptionDialog( event );
break;
case ID_RELOAD3D_BOARD:
NewDisplay();
return;
break;
case ID_ROTATE3D_X_POS:
g_Parm_3D_Visu.m_ROTX += ROT_ANGLE;
break;
case ID_ROTATE3D_X_NEG:
g_Parm_3D_Visu.m_ROTX -= ROT_ANGLE;
break;
case ID_ROTATE3D_Y_POS:
g_Parm_3D_Visu.m_ROTY += ROT_ANGLE;
break;
case ID_ROTATE3D_Y_NEG:
g_Parm_3D_Visu.m_ROTY -= ROT_ANGLE;
break;
case ID_ROTATE3D_Z_POS:
g_Parm_3D_Visu.m_ROTZ += ROT_ANGLE;
break;
case ID_ROTATE3D_Z_NEG:
g_Parm_3D_Visu.m_ROTZ -= ROT_ANGLE;
break;
case ID_MOVE3D_LEFT:
m_canvas->SetView3D( WXK_LEFT );
return;
case ID_MOVE3D_RIGHT:
m_canvas->SetView3D( WXK_RIGHT );
return;
case ID_MOVE3D_UP:
m_canvas->SetView3D( WXK_UP );
return;
case ID_MOVE3D_DOWN:
m_canvas->SetView3D( WXK_DOWN );
return;
case ID_ORTHO:
ToggleOrtho();
return;
case ID_TOOL_SCREENCOPY_TOCLIBBOARD:
case ID_MENU_SCREENCOPY_PNG:
case ID_MENU_SCREENCOPY_JPEG:
m_canvas->TakeScreenshot( event );
break;
case ID_MENU3D_BGCOLOR_SELECTION:
Set3DBgColor();
return;
case ID_MENU3D_REALISTIC_MODE:
g_Parm_3D_Visu.SetFlag( FL_USE_REALISTIC_MODE, isChecked );
NewDisplay();
return;
case ID_MENU3D_SHOW_BOARD_BODY:
g_Parm_3D_Visu.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
NewDisplay();
return;
case ID_MENU3D_AXIS_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_AXIS, isChecked );
m_canvas->Refresh();
return;
case ID_MENU3D_MODULE_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_MODULE, isChecked );
m_canvas->Refresh();
return;
case ID_MENU3D_USE_COPPER_THICKNESS:
g_Parm_3D_Visu.SetFlag( FL_USE_COPPER_THICKNESS, isChecked );
NewDisplay(GL_ID_BOARD);
return;
case ID_MENU3D_ZONE_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_ZONE, isChecked );
NewDisplay(GL_ID_BOARD);
return;
case ID_MENU3D_ADHESIVE_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_ADHESIVE, isChecked );
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_SILKSCREEN_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_SILKSCREEN, isChecked );
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_SOLDER_MASK_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_SOLDERMASK, isChecked );
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_SOLDER_PASTE_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_SOLDERPASTE, isChecked );
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_COMMENTS_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_COMMENTS, isChecked );
NewDisplay(GL_ID_AUX_LAYERS);
return;
case ID_MENU3D_ECO_ONOFF:
g_Parm_3D_Visu.SetFlag( FL_ECO, isChecked );
NewDisplay(GL_ID_AUX_LAYERS);
return;
default:
wxLogMessage( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) );
return;
}
m_canvas->Refresh( true );
m_canvas->DisplayStatus();
}
void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event )
{
int id = event.GetId();
for( int ii = ID_MENU3D_GRID; ii < ID_MENU3D_GRID_END; ii++ )
{
if( event.GetId() == ii )
continue;
GetMenuBar()->Check( ii, false );
}
switch( id )
{
case ID_MENU3D_GRID_NOGRID:
g_Parm_3D_Visu.SetFlag( FL_GRID, false );
break;
case ID_MENU3D_GRID_10_MM:
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 10.0;
break;
case ID_MENU3D_GRID_5_MM:
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 5.0;
break;
case ID_MENU3D_GRID_2P5_MM:
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 2.5;
break;
case ID_MENU3D_GRID_1_MM:
g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 1.0;
break;
default:
wxLogMessage( wxT( "EDA_3D_FRAME::On3DGridSelection() error: unknown command" ) );
return;
}
NewDisplay( GL_ID_GRID );
}
void EDA_3D_FRAME::NewDisplay( GLuint aGlList )
{
m_reloadRequest = false;
m_canvas->ClearLists( aGlList );
m_canvas->CreateDrawGL_List();
m_canvas->Refresh( true );
m_canvas->DisplayStatus();
}
void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
{
// Reload data if 3D frame shows a footprint,
// because it can be changed since last frame activation
if( m_reloadRequest )
NewDisplay();
event.Skip(); // required under wxMAC
}
/* called to set the background color of the 3D scene
*/
void EDA_3D_FRAME::Set3DBgColor()
{
S3D_COLOR color;
wxColour newcolor, oldcolor;
oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ),
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
newcolor = wxGetColourFromUser( this, oldcolor );
if( !newcolor.IsOk() ) // Happens on cancel dialog
return;
if( newcolor != oldcolor )
{
g_Parm_3D_Visu.m_BgColor.m_Red = (double) newcolor.Red() / 255.0;
g_Parm_3D_Visu.m_BgColor.m_Green = (double) newcolor.Green() / 255.0;
g_Parm_3D_Visu.m_BgColor.m_Blue = (double) newcolor.Blue() / 255.0;
NewDisplay();
}
}
BOARD* EDA_3D_FRAME::GetBoard()
{
return Parent()->GetBoard();
}
-31
View File
@@ -1,31 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_math.cpp
* @brief
*/
#include "3d_math.h"
-184
View File
@@ -1,184 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_math.h
* @brief Defines math related functions
*/
#ifndef _3D_MATH_H
#define _3D_MATH_H
#include <plugins/3dapi/xv3d_types.h>
#include "3d_fastmath.h"
/**
* https://en.wikipedia.org/wiki/Spherical_coordinate_system
*
* @param aInclination θ ∈ [0, π]
* @param aAzimuth φ ∈ [0, 2π]
* @return Cartesian coordinates
*/
inline SFVEC3F SphericalToCartesian( float aInclination, float aAzimuth )
{
float sinInc = glm::sin( aInclination );
return SFVEC3F( sinInc * glm::cos( aAzimuth ), sinInc * glm::sin( aAzimuth ),
glm::cos( aInclination ) );
}
/**
* @todo This is not correct because it is not a gaussian random.
*/
inline SFVEC3F UniformRandomHemisphereDirection()
{
// It was experienced that this function is slow! do not use it :/
// SFVEC3F b( (rand()/(float)RAND_MAX) - 0.5f,
// (rand()/(float)RAND_MAX) - 0.5f,
// (rand()/(float)RAND_MAX) - 0.5f );
SFVEC3F b( Fast_RandFloat() * 0.5f, Fast_RandFloat() * 0.5f, Fast_RandFloat() * 0.5f );
return b;
}
// https://pathtracing.wordpress.com/2011/03/03/cosine-weighted-hemisphere/
inline SFVEC3F CosWeightedRandomHemisphereDirection( const SFVEC3F& n )
{
const float Xi1 = (float) rand() / (float) RAND_MAX;
const float Xi2 = (float) rand() / (float) RAND_MAX;
const float theta = acos( sqrt( 1.0f - Xi1 ) );
const float phi = 2.0f * glm::pi<float>() * Xi2;
const float xs = sinf( theta ) * cosf( phi );
const float ys = cosf( theta );
const float zs = sinf( theta ) * sinf( phi );
const SFVEC3F y( n.x, n.y, n.z );
SFVEC3F h = y;
if( fabs( h.x ) <= fabs( h.y ) && fabs( h.x ) <= fabs( h.z ) )
h.x= 1.0f;
else if( fabs( h.y ) <= fabs( h.x ) && fabs( h.y ) <= fabs( h.z ) )
h.y= 1.0f;
else
h.z= 1.0f;
const SFVEC3F x = glm::normalize( glm::cross( h, y ) );
const SFVEC3F z = glm::normalize( glm::cross( x, y ) );
SFVEC3F direction = xs * x + ys * y + zs * z;
return glm::normalize( direction );
}
/**
* Based on:
* https://github.com/mmp/pbrt-v3/blob/master/src/core/reflection.h
* See also:
* http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_3_Refractions_and_Beers_Law.shtml
*
* @param aInVector incoming vector.
* @param aNormal normal in the intersection point.
* @param aRin_over_Rout incoming refraction index / out refraction index.
* @param aOutVector the refracted vector.
* @return true
*/
inline bool Refract( const SFVEC3F &aInVector, const SFVEC3F &aNormal, float aRin_over_Rout,
SFVEC3F& aOutVector )
{
float cosThetaI = -glm::dot( aNormal, aInVector );
float sin2ThetaI = glm::max( 0.0f, 1.0f - cosThetaI * cosThetaI );
float sin2ThetaT = aRin_over_Rout * aRin_over_Rout * sin2ThetaI;
// Handle total internal reflection for transmission
if( sin2ThetaT >= 1.0f )
return false;
float cosThetaT = sqrtf( 1.0f - sin2ThetaT );
aOutVector = glm::normalize( aRin_over_Rout * aInVector +
( aRin_over_Rout * cosThetaI - cosThetaT ) *
aNormal );
return true;
}
inline float mapf( float x, float in_min, float in_max, float out_min, float out_max )
{
x = glm::clamp( x, in_min, in_max );
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
inline float RGBtoGray( const SFVEC3F &aColor )
{
return (aColor.r * 0.2126f +
aColor.g * 0.7152f +
aColor.b * 0.0722f);
}
inline SFVEC3F MaterialDiffuseToColorCAD( const SFVEC3F &aDiffuseColor )
{
// convert to a discret scale of grays
const float luminance = glm::min(
( ( (float) ( (unsigned int) ( 4.0f * RGBtoGray( aDiffuseColor ) ) ) + 0.5f ) / 4.0f )
* 1.0f,
1.0f );
const float maxValue = glm::max( glm::max( glm::max( aDiffuseColor.r, aDiffuseColor.g ),
aDiffuseColor.b ), FLT_EPSILON );
return ( aDiffuseColor / SFVEC3F( maxValue ) ) * 0.125f + luminance * 0.875f;
}
// http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiJ4KngqMiIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MCwiZXEiOiItKCh4LTEpXjIpKjIrMSIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MTAwMCwid2luZG93IjpbIi0xLjM4NzUwMDAwMDAwMDAwMDIiLCIxLjg2MjQ5OTk5OTk5OTk5OTgiLCItMC43IiwiMS4zIl19XQ--
inline float QuadricEasingInOut( float t )
{
if( t <= 0.5f )
{
return t * t * 2.0f;
}
else
{
t = t - 1.0f;
return -2.0f * ( t * t ) + 1.0f;
}
}
// http://www.wolframalpha.com/input/?i=t%5E2(3-2t)
inline float BezierBlend( float t )
{
return t * t * ( 3.0f - 2.0f * t );
}
#endif // 3D_MATH_H
@@ -1,481 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Implements a model viewer canvas. The purpose of the model viewer is to render
* 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"
#include "../3d_rendering/opengl/opengl_utils.h"
#include "../3d_cache/3d_cache.h"
#include <wx/dcclient.h>
#include <base_units.h>
#include <gl_context_mgr.h>
#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 )
/**
* 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_3D_MODEL_VIEWER". See the wxWidgets documentation on wxLogTrace for
* more information.
*
* @ingroup trace_env_vars
*/
const wxChar* EDA_3D_MODEL_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_MODEL_VIEWER" );
BEGIN_EVENT_TABLE( EDA_3D_MODEL_VIEWER, wxGLCanvas )
EVT_PAINT( EDA_3D_MODEL_VIEWER::OnPaint )
// mouse events
EVT_LEFT_DOWN( EDA_3D_MODEL_VIEWER::OnLeftDown )
EVT_LEFT_UP( EDA_3D_MODEL_VIEWER::OnLeftUp )
EVT_MIDDLE_UP( EDA_3D_MODEL_VIEWER::OnMiddleUp )
EVT_MIDDLE_DOWN( EDA_3D_MODEL_VIEWER::OnMiddleDown)
EVT_RIGHT_DOWN( EDA_3D_MODEL_VIEWER::OnRightClick )
EVT_MOUSEWHEEL( EDA_3D_MODEL_VIEWER::OnMouseWheel )
EVT_MOTION( EDA_3D_MODEL_VIEWER::OnMouseMove )
#ifdef USE_OSX_MAGNIFY_EVENT
EVT_MAGNIFY( EDA_3D_MODEL_VIEWER::OnMagnify )
#endif
// other events
EVT_ERASE_BACKGROUND( EDA_3D_MODEL_VIEWER::OnEraseBackground )
END_EVENT_TABLE()
// This defines the range that all coord will have to be rendered.
// It will use this value to convert to a normalized value between
// -(RANGE_SCALE_3D/2) .. +(RANGE_SCALE_3D/2)
#define RANGE_SCALE_3D 8.0f
EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList,
S3D_CACHE* aCacheManager ) :
HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE ),
m_trackBallCamera( RANGE_SCALE_3D * 4.0f ),
m_cacheManager( aCacheManager )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER" ) );
m_ogl_initialized = false;
m_reload_is_needed = false;
m_ogl_3dmodel = nullptr;
m_3d_model = nullptr;
m_BiuTo3dUnits = 1.0;
m_glRC = nullptr;
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
const DPI_SCALING dpi{ settings, this };
SetScaleFactor( dpi.GetScaleFactor() );
}
EDA_3D_MODEL_VIEWER::~EDA_3D_MODEL_VIEWER()
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::~EDA_3D_MODEL_VIEWER" ) );
if( m_glRC )
{
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
delete m_ogl_3dmodel;
m_ogl_3dmodel = nullptr;
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glRC );
}
}
void EDA_3D_MODEL_VIEWER::Set3DModel( const S3DMODEL& a3DModel )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::Set3DModel with a S3DMODEL" ) );
// Validate a3DModel pointers
wxASSERT( a3DModel.m_Materials != nullptr );
wxASSERT( a3DModel.m_Meshes != nullptr );
wxASSERT( a3DModel.m_MaterialsSize > 0 );
wxASSERT( a3DModel.m_MeshesSize > 0 );
// Delete the old model
delete m_ogl_3dmodel;
m_ogl_3dmodel = nullptr;
m_3d_model = nullptr;
if( ( a3DModel.m_Materials != nullptr ) && ( a3DModel.m_Meshes != nullptr )
&& ( a3DModel.m_MaterialsSize > 0 ) && ( a3DModel.m_MeshesSize > 0 ) )
{
m_3d_model = &a3DModel;
m_reload_is_needed = true;
}
Refresh();
}
void EDA_3D_MODEL_VIEWER::Set3DModel( const wxString& aModelPathName)
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::Set3DModel with a wxString" ) );
if( m_cacheManager )
{
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName, wxEmptyString );
if( model )
Set3DModel( (const S3DMODEL &)*model );
else
Clear3DModel();
}
}
void EDA_3D_MODEL_VIEWER::Clear3DModel()
{
// Delete the old model
m_reload_is_needed = false;
delete m_ogl_3dmodel;
m_ogl_3dmodel = nullptr;
m_3d_model = nullptr;
Refresh();
}
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 );
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glEnable( GL_DEPTH_TEST );
glEnable( GL_CULL_FACE );
glShadeModel( GL_SMOOTH );
glEnable( GL_LINE_SMOOTH );
glEnable( GL_NORMALIZE );
// Setup light
// https://www.opengl.org/sdk/docs/man2/xhtml/glLight.xml
const GLfloat ambient[] = { 0.01f, 0.01f, 0.01f, 1.0f };
const GLfloat diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
// defines a directional light that points along the negative z-axis
const GLfloat position[] = { 0.0f, 0.0f, 2.0f * RANGE_SCALE_3D, 0.0f };
const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse );
glLightfv( GL_LIGHT0, GL_SPECULAR, specular );
glLightfv( GL_LIGHT0, GL_POSITION, position );
glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
}
void EDA_3D_MODEL_VIEWER::ogl_set_arrow_material()
{
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
const SFVEC4F specular = SFVEC4F( 0.1f, 0.1f, 0.1f, 1.0f );
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
}
void EDA_3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
{
event.Skip( false );
// SwapBuffer requires the window to be shown before calling
if( !IsShownOnScreen() )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::OnPaint !IsShown" ) );
return;
}
// "Makes the OpenGL state that is represented by the OpenGL rendering
// context context current, i.e. it will be used by all subsequent OpenGL calls.
// This function may only be called when the window is shown on screen"
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.
// This is done here rather than in a wxSizeEvent handler because our
// OpenGL rendering context (and thus viewport setting) is used with
// multiple canvases: If we updated the viewport in the wxSizeEvent
// handler, changing the size of one canvas causes a viewport setting that
// is wrong when next another canvas is repainted.
wxSize clientSize = GetNativePixelSize();
if( !m_ogl_initialized )
{
m_ogl_initialized = true;
ogl_initialize();
}
if( m_reload_is_needed )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::OnPaint m_reload_is_needed" ) );
m_reload_is_needed = false;
m_ogl_3dmodel = new MODEL_3D( *m_3d_model, MATERIAL_MODE::NORMAL );
// It convert a model as it was a board, so get the max size dimension of the board
// and compute the conversion scale
m_BiuTo3dUnits =
(double) RANGE_SCALE_3D
/ ( (double) m_ogl_3dmodel->GetBBox().GetMaxDimension() * UNITS3D_TO_UNITSPCB );
}
glViewport( 0, 0, clientSize.x, clientSize.y );
m_trackBallCamera.SetCurWindowSize( clientSize );
// clear color and depth buffers
glEnable( GL_DEPTH_TEST );
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
glClearDepth( 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Set projection and modelview matrices
glMatrixMode( GL_PROJECTION );
glLoadMatrixf( glm::value_ptr( m_trackBallCamera.GetProjectionMatrix() ) );
glMatrixMode( GL_MODELVIEW );
glLoadMatrixf( glm::value_ptr( m_trackBallCamera.GetViewMatrix() ) );
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
// Render Model
if( m_ogl_3dmodel )
{
glPushMatrix();
double modelunit_to_3d_units_factor = m_BiuTo3dUnits * UNITS3D_TO_UNITSPCB;
glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor,
modelunit_to_3d_units_factor );
// Center model in the render viewport
const SFVEC3F model_center = m_ogl_3dmodel->GetBBox().GetCenter();
glTranslatef( -model_center.x, -model_center.y, -model_center.z );
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();
}
// YxY squared view port
glViewport( 0, 0, clientSize.y / 8 , clientSize.y / 8 );
glClear( GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 45.0f, 1.0f, 0.01f, RANGE_SCALE_3D * 2.0f );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
const glm::mat4 TranslationMatrix = glm::translate( glm::mat4(1.0f),
SFVEC3F( 0.0f, 0.0f, -RANGE_SCALE_3D ) );
const glm::mat4 ViewMatrix = TranslationMatrix * m_trackBallCamera.GetRotationMatrix();
glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
ogl_set_arrow_material();
glColor3f( 0.9f, 0.0f, 0.0f );
DrawRoundArrow( SFVEC3F( 0.0f, 0.0f, 0.0f ), SFVEC3F( RANGE_SCALE_3D / 2.65f, 0.0f, 0.0f ),
0.275f );
glColor3f( 0.0f, 0.9f, 0.0f );
DrawRoundArrow( SFVEC3F( 0.0f, 0.0f, 0.0f ), SFVEC3F( 0.0f, RANGE_SCALE_3D / 2.65f, 0.0f ),
0.275f );
glColor3f( 0.0f, 0.0f, 0.9f );
DrawRoundArrow( SFVEC3F( 0.0f, 0.0f, 0.0f ), SFVEC3F( 0.0f, 0.0f, RANGE_SCALE_3D / 2.65f ),
0.275f );
// "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."
SwapBuffers();
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
}
void EDA_3D_MODEL_VIEWER::OnEraseBackground( wxEraseEvent& event )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::OnEraseBackground" ) );
// Do nothing, to avoid flashing.
}
void EDA_3D_MODEL_VIEWER::OnMouseWheel( wxMouseEvent& event )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::OnMouseWheel" ) );
if( event.ShiftDown() )
{
//if( event.GetWheelRotation() < 0 )
//SetView3D( WXK_UP ); // move up
//else
//SetView3D( WXK_DOWN ); // move down
}
else if( event.ControlDown() )
{
//if( event.GetWheelRotation() > 0 )
//SetView3D( WXK_RIGHT ); // move right
//else
//SetView3D( WXK_LEFT ); // move left
}
else
{
m_trackBallCamera.Zoom( event.GetWheelRotation() > 0 ? 1.1f : 1/1.1f );
//DisplayStatus();
Refresh( false );
}
m_trackBallCamera.SetCurMousePosition( event.GetPosition() );
}
#ifdef USE_OSX_MAGNIFY_EVENT
void EDA_3D_MODEL_VIEWER::OnMagnify( wxMouseEvent& event )
{
}
#endif
void EDA_3D_MODEL_VIEWER::OnMouseMove( wxMouseEvent& event )
{
const wxSize& nativeWinSize = GetNativePixelSize();
const wxPoint& nativePosition = GetNativePosition( event.GetPosition() );
m_trackBallCamera.SetCurWindowSize( nativeWinSize );
if( event.Dragging() )
{
if( event.LeftIsDown() ) // Drag
m_trackBallCamera.Drag( nativePosition );
// orientation has changed, redraw mesh
Refresh( false );
}
m_trackBallCamera.SetCurMousePosition( nativePosition );
}
void EDA_3D_MODEL_VIEWER::OnLeftDown( wxMouseEvent& event )
{
event.Skip();
}
void EDA_3D_MODEL_VIEWER::OnLeftUp( wxMouseEvent& event )
{
event.Skip();
}
void EDA_3D_MODEL_VIEWER::OnMiddleDown( wxMouseEvent& event )
{
event.Skip();
}
void EDA_3D_MODEL_VIEWER::OnMiddleUp( wxMouseEvent& event )
{
event.Skip();
}
void EDA_3D_MODEL_VIEWER::OnRightClick( wxMouseEvent& event )
{
event.Skip();
}
@@ -1,141 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file c3d_model_viewer.h
* @brief Implements a model viewer canvas.
*
* The purpose of model viewer is to render 3d models that come in the original data from
* the files without any transformations.
*/
#ifndef _C3D_MODEL_VIEWER_H_
#define _C3D_MODEL_VIEWER_H_
#include "3d_rendering/track_ball.h"
#include <gal/hidpi_gl_canvas.h>
class S3D_CACHE;
class MODEL_3D;
/**
* Implement a canvas based on a wxGLCanvas.
*/
class EDA_3D_MODEL_VIEWER : public HIDPI_GL_CANVAS
{
public:
/**
* Create a new 3D Canvas with a attribute list.
*
* @param aParent the parent creator of this canvas.
* @param aAttribList a list of openGL options created by #OGL_ATT_LIST::GetAttributesList.
*/
EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList = nullptr,
S3D_CACHE* aCacheManager = nullptr );
~EDA_3D_MODEL_VIEWER();
/**
* Set this model to be displayed.
*
* @param a3DModel 3D model data.
*/
void Set3DModel( const S3DMODEL& a3DModel );
/**
* Set this model to be displayed.
*
* @param aModelPathName 3D model path name.
*/
void Set3DModel( const wxString& aModelPathName );
/**
* Unload the displayed 3D model.
*/
void Clear3DModel();
private:
void ogl_initialize();
void ogl_set_arrow_material();
void OnPaint( wxPaintEvent& event );
void OnEraseBackground( wxEraseEvent& event );
void OnMouseWheel( wxMouseEvent& event );
#ifdef USE_OSX_MAGNIFY_EVENT
void OnMagnify( wxMouseEvent& event );
#endif
void OnMouseMove( wxMouseEvent& event );
void OnLeftDown( wxMouseEvent& event );
void OnLeftUp( wxMouseEvent& event );
void OnMiddleUp( wxMouseEvent& event );
void OnMiddleDown( wxMouseEvent& event );
void OnRightClick( wxMouseEvent& event );
DECLARE_EVENT_TABLE()
/// openGL context
wxGLContext* m_glRC;
/// Camera used in this canvas
TRACK_BALL m_trackBallCamera;
/// Original 3d model data
const S3DMODEL* m_3d_model;
/// Class holder for 3d model to display on openGL
MODEL_3D* m_ogl_3dmodel;
/// Flag that we have a new model and it need to be reloaded when the paint is called
bool m_reload_is_needed;
/// Flag if open gl was initialized
bool m_ogl_initialized;
/// factor to convert the model or any other items to keep it in relation to
/// the +/-RANGE_SCALE_3D
/// (it is named same as the board render for better understanding proposes)
double m_BiuTo3dUnits;
/// Optional cache manager
S3D_CACHE* m_cacheManager;
/**
* 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_3D_MODEL_VIEWER". See the wxWidgets documentation on wxLogTrace for
* more information.
*/
static const wxChar* m_logTrace;
};
#endif // _C3D_MODEL_VIEWER_H_
-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_
+132
View File
@@ -0,0 +1,132 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_read_mesh.cpp
*/
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <kicad_string.h>
#include <pgm_base.h>
#include <3d_viewer.h>
#include <info3d_visu.h>
#include "3d_struct.h"
#include "modelparsers.h"
S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster,
const wxString aExtension )
{
if ( aExtension == wxT( "x3d" ) )
{
return new X3D_MODEL_PARSER( aMaster );
}
else if ( aExtension == wxT( "wrl" ) )
{
return new VRML_MODEL_PARSER( aMaster );
}
else
{
return NULL;
}
}
const wxString S3D_MASTER::GetShape3DFullFilename()
{
wxString shapeName;
// Expand any environment variables embedded in footprint's m_Shape3DName field.
// To ensure compatibility with most of footprint's m_Shape3DName field,
// if the m_Shape3DName is not an absolute path the default path
// given by the environment variable KISYS3DMOD will be used
if( m_Shape3DName.StartsWith( wxT("${") ) )
shapeName = wxExpandEnvVars( m_Shape3DName );
else
shapeName = m_Shape3DName;
wxFileName fn( shapeName );
if( fn.IsAbsolute() || shapeName.StartsWith( wxT(".") ) )
return shapeName;
wxString default_path;
wxGetEnv( wxT( KISYS3DMOD ), &default_path );
if( default_path.IsEmpty() )
return shapeName;
if( !default_path.EndsWith( wxT("/") ) && !default_path.EndsWith( wxT("\\") ) )
default_path += wxT("/");
default_path += shapeName;
return default_path;
}
int S3D_MASTER::ReadData()
{
if( m_Shape3DName.IsEmpty() )
return 1;
wxString filename = GetShape3DFullFilename();
#ifdef __WINDOWS__
filename.Replace( wxT( "/" ), wxT( "\\" ) );
#else
filename.Replace( wxT( "\\" ), wxT( "/" ) );
#endif
if( !wxFileName::FileExists( filename ) )
{
wxLogDebug( wxT( "3D shape '%s' not found, even tried '%s' after env var substitution." ),
GetChars( m_Shape3DName ),
GetChars( filename )
);
return -1;
}
wxFileName fn( filename );
wxString extension = fn.GetExt();
S3D_MODEL_PARSER* parser = S3D_MODEL_PARSER::Create( this, extension );
if( parser )
{
parser->Load( filename );
delete parser;
return 0;
}
else
{
wxLogDebug( wxT( "Unknown file type '%s'" ), GetChars( extension ) );
}
return -1;
}
-132
View File
@@ -1,132 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file buffers_debug.cpp
* @brief
*/
#include "buffers_debug.h"
#include <wx/image.h> // Used for save an image to disk
/**
* @param aRGBpixelBuffer from the wxWidgets documentation
* "The data given must have the size (width*height*3).
* The data must have been allocated with malloc(), NOT with operator new."
*/
static void dbg_save_rgb_buffer( const wxString& aFileName, unsigned char *aRGBpixelBuffer,
unsigned int aXSize, unsigned int aYSize )
{
wxImage image( aXSize, aYSize );
image.SetData( aRGBpixelBuffer );
image = image.Mirror( false );
image.SaveFile( aFileName + wxT( ".png" ), wxBITMAP_TYPE_PNG );
image.Destroy();
}
void DBG_SaveBuffer( const wxString& aFileName, const unsigned char *aInBuffer,
unsigned int aXSize, unsigned int aYSize )
{
const unsigned int wxh = aXSize * aYSize;
unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
for( unsigned int i = 0; i < wxh; ++i )
{
unsigned char v = aInBuffer[i];
// Set RGB value with all same values intensities
pixelbuffer[i * 3 + 0] = v;
pixelbuffer[i * 3 + 1] = v;
pixelbuffer[i * 3 + 2] = v;
}
dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
}
void DBG_SaveBuffer( const wxString& aFileName, const float *aInBuffer,
unsigned int aXSize, unsigned int aYSize )
{
const unsigned int wxh = aXSize * aYSize;
unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
for( unsigned int i = 0; i < wxh; ++i )
{
const unsigned char v = (unsigned char)glm::min( (int)(aInBuffer[i] * 255.0f), 255 );
// Set RGB value with all same values intensities
pixelbuffer[i * 3 + 0] = v;
pixelbuffer[i * 3 + 1] = v;
pixelbuffer[i * 3 + 2] = v;
}
dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
}
void DBG_SaveBuffer( const wxString& aFileName, const SFVEC3F *aInBuffer,
unsigned int aXSize, unsigned int aYSize )
{
const unsigned int wxh = aXSize * aYSize;
unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
for( unsigned int i = 0; i < wxh; ++i )
{
const SFVEC3F &v = aInBuffer[i];
const unsigned int ix3 = i * 3;
// Set RGB value with all same values intensities
pixelbuffer[ix3 + 0] = (unsigned char) glm::min( (int) ( v.r * 255.0f ), 255 );
pixelbuffer[ix3 + 1] = (unsigned char) glm::min( (int) ( v.g * 255.0f ), 255 );
pixelbuffer[ix3 + 2] = (unsigned char) glm::min( (int) ( v.b * 255.0f ), 255 );
}
dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
}
void DBG_SaveNormalsBuffer( const wxString& aFileName, const SFVEC3F *aInNormalsBuffer,
unsigned int aXSize, unsigned int aYSize )
{
const unsigned int wxh = aXSize * aYSize;
unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
for( unsigned int i = 0; i < wxh; ++i )
{
const SFVEC3F &v = aInNormalsBuffer[i];
const unsigned int ix3 = i * 3;
// Set RGB value with all same values intensities
pixelbuffer[ix3 + 0] = (unsigned char) glm::min( (int) ( ( v.r + 1.0f ) * 127.0f ), 255 );
pixelbuffer[ix3 + 1] = (unsigned char) glm::min( (int) ( ( v.g + 1.0f ) * 127.0f ), 255 );
pixelbuffer[ix3 + 2] = (unsigned char) glm::min( (int) ( ( v.b + 1.0f ) * 127.0f ), 255 );
}
dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
}
-48
View File
@@ -1,48 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file buffers_debug.h
* @brief
*/
#ifndef BUFFER_DEBUG_H
#define BUFFER_DEBUG_H
#include <plugins/3dapi/xv3d_types.h>
#include <wx/string.h>
void DBG_SaveBuffer( const wxString& aFileName, const unsigned char *aInBuffer,
unsigned int aXSize, unsigned int aYSize );
void DBG_SaveBuffer( const wxString& aFileName, const float *aInBuffer,
unsigned int aXSize, unsigned int aYSize );
void DBG_SaveBuffer( const wxString& aFileName, const SFVEC3F *aInBuffer,
unsigned int aXSize, unsigned int aYSize );
void DBG_SaveNormalsBuffer( const wxString& aFileName, const SFVEC3F *aInNormalsBuffer,
unsigned int aXSize, unsigned int aYSize );
#endif // BUFFER_DEBUG_H
-669
View File
@@ -1,669 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file camera.cpp
*/
#include "camera.h"
#include <wx/log.h>
#include <algorithm>
// A helper function to normalize aAngle between -2PI and +2PI
inline void normalise2PI( float& aAngle )
{
while( aAngle > 0.0 )
aAngle -= static_cast<float>( M_PI * 2.0f );
while( aAngle < 0.0 )
aAngle += static_cast<float>( M_PI * 2.0f );
}
/**
* @ingroup trace_env_vars
*/
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;
CAMERA::CAMERA( float aInitialDistance )
{
wxLogTrace( m_logTrace, wxT( "CAMERA::CAMERA" ) );
m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -aInitialDistance );
m_board_lookat_pos_init = SFVEC3F( 0.0f );
m_windowSize = SFVEC2I( 0, 0 );
m_projectionType = PROJECTION_TYPE::PERSPECTIVE;
m_interpolation_mode = CAMERA_INTERPOLATION::BEZIER;
m_minZoom = DEFAULT_MIN_ZOOM;
m_maxZoom = DEFAULT_MAX_ZOOM;
Reset();
}
void CAMERA::Reset()
{
m_parametersChanged = true;
m_projectionMatrix = glm::mat4( 1.0f );
m_projectionMatrixInv = glm::mat4( 1.0f );
m_rotationMatrix = glm::mat4( 1.0f );
m_rotationMatrixAux = glm::mat4( 1.0f );
m_lastPosition = wxPoint( 0, 0 );
m_zoom = 1.0f;
m_zoom_t0 = 1.0f;
m_zoom_t1 = 1.0f;
m_camera_pos = m_camera_pos_init;
m_camera_pos_t0 = m_camera_pos_init;
m_camera_pos_t1 = m_camera_pos_init;
m_lookat_pos = m_board_lookat_pos_init;
m_lookat_pos_t0 = m_board_lookat_pos_init;
m_lookat_pos_t1 = m_board_lookat_pos_init;
m_rotate_aux = SFVEC3F( 0.0f );
m_rotate_aux_t0 = SFVEC3F( 0.0f );
m_rotate_aux_t1 = SFVEC3F( 0.0f );
updateRotationMatrix();
updateViewMatrix();
m_viewMatrixInverse = glm::inverse( m_viewMatrix );
m_scr_nX.clear();
m_scr_nY.clear();
rebuildProjection();
}
void CAMERA::Reset_T1()
{
m_camera_pos_t1 = m_camera_pos_init;
m_zoom_t1 = 1.0f;
m_rotate_aux_t1 = SFVEC3F( 0.0f );
m_lookat_pos_t1 = m_board_lookat_pos_init;
// Since 0 = 2pi, we want to reset the angle to be the closest
// one to where we currently are. That ensures that we rotate
// the board around the smallest distance getting there.
if( m_rotate_aux_t0.x > M_PI )
m_rotate_aux_t1.x = static_cast<float>( 2.0f * M_PI );
if( m_rotate_aux_t0.y > M_PI )
m_rotate_aux_t1.y = static_cast<float>( 2.0f * M_PI );
if( m_rotate_aux_t0.z > M_PI )
m_rotate_aux_t1.z = static_cast<float>( 2.0f * M_PI );
}
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 )
m_zoom = m_minZoom;
if( m_zoom > m_maxZoom )
m_zoom = m_maxZoom;
m_camera_pos.z = m_camera_pos_init.z * m_zoom;
updateViewMatrix();
rebuildProjection();
}
void CAMERA::updateViewMatrix()
{
m_viewMatrix = glm::translate( glm::mat4( 1.0f ), m_camera_pos ) *
m_rotationMatrix * m_rotationMatrixAux *
glm::translate( glm::mat4( 1.0f ), -m_lookat_pos );
}
void CAMERA::updateRotationMatrix()
{
m_rotationMatrixAux = glm::rotate( glm::mat4( 1.0f ), m_rotate_aux.x,
SFVEC3F( 1.0f, 0.0f, 0.0f ) );
normalise2PI( m_rotate_aux.x );
m_rotationMatrixAux = glm::rotate( m_rotationMatrixAux, m_rotate_aux.y,
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
normalise2PI( m_rotate_aux.y );
m_rotationMatrixAux = glm::rotate( m_rotationMatrixAux, m_rotate_aux.z,
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
normalise2PI( m_rotate_aux.z );
m_parametersChanged = true;
updateViewMatrix();
updateFrustum();
}
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 ) )
return;
m_frustum.ratio = (float) m_windowSize.x / (float)m_windowSize.y;
m_frustum.farD = glm::length( m_camera_pos_init ) * m_maxZoom * 2.0f;
switch( m_projectionType )
{
default:
case PROJECTION_TYPE::PERSPECTIVE:
m_frustum.nearD = 0.10f;
m_frustum.angle = 45.0f;
m_projectionMatrix = glm::perspective( glm::radians( m_frustum.angle ), m_frustum.ratio,
m_frustum.nearD, m_frustum.farD );
m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
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.nw = m_frustum.nh * m_frustum.ratio;
m_frustum.fh = 2.0f * 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;
// Initialize Projection Matrix for Orthographic View
m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
m_frustum.ratio * orthoReductionFactor,
-orthoReductionFactor,
orthoReductionFactor,
m_frustum.nearD, m_frustum.farD );
m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
m_frustum.nw = orthoReductionFactor * 2.0f * m_frustum.ratio;
m_frustum.nh = orthoReductionFactor * 2.0f;
m_frustum.fw = m_frustum.nw;
m_frustum.fh = m_frustum.nh;
break;
}
if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
{
m_scr_nX.resize( m_windowSize.x + 1 );
m_scr_nY.resize( m_windowSize.y + 1 );
// Precalc X values for camera -> ray generation
for( unsigned int x = 0; x < (unsigned int)m_windowSize.x + 1; ++x )
{
// Converts 0.0 .. 1.0
const float xNormalizedDeviceCoordinates = ( ( (float)x + 0.5f ) /
(m_windowSize.x - 0.0f) );
// Converts -1.0 .. 1.0
m_scr_nX[x] = 2.0f * xNormalizedDeviceCoordinates - 1.0f;
}
// Precalc Y values for camera -> ray generation
for( unsigned int y = 0; y < (unsigned int)m_windowSize.y + 1 ; ++y )
{
// Converts 0.0 .. 1.0
const float yNormalizedDeviceCoordinates = ( ( (float)y + 0.5f ) /
(m_windowSize.y - 0.0f) );
// Converts -1.0 .. 1.0
m_scr_nY[y] = 2.0f * yNormalizedDeviceCoordinates - 1.0f;
}
updateFrustum();
}
}
void CAMERA::updateFrustum()
{
// Update matrix and vectors
m_viewMatrixInverse = glm::inverse( m_viewMatrix );
m_right = glm::normalize( SFVEC3F( m_viewMatrixInverse *
glm::vec4( SFVEC3F( 1.0, 0.0, 0.0 ), 0.0 ) ) );
m_up = glm::normalize( SFVEC3F( m_viewMatrixInverse *
glm::vec4( SFVEC3F( 0.0, 1.0, 0.0 ), 0.0 ) ) );
m_dir = glm::normalize( SFVEC3F( m_viewMatrixInverse *
glm::vec4( SFVEC3F( 0.0, 0.0, 1.0 ), 0.0 ) ) );
m_pos = SFVEC3F( m_viewMatrixInverse * glm::vec4( SFVEC3F( 0.0, 0.0, 0.0 ), 1.0 ) );
/*
* Frustum is a implementation based on a tutorial by
* 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;
// 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;
if( ( m_windowSize.x > 0 ) && ( m_windowSize.y > 0 ) )
{
// Reserve size for precalc values
m_right_nX.resize( m_windowSize.x + 1 );
m_up_nY.resize( m_windowSize.y + 1 );
// Precalc X values for camera -> ray generation
for( unsigned int x = 0; x < ( (unsigned int) m_windowSize.x + 1 ); ++x )
m_right_nX[x] = half_right_nw * m_scr_nX[x];
// Precalc Y values for camera -> ray generation
for( unsigned int y = 0; y < ( (unsigned int) m_windowSize.y + 1 ); ++y )
m_up_nY[y] = half_up_nh * m_scr_nY[y];
}
}
void CAMERA::MakeRay( const SFVEC2I& aWindowPos, SFVEC3F& aOutOrigin,
SFVEC3F& aOutDirection ) const
{
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];
switch( m_projectionType )
{
default:
case PROJECTION_TYPE::PERSPECTIVE:
aOutDirection = glm::normalize( aOutOrigin - m_pos );
break;
case PROJECTION_TYPE::ORTHO:
aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
break;
}
}
void CAMERA::MakeRay( const SFVEC2F& aWindowPos, SFVEC3F& aOutOrigin,
SFVEC3F& aOutDirection ) const
{
wxASSERT( aWindowPos.x < (float)m_windowSize.x );
wxASSERT( aWindowPos.y < (float)m_windowSize.y );
const SFVEC2F floorWinPos_f = glm::floor( aWindowPos );
const SFVEC2I floorWinPos_i = (SFVEC2I)floorWinPos_f;
const SFVEC2F relativeWinPos = aWindowPos - floorWinPos_f;
// Note: size of vectors m_up and m_right are m_windowSize + 1
const SFVEC3F up_plus_right = m_up_nY[floorWinPos_i.y] * (1.0f - relativeWinPos.y) +
m_up_nY[floorWinPos_i.y + 1] * relativeWinPos.y +
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:
aOutDirection = glm::normalize( aOutOrigin - m_pos );
break;
case PROJECTION_TYPE::ORTHO:
aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON );
break;
}
}
void CAMERA::MakeRayAtCurrentMousePosition( SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const
{
const SFVEC2I windowPos = SFVEC2I( m_lastPosition.x, m_windowSize.y - m_lastPosition.y );
if( ( 0 < windowPos.x ) && ( windowPos.x < m_windowSize.x ) &&
( 0 < windowPos.y ) && ( windowPos.y < m_windowSize.y ) )
{
MakeRay( windowPos, aOutOrigin, aOutDirection );
}
}
const glm::mat4& CAMERA::GetProjectionMatrix() const
{
return m_projectionMatrix;
}
const glm::mat4& CAMERA::GetProjectionMatrixInv() const
{
return m_projectionMatrixInv;
}
float CAMERA::GetCameraMinDimension() const
{
return -m_camera_pos_init.z * m_frustum.tang;
}
void CAMERA::ResetXYpos()
{
m_parametersChanged = true;
m_camera_pos.x = 0.0f;
m_camera_pos.y = 0.0f;
updateViewMatrix();
updateFrustum();
}
void CAMERA::ResetXYpos_T1()
{
m_camera_pos_t1.x = 0.0f;
m_camera_pos_t1.y = 0.0f;
}
const glm::mat4& CAMERA::GetViewMatrix() const
{
return m_viewMatrix;
}
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;
}
void CAMERA::SetCurMousePosition( const wxPoint& aNewMousePosition )
{
m_lastPosition = aNewMousePosition;
}
void CAMERA::ToggleProjection()
{
if( m_projectionType == PROJECTION_TYPE::ORTHO )
m_projectionType = PROJECTION_TYPE::PERSPECTIVE;
else
m_projectionType = PROJECTION_TYPE::ORTHO;
rebuildProjection();
}
bool CAMERA::SetCurWindowSize( const wxSize& aSize )
{
const SFVEC2I newSize = SFVEC2I( aSize.x, aSize.y );
if( m_windowSize != newSize )
{
m_windowSize = newSize;
rebuildProjection();
return true;
}
return false;
}
void CAMERA::ZoomReset()
{
m_zoom = 1.0f;
m_camera_pos.z = m_camera_pos_init.z;
updateViewMatrix();
rebuildProjection();
}
bool CAMERA::Zoom( float aFactor )
{
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();
return true;
}
bool CAMERA::Zoom_T1( float aFactor )
{
if( ( m_zoom <= m_minZoom && aFactor > 1 ) || ( m_zoom >= m_maxZoom && aFactor < 1 )
|| aFactor == 1 )
{
return false;
}
m_zoom_t1 = m_zoom / aFactor;
if( m_zoom_t1 < m_minZoom )
m_zoom_t1 = m_minZoom;
if( m_zoom_t1 > m_maxZoom )
m_zoom_t1 = m_maxZoom;
m_camera_pos_t1.z = m_camera_pos_init.z * m_zoom_t1;
return true;
}
void CAMERA::RotateX( float aAngleInRadians )
{
m_rotate_aux.x += aAngleInRadians;
updateRotationMatrix();
}
void CAMERA::RotateY( float aAngleInRadians )
{
m_rotate_aux.y += aAngleInRadians;
updateRotationMatrix();
}
void CAMERA::RotateZ( float aAngleInRadians )
{
m_rotate_aux.z += aAngleInRadians;
updateRotationMatrix();
}
void CAMERA::RotateX_T1( float aAngleInRadians )
{
m_rotate_aux_t1.x += aAngleInRadians;
}
void CAMERA::RotateY_T1( float aAngleInRadians )
{
m_rotate_aux_t1.y += aAngleInRadians;
}
void CAMERA::RotateZ_T1( float aAngleInRadians )
{
m_rotate_aux_t1.z += aAngleInRadians;
}
void CAMERA::SetT0_and_T1_current_T()
{
m_camera_pos_t0 = m_camera_pos;
m_lookat_pos_t0 = m_lookat_pos;
m_rotate_aux_t0 = m_rotate_aux;
m_zoom_t0 = m_zoom;
m_camera_pos_t1 = m_camera_pos;
m_lookat_pos_t1 = m_lookat_pos;
m_rotate_aux_t1 = m_rotate_aux;
m_zoom_t1 = m_zoom;
}
void CAMERA::Interpolate( float t )
{
wxASSERT( t >= 0.0f );
const float t0 = 1.0f - t;
m_camera_pos = m_camera_pos_t0 * t0 + m_camera_pos_t1 * t;
m_lookat_pos = m_lookat_pos_t0 * t0 + m_lookat_pos_t1 * t;
m_rotate_aux = m_rotate_aux_t0 * t0 + m_rotate_aux_t1 * t;
m_zoom = m_zoom_t0 * t0 + m_zoom_t1 * t;
m_parametersChanged = true;
updateRotationMatrix();
rebuildProjection();
}
bool CAMERA::ParametersChanged()
{
const bool parametersChanged = m_parametersChanged;
m_parametersChanged = false;
return parametersChanged;
}
-370
View File
@@ -1,370 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file camera.h
* @brief Define an abstract camera.
*/
#ifndef CAMERA_H
#define CAMERA_H
#include "../3d_rendering/raytracing/ray.h"
#include <wx/gdicmn.h> // for wxSize
#include <vector>
enum class PROJECTION_TYPE
{
ORTHO = 0,
PERSPECTIVE
};
/**
* Frustum is a implementation based on a tutorial by
* http://www.lighthouse3d.com/tutorials/view-frustum-culling/
*/
struct CAMERA_FRUSTUM
{
SFVEC3F nc;
SFVEC3F fc;
SFVEC3F ntl; ///< Near Top Left
SFVEC3F ntr; ///< Near Top Right
SFVEC3F nbl; ///< Near Bottom Left
SFVEC3F nbr; ///< Near Bottom Right
SFVEC3F ftl; ///< Far Top Left
SFVEC3F ftr; ///< Far Top Right
SFVEC3F fbl; ///< Far Bottom Left
SFVEC3F fbr; ///< Far Bottom Right
float nearD, farD, ratio, angle, tang;
float nw, nh, fw, fh;
};
enum class CAMERA_INTERPOLATION
{
LINEAR,
EASING_IN_OUT, // Quadratic
BEZIER,
};
/**
* A class used to derive camera objects from.
*
* It must be derived by other classes to implement a real camera object.
*/
class CAMERA
{
public:
static const float DEFAULT_MIN_ZOOM;
static const float DEFAULT_MAX_ZOOM;
/**
* Initialize a camera.
*
* @param aInitialDistance Initial Z-distance to the board
*/
explicit CAMERA( float aInitialDistance );
virtual ~CAMERA()
{
}
/**
* Get the rotation matrix to be applied in a transformation camera.
*
* @return the rotation matrix of the camera
*/
glm::mat4 GetRotationMatrix() const;
const glm::mat4& GetViewMatrix() const;
const glm::mat4& GetViewMatrix_Inv() const;
const glm::mat4& GetProjectionMatrix() const;
const glm::mat4& GetProjectionMatrixInv() const;
const SFVEC3F& GetRight() const { return m_right; }
const SFVEC3F& GetUp() const { return m_up; }
const SFVEC3F& GetDir() const { return m_dir; }
const SFVEC3F& GetPos() const { return m_pos; }
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 );
/**
* 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 );
void SetLookAtPos_T1( const SFVEC3F& aLookAtPos )
{
m_lookat_pos_t1 = aLookAtPos;
}
const SFVEC3F& GetLookAtPos_T1() const { return m_lookat_pos_t1; }
const SFVEC3F& GetCameraPos() const { return m_camera_pos; }
const SFVEC3F& GetCameraInitPos() const { return m_camera_pos_init; }
float GetCameraMinDimension() const;
/**
* Calculate a new mouse drag position
*/
virtual void Drag( const wxPoint& aNewMousePosition ) = 0;
virtual void Pan( const wxPoint& aNewMousePosition ) = 0;
virtual void Pan( const SFVEC3F& aDeltaOffsetInc ) = 0;
virtual void Pan_T1( const SFVEC3F& aDeltaOffsetInc ) = 0;
/**
* Reset the camera to initial state
*/
virtual void Reset();
virtual void Reset_T1();
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.
*/
void SetCurMousePosition( const wxPoint& aPosition );
void ToggleProjection();
PROJECTION_TYPE GetProjection() { return m_projectionType; }
void SetProjection( PROJECTION_TYPE aProjection ) { m_projectionType = aProjection; }
/**
* Update the windows size of the camera.
*
* @return true if the windows size changed since last time.
*/
bool SetCurWindowSize( const wxSize& aSize );
void ZoomReset();
bool Zoom( float aFactor );
bool Zoom_T1( float aFactor );
float GetZoom() const { return m_zoom; }
float GetMinZoom() { return m_minZoom; }
void SetMinZoom( float minZoom )
{
m_minZoom = minZoom;
zoomChanged();
}
float GetMaxZoom() { return m_maxZoom; }
void SetMaxZoom( float maxZoom )
{
m_maxZoom = maxZoom;
zoomChanged();
}
void RotateX( float aAngleInRadians );
void RotateY( float aAngleInRadians );
void RotateZ( float aAngleInRadians );
void RotateX_T1( float aAngleInRadians );
void RotateY_T1( float aAngleInRadians );
void RotateZ_T1( float aAngleInRadians );
/**
* This will set T0 and T1 with the current values.
*/
virtual void SetT0_and_T1_current_T();
/**
* It will update the matrix to interpolate between T0 and T1 values.
*
* @param t the interpolation time, between 0.0f and 1.0f (it will clamp if >1).
*/
virtual void Interpolate( float t );
void SetInterpolateMode( CAMERA_INTERPOLATION aInterpolateMode )
{
m_interpolation_mode = aInterpolateMode;
}
/**
* @return true if some of the parameters in camera was changed, it will reset the flag.
*/
bool ParametersChanged();
/**
* @return true if some of the parameters in camera was changed, it will NOT reset the flag.
*/
bool ParametersChangedQuery() const { return m_parametersChanged; }
/**
* Make a ray based on a windows screen position.
*
* @param aWindowPos the windows buffer position.
* @param aOutOrigin out origin position of the ray.
* @param aOutDirection out direction
*/
void MakeRay( const SFVEC2I& aWindowPos, SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const;
/**
* Make a ray based on a windows screen position, it will interpolate based on the
* \a aWindowPos.
*
* @param aWindowPos the windows buffer position (float value).
* @param aOutOrigin out origin position of the ray.
* @param aOutDirection out direction.
*/
void MakeRay( const SFVEC2F& aWindowPos, SFVEC3F& aOutOrigin, SFVEC3F& aOutDirection ) const;
/**
* Make a ray based on the latest mouse position.
*
* @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(); }
protected:
void zoomChanged();
void rebuildProjection();
void updateFrustum();
void updateViewMatrix();
void updateRotationMatrix();
/**
* 3D zoom value -- Z-distance is scaled by it
*/
float m_zoom;
float m_zoom_t0;
float m_zoom_t1;
/**
* Possible 3D zoom range
*/
float m_minZoom;
float m_maxZoom;
/**
* The window size that this camera is working.
*/
SFVEC2I m_windowSize;
/**
* The last mouse position in the screen
*/
wxPoint m_lastPosition;
glm::mat4 m_rotationMatrix;
glm::mat4 m_rotationMatrixAux;
glm::mat4 m_viewMatrix;
glm::mat4 m_viewMatrixInverse;
glm::mat4 m_projectionMatrix;
glm::mat4 m_projectionMatrixInv;
PROJECTION_TYPE m_projectionType;
CAMERA_FRUSTUM m_frustum;
SFVEC3F m_right;
SFVEC3F m_up;
SFVEC3F m_dir;
SFVEC3F m_pos;
SFVEC2F m_focalLen;
SFVEC3F m_camera_pos_init;
SFVEC3F m_camera_pos;
SFVEC3F m_camera_pos_t0;
SFVEC3F m_camera_pos_t1;
SFVEC3F m_lookat_pos;
SFVEC3F m_lookat_pos_t0;
SFVEC3F m_lookat_pos_t1;
SFVEC3F m_board_lookat_pos_init; ///< Default boardlookat position (the board center).
SFVEC3F m_rotate_aux; ///< Stores the rotation angle auxiliary.
SFVEC3F m_rotate_aux_t0;
SFVEC3F m_rotate_aux_t1;
CAMERA_INTERPOLATION m_interpolation_mode;
/**
* Precalc values array used to calc ray for each pixel (constant for the same window size).
*/
std::vector< float > m_scr_nX;
std::vector< float > m_scr_nY;
/**
* Precalc values array used to calc ray for each pixel, for X and Y axis of each new
* camera position.
*/
std::vector< SFVEC3F > m_right_nX;
std::vector< SFVEC3F > m_up_nY;
/**
* Set to true if any of the parameters in the camera was changed
*/
bool m_parametersChanged;
/**
* 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_CAMERA". See the wxWidgets documentation on wxLogTrace for
* more information.
*/
static const wxChar* m_logTrace;
};
#endif // CAMERA_H
-69
View File
@@ -1,69 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file color_rgb.cpp
*/
#include "color_rgb.h"
COLOR_RGB::COLOR_RGB( const SFVEC3F& aColor )
{
r = (unsigned int) glm::clamp( (int) ( aColor.r * 255 ), 0, 255 );
g = (unsigned int) glm::clamp( (int) ( aColor.g * 255 ), 0, 255 );
b = (unsigned int) glm::clamp( (int) ( aColor.b * 255 ), 0, 255 );
}
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2 )
{
const unsigned int r = aC1.r + aC2.r;
const unsigned int g = aC1.g + aC2.g;
const unsigned int b = aC1.b + aC2.b;
return COLOR_RGB( ( r >> 1 ), ( g >> 1 ), ( b >> 1 ) );
}
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3 )
{
const unsigned int r = aC1.r + aC2.r + aC3.r;
const unsigned int g = aC1.g + aC2.g + aC3.g;
const unsigned int b = aC1.b + aC2.b + aC3.b;
return COLOR_RGB( ( r / 3 ), ( g / 3 ), ( b / 3 ) );
}
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3,
const COLOR_RGB& aC4 )
{
const unsigned int r = aC1.r + aC2.r + aC3.r + aC4.r;
const unsigned int g = aC1.g + aC2.g + aC3.g + aC4.g;
const unsigned int b = aC1.b + aC2.b + aC3.b + aC4.b;
return COLOR_RGB( ( r >> 2 ), ( g >> 2 ), ( b >> 2 ) );
}
-61
View File
@@ -1,61 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file color_rgb.h
*/
#ifndef COLOR_RGB_H
#define COLOR_RGB_H
#include <plugins/3dapi/xv3d_types.h>
union COLOR_RGB
{
unsigned char c[3];
struct
{
unsigned char r;
unsigned char g;
unsigned char b;
};
COLOR_RGB( const SFVEC3F& aColor );
COLOR_RGB() { r = 0; g = 0; b = 0; }
COLOR_RGB( unsigned char aR, unsigned char aG, unsigned char aB )
{
r = aR;
g = aG;
b = aB;
}
};
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2 );
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3 );
COLOR_RGB BlendColor( const COLOR_RGB& aC1, const COLOR_RGB& aC2, const COLOR_RGB& aC3,
const COLOR_RGB& aC4 );
#endif // COLOR_RGB_H
-600
View File
@@ -1,600 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file image.cpp
* @brief one 8bit-channel image implementation.
*/
#include "image.h"
#include "buffers_debug.h"
#include <cstring> // For memcpy
#include <algorithm>
#include <atomic>
#include <thread>
#include <chrono>
#ifndef CLAMP
#define CLAMP( n, min, max ) {if( n < min ) n=min; else if( n > max ) n = max;}
#endif
IMAGE::IMAGE( unsigned int aXsize, unsigned int aYsize )
{
m_wxh = aXsize * aYsize;
m_pixels = new unsigned char[m_wxh];
memset( m_pixels, 0, m_wxh );
m_width = aXsize;
m_height = aYsize;
m_wraping = IMAGE_WRAP::CLAMP;
}
IMAGE::IMAGE( const IMAGE& aSrcImage )
{
m_wxh = aSrcImage.GetWidth() * aSrcImage.GetHeight();
m_pixels = new unsigned char[m_wxh];
memcpy( m_pixels, aSrcImage.GetBuffer(), m_wxh );
m_width = aSrcImage.GetWidth();
m_height = aSrcImage.GetHeight();
m_wraping = IMAGE_WRAP::CLAMP;
}
IMAGE::~IMAGE()
{
delete[] m_pixels;
}
unsigned char* IMAGE::GetBuffer() const
{
return m_pixels;
}
bool IMAGE::wrapCoords( int* aXo, int* aYo ) const
{
int x = *aXo;
int y = *aYo;
switch( m_wraping )
{
case IMAGE_WRAP::CLAMP:
x = ( x < 0 ) ? 0 : x;
x = ( x >= (int) ( m_width - 1 ) ) ? ( m_width - 1 ) : x;
y = ( y < 0 ) ? 0 : y;
y = ( y >= (int) ( m_height - 1 ) ) ? ( m_height - 1 ) : y;
break;
case IMAGE_WRAP::WRAP:
x = ( x < 0 ) ? ( ( m_width - 1 ) + x ) : x;
x = ( x >= (int) ( m_width - 1 ) ) ? ( x - m_width ) : x;
y = ( y < 0 ) ? ( ( m_height - 1 ) + y ) : y;
y = ( y >= (int) ( m_height - 1 ) ) ? ( y - m_height ) : y;
break;
default:
break;
}
if( ( x < 0 ) || ( x >= (int) m_width ) || ( y < 0 ) || ( y >= (int) m_height ) )
return false;
*aXo = x;
*aYo = y;
return true;
}
void IMAGE::plot8CircleLines( int aCx, int aCy, int aX, int aY, unsigned char aValue )
{
Hline( aCx - aX, aCx + aX, aCy + aY, aValue );
Hline( aCx - aX, aCx + aX, aCy - aY, aValue );
Hline( aCx - aY, aCx + aY, aCy + aX, aValue );
Hline( aCx - aY, aCx + aY, aCy - aX, aValue );
}
void IMAGE::Setpixel( int aX, int aY, unsigned char aValue )
{
if( wrapCoords( &aX, &aY ) )
m_pixels[aX + aY * m_width] = aValue;
}
unsigned char IMAGE::Getpixel( int aX, int aY ) const
{
if( wrapCoords( &aX, &aY ) )
return m_pixels[aX + aY * m_width];
else
return 0;
}
void IMAGE::Hline( int aXStart, int aXEnd, int aY, unsigned char aValue )
{
if( ( aY < 0 ) || ( aY >= (int) m_height ) || ( ( aXStart < 0 ) && ( aXEnd < 0 ) )
|| ( ( aXStart >= (int) m_width ) && ( aXEnd >= (int) m_width ) ) )
return;
if( aXStart > aXEnd )
{
int swap = aXStart;
aXStart = aXEnd;
aXEnd = swap;
}
// Clamp line
if( aXStart < 0 )
aXStart = 0;
if( aXEnd >= (int)m_width )
aXEnd = m_width - 1;
unsigned char* pixelPtr = &m_pixels[aXStart + aY * m_width];
unsigned char* pixelPtrEnd = pixelPtr + (unsigned int) ( ( aXEnd - aXStart ) + 1 );
while( pixelPtr < pixelPtrEnd )
{
*pixelPtr = aValue;
pixelPtr++;
}
}
// Based on paper
// http://web.engr.oregonstate.edu/~sllu/bcircle.pdf
void IMAGE::CircleFilled( int aCx, int aCy, int aRadius, unsigned char aValue )
{
int x = aRadius;
int y = 0;
int xChange = 1 - 2 * aRadius;
int yChange = 0;
int radiusError = 0;
while( x >= y )
{
plot8CircleLines( aCx, aCy, x, y, aValue );
y++;
radiusError += yChange;
yChange += 2;
if( ( 2 * radiusError + xChange ) > 0 )
{
x--;
radiusError += xChange;
xChange += 2;
}
}
}
void IMAGE::Invert()
{
for( unsigned int it = 0; it < m_wxh; it++ )
m_pixels[it] = 255 - m_pixels[it];
}
void IMAGE::CopyFull( const IMAGE* aImgA, const IMAGE* aImgB, IMAGE_OP aOperation )
{
int aV, bV;
if( aOperation == IMAGE_OP::RAW )
{
if( aImgA == nullptr )
return;
}
else
{
if( ( aImgA == nullptr ) || ( aImgB == nullptr ) )
return;
}
switch( aOperation )
{
case IMAGE_OP::RAW:
memcpy( m_pixels, aImgA->m_pixels, m_wxh );
break;
case IMAGE_OP::ADD:
for( unsigned int it = 0;it < m_wxh; it++ )
{
aV = aImgA->m_pixels[it];
bV = aImgB->m_pixels[it];
aV = (aV + bV);
aV = (aV > 255)?255:aV;
m_pixels[it] = aV;
}
break;
case IMAGE_OP::SUB:
for( unsigned int it = 0;it < m_wxh; it++ )
{
aV = aImgA->m_pixels[it];
bV = aImgB->m_pixels[it];
aV = (aV - bV);
aV = (aV < 0)?0:aV;
m_pixels[it] = aV;
}
break;
case IMAGE_OP::DIF:
for( unsigned int it = 0;it < m_wxh; it++ )
{
aV = aImgA->m_pixels[it];
bV = aImgB->m_pixels[it];
m_pixels[it] = abs( aV - bV );
}
break;
case IMAGE_OP::MUL:
for( unsigned int it = 0;it < m_wxh; it++ )
{
aV = aImgA->m_pixels[it];
bV = aImgB->m_pixels[it];
m_pixels[it] =
(unsigned char) ( ( ( (float) aV / 255.0f ) * ( (float) bV / 255.0f ) ) * 255 );
}
break;
case IMAGE_OP::AND:
for( unsigned int it = 0;it < m_wxh; it++ )
{
m_pixels[it] = aImgA->m_pixels[it] & aImgB->m_pixels[it];
}
break;
case IMAGE_OP::OR:
for( unsigned int it = 0;it < m_wxh; it++ )
{
m_pixels[it] = aImgA->m_pixels[it] | aImgB->m_pixels[it];
}
break;
case IMAGE_OP::XOR:
for( unsigned int it = 0;it < m_wxh; it++ )
{
m_pixels[it] = aImgA->m_pixels[it] ^ aImgB->m_pixels[it];
}
break;
case IMAGE_OP::BLEND50:
for( unsigned int it = 0;it < m_wxh; it++ )
{
aV = aImgA->m_pixels[it];
bV = aImgB->m_pixels[it];
m_pixels[it] = (aV + bV) / 2;
}
break;
case IMAGE_OP::MIN:
for( unsigned int it = 0;it < m_wxh; it++ )
{
aV = aImgA->m_pixels[it];
bV = aImgB->m_pixels[it];
m_pixels[it] = (aV < bV)?aV:bV;
}
break;
case IMAGE_OP::MAX:
for( unsigned int it = 0;it < m_wxh; it++ )
{
aV = aImgA->m_pixels[it];
bV = aImgB->m_pixels[it];
m_pixels[it] = (aV > bV)?aV:bV;
}
break;
default:
break;
}
}
// TIP: If you want create or test filters you can use GIMP
// with a generic convolution matrix and get the values from there.
// http://docs.gimp.org/nl/plug-in-convmatrix.html
// clang-format off
static const S_FILTER FILTERS[] = {
// IMAGE_FILTER::HIPASS
{
{ { 0, -1, -1, -1, 0},
{-1, 2, -4, 2, -1},
{-1, -4, 13, -4, -1},
{-1, 2, -4, 2, -1},
{ 0, -1, -1, -1, 0}
},
7,
255
},
// IMAGE_FILTER::GAUSSIAN_BLUR
{
{ { 3, 5, 7, 5, 3},
{ 5, 9, 12, 9, 5},
{ 7, 12, 20, 12, 7},
{ 5, 9, 12, 9, 5},
{ 3, 5, 7, 5, 3}
},
182,
0
},
// IMAGE_FILTER::GAUSSIAN_BLUR2
{
{ { 1, 4, 7, 4, 1},
{ 4, 16, 26, 16, 4},
{ 7, 26, 41, 26, 7},
{ 4, 16, 26, 16, 4},
{ 1, 4, 7, 4, 1}
},
273,
0
},
// IMAGE_FILTER::INVERT_BLUR
{
{ { 0, 0, 0, 0, 0},
{ 0, 0, -1, 0, 0},
{ 0, -1, 0, -1, 0},
{ 0, 0, -1, 0, 0},
{ 0, 0, 0, 0, 0}
},
4,
255
},
// IMAGE_FILTER::CARTOON
{
{ {-1, -1, -1, -1, 0},
{-1, 0, 0, 0, 0},
{-1, 0, 4, 0, 0},
{ 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 4}
},
3,
0
},
// IMAGE_FILTER::EMBOSS
{
{ {-1, -1, -1, -1, 0},
{-1, -1, -1, 0, 1},
{-1, -1, 0, 1, 1},
{-1, 0, 1, 1, 1},
{ 0, 1, 1, 1, 1}
},
1,
128
},
// IMAGE_FILTER::SHARPEN
{
{ {-1, -1, -1, -1, -1},
{-1, 2, 2, 2, -1},
{-1, 2, 8, 2, -1},
{-1, 2, 2, 2, -1},
{-1, -1, -1, -1, -1}
},
8,
0
},
// IMAGE_FILTER::MELT
{
{ { 4, 2, 6, 8, 1},
{ 1, 2, 5, 4, 2},
{ 0, -1, 1, -1, 0},
{ 0, 0, -2, 0, 0},
{ 0, 0, 0, 0, 0}
},
32,
0
},
// IMAGE_FILTER::SOBEL_GX
{
{ { 0, 0, 0, 0, 0},
{ 0, -1, 0, 1, 0},
{ 0, -2, 0, 2, 0},
{ 0, -1, 0, 1, 0},
{ 0, 0, 0, 0, 0}
},
1,
0
},
// IMAGE_FILTER::SOBEL_GY
{
{ { 1, 2, 4, 2, 1},
{-1, -1, 0, 1, 1},
{-2, -2, 0, 2, 2},
{-1, -1, 0, 1, 1},
{-1, -2, -4, -2, -1},
},
1,
0
},
// IMAGE_FILTER::BLUR_3X3
{
{ { 0, 0, 0, 0, 0},
{ 0, 1, 2, 1, 0},
{ 0, 2, 4, 2, 0},
{ 0, 1, 2, 1, 0},
{ 0, 0, 0, 0, 0},
},
16,
0
}
};// Filters
// clang-format on
/// @todo: This function can be optimized slipping it between the edges and
/// do it without use the getpixel function.
/// Optimization can be done to m_pixels[ix + iy * m_width]
/// but keep in mind the parallel process of the algorithm
void IMAGE::EfxFilter( IMAGE* aInImg, IMAGE_FILTER aFilterType )
{
S_FILTER filter = FILTERS[static_cast<int>( aFilterType )];
aInImg->m_wraping = IMAGE_WRAP::CLAMP;
m_wraping = IMAGE_WRAP::CLAMP;
std::atomic<size_t> nextRow( 0 );
std::atomic<size_t> threadsFinished( 0 );
size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
for( size_t ii = 0; ii < parallelThreadCount; ++ii )
{
std::thread t = std::thread( [&]()
{
for( size_t iy = nextRow.fetch_add( 1 ); iy < m_height; iy = nextRow.fetch_add( 1 ) )
{
for( size_t ix = 0; ix < m_width; ix++ )
{
int v = 0;
for( size_t sy = 0; sy < 5; sy++ )
{
for( size_t sx = 0; sx < 5; sx++ )
{
int factor = filter.kernel[sx][sy];
unsigned char pixelv = aInImg->Getpixel( ix + sx - 2, iy + sy - 2 );
v += pixelv * factor;
}
}
v /= filter.div;
v += filter.offset;
CLAMP(v, 0, 255);
/// @todo This needs to write to a separate buffer.
m_pixels[ix + iy * m_width] = v;
}
}
threadsFinished++;
} );
t.detach();
}
while( threadsFinished < parallelThreadCount )
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
}
void IMAGE::EfxFilter_SkipCenter( IMAGE* aInImg, IMAGE_FILTER aFilterType, unsigned int aRadius )
{
if( ( !aInImg ) || ( m_width != aInImg->m_width ) || ( m_height != aInImg->m_height ) )
return;
S_FILTER filter = FILTERS[static_cast<int>( aFilterType )];
aInImg->m_wraping = IMAGE_WRAP::ZERO;
const unsigned int radiusSquared = aRadius * aRadius;
const unsigned int xCenter = m_width / 2;
const unsigned int yCenter = m_height / 2;
for( size_t iy = 0; iy < m_height; iy++ )
{
int yc = iy - yCenter;
unsigned int ycsq = yc * yc;
for( size_t ix = 0; ix < m_width; ix++ )
{
int xc = ix - xCenter;
unsigned int xcsq = xc * xc;
if( ( xcsq + ycsq ) < radiusSquared )
{
const unsigned int offset = ix + iy * m_width;
m_pixels[offset] = aInImg->m_pixels[offset];
continue;
}
int v = 0;
for( size_t sy = 0; sy < 5; sy++ )
{
for( size_t sx = 0; sx < 5; sx++ )
{
int factor = filter.kernel[sx][sy];
unsigned char pixelv = aInImg->Getpixel( ix + sx - 2, iy + sy - 2 );
v += pixelv * factor;
}
}
v /= filter.div;
v += filter.offset;
CLAMP(v, 0, 255);
m_pixels[ix + iy * m_width] = v;
}
}
}
void IMAGE::SetPixelsFromNormalizedFloat( const float* aNormalizedFloatArray )
{
for( unsigned int i = 0; i < m_wxh; i++ )
{
int v = aNormalizedFloatArray[i] * 255;
CLAMP( v, 0, 255 );
m_pixels[i] = v;
}
}
void IMAGE::SaveAsPNG( const wxString& aFileName ) const
{
DBG_SaveBuffer( aFileName, m_pixels, m_width, m_height );
}
-235
View File
@@ -1,235 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file image.h
* @brief one 8bit-channel image definition.
*/
#ifndef IMAGE_H
#define IMAGE_H
#include <wx/string.h>
/// Image operation type
enum class IMAGE_OP
{
RAW,
ADD,
SUB,
DIF,
MUL,
AND,
OR,
XOR,
BLEND50,
MIN,
MAX
};
/// Image wrap type enumeration
enum class IMAGE_WRAP
{
ZERO, ///< Coords that wraps are not evaluated
CLAMP, ///< Coords are clamped to image size
WRAP ///< Coords are wrapped around
};
/// Filter type enumeration
enum class IMAGE_FILTER
{
HIPASS,
GAUSSIAN_BLUR,
GAUSSIAN_BLUR2,
INVERT_BLUR,
CARTOON,
EMBOSS,
SHARPEN,
MELT,
SOBEL_GX,
SOBEL_GY,
BLUR_3X3,
};
/// 5x5 Filter struct parameters
struct S_FILTER
{
signed char kernel[5][5];
unsigned int div;
unsigned char offset;
};
/**
* Manage an 8-bit channel image.
*/
class IMAGE
{
public:
/**
* Construct a IMAGE based on image size.
*
* @param aXsize x size
* @param aYsize y size
*/
IMAGE( unsigned int aXsize, unsigned int aYsize );
/**
* Construct a IMAGE based from an existing image.
*
* It will make a copy the \a aSrcImage.
*
* @param aSrcImage
*/
IMAGE( const IMAGE& aSrcImage );
~IMAGE();
/**
* Set a value in a pixel position, position is clamped in accordance with the
* current clamp settings.
*
* @param aX x position
* @param aY y position
* @param aValue value to set the pixel
*/
void Setpixel( int aX, int aY, unsigned char aValue );
/**
* Get the pixel value from pixel position, position is clamped in accord with the
* current clamp settings.
*
* @param aX x position
* @param aY y position
* @return unsigned char - pixel value
*/
unsigned char Getpixel( int aX, int aY ) const;
/**
* Draw a horizontal line.
*
* @param aXStart x start position
* @param aXEnd x end position
* @param aY y position
* @param aValue value to add
*/
void Hline( int aXStart, int aXEnd, int aY, unsigned char aValue );
void CircleFilled( int aCx, int aCy, int aRadius, unsigned char aValue );
/**
* Perform a copy operation based on \a aOperation type.
*
* The available image operations.
* - IMAGE_OP::RAW this <- aImgA
* - IMAGE_OP::ADD this <- CLAMP(aImgA + aImgB)
* - IMAGE_OP::SUB this <- CLAMP(aImgA - aImgB)
* - IMAGE_OP::DIF this <- abs(aImgA - aImgB)
* - IMAGE_OP::MUL this <- aImgA * aImgB
* - IMAGE_OP::AND this <- aImgA & aImgB
* - IMAGE_OP::OR this <- aImgA | aImgB
* - IMAGE_OP::XOR this <- aImgA ^ aImgB
* - IMAGE_OP::BLEND50 this <- (aImgA + aImgB) / 2
* - IMAGE_OP::MIN this <- (aImgA < aImgB) ? aImgA : aImgB
* - IMAGE_OP::MAX this <- (aImgA > aImgB) ? aImgA : aImgB
*
* @param aImgA an image input.
* @param aImgB an image input.
* @param aOperation operation to perform
*/
void CopyFull( const IMAGE* aImgA, const IMAGE* aImgB, IMAGE_OP aOperation );
/**
* Invert the values of this image <- (255 - this)
*/
void Invert();
/**
* Apply a filter to the input image and store it in the image class.
*
* @param aInImg input image
* @param aFilterType filter type to apply
*/
void EfxFilter( IMAGE* aInImg, IMAGE_FILTER aFilterType );
/**
* Apply a filter to the input image and store it in the image class.
* skip the circle center defined by radius
*
* @param aInImg input image
* @param aFilterType filter type to apply
* @param aRadius center circle that the effect will not be applied
*/
void EfxFilter_SkipCenter( IMAGE* aInImg, IMAGE_FILTER aFilterType, unsigned int aRadius );
/**
* Save image buffer to a PNG file into the working folder.
*
* Each RGB channel will have the 8bit-channel from the image.
*
* @param aFileName file name (without extension)
*/
void SaveAsPNG( const wxString& aFileName ) const;
/**
* Set the current channel from a float normalized (0.0 - 1.0) buffer.
*
* this <- CLAMP(NormalizedFloat * 255)
*
* @param aNormalizedFloatArray a float array with the same size of the image
*/
void SetPixelsFromNormalizedFloat( const float* aNormalizedFloatArray );
/**
* Get the image buffer pointer.
*
* @return unsigned char* the pointer of the buffer 8bit channel.
*/
unsigned char* GetBuffer() const;
unsigned int GetWidth() const { return m_width; }
unsigned int GetHeight() const { return m_height; }
private:
/**
* Calculate the coordinates points in accord with the current clamping settings.
*
* @param aXo X coordinate to be converted (output).
* @param aXo Y coordinate to be converted (output).
* @return bool - true if the coordinates are inside the image, false otherwise.
*/
bool wrapCoords( int* aXo, int* aYo ) const;
void plot8CircleLines( int aCx, int aCy, int aX, int aY, unsigned char aValue );
unsigned char* m_pixels; ///< buffer to store the image 8bit-channel
unsigned int m_width; ///< width of the image
unsigned int m_height; ///< height of the image
unsigned int m_wxh; ///< width * height precalc value
IMAGE_WRAP m_wraping; ///< current wrapping type
};
#endif // IMAGE_H
-610
View File
@@ -1,610 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Oleg Endo <olegendo@gcc.gnu.org>
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file c_ogl_3dmodel.cpp
* @brief
*/
#include <algorithm>
#include <stdexcept>
#include <gal/opengl/kiglew.h> // Must be included first
#include "3d_model.h"
#include "../common_ogl/ogl_utils.h"
#include "../3d_math.h"
#include <utility>
#include <wx/debug.h>
#include <wx/log.h>
#include <chrono>
#include <memory>
/*
* Flag to enable connectivity profiling.
*
* @ingroup trace_env_vars
*/
const wxChar* MODEL_3D::m_logTrace = wxT( "KI_TRACE_EDA_OGL_3DMODEL" );
void MODEL_3D::MakeBbox( const BBOX_3D& aBox, unsigned int aIdxOffset, VERTEX* aVtxOut,
GLuint* aIdxOut, const glm::vec4& aColor )
{
aVtxOut[0].m_pos = { aBox.Min().x, aBox.Min().y, aBox.Min().z };
aVtxOut[1].m_pos = { aBox.Max().x, aBox.Min().y, aBox.Min().z };
aVtxOut[2].m_pos = { aBox.Max().x, aBox.Max().y, aBox.Min().z };
aVtxOut[3].m_pos = { aBox.Min().x, aBox.Max().y, aBox.Min().z };
aVtxOut[4].m_pos = { aBox.Min().x, aBox.Min().y, aBox.Max().z };
aVtxOut[5].m_pos = { aBox.Max().x, aBox.Min().y, aBox.Max().z };
aVtxOut[6].m_pos = { aBox.Max().x, aBox.Max().y, aBox.Max().z };
aVtxOut[7].m_pos = { aBox.Min().x, aBox.Max().y, aBox.Max().z };
for( unsigned int i = 0; i < 8; ++i )
aVtxOut[i].m_color = aVtxOut[i].m_cad_color = glm::clamp( aColor * 255.0f, 0.0f, 255.0f );
#define bbox_line( vtx_a, vtx_b )\
do { *aIdxOut++ = vtx_a + aIdxOffset; \
*aIdxOut++ = vtx_b + aIdxOffset; } while( 0 )
bbox_line( 0, 1 );
bbox_line( 1, 2 );
bbox_line( 2, 3 );
bbox_line( 3, 0 );
bbox_line( 4, 5 );
bbox_line( 5, 6 );
bbox_line( 6, 7 );
bbox_line( 7, 4 );
bbox_line( 0, 4 );
bbox_line( 1, 5 );
bbox_line( 2, 6 );
bbox_line( 3, 7 );
#undef bbox_line
}
MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
{
wxLogTrace( m_logTrace, wxT( "MODEL_3D::MODEL_3D %u meshes %u materials" ),
static_cast<unsigned int>( a3DModel.m_MeshesSize ),
static_cast<unsigned int>( a3DModel.m_MaterialsSize ) );
auto start_time = std::chrono::high_resolution_clock::now();
GLuint buffers[8];
/**
* WARNING: Horrible hack here!
* Somehow, buffer values are being shared between pcbnew and the 3d viewer, which then frees
* the buffer, resulting in errors in pcbnew. To resolve this temporarily, we generate
* extra buffers in 3dviewer and use the higher numbers. These are freed on close.
* todo: Correctly separate the OpenGL contexts to prevent overlapping buffer vals
*/
glGenBuffers( 6, buffers );
m_bbox_vertex_buffer = buffers[2];
m_bbox_index_buffer = buffers[3];
m_vertex_buffer = buffers[4];
m_index_buffer = buffers[5];
// Validate a3DModel pointers
wxASSERT( a3DModel.m_Materials != nullptr );
wxASSERT( a3DModel.m_Meshes != nullptr );
wxASSERT( a3DModel.m_MaterialsSize > 0 );
wxASSERT( a3DModel.m_MeshesSize > 0 );
m_materialMode = aMaterialMode;
if( a3DModel.m_Materials == nullptr || a3DModel.m_Meshes == nullptr
|| a3DModel.m_MaterialsSize == 0 || a3DModel.m_MeshesSize == 0 )
return;
// create empty bbox for each mesh. it will be updated when the vertices are copied.
m_meshes_bbox.resize( a3DModel.m_MeshesSize );
// copy materials for later use during rendering.
m_materials.reserve( a3DModel.m_MaterialsSize );
for( unsigned int i = 0; i < a3DModel.m_MaterialsSize; ++i )
m_materials.emplace_back( a3DModel.m_Materials[i] );
// build temporary vertex and index buffers for bounding boxes.
// the first box is the outer box.
std::vector<VERTEX> bbox_tmp_vertices( ( m_meshes_bbox.size() + 1 ) * bbox_vtx_count );
std::vector<GLuint> bbox_tmp_indices( ( m_meshes_bbox.size() + 1 ) * bbox_idx_count );
// group all meshes by material.
// for each material create a combined vertex and index buffer.
// some models might have many sub-meshes. so iterate over the
// input meshes only once.
struct MESH_GROUP
{
std::vector<VERTEX> m_vertices;
std::vector<GLuint> m_indices;
};
std::vector<MESH_GROUP> mesh_groups( m_materials.size() );
for( unsigned int mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i )
{
const SMESH& 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_GROUP& mesh_group = mesh_groups[mesh.m_MaterialIdx];
MATERIAL& material = m_materials[mesh.m_MaterialIdx];
if( material.IsTransparent() && m_materialMode != MATERIAL_MODE::DIFFUSE_ONLY )
m_have_transparent_meshes = true;
else
m_have_opaque_meshes = true;
const unsigned int vtx_offset = mesh_group.m_vertices.size();
mesh_group.m_vertices.resize( mesh_group.m_vertices.size() + mesh.m_VertexSize );
// copy vertex data and update the bounding box.
// 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] );
VERTEX& 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);
if( mesh.m_Color != nullptr )
{
avg_color = ( avg_color + mesh.m_Color[vtx_i] ) * 0.5f;
vtx_out.m_color =
glm::clamp( glm::vec4( mesh.m_Color[vtx_i],
1 - material.m_Transparency ) * 255.0f,
0.0f, 255.0f );
vtx_out.m_cad_color =
glm::clamp( glm::vec4( MaterialDiffuseToColorCAD( mesh.m_Color[vtx_i] ),
1 ) * 255.0f, 0.0f, 255.0f );
}
else
{
// the mesh will be rendered with other meshes that might have
// vertex colors. thus, we can't enable/disable vertex colors
// for individual meshes during rendering.
// if there are no vertex colors, use material color instead.
vtx_out.m_color =
glm::clamp( glm::vec4( material.m_Diffuse,
1 - material.m_Transparency ) * 255.0f,
0.0f, 255.0f );
vtx_out.m_cad_color =
glm::clamp( glm::vec4 ( MaterialDiffuseToColorCAD( material.m_Diffuse ),
1 ) * 255.0f,
0.0f, 255.0f );
}
}
if( mesh_bbox.IsInitialized() )
{
// generate geometry for the bounding box
MakeBbox( mesh_bbox, ( 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 );
}
// append indices of this mesh to the mesh group.
const unsigned int idx_offset = mesh_group.m_indices.size();
unsigned int use_idx_count = mesh.m_FaceIdxSize;
if( use_idx_count % 3 != 0 )
{
wxLogTrace( m_logTrace, wxT( " index count %u not multiple of 3, truncating" ),
static_cast<unsigned int>( use_idx_count ) );
use_idx_count = ( use_idx_count / 3 ) * 3;
}
mesh_group.m_indices.resize( mesh_group.m_indices.size() + use_idx_count );
for( unsigned int idx_i = 0; idx_i < use_idx_count; ++idx_i )
{
if( mesh.m_FaceIdx[idx_i] >= mesh.m_VertexSize )
{
wxLogTrace( m_logTrace, wxT( " index %u out of range (%u)" ),
static_cast<unsigned int>( mesh.m_FaceIdx[idx_i] ),
static_cast<unsigned int>( mesh.m_VertexSize ) );
// FIXME: should skip this triangle
}
mesh_group.m_indices[idx_offset + idx_i] = mesh.m_FaceIdx[idx_i] + vtx_offset;
}
}
// generate geometry for the outer bounding box
if( m_model_bbox.IsInitialized() )
MakeBbox( m_model_bbox, 0, &bbox_tmp_vertices[0], &bbox_tmp_indices[0],
{ 0.0f, 1.0f, 0.0f, 1.0f } );
// create bounding box buffers
glGenBuffers( 1, &m_bbox_vertex_buffer );
glBindBuffer( GL_ARRAY_BUFFER, m_bbox_vertex_buffer );
glBufferData( GL_ARRAY_BUFFER, sizeof( VERTEX ) * bbox_tmp_vertices.size(),
bbox_tmp_vertices.data(), GL_STATIC_DRAW );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_bbox_index_buffer );
if( bbox_tmp_vertices.size() <= std::numeric_limits<GLushort>::max() )
{
m_bbox_index_buffer_type = GL_UNSIGNED_SHORT;
auto u16buf = std::make_unique<GLushort[]>( bbox_tmp_indices.size() );
for( unsigned int i = 0; i < bbox_tmp_indices.size(); ++i )
u16buf[i] = static_cast<GLushort>( bbox_tmp_indices[i] );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( GLushort ) * bbox_tmp_indices.size(),
u16buf.get(), GL_STATIC_DRAW );
}
else
{
m_bbox_index_buffer_type = GL_UNSIGNED_INT;
glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( GLuint ) * bbox_tmp_indices.size(),
bbox_tmp_indices.data(), GL_STATIC_DRAW );
}
// merge the mesh group geometry data.
unsigned int total_vertex_count = 0;
unsigned int total_index_count = 0;
for( const MESH_GROUP& mg : mesh_groups )
{
total_vertex_count += mg.m_vertices.size();
total_index_count += mg.m_indices.size();
}
wxLogTrace( m_logTrace, wxT( " total %u vertices, %u indices" ),
total_vertex_count, total_index_count );
glBindBuffer( GL_ARRAY_BUFFER, m_vertex_buffer );
glBufferData( GL_ARRAY_BUFFER, sizeof( VERTEX ) * total_vertex_count,
nullptr, GL_STATIC_DRAW );
unsigned int idx_size = 0;
if( total_vertex_count <= std::numeric_limits<GLushort>::max() )
{
m_index_buffer_type = GL_UNSIGNED_SHORT;
idx_size = sizeof( GLushort );
}
else
{
m_index_buffer_type = GL_UNSIGNED_INT;
idx_size = sizeof( GLuint );
}
// 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 ) );
unsigned int prev_vtx_count = 0;
unsigned int idx_offset = 0;
unsigned int vtx_offset = 0;
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() );
if( m_index_buffer_type == GL_UNSIGNED_SHORT )
{
GLushort* idx_out = reinterpret_cast<GLushort*>( tmp_idx_ptr + idx_offset );
for( GLuint 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 );
for( GLuint idx : mg.m_indices )
*idx_out++ = static_cast<GLuint>( idx + prev_vtx_count );
}
glBufferSubData( GL_ARRAY_BUFFER, vtx_offset, mg.m_vertices.size() * sizeof( VERTEX ),
mg.m_vertices.data() );
mat.m_render_idx_buffer_offset = idx_offset;
mat.m_render_idx_count = mg.m_indices.size();
prev_vtx_count += mg.m_vertices.size();
idx_offset += mg.m_indices.size() * idx_size;
vtx_offset += mg.m_vertices.size() * sizeof( VERTEX );
}
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_index_buffer );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, idx_size * total_index_count, tmp_idx.get(),
GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
auto end_time = std::chrono::high_resolution_clock::now();
wxLogTrace( m_logTrace, wxT( " loaded in %u ms\n" ),
(unsigned int)std::chrono::duration_cast<std::chrono::milliseconds> (
end_time - start_time).count() );
}
void MODEL_3D::BeginDrawMulti( bool aUseColorInformation )
{
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
if( aUseColorInformation )
{
glEnableClientState( GL_COLOR_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnable( GL_COLOR_MATERIAL );
}
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
}
void MODEL_3D::EndDrawMulti()
{
glDisable( GL_COLOR_MATERIAL );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
}
void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMaterial,
const SFVEC3F& aSelectionColor,
const glm::mat4 *aModelWorldMatrix,
const SFVEC3F *aCameraWorldPos ) const
{
if( aOpacity <= FLT_EPSILON )
return;
if( !glBindBuffer )
throw std::runtime_error( "The OpenGL context no longer exists: unable to draw" );
glBindBuffer( GL_ARRAY_BUFFER, m_vertex_buffer );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_index_buffer );
glVertexPointer( 3, GL_FLOAT, sizeof( VERTEX ),
reinterpret_cast<const void*>( offsetof( VERTEX, m_pos ) ) );
glNormalPointer( GL_BYTE, sizeof( VERTEX ),
reinterpret_cast<const void*>( offsetof( VERTEX, m_nrm ) ) );
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VERTEX ),
reinterpret_cast<const void*>( m_materialMode == MATERIAL_MODE::CAD_MODE
? offsetof( VERTEX, m_cad_color )
: offsetof( VERTEX, m_color ) ) );
glTexCoordPointer( 2, GL_FLOAT, sizeof( VERTEX ),
reinterpret_cast<const void*>( offsetof( VERTEX, m_tex_uv ) ) );
const SFVEC4F param = SFVEC4F( 1.0f, 1.0f, 1.0f, aOpacity );
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 )
{
// 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 )
&& ( 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 )
{
bool aInsideB = a.first->m_bbox.Inside( b.first->m_bbox );
bool bInsideA = b.first->m_bbox.Inside( a.first->m_bbox );
// If A is inside B, then A is rendered first
if( aInsideB != bInsideA )
return bInsideA;
if( a.second != b.second )
return a.second > b.second;
return a.first > b.first; // compare pointers as a last resort
} );
for( const std::pair<const MODEL_3D::MATERIAL*, float>& mat : materialsSorted )
{
materialsToRender.push_back( mat.first );
}
}
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 );
break;
case MATERIAL_MODE::DIFFUSE_ONLY:
OglSetDiffuseMaterial( mat->m_Diffuse, aOpacity, aUseSelectedMaterial, aSelectionColor );
break;
case MATERIAL_MODE::CAD_MODE:
OglSetDiffuseMaterial( MaterialDiffuseToColorCAD( mat->m_Diffuse ), aOpacity,
aUseSelectedMaterial, aSelectionColor );
break;
default:
break;
}
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 ) ) );
}
}
MODEL_3D::~MODEL_3D()
{
if( glDeleteBuffers )
{
glDeleteBuffers( 1, &m_vertex_buffer );
glDeleteBuffers( 1, &m_index_buffer );
glDeleteBuffers( 1, &m_bbox_vertex_buffer );
glDeleteBuffers( 1, &m_bbox_index_buffer );
}
}
void MODEL_3D::DrawBbox() const
{
if( !glBindBuffer )
throw std::runtime_error( "The OpenGL context no longer exists: unable to draw bbox" );
glBindBuffer( GL_ARRAY_BUFFER, m_bbox_vertex_buffer );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_bbox_index_buffer );
glVertexPointer( 3, GL_FLOAT, sizeof( VERTEX ),
reinterpret_cast<const void*>( offsetof( VERTEX, m_pos ) ) );
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VERTEX ),
reinterpret_cast<const void*>( offsetof( VERTEX, m_color ) ) );
glDrawElements( GL_LINES, bbox_idx_count, m_bbox_index_buffer_type,
reinterpret_cast<const void*>( 0 ) );
}
void MODEL_3D::DrawBboxes() const
{
if( !glBindBuffer )
throw std::runtime_error( "The OpenGL context no longer exists: unable to draw bboxes" );
glBindBuffer( GL_ARRAY_BUFFER, m_bbox_vertex_buffer );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_bbox_index_buffer );
glVertexPointer( 3, GL_FLOAT, sizeof( VERTEX ),
reinterpret_cast<const void*>( offsetof( VERTEX, m_pos ) ) );
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VERTEX ),
reinterpret_cast<const void*>( offsetof( VERTEX, m_color ) ) );
unsigned int idx_size = m_bbox_index_buffer_type == GL_UNSIGNED_SHORT ? sizeof( GLushort )
: sizeof( GLuint );
glDrawElements( GL_LINES, bbox_idx_count * m_meshes_bbox.size(), m_bbox_index_buffer_type,
reinterpret_cast<const void*>(
static_cast<uintptr_t>( bbox_idx_count * idx_size ) ) );
}
-176
View File
@@ -1,176 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Oleg Endo <olegendo@gcc.gnu.org>
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _MODEL_3D_H_
#define _MODEL_3D_H_
#include <vector>
#include <plugins/3dapi/c3dmodel.h>
#include "../../common_ogl/openGL_includes.h"
#include "../raytracing/shapes3D/bbox_3d.h"
#include "../../3d_enums.h"
#include <wx/chartype.h>
class MODEL_3D
{
public:
/**
* Load a 3D model.
*
* @note This must be called inside a gl context.
*
* @param a3DModel a 3d model data to load.
* @param aMaterialMode a mode to render the materials of the model.
*/
MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode );
~MODEL_3D();
/**
* Render the model into the current context.
*/
void DrawOpaque( bool aUseSelectedMaterial, SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
{
Draw( false, 1.0f, aUseSelectedMaterial, aSelectionColor, nullptr, nullptr );
}
/**
* Render the model into the current context.
*/
void DrawTransparent( float aOpacity, bool aUseSelectedMaterial,
SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
{
Draw( true, aOpacity, aUseSelectedMaterial, aSelectionColor, nullptr, nullptr );
}
/**
* 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.
*/
bool HasOpaqueMeshes() const { return m_have_opaque_meshes; }
/**
* Return true if have transparent mesh's to render.
*/
bool HasTransparentMeshes() const { return m_have_transparent_meshes; }
/**
* Draw main bounding box of the model.
*/
void DrawBbox() const;
/**
* Draw individual bounding boxes of each mesh.
*/
void DrawBboxes() const;
/**
* Get the main bounding box.
* @return the main model bounding box.
*/
const BBOX_3D& GetBBox() const { return m_model_bbox; }
/**
* Set some basic render states before drawing multiple models.
*/
static void BeginDrawMulti( bool aUseColorInformation );
/**
* Cleanup render states after drawing multiple models.
*/
static void EndDrawMulti();
private:
static const wxChar* m_logTrace;
// the material mode that was used to generate the rendering data.
// FIXME: this can be selected at run-time and does not require re-creation
// of the whole model objects.
MATERIAL_MODE m_materialMode;
BBOX_3D m_model_bbox; ///< global bounding box for this model
std::vector<BBOX_3D> m_meshes_bbox; ///< individual bbox for each mesh
// unified vertex format for mesh rendering.
struct VERTEX
{
glm::vec3 m_pos;
glm::u8vec4 m_nrm; // only 3 components used
glm::u8vec4 m_color; // regular color
glm::u8vec4 m_cad_color; // "CAD" mode rendering color
glm::vec2 m_tex_uv;
};
// vertex buffer and index buffers that include all the individual meshes
// lumped together.
GLuint m_vertex_buffer = 0;
GLuint m_index_buffer = 0;
GLenum m_index_buffer_type = GL_INVALID_ENUM;
// internal material definition
// all meshes are grouped by material for rendering purposes.
struct MATERIAL : SMATERIAL
{
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; }
};
std::vector<MATERIAL> m_materials;
// a model can consist of transparent and opaque parts. remember which
// ones are present during initial buffer and data setup. use it later
// during rendering.
bool m_have_opaque_meshes = false;
bool m_have_transparent_meshes = false;
// vertex buffer and index buffer for the bounding boxes.
// the first box is always the outer box, followed by inner boxes (one for each mesh).
static constexpr unsigned int bbox_vtx_count = 8;
static constexpr unsigned int bbox_idx_count = 24;
GLuint m_bbox_vertex_buffer = 0;
GLuint m_bbox_index_buffer = 0;
GLenum m_bbox_index_buffer_type = GL_INVALID_ENUM;
static void MakeBbox( const BBOX_3D& aBox, unsigned int aIdxOffset, VERTEX* aVtxOut,
GLuint* aIdxOut, const glm::vec4& aColor );
};
#endif // _MODEL_3D_H_
File diff suppressed because it is too large Load Diff

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